Subversion Repositories SmartDukaan

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
130 ashish 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.user;
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
/**
27
 * Phone
28
 * 
29
 */
30
public class Phone implements TBase<Phone._Fields>, java.io.Serializable, Cloneable, Comparable<Phone> {
31
  private static final TStruct STRUCT_DESC = new TStruct("Phone");
32
 
33
  private static final TField ID_FIELD_DESC = new TField("id", TType.I64, (short)1);
34
  private static final TField COUNTRY_CODE_FIELD_DESC = new TField("countryCode", TType.STRING, (short)2);
35
  private static final TField AREA_CODE_FIELD_DESC = new TField("areaCode", TType.STRING, (short)3);
36
  private static final TField NUMBER_FIELD_DESC = new TField("number", TType.STRING, (short)4);
37
  private static final TField EXTENSION_FIELD_DESC = new TField("extension", TType.STRING, (short)5);
38
  private static final TField TYPE_FIELD_DESC = new TField("type", TType.I32, (short)6);
39
 
40
  private long id;
41
  private String countryCode;
42
  private String areaCode;
43
  private String number;
44
  private String extension;
45
  private PhoneType type;
46
 
47
  /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
48
  public enum _Fields implements TFieldIdEnum {
49
    ID((short)1, "id"),
50
    COUNTRY_CODE((short)2, "countryCode"),
51
    AREA_CODE((short)3, "areaCode"),
52
    NUMBER((short)4, "number"),
53
    EXTENSION((short)5, "extension"),
54
    /**
55
     * 
56
     * @see PhoneType
57
     */
58
    TYPE((short)6, "type");
59
 
60
    private static final Map<Integer, _Fields> byId = new HashMap<Integer, _Fields>();
61
    private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
62
 
63
    static {
64
      for (_Fields field : EnumSet.allOf(_Fields.class)) {
65
        byId.put((int)field._thriftId, field);
66
        byName.put(field.getFieldName(), field);
67
      }
68
    }
69
 
70
    /**
71
     * Find the _Fields constant that matches fieldId, or null if its not found.
72
     */
73
    public static _Fields findByThriftId(int fieldId) {
74
      return byId.get(fieldId);
75
    }
76
 
77
    /**
78
     * Find the _Fields constant that matches fieldId, throwing an exception
79
     * if it is not found.
80
     */
81
    public static _Fields findByThriftIdOrThrow(int fieldId) {
82
      _Fields fields = findByThriftId(fieldId);
83
      if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
84
      return fields;
85
    }
86
 
87
    /**
88
     * Find the _Fields constant that matches name, or null if its not found.
89
     */
90
    public static _Fields findByName(String name) {
91
      return byName.get(name);
92
    }
93
 
94
    private final short _thriftId;
95
    private final String _fieldName;
96
 
97
    _Fields(short thriftId, String fieldName) {
98
      _thriftId = thriftId;
99
      _fieldName = fieldName;
100
    }
101
 
102
    public short getThriftFieldId() {
103
      return _thriftId;
104
    }
105
 
106
    public String getFieldName() {
107
      return _fieldName;
108
    }
109
  }
110
 
111
  // isset id assignments
112
  private static final int __ID_ISSET_ID = 0;
113
  private BitSet __isset_bit_vector = new BitSet(1);
114
 
115
  public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
116
    put(_Fields.ID, new FieldMetaData("id", TFieldRequirementType.DEFAULT, 
117
        new FieldValueMetaData(TType.I64)));
118
    put(_Fields.COUNTRY_CODE, new FieldMetaData("countryCode", TFieldRequirementType.DEFAULT, 
119
        new FieldValueMetaData(TType.STRING)));
120
    put(_Fields.AREA_CODE, new FieldMetaData("areaCode", TFieldRequirementType.DEFAULT, 
121
        new FieldValueMetaData(TType.STRING)));
122
    put(_Fields.NUMBER, new FieldMetaData("number", TFieldRequirementType.DEFAULT, 
123
        new FieldValueMetaData(TType.STRING)));
124
    put(_Fields.EXTENSION, new FieldMetaData("extension", TFieldRequirementType.DEFAULT, 
125
        new FieldValueMetaData(TType.STRING)));
126
    put(_Fields.TYPE, new FieldMetaData("type", TFieldRequirementType.DEFAULT, 
127
        new EnumMetaData(TType.ENUM, PhoneType.class)));
128
  }});
129
 
130
  static {
131
    FieldMetaData.addStructMetaDataMap(Phone.class, metaDataMap);
132
  }
133
 
