Subversion Repositories SmartDukaan

Rev

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

Rev Author Line No. Line
100 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.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.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 Item implements TBase<Item._Fields>, java.io.Serializable, Cloneable {
27
  private static final TStruct STRUCT_DESC = new TStruct("Item");
28
 
29
  private static final TField ID_FIELD_DESC = new TField("id", TType.I64, (short)1);
30
  private static final TField CATEGORY_ID_FIELD_DESC = new TField("category_id", TType.I64, (short)2);
31
  private static final TField ITEM_ATTRIBS_FIELD_DESC = new TField("itemAttribs", TType.STRUCT, (short)3);
32
  private static final TField ITEM_INVENTORY_FIELD_DESC = new TField("itemInventory", TType.STRUCT, (short)4);
33
 
34
  private long id;
35
  private long category_id;
36
  private ItemAttribs itemAttribs;
37
  private ItemInventory itemInventory;
38
 
39
  /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
40
  public enum _Fields implements TFieldIdEnum {
41
    ID((short)1, "id"),
42
    CATEGORY_ID((short)2, "category_id"),
43
    ITEM_ATTRIBS((short)3, "itemAttribs"),
44
    ITEM_INVENTORY((short)4, "itemInventory");
45
 
46
    private static final Map<Integer, _Fields> byId = new HashMap<Integer, _Fields>();
47
    private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
48
 
49
    static {
50
      for (_Fields field : EnumSet.allOf(_Fields.class)) {
51
        byId.put((int)field._thriftId, field);
52
        byName.put(field.getFieldName(), field);
53
      }
54
    }
55
 
56
    /**
57
     * Find the _Fields constant that matches fieldId, or null if its not found.
58
     */
59
    public static _Fields findByThriftId(int fieldId) {
60
      return byId.get(fieldId);
61
    }
62
 
63
    /**
64
     * Find the _Fields constant that matches fieldId, throwing an exception
65
     * if it is not found.
66
     */
67
    public static _Fields findByThriftIdOrThrow(int fieldId) {
68
      _Fields fields = findByThriftId(fieldId);
69
      if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
70
      return fields;
71
    }
72
 
73
    /**
74
     * Find the _Fields constant that matches name, or null if its not found.
75
     */
76
    public static _Fields findByName(String name) {
77
      return byName.get(name);
78
    }
79
 
80
    private final short _thriftId;
81
    private final String _fieldName;
82
 
83
    _Fields(short thriftId, String fieldName) {
84
      _thriftId = thriftId;
85
      _fieldName = fieldName;
86
    }
87
 
88
    public short getThriftFieldId() {
89
      return _thriftId;
90
    }
91
 
92
    public String getFieldName() {
93
      return _fieldName;
94
    }
95
  }
96
 
97
  // isset id assignments
98
  private static final int __ID_ISSET_ID = 0;
99
  private static final int __CATEGORY_ID_ISSET_ID = 1;
100
  private BitSet __isset_bit_vector = new BitSet(2);
101
 
102
  public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
103
    put(_Fields.ID, new FieldMetaData("id", TFieldRequirementType.DEFAULT, 
104
        new FieldValueMetaData(TType.I64)));
105
    put(_Fields.CATEGORY_ID, new FieldMetaData("category_id", TFieldRequirementType.DEFAULT, 
106
        new FieldValueMetaData(TType.I64)));
107
    put(_Fields.ITEM_ATTRIBS, new FieldMetaData("itemAttribs", TFieldRequirementType.DEFAULT, 
108
        new StructMetaData(TType.STRUCT, ItemAttribs.class)));
109
    put(_Fields.ITEM_INVENTORY, new FieldMetaData("itemInventory", TFieldRequirementType.DEFAULT, 
110
        new StructMetaData(TType.STRUCT, ItemInventory.class)));
111
  }});
112
 
113
  static {
114
    FieldMetaData.addStructMetaDataMap(Item.class, metaDataMap);
115
  }
116
 
