Subversion Repositories SmartDukaan

Rev

Rev 3430 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1969 rajveer 1
/**
2
 * Autogenerated by Thrift
3
 *
4
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
5
 */
6
package in.shop2020.model.v1.catalog;
7
 
8
import java.util.List;
9
import java.util.ArrayList;
10
import java.util.Map;
11
import java.util.HashMap;
12
import java.util.EnumMap;
13
import java.util.Set;
14
import java.util.HashSet;
15
import java.util.EnumSet;
16
import java.util.Collections;
17
import java.util.BitSet;
18
import java.util.Arrays;
19
import org.slf4j.Logger;
20
import org.slf4j.LoggerFactory;
21
 
22
import org.apache.thrift.*;
23
import org.apache.thrift.meta_data.*;
24
import org.apache.thrift.protocol.*;
25
 
26
public class Category implements TBase<Category._Fields>, java.io.Serializable, Cloneable, Comparable<Category> {
27
  private static final TStruct STRUCT_DESC = new TStruct("Category");
28
 
29
  private static final TField ID_FIELD_DESC = new TField("id", TType.I64, (short)1);
30
  private static final TField LABEL_FIELD_DESC = new TField("label", TType.STRING, (short)2);
31
  private static final TField DESCRIPTION_FIELD_DESC = new TField("description", TType.STRING, (short)3);
32
  private static final TField PARENT_CATEGORY_ID_FIELD_DESC = new TField("parent_category_id", TType.I64, (short)4);
33
  private static final TField CHILDREN_CATEGORY_IDS_FIELD_DESC = new TField("children_category_ids", TType.LIST, (short)5);
34
 
35
  private long id;
36
  private String label;
37
  private String description;
38
  private long parent_category_id;
39
  private List<Long> children_category_ids;
40
 
41
  /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
42
  public enum _Fields implements TFieldIdEnum {
43
    ID((short)1, "id"),
44
    LABEL((short)2, "label"),
45
    DESCRIPTION((short)3, "description"),
46
    PARENT_CATEGORY_ID((short)4, "parent_category_id"),
47
    /**
48
     * This field should not be used.
49
     */
50
    CHILDREN_CATEGORY_IDS((short)5, "children_category_ids");
51
 
52
    private static final Map<Integer, _Fields> byId = new HashMap<Integer, _Fields>();
53
    private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
54
 
55
    static {
56
      for (_Fields field : EnumSet.allOf(_Fields.class)) {
57
        byId.put((int)field._thriftId, field);
58
        byName.put(field.getFieldName(), field);
59
      }
60
    }
61
 
62
    /**
63
     * Find the _Fields constant that matches fieldId, or null if its not found.
64
     */
65
    public static _Fields findByThriftId(int fieldId) {
66
      return byId.get(fieldId);
67
    }
68
 
69
    /**
70
     * Find the _Fields constant that matches fieldId, throwing an exception
71
     * if it is not found.
72
     */
73
    public static _Fields findByThriftIdOrThrow(int fieldId) {
74
      _Fields fields = findByThriftId(fieldId);
75
      if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
76
      return fields;
77
    }
78
 
79
    /**
80
     * Find the _Fields constant that matches name, or null if its not found.
81
     */
82
    public static _Fields findByName(String name) {
83
      return byName.get(name);
84
    }
85
 
86
    private final short _thriftId;
87
    private final String _fieldName;
88
 
89
    _Fields(short thriftId, String fieldName) {
90
      _thriftId = thriftId;
91
      _fieldName = fieldName;
92
    }
93
 
94
    public short getThriftFieldId() {
95
      return _thriftId;
96
    }
97
 
98
    public String getFieldName() {
99
      return _fieldName;
100
    }
101
  }
102
 
103
  // isset id assignments
104
  private static final int __ID_ISSET_ID = 0;
105
  private static final int __PARENT_CATEGORY_ID_ISSET_ID = 1;
106
  private BitSet __isset_bit_vector = new BitSet(2);
107
 
108
  public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
109
    put(_Fields.ID, new FieldMetaData("id", TFieldRequirementType.DEFAULT, 
110
        new FieldValueMetaData(TType.I64)));
111
    put(_Fields.LABEL, new FieldMetaData("label", TFieldRequirementType.DEFAULT, 
112
        new FieldValueMetaData(TType.STRING)));
113
    put(_Fields.DESCRIPTION, new FieldMetaData("description", TFieldRequirementType.DEFAULT, 
114
        new FieldValueMetaData(TType.STRING)));
115
    put(_Fields.PARENT_CATEGORY_ID, new FieldMetaData("parent_category_id", TFieldRequirementType.DEFAULT, 
116
        new FieldValueMetaData(TType.I64)));
117
    put(_Fields.CHILDREN_CATEGORY_IDS, new FieldMetaData("children_category_ids", TFieldRequirementType.DEFAULT, 
118
        new ListMetaData(TType.LIST, 
119
            new FieldValueMetaData(TType.I64))));
120
  }});
