// Code generated by thriftrw v1.29.2. DO NOT EDIT.
// @generated

package shadower

import (
	bytes "bytes"
	base64 "encoding/base64"
	json "encoding/json"
	fmt "fmt"
	math "math"
	strconv "strconv"
	strings "strings"

	multierr "go.uber.org/multierr"
	stream "go.uber.org/thriftrw/protocol/stream"
	thriftreflect "go.uber.org/thriftrw/thriftreflect"
	wire "go.uber.org/thriftrw/wire"
	zapcore "go.uber.org/zap/zapcore"

	shared "github.com/uber/cadence/.gen/go/shared"
)

const ErrNonRetryableType string = "com.uber.cadence.internal.shadowing.NonRetryableException"

const ErrReasonDomainNotExists string = "domain not exists"

const ErrReasonInvalidQuery string = "invalid visibility query"

const ErrReasonWorkflowTypeNotRegistered string = "workflow type not registered"

const LocalDomainName string = "cadence-shadower"

const ReplayWorkflowActivityName string = "replayWorkflowActivity"

const ScanWorkflowActivityName string = "scanWorkflowActivity"

const TaskList string = "cadence-shadower-tl"

const WorkflowIDSuffix string = "-shadow-workflow"

const WorkflowName string = "cadence-shadow-workflow"

type ExitCondition struct {
	ExpirationIntervalInSeconds *int32 `json:"expirationIntervalInSeconds,omitempty"`
	ShadowCount                 *int32 `json:"shadowCount,omitempty"`
}

// ToWire translates a ExitCondition struct into a Thrift-level intermediate
// representation. This intermediate representation may be serialized
// into bytes using a ThriftRW protocol implementation.
//
// An error is returned if the struct or any of its fields failed to
// validate.
//
//	x, err := v.ToWire()
//	if err != nil {
//	  return err
//	}
//
//	if err := binaryProtocol.Encode(x, writer); err != nil {
//	  return err
//	}
func (v *ExitCondition) ToWire() (wire.Value, error) {
	var (
		fields [2]wire.Field
		i      int = 0
		w      wire.Value
		err    error
	)

	if v.ExpirationIntervalInSeconds != nil {
		w, err = wire.NewValueI32(*(v.ExpirationIntervalInSeconds)), error(nil)
		if err != nil {
			return w, err
		}
		fields[i] = wire.Field{ID: 10, Value: w}
		i++
	}
	if v.ShadowCount != nil {
		w, err = wire.NewValueI32(*(v.ShadowCount)), error(nil)
		if err != nil {
			return w, err
		}
		fields[i] = wire.Field{ID: 20, Value: w}
		i++
	}

	return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil
}

// FromWire deserializes a ExitCondition struct from its Thrift-level
// representation. The Thrift-level representation may be obtained
// from a ThriftRW protocol implementation.
//
// An error is returned if we were unable to build a ExitCondition struct
// from the provided intermediate representation.
//
//	x, err := binaryProtocol.Decode(reader, wire.TStruct)
//	if err != nil {
//	  return nil, err
//	}
//
//	var v ExitCondition
//	if err := v.FromWire(x); err != nil {
//	  return nil, err
//	}
//	return &v, nil
func (v *ExitCondition) FromWire(w wire.Value) error {
	var err error

	for _, field := range w.GetStruct().Fields {
		switch field.ID {
		case 10:
			if field.Value.Type() == wire.TI32 {
				var x int32
				x, err = field.Value.GetI32(), error(nil)
				v.ExpirationIntervalInSeconds = &x
				if err != nil {
					return err
				}

			}
		case 20:
			if field.Value.Type() == wire.TI32 {
				var x int32
				x, err = field.Value.GetI32(), error(nil)
				v.ShadowCount = &x
				if err != nil {
					return err
				}

			}
		}
	}

	return nil
}

// Encode serializes a ExitCondition struct directly into bytes, without going
// through an intermediary type.
//
// An error is returned if a ExitCondition struct could not be encoded.
func (v *ExitCondition) Encode(sw stream.Writer) error {
	if err := sw.WriteStructBegin(); err != nil {
		return err
	}

	if v.ExpirationIntervalInSeconds != nil {
		if err := sw.WriteFieldBegin(stream.FieldHeader{ID: 10, Type: wire.TI32}); err != nil {
			return err
		}
		if err := sw.WriteInt32(*(v.ExpirationIntervalInSeconds)); err != nil {
			return err
		}
		if err := sw.WriteFieldEnd(); err != nil {
			return err
		}
	}

	if v.ShadowCount != nil {
		if err := sw.WriteFieldBegin(stream.FieldHeader{ID: 20, Type: wire.TI32}); err != nil {
			return err
		}
		if err := sw.WriteInt32(*(v.ShadowCount)); err != nil {
			return err
		}
		if err := sw.WriteFieldEnd(); err != nil {
			return err
		}
	}

	return sw.WriteStructEnd()
}

// Decode deserializes a ExitCondition struct directly from its Thrift-level
// representation, without going through an intemediary type.
//
// An error is returned if a ExitCondition struct could not be generated from the wire
// representation.
func (v *ExitCondition) Decode(sr stream.Reader) error {

	if err := sr.ReadStructBegin(); err != nil {
		return err
	}

	fh, ok, err := sr.ReadFieldBegin()
	if err != nil {
		return err
	}

	for ok {
		switch {
		case fh.ID == 10 && fh.Type == wire.TI32:
			var x int32
			x, err = sr.ReadInt32()
			v.ExpirationIntervalInSeconds = &x
			if err != nil {
				return err
			}

		case fh.ID == 20 && fh.Type == wire.TI32:
			var x int32
			x, err = sr.ReadInt32()
			v.ShadowCount = &x
			if err != nil {
				return err
			}

		default:
			if err := sr.Skip(fh.Type); err != nil {
				return err
			}
		}

		if err := sr.ReadFieldEnd(); err != nil {
			return err
		}

		if fh, ok, err = sr.ReadFieldBegin(); err != nil {
			return err
		}
	}

	if err := sr.ReadStructEnd(); err != nil {
		return err
	}

	return nil
}

// String returns a readable string representation of a ExitCondition
// struct.
func (v *ExitCondition) String() string {
	if v == nil {
		return "<nil>"
	}

	var fields [2]string
	i := 0
	if v.ExpirationIntervalInSeconds != nil {
		fields[i] = fmt.Sprintf("ExpirationIntervalInSeconds: %v", *(v.ExpirationIntervalInSeconds))
		i++
	}
	if v.ShadowCount != nil {
		fields[i] = fmt.Sprintf("ShadowCount: %v", *(v.ShadowCount))
		i++
	}

	return fmt.Sprintf("ExitCondition{%v}", strings.Join(fields[:i], ", "))
}

func _I32_EqualsPtr(lhs, rhs *int32) bool {
	if lhs != nil && rhs != nil {

		x := *lhs
		y := *rhs
		return (x == y)
	}
	return lhs == nil && rhs == nil
}

// Equals returns true if all the fields of this ExitCondition match the
// provided ExitCondition.
//
// This function performs a deep comparison.
func (v *ExitCondition) Equals(rhs *ExitCondition) bool {
	if v == nil {
		return rhs == nil
	} else if rhs == nil {
		return false
	}
	if !_I32_EqualsPtr(v.ExpirationIntervalInSeconds, rhs.ExpirationIntervalInSeconds) {
		return false
	}
	if !_I32_EqualsPtr(v.ShadowCount, rhs.ShadowCount) {
		return false
	}

	return true
}

// MarshalLogObject implements zapcore.ObjectMarshaler, enabling
// fast logging of ExitCondition.
func (v *ExitCondition) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {
	if v == nil {
		return nil
	}
	if v.ExpirationIntervalInSeconds != nil {
		enc.AddInt32("expirationIntervalInSeconds", *v.ExpirationIntervalInSeconds)
	}
	if v.ShadowCount != nil {
		enc.AddInt32("shadowCount", *v.ShadowCount)
	}
	return err
}

// GetExpirationIntervalInSeconds returns the value of ExpirationIntervalInSeconds if it is set or its
// zero value if it is unset.
func (v *ExitCondition) GetExpirationIntervalInSeconds() (o int32) {
	if v != nil && v.ExpirationIntervalInSeconds != nil {
		return *v.ExpirationIntervalInSeconds
	}

	return
}

// IsSetExpirationIntervalInSeconds returns true if ExpirationIntervalInSeconds is not nil.
func (v *ExitCondition) IsSetExpirationIntervalInSeconds() bool {
	return v != nil && v.ExpirationIntervalInSeconds != nil
}

// GetShadowCount returns the value of ShadowCount if it is set or its
// zero value if it is unset.
func (v *ExitCondition) GetShadowCount() (o int32) {
	if v != nil && v.ShadowCount != nil {
		return *v.ShadowCount
	}

	return
}

// IsSetShadowCount returns true if ShadowCount is not nil.
func (v *ExitCondition) IsSetShadowCount() bool {
	return v != nil && v.ShadowCount != nil
}

type Mode int32

const (
	ModeNormal     Mode = 0
	ModeContinuous Mode = 1
)

// Mode_Values returns all recognized values of Mode.
func Mode_Values() []Mode {
	return []Mode{
		ModeNormal,
		ModeContinuous,
	}
}

// UnmarshalText tries to decode Mode from a byte slice
// containing its name.
//
//	var v Mode
//	err := v.UnmarshalText([]byte("Normal"))
func (v *Mode) UnmarshalText(value []byte) error {
	switch s := string(value); s {
	case "Normal":
		*v = ModeNormal
		return nil
	case "Continuous":
		*v = ModeContinuous
		return nil
	default:
		val, err := strconv.ParseInt(s, 10, 32)
		if err != nil {
			return fmt.Errorf("unknown enum value %q for %q: %v", s, "Mode", err)
		}
		*v = Mode(val)
		return nil
	}
}

// MarshalText encodes Mode to text.
//
// If the enum value is recognized, its name is returned.
// Otherwise, its integer value is returned.
//
// This implements the TextMarshaler interface.
func (v Mode) MarshalText() ([]byte, error) {
	switch int32(v) {
	case 0:
		return []byte("Normal"), nil
	case 1:
		return []byte("Continuous"), nil
	}
	return []byte(strconv.FormatInt(int64(v), 10)), nil
}

// MarshalLogObject implements zapcore.ObjectMarshaler, enabling
// fast logging of Mode.
// Enums are logged as objects, where the value is logged with key "value", and
// if this value's name is known, the name is logged with key "name".
func (v Mode) MarshalLogObject(enc zapcore.ObjectEncoder) error {
	enc.AddInt32("value", int32(v))
	switch int32(v) {
	case 0:
		enc.AddString("name", "Normal")
	case 1:
		enc.AddString("name", "Continuous")
	}
	return nil
}

// Ptr returns a pointer to this enum value.
func (v Mode) Ptr() *Mode {
	return &v
}