117
  public Item() {
118
  }
119
 
120
  public Item(
121
    long id,
122
    long category_id,
123
    ItemAttribs itemAttribs,
124
    ItemInventory itemInventory)
125
  {
126
    this();
127
    this.id = id;
128
    setIdIsSet(true);
129
    this.category_id = category_id;
130
    setCategory_idIsSet(true);
131
    this.itemAttribs = itemAttribs;
132
    this.itemInventory = itemInventory;
133
  }
134
 
135
  /**
136
   * Performs a deep copy on <i>other</i>.
137
   */
138
  public Item(Item other) {
139
    __isset_bit_vector.clear();
140
    __isset_bit_vector.or(other.__isset_bit_vector);
141
    this.id = other.id;
142
    this.category_id = other.category_id;
143
    if (other.isSetItemAttribs()) {
144
      this.itemAttribs = new ItemAttribs(other.itemAttribs);
145
    }
146
    if (other.isSetItemInventory()) {
147
      this.itemInventory = new ItemInventory(other.itemInventory);
148
    }
149
  }
150
 
151
  public Item deepCopy() {
152
    return new Item(this);
153
  }
154
 
155
  @Deprecated
156
  public Item clone() {
157
    return new Item(this);
158
  }
159
 
160
  public long getId() {
161
    return this.id;
162
  }
163
 
164
  public Item setId(long id) {
165
    this.id = id;
166
    setIdIsSet(true);
167
    return this;
168
  }
169
 
170
  public void unsetId() {
171
    __isset_bit_vector.clear(__ID_ISSET_ID);
172
  }
173
 
174
  /** Returns true if field id is set (has been asigned a value) and false otherwise */
175
  public boolean isSetId() {
176
    return __isset_bit_vector.get(__ID_ISSET_ID);
177
  }
178
 
179
  public void setIdIsSet(boolean value) {
180
    __isset_bit_vector.set(__ID_ISSET_ID, value);
181
  }
182
 
183
  public long getCategory_id() {
184
    return this.category_id;
185
  }
186
 
187
  public Item setCategory_id(long category_id) {
188
    this.category_id = category_id;
189
    setCategory_idIsSet(true);
190
    return this;
191
  }
192
 
193
  public void unsetCategory_id() {
194
    __isset_bit_vector.clear(__CATEGORY_ID_ISSET_ID);
195
  }
196
 
197
  /** Returns true if field category_id is set (has been asigned a value) and false otherwise */
198
  public boolean isSetCategory_id() {
199
    return __isset_bit_vector.get(__CATEGORY_ID_ISSET_ID);
200
  }
201
 
202
  public void setCategory_idIsSet(boolean value) {
203
    __isset_bit_vector.set(__CATEGORY_ID_ISSET_ID, value);
204
  }
205
 
206
  public ItemAttribs getItemAttribs() {
207
    return this.itemAttribs;
208
  }
209
 
210
  public Item setItemAttribs(ItemAttribs itemAttribs) {
211
    this.itemAttribs = itemAttribs;
212
    return this;
213
  }
214
 
215
  public void unsetItemAttribs() {
216
    this.itemAttribs = null;
217
  }
218
 
219
  /** Returns true if field itemAttribs is set (has been asigned a value) and false otherwise */
220
  public boolean isSetItemAttribs() {
221
    return this.itemAttribs != null;
222
  }
223
 
224
  public void setItemAttribsIsSet(boolean value) {
225
    if (!value) {
226
      this.itemAttribs = null;
227
    }
228
  }
229
 
230
  public ItemInventory getItemInventory() {
231
    return this.itemInventory;
232
  }
233
 
234
  public Item setItemInventory(ItemInventory itemInventory) {
235
    this.itemInventory = itemInventory;
236
    return this;
237
  }
238
 
239
  public void unsetItemInventory() {
240
    this.itemInventory = null;
241
  }
242
 
243
  /** Returns true if field itemInventory is set (has been asigned a value) and false otherwise */
