// Copyright 2024 CloudWeGo Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//   http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// Code generated by thriftgo (0.3.15). DO NOT EDIT.

package validation

import (
	"database/sql"
	"database/sql/driver"
	"fmt"
	"github.com/cloudwego/thriftgo/extension/thrift_option"
)

const (
	HELLO = "hello there"
)

type MyEnum int64

const (
	MyEnum_X   MyEnum = 0
	MyEnum_XL  MyEnum = 1
	MyEnum_XXL MyEnum = 2
)

func (p MyEnum) String() string {
	switch p {
	case MyEnum_X:
		return "X"
	case MyEnum_XL:
		return "XL"
	case MyEnum_XXL:
		return "XXL"
	}
	return "<UNSET>"
}

func MyEnumFromString(s string) (MyEnum, error) {
	switch s {
	case "X":
		return MyEnum_X, nil
	case "XL":
		return MyEnum_XL, nil
	case "XXL":
		return MyEnum_XXL, nil
	}
	return MyEnum(0), fmt.Errorf("not a valid MyEnum string")
}

func MyEnumPtr(v MyEnum) *MyEnum { return &v }
func (p *MyEnum) Scan(value interface{}) (err error) {
	var result sql.NullInt64
	err = result.Scan(value)
	*p = MyEnum(result.Int64)
	return
}

func (p *MyEnum) Value() (driver.Value, error) {
	if p == nil {
		return nil, nil
	}
	return int64(*p), nil
}

type MyBasicTypedef = string

type MyStructTypedef = TestInfo

func NewMyStructTypedef() *MyStructTypedef {
	return (*MyStructTypedef)(NewTestInfo())
}

type _StructOptions struct {
	PersonStringInfo             string                  `thrift:"person_string_info,1,required" json:"person_string_info"`
	PersonMapInfo                map[string]string       `thrift:"person_map_info,2,required" json:"person_map_info"`
	PersonEnumInfo               MyEnum                  `thrift:"person_enum_info,3,required" json:"person_enum_info"`
	PersonBasicTypedefInfo       MyBasicTypedef          `thrift:"person_basic_typedef_info,4,required" json:"person_basic_typedef_info"`
	PersonStructTypedefInfo      *MyStructTypedef        `thrift:"person_struct_typedef_info,5,required" json:"person_struct_typedef_info"`
	PersonStructDefaultValueInfo *MyStructWithDefaultVal `thrift:"person_struct_default_value_info,6,required" json:"person_struct_default_value_info"`
}

func New_StructOptions() *_StructOptions {
	return &_StructOptions{}
}

func (p *_StructOptions) InitDefault() {
}

func (p *_StructOptions) GetPersonStringInfo() (v string) {
	return p.PersonStringInfo
}

func (p *_StructOptions) GetPersonMapInfo() (v map[string]string) {
	return p.PersonMapInfo
}

func (p *_StructOptions) GetPersonEnumInfo() (v MyEnum) {
	return p.PersonEnumInfo
}

func (p *_StructOptions) GetPersonBasicTypedefInfo() (v MyBasicTypedef) {
	return p.PersonBasicTypedefInfo
}

var _StructOptions_PersonStructTypedefInfo_DEFAULT *MyStructTypedef

func (p *_StructOptions) GetPersonStructTypedefInfo() (v *MyStructTypedef) {
	if !p.IsSetPersonStructTypedefInfo() {
		return _StructOptions_PersonStructTypedefInfo_DEFAULT
	}
	return p.PersonStructTypedefInfo
}

var _StructOptions_PersonStructDefaultValueInfo_DEFAULT *MyStructWithDefaultVal

func (p *_StructOptions) GetPersonStructDefaultValueInfo() (v *MyStructWithDefaultVal) {
	if !p.IsSetPersonStructDefaultValueInfo() {
		return _StructOptions_PersonStructDefaultValueInfo_DEFAULT
	}
	return p.PersonStructDefaultValueInfo
}

func (p *_StructOptions) IsSetPersonStructTypedefInfo() bool {
	return p.PersonStructTypedefInfo != nil
}

func (p *_StructOptions) IsSetPersonStructDefaultValueInfo() bool {
	return p.PersonStructDefaultValueInfo != nil
}

func (p *_StructOptions) String() string {
	if p == nil {
		return "<nil>"
	}
	return fmt.Sprintf("_StructOptions(%+v)", *p)
}

var fieldIDToName__StructOptions = map[int16]string{
	1: "person_string_info",
	2: "person_map_info",
	3: "person_enum_info",
	4: "person_basic_typedef_info",
	5: "person_struct_typedef_info",
	6: "person_struct_default_value_info",
}

