Subversion Repositories SmartDukaan

Rev

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

Rev Author Line No. Line
5945 mandeep.dh 1
/**
2
 * Autogenerated by Thrift Compiler (0.7.0)
3
 *
4
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
5
 */
6
package in.shop2020.model.v1.inventory;
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.nio.ByteBuffer;
19
import java.util.Arrays;
20
import org.slf4j.Logger;
21
import org.slf4j.LoggerFactory;
22
 
23
public class ItemInventory implements org.apache.thrift.TBase<ItemInventory, ItemInventory._Fields>, java.io.Serializable, Cloneable {
24
  private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("ItemInventory");
25
 
26
  private static final org.apache.thrift.protocol.TField ID_FIELD_DESC = new org.apache.thrift.protocol.TField("id", org.apache.thrift.protocol.TType.I64, (short)1);
27
  private static final org.apache.thrift.protocol.TField AVAILABILITY_FIELD_DESC = new org.apache.thrift.protocol.TField("availability", org.apache.thrift.protocol.TType.MAP, (short)2);
28
  private static final org.apache.thrift.protocol.TField RESERVED_FIELD_DESC = new org.apache.thrift.protocol.TField("reserved", org.apache.thrift.protocol.TType.MAP, (short)3);
29
 
30
  private long id; // required
31
  private Map<Long,Long> availability; // required
32
  private Map<Long,Long> reserved; // required
33
 
34
  /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
35
  public enum _Fields implements org.apache.thrift.TFieldIdEnum {
36
    ID((short)1, "id"),
37
    AVAILABILITY((short)2, "availability"),
38
    RESERVED((short)3, "reserved");
39
 
40
    private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
41
 
42
    static {
43
      for (_Fields field : EnumSet.allOf(_Fields.class)) {
44
        byName.put(field.getFieldName(), field);
45
      }
46
    }
47
 
48
    /**
49
     * Find the _Fields constant that matches fieldId, or null if its not found.
50
     */
51
    public static _Fields findByThriftId(int fieldId) {
52
      switch(fieldId) {
53
        case 1: // ID
54
          return ID;
55
        case 2: // AVAILABILITY
56
          return AVAILABILITY;
57
        case 3: // RESERVED
58
          return RESERVED;
59
        default:
60
          return null;
61
      }
62
    }
63
 
64
    /**
65
     * Find the _Fields constant that matches fieldId, throwing an exception
66
     * if it is not found.
67
     */
68
    public static _Fields findByThriftIdOrThrow(int fieldId) {
69
      _Fields fields = findByThriftId(fieldId);
70
      if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
71
      return fields;
72
    }
73
 
74
    /**
75
     * Find the _Fields constant that matches name, or null if its not found.
76
     */
77
    public static _Fields findByName(String name) {
78
      return byName.get(name);
79
    }
80
 
81
    private final short _thriftId;
82
    private final String _fieldName;
83
 
84
    _Fields(short thriftId, String fieldName) {
85
      _thriftId = thriftId;
86
      _fieldName = fieldName;
87
    }
88
 
89
    public short getThriftFieldId() {
90
      return _thriftId;
91
    }
92
 
93
    public String getFieldName() {
94
      return _fieldName;
95
    }
96
  }
97
 
98
  // isset id assignments
99
  private static final int __ID_ISSET_ID = 0;
100
  private BitSet __isset_bit_vector = new BitSet(1);
101
 
102
  public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
103
  static {
104
    Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
105
    tmpMap.put(_Fields.ID, new org.apache.thrift.meta_data.FieldMetaData("id", org.apache.thrift.TFieldRequirementType.DEFAULT, 
106
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)));
107
    tmpMap.put(_Fields.AVAILABILITY, new org.apache.thrift.meta_data.FieldMetaData("availability", org.apache.thrift.TFieldRequirementType.DEFAULT, 
108
        new org.apache.thrift.meta_data.MapMetaData(org.apache.thrift.protocol.TType.MAP, 
109
            new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64), 
110
            new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64))));
111
    tmpMap.put(_Fields.RESERVED, new org.apache.thrift.meta_data.FieldMetaData("reserved", org.apache.thrift.TFieldRequirementType.DEFAULT, 
112
        new org.apache.thrift.meta_data.MapMetaData(org.apache.thrift.protocol.TType.MAP, 
113
            new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64), 
114
            new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64))));
115
    metaDataMap = Collections.unmodifiableMap(tmpMap);
116
    org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(ItemInventory.class, metaDataMap);
117
  }
118
 
119
  public ItemInventory() {
120
  }
121
 
122
  public ItemInventory(
123
    long id,
124
    Map<Long,Long> availability,
125
    Map<Long,Long> reserved)