244
  public boolean isSetItemInventory() {
245
    return this.itemInventory != null;
246
  }
247
 
248
  public void setItemInventoryIsSet(boolean value) {
249
    if (!value) {
250
      this.itemInventory = null;
251
    }
252
  }
253
 
254
  public void setFieldValue(_Fields field, Object value) {
255
    switch (field) {
256
    case ID:
257
      if (value == null) {
258
        unsetId();
259
      } else {
260
        setId((Long)value);
261
      }
262
      break;
263
 
264
    case CATEGORY_ID:
265
      if (value == null) {
266
        unsetCategory_id();
267
      } else {
268
        setCategory_id((Long)value);
269
      }
270
      break;
271
 
272
    case ITEM_ATTRIBS:
273
      if (value == null) {
274
        unsetItemAttribs();
275
      } else {
276
        setItemAttribs((ItemAttribs)value);
277
      }
278
      break;
279
 
280
    case ITEM_INVENTORY:
281
      if (value == null) {
282
        unsetItemInventory();
283
      } else {
284
        setItemInventory((ItemInventory)value);
285
      }
286
      break;
287
 
288
    }
289
  }
290
 
291
  public void setFieldValue(int fieldID, Object value) {
292
    setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value);
293
  }
294
 
295
  public Object getFieldValue(_Fields field) {
296
    switch (field) {
297
    case ID:
298
      return new Long(getId());
299
 
300
    case CATEGORY_ID:
301
      return new Long(getCategory_id());
302
 
303
    case ITEM_ATTRIBS:
304
      return getItemAttribs();
305
 
306
    case ITEM_INVENTORY:
307
      return getItemInventory();
308
 
309
    }
310
    throw new IllegalStateException();
311
  }
312
 
313
  public Object getFieldValue(int fieldId) {
314
    return getFieldValue(_Fields.findByThriftIdOrThrow(fieldId));
315
  }
316
 
317
  /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
318
  public boolean isSet(_Fields field) {
319
    switch (field) {
320
    case ID:
321
      return isSetId();
322
    case CATEGORY_ID:
323
      return isSetCategory_id();
324
    case ITEM_ATTRIBS:
325
      return isSetItemAttribs();
326
    case ITEM_INVENTORY:
327
      return isSetItemInventory();
328
    }
329
    throw new IllegalStateException();
330
  }
331
 
332
  public boolean isSet(int fieldID) {
333
    return isSet(_Fields.findByThriftIdOrThrow(fieldID));
334
  }
335
 
336
  @Override
337
  public boolean equals(Object that) {
338
    if (that == null)
339
      return false;
340
    if (that instanceof Item)
341
      return this.equals((Item)that);
342
    return false;
343
  }
344
 
345
  public boolean equals(Item 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_category_id = true;
359
    boolean that_present_category_id = true;
360
    if (this_present_category_id || that_present_category_id) {
361
      if (!(this_present_category_id && that_present_category_id))
362
        return false;
363
      if (this.category_id != that.category_id)
364
        return false;
365
    }
366
 
367
    boolean this_present_itemAttribs = true && this.isSetItemAttribs();
368
    boolean that_present_itemAttribs = true && that.isSetItemAttribs();
369
    if (this_present_itemAttribs || that_present_itemAttribs) {
370
      if (!(this_present_itemAttribs && that_present_itemAttribs))
371
        return false;
372
      if (!this.itemAttribs.equals(that.itemAttribs))
373
        return false;
374
    }
375
 
376
    boolean this_present_itemInventory = true && this.isSetItemInventory();
377
    boolean that_present_itemInventory = true && that.isSetItemInventory();
378
    if (this_present_itemInventory || that_present_itemInventory) {
379
      if (!(this_present_itemInventory && that_present_itemInventory))
380
        return false;
381
      if (!this.itemInventory.equals(that.itemInventory))
382
        return false;
383
    }
384
 
385
    return true;
386
  }
387
 
388
  @Override