// Encode encodes Mode directly to bytes.
//
//	sWriter := BinaryStreamer.Writer(writer)
//
//	var v Mode
//	return v.Encode(sWriter)
func (v Mode) Encode(sw stream.Writer) error {
	return sw.WriteInt32(int32(v))
}

// ToWire translates Mode into a Thrift-level intermediate
// representation. This intermediate representation may be serialized
// into bytes using a ThriftRW protocol implementation.
//
// Enums are represented as 32-bit integers over the wire.
func (v Mode) ToWire() (wire.Value, error) {
	return wire.NewValueI32(int32(v)), nil
}

// FromWire deserializes Mode from its Thrift-level
// representation.
//
//	x, err := binaryProtocol.Decode(reader, wire.TI32)
//	if err != nil {
//	  return Mode(0), err
//	}
//
//	var v Mode
//	if err := v.FromWire(x); err != nil {
//	  return Mode(0), err
//	}
//	return v, nil
func (v *Mode) FromWire(w wire.Value) error {
	*v = (Mode)(w.GetI32())
	return nil
}

// Decode reads off the encoded Mode directly off of the wire.
//
//	sReader := BinaryStreamer.Reader(reader)
//
//	var v Mode
//	if err := v.Decode(sReader); err != nil {
//	  return Mode(0), err
//	}
//	return v, nil
func (v *Mode) Decode(sr stream.Reader) error {
	i, err := sr.ReadInt32()
	if err != nil {
		return err
	}
	*v = (Mode)(i)
	return nil
}

// String returns a readable string representation of Mode.
func (v Mode) String() string {
	w := int32(v)
	switch w {
	case 0:
		return "Normal"
	case 1:
		return "Continuous"
	}
	return fmt.Sprintf("Mode(%d)", w)
}

// Equals returns true if this Mode value matches the provided
// value.
func (v Mode) Equals(rhs Mode) bool {
	return v == rhs
}

// MarshalJSON serializes Mode into JSON.
//
// If the enum value is recognized, its name is returned.
// Otherwise, its integer value is returned.
//
// This implements json.Marshaler.
func (v Mode) MarshalJSON() ([]byte, error) {
	switch int32(v) {
	case 0:
		return ([]byte)("\"Normal\""), nil
	case 1:
		return ([]byte)("\"Continuous\""), nil
	}
	return ([]byte)(strconv.FormatInt(int64(v), 10)), nil
}

// UnmarshalJSON attempts to decode Mode from its JSON
// representation.
//
// This implementation supports both, numeric and string inputs. If a
// string is provided, it must be a known enum name.
//
// This implements json.Unmarshaler.
func (v *Mode) UnmarshalJSON(text []byte) error {
	d := json.NewDecoder(bytes.NewReader(text))
	d.UseNumber()
	t, err := d.Token()
	if err != nil {
		return err
	}

	switch w := t.(type) {
	case json.Number:
		x, err := w.Int64()
		if err != nil {
			return err
		}
		if x > math.MaxInt32 {
			return fmt.Errorf("enum overflow from JSON %q for %q", text, "Mode")
		}
		if x < math.MinInt32 {
			return fmt.Errorf("enum underflow from JSON %q for %q", text, "Mode")
		}
		*v = (Mode)(x)
		return nil
	case string:
		return v.UnmarshalText([]byte(w))
	default:
		return fmt.Errorf("invalid JSON value %q (%T) to unmarshal into %q", t, t, "Mode")
	}
}

type ReplayWorkflowActivityParams struct {
	Domain     *string                     `json:"domain,omitempty"`
	Executions []*shared.WorkflowExecution `json:"executions,omitempty"`
}

type _List_WorkflowExecution_ValueList []*shared.WorkflowExecution

func (v _List_WorkflowExecution_ValueList) ForEach(f func(wire.Value) error) error {
	for i, x := range v {
		if x == nil {
			return fmt.Errorf("invalid list '[]*shared.WorkflowExecution', index [%v]: value is nil", i)
		}
		w, err := x.ToWire()
		if err != nil {
			return err
		}
		err = f(w)
		if err != nil {
			return err
		}
	}
	return nil
}

func (v _List_WorkflowExecution_ValueList) Size() int {
	return len(v)
}

func (_List_WorkflowExecution_ValueList) ValueType() wire.Type {
	return wire.TStruct
}

func (_List_WorkflowExecution_ValueList) Close() {}

// ToWire translates a ReplayWorkflowActivityParams struct into a Thrift-level intermediate
// representation. This intermediate representation may be serialized
// into bytes using a ThriftRW protocol implementation.
//
// An error is returned if the struct or any of its fields failed to
// validate.
//
//	x, err := v.ToWire()
//	if err != nil {
//	  return err
//	}
//
//	if err := binaryProtocol.Encode(x, writer); err != nil {
//	  return err
//	}
func (v *ReplayWorkflowActivityParams) ToWire() (wire.Value, error) {
	var (
		fields [2]wire.Field
		i      int = 0
		w      wire.Value
		err    error
	)

	if v.Domain != nil {
		w, err = wire.NewValueString(*(v.Domain)), error(nil)
		if err != nil {
			return w, err
		}
		fields[i] = wire.Field{ID: 10, Value: w}
		i++
	}
	if v.Executions != nil {
		w, err = wire.NewValueList(_List_WorkflowExecution_ValueList(v.Executions)), error(nil)
		if err != nil {
			return w, err
		}
		fields[i] = wire.Field{ID: 20, Value: w}
		i++
	}

	return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil
}

func _WorkflowExecution_Read(w wire.Value) (*shared.WorkflowExecution, error) {
	var v shared.WorkflowExecution
	err := v.FromWire(w)
	return &v, err
}

func _List_WorkflowExecution_Read(l wire.ValueList) ([]*shared.WorkflowExecution, error) {
	if l.ValueType() != wire.TStruct {
		return nil, nil
	}

	o := make([]*shared.WorkflowExecution, 0, l.Size())
	err := l.ForEach(func(x wire.Value) error {
		i, err := _WorkflowExecution_Read(x)
		if err != nil {
			return err
		}
		o = append(o, i)
		return nil
	})
	l.Close()
	return o, err
}

// FromWire deserializes a ReplayWorkflowActivityParams struct from its Thrift-level
// representation. The Thrift-level representation may be obtained
// from a ThriftRW protocol implementation.
//
// An error is returned if we were unable to build a ReplayWorkflowActivityParams struct
// from the provided intermediate representation.
//
//	x, err := binaryProtocol.Decode(reader, wire.TStruct)
//	if err != nil {
//	  return nil, err
//	}
//
//	var v ReplayWorkflowActivityParams
//	if err := v.FromWire(x); err != nil {
//	  return nil, err
//	}
//	return &v, nil
func (v *ReplayWorkflowActivityParams) FromWire(w wire.Value) error {
	var err error

	for _, field := range w.GetStruct().Fields {
		switch field.ID {
		case 10:
			if field.Value.Type() == wire.TBinary {
				var x string
				x, err = field.Value.GetString(), error(nil)
				v.Domain = &x
				if err != nil {
					return err
				}

			}
		case 20:
			if field.Value.Type() == wire.TList {
				v.Executions, err = _List_WorkflowExecution_Read(field.Value.GetList())
				if err != nil {
					return err
				}

			}
		}
	}

	return nil
}

func _List_WorkflowExecution_Encode(val []*shared.WorkflowExecution, sw stream.Writer) error {

	lh := stream.ListHeader{
		Type:   wire.TStruct,
		Length: len(val),
	}
	if err := sw.WriteListBegin(lh); err != nil {
		return err
	}

	for i, v := range val {
		if v == nil {
			return fmt.Errorf("invalid list '[]*shared.WorkflowExecution', index [%v]: value is nil", i)
		}
		if err := v.Encode(sw); err != nil {
			return err
		}
	}
	return sw.WriteListEnd()
}

// Encode serializes a ReplayWorkflowActivityParams struct directly into bytes, without going
// through an intermediary type.
//
// An error is returned if a ReplayWorkflowActivityParams struct could not be encoded.
func (v *ReplayWorkflowActivityParams) Encode(sw stream.Writer) error {
	if err := sw.WriteStructBegin(); err != nil {
		return err
	}

	if v.Domain != nil {
		if err := sw.WriteFieldBegin(stream.FieldHeader{ID: 10, Type: wire.TBinary}); err != nil {
			return err
		}
		if err := sw.WriteString(*(v.Domain)); err != nil {
			return err
		}
		if err := sw.WriteFieldEnd(); err != nil {
			return err
		}
	}

	if v.Executions != nil {
		if err := sw.WriteFieldBegin(stream.FieldHeader{ID: 20, Type: wire.TList}); err != nil {
			return err
		}
		if err := _List_WorkflowExecution_Encode(v.Executions, sw); err != nil {
			return err
		}
		if err := sw.WriteFieldEnd(); err != nil {
			return err
		}
	}

	return sw.WriteStructEnd()
}

func _WorkflowExecution_Decode(sr stream.Reader) (*shared.WorkflowExecution, error) {
	var v shared.WorkflowExecution
	err := v.Decode(sr)
	return &v, err
}

func _List_WorkflowExecution_Decode(sr stream.Reader) ([]*shared.WorkflowExecution, error) {
	lh, err := sr.ReadListBegin()
	if err != nil {
		return nil, err
	}

	if lh.Type != wire.TStruct {
		for i := 0; i < lh.Length; i++ {
			if err := sr.Skip(lh.Type); err != nil {
				return nil, err
			}
		}
		return nil, sr.ReadListEnd()
	}

	o := make([]*shared.WorkflowExecution, 0, lh.Length)
	for i := 0; i < lh.Length; i++ {
		v, err := _WorkflowExecution_Decode(sr)
		if err != nil {
			return nil, err
		}
		o = append(o, v)
	}

	if err = sr.ReadListEnd(); err != nil {
		return nil, err
	}
	return o, err
}

// Decode deserializes a ReplayWorkflowActivityParams struct directly from its Thrift-level
// representation, without going through an intemediary type.
//
// An error is returned if a ReplayWorkflowActivityParams struct could not be generated from the wire
// representation.
func (v *ReplayWorkflowActivityParams) Decode(sr stream.Reader) error {

	if err := sr.ReadStructBegin(); err != nil {
		return err
	}

	fh, ok, err := sr.ReadFieldBegin()
	if err != nil {
		return err
	}

	for ok {
		switch {
		case fh.ID == 10 && fh.Type == wire.TBinary:
			var x string
			x, err = sr.ReadString()
			v.Domain = &x
			if err != nil {
				return err
			}

		case fh.ID == 20 && fh.Type == wire.TList:
			v.Executions, err = _List_WorkflowExecution_Decode(sr)
			if err != nil {
				return err
			}

		default:
			if err := sr.Skip(fh.Type); err != nil {
				return err
			}
		}

		if err := sr.ReadFieldEnd(); err != nil {
			return err
		}

		if fh, ok, err = sr.ReadFieldBegin(); err != nil {
			return err
		}
	}

	if err := sr.ReadStructEnd(); err != nil {
		return err
	}

	return nil
}

