Subversion Repositories SmartDukaan

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
553 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.model.v1.user;
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
 
771 rajveer 26
/**
27
 * Not used right now, will decide later
28
 * enum WidgetType{
29
 * 	ACCESSORIES,
30
 * 	RATINGS,
31
 * 	SIMILAR_ITEMS,
32
 * 	RECOMMENDED_ITEMS,
33
 * 	DEAL_PROMOTIONS,
34
 * 	
35
 * 	MY_RESEARCH,
36
 * 	BROWSE_HISTORY
37
 * }
38
 * 
39
 * enum RatingType{
40
 * 	SHOP2020,
41
 * 	AMAZON,
42
 * 	USER_ALL,
43
 * 	USER_CURRENT
44
 * }
45
 * 
46
 * struct RatingsWidget{
47
 * 	1:i64 catalog_item_id,
48
 * 	2:map<RatingType,double> ratings,
49
 * 	3:i64 user_id
50
 * }
51
 */
553 chandransh 52
public class WidgetItem implements TBase<WidgetItem._Fields>, java.io.Serializable, Cloneable, Comparable<WidgetItem> {
53
  private static final TStruct STRUCT_DESC = new TStruct("WidgetItem");
54
 
55
  private static final TField ID_FIELD_DESC = new TField("id", TType.I64, (short)1);
56
  private static final TField ITEM_ID_FIELD_DESC = new TField("item_id", TType.I64, (short)2);
771 rajveer 57
  private static final TField ENABLED_FIELD_DESC = new TField("enabled", TType.BOOL, (short)3);
58
  private static final TField TIMESTAMP_FIELD_DESC = new TField("timestamp", TType.I64, (short)4);
553 chandransh 59
 
60
  private long id;
61
  private long item_id;
62
  private boolean enabled;
63
  private long timestamp;
64
 
65
  /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
66
  public enum _Fields implements TFieldIdEnum {
67
    ID((short)1, "id"),
68
    ITEM_ID((short)2, "item_id"),
771 rajveer 69
    ENABLED((short)3, "enabled"),
70
    TIMESTAMP((short)4, "timestamp");
553 chandransh 71
 
72
    private static final Map<Integer, _Fields> byId = new HashMap<Integer, _Fields>();
73
    private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
74
 
75
    static {
76
      for (_Fields field : EnumSet.allOf(_Fields.class)) {
77
        byId.put((int)field._thriftId, field);
78
        byName.put(field.getFieldName(), field);
79
      }
80
    }
81
 
82
    /**
83
     * Find the _Fields constant that matches fieldId, or null if its not found.
84
     */
85
    public static _Fields findByThriftId(int fieldId) {
86
      return byId.get(fieldId);
87
    }
88
 
89
    /**
90
     * Find the _Fields constant that matches fieldId, throwing an exception
91
     * if it is not found.
92
     */
93
    public static _Fields findByThriftIdOrThrow(int fieldId) {
94
      _Fields fields = findByThriftId(fieldId);
95
      if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
96
      return fields;
97
    }
98
 
99
    /**
100
     * Find the _Fields constant that matches name, or null if its not found.
101
     */
102
    public static _Fields findByName(String name) {
103
      return byName.get(name);
104
    }
105
 
106
    private final short _thriftId;
107
    private final String _fieldName;
108
 
109
    _Fields(short thriftId, String fieldName) {
110
      _thriftId = thriftId;
111
      _fieldName = fieldName;
112
    }
113
 
114
    public short getThriftFieldId() {
115
      return _thriftId;
116
    }
117
 
118
    public String getFieldName() {
119
      return _fieldName;
120
    }
121
  }
122
 
123
  // isset id assignments
124
  private static final int __ID_ISSET_ID = 0;
125
  private static final int __ITEM_ID_ISSET_ID = 1;
126
  private static final int __ENABLED_ISSET_ID = 2;
127
  private static final int __TIMESTAMP_ISSET_ID = 3;
128
  private BitSet __isset_bit_vector = new BitSet(4);
129
 
130
  public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
131
    put(_Fields.ID, new FieldMetaData("id", TFieldRequirementType.DEFAULT, 
132
        new FieldValueMetaData(TType.I64)));
133
    put(_Fields.ITEM_ID, new FieldMetaData("item_id", TFieldRequirementType.DEFAULT, 
134
        new FieldValueMetaData(TType.I64)));
135
    put(_Fields.ENABLED, new FieldMetaData("enabled", TFieldRequirementType.DEFAULT, 
136
        new FieldValueMetaData(TType.BOOL)));
137
    put(_Fields.TIMESTAMP, new FieldMetaData("timestamp", TFieldRequirementType.DEFAULT, 
138
        new FieldValueMetaData(TType.I64)));
139
  }});
