/*
 * Turing Minimal Openapi Spec for SDK
 *
 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
 *
 * API version: 0.0.1
 */

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

package openapi

import (
	"encoding/json"
	"fmt"
)

// EnsemblingJobSink - struct for EnsemblingJobSink
type EnsemblingJobSink struct {
	BigQuerySink *BigQuerySink
}

// BigQuerySinkAsEnsemblingJobSink is a convenience function that returns BigQuerySink wrapped in EnsemblingJobSink
func BigQuerySinkAsEnsemblingJobSink(v *BigQuerySink) EnsemblingJobSink {
	return EnsemblingJobSink{ BigQuerySink: v}
}


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

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

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

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

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

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

	// all schemas are nil
	return nil
}

type NullableEnsemblingJobSink struct {
	value *EnsemblingJobSink
	isSet bool
}

func (v NullableEnsemblingJobSink) Get() *EnsemblingJobSink {
	return v.value
}

func (v *NullableEnsemblingJobSink) Set(val *EnsemblingJobSink) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableEnsemblingJobSink(val *EnsemblingJobSink) *NullableEnsemblingJobSink {
	return &NullableEnsemblingJobSink{value: val, isSet: true}
}

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

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