// String returns a readable string representation of a ReplayWorkflowActivityParams
// struct.
func (v *ReplayWorkflowActivityParams) String() string {
	if v == nil {
		return "<nil>"
	}

	var fields [2]string
	i := 0
	if v.Domain != nil {
		fields[i] = fmt.Sprintf("Domain: %v", *(v.Domain))
		i++
	}
	if v.Executions != nil {
		fields[i] = fmt.Sprintf("Executions: %v", v.Executions)
		i++
	}

	return fmt.Sprintf("ReplayWorkflowActivityParams{%v}", strings.Join(fields[:i], ", "))
}

func _String_EqualsPtr(lhs, rhs *string) bool {
	if lhs != nil && rhs != nil {

		x := *lhs
		y := *rhs
		return (x == y)
	}
	return lhs == nil && rhs == nil
}

func _List_WorkflowExecution_Equals(lhs, rhs []*shared.WorkflowExecution) bool {
	if len(lhs) != len(rhs) {
		return false
	}

	for i, lv := range lhs {
		rv := rhs[i]
		if !lv.Equals(rv) {
			return false
		}
	}

	return true
}

// Equals returns true if all the fields of this ReplayWorkflowActivityParams match the
// provided ReplayWorkflowActivityParams.
//
// This function performs a deep comparison.
func (v *ReplayWorkflowActivityParams) Equals(rhs *ReplayWorkflowActivityParams) bool {
	if v == nil {
		return rhs == nil
	} else if rhs == nil {
		return false
	}
	if !_String_EqualsPtr(v.Domain, rhs.Domain) {
		return false
	}
	if !((v.Executions == nil && rhs.Executions == nil) || (v.Executions != nil && rhs.Executions != nil && _List_WorkflowExecution_Equals(v.Executions, rhs.Executions))) {
		return false
	}

	return true
}

type _List_WorkflowExecution_Zapper []*shared.WorkflowExecution

// MarshalLogArray implements zapcore.ArrayMarshaler, enabling
// fast logging of _List_WorkflowExecution_Zapper.
func (l _List_WorkflowExecution_Zapper) MarshalLogArray(enc zapcore.ArrayEncoder) (err error) {
	for _, v := range l {
		err = multierr.Append(err, enc.AppendObject(v))
	}
	return err
}

// MarshalLogObject implements zapcore.ObjectMarshaler, enabling
// fast logging of ReplayWorkflowActivityParams.
func (v *ReplayWorkflowActivityParams) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {
	if v == nil {
		return nil
	}
	if v.Domain != nil {
		enc.AddString("domain", *v.Domain)
	}
	if v.Executions != nil {
		err = multierr.Append(err, enc.AddArray("executions", (_List_WorkflowExecution_Zapper)(v.Executions)))
	}
	return err
}

// GetDomain returns the value of Domain if it is set or its
// zero value if it is unset.
func (v *ReplayWorkflowActivityParams) GetDomain() (o string) {
	if v != nil && v.Domain != nil {
		return *v.Domain
	}

	return
}

// IsSetDomain returns true if Domain is not nil.
func (v *ReplayWorkflowActivityParams) IsSetDomain() bool {
	return v != nil && v.Domain != nil
}

// GetExecutions returns the value of Executions if it is set or its
// zero value if it is unset.
func (v *ReplayWorkflowActivityParams) GetExecutions() (o []*shared.WorkflowExecution) {
	if v != nil && v.Executions != nil {
		return v.Executions
	}

	return
}

// IsSetExecutions returns true if Executions is not nil.
func (v *ReplayWorkflowActivityParams) IsSetExecutions() bool {
	return v != nil && v.Executions != nil
}

type ReplayWorkflowActivityResult struct {
	Succeeded *int32 `json:"succeeded,omitempty"`
	Skipped   *int32 `json:"skipped,omitempty"`
	Failed    *int32 `json:"failed,omitempty"`
}

// ToWire translates a ReplayWorkflowActivityResult struct into a Thrift-level intermediate
// representation. This intermediate representation may be serialized
// into bytes using a ThriftRW protocol implementation.
//
// An error is returned if the struct or any of its fields failed to
// validate.
//
//	x, err := v.ToWire()
//	if err != nil {
//	  return err
//	}
//
//	if err := binaryProtocol.Encode(x, writer); err != nil {
//	  return err
//	}
func (v *ReplayWorkflowActivityResult) ToWire() (wire.Value, error) {
	var (
		fields [3]wire.Field
		i      int = 0
		w      wire.Value
		err    error
	)

	if v.Succeeded != nil {
		w, err = wire.NewValueI32(*(v.Succeeded)), error(nil)
		if err != nil {
			return w, err
		}
		fields[i] = wire.Field{ID: 10, Value: w}
		i++
	}
	if v.Skipped != nil {
		w, err = wire.NewValueI32(*(v.Skipped)), error(nil)
		if err != nil {
			return w, err
		}
		fields[i] = wire.Field{ID: 20, Value: w}
		i++
	}
	if v.Failed != nil {
		w, err = wire.NewValueI32(*(v.Failed)), error(nil)
		if err != nil {
			return w, err
		}
		fields[i] = wire.Field{ID: 30, Value: w}
		i++
	}

	return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil
}

// FromWire deserializes a ReplayWorkflowActivityResult struct from its Thrift-level
// representation. The Thrift-level representation may be obtained
// from a ThriftRW protocol implementation.
//
// An error is returned if we were unable to build a ReplayWorkflowActivityResult struct
// from the provided intermediate representation.
//
//	x, err := binaryProtocol.Decode(reader, wire.TStruct)
//	if err != nil {
//	  return nil, err
//	}
//
//	var v ReplayWorkflowActivityResult
//	if err := v.FromWire(x); err != nil {
//	  return nil, err
//	}
//	return &v, nil
func (v *ReplayWorkflowActivityResult) FromWire(w wire.Value) error {
	var err error

	for _, field := range w.GetStruct().Fields {
		switch field.ID {
		case 10:
			if field.Value.Type() == wire.TI32 {
				var x int32
				x, err = field.Value.GetI32(), error(nil)
				v.Succeeded = &x
				if err != nil {
					return err
				}

			}
		case 20:
			if field.Value.Type() == wire.TI32 {
				var x int32
				x, err = field.Value.GetI32(), error(nil)
				v.Skipped = &x
				if err != nil {
					return err
				}

			}
		case 30:
			if field.Value.Type() == wire.TI32 {
				var x int32
				x, err = field.Value.GetI32(), error(nil)
				v.Failed = &x
				if err != nil {
					return err
				}

			}
		}
	}

	return nil
}

// Encode serializes a ReplayWorkflowActivityResult struct directly into bytes, without going
// through an intermediary type.
//
// An error is returned if a ReplayWorkflowActivityResult struct could not be encoded.
func (v *ReplayWorkflowActivityResult) Encode(sw stream.Writer) error {
	if err := sw.WriteStructBegin(); err != nil {
		return err
	}

	if v.Succeeded != nil {
		if err := sw.WriteFieldBegin(stream.FieldHeader{ID: 10, Type: wire.TI32}); err != nil {
			return err
		}
		if err := sw.WriteInt32(*(v.Succeeded)); err != nil {
			return err
		}
		if err := sw.WriteFieldEnd(); err != nil {
			return err
		}
	}

	if v.Skipped != nil {
		if err := sw.WriteFieldBegin(stream.FieldHeader{ID: 20, Type: wire.TI32}); err != nil {
			return err
		}
		if err := sw.WriteInt32(*(v.Skipped)); err != nil {
			return err
		}
		if err := sw.WriteFieldEnd(); err != nil {
			return err
		}
	}

	if v.Failed != nil {
		if err := sw.WriteFieldBegin(stream.FieldHeader{ID: 30, Type: wire.TI32}); err != nil {
			return err
		}
		if err := sw.WriteInt32(*(v.Failed)); err != nil {
			return err
		}
		if err := sw.WriteFieldEnd(); err != nil {
			return err
		}
	}

	return sw.WriteStructEnd()
}

// Decode deserializes a ReplayWorkflowActivityResult struct directly from its Thrift-level
// representation, without going through an intemediary type.
//
// An error is returned if a ReplayWorkflowActivityResult struct could not be generated from the wire
// representation.
func (v *ReplayWorkflowActivityResult) Decode(sr stream.Reader) error {

	if err := sr.ReadStructBegin(); err != nil {
		return err
	}

	fh, ok, err := sr.ReadFieldBegin()
	if err != nil {
		return err
	}

	for ok {
		switch {
		case fh.ID == 10 && fh.Type == wire.TI32:
			var x int32
			x, err = sr.ReadInt32()
			v.Succeeded = &x
			if err != nil {
				return err
			}

		case fh.ID == 20 && fh.Type == wire.TI32:
			var x int32
			x, err = sr.ReadInt32()
			v.Skipped = &x
			if err != nil {
				return err
			}

		case fh.ID == 30 && fh.Type == wire.TI32:
			var x int32
			x, err = sr.ReadInt32()
			v.Failed = &x
			if err != nil {
				return err
			}

		default:
			if err := sr.Skip(fh.Type); err != nil {
				return err
			}
		}

		if err := sr.ReadFieldEnd(); err != nil {
			return err
		}

		if fh, ok, err = sr.ReadFieldBegin(); err != nil {
			return err
		}
	}

	if err := sr.ReadStructEnd(); err != nil {
		return err
	}

	return nil
}

// String returns a readable string representation of a ReplayWorkflowActivityResult
// struct.
func (v *ReplayWorkflowActivityResult) String() string {
	if v == nil {
		return "<nil>"
	}

	var fields [3]string
	i := 0
	if v.Succeeded != nil {
		fields[i] = fmt.Sprintf("Succeeded: %v", *(v.Succeeded))
		i++
	}
	if v.Skipped != nil {
		fields[i] = fmt.Sprintf("Skipped: %v", *(v.Skipped))
		i++
	}
	if v.Failed != nil {
		fields[i] = fmt.Sprintf("Failed: %v", *(v.Failed))
		i++
	}

	return fmt.Sprintf("ReplayWorkflowActivityResult{%v}", strings.Join(fields[:i], ", "))
}

// Equals returns true if all the fields of this ReplayWorkflowActivityResult match the
// provided ReplayWorkflowActivityResult.
//
// This function performs a deep comparison.
func (v *ReplayWorkflowActivityResult) Equals(rhs *ReplayWorkflowActivityResult) bool {
	if v == nil {
		return rhs == nil
	} else if rhs == nil {
		return false
	}
	if !_I32_EqualsPtr(v.Succeeded, rhs.Succeeded) {
		return false
	}
	if !_I32_EqualsPtr(v.Skipped, rhs.Skipped) {
		return false
	}
	if !_I32_EqualsPtr(v.Failed, rhs.Failed) {
		return false
	}

	return true
}

// MarshalLogObject implements zapcore.ObjectMarshaler, enabling
// fast logging of ReplayWorkflowActivityResult.
func (v *ReplayWorkflowActivityResult) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {
	if v == nil {
		return nil
	}
	if v.Succeeded != nil {
		enc.AddInt32("succeeded", *v.Succeeded)
	}
	if v.Skipped != nil {
		enc.AddInt32("skipped", *v.Skipped)
	}
	if v.Failed != nil {
		enc.AddInt32("failed", *v.Failed)
	}
	return err
}