134
  public Phone() {
135
  }
136
 
137
  public Phone(
138
    long id,
139
    String countryCode,
140
    String areaCode,
141
    String number,
142
    String extension,
143
    PhoneType type)
144
  {
145
    this();
146
    this.id = id;
147
    setIdIsSet(true);
148
    this.countryCode = countryCode;
149
    this.areaCode = areaCode;
150
    this.number = number;
151
    this.extension = extension;
152
    this.type = type;
153
  }
154
 
155
  /**
156
   * Performs a deep copy on <i>other</i>.
157
   */
158
  public Phone(Phone other) {
159
    __isset_bit_vector.clear();
160
    __isset_bit_vector.or(other.__isset_bit_vector);
161
    this.id = other.id;
162
    if (other.isSetCountryCode()) {
163
      this.countryCode = other.countryCode;
164
    }
165
    if (other.isSetAreaCode()) {
166
      this.areaCode = other.areaCode;
167
    }
168
    if (other.isSetNumber()) {
169
      this.number = other.number;
170
    }
171
    if (other.isSetExtension()) {
172
      this.extension = other.extension;
173
    }
174
    if (other.isSetType()) {
175
      this.type = other.type;
176
    }
177
  }
178
 
179
  public Phone deepCopy() {
180
    return new Phone(this);
181
  }
182
 
183
  @Deprecated
184
  public Phone clone() {
185
    return new Phone(this);
186
  }
187
 
188
  public long getId() {
189
    return this.id;
190
  }
191
 
192
  public Phone setId(long id) {
193
    this.id = id;
194
    setIdIsSet(true);
195
    return this;
196
  }
197
 
198
  public void unsetId() {
199
    __isset_bit_vector.clear(__ID_ISSET_ID);
200
  }
201
 
202
  /** Returns true if field id is set (has been asigned a value) and false otherwise */
203
  public boolean isSetId() {
204
    return __isset_bit_vector.get(__ID_ISSET_ID);
205
  }
206
 
207
  public void setIdIsSet(boolean value) {
208
    __isset_bit_vector.set(__ID_ISSET_ID, value);
209
  }
210
 
211
  public String getCountryCode() {
212
    return this.countryCode;
213
  }
214
 
215
  public Phone setCountryCode(String countryCode) {
216
    this.countryCode = countryCode;
217
    return this;
218
  }
219
 
220
  public void unsetCountryCode() {
221
    this.countryCode = null;
222
  }
223
 
224
  /** Returns true if field countryCode is set (has been asigned a value) and false otherwise */
225
  public boolean isSetCountryCode() {
226
    return this.countryCode != null;
227
  }
228
 
229
  public void setCountryCodeIsSet(boolean value) {
230
    if (!value) {
231
      this.countryCode = null;
232
    }
233
  }
234
 
235
  public String getAreaCode() {
236
    return this.areaCode;
237
  }
238
 
239
  public Phone setAreaCode(String areaCode) {
240
    this.areaCode = areaCode;
241
    return this;
242
  }
243
 
244
  public void unsetAreaCode() {
245
    this.areaCode = null;
246
  }
247
 
248
  /** Returns true if field areaCode is set (has been asigned a value) and false otherwise */
249
  public boolean isSetAreaCode() {
250
    return this.areaCode != null;
251
  }
252
 
253
  public void setAreaCodeIsSet(boolean value) {
254
    if (!value) {
255
      this.areaCode = null;
256
    }
257
  }
258
 
259
  public String getNumber() {
260
    return this.number;
261
  }
262
 
263
  public Phone setNumber(String number) {
264
    this.number = number;
265
    return this;
266
  }
267
 
268
  public void unsetNumber() {
269
    this.number = null;
270
  }
271
 
272
  /** Returns true if field number is set (has been asigned a value) and false otherwise */
273
  public boolean isSetNumber() {
274
    return this.number != null;
275
  }
276
 
277
  public void setNumberIsSet(boolean value) {
278
    if (!value) {
279
      this.number = null;
280
    }
281
  }
282
 
283
  public String getExtension() {
284
    return this.extension;
285
  }
286
 
287
  public Phone setExtension(String extension) {
288
    this.extension = extension;
289
    return this;
290
  }
291
 
292
  public void unsetExtension() {
293
    this.extension = null;
294
  }
295
 
296
  /** Returns true if field extension is set (has been asigned a value) and false otherwise */
297
  public boolean isSetExtension() {
298
    return this.extension != null;
299
  }
300
 
301
  public void setExtensionIsSet(boolean value) {
302
    if (!value) {
303
      this.extension = null;
304
    }
305
  }