121
 
122
  static {
123
    FieldMetaData.addStructMetaDataMap(Category.class, metaDataMap);
124
  }
125
 
126
  public Category() {
127
  }
128
 
129
  public Category(
130
    long id,
131
    String label,
132
    String description,
133
    long parent_category_id,
134
    List<Long> children_category_ids)
135
  {
136
    this();
137
    this.id = id;
138
    setIdIsSet(true);
139
    this.label = label;
140
    this.description = description;
141
    this.parent_category_id = parent_category_id;
142
    setParent_category_idIsSet(true);
143
    this.children_category_ids = children_category_ids;
144
  }
145
 
146
  /**
147
   * Performs a deep copy on <i>other</i>.
148
   */
149
  public Category(Category other) {
150
    __isset_bit_vector.clear();
151
    __isset_bit_vector.or(other.__isset_bit_vector);
152
    this.id = other.id;
153
    if (other.isSetLabel()) {
154
      this.label = other.label;
155
    }
156
    if (other.isSetDescription()) {
157
      this.description = other.description;
158
    }
159
    this.parent_category_id = other.parent_category_id;
160
    if (other.isSetChildren_category_ids()) {
161
      List<Long> __this__children_category_ids = new ArrayList<Long>();
162
      for (Long other_element : other.children_category_ids) {
163
        __this__children_category_ids.add(other_element);
164
      }
165
      this.children_category_ids = __this__children_category_ids;
166
    }
167
  }
168
 
169
  public Category deepCopy() {
170
    return new Category(this);
171
  }
172
 
173
  @Deprecated
174
  public Category clone() {
175
    return new Category(this);
176
  }
177
 
178
  public long getId() {
179
    return this.id;
180
  }
181
 
182
  public Category setId(long id) {
183
    this.id = id;
184
    setIdIsSet(true);
185
    return this;
186
  }
187
 
188
  public void unsetId() {
189
    __isset_bit_vector.clear(__ID_ISSET_ID);
190
  }
191
 
192
  /** Returns true if field id is set (has been asigned a value) and false otherwise */
193
  public boolean isSetId() {
194
    return __isset_bit_vector.get(__ID_ISSET_ID);
195
  }
196
 
197
  public void setIdIsSet(boolean value) {
198
    __isset_bit_vector.set(__ID_ISSET_ID, value);
199
  }
200
 
201
  public String getLabel() {
202
    return this.label;
203
  }
204
 
205
  public Category setLabel(String label) {
206
    this.label = label;
207
    return this;
208
  }
209
 
210
  public void unsetLabel() {
211
    this.label = null;
212
  }
213
 
214
  /** Returns true if field label is set (has been asigned a value) and false otherwise */
215
  public boolean isSetLabel() {
216
    return this.label != null;
217
  }
218
 
219
  public void setLabelIsSet(boolean value) {
220
    if (!value) {
221
      this.label = null;
222
    }
223
  }
224
 
225
  public String getDescription() {
226
    return this.description;
227
  }
228
 
229
  public Category setDescription(String description) {
230
    this.description = description;
231
    return this;
232
  }
233
 
234
  public void unsetDescription() {
235
    this.description = null;
236
  }
237
 
238
  /** Returns true if field description is set (has been asigned a value) and false otherwise */
239
  public boolean isSetDescription() {
240
    return this.description != null;
241
  }
242
 
243
  public void setDescriptionIsSet(boolean value) {
244
    if (!value) {
245
      this.description = null;
246
    }
247
  }
248
 
249
  public long getParent_category_id() {
250
    return this.parent_category_id;
251
  }
252
 
253
  public Category setParent_category_id(long parent_category_id) {
254
    this.parent_category_id = parent_category_id;
255
    setParent_category_idIsSet(true);
256
    return this;
257
  }
258
 
259
  public void unsetParent_category_id() {
260
    __isset_bit_vector.clear(__PARENT_CATEGORY_ID_ISSET_ID);
261
  }
262
 
263
  /** Returns true if field parent_category_id is set (has been asigned a value) and false otherwise */
