Subversion Repositories SmartDukaan

Rev

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

Rev Author Line No. Line
2820 chandransh 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.warehouse;
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 Scan implements TBase<Scan._Fields>, java.io.Serializable, Cloneable, Comparable<Scan> {
27
  private static final TStruct STRUCT_DESC = new TStruct("Scan");
28
 
29
  private static final TField ID_FIELD_DESC = new TField("id", TType.I64, (short)1);
30
  private static final TField ITEM_ID_FIELD_DESC = new TField("itemId", TType.I64, (short)2);
31
  private static final TField STOCK_LEDGER_ID_FIELD_DESC = new TField("stockLedgerId", TType.I64, (short)3);
32
  private static final TField TYPE_FIELD_DESC = new TField("type", TType.I32, (short)4);
33
  private static final TField SCANNED_AT_FIELD_DESC = new TField("scannedAt", TType.I64, (short)5);
34
 
35
  private long id;
36
  private long itemId;
37
  private long stockLedgerId;
38
  private ScanType type;
39
  private long scannedAt;
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
    ITEM_ID((short)2, "itemId"),
45
    STOCK_LEDGER_ID((short)3, "stockLedgerId"),
46
    /**
47
     * 
48
     * @see ScanType
49
     */
50
    TYPE((short)4, "type"),
51
    SCANNED_AT((short)5, "scannedAt");
52
 
53
    private static final Map<Integer, _Fields> byId = new HashMap<Integer, _Fields>();
54
    private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
55
 
56
    static {
57
      for (_Fields field : EnumSet.allOf(_Fields.class)) {
58
        byId.put((int)field._thriftId, field);
59
        byName.put(field.getFieldName(), field);
60
      }
61
    }
62
 
63
    /**
64
     * Find the _Fields constant that matches fieldId, or null if its not found.
65
     */
66
    public static _Fields findByThriftId(int fieldId) {
67
      return byId.get(fieldId);
68
    }
69
 
70
    /**
71
     * Find the _Fields constant that matches fieldId, throwing an exception
72
     * if it is not found.
73
     */
74
    public static _Fields findByThriftIdOrThrow(int fieldId) {
75
      _Fields fields = findByThriftId(fieldId);
76
      if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
77
      return fields;
78
    }
79
 
80
    /**
81
     * Find the _Fields constant that matches name, or null if its not found.
82
     */
83
    public static _Fields findByName(String name) {
84
      return byName.get(name);
85
    }
86
 
87
    private final short _thriftId;
88
    private final String _fieldName;
89
 
90
    _Fields(short thriftId, String fieldName) {
91
      _thriftId = thriftId;
92
      _fieldName = fieldName;
93
    }
94
 
95
    public short getThriftFieldId() {
96
      return _thriftId;
97
    }
98
 
99
    public String getFieldName() {
100
      return _fieldName;
101
    }
102
  }
103
 
104
  // isset id assignments
105
  private static final int __ID_ISSET_ID = 0;
106
  private static final int __ITEMID_ISSET_ID = 1;
107
  private static final int __STOCKLEDGERID_ISSET_ID = 2;
108
  private static final int __SCANNEDAT_ISSET_ID = 3;
109
  private BitSet __isset_bit_vector = new BitSet(4);
110
 
111
  public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
112
    put(_Fields.ID, new FieldMetaData("id", TFieldRequirementType.DEFAULT, 
113
        new FieldValueMetaData(TType.I64)));
114
    put(_Fields.ITEM_ID, new FieldMetaData("itemId", TFieldRequirementType.DEFAULT, 
115
        new FieldValueMetaData(TType.I64)));
116
    put(_Fields.STOCK_LEDGER_ID, new FieldMetaData("stockLedgerId", TFieldRequirementType.DEFAULT, 
117
        new FieldValueMetaData(TType.I64)));
118
    put(_Fields.TYPE, new FieldMetaData("type", TFieldRequirementType.DEFAULT, 
119
        new EnumMetaData(TType.ENUM, ScanType.class)));
120
    put(_Fields.SCANNED_AT, new FieldMetaData("scannedAt", TFieldRequirementType.DEFAULT, 
121
        new FieldValueMetaData(TType.I64)));
