/*
Web Application 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 waf

import (
	"encoding/json"
	"fmt"
)

// WAFEvents200ResultsInnerTop10CountriesInner - struct for WAFEvents200ResultsInnerTop10CountriesInner
type WAFEvents200ResultsInnerTop10CountriesInner struct {
	Int64 *int64
	String *string
}

// int64AsWAFEvents200ResultsInnerTop10CountriesInner is a convenience function that returns int64 wrapped in WAFEvents200ResultsInnerTop10CountriesInner
func Int64AsWAFEvents200ResultsInnerTop10CountriesInner(v *int64) WAFEvents200ResultsInnerTop10CountriesInner {
	return WAFEvents200ResultsInnerTop10CountriesInner{
		Int64: v,
	}
}

// stringAsWAFEvents200ResultsInnerTop10CountriesInner is a convenience function that returns string wrapped in WAFEvents200ResultsInnerTop10CountriesInner
func StringAsWAFEvents200ResultsInnerTop10CountriesInner(v *string) WAFEvents200ResultsInnerTop10CountriesInner {
	return WAFEvents200ResultsInnerTop10CountriesInner{
		String: v,
	}
}


// Unmarshal JSON data into one of the pointers in the struct
func (dst *WAFEvents200ResultsInnerTop10CountriesInner) UnmarshalJSON(data []byte) error {
	var err error
	match := 0
	// try to unmarshal data into Int64
	err = newStrictDecoder(data).Decode(&dst.Int64)
	if err == nil {
		jsonInt64, _ := json.Marshal(dst.Int64)
		if string(jsonInt64) == "{}" { // empty struct
			dst.Int64 = nil
		} else {
			match++
		}
	} else {
		dst.Int64 = 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.Int64 = nil
		dst.String = nil

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

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

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

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

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

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

	// all schemas are nil
	return nil
}

type NullableWAFEvents200ResultsInnerTop10CountriesInner struct {
	value *WAFEvents200ResultsInnerTop10CountriesInner
	isSet bool
}

func (v NullableWAFEvents200ResultsInnerTop10CountriesInner) Get() *WAFEvents200ResultsInnerTop10CountriesInner {
	return v.value
}

func (v *NullableWAFEvents200ResultsInnerTop10CountriesInner) Set(val *WAFEvents200ResultsInnerTop10CountriesInner) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableWAFEvents200ResultsInnerTop10CountriesInner(val *WAFEvents200ResultsInnerTop10CountriesInner) *NullableWAFEvents200ResultsInnerTop10CountriesInner {
	return &NullableWAFEvents200ResultsInnerTop10CountriesInner{value: val, isSet: true}
}

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

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