126
  {
127
    this();
128
    this.id = id;
129
    setIdIsSet(true);
130
    this.availability = availability;
131
    this.reserved = reserved;
132
  }
133
 
134
  /**
135
   * Performs a deep copy on <i>other</i>.
136
   */
137
  public ItemInventory(ItemInventory other) {
138
    __isset_bit_vector.clear();
139
    __isset_bit_vector.or(other.__isset_bit_vector);
140
    this.id = other.id;
141
    if (other.isSetAvailability()) {
142
      Map<Long,Long> __this__availability = new HashMap<Long,Long>();
143
      for (Map.Entry<Long, Long> other_element : other.availability.entrySet()) {
144
 
145
        Long other_element_key = other_element.getKey();
146
        Long other_element_value = other_element.getValue();
147
 
148
        Long __this__availability_copy_key = other_element_key;
149
 
150
        Long __this__availability_copy_value = other_element_value;
151
 
152
        __this__availability.put(__this__availability_copy_key, __this__availability_copy_value);
153
      }
154
      this.availability = __this__availability;
155
    }
156
    if (other.isSetReserved()) {
157
      Map<Long,Long> __this__reserved = new HashMap<Long,Long>();
158
      for (Map.Entry<Long, Long> other_element : other.reserved.entrySet()) {
159
 
160
        Long other_element_key = other_element.getKey();
161
        Long other_element_value = other_element.getValue();
162
 
163
        Long __this__reserved_copy_key = other_element_key;
164
 
165
        Long __this__reserved_copy_value = other_element_value;
166
 
167
        __this__reserved.put(__this__reserved_copy_key, __this__reserved_copy_value);
168
      }
169
      this.reserved = __this__reserved;
170
    }
171
  }
172
 
173
  public ItemInventory deepCopy() {
174
    return new ItemInventory(this);
175
  }
176
 
177
  @Override
178
  public void clear() {
179
    setIdIsSet(false);
180
    this.id = 0;
181
    this.availability = null;
182
    this.reserved = null;
183
  }
184
 
185
  public long getId() {
186
    return this.id;
187
  }
188
 
189
  public void setId(long id) {
190
    this.id = id;
191
    setIdIsSet(true);
192
  }
193
 
194
  public void unsetId() {
195
    __isset_bit_vector.clear(__ID_ISSET_ID);
196
  }
197
 
198
  /** Returns true if field id is set (has been assigned a value) and false otherwise */
199
  public boolean isSetId() {
200
    return __isset_bit_vector.get(__ID_ISSET_ID);
201
  }
202
 
203
  public void setIdIsSet(boolean value) {
204
    __isset_bit_vector.set(__ID_ISSET_ID, value);
205
  }
206
 
207
  public int getAvailabilitySize() {
208
    return (this.availability == null) ? 0 : this.availability.size();
209
  }
210
 
211
  public void putToAvailability(long key, long val) {
212
    if (this.availability == null) {
213
      this.availability = new HashMap<Long,Long>();
214
    }
215
    this.availability.put(key, val);
216
  }
217
 
218
  public Map<Long,Long> getAvailability() {
219
    return this.availability;
220
  }
221
 
222
  public void setAvailability(Map<Long,Long> availability) {
223
    this.availability = availability;
224
  }
225
 
226
  public void unsetAvailability() {
227
    this.availability = null;
228
  }
229
 
230
  /** Returns true if field availability is set (has been assigned a value) and false otherwise */
231
  public boolean isSetAvailability() {
232
    return this.availability != null;
233
  }
234
 
235
  public void setAvailabilityIsSet(boolean value) {
236
    if (!value) {
237
      this.availability = null;
238
    }
239
  }
240
 
241
  public int getReservedSize() {
242
    return (this.reserved == null) ? 0 : this.reserved.size();
243
  }
244
 
245
  public void putToReserved(long key, long val) {
246
    if (this.reserved == null) {
247
      this.reserved = new HashMap<Long,Long>();
248
    }
249
    this.reserved.put(key, val);
250
  }
251
 
252
  public Map<Long,Long> getReserved() {
253
    return this.reserved;
254
  }
255
 
256
  public void setReserved(Map<Long,Long> reserved) {
257
    this.reserved = reserved;
258
  }
259
 
260
  public void unsetReserved() {
261
    this.reserved = null;
262
  }
263
 
264
  /** Returns true if field reserved is set (has been assigned a value) and false otherwise */
265
  public boolean isSetReserved() {
266
    return this.reserved != null;
267
  }
268
 
269
  public void setReservedIsSet(boolean value) {
270
    if (!value) {
271
      this.reserved = null;
272
    }
273
  }
274
 
