Subversion Repositories SmartDukaan

Rev

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

Rev Author Line No. Line
5504 phani.kuma 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.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.nio.ByteBuffer;
19
import java.util.Arrays;
20
import org.slf4j.Logger;
21
import org.slf4j.LoggerFactory;
22
 
23
public class VoucherItemMapping implements org.apache.thrift.TBase<VoucherItemMapping, VoucherItemMapping._Fields>, java.io.Serializable, Cloneable {
24
  private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("VoucherItemMapping");
25
 
26
  private static final org.apache.thrift.protocol.TField VOUCHER_TYPE_FIELD_DESC = new org.apache.thrift.protocol.TField("voucherType", org.apache.thrift.protocol.TType.STRING, (short)1);
27
  private static final org.apache.thrift.protocol.TField ITEM_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("itemId", org.apache.thrift.protocol.TType.I64, (short)2);
28
  private static final org.apache.thrift.protocol.TField AMOUNT_FIELD_DESC = new org.apache.thrift.protocol.TField("amount", org.apache.thrift.protocol.TType.I64, (short)3);
29
 
30
  private String voucherType; // required
31
  private long itemId; // required
32
  private long amount; // 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
    VOUCHER_TYPE((short)1, "voucherType"),
37
    ITEM_ID((short)2, "itemId"),
38
    AMOUNT((short)3, "amount");
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: // VOUCHER_TYPE
54
          return VOUCHER_TYPE;
55
        case 2: // ITEM_ID
56
          return ITEM_ID;
57
        case 3: // AMOUNT
58
          return AMOUNT;
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 __ITEMID_ISSET_ID = 0;
100
  private static final int __AMOUNT_ISSET_ID = 1;
101
  private BitSet __isset_bit_vector = new BitSet(2);
102
 
103
  public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
104
  static {
105
    Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
106
    tmpMap.put(_Fields.VOUCHER_TYPE, new org.apache.thrift.meta_data.FieldMetaData("voucherType", org.apache.thrift.TFieldRequirementType.DEFAULT, 
107
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
108
    tmpMap.put(_Fields.ITEM_ID, new org.apache.thrift.meta_data.FieldMetaData("itemId", org.apache.thrift.TFieldRequirementType.DEFAULT, 
109
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)));
110
    tmpMap.put(_Fields.AMOUNT, new org.apache.thrift.meta_data.FieldMetaData("amount", org.apache.thrift.TFieldRequirementType.DEFAULT, 
111
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)));
112
    metaDataMap = Collections.unmodifiableMap(tmpMap);
113
    org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(VoucherItemMapping.class, metaDataMap);
114
  }
115
 
116
  public VoucherItemMapping() {
117
  }
118
 
119
  public VoucherItemMapping(
120
    String voucherType,
121
    long itemId,
122
    long amount)
123
  {
124
    this();
125
    this.voucherType = voucherType;
126
    this.itemId = itemId;
127
    setItemIdIsSet(true);
128
    this.amount = amount;
129
    setAmountIsSet(true);
130
  }
131
 
132
  /**
133
   * Performs a deep copy on <i>other</i>.
134
   */
135
  public VoucherItemMapping(VoucherItemMapping other) {
136
    __isset_bit_vector.clear();
137
    __isset_bit_vector.or(other.__isset_bit_vector);
138
    if (other.isSetVoucherType()) {
139
      this.voucherType = other.voucherType;
140
    }
141
    this.itemId = other.itemId;
142
    this.amount = other.amount;
143
  }
144
 
145
  public VoucherItemMapping deepCopy() {
146
    return new VoucherItemMapping(this);
147
  }
148
 
149
  @Override
150
  public void clear() {
151
    this.voucherType = null;
152
    setItemIdIsSet(false);
153
    this.itemId = 0;
154
    setAmountIsSet(false);
155
    this.amount = 0;
156
  }
157
 
158
  public String getVoucherType() {
159
    return this.voucherType;
160
  }
161
 
162
  public void setVoucherType(String voucherType) {
163
    this.voucherType = voucherType;
164
  }
165
 
166
  public void unsetVoucherType() {
167
    this.voucherType = null;
168
  }
169
 
170
  /** Returns true if field voucherType is set (has been assigned a value) and false otherwise */
171
  public boolean isSetVoucherType() {
172
    return this.voucherType != null;
173
  }
174
 
175
  public void setVoucherTypeIsSet(boolean value) {
176
    if (!value) {
177
      this.voucherType = null;
178
    }
179
  }
180
 
181
  public long getItemId() {
182
    return this.itemId;
183
  }
184
 
185
  public void setItemId(long itemId) {
186
    this.itemId = itemId;
187
    setItemIdIsSet(true);
188
  }
189
 
190
  public void unsetItemId() {
191
    __isset_bit_vector.clear(__ITEMID_ISSET_ID);
192
  }
193
 
194
  /** Returns true if field itemId is set (has been assigned a value) and false otherwise */
195
  public boolean isSetItemId() {
196
    return __isset_bit_vector.get(__ITEMID_ISSET_ID);
197
  }
198
 
199
  public void setItemIdIsSet(boolean value) {
200
    __isset_bit_vector.set(__ITEMID_ISSET_ID, value);
201
  }
202
 
203
  public long getAmount() {
204
    return this.amount;
205
  }
206
 
207
  public void setAmount(long amount) {
208
    this.amount = amount;
209
    setAmountIsSet(true);
210
  }
211
 
212
  public void unsetAmount() {
213
    __isset_bit_vector.clear(__AMOUNT_ISSET_ID);
214
  }
215
 
216
  /** Returns true if field amount is set (has been assigned a value) and false otherwise */
217
  public boolean isSetAmount() {
218
    return __isset_bit_vector.get(__AMOUNT_ISSET_ID);
219
  }
220
 
221
  public void setAmountIsSet(boolean value) {
222
    __isset_bit_vector.set(__AMOUNT_ISSET_ID, value);
223
  }
224
 
225
  public void setFieldValue(_Fields field, Object value) {
226
    switch (field) {
227
    case VOUCHER_TYPE:
228
      if (value == null) {
229
        unsetVoucherType();
230
      } else {
231
        setVoucherType((String)value);
232
      }
233
      break;
234
 
235
    case ITEM_ID:
236
      if (value == null) {
237
        unsetItemId();
238
      } else {
239
        setItemId((Long)value);
240
      }
241
      break;
242
 
243
    case AMOUNT:
244
      if (value == null) {
245
        unsetAmount();
246
      } else {
247
        setAmount((Long)value);
248
      }
249
      break;
250
 
251
    }
252
  }
253
 
254
  public Object getFieldValue(_Fields field) {
255
    switch (field) {
256
    case VOUCHER_TYPE:
257
      return getVoucherType();
258
 
259
    case ITEM_ID:
260
      return Long.valueOf(getItemId());
261
 
262
    case AMOUNT:
263
      return Long.valueOf(getAmount());
264
 
265
    }
266
    throw new IllegalStateException();
267
  }
268
 
269
  /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
270
  public boolean isSet(_Fields field) {
271
    if (field == null) {
272
      throw new IllegalArgumentException();
273
    }
274
 
275
    switch (field) {
276
    case VOUCHER_TYPE:
277
      return isSetVoucherType();
278
    case ITEM_ID:
279
      return isSetItemId();
280
    case AMOUNT:
281
      return isSetAmount();
282
    }
283
    throw new IllegalStateException();
284
  }
285
 
286
  @Override
287
  public boolean equals(Object that) {
288
    if (that == null)
289
      return false;
290
    if (that instanceof VoucherItemMapping)
291
      return this.equals((VoucherItemMapping)that);
292
    return false;
293
  }
294
 
295
  public boolean equals(VoucherItemMapping that) {
296
    if (that == null)
297
      return false;
298
 
299
    boolean this_present_voucherType = true && this.isSetVoucherType();
300
    boolean that_present_voucherType = true && that.isSetVoucherType();
301
    if (this_present_voucherType || that_present_voucherType) {
302
      if (!(this_present_voucherType && that_present_voucherType))
303
        return false;
304
      if (!this.voucherType.equals(that.voucherType))
305
        return false;
306
    }
307
 
308
    boolean this_present_itemId = true;
309
    boolean that_present_itemId = true;
310
    if (this_present_itemId || that_present_itemId) {
311
      if (!(this_present_itemId && that_present_itemId))
312
        return false;
313
      if (this.itemId != that.itemId)
314
        return false;
315
    }
316
 
317
    boolean this_present_amount = true;
318
    boolean that_present_amount = true;
319
    if (this_present_amount || that_present_amount) {
320
      if (!(this_present_amount && that_present_amount))
321
        return false;
322
      if (this.amount != that.amount)
323
        return false;
324
    }
325
 
326
    return true;
327
  }
328
 
329
  @Override
330
  public int hashCode() {
331
    return 0;
332
  }
333
 
334
  public int compareTo(VoucherItemMapping other) {
335
    if (!getClass().equals(other.getClass())) {
336
      return getClass().getName().compareTo(other.getClass().getName());
337
    }
338
 
339
    int lastComparison = 0;
340
    VoucherItemMapping typedOther = (VoucherItemMapping)other;
341
 
342
    lastComparison = Boolean.valueOf(isSetVoucherType()).compareTo(typedOther.isSetVoucherType());
343
    if (lastComparison != 0) {
344
      return lastComparison;
345
    }
346
    if (isSetVoucherType()) {
347
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.voucherType, typedOther.voucherType);
348
      if (lastComparison != 0) {
349
        return lastComparison;
350
      }
351
    }
352
    lastComparison = Boolean.valueOf(isSetItemId()).compareTo(typedOther.isSetItemId());
353
    if (lastComparison != 0) {
354
      return lastComparison;
355
    }
356
    if (isSetItemId()) {
357
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.itemId, typedOther.itemId);
358
      if (lastComparison != 0) {
359
        return lastComparison;
360
      }
361
    }
