/*
Network Lists API

No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)

API version: 1.0.0
*/

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

package networklist

import (
	"encoding/json"
	"fmt"
)

// NetworkListUuidResponseEntry - struct for NetworkListUuidResponseEntry
type NetworkListUuidResponseEntry struct {
	NetworkListUuidResponseEntryInt *NetworkListUuidResponseEntryInt
	NetworkListUuidResponseEntryString *NetworkListUuidResponseEntryString
}

// NetworkListUuidResponseEntryIntAsNetworkListUuidResponseEntry is a convenience function that returns NetworkListUuidResponseEntryInt wrapped in NetworkListUuidResponseEntry
func NetworkListUuidResponseEntryIntAsNetworkListUuidResponseEntry(v *NetworkListUuidResponseEntryInt) NetworkListUuidResponseEntry {
	return NetworkListUuidResponseEntry{
		NetworkListUuidResponseEntryInt: v,
	}
}

// NetworkListUuidResponseEntryStringAsNetworkListUuidResponseEntry is a convenience function that returns NetworkListUuidResponseEntryString wrapped in NetworkListUuidResponseEntry
func NetworkListUuidResponseEntryStringAsNetworkListUuidResponseEntry(v *NetworkListUuidResponseEntryString) NetworkListUuidResponseEntry {
	return NetworkListUuidResponseEntry{
		NetworkListUuidResponseEntryString: v,
	}
}


// Unmarshal JSON data into one of the pointers in the struct
func (dst *NetworkListUuidResponseEntry) UnmarshalJSON(data []byte) error {
	var err error
	match := 0
	// try to unmarshal data into NetworkListUuidResponseEntryInt
	err = newStrictDecoder(data).Decode(&dst.NetworkListUuidResponseEntryInt)
	if err == nil {
		jsonNetworkListUuidResponseEntryInt, _ := json.Marshal(dst.NetworkListUuidResponseEntryInt)
		if string(jsonNetworkListUuidResponseEntryInt) == "{}" { // empty struct
			dst.NetworkListUuidResponseEntryInt = nil
		} else {
			match++
		}
	} else {
		dst.NetworkListUuidResponseEntryInt = nil
	}

	// try to unmarshal data into NetworkListUuidResponseEntryString
	err = newStrictDecoder(data).Decode(&dst.NetworkListUuidResponseEntryString)
	if err == nil {
		jsonNetworkListUuidResponseEntryString, _ := json.Marshal(dst.NetworkListUuidResponseEntryString)
		if string(jsonNetworkListUuidResponseEntryString) == "{}" { // empty struct
			dst.NetworkListUuidResponseEntryString = nil
		} else {
			match++
		}
	} else {
		dst.NetworkListUuidResponseEntryString = nil
	}

	if match > 1 { // more than 1 match
		// reset to nil
		dst.NetworkListUuidResponseEntryInt = nil
		dst.NetworkListUuidResponseEntryString = nil

		return fmt.Errorf("data matches more than one schema in oneOf(NetworkListUuidResponseEntry)")
	} else if match == 1 {
		return nil // exactly one match
	} else { // no match
		return fmt.Errorf("data failed to match schemas in oneOf(NetworkListUuidResponseEntry)")
	}
}

// Marshal data from the first non-nil pointers in the struct to JSON
func (src NetworkListUuidResponseEntry) MarshalJSON() ([]byte, error) {
	if src.NetworkListUuidResponseEntryInt != nil {
		return json.Marshal(&src.NetworkListUuidResponseEntryInt)
	}

	if src.NetworkListUuidResponseEntryString != nil {
		return json.Marshal(&src.NetworkListUuidResponseEntryString)
	}

	return nil, nil // no data in oneOf schemas
}

// Get the actual instance
func (obj *NetworkListUuidResponseEntry) GetActualInstance() (interface{}) {
	if obj == nil {
		return nil
	}
	if obj.NetworkListUuidResponseEntryInt != nil {
		return obj.NetworkListUuidResponseEntryInt
	}

	if obj.NetworkListUuidResponseEntryString != nil {
		return obj.NetworkListUuidResponseEntryString
	}

	// all schemas are nil
	return nil
}

type NullableNetworkListUuidResponseEntry struct {
	value *NetworkListUuidResponseEntry
	isSet bool
}

func (v NullableNetworkListUuidResponseEntry) Get() *NetworkListUuidResponseEntry {
	return v.value
}

func (v *NullableNetworkListUuidResponseEntry) Set(val *NetworkListUuidResponseEntry) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableNetworkListUuidResponseEntry(val *NetworkListUuidResponseEntry) *NullableNetworkListUuidResponseEntry {
	return &NullableNetworkListUuidResponseEntry{value: val, isSet: true}
}

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

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