264
  public boolean isSetParent_category_id() {
265
    return __isset_bit_vector.get(__PARENT_CATEGORY_ID_ISSET_ID);
266
  }
267
 
268
  public void setParent_category_idIsSet(boolean value) {
269
    __isset_bit_vector.set(__PARENT_CATEGORY_ID_ISSET_ID, value);
270
  }
271
 
272
  public int getChildren_category_idsSize() {
273
    return (this.children_category_ids == null) ? 0 : this.children_category_ids.size();
274
  }
275
 
276
  public java.util.Iterator<Long> getChildren_category_idsIterator() {
277
    return (this.children_category_ids == null) ? null : this.children_category_ids.iterator();
278
  }
279
 
280
  public void addToChildren_category_ids(long elem) {
281
    if (this.children_category_ids == null) {
282
      this.children_category_ids = new ArrayList<Long>();
283
    }
284
    this.children_category_ids.add(elem);
285
  }
286
 
287
  /**
288
   * This field should not be used.
289
   */
290
  public List<Long> getChildren_category_ids() {
291
    return this.children_category_ids;
292
  }
293
 
294
  /**
295
   * This field should not be used.
296
   */
297
  public Category setChildren_category_ids(List<Long> children_category_ids) {
298
    this.children_category_ids = children_category_ids;
299
    return this;
300
  }
301
 
302
  public void unsetChildren_category_ids() {
303
    this.children_category_ids = null;
304
  }
305
 
306
  /** Returns true if field children_category_ids is set (has been asigned a value) and false otherwise */
307
  public boolean isSetChildren_category_ids() {
308
    return this.children_category_ids != null;
309
  }
310
 
311
  public void setChildren_category_idsIsSet(boolean value) {
312
    if (!value) {
313
      this.children_category_ids = null;
314
    }
315
  }
316
 
317
  public void setFieldValue(_Fields field, Object value) {
318
    switch (field) {
319
    case ID:
320
      if (value == null) {
321
        unsetId();
322
      } else {
323
        setId((Long)value);
324
      }
325
      break;
326
 
327
    case LABEL:
328
      if (value == null) {
329
        unsetLabel();
330
      } else {
331
        setLabel((String)value);
332
      }
333
      break;
334
 
335
    case DESCRIPTION:
336
      if (value == null) {
337
        unsetDescription();
338
      } else {
339
        setDescription((String)value);
340
      }
341
      break;
342
 
343
    case PARENT_CATEGORY_ID:
344
      if (value == null) {
345
        unsetParent_category_id();
346
      } else {
347
        setParent_category_id((Long)value);
348
      }
349
      break;
350
 
351
    case CHILDREN_CATEGORY_IDS:
352
      if (value == null) {
353
        unsetChildren_category_ids();
354
      } else {
355
        setChildren_category_ids((List<Long>)value);
356
      }
357
      break;
358
 
359
    }
360
  }
361
 
362
  public void setFieldValue(int fieldID, Object value) {
363
    setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value);
364
  }
365
 
366
  public Object getFieldValue(_Fields field) {
367
    switch (field) {
368
    case ID:
369
      return new Long(getId());
370
 
371
    case LABEL:
372
      return getLabel();
373
 
374
    case DESCRIPTION:
375
      return getDescription();
376
 
377
    case PARENT_CATEGORY_ID:
378
      return new Long(getParent_category_id());
379
 
380
    case CHILDREN_CATEGORY_IDS:
381
      return getChildren_category_ids();
382
 
383
    }
384
    throw new IllegalStateException();
385
  }
386
 
387
  public Object getFieldValue(int fieldId) {
388
    return getFieldValue(_Fields.findByThriftIdOrThrow(fieldId));
389
  }
390
 
391
  /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
392
  public boolean isSet(_Fields field) {
393
    switch (field) {
394
    case ID:
395
      return isSetId();
396
    case LABEL:
397
      return isSetLabel();
398
    case DESCRIPTION:
399
      return isSetDescription();
400
    case PARENT_CATEGORY_ID:
401
      return isSetParent_category_id();
402
    case CHILDREN_CATEGORY_IDS:
403
      return isSetChildren_category_ids();
404
    }
405
    throw new IllegalStateException();
406
  }
407
 
408
  public boolean isSet(int fieldID) {
409
    return isSet(_Fields.findByThriftIdOrThrow(fieldID));
410
  }
411
 
412
  @Override
413
  public boolean equals(Object that) {
414
    if (that == null)
415
      return false;
416
    if (that instanceof Category)
417
      return this.equals((Category)that);
418
    return false;
419
  }
420
 
