/*
Merlin

API Guide for accessing Merlin's model management, deployment, and serving functionalities

API version: 0.14.0
*/

// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.

package client

import (
	"encoding/json"
	"fmt"
)

// ResultType the model 'ResultType'
type ResultType string

// List of ResultType
const (
	RESULTTYPE_DOUBLE  ResultType = "DOUBLE"
	RESULTTYPE_FLOAT   ResultType = "FLOAT"
	RESULTTYPE_INTEGER ResultType = "INTEGER"
	RESULTTYPE_LONG    ResultType = "LONG"
	RESULTTYPE_STRING  ResultType = "STRING"
	RESULTTYPE_ARRAY   ResultType = "ARRAY"
)

// All allowed values of ResultType enum
var AllowedResultTypeEnumValues = []ResultType{
	"DOUBLE",
	"FLOAT",
	"INTEGER",
	"LONG",
	"STRING",
	"ARRAY",
}

func (v *ResultType) UnmarshalJSON(src []byte) error {
	var value string
	err := json.Unmarshal(src, &value)
	if err != nil {
		return err
	}
	enumTypeValue := ResultType(value)
	for _, existing := range AllowedResultTypeEnumValues {
		if existing == enumTypeValue {
			*v = enumTypeValue
			return nil
		}
	}

	return fmt.Errorf("%+v is not a valid ResultType", value)
}

// NewResultTypeFromValue returns a pointer to a valid ResultType
// for the value passed as argument, or an error if the value passed is not allowed by the enum
func NewResultTypeFromValue(v string) (*ResultType, error) {
	ev := ResultType(v)
	if ev.IsValid() {
		return &ev, nil
	} else {
		return nil, fmt.Errorf("invalid value '%v' for ResultType: valid values are %v", v, AllowedResultTypeEnumValues)
	}
}

// IsValid return true if the value is valid for the enum, false otherwise
func (v ResultType) IsValid() bool {
	for _, existing := range AllowedResultTypeEnumValues {
		if existing == v {
			return true
		}
	}
	return false
}

// Ptr returns reference to ResultType value
func (v ResultType) Ptr() *ResultType {
	return &v
}

type NullableResultType struct {
	value *ResultType
	isSet bool
}

func (v NullableResultType) Get() *ResultType {
	return v.value
}

func (v *NullableResultType) Set(val *ResultType) {
	v.value = val
	v.isSet = true
}

func (v NullableResultType) IsSet() bool {
	return v.isSet
}

func (v *NullableResultType) Unset() {
	v.value = nil
	v.isSet = false
}

func NewNullableResultType(val *ResultType) *NullableResultType {
	return &NullableResultType{value: val, isSet: true}
}

func (v NullableResultType) MarshalJSON() ([]byte, error) {
	return json.Marshal(v.value)
}

func (v *NullableResultType) UnmarshalJSON(src []byte) error {
	v.isSet = true
	return json.Unmarshal(src, &v.value)
}