type MyStructWithDefaultVal struct {
	V1  string            `thrift:"v1,1,required" json:"v1"`
	V2  string            `thrift:"v2,2,required" json:"v2"`
	V3  int8              `thrift:"v3,3,required" json:"v3"`
	V4  int16             `thrift:"v4,4,required" json:"v4"`
	V5  int32             `thrift:"v5,5,required" json:"v5"`
	V6  int64             `thrift:"v6,6,required" json:"v6"`
	V7  bool              `thrift:"v7,7,required" json:"v7"`
	V8  float64           `thrift:"v8,8,required" json:"v8"`
	V9  map[string]string `thrift:"v9,9,required" json:"v9"`
	V10 []string          `thrift:"v10,10,required" json:"v10"`
	V11 string            `thrift:"v11,11,required" json:"v11"`
}

func NewMyStructWithDefaultVal() *MyStructWithDefaultVal {
	return &MyStructWithDefaultVal{

		V2: "v2",
		V3: 8,
		V4: 16,
		V5: 32,
		V6: 64,
		V7: true,
		V8: 3.1415926123456,
		V9: map[string]string{
			"k1": "v1",
		},
		V10: []string{
			"k1",
			"k2",
		},
		V11: HELLO,
	}
}

func (p *MyStructWithDefaultVal) InitDefault() {
	p.V2 = "v2"
	p.V3 = 8
	p.V4 = 16
	p.V5 = 32
	p.V6 = 64
	p.V7 = true
	p.V8 = 3.1415926123456
	p.V9 = map[string]string{
		"k1": "v1",
	}
	p.V10 = []string{
		"k1",
		"k2",
	}
	p.V11 = HELLO
}

func (p *MyStructWithDefaultVal) GetV1() (v string) {
	return p.V1
}

func (p *MyStructWithDefaultVal) GetV2() (v string) {
	return p.V2
}

func (p *MyStructWithDefaultVal) GetV3() (v int8) {
	return p.V3
}

func (p *MyStructWithDefaultVal) GetV4() (v int16) {
	return p.V4
}

func (p *MyStructWithDefaultVal) GetV5() (v int32) {
	return p.V5
}

func (p *MyStructWithDefaultVal) GetV6() (v int64) {
	return p.V6
}

func (p *MyStructWithDefaultVal) GetV7() (v bool) {
	return p.V7
}

func (p *MyStructWithDefaultVal) GetV8() (v float64) {
	return p.V8
}

func (p *MyStructWithDefaultVal) GetV9() (v map[string]string) {
	return p.V9
}

func (p *MyStructWithDefaultVal) GetV10() (v []string) {
	return p.V10
}

func (p *MyStructWithDefaultVal) GetV11() (v string) {
	return p.V11
}

func (p *MyStructWithDefaultVal) String() string {
	if p == nil {
		return "<nil>"
	}
	return fmt.Sprintf("MyStructWithDefaultVal(%+v)", *p)
}

var fieldIDToName_MyStructWithDefaultVal = map[int16]string{
	1:  "v1",
	2:  "v2",
	3:  "v3",
	4:  "v4",
	5:  "v5",
	6:  "v6",
	7:  "v7",
	8:  "v8",
	9:  "v9",
	10: "v10",
	11: "v11",
}

type _FieldOptions struct {
	CardFieldInfo string `thrift:"card_field_info,1,required" json:"card_field_info"`
}

func New_FieldOptions() *_FieldOptions {
	return &_FieldOptions{}
}

func (p *_FieldOptions) InitDefault() {
}

func (p *_FieldOptions) GetCardFieldInfo() (v string) {
	return p.CardFieldInfo
}

func (p *_FieldOptions) String() string {
	if p == nil {
		return "<nil>"
	}
	return fmt.Sprintf("_FieldOptions(%+v)", *p)
}

var fieldIDToName__FieldOptions = map[int16]string{
	1: "card_field_info",
}

type TestInfo struct {
	Name   string `thrift:"name,1,required" json:"name"`
	Number int16  `thrift:"number,2,required" json:"number"`
}

func NewTestInfo() *TestInfo {
	return &TestInfo{}
}

func (p *TestInfo) InitDefault() {
}

func (p *TestInfo) GetName() (v string) {
	return p.Name
}

func (p *TestInfo) GetNumber() (v int16) {
	return p.Number
}

func (p *TestInfo) String() string {
	if p == nil {
		return "<nil>"
	}
	return fmt.Sprintf("TestInfo(%+v)", *p)
}

var fieldIDToName_TestInfo = map[int16]string{
	1: "name",
	2: "number",
}

type _ServiceOptions struct {
	SvcInfo *TestInfo `thrift:"svc_info,1,required" json:"svc_info"`
}

func New_ServiceOptions() *_ServiceOptions {
	return &_ServiceOptions{}
}

func (p *_ServiceOptions) InitDefault() {
}

var _ServiceOptions_SvcInfo_DEFAULT *TestInfo

func (p *_ServiceOptions) GetSvcInfo() (v *TestInfo) {
	if !p.IsSetSvcInfo() {
		return _ServiceOptions_SvcInfo_DEFAULT
	}
	return p.SvcInfo
}

func (p *_ServiceOptions) IsSetSvcInfo() bool {
	return p.SvcInfo != nil
}

func (p *_ServiceOptions) String() string {
	if p == nil {
		return "<nil>"
	}
	return fmt.Sprintf("_ServiceOptions(%+v)", *p)
}