275
  public void setFieldValue(_Fields field, Object value) {
276
    switch (field) {
277
    case ID:
278
      if (value == null) {
279
        unsetId();
280
      } else {
281
        setId((Long)value);
282
      }
283
      break;
284
 
285
    case AVAILABILITY:
286
      if (value == null) {
287
        unsetAvailability();
288
      } else {
289
        setAvailability((Map<Long,Long>)value);
290
      }
291
      break;
292
 
293
    case RESERVED:
294
      if (value == null) {
295
        unsetReserved();
296
      } else {
297
        setReserved((Map<Long,Long>)value);
298
      }
299
      break;
300
 
301
    }
302
  }
303
 
304
  public Object getFieldValue(_Fields field) {
305
    switch (field) {
306
    case ID:
307
      return Long.valueOf(getId());
308
 
309
    case AVAILABILITY:
310
      return getAvailability();
311
 
312
    case RESERVED:
313
      return getReserved();
314
 
315
    }
316
    throw new IllegalStateException();
317
  }
318
 
319
  /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
320
  public boolean isSet(_Fields field) {
321
    if (field == null) {
322
      throw new IllegalArgumentException();
323
    }
324
 
325
    switch (field) {
326
    case ID:
327
      return isSetId();
328
    case AVAILABILITY:
329
      return isSetAvailability();
330
    case RESERVED:
331
      return isSetReserved();
332
    }
333
    throw new IllegalStateException();
334
  }
335
 
336
  @Override
337
  public boolean equals(Object that) {
338
    if (that == null)
339
      return false;
340
    if (that instanceof ItemInventory)
341
      return this.equals((ItemInventory)that);
342
    return false;
343
  }
344
 
345
  public boolean equals(ItemInventory that) {
346
    if (that == null)
347
      return false;
348
 
349
    boolean this_present_id = true;
350
    boolean that_present_id = true;
351
    if (this_present_id || that_present_id) {
352
      if (!(this_present_id && that_present_id))
353
        return false;
354
      if (this.id != that.id)
355
        return false;
356
    }
357
 
358
    boolean this_present_availability = true && this.isSetAvailability();
359
    boolean that_present_availability = true && that.isSetAvailability();
360
    if (this_present_availability || that_present_availability) {
361
      if (!(this_present_availability && that_present_availability))
362
        return false;
363
      if (!this.availability.equals(that.availability))
364
        return false;
365
    }
366
 
367
    boolean this_present_reserved = true && this.isSetReserved();
368
    boolean that_present_reserved = true && that.isSetReserved();
369
    if (this_present_reserved || that_present_reserved) {
370
      if (!(this_present_reserved && that_present_reserved))
371
        return false;
372
      if (!this.reserved.equals(that.reserved))
373
        return false;
374
    }
375
 
376
    return true;
377
  }
378
 
379
  @Override
380
  public int hashCode() {
381
    return 0;
382
  }
383
 
384
  public int compareTo(ItemInventory other) {
385
    if (!getClass().equals(other.getClass())) {
386
      return getClass().getName().compareTo(other.getClass().getName());
387
    }
388
 
389
    int lastComparison = 0;
390
    ItemInventory typedOther = (ItemInventory)other;
391
 
392
    lastComparison = Boolean.valueOf(isSetId()).compareTo(typedOther.isSetId());
393
    if (lastComparison != 0) {
394
      return lastComparison;
395
    }
396
    if (isSetId()) {
397
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.id, typedOther.id);
398
      if (lastComparison != 0) {
399
        return lastComparison;
400
      }
401
    }
402
    lastComparison = Boolean.valueOf(isSetAvailability()).compareTo(typedOther.isSetAvailability());
403
    if (lastComparison != 0) {
404
      return lastComparison;
405
    }
406
    if (isSetAvailability()) {
407
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.availability, typedOther.availability);
408
      if (lastComparison != 0) {
409
        return lastComparison;
410
      }
411
    }
412
    lastComparison = Boolean.valueOf(isSetReserved()).compareTo(typedOther.isSetReserved());
413
    if (lastComparison != 0) {
414
      return lastComparison;
415
    }
416
    if (isSetReserved()) {
417
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.reserved, typedOther.reserved);
418
      if (lastComparison != 0) {
419
        return lastComparison;
420
      }
421
    }
422
    return 0;
423
  }
424
 
425
  public _Fields fieldForId(int fieldId) {
426
    return _Fields.findByThriftId(fieldId);
427
  }
428
 
429
  public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
430
    org.apache.thrift.protocol.TField field;
431
    iprot.readStructBegin();
432
    while (true)
