// 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 option_gen

import (
	"context"
	"database/sql"
	"database/sql/driver"
	"fmt"
)

type MyEnum int64

const (
	MyEnum_A MyEnum = 0
	MyEnum_B MyEnum = 1
)

func (p MyEnum) String() string {
	switch p {
	case MyEnum_A:
		return "A"
	case MyEnum_B:
		return "B"
	}
	return "<UNSET>"
}

func MyEnumFromString(s string) (MyEnum, error) {
	switch s {
	case "A":
		return MyEnum_A, nil
	case "B":
		return MyEnum_B, 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 IDCard struct {
	Number string `thrift:"number,1,required" json:"number"`
	Age    int8   `thrift:"age,2,required" json:"age"`
}

func NewIDCard() *IDCard {
	return &IDCard{}
}

func (p *IDCard) InitDefault() {
}

func (p *IDCard) GetNumber() (v string) {
	return p.Number
}

func (p *IDCard) GetAge() (v int8) {
	return p.Age
}

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

var fieldIDToName_IDCard = map[int16]string{
	1: "number",
	2: "age",
}

type Person struct {
	Name string  `thrift:"name,1,required" json:"name"`
	ID   *IDCard `thrift:"id,2,required" json:"id"`
}

func NewPerson() *Person {
	return &Person{}
}

func (p *Person) InitDefault() {
}

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

var Person_ID_DEFAULT *IDCard

func (p *Person) GetID() (v *IDCard) {
	if !p.IsSetID() {
		return Person_ID_DEFAULT
	}
	return p.ID
}

func (p *Person) IsSetID() bool {
	return p.ID != nil
}

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

var fieldIDToName_Person = map[int16]string{
	1: "name",
	2: "id",
}

type PersonB struct {
}

func NewPersonB() *PersonB {
	return &PersonB{}
}

func (p *PersonB) InitDefault() {
}

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

var fieldIDToName_PersonB = map[int16]string{}

type PersonC struct {
}

func NewPersonC() *PersonC {
	return &PersonC{}
}

func (p *PersonC) InitDefault() {
}

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

var fieldIDToName_PersonC = map[int16]string{}

type TinyStruct struct {
	B1 bool `thrift:"b1,1,required" json:"b1"`
	B2 bool `thrift:"b2,2,required" json:"b2"`
}

func NewTinyStruct() *TinyStruct {
	return &TinyStruct{}
}

func (p *TinyStruct) InitDefault() {
}

func (p *TinyStruct) GetB1() (v bool) {
	return p.B1
}

func (p *TinyStruct) GetB2() (v bool) {
	return p.B2
}

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

var fieldIDToName_TinyStruct = map[int16]string{
	1: "b1",
	2: "b2",
}

type MyService interface {
	M1(ctx context.Context) (r string, err error)

	M2(ctx context.Context) (r string, err error)
}

type MyServiceM1Args struct {
}

func NewMyServiceM1Args() *MyServiceM1Args {
	return &MyServiceM1Args{}
}

func (p *MyServiceM1Args) InitDefault() {
}

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

var fieldIDToName_MyServiceM1Args = map[int16]string{}

type MyServiceM1Result struct {
	Success *string `thrift:"success,0,optional" json:"success,omitempty"`
}

func NewMyServiceM1Result() *MyServiceM1Result {
	return &MyServiceM1Result{}
}

func (p *MyServiceM1Result) InitDefault() {
}

var MyServiceM1Result_Success_DEFAULT string

func (p *MyServiceM1Result) GetSuccess() (v string) {
	if !p.IsSetSuccess() {
		return MyServiceM1Result_Success_DEFAULT
	}
	return *p.Success
}

func (p *MyServiceM1Result) IsSetSuccess() bool {
	return p.Success != nil
}

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

var fieldIDToName_MyServiceM1Result = map[int16]string{
	0: "success",
}

type MyServiceM2Args struct {
}

func NewMyServiceM2Args() *MyServiceM2Args {
	return &MyServiceM2Args{}
}

func (p *MyServiceM2Args) InitDefault() {
}

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

var fieldIDToName_MyServiceM2Args = map[int16]string{}

type MyServiceM2Result struct {
	Success *string `thrift:"success,0,optional" json:"success,omitempty"`
}

func NewMyServiceM2Result() *MyServiceM2Result {
	return &MyServiceM2Result{}
}

func (p *MyServiceM2Result) InitDefault() {
}

var MyServiceM2Result_Success_DEFAULT string

func (p *MyServiceM2Result) GetSuccess() (v string) {
	if !p.IsSetSuccess() {
		return MyServiceM2Result_Success_DEFAULT
	}
	return *p.Success
}

func (p *MyServiceM2Result) IsSetSuccess() bool {
	return p.Success != nil
}

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

var fieldIDToName_MyServiceM2Result = map[int16]string{
	0: "success",
}