// GetSucceeded returns the value of Succeeded if it is set or its
// zero value if it is unset.
func (v *ReplayWorkflowActivityResult) GetSucceeded() (o int32) {
	if v != nil && v.Succeeded != nil {
		return *v.Succeeded
	}

	return
}

// IsSetSucceeded returns true if Succeeded is not nil.
func (v *ReplayWorkflowActivityResult) IsSetSucceeded() bool {
	return v != nil && v.Succeeded != nil
}

// GetSkipped returns the value of Skipped if it is set or its
// zero value if it is unset.
func (v *ReplayWorkflowActivityResult) GetSkipped() (o int32) {
	if v != nil && v.Skipped != nil {
		return *v.Skipped
	}

	return
}

// IsSetSkipped returns true if Skipped is not nil.
func (v *ReplayWorkflowActivityResult) IsSetSkipped() bool {
	return v != nil && v.Skipped != nil
}

// GetFailed returns the value of Failed if it is set or its
// zero value if it is unset.
func (v *ReplayWorkflowActivityResult) GetFailed() (o int32) {
	if v != nil && v.Failed != nil {
		return *v.Failed
	}

	return
}

// IsSetFailed returns true if Failed is not nil.
func (v *ReplayWorkflowActivityResult) IsSetFailed() bool {
	return v != nil && v.Failed != nil
}

type ScanWorkflowActivityParams struct {
	Domain        *string  `json:"domain,omitempty"`
	WorkflowQuery *string  `json:"workflowQuery,omitempty"`
	NextPageToken []byte   `json:"nextPageToken,omitempty"`
	PageSize      *int32   `json:"pageSize,omitempty"`
	SamplingRate  *float64 `json:"samplingRate,omitempty"`
}

// ToWire translates a ScanWorkflowActivityParams struct into a Thrift-level intermediate
// representation. This intermediate representation may be serialized
// into bytes using a ThriftRW protocol implementation.
//
// An error is returned if the struct or any of its fields failed to
// validate.
//
//	x, err := v.ToWire()
//	if err != nil {
//	  return err
//	}
//
//	if err := binaryProtocol.Encode(x, writer); err != nil {
//	  return err
//	}
func (v *ScanWorkflowActivityParams) ToWire() (wire.Value, error) {
	var (
		fields [5]wire.Field
		i      int = 0
		w      wire.Value
		err    error
	)

	if v.Domain != nil {
		w, err = wire.NewValueString(*(v.Domain)), error(nil)
		if err != nil {
			return w, err
		}
		fields[i] = wire.Field{ID: 10, Value: w}
		i++
	}
	if v.WorkflowQuery != nil {
		w, err = wire.NewValueString(*(v.WorkflowQuery)), error(nil)
		if err != nil {
			return w, err
		}
		fields[i] = wire.Field{ID: 20, Value: w}
		i++
	}
	if v.NextPageToken != nil {
		w, err = wire.NewValueBinary(v.NextPageToken), error(nil)
		if err != nil {
			return w, err
		}
		fields[i] = wire.Field{ID: 30, Value: w}
		i++
	}
	if v.PageSize != nil {
		w, err = wire.NewValueI32(*(v.PageSize)), error(nil)
		if err != nil {
			return w, err
		}
		fields[i] = wire.Field{ID: 40, Value: w}
		i++
	}
	if v.SamplingRate != nil {
		w, err = wire.NewValueDouble(*(v.SamplingRate)), error(nil)
		if err != nil {
			return w, err
		}
		fields[i] = wire.Field{ID: 50, Value: w}
		i++
	}

	return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil
}

// FromWire deserializes a ScanWorkflowActivityParams struct from its Thrift-level
// representation. The Thrift-level representation may be obtained
// from a ThriftRW protocol implementation.
//
// An error is returned if we were unable to build a ScanWorkflowActivityParams struct
// from the provided intermediate representation.
//
//	x, err := binaryProtocol.Decode(reader, wire.TStruct)
//	if err != nil {
//	  return nil, err
//	}
//
//	var v ScanWorkflowActivityParams
//	if err := v.FromWire(x); err != nil {
//	  return nil, err
//	}
//	return &v, nil
func (v *ScanWorkflowActivityParams) FromWire(w wire.Value) error {
	var err error

	for _, field := range w.GetStruct().Fields {
		switch field.ID {
		case 10:
			if field.Value.Type() == wire.TBinary {
				var x string
				x, err = field.Value.GetString(), error(nil)
				v.Domain = &x
				if err != nil {
					return err
				}

			}
		case 20:
			if field.Value.Type() == wire.TBinary {
				var x string
				x, err = field.Value.GetString(), error(nil)
				v.WorkflowQuery = &x
				if err != nil {
					return err
				}

			}
		case 30:
			if field.Value.Type() == wire.TBinary {
				v.NextPageToken, err = field.Value.GetBinary(), error(nil)
				if err != nil {
					return err
				}

			}
		case 40:
			if field.Value.Type() == wire.TI32 {
				var x int32
				x, err = field.Value.GetI32(), error(nil)
				v.PageSize = &x
				if err != nil {
					return err
				}

			}
		case 50:
			if field.Value.Type() == wire.TDouble {
				var x float64
				x, err = field.Value.GetDouble(), error(nil)
				v.SamplingRate = &x
				if err != nil {
					return err
				}

			}
		}
	}

	return nil
}

// Encode serializes a ScanWorkflowActivityParams struct directly into bytes, without going
// through an intermediary type.
//
// An error is returned if a ScanWorkflowActivityParams struct could not be encoded.
func (v *ScanWorkflowActivityParams) Encode(sw stream.Writer) error {
	if err := sw.WriteStructBegin(); err != nil {
		return err
	}

	if v.Domain != nil {
		if err := sw.WriteFieldBegin(stream.FieldHeader{ID: 10, Type: wire.TBinary}); err != nil {
			return err
		}
		if err := sw.WriteString(*(v.Domain)); err != nil {
			return err
		}
		if err := sw.WriteFieldEnd(); err != nil {
			return err
		}
	}

	if v.WorkflowQuery != nil {
		if err := sw.WriteFieldBegin(stream.FieldHeader{ID: 20, Type: wire.TBinary}); err != nil {
			return err
		}
		if err := sw.WriteString(*(v.WorkflowQuery)); err != nil {
			return err
		}
		if err := sw.WriteFieldEnd(); err != nil {
			return err
		}
	}

	if v.NextPageToken != nil {
		if err := sw.WriteFieldBegin(stream.FieldHeader{ID: 30, Type: wire.TBinary}); err != nil {
			return err
		}
		if err := sw.WriteBinary(v.NextPageToken); err != nil {
			return err
		}
		if err := sw.WriteFieldEnd(); err != nil {
			return err
		}
	}

	if v.PageSize != nil {
		if err := sw.WriteFieldBegin(stream.FieldHeader{ID: 40, Type: wire.TI32}); err != nil {
			return err
		}
		if err := sw.WriteInt32(*(v.PageSize)); err != nil {
			return err
		}
		if err := sw.WriteFieldEnd(); err != nil {
			return err
		}
	}

	if v.SamplingRate != nil {
		if err := sw.WriteFieldBegin(stream.FieldHeader{ID: 50, Type: wire.TDouble}); err != nil {
			return err
		}
		if err := sw.WriteDouble(*(v.SamplingRate)); err != nil {
			return err
		}
		if err := sw.WriteFieldEnd(); err != nil {
			return err
		}
	}

	return sw.WriteStructEnd()
}

// Decode deserializes a ScanWorkflowActivityParams struct directly from its Thrift-level
// representation, without going through an intemediary type.
//
// An error is returned if a ScanWorkflowActivityParams struct could not be generated from the wire
// representation.
func (v *ScanWorkflowActivityParams) Decode(sr stream.Reader) error {

	if err := sr.ReadStructBegin(); err != nil {
		return err
	}

	fh, ok, err := sr.ReadFieldBegin()
	if err != nil {
		return err
	}

	for ok {
		switch {
		case fh.ID == 10 && fh.Type == wire.TBinary:
			var x string
			x, err = sr.ReadString()
			v.Domain = &x
			if err != nil {
				return err
			}

		case fh.ID == 20 && fh.Type == wire.TBinary:
			var x string
			x, err = sr.ReadString()
			v.WorkflowQuery = &x
			if err != nil {
				return err
			}

		case fh.ID == 30 && fh.Type == wire.TBinary:
			v.NextPageToken, err = sr.ReadBinary()
			if err != nil {
				return err
			}

		case fh.ID == 40 && fh.Type == wire.TI32:
			var x int32
			x, err = sr.ReadInt32()
			v.PageSize = &x
			if err != nil {
				return err
			}

		case fh.ID == 50 && fh.Type == wire.TDouble:
			var x float64
			x, err = sr.ReadDouble()
			v.SamplingRate = &x
			if err != nil {
				return err
			}

		default:
			if err := sr.Skip(fh.Type); err != nil {
				return err
			}
		}

		if err := sr.ReadFieldEnd(); err != nil {
			return err
		}

		if fh, ok, err = sr.ReadFieldBegin(); err != nil {
			return err
		}
	}

	if err := sr.ReadStructEnd(); err != nil {
		return err
	}

	return nil
}

// String returns a readable string representation of a ScanWorkflowActivityParams
// struct.
func (v *ScanWorkflowActivityParams) String() string {
	if v == nil {
		return "<nil>"
	}

	var fields [5]string
	i := 0
	if v.Domain != nil {
		fields[i] = fmt.Sprintf("Domain: %v", *(v.Domain))
		i++
	}
	if v.WorkflowQuery != nil {
		fields[i] = fmt.Sprintf("WorkflowQuery: %v", *(v.WorkflowQuery))
		i++
	}
	if v.NextPageToken != nil {
		fields[i] = fmt.Sprintf("NextPageToken: %v", v.NextPageToken)
		i++
	}
	if v.PageSize != nil {
		fields[i] = fmt.Sprintf("PageSize: %v", *(v.PageSize))
		i++
	}
	if v.SamplingRate != nil {
		fields[i] = fmt.Sprintf("SamplingRate: %v", *(v.SamplingRate))
		i++
	}

	return fmt.Sprintf("ScanWorkflowActivityParams{%v}", strings.Join(fields[:i], ", "))
}

func _Double_EqualsPtr(lhs, rhs *float64) bool {
	if lhs != nil && rhs != nil {

		x := *lhs
		y := *rhs
		return (x == y)
	}
	return lhs == nil && rhs == nil
}