433
    {
434
      field = iprot.readFieldBegin();
435
      if (field.type == org.apache.thrift.protocol.TType.STOP) { 
436
        break;
437
      }
438
      switch (field.id) {
439
        case 1: // ID
440
          if (field.type == org.apache.thrift.protocol.TType.I64) {
441
            this.id = iprot.readI64();
442
            setIdIsSet(true);
443
          } else { 
444
            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
445
          }
446
          break;
447
        case 2: // AVAILABILITY
448
          if (field.type == org.apache.thrift.protocol.TType.MAP) {
449
            {
450
              org.apache.thrift.protocol.TMap _map0 = iprot.readMapBegin();
451
              this.availability = new HashMap<Long,Long>(2*_map0.size);
452
              for (int _i1 = 0; _i1 < _map0.size; ++_i1)
453
              {
454
                long _key2; // required
455
                long _val3; // required
456
                _key2 = iprot.readI64();
457
                _val3 = iprot.readI64();
458
                this.availability.put(_key2, _val3);
459
              }
460
              iprot.readMapEnd();
461
            }
462
          } else { 
463
            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
464
          }
465
          break;
466
        case 3: // RESERVED
467
          if (field.type == org.apache.thrift.protocol.TType.MAP) {
468
            {
469
              org.apache.thrift.protocol.TMap _map4 = iprot.readMapBegin();
470
              this.reserved = new HashMap<Long,Long>(2*_map4.size);
471
              for (int _i5 = 0; _i5 < _map4.size; ++_i5)
472
              {
473
                long _key6; // required
474
                long _val7; // required
475
                _key6 = iprot.readI64();
476
                _val7 = iprot.readI64();
477
                this.reserved.put(_key6, _val7);
478
              }
479
              iprot.readMapEnd();
480
            }
481
          } else { 
482
            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
483
          }
484
          break;
485
        default:
486
          org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
487
      }
488
      iprot.readFieldEnd();
489
    }
490
    iprot.readStructEnd();
491
    validate();
492
  }
493
 
494
  public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
495
    validate();
496
 
497
    oprot.writeStructBegin(STRUCT_DESC);
498
    oprot.writeFieldBegin(ID_FIELD_DESC);
499
    oprot.writeI64(this.id);
500
    oprot.writeFieldEnd();
501
    if (this.availability != null) {
502
      oprot.writeFieldBegin(AVAILABILITY_FIELD_DESC);
503
      {
504
        oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.I64, org.apache.thrift.protocol.TType.I64, this.availability.size()));
505
        for (Map.Entry<Long, Long> _iter8 : this.availability.entrySet())
506
        {
507
          oprot.writeI64(_iter8.getKey());
508
          oprot.writeI64(_iter8.getValue());
509
        }
510
        oprot.writeMapEnd();
511
      }
512
      oprot.writeFieldEnd();
513
    }
514
    if (this.reserved != null) {
515
      oprot.writeFieldBegin(RESERVED_FIELD_DESC);
516
      {
517
        oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.I64, org.apache.thrift.protocol.TType.I64, this.reserved.size()));
518
        for (Map.Entry<Long, Long> _iter9 : this.reserved.entrySet())
519
        {
520
          oprot.writeI64(_iter9.getKey());
521
          oprot.writeI64(_iter9.getValue());
522
        }
523
        oprot.writeMapEnd();
524
      }
525
      oprot.writeFieldEnd();
526
    }
527
    oprot.writeFieldStop();
528
    oprot.writeStructEnd();
529
  }
530
 
531
  @Override
532
  public String toString() {
533
    StringBuilder sb = new StringBuilder("ItemInventory(");
534
    boolean first = true;
535
 
536
    sb.append("id:");
537
    sb.append(this.id);
538
    first = false;
539
    if (!first) sb.append(", ");
540
    sb.append("availability:");
541
    if (this.availability == null) {
542
      sb.append("null");
543
    } else {
544
      sb.append(this.availability);
545
    }
546
    first = false;
547
    if (!first) sb.append(", ");
548
    sb.append("reserved:");
549
    if (this.reserved == null) {
550
      sb.append("null");
551
    } else {
552
      sb.append(this.reserved);
553
    }
554
    first = false;
555
    sb.append(")");
556
    return sb.toString();
557
  }
558
 
559
  public void validate() throws org.apache.thrift.TException {
560
    // check for required fields
561
  }
562
 
563
  private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
564
    try {
565
      write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
566
    } catch (org.apache.thrift.TException te) {
567
      throw new java.io.IOException(te);
568
    }
569
  }
570
 
571
  private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
572
    try {
573
      // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor.
574
      __isset_bit_vector = new BitSet(1);
575
      read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
576
    } catch (org.apache.thrift.TException te) {
577
      throw new java.io.IOException(te);
578
    }
579
  }
580
 
581
}
582