blob: 7888892f633ffdc13ee1657079c04b17b9d6d4b2 [file] [log] [blame]
Rohan Agrawalc32d9932020-06-15 11:01:47 +00001// Autogenerated by Thrift Compiler (0.9.3)
2// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
3
4package baggage
5
6import (
7 "bytes"
8 "fmt"
9 "github.com/uber/jaeger-client-go/thrift"
10)
11
12// (needed to ensure safety because of naive import list construction.)
13var _ = thrift.ZERO
14var _ = fmt.Printf
15var _ = bytes.Equal
16
17var GoUnusedProtection__ int
18
19// Attributes:
20// - BaggageKey
21// - MaxValueLength
22type BaggageRestriction struct {
23 BaggageKey string `thrift:"baggageKey,1,required" json:"baggageKey"`
24 MaxValueLength int32 `thrift:"maxValueLength,2,required" json:"maxValueLength"`
25}
26
27func NewBaggageRestriction() *BaggageRestriction {
28 return &BaggageRestriction{}
29}
30
31func (p *BaggageRestriction) GetBaggageKey() string {
32 return p.BaggageKey
33}
34
35func (p *BaggageRestriction) GetMaxValueLength() int32 {
36 return p.MaxValueLength
37}
38func (p *BaggageRestriction) Read(iprot thrift.TProtocol) error {
39 if _, err := iprot.ReadStructBegin(); err != nil {
40 return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err)
41 }
42
43 var issetBaggageKey bool = false
44 var issetMaxValueLength bool = false
45
46 for {
47 _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()
48 if err != nil {
49 return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err)
50 }
51 if fieldTypeId == thrift.STOP {
52 break
53 }
54 switch fieldId {
55 case 1:
56 if err := p.readField1(iprot); err != nil {
57 return err
58 }
59 issetBaggageKey = true
60 case 2:
61 if err := p.readField2(iprot); err != nil {
62 return err
63 }
64 issetMaxValueLength = true
65 default:
66 if err := iprot.Skip(fieldTypeId); err != nil {
67 return err
68 }
69 }
70 if err := iprot.ReadFieldEnd(); err != nil {
71 return err
72 }
73 }
74 if err := iprot.ReadStructEnd(); err != nil {
75 return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
76 }
77 if !issetBaggageKey {
78 return thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("Required field BaggageKey is not set"))
79 }
80 if !issetMaxValueLength {
81 return thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("Required field MaxValueLength is not set"))
82 }
83 return nil
84}
85
86func (p *BaggageRestriction) readField1(iprot thrift.TProtocol) error {
87 if v, err := iprot.ReadString(); err != nil {
88 return thrift.PrependError("error reading field 1: ", err)
89 } else {
90 p.BaggageKey = v
91 }
92 return nil
93}
94
95func (p *BaggageRestriction) readField2(iprot thrift.TProtocol) error {
96 if v, err := iprot.ReadI32(); err != nil {
97 return thrift.PrependError("error reading field 2: ", err)
98 } else {
99 p.MaxValueLength = v
100 }
101 return nil
102}
103
104func (p *BaggageRestriction) Write(oprot thrift.TProtocol) error {
105 if err := oprot.WriteStructBegin("BaggageRestriction"); err != nil {
106 return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err)
107 }
108 if err := p.writeField1(oprot); err != nil {
109 return err
110 }
111 if err := p.writeField2(oprot); err != nil {
112 return err
113 }
114 if err := oprot.WriteFieldStop(); err != nil {
115 return thrift.PrependError("write field stop error: ", err)
116 }
117 if err := oprot.WriteStructEnd(); err != nil {
118 return thrift.PrependError("write struct stop error: ", err)
119 }
120 return nil
121}
122
123func (p *BaggageRestriction) writeField1(oprot thrift.TProtocol) (err error) {
124 if err := oprot.WriteFieldBegin("baggageKey", thrift.STRING, 1); err != nil {
125 return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:baggageKey: ", p), err)
126 }
127 if err := oprot.WriteString(string(p.BaggageKey)); err != nil {
128 return thrift.PrependError(fmt.Sprintf("%T.baggageKey (1) field write error: ", p), err)
129 }
130 if err := oprot.WriteFieldEnd(); err != nil {
131 return thrift.PrependError(fmt.Sprintf("%T write field end error 1:baggageKey: ", p), err)
132 }
133 return err
134}
135
136func (p *BaggageRestriction) writeField2(oprot thrift.TProtocol) (err error) {
137 if err := oprot.WriteFieldBegin("maxValueLength", thrift.I32, 2); err != nil {
138 return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:maxValueLength: ", p), err)
139 }
140 if err := oprot.WriteI32(int32(p.MaxValueLength)); err != nil {
141 return thrift.PrependError(fmt.Sprintf("%T.maxValueLength (2) field write error: ", p), err)
142 }
143 if err := oprot.WriteFieldEnd(); err != nil {
144 return thrift.PrependError(fmt.Sprintf("%T write field end error 2:maxValueLength: ", p), err)
145 }
146 return err
147}
148
149func (p *BaggageRestriction) String() string {
150 if p == nil {
151 return "<nil>"
152 }
153 return fmt.Sprintf("BaggageRestriction(%+v)", *p)
154}