// Equals returns true if all the fields of this ScanWorkflowActivityParams match the
// provided ScanWorkflowActivityParams.
//
// This function performs a deep comparison.
func (v *ScanWorkflowActivityParams) Equals(rhs *ScanWorkflowActivityParams) bool {
	if v == nil {
		return rhs == nil
	} else if rhs == nil {
		return false
	}
	if !_String_EqualsPtr(v.Domain, rhs.Domain) {
		return false
	}
	if !_String_EqualsPtr(v.WorkflowQuery, rhs.WorkflowQuery) {
		return false
	}
	if !((v.NextPageToken == nil && rhs.NextPageToken == nil) || (v.NextPageToken != nil && rhs.NextPageToken != nil && bytes.Equal(v.NextPageToken, rhs.NextPageToken))) {
		return false
	}
	if !_I32_EqualsPtr(v.PageSize, rhs.PageSize) {
		return false
	}
	if !_Double_EqualsPtr(v.SamplingRate, rhs.SamplingRate) {
		return false
	}

	return true
}

// MarshalLogObject implements zapcore.ObjectMarshaler, enabling
// fast logging of ScanWorkflowActivityParams.
func (v *ScanWorkflowActivityParams) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {
	if v == nil {
		return nil
	}
	if v.Domain != nil {
		enc.AddString("domain", *v.Domain)
	}
	if v.WorkflowQuery != nil {
		enc.AddString("workflowQuery", *v.WorkflowQuery)
	}
	if v.NextPageToken != nil {
		enc.AddString("nextPageToken", base64.StdEncoding.EncodeToString(v.NextPageToken))
	}
	if v.PageSize != nil {
		enc.AddInt32("pageSize", *v.PageSize)
	}
	if v.SamplingRate != nil {
		enc.AddFloat64("samplingRate", *v.SamplingRate)
	}
	return err
}

// GetDomain returns the value of Domain if it is set or its
// zero value if it is unset.
func (v *ScanWorkflowActivityParams) GetDomain() (o string) {
	if v != nil && v.Domain != nil {
		return *v.Domain
	}

	return
}

// IsSetDomain returns true if Domain is not nil.
func (v *ScanWorkflowActivityParams) IsSetDomain() bool {
	return v != nil && v.Domain != nil
}

// GetWorkflowQuery returns the value of WorkflowQuery if it is set or its
// zero value if it is unset.
func (v *ScanWorkflowActivityParams) GetWorkflowQuery() (o string) {
	if v != nil && v.WorkflowQuery != nil {
		return *v.WorkflowQuery
	}

	return
}

// IsSetWorkflowQuery returns true if WorkflowQuery is not nil.
func (v *ScanWorkflowActivityParams) IsSetWorkflowQuery() bool {
	return v != nil && v.WorkflowQuery != nil
}

// GetNextPageToken returns the value of NextPageToken if it is set or its
// zero value if it is unset.
func (v *ScanWorkflowActivityParams) GetNextPageToken() (o []byte) {
	if v != nil && v.NextPageToken != nil {
		return v.NextPageToken
	}

	return
}

// IsSetNextPageToken returns true if NextPageToken is not nil.
func (v *ScanWorkflowActivityParams) IsSetNextPageToken() bool {
	return v != nil && v.NextPageToken != nil
}

// GetPageSize returns the value of PageSize if it is set or its
// zero value if it is unset.
func (v *ScanWorkflowActivityParams) GetPageSize() (o int32) {
	if v != nil && v.PageSize != nil {
		return *v.PageSize
	}

	return
}

// IsSetPageSize returns true if PageSize is not nil.
func (v *ScanWorkflowActivityParams) IsSetPageSize() bool {
	return v != nil && v.PageSize != nil
}

// GetSamplingRate returns the value of SamplingRate if it is set or its
// zero value if it is unset.
func (v *ScanWorkflowActivityParams) GetSamplingRate() (o float64) {
	if v != nil && v.SamplingRate != nil {
		return *v.SamplingRate
	}

	return
}

// IsSetSamplingRate returns true if SamplingRate is not nil.
func (v *ScanWorkflowActivityParams) IsSetSamplingRate() bool {
	return v != nil && v.SamplingRate != nil
}

type ScanWorkflowActivityResult struct {
	Executions    []*shared.WorkflowExecution `json:"executions,omitempty"`
	NextPageToken []byte                      `json:"nextPageToken,omitempty"`
}

// ToWire translates a ScanWorkflowActivityResult struct into a Thrift-level intermediate
// representation. This intermediate representation may be serialized
// into bytes using a ThriftRW protocol implementation.
//
// An error is returned if the struct or any of its fields failed to
// validate.
//
//	x, err := v.ToWire()
//	if err != nil {
//	  return err
//	}
//
//	if err := binaryProtocol.Encode(x, writer); err != nil {
//	  return err
//	}
func (v *ScanWorkflowActivityResult) ToWire() (wire.Value, error) {
	var (
		fields [2]wire.Field
		i      int = 0
		w      wire.Value
		err    error
	)

	if v.Executions != nil {
		w, err = wire.NewValueList(_List_WorkflowExecution_ValueList(v.Executions)), error(nil)
		if err != nil {
			return w, err
		}
		fields[i] = wire.Field{ID: 10, Value: w}
		i++
	}
	if v.NextPageToken != nil {
		w, err = wire.NewValueBinary(v.NextPageToken), error(nil)
		if err != nil {
			return w, err
		}
		fields[i] = wire.Field{ID: 20, Value: w}
		i++
	}

	return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil
}

// FromWire deserializes a ScanWorkflowActivityResult struct from its Thrift-level
// representation. The Thrift-level representation may be obtained
// from a ThriftRW protocol implementation.
//
// An error is returned if we were unable to build a ScanWorkflowActivityResult struct
// from the provided intermediate representation.
//
//	x, err := binaryProtocol.Decode(reader, wire.TStruct)
//	if err != nil {
//	  return nil, err
//	}
//
//	var v ScanWorkflowActivityResult
//	if err := v.FromWire(x); err != nil {
//	  return nil, err
//	}
//	return &v, nil
func (v *ScanWorkflowActivityResult) FromWire(w wire.Value) error {
	var err error

	for _, field := range w.GetStruct().Fields {
		switch field.ID {
		case 10:
			if field.Value.Type() == wire.TList {
				v.Executions, err = _List_WorkflowExecution_Read(field.Value.GetList())
				if err != nil {
					return err
				}

			}
		case 20:
			if field.Value.Type() == wire.TBinary {
				v.NextPageToken, err = field.Value.GetBinary(), error(nil)
				if err != nil {
					return err
				}

			}
		}
	}

	return nil
}

// Encode serializes a ScanWorkflowActivityResult struct directly into bytes, without going
// through an intermediary type.
//
// An error is returned if a ScanWorkflowActivityResult struct could not be encoded.
func (v *ScanWorkflowActivityResult) Encode(sw stream.Writer) error {
	if err := sw.WriteStructBegin(); err != nil {
		return err
	}

	if v.Executions != nil {
		if err := sw.WriteFieldBegin(stream.FieldHeader{ID: 10, Type: wire.TList}); err != nil {
			return err
		}
		if err := _List_WorkflowExecution_Encode(v.Executions, sw); err != nil {
			return err
		}
		if err := sw.WriteFieldEnd(); err != nil {
			return err
		}
	}

	if v.NextPageToken != nil {
		if err := sw.WriteFieldBegin(stream.FieldHeader{ID: 20, Type: wire.TBinary}); err != nil {
			return err
		}
		if err := sw.WriteBinary(v.NextPageToken); err != nil {
			return err
		}
		if err := sw.WriteFieldEnd(); err != nil {
			return err
		}
	}

	return sw.WriteStructEnd()
}

// Decode deserializes a ScanWorkflowActivityResult struct directly from its Thrift-level
// representation, without going through an intemediary type.
//
// An error is returned if a ScanWorkflowActivityResult struct could not be generated from the wire
// representation.
func (v *ScanWorkflowActivityResult) Decode(sr stream.Reader) error {

	if err := sr.ReadStructBegin(); err != nil {
		return err
	}

	fh, ok, err := sr.ReadFieldBegin()
	if err != nil {
		return err
	}

	for ok {
		switch {
		case fh.ID == 10 && fh.Type == wire.TList:
			v.Executions, err = _List_WorkflowExecution_Decode(sr)
			if err != nil {
				return err
			}

		case fh.ID == 20 && fh.Type == wire.TBinary:
			v.NextPageToken, err = sr.ReadBinary()
			if err != nil {
				return err
			}

		default:
			if err := sr.Skip(fh.Type); err != nil {
				return err
			}
		}

		if err := sr.ReadFieldEnd(); err != nil {
			return err
		}

		if fh, ok, err = sr.ReadFieldBegin(); err != nil {
			return err
		}
	}

	if err := sr.ReadStructEnd(); err != nil {
		return err
	}

	return nil
}

// String returns a readable string representation of a ScanWorkflowActivityResult
// struct.
func (v *ScanWorkflowActivityResult) String() string {
	if v == nil {
		return "<nil>"
	}

	var fields [2]string
	i := 0
	if v.Executions != nil {
		fields[i] = fmt.Sprintf("Executions: %v", v.Executions)
		i++
	}
	if v.NextPageToken != nil {
		fields[i] = fmt.Sprintf("NextPageToken: %v", v.NextPageToken)
		i++
	}

	return fmt.Sprintf("ScanWorkflowActivityResult{%v}", strings.Join(fields[:i], ", "))
}

// Equals returns true if all the fields of this ScanWorkflowActivityResult match the
// provided ScanWorkflowActivityResult.
//
// This function performs a deep comparison.
func (v *ScanWorkflowActivityResult) Equals(rhs *ScanWorkflowActivityResult) bool {
	if v == nil {
		return rhs == nil
	} else if rhs == nil {
		return false
	}
	if !((v.Executions == nil && rhs.Executions == nil) || (v.Executions != nil && rhs.Executions != nil && _List_WorkflowExecution_Equals(v.Executions, rhs.Executions))) {
		return false
	}
	if !((v.NextPageToken == nil && rhs.NextPageToken == nil) || (v.NextPageToken != nil && rhs.NextPageToken != nil && bytes.Equal(v.NextPageToken, rhs.NextPageToken))) {
		return false
	}

	return true
}

// MarshalLogObject implements zapcore.ObjectMarshaler, enabling
// fast logging of ScanWorkflowActivityResult.
func (v *ScanWorkflowActivityResult) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {
	if v == nil {
		return nil
	}
	if v.Executions != nil {
		err = multierr.Append(err, enc.AddArray("executions", (_List_WorkflowExecution_Zapper)(v.Executions)))
	}
	if v.NextPageToken != nil {
		enc.AddString("nextPageToken", base64.StdEncoding.EncodeToString(v.NextPageToken))
	}
	return err
}

// GetExecutions returns the value of Executions if it is set or its
// zero value if it is unset.
func (v *ScanWorkflowActivityResult) GetExecutions() (o []*shared.WorkflowExecution) {
	if v != nil && v.Executions != nil {
		return v.Executions
	}

	return
}

// IsSetExecutions returns true if Executions is not nil.
func (v *ScanWorkflowActivityResult) IsSetExecutions() bool {
	return v != nil && v.Executions != nil
}