421
  public boolean equals(Category that) {
422
    if (that == null)
423
      return false;
424
 
425
    boolean this_present_id = true;
426
    boolean that_present_id = true;
427
    if (this_present_id || that_present_id) {
428
      if (!(this_present_id && that_present_id))
429
        return false;
430
      if (this.id != that.id)
431
        return false;
432
    }
433
 
434
    boolean this_present_label = true && this.isSetLabel();
435
    boolean that_present_label = true && that.isSetLabel();
436
    if (this_present_label || that_present_label) {
437
      if (!(this_present_label && that_present_label))
438
        return false;
439
      if (!this.label.equals(that.label))
440
        return false;
441
    }
442
 
443
    boolean this_present_description = true && this.isSetDescription();
444
    boolean that_present_description = true && that.isSetDescription();
445
    if (this_present_description || that_present_description) {
446
      if (!(this_present_description && that_present_description))
447
        return false;
448
      if (!this.description.equals(that.description))
449
        return false;
450
    }
451
 
452
    boolean this_present_parent_category_id = true;
453
    boolean that_present_parent_category_id = true;
454
    if (this_present_parent_category_id || that_present_parent_category_id) {
455
      if (!(this_present_parent_category_id && that_present_parent_category_id))
456
        return false;
457
      if (this.parent_category_id != that.parent_category_id)
458
        return false;
459
    }
460
 
461
    boolean this_present_children_category_ids = true && this.isSetChildren_category_ids();
462
    boolean that_present_children_category_ids = true && that.isSetChildren_category_ids();
463
    if (this_present_children_category_ids || that_present_children_category_ids) {
464
      if (!(this_present_children_category_ids && that_present_children_category_ids))
465
        return false;
466
      if (!this.children_category_ids.equals(that.children_category_ids))
467
        return false;
468
    }
469
 
470
    return true;
471
  }
472
 
473
  @Override
474
  public int hashCode() {
475
    return 0;
476
  }
477
 
478
  public int compareTo(Category other) {
479
    if (!getClass().equals(other.getClass())) {
480
      return getClass().getName().compareTo(other.getClass().getName());
481
    }
482
 
483
    int lastComparison = 0;
484
    Category typedOther = (Category)other;
485
 
486
    lastComparison = Boolean.valueOf(isSetId()).compareTo(isSetId());
487
    if (lastComparison != 0) {
488
      return lastComparison;
489
    }
490
    lastComparison = TBaseHelper.compareTo(id, typedOther.id);
491
    if (lastComparison != 0) {
492
      return lastComparison;
493
    }
494
    lastComparison = Boolean.valueOf(isSetLabel()).compareTo(isSetLabel());
495
    if (lastComparison != 0) {
496
      return lastComparison;
497
    }
498
    lastComparison = TBaseHelper.compareTo(label, typedOther.label);
499
    if (lastComparison != 0) {
500
      return lastComparison;
501
    }
502
    lastComparison = Boolean.valueOf(isSetDescription()).compareTo(isSetDescription());
503
    if (lastComparison != 0) {
504
      return lastComparison;
505
    }
506
    lastComparison = TBaseHelper.compareTo(description, typedOther.description);
507
    if (lastComparison != 0) {
508
      return lastComparison;
509
    }
510
    lastComparison = Boolean.valueOf(isSetParent_category_id()).compareTo(isSetParent_category_id());
511
    if (lastComparison != 0) {
512
      return lastComparison;
513
    }
514
    lastComparison = TBaseHelper.compareTo(parent_category_id, typedOther.parent_category_id);
515
    if (lastComparison != 0) {
516
      return lastComparison;
517
    }
518
    lastComparison = Boolean.valueOf(isSetChildren_category_ids()).compareTo(isSetChildren_category_ids());
519
    if (lastComparison != 0) {
520
      return lastComparison;
521
    }
522
    lastComparison = TBaseHelper.compareTo(children_category_ids, typedOther.children_category_ids);
523
    if (lastComparison != 0) {
524
      return lastComparison;
525
    }
526
    return 0;
527
  }
528
 