362
    lastComparison = Boolean.valueOf(isSetAmount()).compareTo(typedOther.isSetAmount());
363
    if (lastComparison != 0) {
364
      return lastComparison;
365
    }
366
    if (isSetAmount()) {
367
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.amount, typedOther.amount);
368
      if (lastComparison != 0) {
369
        return lastComparison;
370
      }
371
    }
372
    return 0;
373
  }
374
 
375
  public _Fields fieldForId(int fieldId) {
376
    return _Fields.findByThriftId(fieldId);
377
  }
378
 
379
  public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
380
    org.apache.thrift.protocol.TField field;
381
    iprot.readStructBegin();
382
    while (true)
383
    {
384
      field = iprot.readFieldBegin();
385
      if (field.type == org.apache.thrift.protocol.TType.STOP) { 
386
        break;
387
      }
388
      switch (field.id) {
389
        case 1: // VOUCHER_TYPE
390
          if (field.type == org.apache.thrift.protocol.TType.STRING) {
391
            this.voucherType = iprot.readString();
392
          } else { 
393
            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
394
          }
395
          break;
396
        case 2: // ITEM_ID
397
          if (field.type == org.apache.thrift.protocol.TType.I64) {
398
            this.itemId = iprot.readI64();
399
            setItemIdIsSet(true);
400
          } else { 
401
            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
402
          }
403
          break;
404
        case 3: // AMOUNT
405
          if (field.type == org.apache.thrift.protocol.TType.I64) {
406
            this.amount = iprot.readI64();
407
            setAmountIsSet(true);
408
          } else { 
409
            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
410
          }
411
          break;
412
        default:
413
          org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
414
      }
415
      iprot.readFieldEnd();
416
    }
