/*
Mender API

Combined API specification for the features of the different Mender backend services, suitable for code generation applications 

API version: 1
Contact: support@mender.io
*/

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

package client

import (
	"encoding/json"
)

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

// Count Counter type
type Count struct {
	// The count of requested items.
	Count *int32 `json:"count,omitempty"`
	AdditionalProperties map[string]interface{}
}

type _Count Count

// NewCount instantiates a new Count 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 NewCount() *Count {
	this := Count{}
	return &this
}

// NewCountWithDefaults instantiates a new Count 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 NewCountWithDefaults() *Count {
	this := Count{}
	return &this
}

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

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

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

	return false
}

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

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

func (o Count) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	if !IsNil(o.Count) {
		toSerialize["count"] = o.Count
	}

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

	return toSerialize, nil
}

func (o *Count) UnmarshalJSON(data []byte) (err error) {
	varCount := _Count{}

	err = json.Unmarshal(data, &varCount)

	if err != nil {
		return err
	}

	*o = Count(varCount)

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

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

	return err
}

type NullableCount struct {
	value *Count
	isSet bool
}

func (v NullableCount) Get() *Count {
	return v.value
}

func (v *NullableCount) Set(val *Count) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableCount(val *Count) *NullableCount {
	return &NullableCount{value: val, isSet: true}
}

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

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