140
 
141
  static {
142
    FieldMetaData.addStructMetaDataMap(WidgetItem.class, metaDataMap);
143
  }
144
 
145
  public WidgetItem() {
146
  }
147
 
148
  public WidgetItem(
149
    long id,
150
    long item_id,
151
    boolean enabled,
152
    long timestamp)
153
  {
154
    this();
155
    this.id = id;
156
    setIdIsSet(true);
157
    this.item_id = item_id;
158
    setItem_idIsSet(true);
159
    this.enabled = enabled;
160
    setEnabledIsSet(true);
161
    this.timestamp = timestamp;
162
    setTimestampIsSet(true);
163
  }
164
 
165
  /**
166
   * Performs a deep copy on <i>other</i>.
167
   */
168
  public WidgetItem(WidgetItem other) {
169
    __isset_bit_vector.clear();
170
    __isset_bit_vector.or(other.__isset_bit_vector);
171
    this.id = other.id;
172
    this.item_id = other.item_id;
173
    this.enabled = other.enabled;
174
    this.timestamp = other.timestamp;
175
  }
176
 
177
  public WidgetItem deepCopy() {
178
    return new WidgetItem(this);
179
  }
180
 
181
  @Deprecated
182
  public WidgetItem clone() {
183
    return new WidgetItem(this);
184
  }
185
 
186
  public long getId() {
187
    return this.id;
188
  }
189
 
190
  public WidgetItem setId(long id) {
191
    this.id = id;
192
    setIdIsSet(true);
193
    return this;
194
  }
195
 
196
  public void unsetId() {
197
    __isset_bit_vector.clear(__ID_ISSET_ID);
198
  }
199
 
200
  /** Returns true if field id is set (has been asigned a value) and false otherwise */
201
  public boolean isSetId() {
202
    return __isset_bit_vector.get(__ID_ISSET_ID);
203
  }
204
 
205
  public void setIdIsSet(boolean value) {
206
    __isset_bit_vector.set(__ID_ISSET_ID, value);
207
  }
208
 
209
  public long getItem_id() {
210
    return this.item_id;
211
  }
212
 
213
  public WidgetItem setItem_id(long item_id) {
214
    this.item_id = item_id;
215
    setItem_idIsSet(true);
216
    return this;
217
  }
218
 
219
  public void unsetItem_id() {
220
    __isset_bit_vector.clear(__ITEM_ID_ISSET_ID);
221
  }
222
 
223
  /** Returns true if field item_id is set (has been asigned a value) and false otherwise */
224
  public boolean isSetItem_id() {
225
    return __isset_bit_vector.get(__ITEM_ID_ISSET_ID);
226
  }
227
 
228
  public void setItem_idIsSet(boolean value) {
229
    __isset_bit_vector.set(__ITEM_ID_ISSET_ID, value);
230
  }
231
 
232
  public boolean isEnabled() {
233
    return this.enabled;
234
  }
235
 
236
  public WidgetItem setEnabled(boolean enabled) {
237
    this.enabled = enabled;
238
    setEnabledIsSet(true);
239
    return this;
240
  }
241
 
242
  public void unsetEnabled() {
243
    __isset_bit_vector.clear(__ENABLED_ISSET_ID);
244
  }
245
 
246
  /** Returns true if field enabled is set (has been asigned a value) and false otherwise */
247
  public boolean isSetEnabled() {
248
    return __isset_bit_vector.get(__ENABLED_ISSET_ID);
249
  }
250
 
251
  public void setEnabledIsSet(boolean value) {
252
    __isset_bit_vector.set(__ENABLED_ISSET_ID, value);
253
  }
254
 
255
  public long getTimestamp() {
256
    return this.timestamp;
257
  }
258
 
259
  public WidgetItem setTimestamp(long timestamp) {
260
    this.timestamp = timestamp;
261
    setTimestampIsSet(true);
262
    return this;
263
  }
264
 
265
  public void unsetTimestamp() {
266
    __isset_bit_vector.clear(__TIMESTAMP_ISSET_ID);
267
  }
268
 
269
  /** Returns true if field timestamp is set (has been asigned a value) and false otherwise */
270
  public boolean isSetTimestamp() {
271
    return __isset_bit_vector.get(__TIMESTAMP_ISSET_ID);
272
  }
273
 