122
  }});
123
 
124
  static {
125
    FieldMetaData.addStructMetaDataMap(Scan.class, metaDataMap);
126
  }
127
 
128
  public Scan() {
129
  }
130
 
131
  public Scan(
132
    long id,
133
    long itemId,
134
    long stockLedgerId,
135
    ScanType type,
136
    long scannedAt)
137
  {
138
    this();
139
    this.id = id;
140
    setIdIsSet(true);
141
    this.itemId = itemId;
142
    setItemIdIsSet(true);
143
    this.stockLedgerId = stockLedgerId;
144
    setStockLedgerIdIsSet(true);
145
    this.type = type;
146
    this.scannedAt = scannedAt;
147
    setScannedAtIsSet(true);
148
  }
149
 
150
  /**
151
   * Performs a deep copy on <i>other</i>.
152
   */
153
  public Scan(Scan other) {
154
    __isset_bit_vector.clear();
155
    __isset_bit_vector.or(other.__isset_bit_vector);
156
    this.id = other.id;
157
    this.itemId = other.itemId;
158
    this.stockLedgerId = other.stockLedgerId;
159
    if (other.isSetType()) {
160
      this.type = other.type;
161
    }
162
    this.scannedAt = other.scannedAt;
163
  }
164
 
165
  public Scan deepCopy() {
166
    return new Scan(this);
167
  }
168
 
169
  @Deprecated
170
  public Scan clone() {
171
    return new Scan(this);
172
  }
173
 
174
  public long getId() {
175
    return this.id;
176
  }
177
 
178
  public Scan setId(long id) {
179
    this.id = id;
180
    setIdIsSet(true);
181
    return this;
182
  }
183
 
184
  public void unsetId() {
185
    __isset_bit_vector.clear(__ID_ISSET_ID);
186
  }
187
 
188
  /** Returns true if field id is set (has been asigned a value) and false otherwise */
189
  public boolean isSetId() {
190
    return __isset_bit_vector.get(__ID_ISSET_ID);
191
  }
192
 
193
  public void setIdIsSet(boolean value) {
194
    __isset_bit_vector.set(__ID_ISSET_ID, value);
195
  }
196
 
197
  public long getItemId() {
198
    return this.itemId;
199
  }
200
 
201
  public Scan setItemId(long itemId) {
202
    this.itemId = itemId;
203
    setItemIdIsSet(true);
204
    return this;
205
  }
206
 
207
  public void unsetItemId() {
208
    __isset_bit_vector.clear(__ITEMID_ISSET_ID);
209
  }
210
 
211
  /** Returns true if field itemId is set (has been asigned a value) and false otherwise */
212
  public boolean isSetItemId() {
213
    return __isset_bit_vector.get(__ITEMID_ISSET_ID);
214
  }
215
 
216
  public void setItemIdIsSet(boolean value) {
217
    __isset_bit_vector.set(__ITEMID_ISSET_ID, value);
218
  }
219
 
220
  public long getStockLedgerId() {
221
    return this.stockLedgerId;
222
  }
223
 
224
  public Scan setStockLedgerId(long stockLedgerId) {
225
    this.stockLedgerId = stockLedgerId;
226
    setStockLedgerIdIsSet(true);
227
    return this;
228
  }
229
 
230
  public void unsetStockLedgerId() {
231
    __isset_bit_vector.clear(__STOCKLEDGERID_ISSET_ID);
232
  }
233
 
234
  /** Returns true if field stockLedgerId is set (has been asigned a value) and false otherwise */
235
  public boolean isSetStockLedgerId() {
236
    return __isset_bit_vector.get(__STOCKLEDGERID_ISSET_ID);
237
  }
238
 
239
  public void setStockLedgerIdIsSet(boolean value) {
240
    __isset_bit_vector.set(__STOCKLEDGERID_ISSET_ID, value);
241
  }
242
 
243
  /**
244
   * 
245
   * @see ScanType
246
   */
247
  public ScanType getType() {
248
    return this.type;
249
  }
250
 
251
  /**
252
   * 
253
   * @see ScanType
254
   */
