/*
ChromaDB API

This is OpenAPI schema for ChromaDB API.

API version: 1.0.0
*/

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

package openapi

import (
	"encoding/json"
	"fmt"
)

// EmbeddingsInner struct for EmbeddingsInner
type EmbeddingsInner struct {
	ArrayOfFloat32 *[]float32
	ArrayOfInt32   *[]int32
}

// Unmarshal JSON data into any of the pointers in the struct
func (dst *EmbeddingsInner) UnmarshalJSON(data []byte) error {
	var err error
	// try to unmarshal JSON data into ArrayOfFloat32
	err = json.Unmarshal(data, &dst.ArrayOfFloat32)
	if err == nil {
		jsonArrayOfFloat32, _ := json.Marshal(dst.ArrayOfFloat32)
		if string(jsonArrayOfFloat32) == "{}" { // empty struct
			dst.ArrayOfFloat32 = nil
		} else {
			return nil // data stored in dst.ArrayOfFloat32, return on the first match
		}
	} else {
		dst.ArrayOfFloat32 = nil
	}

	// try to unmarshal JSON data into ArrayOfInt32
	err = json.Unmarshal(data, &dst.ArrayOfInt32)
	if err == nil {
		jsonArrayOfInt32, _ := json.Marshal(dst.ArrayOfInt32)
		if string(jsonArrayOfInt32) == "{}" { // empty struct
			dst.ArrayOfInt32 = nil
		} else {
			return nil // data stored in dst.ArrayOfInt32, return on the first match
		}
	} else {
		dst.ArrayOfInt32 = nil
	}

	return fmt.Errorf("data failed to match schemas in anyOf(EmbeddingsInner)")
}

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

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

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

type NullableEmbeddingsInner struct {
	value *EmbeddingsInner
	isSet bool
}

func (v NullableEmbeddingsInner) Get() *EmbeddingsInner {
	return v.value
}

func (v *NullableEmbeddingsInner) Set(val *EmbeddingsInner) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableEmbeddingsInner(val *EmbeddingsInner) *NullableEmbeddingsInner {
	return &NullableEmbeddingsInner{value: val, isSet: true}
}

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

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