529
  public void read(TProtocol iprot) throws TException {
530
    TField field;
531
    iprot.readStructBegin();
532
    while (true)
533
    {
534
      field = iprot.readFieldBegin();
535
      if (field.type == TType.STOP) { 
536
        break;
537
      }
538
      _Fields fieldId = _Fields.findByThriftId(field.id);
539
      if (fieldId == null) {
540
        TProtocolUtil.skip(iprot, field.type);
541
      } else {
542
        switch (fieldId) {
543
          case ID:
544
            if (field.type == TType.I64) {
545
              this.id = iprot.readI64();
546
              setIdIsSet(true);
547
            } else { 
548
              TProtocolUtil.skip(iprot, field.type);
549
            }
550
            break;
551
          case LABEL:
552
            if (field.type == TType.STRING) {
553
              this.label = iprot.readString();
554
            } else { 
555
              TProtocolUtil.skip(iprot, field.type);
556
            }
557
            break;
558
          case DESCRIPTION:
559
            if (field.type == TType.STRING) {
560
              this.description = iprot.readString();
561
            } else { 
562
              TProtocolUtil.skip(iprot, field.type);
563
            }
564
            break;
565
          case PARENT_CATEGORY_ID:
566
            if (field.type == TType.I64) {
567
              this.parent_category_id = iprot.readI64();
568
              setParent_category_idIsSet(true);
569
            } else { 
570
              TProtocolUtil.skip(iprot, field.type);
571
            }
572
            break;
573
          case CHILDREN_CATEGORY_IDS:
574
            if (field.type == TType.LIST) {
575
              {
576
                TList _list10 = iprot.readListBegin();
577
                this.children_category_ids = new ArrayList<Long>(_list10.size);
578
                for (int _i11 = 0; _i11 < _list10.size; ++_i11)
579
                {
580
                  long _elem12;
581
                  _elem12 = iprot.readI64();
582
                  this.children_category_ids.add(_elem12);
583
                }
584
                iprot.readListEnd();
585
              }
586
            } else { 
587
              TProtocolUtil.skip(iprot, field.type);
588
            }
589
            break;
590
        }
591
        iprot.readFieldEnd();
592
      }
593
    }
594
    iprot.readStructEnd();
595
    validate();
596
  }
597
 
598
  public void write(TProtocol oprot) throws TException {
599
    validate();
600
 
601
    oprot.writeStructBegin(STRUCT_DESC);
602
    oprot.writeFieldBegin(ID_FIELD_DESC);
603
    oprot.writeI64(this.id);
604
    oprot.writeFieldEnd();
605
    if (this.label != null) {
606
      oprot.writeFieldBegin(LABEL_FIELD_DESC);
607
      oprot.writeString(this.label);
608
      oprot.writeFieldEnd();
609
    }
610
    if (this.description != null) {
611
      oprot.writeFieldBegin(DESCRIPTION_FIELD_DESC);
612
      oprot.writeString(this.description);
613
      oprot.writeFieldEnd();
614
    }
615
    oprot.writeFieldBegin(PARENT_CATEGORY_ID_FIELD_DESC);
616
    oprot.writeI64(this.parent_category_id);
617
    oprot.writeFieldEnd();
618
    if (this.children_category_ids != null) {
619
      oprot.writeFieldBegin(CHILDREN_CATEGORY_IDS_FIELD_DESC);
620
      {
621
        oprot.writeListBegin(new TList(TType.I64, this.children_category_ids.size()));
622
        for (long _iter13 : this.children_category_ids)
623
        {
624
          oprot.writeI64(_iter13);
625
        }
626
        oprot.writeListEnd();
627
      }
628
      oprot.writeFieldEnd();
629
    }
630
    oprot.writeFieldStop();
631
    oprot.writeStructEnd();
632
  }
633
 
634
  @Override
635
  public String toString() {
636
    StringBuilder sb = new StringBuilder("Category(");
637
    boolean first = true;
638
 
639
    sb.append("id:");
640
    sb.append(this.id);
641
    first = false;
642
    if (!first) sb.append(", ");
643
    sb.append("label:");
644
    if (this.label == null) {
645
      sb.append("null");
646
    } else {
647
      sb.append(this.label);
648
    }
649
    first = false;
650
    if (!first) sb.append(", ");
651
    sb.append("description:");
652
    if (this.description == null) {
653
      sb.append("null");
654
    } else {
655
      sb.append(this.description);
656
    }
657
    first = false;
658
    if (!first) sb.append(", ");
659
    sb.append("parent_category_id:");
660
    sb.append(this.parent_category_id);
661
    first = false;
662
    if (!first) sb.append(", ");
663
    sb.append("children_category_ids:");
664
    if (this.children_category_ids == null) {
665
      sb.append("null");
666
    } else {
667
      sb.append(this.children_category_ids);
668
    }
669
    first = false;
670
    sb.append(")");
671
    return sb.toString();
672
  }
673
 
674
  public void validate() throws TException {
675
    // check for required fields
676
  }
677
 
678
}
679