255
  public Scan setType(ScanType type) {
256
    this.type = type;
257
    return this;
258
  }
259
 
260
  public void unsetType() {
261
    this.type = null;
262
  }
263
 
264
  /** Returns true if field type is set (has been asigned a value) and false otherwise */
265
  public boolean isSetType() {
266
    return this.type != null;
267
  }
268
 
269
  public void setTypeIsSet(boolean value) {
270
    if (!value) {
271
      this.type = null;
272
    }
273
  }
274
 
275
  public long getScannedAt() {
276
    return this.scannedAt;
277
  }
278
 
279
  public Scan setScannedAt(long scannedAt) {
280
    this.scannedAt = scannedAt;
281
    setScannedAtIsSet(true);
282
    return this;
283
  }
284
 
285
  public void unsetScannedAt() {
286
    __isset_bit_vector.clear(__SCANNEDAT_ISSET_ID);
287
  }
288
 
289
  /** Returns true if field scannedAt is set (has been asigned a value) and false otherwise */
290
  public boolean isSetScannedAt() {
291
    return __isset_bit_vector.get(__SCANNEDAT_ISSET_ID);
292
  }
293
 
294
  public void setScannedAtIsSet(boolean value) {
295
    __isset_bit_vector.set(__SCANNEDAT_ISSET_ID, value);
296
  }
297
 
298
  public void setFieldValue(_Fields field, Object value) {
299
    switch (field) {
300
    case ID:
301
      if (value == null) {
302
        unsetId();
303
      } else {
304
        setId((Long)value);
305
      }
306
      break;
307
 
308
    case ITEM_ID:
309
      if (value == null) {
310
        unsetItemId();
311
      } else {
312
        setItemId((Long)value);
313
      }
314
      break;
315
 
316
    case STOCK_LEDGER_ID:
317
      if (value == null) {
318
        unsetStockLedgerId();
319
      } else {
320
        setStockLedgerId((Long)value);
321
      }
322
      break;
323
 
324
    case TYPE:
325
      if (value == null) {
326
        unsetType();
327
      } else {
328
        setType((ScanType)value);
329
      }
330
      break;
331
 
332
    case SCANNED_AT:
333
      if (value == null) {
334
        unsetScannedAt();
335
      } else {
336
        setScannedAt((Long)value);
337
      }
338
      break;
339
 
340
    }
341
  }
342
 
343
  public void setFieldValue(int fieldID, Object value) {
344
    setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value);
345
  }
346
 
347
  public Object getFieldValue(_Fields field) {
348
    switch (field) {
349
    case ID:
350
      return new Long(getId());
351
 
352
    case ITEM_ID:
353
      return new Long(getItemId());
354
 
355
    case STOCK_LEDGER_ID:
356
      return new Long(getStockLedgerId());
357
 
358
    case TYPE:
359
      return getType();
360
 
361
    case SCANNED_AT:
362
      return new Long(getScannedAt());
363
 
364
    }
365
    throw new IllegalStateException();
366
  }
367
 
368
  public Object getFieldValue(int fieldId) {
369
    return getFieldValue(_Fields.findByThriftIdOrThrow(fieldId));
370
  }
371
 
372
  /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
373
  public boolean isSet(_Fields field) {
374
    switch (field) {
375
    case ID:
376
      return isSetId();
377
    case ITEM_ID:
378
      return isSetItemId();
379
    case STOCK_LEDGER_ID:
380
      return isSetStockLedgerId();
381
    case TYPE:
382
      return isSetType();
383
    case SCANNED_AT:
384
      return isSetScannedAt();
385
    }
386
    throw new IllegalStateException();
387
  }
388
 
389
  public boolean isSet(int fieldID) {
390
    return isSet(_Fields.findByThriftIdOrThrow(fieldID));
391
  }
392
 
393
  @Override
394
  public boolean equals(Object that) {
395
    if (that == null)
396
      return false;
397
    if (that instanceof Scan)
398
      return this.equals((Scan)that);
399
    return false;
400
  }
401
 
