/*
Edge Firewall API

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

API version: 2.0.0
*/

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

package edgefirewall

import (
	"encoding/json"
	"fmt"
)

// SetCustomResponseArgumentStatusCode - struct for SetCustomResponseArgumentStatusCode
type SetCustomResponseArgumentStatusCode struct {
	Int32 *int32
	String *string
}

// int32AsSetCustomResponseArgumentStatusCode is a convenience function that returns int32 wrapped in SetCustomResponseArgumentStatusCode
func Int32AsSetCustomResponseArgumentStatusCode(v *int32) SetCustomResponseArgumentStatusCode {
	return SetCustomResponseArgumentStatusCode{
		Int32: v,
	}
}

// stringAsSetCustomResponseArgumentStatusCode is a convenience function that returns string wrapped in SetCustomResponseArgumentStatusCode
func StringAsSetCustomResponseArgumentStatusCode(v *string) SetCustomResponseArgumentStatusCode {
	return SetCustomResponseArgumentStatusCode{
		String: v,
	}
}


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

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

	if match > 1 { // more than 1 match
		// reset to nil
		dst.Int32 = nil
		dst.String = nil

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

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

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

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

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

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

	// all schemas are nil
	return nil
}

type NullableSetCustomResponseArgumentStatusCode struct {
	value *SetCustomResponseArgumentStatusCode
	isSet bool
}

func (v NullableSetCustomResponseArgumentStatusCode) Get() *SetCustomResponseArgumentStatusCode {
	return v.value
}

func (v *NullableSetCustomResponseArgumentStatusCode) Set(val *SetCustomResponseArgumentStatusCode) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableSetCustomResponseArgumentStatusCode(val *SetCustomResponseArgumentStatusCode) *NullableSetCustomResponseArgumentStatusCode {
	return &NullableSetCustomResponseArgumentStatusCode{value: val, isSet: true}
}

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

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


