/*
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 TaskSourceConfig type satisfies the MappedNullable interface at compile time
var _ MappedNullable = &TaskSourceConfig{}

// TaskSourceConfig source-related configuration
type TaskSourceConfig struct {
	FullMigrateConf *TaskFullMigrateConf `json:"full_migrate_conf,omitempty"`
	IncrMigrateConf *TaskIncrMigrateConf `json:"incr_migrate_conf,omitempty"`
	// source configuration
	SourceConf []TaskSourceConf `json:"source_conf"`
}

type _TaskSourceConfig TaskSourceConfig

// NewTaskSourceConfig instantiates a new TaskSourceConfig 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 NewTaskSourceConfig(sourceConf []TaskSourceConf) *TaskSourceConfig {
	this := TaskSourceConfig{}
	this.SourceConf = sourceConf
	return &this
}

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

// GetFullMigrateConf returns the FullMigrateConf field value if set, zero value otherwise.
func (o *TaskSourceConfig) GetFullMigrateConf() TaskFullMigrateConf {
	if o == nil || IsNil(o.FullMigrateConf) {
		var ret TaskFullMigrateConf
		return ret
	}
	return *o.FullMigrateConf
}

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

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

	return false
}

// SetFullMigrateConf gets a reference to the given TaskFullMigrateConf and assigns it to the FullMigrateConf field.
func (o *TaskSourceConfig) SetFullMigrateConf(v TaskFullMigrateConf) {
	o.FullMigrateConf = &v
}

// GetIncrMigrateConf returns the IncrMigrateConf field value if set, zero value otherwise.
func (o *TaskSourceConfig) GetIncrMigrateConf() TaskIncrMigrateConf {
	if o == nil || IsNil(o.IncrMigrateConf) {
		var ret TaskIncrMigrateConf
		return ret
	}
	return *o.IncrMigrateConf
}

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

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

	return false
}

// SetIncrMigrateConf gets a reference to the given TaskIncrMigrateConf and assigns it to the IncrMigrateConf field.
func (o *TaskSourceConfig) SetIncrMigrateConf(v TaskIncrMigrateConf) {
	o.IncrMigrateConf = &v
}

// GetSourceConf returns the SourceConf field value
func (o *TaskSourceConfig) GetSourceConf() []TaskSourceConf {
	if o == nil {
		var ret []TaskSourceConf
		return ret
	}

	return o.SourceConf
}

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

// SetSourceConf sets field value
func (o *TaskSourceConfig) SetSourceConf(v []TaskSourceConf) {
	o.SourceConf = v
}

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

func (o TaskSourceConfig) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	if !IsNil(o.FullMigrateConf) {
		toSerialize["full_migrate_conf"] = o.FullMigrateConf
	}
	if !IsNil(o.IncrMigrateConf) {
		toSerialize["incr_migrate_conf"] = o.IncrMigrateConf
	}
	toSerialize["source_conf"] = o.SourceConf
	return toSerialize, nil
}

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

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

	varTaskSourceConfig := _TaskSourceConfig{}

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

	if err != nil {
		return err
	}

	*o = TaskSourceConfig(varTaskSourceConfig)

	return err
}

type NullableTaskSourceConfig struct {
	value *TaskSourceConfig
	isSet bool
}

func (v NullableTaskSourceConfig) Get() *TaskSourceConfig {
	return v.value
}

func (v *NullableTaskSourceConfig) Set(val *TaskSourceConfig) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableTaskSourceConfig(val *TaskSourceConfig) *NullableTaskSourceConfig {
	return &NullableTaskSourceConfig{value: val, isSet: true}
}

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

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