// GetNextPageToken returns the value of NextPageToken if it is set or its
// zero value if it is unset.
func (v *ScanWorkflowActivityResult) GetNextPageToken() (o []byte) {
	if v != nil && v.NextPageToken != nil {
		return v.NextPageToken
	}

	return
}

// IsSetNextPageToken returns true if NextPageToken is not nil.
func (v *ScanWorkflowActivityResult) IsSetNextPageToken() bool {
	return v != nil && v.NextPageToken != nil
}

type WorkflowParams struct {
	Domain        *string         `json:"domain,omitempty"`
	TaskList      *string         `json:"taskList,omitempty"`
	WorkflowQuery *string         `json:"workflowQuery,omitempty"`
	NextPageToken []byte          `json:"nextPageToken,omitempty"`
	SamplingRate  *float64        `json:"samplingRate,omitempty"`
	ShadowMode    *Mode           `json:"shadowMode,omitempty"`
	ExitCondition *ExitCondition  `json:"exitCondition,omitempty"`
	Concurrency   *int32          `json:"concurrency,omitempty"`
	LastRunResult *WorkflowResult `json:"lastRunResult,omitempty"`
}

// ToWire translates a WorkflowParams struct into a Thrift-level intermediate
// representation. This intermediate representation may be serialized
// into bytes using a ThriftRW protocol implementation.
//
// An error is returned if the struct or any of its fields failed to
// validate.
//
//	x, err := v.ToWire()
//	if err != nil {
//	  return err
//	}
//
//	if err := binaryProtocol.Encode(x, writer); err != nil {
//	  return err
//	}
func (v *WorkflowParams) ToWire() (wire.Value, error) {
	var (
		fields [9]wire.Field
		i      int = 0
		w      wire.Value
		err    error
	)

	if v.Domain != nil {
		w, err = wire.NewValueString(*(v.Domain)), error(nil)
		if err != nil {
			return w, err
		}
		fields[i] = wire.Field{ID: 10, Value: w}
		i++
	}
	if v.TaskList != nil {
		w, err = wire.NewValueString(*(v.TaskList)), error(nil)
		if err != nil {
			return w, err
		}
		fields[i] = wire.Field{ID: 20, Value: w}
		i++
	}
	if v.WorkflowQuery != nil {
		w, err = wire.NewValueString(*(v.WorkflowQuery)), error(nil)
		if err != nil {
			return w, err
		}
		fields[i] = wire.Field{ID: 30, Value: w}
		i++
	}
	if v.NextPageToken != nil {
		w, err = wire.NewValueBinary(v.NextPageToken), error(nil)
		if err != nil {
			return w, err
		}
		fields[i] = wire.Field{ID: 40, Value: w}
		i++
	}
	if v.SamplingRate != nil {
		w, err = wire.NewValueDouble(*(v.SamplingRate)), error(nil)
		if err != nil {
			return w, err
		}
		fields[i] = wire.Field{ID: 50, Value: w}
		i++
	}
	if v.ShadowMode != nil {
		w, err = v.ShadowMode.ToWire()
		if err != nil {
			return w, err
		}
		fields[i] = wire.Field{ID: 60, Value: w}
		i++
	}
	if v.ExitCondition != nil {
		w, err = v.ExitCondition.ToWire()
		if err != nil {
			return w, err
		}
		fields[i] = wire.Field{ID: 70, Value: w}
		i++
	}
	if v.Concurrency != nil {
		w, err = wire.NewValueI32(*(v.Concurrency)), error(nil)
		if err != nil {
			return w, err
		}
		fields[i] = wire.Field{ID: 80, Value: w}
		i++
	}
	if v.LastRunResult != nil {
		w, err = v.LastRunResult.ToWire()
		if err != nil {
			return w, err
		}
		fields[i] = wire.Field{ID: 90, Value: w}
		i++
	}

	return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil
}

func _Mode_Read(w wire.Value) (Mode, error) {
	var v Mode
	err := v.FromWire(w)
	return v, err
}

func _ExitCondition_Read(w wire.Value) (*ExitCondition, error) {
	var v ExitCondition
	err := v.FromWire(w)
	return &v, err
}

func _WorkflowResult_Read(w wire.Value) (*WorkflowResult, error) {
	var v WorkflowResult
	err := v.FromWire(w)
	return &v, err
}

// FromWire deserializes a WorkflowParams struct from its Thrift-level
// representation. The Thrift-level representation may be obtained
// from a ThriftRW protocol implementation.
//
// An error is returned if we were unable to build a WorkflowParams struct
// from the provided intermediate representation.
//
//	x, err := binaryProtocol.Decode(reader, wire.TStruct)
//	if err != nil {
//	  return nil, err
//	}
//
//	var v WorkflowParams
//	if err := v.FromWire(x); err != nil {
//	  return nil, err
//	}
//	return &v, nil
func (v *WorkflowParams) FromWire(w wire.Value) error {
	var err error

	for _, field := range w.GetStruct().Fields {
		switch field.ID {
		case 10:
			if field.Value.Type() == wire.TBinary {
				var x string
				x, err = field.Value.GetString(), error(nil)
				v.Domain = &x
				if err != nil {
					return err
				}

			}
		case 20:
			if field.Value.Type() == wire.TBinary {
				var x string
				x, err = field.Value.GetString(), error(nil)
				v.TaskList = &x
				if err != nil {
					return err
				}

			}
		case 30:
			if field.Value.Type() == wire.TBinary {
				var x string
				x, err = field.Value.GetString(), error(nil)
				v.WorkflowQuery = &x
				if err != nil {
					return err
				}

			}
		case 40:
			if field.Value.Type() == wire.TBinary {
				v.NextPageToken, err = field.Value.GetBinary(), error(nil)
				if err != nil {
					return err
				}

			}
		case 50:
			if field.Value.Type() == wire.TDouble {
				var x float64
				x, err = field.Value.GetDouble(), error(nil)
				v.SamplingRate = &x
				if err != nil {
					return err
				}

			}
		case 60:
			if field.Value.Type() == wire.TI32 {
				var x Mode
				x, err = _Mode_Read(field.Value)
				v.ShadowMode = &x
				if err != nil {
					return err
				}

			}
		case 70:
			if field.Value.Type() == wire.TStruct {
				v.ExitCondition, err = _ExitCondition_Read(field.Value)
				if err != nil {
					return err
				}

			}
		case 80:
			if field.Value.Type() == wire.TI32 {
				var x int32
				x, err = field.Value.GetI32(), error(nil)
				v.Concurrency = &x
				if err != nil {
					return err
				}

			}
		case 90:
			if field.Value.Type() == wire.TStruct {
				v.LastRunResult, err = _WorkflowResult_Read(field.Value)
				if err != nil {
					return err
				}

			}
		}
	}

	return nil
}

// Encode serializes a WorkflowParams struct directly into bytes, without going
// through an intermediary type.
//
// An error is returned if a WorkflowParams struct could not be encoded.
func (v *WorkflowParams) Encode(sw stream.Writer) error {
	if err := sw.WriteStructBegin(); err != nil {
		return err
	}

	if v.Domain != nil {
		if err := sw.WriteFieldBegin(stream.FieldHeader{ID: 10, Type: wire.TBinary}); err != nil {
			return err
		}
		if err := sw.WriteString(*(v.Domain)); err != nil {
			return err
		}
		if err := sw.WriteFieldEnd(); err != nil {
			return err
		}
	}

	if v.TaskList != nil {
		if err := sw.WriteFieldBegin(stream.FieldHeader{ID: 20, Type: wire.TBinary}); err != nil {
			return err
		}
		if err := sw.WriteString(*(v.TaskList)); err != nil {
			return err
		}
		if err := sw.WriteFieldEnd(); err != nil {
			return err
		}
	}

	if v.WorkflowQuery != nil {
		if err := sw.WriteFieldBegin(stream.FieldHeader{ID: 30, Type: wire.TBinary}); err != nil {
			return err
		}
		if err := sw.WriteString(*(v.WorkflowQuery)); err != nil {
			return err
		}
		if err := sw.WriteFieldEnd(); err != nil {
			return err
		}
	}

	if v.NextPageToken != nil {
		if err := sw.WriteFieldBegin(stream.FieldHeader{ID: 40, Type: wire.TBinary}); err != nil {
			return err
		}
		if err := sw.WriteBinary(v.NextPageToken); err != nil {
			return err
		}
		if err := sw.WriteFieldEnd(); err != nil {
			return err
		}
	}

	if v.SamplingRate != nil {
		if err := sw.WriteFieldBegin(stream.FieldHeader{ID: 50, Type: wire.TDouble}); err != nil {
			return err
		}
		if err := sw.WriteDouble(*(v.SamplingRate)); err != nil {
			return err
		}
		if err := sw.WriteFieldEnd(); err != nil {
			return err
		}
	}

	if v.ShadowMode != nil {
		if err := sw.WriteFieldBegin(stream.FieldHeader{ID: 60, Type: wire.TI32}); err != nil {
			return err
		}
		if err := v.ShadowMode.Encode(sw); err != nil {
			return err
		}
		if err := sw.WriteFieldEnd(); err != nil {
			return err
		}
	}

	if v.ExitCondition != nil {
		if err := sw.WriteFieldBegin(stream.FieldHeader{ID: 70, Type: wire.TStruct}); err != nil {
			return err
		}
		if err := v.ExitCondition.Encode(sw); err != nil {
			return err
		}
		if err := sw.WriteFieldEnd(); err != nil {
			return err
		}
	}

	if v.Concurrency != nil {
		if err := sw.WriteFieldBegin(stream.FieldHeader{ID: 80, Type: wire.TI32}); err != nil {
			return err
		}
		if err := sw.WriteInt32(*(v.Concurrency)); err != nil {
			return err
		}
		if err := sw.WriteFieldEnd(); err != nil {
			return err
		}
	}

	if v.LastRunResult != nil {
		if err := sw.WriteFieldBegin(stream.FieldHeader{ID: 90, Type: wire.TStruct}); err != nil {
			return err
		}
		if err := v.LastRunResult.Encode(sw); err != nil {
			return err
		}
		if err := sw.WriteFieldEnd(); err != nil {
			return err
		}
	}

	return sw.WriteStructEnd()
}

func _Mode_Decode(sr stream.Reader) (Mode, error) {
	var v Mode
	err := v.Decode(sr)
	return v, err
}

func _ExitCondition_Decode(sr stream.Reader) (*ExitCondition, error) {
	var v ExitCondition
	err := v.Decode(sr)
	return &v, err
}

func _WorkflowResult_Decode(sr stream.Reader) (*WorkflowResult, error) {
	var v WorkflowResult
	err := v.Decode(sr)
	return &v, err
}