var fieldIDToName__ServiceOptions = map[int16]string{
	1: "svc_info",
}

type _MethodOptions struct {
	MethodInfo *TestInfo `thrift:"method_info,1,required" json:"method_info"`
}

func New_MethodOptions() *_MethodOptions {
	return &_MethodOptions{}
}

func (p *_MethodOptions) InitDefault() {
}

var _MethodOptions_MethodInfo_DEFAULT *TestInfo

func (p *_MethodOptions) GetMethodInfo() (v *TestInfo) {
	if !p.IsSetMethodInfo() {
		return _MethodOptions_MethodInfo_DEFAULT
	}
	return p.MethodInfo
}

func (p *_MethodOptions) IsSetMethodInfo() bool {
	return p.MethodInfo != nil
}

func (p *_MethodOptions) String() string {
	if p == nil {
		return "<nil>"
	}
	return fmt.Sprintf("_MethodOptions(%+v)", *p)
}

var fieldIDToName__MethodOptions = map[int16]string{
	1: "method_info",
}

type _EnumOptions struct {
	EnumInfo *TestInfo `thrift:"enum_info,1,required" json:"enum_info"`
}

func New_EnumOptions() *_EnumOptions {
	return &_EnumOptions{}
}

func (p *_EnumOptions) InitDefault() {
}

var _EnumOptions_EnumInfo_DEFAULT *TestInfo

func (p *_EnumOptions) GetEnumInfo() (v *TestInfo) {
	if !p.IsSetEnumInfo() {
		return _EnumOptions_EnumInfo_DEFAULT
	}
	return p.EnumInfo
}

func (p *_EnumOptions) IsSetEnumInfo() bool {
	return p.EnumInfo != nil
}

func (p *_EnumOptions) String() string {
	if p == nil {
		return "<nil>"
	}
	return fmt.Sprintf("_EnumOptions(%+v)", *p)
}

var fieldIDToName__EnumOptions = map[int16]string{
	1: "enum_info",
}

type _EnumValueOptions struct {
	EnumValueInfo *TestInfo `thrift:"enum_value_info,1,required" json:"enum_value_info"`
}

func New_EnumValueOptions() *_EnumValueOptions {
	return &_EnumValueOptions{}
}

func (p *_EnumValueOptions) InitDefault() {
}

var _EnumValueOptions_EnumValueInfo_DEFAULT *TestInfo

func (p *_EnumValueOptions) GetEnumValueInfo() (v *TestInfo) {
	if !p.IsSetEnumValueInfo() {
		return _EnumValueOptions_EnumValueInfo_DEFAULT
	}
	return p.EnumValueInfo
}

func (p *_EnumValueOptions) IsSetEnumValueInfo() bool {
	return p.EnumValueInfo != nil
}

func (p *_EnumValueOptions) String() string {
	if p == nil {
		return "<nil>"
	}
	return fmt.Sprintf("_EnumValueOptions(%+v)", *p)
}

var fieldIDToName__EnumValueOptions = map[int16]string{
	1: "enum_value_info",
}
var (
	STRUCT_OPTION_PERSON_STRING_INFO               = thrift_option.NewStructOption("../option_idl/annotations/validation/validation.thrift", "person_string_info")
	STRUCT_OPTION_PERSON_MAP_INFO                  = thrift_option.NewStructOption("../option_idl/annotations/validation/validation.thrift", "person_map_info")
	STRUCT_OPTION_PERSON_ENUM_INFO                 = thrift_option.NewStructOption("../option_idl/annotations/validation/validation.thrift", "person_enum_info")
	STRUCT_OPTION_PERSON_BASIC_TYPEDEF_INFO        = thrift_option.NewStructOption("../option_idl/annotations/validation/validation.thrift", "person_basic_typedef_info")
	STRUCT_OPTION_PERSON_STRUCT_TYPEDEF_INFO       = thrift_option.NewStructOption("../option_idl/annotations/validation/validation.thrift", "person_struct_typedef_info")
	STRUCT_OPTION_PERSON_STRUCT_DEFAULT_VALUE_INFO = thrift_option.NewStructOption("../option_idl/annotations/validation/validation.thrift", "person_struct_default_value_info")
	FIELD_OPTION_CARD_FIELD_INFO                   = thrift_option.NewFieldOption("../option_idl/annotations/validation/validation.thrift", "card_field_info")
	SERVICE_OPTION_SVC_INFO                        = thrift_option.NewServiceOption("../option_idl/annotations/validation/validation.thrift", "svc_info")
	METHOD_OPTION_METHOD_INFO                      = thrift_option.NewMethodOption("../option_idl/annotations/validation/validation.thrift", "method_info")
	ENUM_OPTION_ENUM_INFO                          = thrift_option.NewEnumOption("../option_idl/annotations/validation/validation.thrift", "enum_info")
	ENUM_VALUE_OPTION_ENUM_VALUE_INFO              = thrift_option.NewEnumValueOption("../option_idl/annotations/validation/validation.thrift", "enum_value_info")
)