402
  public boolean equals(Scan that) {
403
    if (that == null)
404
      return false;
405
 
406
    boolean this_present_id = true;
407
    boolean that_present_id = true;
408
    if (this_present_id || that_present_id) {
409
      if (!(this_present_id && that_present_id))
410
        return false;
411
      if (this.id != that.id)
412
        return false;
413
    }
414
 
415
    boolean this_present_itemId = true;
416
    boolean that_present_itemId = true;
417
    if (this_present_itemId || that_present_itemId) {
418
      if (!(this_present_itemId && that_present_itemId))
419
        return false;
420
      if (this.itemId != that.itemId)
421
        return false;
422
    }
423
 
424
    boolean this_present_stockLedgerId = true;
425
    boolean that_present_stockLedgerId = true;
426
    if (this_present_stockLedgerId || that_present_stockLedgerId) {
427
      if (!(this_present_stockLedgerId && that_present_stockLedgerId))
428
        return false;
429
      if (this.stockLedgerId != that.stockLedgerId)
430
        return false;
431
    }
432
 
433
    boolean this_present_type = true && this.isSetType();
434
    boolean that_present_type = true && that.isSetType();
435
    if (this_present_type || that_present_type) {
436
      if (!(this_present_type && that_present_type))
437
        return false;
438
      if (!this.type.equals(that.type))
439
        return false;
440
    }
441
 
442
    boolean this_present_scannedAt = true;
443
    boolean that_present_scannedAt = true;
444
    if (this_present_scannedAt || that_present_scannedAt) {
445
      if (!(this_present_scannedAt && that_present_scannedAt))
446
        return false;
447
      if (this.scannedAt != that.scannedAt)
448
        return false;
449
    }
450
 
451
    return true;
452
  }
453
 
454
  @Override
455
  public int hashCode() {
456
    return 0;
457
  }
458
 
459
  public int compareTo(Scan other) {
460
    if (!getClass().equals(other.getClass())) {
461
      return getClass().getName().compareTo(other.getClass().getName());
462
    }
463
 
464
    int lastComparison = 0;
465
    Scan typedOther = (Scan)other;
466
 
467
    lastComparison = Boolean.valueOf(isSetId()).compareTo(isSetId());
468
    if (lastComparison != 0) {
469
      return lastComparison;
470
    }
471
    lastComparison = TBaseHelper.compareTo(id, typedOther.id);
472
    if (lastComparison != 0) {
473
      return lastComparison;
474
    }
475
    lastComparison = Boolean.valueOf(isSetItemId()).compareTo(isSetItemId());
476
    if (lastComparison != 0) {
477
      return lastComparison;
478
    }
479
    lastComparison = TBaseHelper.compareTo(itemId, typedOther.itemId);
480
    if (lastComparison != 0) {
481
      return lastComparison;
482
    }
483
    lastComparison = Boolean.valueOf(isSetStockLedgerId()).compareTo(isSetStockLedgerId());
484
    if (lastComparison != 0) {
485
      return lastComparison;
486
    }
487
    lastComparison = TBaseHelper.compareTo(stockLedgerId, typedOther.stockLedgerId);
488
    if (lastComparison != 0) {
489
      return lastComparison;
490
    }
491
    lastComparison = Boolean.valueOf(isSetType()).compareTo(isSetType());
492
    if (lastComparison != 0) {
493
      return lastComparison;
494
    }
495
    lastComparison = TBaseHelper.compareTo(type, typedOther.type);
496
    if (lastComparison != 0) {
497
      return lastComparison;
498
    }
499
    lastComparison = Boolean.valueOf(isSetScannedAt()).compareTo(isSetScannedAt());
500
    if (lastComparison != 0) {
501
      return lastComparison;
502
    }
503
    lastComparison = TBaseHelper.compareTo(scannedAt, typedOther.scannedAt);
504
    if (lastComparison != 0) {
505
      return lastComparison;
506
    }
507
    return 0;
508
  }
509
 