// Decode deserializes a WorkflowParams struct directly from its Thrift-level
// representation, without going through an intemediary type.
//
// An error is returned if a WorkflowParams struct could not be generated from the wire
// representation.
func (v *WorkflowParams) Decode(sr stream.Reader) error {

	if err := sr.ReadStructBegin(); err != nil {
		return err
	}

	fh, ok, err := sr.ReadFieldBegin()
	if err != nil {
		return err
	}

	for ok {
		switch {
		case fh.ID == 10 && fh.Type == wire.TBinary:
			var x string
			x, err = sr.ReadString()
			v.Domain = &x
			if err != nil {
				return err
			}

		case fh.ID == 20 && fh.Type == wire.TBinary:
			var x string
			x, err = sr.ReadString()
			v.TaskList = &x
			if err != nil {
				return err
			}

		case fh.ID == 30 && fh.Type == wire.TBinary:
			var x string
			x, err = sr.ReadString()
			v.WorkflowQuery = &x
			if err != nil {
				return err
			}

		case fh.ID == 40 && fh.Type == wire.TBinary:
			v.NextPageToken, err = sr.ReadBinary()
			if err != nil {
				return err
			}

		case fh.ID == 50 && fh.Type == wire.TDouble:
			var x float64
			x, err = sr.ReadDouble()
			v.SamplingRate = &x
			if err != nil {
				return err
			}

		case fh.ID == 60 && fh.Type == wire.TI32:
			var x Mode
			x, err = _Mode_Decode(sr)
			v.ShadowMode = &x
			if err != nil {
				return err
			}

		case fh.ID == 70 && fh.Type == wire.TStruct:
			v.ExitCondition, err = _ExitCondition_Decode(sr)
			if err != nil {
				return err
			}

		case fh.ID == 80 && fh.Type == wire.TI32:
			var x int32
			x, err = sr.ReadInt32()
			v.Concurrency = &x
			if err != nil {
				return err
			}

		case fh.ID == 90 && fh.Type == wire.TStruct:
			v.LastRunResult, err = _WorkflowResult_Decode(sr)
			if err != nil {
				return err
			}

		default:
			if err := sr.Skip(fh.Type); err != nil {
				return err
			}
		}

		if err := sr.ReadFieldEnd(); err != nil {
			return err
		}

		if fh, ok, err = sr.ReadFieldBegin(); err != nil {
			return err
		}
	}

	if err := sr.ReadStructEnd(); err != nil {
		return err
	}

	return nil
}

// String returns a readable string representation of a WorkflowParams
// struct.
func (v *WorkflowParams) String() string {
	if v == nil {
		return "<nil>"
	}

	var fields [9]string
	i := 0
	if v.Domain != nil {
		fields[i] = fmt.Sprintf("Domain: %v", *(v.Domain))
		i++
	}
	if v.TaskList != nil {
		fields[i] = fmt.Sprintf("TaskList: %v", *(v.TaskList))
		i++
	}
	if v.WorkflowQuery != nil {
		fields[i] = fmt.Sprintf("WorkflowQuery: %v", *(v.WorkflowQuery))
		i++
	}
	if v.NextPageToken != nil {
		fields[i] = fmt.Sprintf("NextPageToken: %v", v.NextPageToken)
		i++
	}
	if v.SamplingRate != nil {
		fields[i] = fmt.Sprintf("SamplingRate: %v", *(v.SamplingRate))
		i++
	}
	if v.ShadowMode != nil {
		fields[i] = fmt.Sprintf("ShadowMode: %v", *(v.ShadowMode))
		i++
	}
	if v.ExitCondition != nil {
		fields[i] = fmt.Sprintf("ExitCondition: %v", v.ExitCondition)
		i++
	}
	if v.Concurrency != nil {
		fields[i] = fmt.Sprintf("Concurrency: %v", *(v.Concurrency))
		i++
	}
	if v.LastRunResult != nil {
		fields[i] = fmt.Sprintf("LastRunResult: %v", v.LastRunResult)
		i++
	}

	return fmt.Sprintf("WorkflowParams{%v}", strings.Join(fields[:i], ", "))
}

func _Mode_EqualsPtr(lhs, rhs *Mode) bool {
	if lhs != nil && rhs != nil {

		x := *lhs
		y := *rhs
		return x.Equals(y)
	}
	return lhs == nil && rhs == nil
}

// Equals returns true if all the fields of this WorkflowParams match the
// provided WorkflowParams.
//
// This function performs a deep comparison.
func (v *WorkflowParams) Equals(rhs *WorkflowParams) bool {
	if v == nil {
		return rhs == nil
	} else if rhs == nil {
		return false
	}
	if !_String_EqualsPtr(v.Domain, rhs.Domain) {
		return false
	}
	if !_String_EqualsPtr(v.TaskList, rhs.TaskList) {
		return false
	}
	if !_String_EqualsPtr(v.WorkflowQuery, rhs.WorkflowQuery) {
		return false
	}
	if !((v.NextPageToken == nil && rhs.NextPageToken == nil) || (v.NextPageToken != nil && rhs.NextPageToken != nil && bytes.Equal(v.NextPageToken, rhs.NextPageToken))) {
		return false
	}
	if !_Double_EqualsPtr(v.SamplingRate, rhs.SamplingRate) {
		return false
	}
	if !_Mode_EqualsPtr(v.ShadowMode, rhs.ShadowMode) {
		return false
	}
	if !((v.ExitCondition == nil && rhs.ExitCondition == nil) || (v.ExitCondition != nil && rhs.ExitCondition != nil && v.ExitCondition.Equals(rhs.ExitCondition))) {
		return false
	}
	if !_I32_EqualsPtr(v.Concurrency, rhs.Concurrency) {
		return false
	}
	if !((v.LastRunResult == nil && rhs.LastRunResult == nil) || (v.LastRunResult != nil && rhs.LastRunResult != nil && v.LastRunResult.Equals(rhs.LastRunResult))) {
		return false
	}

	return true
}

// MarshalLogObject implements zapcore.ObjectMarshaler, enabling
// fast logging of WorkflowParams.
func (v *WorkflowParams) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {
	if v == nil {
		return nil
	}
	if v.Domain != nil {
		enc.AddString("domain", *v.Domain)
	}
	if v.TaskList != nil {
		enc.AddString("taskList", *v.TaskList)
	}
	if v.WorkflowQuery != nil {
		enc.AddString("workflowQuery", *v.WorkflowQuery)
	}
	if v.NextPageToken != nil {
		enc.AddString("nextPageToken", base64.StdEncoding.EncodeToString(v.NextPageToken))
	}
	if v.SamplingRate != nil {
		enc.AddFloat64("samplingRate", *v.SamplingRate)
	}
	if v.ShadowMode != nil {
		err = multierr.Append(err, enc.AddObject("shadowMode", *v.ShadowMode))
	}
	if v.ExitCondition != nil {
		err = multierr.Append(err, enc.AddObject("exitCondition", v.ExitCondition))
	}
	if v.Concurrency != nil {
		enc.AddInt32("concurrency", *v.Concurrency)
	}
	if v.LastRunResult != nil {
		err = multierr.Append(err, enc.AddObject("lastRunResult", v.LastRunResult))
	}
	return err
}

// GetDomain returns the value of Domain if it is set or its
// zero value if it is unset.
func (v *WorkflowParams) GetDomain() (o string) {
	if v != nil && v.Domain != nil {
		return *v.Domain
	}

	return
}

// IsSetDomain returns true if Domain is not nil.
func (v *WorkflowParams) IsSetDomain() bool {
	return v != nil && v.Domain != nil
}

// GetTaskList returns the value of TaskList if it is set or its
// zero value if it is unset.
func (v *WorkflowParams) GetTaskList() (o string) {
	if v != nil && v.TaskList != nil {
		return *v.TaskList
	}

	return
}

// IsSetTaskList returns true if TaskList is not nil.
func (v *WorkflowParams) IsSetTaskList() bool {
	return v != nil && v.TaskList != nil
}

// GetWorkflowQuery returns the value of WorkflowQuery if it is set or its
// zero value if it is unset.
func (v *WorkflowParams) GetWorkflowQuery() (o string) {
	if v != nil && v.WorkflowQuery != nil {
		return *v.WorkflowQuery
	}

	return
}

// IsSetWorkflowQuery returns true if WorkflowQuery is not nil.
func (v *WorkflowParams) IsSetWorkflowQuery() bool {
	return v != nil && v.WorkflowQuery != nil
}

// GetNextPageToken returns the value of NextPageToken if it is set or its
// zero value if it is unset.
func (v *WorkflowParams) GetNextPageToken() (o []byte) {
	if v != nil && v.NextPageToken != nil {
		return v.NextPageToken
	}

	return
}

// IsSetNextPageToken returns true if NextPageToken is not nil.
func (v *WorkflowParams) IsSetNextPageToken() bool {
	return v != nil && v.NextPageToken != nil
}

// GetSamplingRate returns the value of SamplingRate if it is set or its
// zero value if it is unset.
func (v *WorkflowParams) GetSamplingRate() (o float64) {
	if v != nil && v.SamplingRate != nil {
		return *v.SamplingRate
	}

	return
}

// IsSetSamplingRate returns true if SamplingRate is not nil.
func (v *WorkflowParams) IsSetSamplingRate() bool {
	return v != nil && v.SamplingRate != nil
}

// GetShadowMode returns the value of ShadowMode if it is set or its
// zero value if it is unset.
func (v *WorkflowParams) GetShadowMode() (o Mode) {
	if v != nil && v.ShadowMode != nil {
		return *v.ShadowMode
	}

	return
}

// IsSetShadowMode returns true if ShadowMode is not nil.
func (v *WorkflowParams) IsSetShadowMode() bool {
	return v != nil && v.ShadowMode != nil
}

// GetExitCondition returns the value of ExitCondition if it is set or its
// zero value if it is unset.
func (v *WorkflowParams) GetExitCondition() (o *ExitCondition) {
	if v != nil && v.ExitCondition != nil {
		return v.ExitCondition
	}

	return
}

// IsSetExitCondition returns true if ExitCondition is not nil.
func (v *WorkflowParams) IsSetExitCondition() bool {
	return v != nil && v.ExitCondition != nil
}

// GetConcurrency returns the value of Concurrency if it is set or its
// zero value if it is unset.
func (v *WorkflowParams) GetConcurrency() (o int32) {
	if v != nil && v.Concurrency != nil {
		return *v.Concurrency
	}

	return
}

// IsSetConcurrency returns true if Concurrency is not nil.
func (v *WorkflowParams) IsSetConcurrency() bool {
	return v != nil && v.Concurrency != nil
}

// GetLastRunResult returns the value of LastRunResult if it is set or its
// zero value if it is unset.
func (v *WorkflowParams) GetLastRunResult() (o *WorkflowResult) {
	if v != nil && v.LastRunResult != nil {
		return v.LastRunResult
	}

	return
}

// IsSetLastRunResult returns true if LastRunResult is not nil.
func (v *WorkflowParams) IsSetLastRunResult() bool {
	return v != nil && v.LastRunResult != nil
}

type WorkflowResult struct {
	Succeeded *int32 `json:"succeeded,omitempty"`
	Skipped   *int32 `json:"skipped,omitempty"`
	Failed    *int32 `json:"failed,omitempty"`
}