274
  public void setTimestampIsSet(boolean value) {
275
    __isset_bit_vector.set(__TIMESTAMP_ISSET_ID, value);
276
  }
277
 
278
  public void setFieldValue(_Fields field, Object value) {
279
    switch (field) {
280
    case ID:
281
      if (value == null) {
282
        unsetId();
283
      } else {
284
        setId((Long)value);
285
      }
286
      break;
287
 
288
    case ITEM_ID:
289
      if (value == null) {
290
        unsetItem_id();
291
      } else {
292
        setItem_id((Long)value);
293
      }
294
      break;
295
 
296
    case ENABLED:
297
      if (value == null) {
298
        unsetEnabled();
299
      } else {
300
        setEnabled((Boolean)value);
301
      }
302
      break;
303
 
304
    case TIMESTAMP:
305
      if (value == null) {
306
        unsetTimestamp();
307
      } else {
308
        setTimestamp((Long)value);
309
      }
310
      break;
311
 
312
    }
313
  }
314
 
315
  public void setFieldValue(int fieldID, Object value) {
316
    setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value);
317
  }
318
 
319
  public Object getFieldValue(_Fields field) {
320
    switch (field) {
321
    case ID:
322
      return new Long(getId());
323
 
324
    case ITEM_ID:
325
      return new Long(getItem_id());
326
 
327
    case ENABLED:
328
      return new Boolean(isEnabled());
329
 
330
    case TIMESTAMP:
331
      return new Long(getTimestamp());
332
 
333
    }
334
    throw new IllegalStateException();
335
  }
336
 
337
  public Object getFieldValue(int fieldId) {
338
    return getFieldValue(_Fields.findByThriftIdOrThrow(fieldId));
339
  }
340
 
341
  /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
342
  public boolean isSet(_Fields field) {
343
    switch (field) {
344
    case ID:
345
      return isSetId();
346
    case ITEM_ID:
347
      return isSetItem_id();
348
    case ENABLED:
349
      return isSetEnabled();
350
    case TIMESTAMP:
351
      return isSetTimestamp();
352
    }
353
    throw new IllegalStateException();
354
  }
355
 
356
  public boolean isSet(int fieldID) {
357
    return isSet(_Fields.findByThriftIdOrThrow(fieldID));
358
  }
359
 
360
  @Override
361
  public boolean equals(Object that) {
362
    if (that == null)
363
      return false;
364
    if (that instanceof WidgetItem)
365
      return this.equals((WidgetItem)that);
366
    return false;
367
  }
368
 
369
  public boolean equals(WidgetItem that) {
370
    if (that == null)
371
      return false;
372
 
373
    boolean this_present_id = true;
374
    boolean that_present_id = true;
375
    if (this_present_id || that_present_id) {
376
      if (!(this_present_id && that_present_id))
377
        return false;
378
      if (this.id != that.id)
379
        return false;
380
    }
381
 
382
    boolean this_present_item_id = true;
383
    boolean that_present_item_id = true;
384
    if (this_present_item_id || that_present_item_id) {
385
      if (!(this_present_item_id && that_present_item_id))
386
        return false;
387
      if (this.item_id != that.item_id)
388
        return false;
389
    }
390
 
391
    boolean this_present_enabled = true;
392
    boolean that_present_enabled = true;
393
    if (this_present_enabled || that_present_enabled) {
394
      if (!(this_present_enabled && that_present_enabled))
395
        return false;
396
      if (this.enabled != that.enabled)
397
        return false;
398
    }
399
 
400
    boolean this_present_timestamp = true;
401
    boolean that_present_timestamp = true;
402
    if (this_present_timestamp || that_present_timestamp) {
403
      if (!(this_present_timestamp && that_present_timestamp))
404
        return false;
405
      if (this.timestamp != that.timestamp)
406
        return false;
407
    }
408
 
409
    return true;
410
  }
411
 
412
  @Override
413
  public int hashCode() {
414
    return 0;
415
  }
416
 
