bunnyshell.com/sdk@v0.16.0/model_enum_type_item_values_inner.go (about) 1 /* 2 API Bunnyshell Environments 3 4 Interact with Bunnyshell Platform 5 6 API version: 1.1.0 7 Contact: osi+support@bunnyshell.com 8 */ 9 10 // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. 11 12 package sdk 13 14 import ( 15 "encoding/json" 16 "fmt" 17 ) 18 19 // EnumTypeItemValuesInner - struct for EnumTypeItemValuesInner 20 type EnumTypeItemValuesInner struct { 21 BooleanValueItem *BooleanValueItem 22 FloatValueItem *FloatValueItem 23 IntegerValueItem *IntegerValueItem 24 StringValueItem *StringValueItem 25 } 26 27 // BooleanValueItemAsEnumTypeItemValuesInner is a convenience function that returns BooleanValueItem wrapped in EnumTypeItemValuesInner 28 func BooleanValueItemAsEnumTypeItemValuesInner(v *BooleanValueItem) EnumTypeItemValuesInner { 29 return EnumTypeItemValuesInner{ 30 BooleanValueItem: v, 31 } 32 } 33 34 // FloatValueItemAsEnumTypeItemValuesInner is a convenience function that returns FloatValueItem wrapped in EnumTypeItemValuesInner 35 func FloatValueItemAsEnumTypeItemValuesInner(v *FloatValueItem) EnumTypeItemValuesInner { 36 return EnumTypeItemValuesInner{ 37 FloatValueItem: v, 38 } 39 } 40 41 // IntegerValueItemAsEnumTypeItemValuesInner is a convenience function that returns IntegerValueItem wrapped in EnumTypeItemValuesInner 42 func IntegerValueItemAsEnumTypeItemValuesInner(v *IntegerValueItem) EnumTypeItemValuesInner { 43 return EnumTypeItemValuesInner{ 44 IntegerValueItem: v, 45 } 46 } 47 48 // StringValueItemAsEnumTypeItemValuesInner is a convenience function that returns StringValueItem wrapped in EnumTypeItemValuesInner 49 func StringValueItemAsEnumTypeItemValuesInner(v *StringValueItem) EnumTypeItemValuesInner { 50 return EnumTypeItemValuesInner{ 51 StringValueItem: v, 52 } 53 } 54 55 // Unmarshal JSON data into one of the pointers in the struct 56 func (dst *EnumTypeItemValuesInner) UnmarshalJSON(data []byte) error { 57 var err error 58 // use discriminator value to speed up the lookup 59 var jsonDict map[string]interface{} 60 err = newStrictDecoder(data).Decode(&jsonDict) 61 if err != nil { 62 return fmt.Errorf("failed to unmarshal JSON into map for the discriminator lookup") 63 } 64 65 // check if the discriminator value is 'BooleanValue-item' 66 if jsonDict["type"] == "BooleanValue-item" { 67 // try to unmarshal JSON data into BooleanValueItem 68 err = json.Unmarshal(data, &dst.BooleanValueItem) 69 if err == nil { 70 return nil // data stored in dst.BooleanValueItem, return on the first match 71 } else { 72 dst.BooleanValueItem = nil 73 return fmt.Errorf("failed to unmarshal EnumTypeItemValuesInner as BooleanValueItem: %s", err.Error()) 74 } 75 } 76 77 // check if the discriminator value is 'FloatValue-item' 78 if jsonDict["type"] == "FloatValue-item" { 79 // try to unmarshal JSON data into FloatValueItem 80 err = json.Unmarshal(data, &dst.FloatValueItem) 81 if err == nil { 82 return nil // data stored in dst.FloatValueItem, return on the first match 83 } else { 84 dst.FloatValueItem = nil 85 return fmt.Errorf("failed to unmarshal EnumTypeItemValuesInner as FloatValueItem: %s", err.Error()) 86 } 87 } 88 89 // check if the discriminator value is 'IntegerValue-item' 90 if jsonDict["type"] == "IntegerValue-item" { 91 // try to unmarshal JSON data into IntegerValueItem 92 err = json.Unmarshal(data, &dst.IntegerValueItem) 93 if err == nil { 94 return nil // data stored in dst.IntegerValueItem, return on the first match 95 } else { 96 dst.IntegerValueItem = nil 97 return fmt.Errorf("failed to unmarshal EnumTypeItemValuesInner as IntegerValueItem: %s", err.Error()) 98 } 99 } 100 101 // check if the discriminator value is 'StringValue-item' 102 if jsonDict["type"] == "StringValue-item" { 103 // try to unmarshal JSON data into StringValueItem 104 err = json.Unmarshal(data, &dst.StringValueItem) 105 if err == nil { 106 return nil // data stored in dst.StringValueItem, return on the first match 107 } else { 108 dst.StringValueItem = nil 109 return fmt.Errorf("failed to unmarshal EnumTypeItemValuesInner as StringValueItem: %s", err.Error()) 110 } 111 } 112 113 // check if the discriminator value is 'bool' 114 if jsonDict["type"] == "bool" { 115 // try to unmarshal JSON data into BooleanValueItem 116 err = json.Unmarshal(data, &dst.BooleanValueItem) 117 if err == nil { 118 return nil // data stored in dst.BooleanValueItem, return on the first match 119 } else { 120 dst.BooleanValueItem = nil 121 return fmt.Errorf("failed to unmarshal EnumTypeItemValuesInner as BooleanValueItem: %s", err.Error()) 122 } 123 } 124 125 // check if the discriminator value is 'float' 126 if jsonDict["type"] == "float" { 127 // try to unmarshal JSON data into FloatValueItem 128 err = json.Unmarshal(data, &dst.FloatValueItem) 129 if err == nil { 130 return nil // data stored in dst.FloatValueItem, return on the first match 131 } else { 132 dst.FloatValueItem = nil 133 return fmt.Errorf("failed to unmarshal EnumTypeItemValuesInner as FloatValueItem: %s", err.Error()) 134 } 135 } 136 137 // check if the discriminator value is 'int' 138 if jsonDict["type"] == "int" { 139 // try to unmarshal JSON data into IntegerValueItem 140 err = json.Unmarshal(data, &dst.IntegerValueItem) 141 if err == nil { 142 return nil // data stored in dst.IntegerValueItem, return on the first match 143 } else { 144 dst.IntegerValueItem = nil 145 return fmt.Errorf("failed to unmarshal EnumTypeItemValuesInner as IntegerValueItem: %s", err.Error()) 146 } 147 } 148 149 // check if the discriminator value is 'string' 150 if jsonDict["type"] == "string" { 151 // try to unmarshal JSON data into StringValueItem 152 err = json.Unmarshal(data, &dst.StringValueItem) 153 if err == nil { 154 return nil // data stored in dst.StringValueItem, return on the first match 155 } else { 156 dst.StringValueItem = nil 157 return fmt.Errorf("failed to unmarshal EnumTypeItemValuesInner as StringValueItem: %s", err.Error()) 158 } 159 } 160 161 return nil 162 } 163 164 // Marshal data from the first non-nil pointers in the struct to JSON 165 func (src EnumTypeItemValuesInner) MarshalJSON() ([]byte, error) { 166 if src.BooleanValueItem != nil { 167 return json.Marshal(&src.BooleanValueItem) 168 } 169 170 if src.FloatValueItem != nil { 171 return json.Marshal(&src.FloatValueItem) 172 } 173 174 if src.IntegerValueItem != nil { 175 return json.Marshal(&src.IntegerValueItem) 176 } 177 178 if src.StringValueItem != nil { 179 return json.Marshal(&src.StringValueItem) 180 } 181 182 return nil, nil // no data in oneOf schemas 183 } 184 185 // Get the actual instance 186 func (obj *EnumTypeItemValuesInner) GetActualInstance() interface{} { 187 if obj == nil { 188 return nil 189 } 190 if obj.BooleanValueItem != nil { 191 return obj.BooleanValueItem 192 } 193 194 if obj.FloatValueItem != nil { 195 return obj.FloatValueItem 196 } 197 198 if obj.IntegerValueItem != nil { 199 return obj.IntegerValueItem 200 } 201 202 if obj.StringValueItem != nil { 203 return obj.StringValueItem 204 } 205 206 // all schemas are nil 207 return nil 208 } 209 210 type NullableEnumTypeItemValuesInner struct { 211 value *EnumTypeItemValuesInner 212 isSet bool 213 } 214 215 func (v NullableEnumTypeItemValuesInner) Get() *EnumTypeItemValuesInner { 216 return v.value 217 } 218 219 func (v *NullableEnumTypeItemValuesInner) Set(val *EnumTypeItemValuesInner) { 220 v.value = val 221 v.isSet = true 222 } 223 224 func (v NullableEnumTypeItemValuesInner) IsSet() bool { 225 return v.isSet 226 } 227 228 func (v *NullableEnumTypeItemValuesInner) Unset() { 229 v.value = nil 230 v.isSet = false 231 } 232 233 func NewNullableEnumTypeItemValuesInner(val *EnumTypeItemValuesInner) *NullableEnumTypeItemValuesInner { 234 return &NullableEnumTypeItemValuesInner{value: val, isSet: true} 235 } 236 237 func (v NullableEnumTypeItemValuesInner) MarshalJSON() ([]byte, error) { 238 return json.Marshal(v.value) 239 } 240 241 func (v *NullableEnumTypeItemValuesInner) UnmarshalJSON(src []byte) error { 242 v.isSet = true 243 return json.Unmarshal(src, &v.value) 244 }