306
 
307
  /**
308
   * 
309
   * @see PhoneType
310
   */
311
  public PhoneType getType() {
312
    return this.type;
313
  }
314
 
315
  /**
316
   * 
317
   * @see PhoneType
318
   */
319
  public Phone setType(PhoneType type) {
320
    this.type = type;
321
    return this;
322
  }
323
 
324
  public void unsetType() {
325
    this.type = null;
326
  }
327
 
328
  /** Returns true if field type is set (has been asigned a value) and false otherwise */
329
  public boolean isSetType() {
330
    return this.type != null;
331
  }
332
 
333
  public void setTypeIsSet(boolean value) {
334
    if (!value) {
335
      this.type = null;
336
    }
337
  }
338
 
339
  public void setFieldValue(_Fields field, Object value) {
340
    switch (field) {
341
    case ID:
342
      if (value == null) {
343
        unsetId();
344
      } else {
345
        setId((Long)value);
346
      }
347
      break;
348
 
349
    case COUNTRY_CODE:
350
      if (value == null) {
351
        unsetCountryCode();
352
      } else {
353
        setCountryCode((String)value);
354
      }
355
      break;
356
 
357
    case AREA_CODE:
358
      if (value == null) {
359
        unsetAreaCode();
360
      } else {
361
        setAreaCode((String)value);
362
      }
363
      break;
364
 
365
    case NUMBER:
366
      if (value == null) {
367
        unsetNumber();
368
      } else {
369
        setNumber((String)value);
370
      }
371
      break;
372
 
373
    case EXTENSION:
374
      if (value == null) {
375
        unsetExtension();
376
      } else {
377
        setExtension((String)value);
378
      }
379
      break;
380
 
381
    case TYPE:
382
      if (value == null) {
383
        unsetType();
384
      } else {
385
        setType((PhoneType)value);
386
      }
387
      break;
388
 
389
    }
390
  }
391
 
392
  public void setFieldValue(int fieldID, Object value) {
393
    setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value);
394
  }
395
 
396
  public Object getFieldValue(_Fields field) {
397
    switch (field) {
398
    case ID:
399
      return new Long(getId());
400
 
401
    case COUNTRY_CODE:
402
      return getCountryCode();
403
 
404
    case AREA_CODE:
405
      return getAreaCode();
406
 
407
    case NUMBER:
408
      return getNumber();
409
 
410
    case EXTENSION:
411
      return getExtension();
412
 
413
    case TYPE:
414
      return getType();
415
 
416
    }
417
    throw new IllegalStateException();
418
  }
419
 
420
  public Object getFieldValue(int fieldId) {
421
    return getFieldValue(_Fields.findByThriftIdOrThrow(fieldId));
422
  }
423
 
424
  /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
425
  public boolean isSet(_Fields field) {
426
    switch (field) {
427
    case ID:
428
      return isSetId();
429
    case COUNTRY_CODE:
430
      return isSetCountryCode();
431
    case AREA_CODE:
432
      return isSetAreaCode();
433
    case NUMBER:
434
      return isSetNumber();
435
    case EXTENSION:
436
      return isSetExtension();
437
    case TYPE:
438
      return isSetType();
439
    }
440
    throw new IllegalStateException();
441
  }
442
 
443
  public boolean isSet(int fieldID) {
444
    return isSet(_Fields.findByThriftIdOrThrow(fieldID));
445
  }
446
 
447
  @Override
448
  public boolean equals(Object that) {
449
    if (that == null)
450
      return false;
451
    if (that instanceof Phone)
452
      return this.equals((Phone)that);
453
    return false;
454
  }
455
 
