/
nozap.go
1061 lines (934 loc) · 25.6 KB
/
nozap.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Code generated by thriftrw v1.20.2. DO NOT EDIT.
// @generated
package nozap
import (
bytes "bytes"
json "encoding/json"
errors "errors"
fmt "fmt"
thriftreflect "go.uber.org/thriftrw/thriftreflect"
wire "go.uber.org/thriftrw/wire"
math "math"
strconv "strconv"
strings "strings"
)
type EnumDefault int32
const (
EnumDefaultFoo EnumDefault = 0
EnumDefaultBar EnumDefault = 1
EnumDefaultBaz EnumDefault = 2
)
// EnumDefault_Values returns all recognized values of EnumDefault.
func EnumDefault_Values() []EnumDefault {
return []EnumDefault{
EnumDefaultFoo,
EnumDefaultBar,
EnumDefaultBaz,
}
}
// UnmarshalText tries to decode EnumDefault from a byte slice
// containing its name.
//
// var v EnumDefault
// err := v.UnmarshalText([]byte("Foo"))
func (v *EnumDefault) UnmarshalText(value []byte) error {
switch s := string(value); s {
case "Foo":
*v = EnumDefaultFoo
return nil
case "Bar":
*v = EnumDefaultBar
return nil
case "Baz":
*v = EnumDefaultBaz
return nil
default:
val, err := strconv.ParseInt(s, 10, 32)
if err != nil {
return fmt.Errorf("unknown enum value %q for %q: %v", s, "EnumDefault", err)
}
*v = EnumDefault(val)
return nil
}
}
// MarshalText encodes EnumDefault 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 EnumDefault) MarshalText() ([]byte, error) {
switch int32(v) {
case 0:
return []byte("Foo"), nil
case 1:
return []byte("Bar"), nil
case 2:
return []byte("Baz"), nil
}
return []byte(strconv.FormatInt(int64(v), 10)), nil
}
// Ptr returns a pointer to this enum value.
func (v EnumDefault) Ptr() *EnumDefault {
return &v
}
// ToWire translates EnumDefault 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 EnumDefault) ToWire() (wire.Value, error) {
return wire.NewValueI32(int32(v)), nil
}
// FromWire deserializes EnumDefault from its Thrift-level
// representation.
//
// x, err := binaryProtocol.Decode(reader, wire.TI32)
// if err != nil {
// return EnumDefault(0), err
// }
//
// var v EnumDefault
// if err := v.FromWire(x); err != nil {
// return EnumDefault(0), err
// }
// return v, nil
func (v *EnumDefault) FromWire(w wire.Value) error {
*v = (EnumDefault)(w.GetI32())
return nil
}
// String returns a readable string representation of EnumDefault.
func (v EnumDefault) String() string {
w := int32(v)
switch w {
case 0:
return "Foo"
case 1:
return "Bar"
case 2:
return "Baz"
}
return fmt.Sprintf("EnumDefault(%d)", w)
}
// Equals returns true if this EnumDefault value matches the provided
// value.
func (v EnumDefault) Equals(rhs EnumDefault) bool {
return v == rhs
}
// MarshalJSON serializes EnumDefault into JSON.
//
// If the enum value is recognized, its name is returned. Otherwise,
// its integer value is returned.
//
// This implements json.Marshaler.
func (v EnumDefault) MarshalJSON() ([]byte, error) {
switch int32(v) {
case 0:
return ([]byte)("\"Foo\""), nil
case 1:
return ([]byte)("\"Bar\""), nil
case 2:
return ([]byte)("\"Baz\""), nil
}
return ([]byte)(strconv.FormatInt(int64(v), 10)), nil
}
// UnmarshalJSON attempts to decode EnumDefault 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 *EnumDefault) 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, "EnumDefault")
}
if x < math.MinInt32 {
return fmt.Errorf("enum underflow from JSON %q for %q", text, "EnumDefault")
}
*v = (EnumDefault)(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, "EnumDefault")
}
}
type PrimitiveRequiredStruct struct {
BoolField bool `json:"boolField,required"`
ByteField int8 `json:"byteField,required"`
Int16Field int16 `json:"int16Field,required"`
Int32Field int32 `json:"int32Field,required"`
Int64Field int64 `json:"int64Field,required"`
DoubleField float64 `json:"doubleField,required"`
StringField string `json:"stringField,required"`
BinaryField []byte `json:"binaryField,required"`
ListOfStrings []string `json:"listOfStrings,required"`
SetOfInts map[int32]struct{} `json:"setOfInts,required"`
MapOfIntsToDoubles map[int64]float64 `json:"mapOfIntsToDoubles,required"`
}
type _List_String_ValueList []string
func (v _List_String_ValueList) ForEach(f func(wire.Value) error) error {
for _, x := range v {
w, err := wire.NewValueString(x), error(nil)
if err != nil {
return err
}
err = f(w)
if err != nil {
return err
}
}
return nil
}
func (v _List_String_ValueList) Size() int {
return len(v)
}
func (_List_String_ValueList) ValueType() wire.Type {
return wire.TBinary
}
func (_List_String_ValueList) Close() {}
type _Set_I32_mapType_ValueList map[int32]struct{}
func (v _Set_I32_mapType_ValueList) ForEach(f func(wire.Value) error) error {
for x := range v {
w, err := wire.NewValueI32(x), error(nil)
if err != nil {
return err
}
if err := f(w); err != nil {
return err
}
}
return nil
}
func (v _Set_I32_mapType_ValueList) Size() int {
return len(v)
}
func (_Set_I32_mapType_ValueList) ValueType() wire.Type {
return wire.TI32
}
func (_Set_I32_mapType_ValueList) Close() {}
type _Map_I64_Double_MapItemList map[int64]float64
func (m _Map_I64_Double_MapItemList) ForEach(f func(wire.MapItem) error) error {
for k, v := range m {
kw, err := wire.NewValueI64(k), error(nil)
if err != nil {
return err
}
vw, err := wire.NewValueDouble(v), error(nil)
if err != nil {
return err
}
err = f(wire.MapItem{Key: kw, Value: vw})
if err != nil {
return err
}
}
return nil
}
func (m _Map_I64_Double_MapItemList) Size() int {
return len(m)
}
func (_Map_I64_Double_MapItemList) KeyType() wire.Type {
return wire.TI64
}
func (_Map_I64_Double_MapItemList) ValueType() wire.Type {
return wire.TDouble
}
func (_Map_I64_Double_MapItemList) Close() {}
// ToWire translates a PrimitiveRequiredStruct 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 *PrimitiveRequiredStruct) ToWire() (wire.Value, error) {
var (
fields [11]wire.Field
i int = 0
w wire.Value
err error
)
w, err = wire.NewValueBool(v.BoolField), error(nil)
if err != nil {
return w, err
}
fields[i] = wire.Field{ID: 1, Value: w}
i++
w, err = wire.NewValueI8(v.ByteField), error(nil)
if err != nil {
return w, err
}
fields[i] = wire.Field{ID: 2, Value: w}
i++
w, err = wire.NewValueI16(v.Int16Field), error(nil)
if err != nil {
return w, err
}
fields[i] = wire.Field{ID: 3, Value: w}
i++
w, err = wire.NewValueI32(v.Int32Field), error(nil)
if err != nil {
return w, err
}
fields[i] = wire.Field{ID: 4, Value: w}
i++
w, err = wire.NewValueI64(v.Int64Field), error(nil)
if err != nil {
return w, err
}
fields[i] = wire.Field{ID: 5, Value: w}
i++
w, err = wire.NewValueDouble(v.DoubleField), error(nil)
if err != nil {
return w, err
}
fields[i] = wire.Field{ID: 6, Value: w}
i++
w, err = wire.NewValueString(v.StringField), error(nil)
if err != nil {
return w, err
}
fields[i] = wire.Field{ID: 7, Value: w}
i++
if v.BinaryField == nil {
return w, errors.New("field BinaryField of PrimitiveRequiredStruct is required")
}
w, err = wire.NewValueBinary(v.BinaryField), error(nil)
if err != nil {
return w, err
}
fields[i] = wire.Field{ID: 8, Value: w}
i++
if v.ListOfStrings == nil {
return w, errors.New("field ListOfStrings of PrimitiveRequiredStruct is required")
}
w, err = wire.NewValueList(_List_String_ValueList(v.ListOfStrings)), error(nil)
if err != nil {
return w, err
}
fields[i] = wire.Field{ID: 9, Value: w}
i++
if v.SetOfInts == nil {
return w, errors.New("field SetOfInts of PrimitiveRequiredStruct is required")
}
w, err = wire.NewValueSet(_Set_I32_mapType_ValueList(v.SetOfInts)), error(nil)
if err != nil {
return w, err
}
fields[i] = wire.Field{ID: 10, Value: w}
i++
if v.MapOfIntsToDoubles == nil {
return w, errors.New("field MapOfIntsToDoubles of PrimitiveRequiredStruct is required")
}
w, err = wire.NewValueMap(_Map_I64_Double_MapItemList(v.MapOfIntsToDoubles)), error(nil)
if err != nil {
return w, err
}
fields[i] = wire.Field{ID: 11, Value: w}
i++
return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil
}
func _List_String_Read(l wire.ValueList) ([]string, error) {
if l.ValueType() != wire.TBinary {
return nil, nil
}
o := make([]string, 0, l.Size())
err := l.ForEach(func(x wire.Value) error {
i, err := x.GetString(), error(nil)
if err != nil {
return err
}
o = append(o, i)
return nil
})
l.Close()
return o, err
}
func _Set_I32_mapType_Read(s wire.ValueList) (map[int32]struct{}, error) {
if s.ValueType() != wire.TI32 {
return nil, nil
}
o := make(map[int32]struct{}, s.Size())
err := s.ForEach(func(x wire.Value) error {
i, err := x.GetI32(), error(nil)
if err != nil {
return err
}
o[i] = struct{}{}
return nil
})
s.Close()
return o, err
}
func _Map_I64_Double_Read(m wire.MapItemList) (map[int64]float64, error) {
if m.KeyType() != wire.TI64 {
return nil, nil
}
if m.ValueType() != wire.TDouble {
return nil, nil
}
o := make(map[int64]float64, m.Size())
err := m.ForEach(func(x wire.MapItem) error {
k, err := x.Key.GetI64(), error(nil)
if err != nil {
return err
}
v, err := x.Value.GetDouble(), error(nil)
if err != nil {
return err
}
o[k] = v
return nil
})
m.Close()
return o, err
}
// FromWire deserializes a PrimitiveRequiredStruct 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 PrimitiveRequiredStruct struct
// from the provided intermediate representation.
//
// x, err := binaryProtocol.Decode(reader, wire.TStruct)
// if err != nil {
// return nil, err
// }
//
// var v PrimitiveRequiredStruct
// if err := v.FromWire(x); err != nil {
// return nil, err
// }
// return &v, nil
func (v *PrimitiveRequiredStruct) FromWire(w wire.Value) error {
var err error
boolFieldIsSet := false
byteFieldIsSet := false
int16FieldIsSet := false
int32FieldIsSet := false
int64FieldIsSet := false
doubleFieldIsSet := false
stringFieldIsSet := false
binaryFieldIsSet := false
listOfStringsIsSet := false
setOfIntsIsSet := false
mapOfIntsToDoublesIsSet := false
for _, field := range w.GetStruct().Fields {
switch field.ID {
case 1:
if field.Value.Type() == wire.TBool {
v.BoolField, err = field.Value.GetBool(), error(nil)
if err != nil {
return err
}
boolFieldIsSet = true
}
case 2:
if field.Value.Type() == wire.TI8 {
v.ByteField, err = field.Value.GetI8(), error(nil)
if err != nil {
return err
}
byteFieldIsSet = true
}
case 3:
if field.Value.Type() == wire.TI16 {
v.Int16Field, err = field.Value.GetI16(), error(nil)
if err != nil {
return err
}
int16FieldIsSet = true
}
case 4:
if field.Value.Type() == wire.TI32 {
v.Int32Field, err = field.Value.GetI32(), error(nil)
if err != nil {
return err
}
int32FieldIsSet = true
}
case 5:
if field.Value.Type() == wire.TI64 {
v.Int64Field, err = field.Value.GetI64(), error(nil)
if err != nil {
return err
}
int64FieldIsSet = true
}
case 6:
if field.Value.Type() == wire.TDouble {
v.DoubleField, err = field.Value.GetDouble(), error(nil)
if err != nil {
return err
}
doubleFieldIsSet = true
}
case 7:
if field.Value.Type() == wire.TBinary {
v.StringField, err = field.Value.GetString(), error(nil)
if err != nil {
return err
}
stringFieldIsSet = true
}
case 8:
if field.Value.Type() == wire.TBinary {
v.BinaryField, err = field.Value.GetBinary(), error(nil)
if err != nil {
return err
}
binaryFieldIsSet = true
}
case 9:
if field.Value.Type() == wire.TList {
v.ListOfStrings, err = _List_String_Read(field.Value.GetList())
if err != nil {
return err
}
listOfStringsIsSet = true
}
case 10:
if field.Value.Type() == wire.TSet {
v.SetOfInts, err = _Set_I32_mapType_Read(field.Value.GetSet())
if err != nil {
return err
}
setOfIntsIsSet = true
}
case 11:
if field.Value.Type() == wire.TMap {
v.MapOfIntsToDoubles, err = _Map_I64_Double_Read(field.Value.GetMap())
if err != nil {
return err
}
mapOfIntsToDoublesIsSet = true
}
}
}
if !boolFieldIsSet {
return errors.New("field BoolField of PrimitiveRequiredStruct is required")
}
if !byteFieldIsSet {
return errors.New("field ByteField of PrimitiveRequiredStruct is required")
}
if !int16FieldIsSet {
return errors.New("field Int16Field of PrimitiveRequiredStruct is required")
}
if !int32FieldIsSet {
return errors.New("field Int32Field of PrimitiveRequiredStruct is required")
}
if !int64FieldIsSet {
return errors.New("field Int64Field of PrimitiveRequiredStruct is required")
}
if !doubleFieldIsSet {
return errors.New("field DoubleField of PrimitiveRequiredStruct is required")
}
if !stringFieldIsSet {
return errors.New("field StringField of PrimitiveRequiredStruct is required")
}
if !binaryFieldIsSet {
return errors.New("field BinaryField of PrimitiveRequiredStruct is required")
}
if !listOfStringsIsSet {
return errors.New("field ListOfStrings of PrimitiveRequiredStruct is required")
}
if !setOfIntsIsSet {
return errors.New("field SetOfInts of PrimitiveRequiredStruct is required")
}
if !mapOfIntsToDoublesIsSet {
return errors.New("field MapOfIntsToDoubles of PrimitiveRequiredStruct is required")
}
return nil
}
// String returns a readable string representation of a PrimitiveRequiredStruct
// struct.
func (v *PrimitiveRequiredStruct) String() string {
if v == nil {
return "<nil>"
}
var fields [11]string
i := 0
fields[i] = fmt.Sprintf("BoolField: %v", v.BoolField)
i++
fields[i] = fmt.Sprintf("ByteField: %v", v.ByteField)
i++
fields[i] = fmt.Sprintf("Int16Field: %v", v.Int16Field)
i++
fields[i] = fmt.Sprintf("Int32Field: %v", v.Int32Field)
i++
fields[i] = fmt.Sprintf("Int64Field: %v", v.Int64Field)
i++
fields[i] = fmt.Sprintf("DoubleField: %v", v.DoubleField)
i++
fields[i] = fmt.Sprintf("StringField: %v", v.StringField)
i++
fields[i] = fmt.Sprintf("BinaryField: %v", v.BinaryField)
i++
fields[i] = fmt.Sprintf("ListOfStrings: %v", v.ListOfStrings)
i++
fields[i] = fmt.Sprintf("SetOfInts: %v", v.SetOfInts)
i++
fields[i] = fmt.Sprintf("MapOfIntsToDoubles: %v", v.MapOfIntsToDoubles)
i++
return fmt.Sprintf("PrimitiveRequiredStruct{%v}", strings.Join(fields[:i], ", "))
}
func _List_String_Equals(lhs, rhs []string) bool {
if len(lhs) != len(rhs) {
return false
}
for i, lv := range lhs {
rv := rhs[i]
if !(lv == rv) {
return false
}
}
return true
}
func _Set_I32_mapType_Equals(lhs, rhs map[int32]struct{}) bool {
if len(lhs) != len(rhs) {
return false
}
for x := range rhs {
if _, ok := lhs[x]; !ok {
return false
}
}
return true
}
func _Map_I64_Double_Equals(lhs, rhs map[int64]float64) bool {
if len(lhs) != len(rhs) {
return false
}
for lk, lv := range lhs {
rv, ok := rhs[lk]
if !ok {
return false
}
if !(lv == rv) {
return false
}
}
return true
}
// Equals returns true if all the fields of this PrimitiveRequiredStruct match the
// provided PrimitiveRequiredStruct.
//
// This function performs a deep comparison.
func (v *PrimitiveRequiredStruct) Equals(rhs *PrimitiveRequiredStruct) bool {
if v == nil {
return rhs == nil
} else if rhs == nil {
return false
}
if !(v.BoolField == rhs.BoolField) {
return false
}
if !(v.ByteField == rhs.ByteField) {
return false
}
if !(v.Int16Field == rhs.Int16Field) {
return false
}
if !(v.Int32Field == rhs.Int32Field) {
return false
}
if !(v.Int64Field == rhs.Int64Field) {
return false
}
if !(v.DoubleField == rhs.DoubleField) {
return false
}
if !(v.StringField == rhs.StringField) {
return false
}
if !bytes.Equal(v.BinaryField, rhs.BinaryField) {
return false
}
if !_List_String_Equals(v.ListOfStrings, rhs.ListOfStrings) {
return false
}
if !_Set_I32_mapType_Equals(v.SetOfInts, rhs.SetOfInts) {
return false
}
if !_Map_I64_Double_Equals(v.MapOfIntsToDoubles, rhs.MapOfIntsToDoubles) {
return false
}
return true
}
// GetBoolField returns the value of BoolField if it is set or its
// zero value if it is unset.
func (v *PrimitiveRequiredStruct) GetBoolField() (o bool) {
if v != nil {
o = v.BoolField
}
return
}
// GetByteField returns the value of ByteField if it is set or its
// zero value if it is unset.
func (v *PrimitiveRequiredStruct) GetByteField() (o int8) {
if v != nil {
o = v.ByteField
}
return
}
// GetInt16Field returns the value of Int16Field if it is set or its
// zero value if it is unset.
func (v *PrimitiveRequiredStruct) GetInt16Field() (o int16) {
if v != nil {
o = v.Int16Field
}
return
}
// GetInt32Field returns the value of Int32Field if it is set or its
// zero value if it is unset.
func (v *PrimitiveRequiredStruct) GetInt32Field() (o int32) {
if v != nil {
o = v.Int32Field
}
return
}
// GetInt64Field returns the value of Int64Field if it is set or its
// zero value if it is unset.
func (v *PrimitiveRequiredStruct) GetInt64Field() (o int64) {
if v != nil {
o = v.Int64Field
}
return
}
// GetDoubleField returns the value of DoubleField if it is set or its
// zero value if it is unset.
func (v *PrimitiveRequiredStruct) GetDoubleField() (o float64) {
if v != nil {
o = v.DoubleField
}
return
}
// GetStringField returns the value of StringField if it is set or its
// zero value if it is unset.
func (v *PrimitiveRequiredStruct) GetStringField() (o string) {
if v != nil {
o = v.StringField
}
return
}
// GetBinaryField returns the value of BinaryField if it is set or its
// zero value if it is unset.
func (v *PrimitiveRequiredStruct) GetBinaryField() (o []byte) {
if v != nil {
o = v.BinaryField
}
return
}
// IsSetBinaryField returns true if BinaryField is not nil.
func (v *PrimitiveRequiredStruct) IsSetBinaryField() bool {
return v != nil && v.BinaryField != nil
}
// GetListOfStrings returns the value of ListOfStrings if it is set or its
// zero value if it is unset.
func (v *PrimitiveRequiredStruct) GetListOfStrings() (o []string) {
if v != nil {
o = v.ListOfStrings
}
return
}
// IsSetListOfStrings returns true if ListOfStrings is not nil.
func (v *PrimitiveRequiredStruct) IsSetListOfStrings() bool {
return v != nil && v.ListOfStrings != nil
}
// GetSetOfInts returns the value of SetOfInts if it is set or its
// zero value if it is unset.
func (v *PrimitiveRequiredStruct) GetSetOfInts() (o map[int32]struct{}) {
if v != nil {
o = v.SetOfInts
}
return
}
// IsSetSetOfInts returns true if SetOfInts is not nil.
func (v *PrimitiveRequiredStruct) IsSetSetOfInts() bool {
return v != nil && v.SetOfInts != nil
}
// GetMapOfIntsToDoubles returns the value of MapOfIntsToDoubles if it is set or its
// zero value if it is unset.
func (v *PrimitiveRequiredStruct) GetMapOfIntsToDoubles() (o map[int64]float64) {
if v != nil {
o = v.MapOfIntsToDoubles
}
return
}
// IsSetMapOfIntsToDoubles returns true if MapOfIntsToDoubles is not nil.
func (v *PrimitiveRequiredStruct) IsSetMapOfIntsToDoubles() bool {
return v != nil && v.MapOfIntsToDoubles != nil
}
type Primitives PrimitiveRequiredStruct
// ToWire translates Primitives into a Thrift-level intermediate
// representation. This intermediate representation may be serialized
// into bytes using a ThriftRW protocol implementation.
func (v *Primitives) ToWire() (wire.Value, error) {
x := (*PrimitiveRequiredStruct)(v)
return x.ToWire()
}
// String returns a readable string representation of Primitives.
func (v *Primitives) String() string {
x := (*PrimitiveRequiredStruct)(v)
return fmt.Sprint(x)
}
// FromWire deserializes Primitives from its Thrift-level
// representation. The Thrift-level representation may be obtained
// from a ThriftRW protocol implementation.
func (v *Primitives) FromWire(w wire.Value) error {
return (*PrimitiveRequiredStruct)(v).FromWire(w)
}
// Equals returns true if this Primitives is equal to the provided
// Primitives.
func (lhs *Primitives) Equals(rhs *Primitives) bool {
return (*PrimitiveRequiredStruct)(lhs).Equals((*PrimitiveRequiredStruct)(rhs))
}
type StringList []string
// ToWire translates StringList into a Thrift-level intermediate
// representation. This intermediate representation may be serialized
// into bytes using a ThriftRW protocol implementation.
func (v StringList) ToWire() (wire.Value, error) {
x := ([]string)(v)
return wire.NewValueList(_List_String_ValueList(x)), error(nil)
}
// String returns a readable string representation of StringList.
func (v StringList) String() string {
x := ([]string)(v)
return fmt.Sprint(x)
}
// FromWire deserializes StringList from its Thrift-level
// representation. The Thrift-level representation may be obtained
// from a ThriftRW protocol implementation.
func (v *StringList) FromWire(w wire.Value) error {
x, err := _List_String_Read(w.GetList())
*v = (StringList)(x)
return err
}
// Equals returns true if this StringList is equal to the provided
// StringList.
func (lhs StringList) Equals(rhs StringList) bool {
return _List_String_Equals(([]string)(lhs), ([]string)(rhs))
}
type _Map_String_String_MapItemList map[string]string
func (m _Map_String_String_MapItemList) ForEach(f func(wire.MapItem) error) error {
for k, v := range m {
kw, err := wire.NewValueString(k), error(nil)
if err != nil {
return err
}
vw, err := wire.NewValueString(v), error(nil)
if err != nil {
return err
}
err = f(wire.MapItem{Key: kw, Value: vw})
if err != nil {
return err
}
}
return nil
}
func (m _Map_String_String_MapItemList) Size() int {
return len(m)
}
func (_Map_String_String_MapItemList) KeyType() wire.Type {
return wire.TBinary
}
func (_Map_String_String_MapItemList) ValueType() wire.Type {
return wire.TBinary
}
func (_Map_String_String_MapItemList) Close() {}
func _Map_String_String_Read(m wire.MapItemList) (map[string]string, error) {
if m.KeyType() != wire.TBinary {
return nil, nil
}
if m.ValueType() != wire.TBinary {
return nil, nil
}
o := make(map[string]string, m.Size())
err := m.ForEach(func(x wire.MapItem) error {
k, err := x.Key.GetString(), error(nil)
if err != nil {
return err
}
v, err := x.Value.GetString(), error(nil)
if err != nil {
return err
}
o[k] = v
return nil
})
m.Close()