510
  public void read(TProtocol iprot) throws TException {
511
    TField field;
512
    iprot.readStructBegin();
513
    while (true)
514
    {
515
      field = iprot.readFieldBegin();
516
      if (field.type == TType.STOP) { 
517
        break;
518
      }
519
      _Fields fieldId = _Fields.findByThriftId(field.id);
520
      if (fieldId == null) {
521
        TProtocolUtil.skip(iprot, field.type);
522
      } else {
523
        switch (fieldId) {
524
          case ID:
525
            if (field.type == TType.I64) {
526
              this.id = iprot.readI64();
527
              setIdIsSet(true);
528
            } else { 
529
              TProtocolUtil.skip(iprot, field.type);
530
            }
531
            break;
532
          case ITEM_ID:
533
            if (field.type == TType.I64) {
534
              this.itemId = iprot.readI64();
535
              setItemIdIsSet(true);
536
            } else { 
537
              TProtocolUtil.skip(iprot, field.type);
538
            }
539
            break;
540
          case STOCK_LEDGER_ID:
541
            if (field.type == TType.I64) {
542
              this.stockLedgerId = iprot.readI64();
543
              setStockLedgerIdIsSet(true);
544
            } else { 
545
              TProtocolUtil.skip(iprot, field.type);
546
            }
547
            break;
548
          case TYPE:
549
            if (field.type == TType.I32) {
550
              this.type = ScanType.findByValue(iprot.readI32());
551
            } else { 
552
              TProtocolUtil.skip(iprot, field.type);
553
            }
554
            break;
555
          case SCANNED_AT:
556
            if (field.type == TType.I64) {
557
              this.scannedAt = iprot.readI64();
558
              setScannedAtIsSet(true);
559
            } else { 
560
              TProtocolUtil.skip(iprot, field.type);
561
            }
562
            break;
563
        }
564
        iprot.readFieldEnd();
565
      }
566
    }
567
    iprot.readStructEnd();
568
    validate();
569
  }
570
 
571
  public void write(TProtocol oprot) throws TException {
572
    validate();
573
 
574
    oprot.writeStructBegin(STRUCT_DESC);
575
    oprot.writeFieldBegin(ID_FIELD_DESC);
576
    oprot.writeI64(this.id);
577
    oprot.writeFieldEnd();
578
    oprot.writeFieldBegin(ITEM_ID_FIELD_DESC);
579
    oprot.writeI64(this.itemId);
580
    oprot.writeFieldEnd();
581
    oprot.writeFieldBegin(STOCK_LEDGER_ID_FIELD_DESC);
582
    oprot.writeI64(this.stockLedgerId);
583
    oprot.writeFieldEnd();
584
    if (this.type != null) {
585
      oprot.writeFieldBegin(TYPE_FIELD_DESC);
586
      oprot.writeI32(this.type.getValue());
587
      oprot.writeFieldEnd();
588
    }
589
    oprot.writeFieldBegin(SCANNED_AT_FIELD_DESC);
590
    oprot.writeI64(this.scannedAt);
591
    oprot.writeFieldEnd();
592
    oprot.writeFieldStop();
593
    oprot.writeStructEnd();
594
  }
595
 
596
  @Override
597
  public String toString() {
598
    StringBuilder sb = new StringBuilder("Scan(");
599
    boolean first = true;
600
 
601
    sb.append("id:");
602
    sb.append(this.id);
603
    first = false;
604
    if (!first) sb.append(", ");
605
    sb.append("itemId:");
606
    sb.append(this.itemId);
607
    first = false;
608
    if (!first) sb.append(", ");
609
    sb.append("stockLedgerId:");
610
    sb.append(this.stockLedgerId);
611
    first = false;
612
    if (!first) sb.append(", ");
613
    sb.append("type:");
614
    if (this.type == null) {
615
      sb.append("null");
616
    } else {
617
      String type_name = type.name();
618
      if (type_name != null) {
619
        sb.append(type_name);
620
        sb.append(" (");
621
      }
622
      sb.append(this.type);
623
      if (type_name != null) {
624
        sb.append(")");
625
      }
626
    }
627
    first = false;
628
    if (!first) sb.append(", ");
629
    sb.append("scannedAt:");
630
    sb.append(this.scannedAt);
631
    first = false;
632
    sb.append(")");
633
    return sb.toString();
634
  }
635
 
636
  public void validate() throws TException {
637
    // check for required fields
638
  }
639
 
640
}
641