/*
 * Redfish OAPI specification
 *
 * Partial Redfish OAPI specification for a limited client
 *
 * API version: 0.0.1
 */

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

package client

import (
	"encoding/json"
	"fmt"
)

// State the model 'State'
type State string

// List of State
const (
	STATE_ENABLED State = "Enabled"
	STATE_DISABLED State = "Disabled"
	STATE_STANDBY_OFFLINE State = "StandbyOffline"
	STATE_STANDBY_SPARE State = "StandbySpare"
	STATE_IN_TEST State = "InTest"
	STATE_STARTING State = "Starting"
	STATE_ABSENT State = "Absent"
	STATE_UNAVAILABLE_OFFLINE State = "UnavailableOffline"
	STATE_DEFERRING State = "Deferring"
	STATE_QUIESCED State = "Quiesced"
	STATE_UPDATING State = "Updating"
)

func (v *State) UnmarshalJSON(src []byte) error {
	var value string
	err := json.Unmarshal(src, &value)
	if err != nil {
		return err
	}
	enumTypeValue := State(value)
	for _, existing := range []State{ "Enabled", "Disabled", "StandbyOffline", "StandbySpare", "InTest", "Starting", "Absent", "UnavailableOffline", "Deferring", "Quiesced", "Updating",   } {
		if existing == enumTypeValue {
			*v = enumTypeValue
			return nil
		}
	}

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

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

type NullableState struct {
	value *State
	isSet bool
}

func (v NullableState) Get() *State {
	return v.value
}

func (v *NullableState) Set(val *State) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableState(val *State) *NullableState {
	return &NullableState{value: val, isSet: true}
}

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

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