417
    iprot.readStructEnd();
418
    validate();
419
  }
420
 
421
  public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
422
    validate();
423
 
424
    oprot.writeStructBegin(STRUCT_DESC);
425
    if (this.voucherType != null) {
426
      oprot.writeFieldBegin(VOUCHER_TYPE_FIELD_DESC);
427
      oprot.writeString(this.voucherType);
428
      oprot.writeFieldEnd();
429
    }
430
    oprot.writeFieldBegin(ITEM_ID_FIELD_DESC);
431
    oprot.writeI64(this.itemId);
432
    oprot.writeFieldEnd();
433
    oprot.writeFieldBegin(AMOUNT_FIELD_DESC);
434
    oprot.writeI64(this.amount);
435
    oprot.writeFieldEnd();
436
    oprot.writeFieldStop();
437
    oprot.writeStructEnd();
438
  }
439
 
440
  @Override
441
  public String toString() {
442
    StringBuilder sb = new StringBuilder("VoucherItemMapping(");
443
    boolean first = true;
444
 
445
    sb.append("voucherType:");
446
    if (this.voucherType == null) {
447
      sb.append("null");
448
    } else {
449
      sb.append(this.voucherType);
450
    }
451
    first = false;
452
    if (!first) sb.append(", ");
453
    sb.append("itemId:");
454
    sb.append(this.itemId);
455
    first = false;
456
    if (!first) sb.append(", ");
457
    sb.append("amount:");
458
    sb.append(this.amount);
459
    first = false;
460
    sb.append(")");
461
    return sb.toString();
462
  }
463
 
464
  public void validate() throws org.apache.thrift.TException {
465
    // check for required fields
466
  }
467
 
468
  private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
469
    try {
470
      write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
471
    } catch (org.apache.thrift.TException te) {
472
      throw new java.io.IOException(te);
473
    }
474
  }
475
 
476
  private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
477
    try {
478
      // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor.
479
      __isset_bit_vector = new BitSet(1);
480
      read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
481
    } catch (org.apache.thrift.TException te) {
482
      throw new java.io.IOException(te);
483
    }
484
  }
485
 
486
}
487