456
  public boolean equals(Phone that) {
457
    if (that == null)
458
      return false;
459
 
460
    boolean this_present_id = true;
461
    boolean that_present_id = true;
462
    if (this_present_id || that_present_id) {
463
      if (!(this_present_id && that_present_id))
464
        return false;
465
      if (this.id != that.id)
466
        return false;
467
    }
468
 
469
    boolean this_present_countryCode = true && this.isSetCountryCode();
470
    boolean that_present_countryCode = true && that.isSetCountryCode();
471
    if (this_present_countryCode || that_present_countryCode) {
472
      if (!(this_present_countryCode && that_present_countryCode))
473
        return false;
474
      if (!this.countryCode.equals(that.countryCode))
475
        return false;
476
    }
477
 
478
    boolean this_present_areaCode = true && this.isSetAreaCode();
479
    boolean that_present_areaCode = true && that.isSetAreaCode();
480
    if (this_present_areaCode || that_present_areaCode) {
481
      if (!(this_present_areaCode && that_present_areaCode))
482
        return false;
483
      if (!this.areaCode.equals(that.areaCode))
484
        return false;
485
    }
486
 
487
    boolean this_present_number = true && this.isSetNumber();
488
    boolean that_present_number = true && that.isSetNumber();
489
    if (this_present_number || that_present_number) {
490
      if (!(this_present_number && that_present_number))
491
        return false;
492
      if (!this.number.equals(that.number))
493
        return false;
494
    }
495
 
496
    boolean this_present_extension = true && this.isSetExtension();
497
    boolean that_present_extension = true && that.isSetExtension();
498
    if (this_present_extension || that_present_extension) {
499
      if (!(this_present_extension && that_present_extension))
500
        return false;
501
      if (!this.extension.equals(that.extension))
502
        return false;
503
    }
504
 
505
    boolean this_present_type = true && this.isSetType();
506
    boolean that_present_type = true && that.isSetType();
507
    if (this_present_type || that_present_type) {
508
      if (!(this_present_type && that_present_type))
509
        return false;
510
      if (!this.type.equals(that.type))
511
        return false;
512
    }
513
 
514
    return true;
515
  }
516
 
517
  @Override
518
  public int hashCode() {
519
    return 0;
520
  }
521
 
522
  public int compareTo(Phone other) {
523
    if (!getClass().equals(other.getClass())) {
524
      return getClass().getName().compareTo(other.getClass().getName());
525
    }
526
 
527
    int lastComparison = 0;
528
    Phone typedOther = (Phone)other;
529
 
530
    lastComparison = Boolean.valueOf(isSetId()).compareTo(isSetId());
531
    if (lastComparison != 0) {
532
      return lastComparison;
533
    }
534
    lastComparison = TBaseHelper.compareTo(id, typedOther.id);
535
    if (lastComparison != 0) {
536
      return lastComparison;
537
    }
538
    lastComparison = Boolean.valueOf(isSetCountryCode()).compareTo(isSetCountryCode());
539
    if (lastComparison != 0) {
540
      return lastComparison;
541
    }
542
    lastComparison = TBaseHelper.compareTo(countryCode, typedOther.countryCode);
543
    if (lastComparison != 0) {
544
      return lastComparison;
545
    }
546
    lastComparison = Boolean.valueOf(isSetAreaCode()).compareTo(isSetAreaCode());
547
    if (lastComparison != 0) {
548
      return lastComparison;
549
    }
550
    lastComparison = TBaseHelper.compareTo(areaCode, typedOther.areaCode);
551
    if (lastComparison != 0) {
552
      return lastComparison;
553
    }
554
    lastComparison = Boolean.valueOf(isSetNumber()).compareTo(isSetNumber());
555
    if (lastComparison != 0) {
556
      return lastComparison;
557
    }
558
    lastComparison = TBaseHelper.compareTo(number, typedOther.number);
559
    if (lastComparison != 0) {
560
      return lastComparison;
561
    }
562
    lastComparison = Boolean.valueOf(isSetExtension()).compareTo(isSetExtension());
563
    if (lastComparison != 0) {
564
      return lastComparison;
565
    }
566
    lastComparison = TBaseHelper.compareTo(extension, typedOther.extension);
567
    if (lastComparison != 0) {
568
      return lastComparison;
569
    }
570
    lastComparison = Boolean.valueOf(isSetType()).compareTo(isSetType());
571
    if (lastComparison != 0) {
572
      return lastComparison;
573
    }
574
    lastComparison = TBaseHelper.compareTo(type, typedOther.type);
575
    if (lastComparison != 0) {
576
      return lastComparison;
577
    }
578
    return 0;
579
  }
580
 