// ToWire translates a WorkflowResult struct into a Thrift-level intermediate
// representation. This intermediate representation may be serialized
// into bytes using a ThriftRW protocol implementation.
//
// An error is returned if the struct or any of its fields failed to
// validate.
//
//	x, err := v.ToWire()
//	if err != nil {
//	  return err
//	}
//
//	if err := binaryProtocol.Encode(x, writer); err != nil {
//	  return err
//	}
func (v *WorkflowResult) ToWire() (wire.Value, error) {
	var (
		fields [3]wire.Field
		i      int = 0
		w      wire.Value
		err    error
	)

	if v.Succeeded != nil {
		w, err = wire.NewValueI32(*(v.Succeeded)), error(nil)
		if err != nil {
			return w, err
		}
		fields[i] = wire.Field{ID: 10, Value: w}
		i++
	}
	if v.Skipped != nil {
		w, err = wire.NewValueI32(*(v.Skipped)), error(nil)
		if err != nil {
			return w, err
		}
		fields[i] = wire.Field{ID: 20, Value: w}
		i++
	}
	if v.Failed != nil {
		w, err = wire.NewValueI32(*(v.Failed)), error(nil)
		if err != nil {
			return w, err
		}
		fields[i] = wire.Field{ID: 30, Value: w}
		i++
	}

	return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil
}

// FromWire deserializes a WorkflowResult struct from its Thrift-level
// representation. The Thrift-level representation may be obtained
// from a ThriftRW protocol implementation.
//
// An error is returned if we were unable to build a WorkflowResult struct
// from the provided intermediate representation.
//
//	x, err := binaryProtocol.Decode(reader, wire.TStruct)
//	if err != nil {
//	  return nil, err
//	}
//
//	var v WorkflowResult
//	if err := v.FromWire(x); err != nil {
//	  return nil, err
//	}
//	return &v, nil
func (v *WorkflowResult) FromWire(w wire.Value) error {
	var err error

	for _, field := range w.GetStruct().Fields {
		switch field.ID {
		case 10:
			if field.Value.Type() == wire.TI32 {
				var x int32
				x, err = field.Value.GetI32(), error(nil)
				v.Succeeded = &x
				if err != nil {
					return err
				}

			}
		case 20:
			if field.Value.Type() == wire.TI32 {
				var x int32
				x, err = field.Value.GetI32(), error(nil)
				v.Skipped = &x
				if err != nil {
					return err
				}

			}
		case 30:
			if field.Value.Type() == wire.TI32 {
				var x int32
				x, err = field.Value.GetI32(), error(nil)
				v.Failed = &x
				if err != nil {
					return err
				}

			}
		}
	}

	return nil
}

// Encode serializes a WorkflowResult struct directly into bytes, without going
// through an intermediary type.
//
// An error is returned if a WorkflowResult struct could not be encoded.
func (v *WorkflowResult) Encode(sw stream.Writer) error {
	if err := sw.WriteStructBegin(); err != nil {
		return err
	}

	if v.Succeeded != nil {
		if err := sw.WriteFieldBegin(stream.FieldHeader{ID: 10, Type: wire.TI32}); err != nil {
			return err
		}
		if err := sw.WriteInt32(*(v.Succeeded)); err != nil {
			return err
		}
		if err := sw.WriteFieldEnd(); err != nil {
			return err
		}
	}

	if v.Skipped != nil {
		if err := sw.WriteFieldBegin(stream.FieldHeader{ID: 20, Type: wire.TI32}); err != nil {
			return err
		}
		if err := sw.WriteInt32(*(v.Skipped)); err != nil {
			return err
		}
		if err := sw.WriteFieldEnd(); err != nil {
			return err
		}
	}

	if v.Failed != nil {
		if err := sw.WriteFieldBegin(stream.FieldHeader{ID: 30, Type: wire.TI32}); err != nil {
			return err
		}
		if err := sw.WriteInt32(*(v.Failed)); err != nil {
			return err
		}
		if err := sw.WriteFieldEnd(); err != nil {
			return err
		}
	}

	return sw.WriteStructEnd()
}

// Decode deserializes a WorkflowResult struct directly from its Thrift-level
// representation, without going through an intemediary type.
//
// An error is returned if a WorkflowResult struct could not be generated from the wire
// representation.
func (v *WorkflowResult) Decode(sr stream.Reader) error {

	if err := sr.ReadStructBegin(); err != nil {
		return err
	}

	fh, ok, err := sr.ReadFieldBegin()
	if err != nil {
		return err
	}

	for ok {
		switch {
		case fh.ID == 10 && fh.Type == wire.TI32:
			var x int32
			x, err = sr.ReadInt32()
			v.Succeeded = &x
			if err != nil {
				return err
			}

		case fh.ID == 20 && fh.Type == wire.TI32:
			var x int32
			x, err = sr.ReadInt32()
			v.Skipped = &x
			if err != nil {
				return err
			}

		case fh.ID == 30 && fh.Type == wire.TI32:
			var x int32
			x, err = sr.ReadInt32()
			v.Failed = &x
			if err != nil {
				return err
			}

		default:
			if err := sr.Skip(fh.Type); err != nil {
				return err
			}
		}

		if err := sr.ReadFieldEnd(); err != nil {
			return err
		}

		if fh, ok, err = sr.ReadFieldBegin(); err != nil {
			return err
		}
	}

	if err := sr.ReadStructEnd(); err != nil {
		return err
	}

	return nil
}

// String returns a readable string representation of a WorkflowResult
// struct.
func (v *WorkflowResult) String() string {
	if v == nil {
		return "<nil>"
	}

	var fields [3]string
	i := 0
	if v.Succeeded != nil {
		fields[i] = fmt.Sprintf("Succeeded: %v", *(v.Succeeded))
		i++
	}
	if v.Skipped != nil {
		fields[i] = fmt.Sprintf("Skipped: %v", *(v.Skipped))
		i++
	}
	if v.Failed != nil {
		fields[i] = fmt.Sprintf("Failed: %v", *(v.Failed))
		i++
	}

	return fmt.Sprintf("WorkflowResult{%v}", strings.Join(fields[:i], ", "))
}

// Equals returns true if all the fields of this WorkflowResult match the
// provided WorkflowResult.
//
// This function performs a deep comparison.
func (v *WorkflowResult) Equals(rhs *WorkflowResult) bool {
	if v == nil {
		return rhs == nil
	} else if rhs == nil {
		return false
	}
	if !_I32_EqualsPtr(v.Succeeded, rhs.Succeeded) {
		return false
	}
	if !_I32_EqualsPtr(v.Skipped, rhs.Skipped) {
		return false
	}
	if !_I32_EqualsPtr(v.Failed, rhs.Failed) {
		return false
	}

	return true
}

// MarshalLogObject implements zapcore.ObjectMarshaler, enabling
// fast logging of WorkflowResult.
func (v *WorkflowResult) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {
	if v == nil {
		return nil
	}
	if v.Succeeded != nil {
		enc.AddInt32("succeeded", *v.Succeeded)
	}
	if v.Skipped != nil {
		enc.AddInt32("skipped", *v.Skipped)
	}
	if v.Failed != nil {
		enc.AddInt32("failed", *v.Failed)
	}
	return err
}

// GetSucceeded returns the value of Succeeded if it is set or its
// zero value if it is unset.
func (v *WorkflowResult) GetSucceeded() (o int32) {
	if v != nil && v.Succeeded != nil {
		return *v.Succeeded
	}

	return
}

// IsSetSucceeded returns true if Succeeded is not nil.
func (v *WorkflowResult) IsSetSucceeded() bool {
	return v != nil && v.Succeeded != nil
}

// GetSkipped returns the value of Skipped if it is set or its
// zero value if it is unset.
func (v *WorkflowResult) GetSkipped() (o int32) {
	if v != nil && v.Skipped != nil {
		return *v.Skipped
	}

	return
}

// IsSetSkipped returns true if Skipped is not nil.
func (v *WorkflowResult) IsSetSkipped() bool {
	return v != nil && v.Skipped != nil
}

// GetFailed returns the value of Failed if it is set or its
// zero value if it is unset.
func (v *WorkflowResult) GetFailed() (o int32) {
	if v != nil && v.Failed != nil {
		return *v.Failed
	}

	return
}

// IsSetFailed returns true if Failed is not nil.
func (v *WorkflowResult) IsSetFailed() bool {
	return v != nil && v.Failed != nil
}

// ThriftModule represents the IDL file used to generate this package.
var ThriftModule = &thriftreflect.ThriftModule{
	Name:     "shadower",
	Package:  "github.com/uber/cadence/.gen/go/shadower",
	FilePath: "shadower.thrift",
	SHA1:     "f29a425548641e51e02ec1978279c1e37b9df792",
	Includes: []*thriftreflect.ThriftModule{
		shared.ThriftModule,
	},
	Raw: rawIDL,
}

const rawIDL = "// Copyright (c) 2017-2021 Uber Technologies, Inc.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n\nnamespace java com.uber.cadence.shadower\n\ninclude \"shared.thrift\"\n\nconst string LocalDomainName = \"cadence-shadower\"\nconst string TaskList = \"cadence-shadower-tl\"\n\nconst string WorkflowName = \"cadence-shadow-workflow\"\n\nconst string ScanWorkflowActivityName = \"scanWorkflowActivity\"\nconst string ReplayWorkflowActivityName = \"replayWorkflowActivity\"\n\nconst string WorkflowIDSuffix = \"-shadow-workflow\"\n\nconst string ErrReasonDomainNotExists = \"domain not exists\"\nconst string ErrReasonInvalidQuery = \"invalid visibility query\"\nconst string ErrReasonWorkflowTypeNotRegistered = \"workflow type not registered\"\nconst string ErrNonRetryableType = \"com.uber.cadence.internal.shadowing.NonRetryableException\"\n\nenum Mode {\n  Normal,\n  Continuous,\n}\n\nstruct ExitCondition {\n  10: optional i32 expirationIntervalInSeconds\n  20: optional i32 shadowCount\n}\n\nstruct WorkflowParams {\n  10: optional string domain \n  20: optional string taskList\n  30: optional string workflowQuery\n  40: optional binary nextPageToken\n  50: optional double samplingRate\n  60: optional Mode shadowMode\n  70: optional ExitCondition exitCondition\n  80: optional i32 concurrency\n  90: optional WorkflowResult lastRunResult\n}\n\nstruct WorkflowResult {\n  10: optional i32 succeeded\n  20: optional i32 skipped\n  30: optional i32 failed\n}\n\nstruct ScanWorkflowActivityParams {\n  10: optional string domain\n  20: optional string workflowQuery\n  30: optional binary nextPageToken\n  40: optional i32 pageSize\n  50: optional double samplingRate\n}\n\nstruct ScanWorkflowActivityResult {\n  10: optional list<shared.WorkflowExecution> executions\n  20: optional binary nextPageToken\n}\n\nstruct ReplayWorkflowActivityParams {\n  10: optional string domain\n  20: optional list<shared.WorkflowExecution> executions\n}\n\nstruct ReplayWorkflowActivityResult {\n  10: optional i32 succeeded\n  20: optional i32 skipped\n  30: optional i32 failed\n}\n"
