summaryrefslogtreecommitdiffstats
path: root/src/jaegertracing/thrift/lib/dart/test/serializer/serializer_test_data.dart
blob: 3586f08fc0f908b00cf9cc791503fd1d0da1b3ea (plain)
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
/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements. See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. The ASF licenses this file
 * to you 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.
 */

library thrift.test.serializer.serializer_test;

import 'package:thrift/thrift.dart';

/// TestTObject is a simple test struct
class TestTObject implements TBase {
  static final TStruct _STRUCT_DESC = new TStruct("TestTObject");
  static final TField _I_FIELD_DESC = new TField("i", TType.I32, 1);
  static final TField _D_FIELD_DESC = new TField("d", TType.DOUBLE, 2);
  static final TField _S_FIELD_DESC = new TField("s", TType.STRING, 3);
  static final TField _L_FIELD_DESC = new TField("l", TType.LIST, 4);
  static final TField _B_FIELD_DESC = new TField("b", TType.BOOL, 5);

  int _i;
  static const int I = 1;
  double _d;
  static const int D = 2;
  String _s;
  static const int S = 3;
  List<String> _l;
  static const int L = 4;
  bool _b;
  static const int B = 5;

  bool __isset_i = false;
  bool __isset_d = false;
  bool __isset_b = false;

  TestTObject() {
  }

  // i
  int get i => this._i;

  set i(int i) {
    this._i = i;
    this.__isset_i = true;
  }

  bool isSetI() => this.__isset_i;

  unsetI() {
    this.__isset_i = false;
  }

  // d
  double get d => this._d;

  set d(double d) {
    this._d = d;
    this.__isset_d = true;
  }

  bool isSetD() => this.__isset_d;

  unsetD() {
    this.__isset_d = false;
  }

  // s
  String get s => this._s;

  set s(String s) {
    this._s = s;
  }

  bool isSetS() => this.s != null;

  unsetS() {
    this.s = null;
  }

  // l
  List<String> get l => this._l;

  set l(List<String> l) {
    this._l = l;
  }

  bool isSetL() => this.l != null;

  unsetL() {
    this.l = null;
  }

  // b
  bool get b => this._b;

  set b(bool b) {
    this._b = b;
    this.__isset_b = true;
  }

  bool isSetB() => this.__isset_b;

  unsetB() {
    this.__isset_b = false;
  }

  getFieldValue(int fieldID) {
    switch (fieldID) {
      case I:
        return this.i;
      case D:
        return this.d;
      case S:
        return this.s;
      case L:
        return this.l;
      case B:
        return this.b;
      default:
        throw new ArgumentError("Field $fieldID doesn't exist!");
    }
  }

  setFieldValue(int fieldID, Object value) {
    switch (fieldID) {
      case I:
        if (value == null) {
          unsetI();
        } else {
          this.i = value;
        }
        break;

      case D:
        if (value == null) {
          unsetD();
        } else {
          this.d = value;
        }
        break;

      case S:
        if (value == null) {
          unsetS();
        } else {
          this.s = value;
        }
        break;

      case L:
        if (value == null) {
          unsetL();
        } else {
          this.l = value as List<String>;
        }
        break;

      case B:
        if (value == null) {
          unsetB();
        } else {
          this.b = value;
        }
        break;

      default:
        throw new ArgumentError("Field $fieldID doesn't exist!");
    }
  }

  // Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise
  bool isSet(int fieldID) {
    switch (fieldID) {
      case I:
        return isSetI();
      case D:
        return isSetD();
      case S:
        return isSetS();
      case L:
        return isSetL();
      case B:
        return isSetB();
      default:
        throw new ArgumentError("Field $fieldID doesn't exist!");
    }
  }

  read(TProtocol iprot) {
    TField field;
    iprot.readStructBegin();
    while (true) {
      field = iprot.readFieldBegin();
      if (field.type == TType.STOP) {
        break;
      }
      switch (field.id) {
        case I:
          if (field.type == TType.I32) {
            this.i = iprot.readI32();
            this.__isset_i = true;
          } else {
            TProtocolUtil.skip(iprot, field.type);
          }
          break;
        case D:
          if (field.type == TType.DOUBLE) {
            this.d = iprot.readDouble();
            this.__isset_d = true;
          } else {
            TProtocolUtil.skip(iprot, field.type);
          }
          break;
        case S:
          if (field.type == TType.STRING) {
            this.s = iprot.readString();
          } else {
            TProtocolUtil.skip(iprot, field.type);
          }
          break;
        case L:
          if (field.type == TType.LIST) {
            {
              TList _list74 = iprot.readListBegin();
              this.l = new List<String>();
              for (int _i75 = 0; _i75 < _list74.length; ++_i75) {
                String _elem76;
                _elem76 = iprot.readString();
                this.l.add(_elem76);
              }
              iprot.readListEnd();
            }
          } else {
            TProtocolUtil.skip(iprot, field.type);
          }
          break;
        case B:
          if (field.type == TType.BOOL) {
            this.b = iprot.readBool();
            this.__isset_b = true;
          } else {
            TProtocolUtil.skip(iprot, field.type);
          }
          break;
        default:
          TProtocolUtil.skip(iprot, field.type);
          break;
      }
      iprot.readFieldEnd();
    }
    iprot.readStructEnd();

    // check for required fields of primitive type, which can't be checked in the validate method
    validate();
  }

  write(TProtocol oprot) {
    validate();

    oprot.writeStructBegin(_STRUCT_DESC);
    oprot.writeFieldBegin(_I_FIELD_DESC);
    oprot.writeI32(this.i);
    oprot.writeFieldEnd();
    oprot.writeFieldBegin(_D_FIELD_DESC);
    oprot.writeDouble(this.d);
    oprot.writeFieldEnd();
    if (this.s != null) {
      oprot.writeFieldBegin(_S_FIELD_DESC);
      oprot.writeString(this.s);
      oprot.writeFieldEnd();
    }
    if (this.l != null) {
      oprot.writeFieldBegin(_L_FIELD_DESC);
      {
        oprot.writeListBegin(new TList(TType.STRING, this.l.length));
        for (var elem77 in this.l) {
          oprot.writeString(elem77);
        }
        oprot.writeListEnd();
      }
      oprot.writeFieldEnd();
    }
    oprot.writeFieldBegin(_B_FIELD_DESC);
    oprot.writeBool(this.b);
    oprot.writeFieldEnd();
    oprot.writeFieldStop();
    oprot.writeStructEnd();
  }

  String toString() {
    StringBuffer ret = new StringBuffer("TestTObject(");

    ret.write("i:");
    ret.write(this.i);

    ret.write(", ");
    ret.write("d:");
    ret.write(this.d);

    ret.write(", ");
    ret.write("s:");
    if (this.s == null) {
      ret.write("null");
    } else {
      ret.write(this.s);
    }

    ret.write(", ");
    ret.write("l:");
    if (this.l == null) {
      ret.write("null");
    } else {
      ret.write(this.l);
    }

    ret.write(", ");
    ret.write("b:");
    ret.write(this.b);

    ret.write(")");

    return ret.toString();
  }

  validate() {
    // check for required fields
    // check that fields of type enum have valid values
  }

}