581
  public void read(TProtocol iprot) throws TException {
582
    TField field;
583
    iprot.readStructBegin();
584
    while (true)
585
    {
586
      field = iprot.readFieldBegin();
587
      if (field.type == TType.STOP) { 
588
        break;
589
      }
590
      _Fields fieldId = _Fields.findByThriftId(field.id);
591
      if (fieldId == null) {
592
        TProtocolUtil.skip(iprot, field.type);
593
      } else {
594
        switch (fieldId) {
595
          case ID:
596
            if (field.type == TType.I64) {
597
              this.id = iprot.readI64();
598
              setIdIsSet(true);
599
            } else { 
600
              TProtocolUtil.skip(iprot, field.type);
601
            }
602
            break;
603
          case COUNTRY_CODE:
604
            if (field.type == TType.STRING) {
605
              this.countryCode = iprot.readString();
606
            } else { 
607
              TProtocolUtil.skip(iprot, field.type);
608
            }
609
            break;
610
          case AREA_CODE:
611
            if (field.type == TType.STRING) {
612
              this.areaCode = iprot.readString();
613
            } else { 
614
              TProtocolUtil.skip(iprot, field.type);
615
            }
616
            break;
617
          case NUMBER:
618
            if (field.type == TType.STRING) {
619
              this.number = iprot.readString();
620
            } else { 
621
              TProtocolUtil.skip(iprot, field.type);
622
            }
623
            break;
624
          case EXTENSION:
625
            if (field.type == TType.STRING) {
626
              this.extension = iprot.readString();
627
            } else { 
628
              TProtocolUtil.skip(iprot, field.type);
629
            }
630
            break;
631
          case TYPE:
632
            if (field.type == TType.I32) {
633
              this.type = PhoneType.findByValue(iprot.readI32());
634
            } else { 
635
              TProtocolUtil.skip(iprot, field.type);
636
            }
637
            break;
638
        }
639
        iprot.readFieldEnd();
640
      }
641
    }
642
    iprot.readStructEnd();
643
    validate();
644
  }
645
 
646
  public void write(TProtocol oprot) throws TException {
647
    validate();
648
 
649
    oprot.writeStructBegin(STRUCT_DESC);
650
    oprot.writeFieldBegin(ID_FIELD_DESC);
651
    oprot.writeI64(this.id);
652
    oprot.writeFieldEnd();
653
    if (this.countryCode != null) {
654
      oprot.writeFieldBegin(COUNTRY_CODE_FIELD_DESC);
655
      oprot.writeString(this.countryCode);
656
      oprot.writeFieldEnd();
657
    }
658
    if (this.areaCode != null) {
659
      oprot.writeFieldBegin(AREA_CODE_FIELD_DESC);
660
      oprot.writeString(this.areaCode);
661
      oprot.writeFieldEnd();
662
    }
663
    if (this.number != null) {
664
      oprot.writeFieldBegin(NUMBER_FIELD_DESC);
665
      oprot.writeString(this.number);
666
      oprot.writeFieldEnd();
667
    }
668
    if (this.extension != null) {
669
      oprot.writeFieldBegin(EXTENSION_FIELD_DESC);
670
      oprot.writeString(this.extension);
671
      oprot.writeFieldEnd();
672
    }
673
    if (this.type != null) {
674
      oprot.writeFieldBegin(TYPE_FIELD_DESC);
675
      oprot.writeI32(this.type.getValue());
676
      oprot.writeFieldEnd();
677
    }
678
    oprot.writeFieldStop();
679
    oprot.writeStructEnd();
680
  }
681
 
682
  @Override
683
  public String toString() {
684
    StringBuilder sb = new StringBuilder("Phone(");
685
    boolean first = true;
686
 
687
    sb.append("id:");
688
    sb.append(this.id);
689
    first = false;
690
    if (!first) sb.append(", ");
691
    sb.append("countryCode:");
692
    if (this.countryCode == null) {
693
      sb.append("null");
694
    } else {
695
      sb.append(this.countryCode);
696
    }
697
    first = false;
698
    if (!first) sb.append(", ");
699
    sb.append("areaCode:");
700
    if (this.areaCode == null) {
701
      sb.append("null");
702
    } else {
703
      sb.append(this.areaCode);
704
    }
705
    first = false;
706
    if (!first) sb.append(", ");
707
    sb.append("number:");
708
    if (this.number == null) {
709
      sb.append("null");
710
    } else {
711
      sb.append(this.number);
712
    }
713
    first = false;
714
    if (!first) sb.append(", ");
715
    sb.append("extension:");
716
    if (this.extension == null) {
717
      sb.append("null");
718
    } else {
719
      sb.append(this.extension);
720
    }
721
    first = false;
722
    if (!first) sb.append(", ");
723
    sb.append("type:");
724
    if (this.type == null) {
725
      sb.append("null");
726
    } else {
727
      String type_name = type.name();
728
      if (type_name != null) {
729
        sb.append(type_name);
730
        sb.append(" (");
731
      }
732
      sb.append(this.type);
733
      if (type_name != null) {
734
        sb.append(")");
735
      }
736
    }
737
    first = false;
738
    sb.append(")");
739
    return sb.toString();
740
  }
741
 
742
  public void validate() throws TException {
743
    // check for required fields
744
  }
745
 
746
}
747