417
  public int compareTo(WidgetItem other) {
418
    if (!getClass().equals(other.getClass())) {
419
      return getClass().getName().compareTo(other.getClass().getName());
420
    }
421
 
422
    int lastComparison = 0;
423
    WidgetItem typedOther = (WidgetItem)other;
424
 
425
    lastComparison = Boolean.valueOf(isSetId()).compareTo(isSetId());
426
    if (lastComparison != 0) {
427
      return lastComparison;
428
    }
429
    lastComparison = TBaseHelper.compareTo(id, typedOther.id);
430
    if (lastComparison != 0) {
431
      return lastComparison;
432
    }
433
    lastComparison = Boolean.valueOf(isSetItem_id()).compareTo(isSetItem_id());
434
    if (lastComparison != 0) {
435
      return lastComparison;
436
    }
437
    lastComparison = TBaseHelper.compareTo(item_id, typedOther.item_id);
438
    if (lastComparison != 0) {
439
      return lastComparison;
440
    }
441
    lastComparison = Boolean.valueOf(isSetEnabled()).compareTo(isSetEnabled());
442
    if (lastComparison != 0) {
443
      return lastComparison;
444
    }
445
    lastComparison = TBaseHelper.compareTo(enabled, typedOther.enabled);
446
    if (lastComparison != 0) {
447
      return lastComparison;
448
    }
449
    lastComparison = Boolean.valueOf(isSetTimestamp()).compareTo(isSetTimestamp());
450
    if (lastComparison != 0) {
451
      return lastComparison;
452
    }
453
    lastComparison = TBaseHelper.compareTo(timestamp, typedOther.timestamp);
454
    if (lastComparison != 0) {
455
      return lastComparison;
456
    }
457
    return 0;
458
  }
459
 
460
  public void read(TProtocol iprot) throws TException {
461
    TField field;
462
    iprot.readStructBegin();
463
    while (true)
464
    {
465
      field = iprot.readFieldBegin();
466
      if (field.type == TType.STOP) { 
467
        break;
468
      }
469
      _Fields fieldId = _Fields.findByThriftId(field.id);
470
      if (fieldId == null) {
471
        TProtocolUtil.skip(iprot, field.type);
472
      } else {
473
        switch (fieldId) {
474
          case ID:
475
            if (field.type == TType.I64) {
476
              this.id = iprot.readI64();
477
              setIdIsSet(true);
478
            } else { 
479
              TProtocolUtil.skip(iprot, field.type);
480
            }
481
            break;
482
          case ITEM_ID:
483
            if (field.type == TType.I64) {
484
              this.item_id = iprot.readI64();
485
              setItem_idIsSet(true);
486
            } else { 
487
              TProtocolUtil.skip(iprot, field.type);
488
            }
489
            break;
490
          case ENABLED:
491
            if (field.type == TType.BOOL) {
492
              this.enabled = iprot.readBool();
493
              setEnabledIsSet(true);
494
            } else { 
495
              TProtocolUtil.skip(iprot, field.type);
496
            }
497
            break;
498
          case TIMESTAMP:
499
            if (field.type == TType.I64) {
500
              this.timestamp = iprot.readI64();
501
              setTimestampIsSet(true);
502
            } else { 
503
              TProtocolUtil.skip(iprot, field.type);
504
            }
505
            break;
506
        }
507
        iprot.readFieldEnd();
508
      }
509
    }
510
    iprot.readStructEnd();
511
    validate();
512
  }
513
 
514
  public void write(TProtocol oprot) throws TException {
515
    validate();
516
 
517
    oprot.writeStructBegin(STRUCT_DESC);
518
    oprot.writeFieldBegin(ID_FIELD_DESC);
519
    oprot.writeI64(this.id);
520
    oprot.writeFieldEnd();
521
    oprot.writeFieldBegin(ITEM_ID_FIELD_DESC);
522
    oprot.writeI64(this.item_id);
523
    oprot.writeFieldEnd();
524
    oprot.writeFieldBegin(ENABLED_FIELD_DESC);
525
    oprot.writeBool(this.enabled);
526
    oprot.writeFieldEnd();
527
    oprot.writeFieldBegin(TIMESTAMP_FIELD_DESC);
528
    oprot.writeI64(this.timestamp);
529
    oprot.writeFieldEnd();
530
    oprot.writeFieldStop();
531
    oprot.writeStructEnd();
532
  }
533
 
534
  @Override
535
  public String toString() {
536
    StringBuilder sb = new StringBuilder("WidgetItem(");
537
    boolean first = true;
538
 
539
    sb.append("id:");
540
    sb.append(this.id);
541
    first = false;
542
    if (!first) sb.append(", ");
543
    sb.append("item_id:");
544
    sb.append(this.item_id);
545
    first = false;
546
    if (!first) sb.append(", ");
547
    sb.append("enabled:");
548
    sb.append(this.enabled);
549
    first = false;
550
    if (!first) sb.append(", ");
551
    sb.append("timestamp:");
552
    sb.append(this.timestamp);
553
    first = false;
554
    sb.append(")");
555
    return sb.toString();
556
  }
557
 
558
  public void validate() throws TException {
559
    // check for required fields
560
  }
561
 
562
}
563