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

// SubTaskStatus struct for SubTaskStatus
type SubTaskStatus struct {
	DumpStatus *DumpStatus `json:"dump_status,omitempty"`
	// error message when something wrong
	ErrorMsg   *string     `json:"error_msg,omitempty"`
	LoadStatus *LoadStatus `json:"load_status,omitempty"`
	// task name
	Name string `json:"name"`
	// source name
	SourceName string      `json:"source_name"`
	Stage      TaskStage   `json:"stage"`
	SyncStatus *SyncStatus `json:"sync_status,omitempty"`
	// task unit type
	Unit                string  `json:"unit"`
	UnresolvedDdlLockId *string `json:"unresolved_ddl_lock_id,omitempty"`
	// worker name
	WorkerName string `json:"worker_name"`
}

type _SubTaskStatus SubTaskStatus

// NewSubTaskStatus instantiates a new SubTaskStatus 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 NewSubTaskStatus(name string, sourceName string, stage TaskStage, unit string, workerName string) *SubTaskStatus {
	this := SubTaskStatus{}
	this.Name = name
	this.SourceName = sourceName
	this.Stage = stage
	this.Unit = unit
	this.WorkerName = workerName
	return &this
}

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

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

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

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

	return false
}

// SetDumpStatus gets a reference to the given DumpStatus and assigns it to the DumpStatus field.
func (o *SubTaskStatus) SetDumpStatus(v DumpStatus) {
	o.DumpStatus = &v
}

// GetErrorMsg returns the ErrorMsg field value if set, zero value otherwise.
func (o *SubTaskStatus) GetErrorMsg() string {
	if o == nil || IsNil(o.ErrorMsg) {
		var ret string
		return ret
	}
	return *o.ErrorMsg
}

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

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

	return false
}

// SetErrorMsg gets a reference to the given string and assigns it to the ErrorMsg field.
func (o *SubTaskStatus) SetErrorMsg(v string) {
	o.ErrorMsg = &v
}

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

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

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

	return false
}

// SetLoadStatus gets a reference to the given LoadStatus and assigns it to the LoadStatus field.
func (o *SubTaskStatus) SetLoadStatus(v LoadStatus) {
	o.LoadStatus = &v
}

// GetName returns the Name field value
func (o *SubTaskStatus) GetName() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.Name
}

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

// SetName sets field value
func (o *SubTaskStatus) SetName(v string) {
	o.Name = v
}

// GetSourceName returns the SourceName field value
func (o *SubTaskStatus) GetSourceName() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.SourceName
}

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

// SetSourceName sets field value
func (o *SubTaskStatus) SetSourceName(v string) {
	o.SourceName = v
}

// GetStage returns the Stage field value
func (o *SubTaskStatus) GetStage() TaskStage {
	if o == nil {
		var ret TaskStage
		return ret
	}

	return o.Stage
}

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

// SetStage sets field value
func (o *SubTaskStatus) SetStage(v TaskStage) {
	o.Stage = v
}

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

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

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

	return false
}

// SetSyncStatus gets a reference to the given SyncStatus and assigns it to the SyncStatus field.
func (o *SubTaskStatus) SetSyncStatus(v SyncStatus) {
	o.SyncStatus = &v
}

// GetUnit returns the Unit field value
func (o *SubTaskStatus) GetUnit() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.Unit
}

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

// SetUnit sets field value
func (o *SubTaskStatus) SetUnit(v string) {
	o.Unit = v
}

// GetUnresolvedDdlLockId returns the UnresolvedDdlLockId field value if set, zero value otherwise.
func (o *SubTaskStatus) GetUnresolvedDdlLockId() string {
	if o == nil || IsNil(o.UnresolvedDdlLockId) {
		var ret string
		return ret
	}
	return *o.UnresolvedDdlLockId
}

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

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

	return false
}

// SetUnresolvedDdlLockId gets a reference to the given string and assigns it to the UnresolvedDdlLockId field.
func (o *SubTaskStatus) SetUnresolvedDdlLockId(v string) {
	o.UnresolvedDdlLockId = &v
}

// GetWorkerName returns the WorkerName field value
func (o *SubTaskStatus) GetWorkerName() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.WorkerName
}

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

// SetWorkerName sets field value
func (o *SubTaskStatus) SetWorkerName(v string) {
	o.WorkerName = v
}

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

func (o SubTaskStatus) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	if !IsNil(o.DumpStatus) {
		toSerialize["dump_status"] = o.DumpStatus
	}
	if !IsNil(o.ErrorMsg) {
		toSerialize["error_msg"] = o.ErrorMsg
	}
	if !IsNil(o.LoadStatus) {
		toSerialize["load_status"] = o.LoadStatus
	}
	toSerialize["name"] = o.Name
	toSerialize["source_name"] = o.SourceName
	toSerialize["stage"] = o.Stage
	if !IsNil(o.SyncStatus) {
		toSerialize["sync_status"] = o.SyncStatus
	}
	toSerialize["unit"] = o.Unit
	if !IsNil(o.UnresolvedDdlLockId) {
		toSerialize["unresolved_ddl_lock_id"] = o.UnresolvedDdlLockId
	}
	toSerialize["worker_name"] = o.WorkerName
	return toSerialize, nil
}

func (o *SubTaskStatus) 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{
		"name",
		"source_name",
		"stage",
		"unit",
		"worker_name",
	}

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

	varSubTaskStatus := _SubTaskStatus{}

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

	if err != nil {
		return err
	}

	*o = SubTaskStatus(varSubTaskStatus)

	return err
}

type NullableSubTaskStatus struct {
	value *SubTaskStatus
	isSet bool
}

func (v NullableSubTaskStatus) Get() *SubTaskStatus {
	return v.value
}

func (v *NullableSubTaskStatus) Set(val *SubTaskStatus) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableSubTaskStatus(val *SubTaskStatus) *NullableSubTaskStatus {
	return &NullableSubTaskStatus{value: val, isSet: true}
}

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

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