utils.go raw

   1  /*
   2  Intelligent DNS API
   3  
   4  No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
   5  
   6  API version: 1.0.0
   7  */
   8  
   9  // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
  10  
  11  package idns
  12  
  13  import (
  14  	"encoding/json"
  15  	"reflect"
  16  	"time"
  17  )
  18  
  19  // PtrBool is a helper routine that returns a pointer to given boolean value.
  20  func PtrBool(v bool) *bool { return &v }
  21  
  22  // PtrInt is a helper routine that returns a pointer to given integer value.
  23  func PtrInt(v int) *int { return &v }
  24  
  25  // PtrInt32 is a helper routine that returns a pointer to given integer value.
  26  func PtrInt32(v int32) *int32 { return &v }
  27  
  28  // PtrInt64 is a helper routine that returns a pointer to given integer value.
  29  func PtrInt64(v int64) *int64 { return &v }
  30  
  31  // PtrFloat32 is a helper routine that returns a pointer to given float value.
  32  func PtrFloat32(v float32) *float32 { return &v }
  33  
  34  // PtrFloat64 is a helper routine that returns a pointer to given float value.
  35  func PtrFloat64(v float64) *float64 { return &v }
  36  
  37  // PtrString is a helper routine that returns a pointer to given string value.
  38  func PtrString(v string) *string { return &v }
  39  
  40  // PtrTime is helper routine that returns a pointer to given Time value.
  41  func PtrTime(v time.Time) *time.Time { return &v }
  42  
  43  type NullableBool struct {
  44  	value *bool
  45  	isSet bool
  46  }
  47  
  48  func (v NullableBool) Get() *bool {
  49  	return v.value
  50  }
  51  
  52  func (v *NullableBool) Set(val *bool) {
  53  	v.value = val
  54  	v.isSet = true
  55  }
  56  
  57  func (v NullableBool) IsSet() bool {
  58  	return v.isSet
  59  }
  60  
  61  func (v *NullableBool) Unset() {
  62  	v.value = nil
  63  	v.isSet = false
  64  }
  65  
  66  func NewNullableBool(val *bool) *NullableBool {
  67  	return &NullableBool{value: val, isSet: true}
  68  }
  69  
  70  func (v NullableBool) MarshalJSON() ([]byte, error) {
  71  	return json.Marshal(v.value)
  72  }
  73  
  74  func (v *NullableBool) UnmarshalJSON(src []byte) error {
  75  	v.isSet = true
  76  	return json.Unmarshal(src, &v.value)
  77  }
  78  
  79  type NullableInt struct {
  80  	value *int
  81  	isSet bool
  82  }
  83  
  84  func (v NullableInt) Get() *int {
  85  	return v.value
  86  }
  87  
  88  func (v *NullableInt) Set(val *int) {
  89  	v.value = val
  90  	v.isSet = true
  91  }
  92  
  93  func (v NullableInt) IsSet() bool {
  94  	return v.isSet
  95  }
  96  
  97  func (v *NullableInt) Unset() {
  98  	v.value = nil
  99  	v.isSet = false
 100  }
 101  
 102  func NewNullableInt(val *int) *NullableInt {
 103  	return &NullableInt{value: val, isSet: true}
 104  }
 105  
 106  func (v NullableInt) MarshalJSON() ([]byte, error) {
 107  	return json.Marshal(v.value)
 108  }
 109  
 110  func (v *NullableInt) UnmarshalJSON(src []byte) error {
 111  	v.isSet = true
 112  	return json.Unmarshal(src, &v.value)
 113  }
 114  
 115  type NullableInt32 struct {
 116  	value *int32
 117  	isSet bool
 118  }
 119  
 120  func (v NullableInt32) Get() *int32 {
 121  	return v.value
 122  }
 123  
 124  func (v *NullableInt32) Set(val *int32) {
 125  	v.value = val
 126  	v.isSet = true
 127  }
 128  
 129  func (v NullableInt32) IsSet() bool {
 130  	return v.isSet
 131  }
 132  
 133  func (v *NullableInt32) Unset() {
 134  	v.value = nil
 135  	v.isSet = false
 136  }
 137  
 138  func NewNullableInt32(val *int32) *NullableInt32 {
 139  	return &NullableInt32{value: val, isSet: true}
 140  }
 141  
 142  func (v NullableInt32) MarshalJSON() ([]byte, error) {
 143  	return json.Marshal(v.value)
 144  }
 145  
 146  func (v *NullableInt32) UnmarshalJSON(src []byte) error {
 147  	v.isSet = true
 148  	return json.Unmarshal(src, &v.value)
 149  }
 150  
 151  type NullableInt64 struct {
 152  	value *int64
 153  	isSet bool
 154  }
 155  
 156  func (v NullableInt64) Get() *int64 {
 157  	return v.value
 158  }
 159  
 160  func (v *NullableInt64) Set(val *int64) {
 161  	v.value = val
 162  	v.isSet = true
 163  }
 164  
 165  func (v NullableInt64) IsSet() bool {
 166  	return v.isSet
 167  }
 168  
 169  func (v *NullableInt64) Unset() {
 170  	v.value = nil
 171  	v.isSet = false
 172  }
 173  
 174  func NewNullableInt64(val *int64) *NullableInt64 {
 175  	return &NullableInt64{value: val, isSet: true}
 176  }
 177  
 178  func (v NullableInt64) MarshalJSON() ([]byte, error) {
 179  	return json.Marshal(v.value)
 180  }
 181  
 182  func (v *NullableInt64) UnmarshalJSON(src []byte) error {
 183  	v.isSet = true
 184  	return json.Unmarshal(src, &v.value)
 185  }
 186  
 187  type NullableFloat32 struct {
 188  	value *float32
 189  	isSet bool
 190  }
 191  
 192  func (v NullableFloat32) Get() *float32 {
 193  	return v.value
 194  }
 195  
 196  func (v *NullableFloat32) Set(val *float32) {
 197  	v.value = val
 198  	v.isSet = true
 199  }
 200  
 201  func (v NullableFloat32) IsSet() bool {
 202  	return v.isSet
 203  }
 204  
 205  func (v *NullableFloat32) Unset() {
 206  	v.value = nil
 207  	v.isSet = false
 208  }
 209  
 210  func NewNullableFloat32(val *float32) *NullableFloat32 {
 211  	return &NullableFloat32{value: val, isSet: true}
 212  }
 213  
 214  func (v NullableFloat32) MarshalJSON() ([]byte, error) {
 215  	return json.Marshal(v.value)
 216  }
 217  
 218  func (v *NullableFloat32) UnmarshalJSON(src []byte) error {
 219  	v.isSet = true
 220  	return json.Unmarshal(src, &v.value)
 221  }
 222  
 223  type NullableFloat64 struct {
 224  	value *float64
 225  	isSet bool
 226  }
 227  
 228  func (v NullableFloat64) Get() *float64 {
 229  	return v.value
 230  }
 231  
 232  func (v *NullableFloat64) Set(val *float64) {
 233  	v.value = val
 234  	v.isSet = true
 235  }
 236  
 237  func (v NullableFloat64) IsSet() bool {
 238  	return v.isSet
 239  }
 240  
 241  func (v *NullableFloat64) Unset() {
 242  	v.value = nil
 243  	v.isSet = false
 244  }
 245  
 246  func NewNullableFloat64(val *float64) *NullableFloat64 {
 247  	return &NullableFloat64{value: val, isSet: true}
 248  }
 249  
 250  func (v NullableFloat64) MarshalJSON() ([]byte, error) {
 251  	return json.Marshal(v.value)
 252  }
 253  
 254  func (v *NullableFloat64) UnmarshalJSON(src []byte) error {
 255  	v.isSet = true
 256  	return json.Unmarshal(src, &v.value)
 257  }
 258  
 259  type NullableString struct {
 260  	value *string
 261  	isSet bool
 262  }
 263  
 264  func (v NullableString) Get() *string {
 265  	return v.value
 266  }
 267  
 268  func (v *NullableString) Set(val *string) {
 269  	v.value = val
 270  	v.isSet = true
 271  }
 272  
 273  func (v NullableString) IsSet() bool {
 274  	return v.isSet
 275  }
 276  
 277  func (v *NullableString) Unset() {
 278  	v.value = nil
 279  	v.isSet = false
 280  }
 281  
 282  func NewNullableString(val *string) *NullableString {
 283  	return &NullableString{value: val, isSet: true}
 284  }
 285  
 286  func (v NullableString) MarshalJSON() ([]byte, error) {
 287  	return json.Marshal(v.value)
 288  }
 289  
 290  func (v *NullableString) UnmarshalJSON(src []byte) error {
 291  	v.isSet = true
 292  	return json.Unmarshal(src, &v.value)
 293  }
 294  
 295  type NullableTime struct {
 296  	value *time.Time
 297  	isSet bool
 298  }
 299  
 300  func (v NullableTime) Get() *time.Time {
 301  	return v.value
 302  }
 303  
 304  func (v *NullableTime) Set(val *time.Time) {
 305  	v.value = val
 306  	v.isSet = true
 307  }
 308  
 309  func (v NullableTime) IsSet() bool {
 310  	return v.isSet
 311  }
 312  
 313  func (v *NullableTime) Unset() {
 314  	v.value = nil
 315  	v.isSet = false
 316  }
 317  
 318  func NewNullableTime(val *time.Time) *NullableTime {
 319  	return &NullableTime{value: val, isSet: true}
 320  }
 321  
 322  func (v NullableTime) MarshalJSON() ([]byte, error) {
 323  	return v.value.MarshalJSON()
 324  }
 325  
 326  func (v *NullableTime) UnmarshalJSON(src []byte) error {
 327  	v.isSet = true
 328  	return json.Unmarshal(src, &v.value)
 329  }
 330  
 331  // IsNil checks if an input is nil
 332  func IsNil(i interface{}) bool {
 333  	if i == nil {
 334  		return true
 335  	}
 336  	switch reflect.TypeOf(i).Kind() {
 337  	case reflect.Chan, reflect.Func, reflect.Map, reflect.Ptr, reflect.UnsafePointer, reflect.Interface, reflect.Slice:
 338  		return reflect.ValueOf(i).IsNil()
 339  	case reflect.Array:
 340  		return reflect.ValueOf(i).IsZero()
 341  	}
 342  	return false
 343  }
 344  
 345  type MappedNullable interface {
 346  	ToMap() (map[string]interface{}, error)
 347  }
 348