Subversion Repositories SmartDukaan

Rev

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