/*
Hindsight HTTP API

HTTP API for Hindsight

API version: 0.5.3
*/

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

package hindsight

import (
	"encoding/json"
	"bytes"
	"fmt"
)

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

// MemoryTimeseriesBucket One bucket in the memory ingestion time-series.
type MemoryTimeseriesBucket struct {
	// Bucket start timestamp in ISO-8601 (UTC).
	Time string `json:"time"`
	// World-fact memories ingested in this bucket.
	World *int32 `json:"world,omitempty"`
	// Experience memories ingested in this bucket.
	Experience *int32 `json:"experience,omitempty"`
	// Observations recorded in this bucket.
	Observation *int32 `json:"observation,omitempty"`
}

type _MemoryTimeseriesBucket MemoryTimeseriesBucket

// NewMemoryTimeseriesBucket instantiates a new MemoryTimeseriesBucket 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 NewMemoryTimeseriesBucket(time string) *MemoryTimeseriesBucket {
	this := MemoryTimeseriesBucket{}
	this.Time = time
	var world int32 = 0
	this.World = &world
	var experience int32 = 0
	this.Experience = &experience
	var observation int32 = 0
	this.Observation = &observation
	return &this
}

// NewMemoryTimeseriesBucketWithDefaults instantiates a new MemoryTimeseriesBucket 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 NewMemoryTimeseriesBucketWithDefaults() *MemoryTimeseriesBucket {
	this := MemoryTimeseriesBucket{}
	var world int32 = 0
	this.World = &world
	var experience int32 = 0
	this.Experience = &experience
	var observation int32 = 0
	this.Observation = &observation
	return &this
}

// GetTime returns the Time field value
func (o *MemoryTimeseriesBucket) GetTime() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.Time
}

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

// SetTime sets field value
func (o *MemoryTimeseriesBucket) SetTime(v string) {
	o.Time = v
}

// GetWorld returns the World field value if set, zero value otherwise.
func (o *MemoryTimeseriesBucket) GetWorld() int32 {
	if o == nil || IsNil(o.World) {
		var ret int32
		return ret
	}
	return *o.World
}

// GetWorldOk returns a tuple with the World field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *MemoryTimeseriesBucket) GetWorldOk() (*int32, bool) {
	if o == nil || IsNil(o.World) {
		return nil, false
	}
	return o.World, true
}

// HasWorld returns a boolean if a field has been set.
func (o *MemoryTimeseriesBucket) HasWorld() bool {
	if o != nil && !IsNil(o.World) {
		return true
	}

	return false
}

// SetWorld gets a reference to the given int32 and assigns it to the World field.
func (o *MemoryTimeseriesBucket) SetWorld(v int32) {
	o.World = &v
}

// GetExperience returns the Experience field value if set, zero value otherwise.
func (o *MemoryTimeseriesBucket) GetExperience() int32 {
	if o == nil || IsNil(o.Experience) {
		var ret int32
		return ret
	}
	return *o.Experience
}

// GetExperienceOk returns a tuple with the Experience field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *MemoryTimeseriesBucket) GetExperienceOk() (*int32, bool) {
	if o == nil || IsNil(o.Experience) {
		return nil, false
	}
	return o.Experience, true
}

// HasExperience returns a boolean if a field has been set.
func (o *MemoryTimeseriesBucket) HasExperience() bool {
	if o != nil && !IsNil(o.Experience) {
		return true
	}

	return false
}

// SetExperience gets a reference to the given int32 and assigns it to the Experience field.
func (o *MemoryTimeseriesBucket) SetExperience(v int32) {
	o.Experience = &v
}

// GetObservation returns the Observation field value if set, zero value otherwise.
func (o *MemoryTimeseriesBucket) GetObservation() int32 {
	if o == nil || IsNil(o.Observation) {
		var ret int32
		return ret
	}
	return *o.Observation
}

// GetObservationOk returns a tuple with the Observation field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *MemoryTimeseriesBucket) GetObservationOk() (*int32, bool) {
	if o == nil || IsNil(o.Observation) {
		return nil, false
	}
	return o.Observation, true
}

// HasObservation returns a boolean if a field has been set.
func (o *MemoryTimeseriesBucket) HasObservation() bool {
	if o != nil && !IsNil(o.Observation) {
		return true
	}

	return false
}

// SetObservation gets a reference to the given int32 and assigns it to the Observation field.
func (o *MemoryTimeseriesBucket) SetObservation(v int32) {
	o.Observation = &v
}

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

func (o MemoryTimeseriesBucket) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	toSerialize["time"] = o.Time
	if !IsNil(o.World) {
		toSerialize["world"] = o.World
	}
	if !IsNil(o.Experience) {
		toSerialize["experience"] = o.Experience
	}
	if !IsNil(o.Observation) {
		toSerialize["observation"] = o.Observation
	}
	return toSerialize, nil
}

func (o *MemoryTimeseriesBucket) 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{
		"time",
	}

	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)
		}
	}

	varMemoryTimeseriesBucket := _MemoryTimeseriesBucket{}

	decoder := json.NewDecoder(bytes.NewReader(data))
	decoder.DisallowUnknownFields()
	err = decoder.Decode(&varMemoryTimeseriesBucket)

	if err != nil {
		return err
	}

	*o = MemoryTimeseriesBucket(varMemoryTimeseriesBucket)

	return err
}

type NullableMemoryTimeseriesBucket struct {
	value *MemoryTimeseriesBucket
	isSet bool
}

func (v NullableMemoryTimeseriesBucket) Get() *MemoryTimeseriesBucket {
	return v.value
}

func (v *NullableMemoryTimeseriesBucket) Set(val *MemoryTimeseriesBucket) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableMemoryTimeseriesBucket(val *MemoryTimeseriesBucket) *NullableMemoryTimeseriesBucket {
	return &NullableMemoryTimeseriesBucket{value: val, isSet: true}
}

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

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