389
  public int hashCode() {
390
    return 0;
391
  }
392
 
393
  public void read(TProtocol iprot) throws TException {
394
    TField field;
395
    iprot.readStructBegin();
396
    while (true)
397
    {
398
      field = iprot.readFieldBegin();
399
      if (field.type == TType.STOP) { 
400
        break;
401
      }
402
      _Fields fieldId = _Fields.findByThriftId(field.id);
403
      if (fieldId == null) {
404
        TProtocolUtil.skip(iprot, field.type);
405
      } else {
406
        switch (fieldId) {
407
          case ID:
408
            if (field.type == TType.I64) {
409
              this.id = iprot.readI64();
410
              setIdIsSet(true);
411
            } else { 
412
              TProtocolUtil.skip(iprot, field.type);
413
            }
414
            break;
415
          case CATEGORY_ID:
416
            if (field.type == TType.I64) {
417
              this.category_id = iprot.readI64();
418
              setCategory_idIsSet(true);
419
            } else { 
420
              TProtocolUtil.skip(iprot, field.type);
421
            }
422
            break;
423
          case ITEM_ATTRIBS:
424
            if (field.type == TType.STRUCT) {
425
              this.itemAttribs = new ItemAttribs();
426
              this.itemAttribs.read(iprot);
427
            } else { 
428
              TProtocolUtil.skip(iprot, field.type);
429
            }
430
            break;
431
          case ITEM_INVENTORY:
432
            if (field.type == TType.STRUCT) {
433
              this.itemInventory = new ItemInventory();
434
              this.itemInventory.read(iprot);
435
            } else { 
436
              TProtocolUtil.skip(iprot, field.type);
437
            }
438
            break;
439
        }
440
        iprot.readFieldEnd();
441
      }
442
    }
443
    iprot.readStructEnd();
444
    validate();
445
  }
446
 
447
  public void write(TProtocol oprot) throws TException {
448
    validate();
449
 
450
    oprot.writeStructBegin(STRUCT_DESC);
451
    oprot.writeFieldBegin(ID_FIELD_DESC);
452
    oprot.writeI64(this.id);
453
    oprot.writeFieldEnd();
454
    oprot.writeFieldBegin(CATEGORY_ID_FIELD_DESC);
455
    oprot.writeI64(this.category_id);
456
    oprot.writeFieldEnd();
457
    if (this.itemAttribs != null) {
458
      oprot.writeFieldBegin(ITEM_ATTRIBS_FIELD_DESC);
459
      this.itemAttribs.write(oprot);
460
      oprot.writeFieldEnd();
461
    }
462
    if (this.itemInventory != null) {
463
      oprot.writeFieldBegin(ITEM_INVENTORY_FIELD_DESC);
464
      this.itemInventory.write(oprot);
465
      oprot.writeFieldEnd();
466
    }
467
    oprot.writeFieldStop();
468
    oprot.writeStructEnd();
469
  }
470
 
471
  @Override
472
  public String toString() {
473
    StringBuilder sb = new StringBuilder("Item(");
474
    boolean first = true;
475
 
476
    sb.append("id:");
477
    sb.append(this.id);
478
    first = false;
479
    if (!first) sb.append(", ");
480
    sb.append("category_id:");
481
    sb.append(this.category_id);
482
    first = false;
483
    if (!first) sb.append(", ");
484
    sb.append("itemAttribs:");
485
    if (this.itemAttribs == null) {
486
      sb.append("null");
487
    } else {
488
      sb.append(this.itemAttribs);
489
    }
490
    first = false;
491
    if (!first) sb.append(", ");
492
    sb.append("itemInventory:");
493
    if (this.itemInventory == null) {
494
      sb.append("null");
495
    } else {
496
      sb.append(this.itemInventory);
497
    }
498
    first = false;
499
    sb.append(")");
500
    return sb.toString();
501
  }
502
 
503
  public void validate() throws TException {
504
    // check for required fields
505
  }
506
 
507
}
508