/*
DM OpenAPI DOC

No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)

API version: 6.0.0
*/

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

package dm

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

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

// ShardingGroup struct for ShardingGroup
type ShardingGroup struct {
	DdlList       []string `json:"ddl_list"`
	FirstLocation string   `json:"first_location"`
	Synced        []string `json:"synced"`
	Target        string   `json:"target"`
	Unsynced      []string `json:"unsynced"`
}

type _ShardingGroup ShardingGroup

// NewShardingGroup instantiates a new ShardingGroup 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 NewShardingGroup(ddlList []string, firstLocation string, synced []string, target string, unsynced []string) *ShardingGroup {
	this := ShardingGroup{}
	this.DdlList = ddlList
	this.FirstLocation = firstLocation
	this.Synced = synced
	this.Target = target
	this.Unsynced = unsynced
	return &this
}

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

// GetDdlList returns the DdlList field value
func (o *ShardingGroup) GetDdlList() []string {
	if o == nil {
		var ret []string
		return ret
	}

	return o.DdlList
}

// GetDdlListOk returns a tuple with the DdlList field value
// and a boolean to check if the value has been set.
func (o *ShardingGroup) GetDdlListOk() ([]string, bool) {
	if o == nil {
		return nil, false
	}
	return o.DdlList, true
}

// SetDdlList sets field value
func (o *ShardingGroup) SetDdlList(v []string) {
	o.DdlList = v
}

// GetFirstLocation returns the FirstLocation field value
func (o *ShardingGroup) GetFirstLocation() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.FirstLocation
}

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

// SetFirstLocation sets field value
func (o *ShardingGroup) SetFirstLocation(v string) {
	o.FirstLocation = v
}

// GetSynced returns the Synced field value
func (o *ShardingGroup) GetSynced() []string {
	if o == nil {
		var ret []string
		return ret
	}

	return o.Synced
}

// GetSyncedOk returns a tuple with the Synced field value
// and a boolean to check if the value has been set.
func (o *ShardingGroup) GetSyncedOk() ([]string, bool) {
	if o == nil {
		return nil, false
	}
	return o.Synced, true
}

// SetSynced sets field value
func (o *ShardingGroup) SetSynced(v []string) {
	o.Synced = v
}

// GetTarget returns the Target field value
func (o *ShardingGroup) GetTarget() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.Target
}

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

// SetTarget sets field value
func (o *ShardingGroup) SetTarget(v string) {
	o.Target = v
}

// GetUnsynced returns the Unsynced field value
func (o *ShardingGroup) GetUnsynced() []string {
	if o == nil {
		var ret []string
		return ret
	}

	return o.Unsynced
}

// GetUnsyncedOk returns a tuple with the Unsynced field value
// and a boolean to check if the value has been set.
func (o *ShardingGroup) GetUnsyncedOk() ([]string, bool) {
	if o == nil {
		return nil, false
	}
	return o.Unsynced, true
}

// SetUnsynced sets field value
func (o *ShardingGroup) SetUnsynced(v []string) {
	o.Unsynced = v
}

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

func (o ShardingGroup) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	toSerialize["ddl_list"] = o.DdlList
	toSerialize["first_location"] = o.FirstLocation
	toSerialize["synced"] = o.Synced
	toSerialize["target"] = o.Target
	toSerialize["unsynced"] = o.Unsynced
	return toSerialize, nil
}

func (o *ShardingGroup) 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{
		"ddl_list",
		"first_location",
		"synced",
		"target",
		"unsynced",
	}

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

	varShardingGroup := _ShardingGroup{}

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

	if err != nil {
		return err
	}

	*o = ShardingGroup(varShardingGroup)

	return err
}

type NullableShardingGroup struct {
	value *ShardingGroup
	isSet bool
}

func (v NullableShardingGroup) Get() *ShardingGroup {
	return v.value
}

func (v *NullableShardingGroup) Set(val *ShardingGroup) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableShardingGroup(val *ShardingGroup) *NullableShardingGroup {
	return &NullableShardingGroup{value: val, isSet: true}
}

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

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