/*
Daytona

Daytona AI platform API Docs

API version: 1.0
Contact: support@daytona.com
*/

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

package apiclient

import (
	"encoding/json"
	"fmt"
)

// checks if the MousePosition type satisfies the MappedNullable interface at compile time
var _ MappedNullable = &MousePosition{}

// MousePosition struct for MousePosition
type MousePosition struct {
	// The X coordinate of the mouse cursor position
	X float32 `json:"x"`
	// The Y coordinate of the mouse cursor position
	Y float32 `json:"y"`
	AdditionalProperties map[string]interface{}
}

type _MousePosition MousePosition

// NewMousePosition instantiates a new MousePosition object
// This constructor will assign default values to properties that have it defined,
// and makes sure properties required by API are set, but the set of arguments
// will change when the set of required properties is changed
func NewMousePosition(x float32, y float32) *MousePosition {
	this := MousePosition{}
	this.X = x
	this.Y = y
	return &this
}

// NewMousePositionWithDefaults instantiates a new MousePosition object
// This constructor will only assign default values to properties that have it defined,
// but it doesn't guarantee that properties required by API are set
func NewMousePositionWithDefaults() *MousePosition {
	this := MousePosition{}
	return &this
}

// GetX returns the X field value
func (o *MousePosition) GetX() float32 {
	if o == nil {
		var ret float32
		return ret
	}

	return o.X
}

// GetXOk returns a tuple with the X field value
// and a boolean to check if the value has been set.
func (o *MousePosition) GetXOk() (*float32, bool) {
	if o == nil {
		return nil, false
	}
	return &o.X, true
}

// SetX sets field value
func (o *MousePosition) SetX(v float32) {
	o.X = v
}

// GetY returns the Y field value
func (o *MousePosition) GetY() float32 {
	if o == nil {
		var ret float32
		return ret
	}

	return o.Y
}

// GetYOk returns a tuple with the Y field value
// and a boolean to check if the value has been set.
func (o *MousePosition) GetYOk() (*float32, bool) {
	if o == nil {
		return nil, false
	}
	return &o.Y, true
}

// SetY sets field value
func (o *MousePosition) SetY(v float32) {
	o.Y = v
}

func (o MousePosition) MarshalJSON() ([]byte, error) {
	toSerialize,err := o.ToMap()
	if err != nil {
		return []byte{}, err
	}
	return json.Marshal(toSerialize)
}

func (o MousePosition) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	toSerialize["x"] = o.X
	toSerialize["y"] = o.Y

	for key, value := range o.AdditionalProperties {
		toSerialize[key] = value
	}

	return toSerialize, nil
}

func (o *MousePosition) UnmarshalJSON(data []byte) (err error) {
	// This validates that all required properties are included in the JSON object
	// by unmarshalling the object into a generic map with string keys and checking
	// that every required field exists as a key in the generic map.
	requiredProperties := []string{
		"x",
		"y",
	}

	allProperties := make(map[string]interface{})

	err = json.Unmarshal(data, &allProperties)

	if err != nil {
		return err;
	}

	for _, requiredProperty := range(requiredProperties) {
		if _, exists := allProperties[requiredProperty]; !exists {
			return fmt.Errorf("no value given for required property %v", requiredProperty)
		}
	}

	varMousePosition := _MousePosition{}

	err = json.Unmarshal(data, &varMousePosition)

	if err != nil {
		return err
	}

	*o = MousePosition(varMousePosition)

	additionalProperties := make(map[string]interface{})

	if err = json.Unmarshal(data, &additionalProperties); err == nil {
		delete(additionalProperties, "x")
		delete(additionalProperties, "y")
		o.AdditionalProperties = additionalProperties
	}

	return err
}

type NullableMousePosition struct {
	value *MousePosition
	isSet bool
}

func (v NullableMousePosition) Get() *MousePosition {
	return v.value
}

func (v *NullableMousePosition) Set(val *MousePosition) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableMousePosition(val *MousePosition) *NullableMousePosition {
	return &NullableMousePosition{value: val, isSet: true}
}

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

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


