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
 
26
public class RatingsWidget implements TBase<RatingsWidget._Fields>, java.io.Serializable, Cloneable {
27
  private static final TStruct STRUCT_DESC = new TStruct("RatingsWidget");
28
 
29
  private static final TField CATALOG_ITEM_ID_FIELD_DESC = new TField("catalog_item_id", TType.I64, (short)1);
30
  private static final TField RATINGS_FIELD_DESC = new TField("ratings", TType.MAP, (short)2);
31
  private static final TField USER_ID_FIELD_DESC = new TField("user_id", TType.I64, (short)3);
32
 
33
  private long catalog_item_id;
34
  private Map<RatingType,Double> ratings;
35
  private long user_id;
36
 
37
  /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
38
  public enum _Fields implements TFieldIdEnum {
39
    CATALOG_ITEM_ID((short)1, "catalog_item_id"),
40
    RATINGS((short)2, "ratings"),
41
    USER_ID((short)3, "user_id");
42
 
43
    private static final Map<Integer, _Fields> byId = new HashMap<Integer, _Fields>();
44
    private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
45
 
46
    static {
47
      for (_Fields field : EnumSet.allOf(_Fields.class)) {
48
        byId.put((int)field._thriftId, field);
49
        byName.put(field.getFieldName(), field);
50
      }
51
    }
52
 
53
    /**
54
     * Find the _Fields constant that matches fieldId, or null if its not found.
55
     */
56
    public static _Fields findByThriftId(int fieldId) {
57
      return byId.get(fieldId);
58
    }
59
 
60
    /**
61
     * Find the _Fields constant that matches fieldId, throwing an exception
62
     * if it is not found.
63
     */
64
    public static _Fields findByThriftIdOrThrow(int fieldId) {
65
      _Fields fields = findByThriftId(fieldId);
66
      if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
67
      return fields;
68
    }
69
 
70
    /**
71
     * Find the _Fields constant that matches name, or null if its not found.
72
     */
73
    public static _Fields findByName(String name) {
74
      return byName.get(name);
75
    }
76
 
77
    private final short _thriftId;
78
    private final String _fieldName;
79
 
80
    _Fields(short thriftId, String fieldName) {
81
      _thriftId = thriftId;
82
      _fieldName = fieldName;
83
    }
84
 
85
    public short getThriftFieldId() {
86
      return _thriftId;
87
    }
88
 
89
    public String getFieldName() {
90
      return _fieldName;
91
    }
92
  }
93
 
94
  // isset id assignments
95
  private static final int __CATALOG_ITEM_ID_ISSET_ID = 0;
96
  private static final int __USER_ID_ISSET_ID = 1;
97
  private BitSet __isset_bit_vector = new BitSet(2);
98
 
99
  public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
100
    put(_Fields.CATALOG_ITEM_ID, new FieldMetaData("catalog_item_id", TFieldRequirementType.DEFAULT, 
101
        new FieldValueMetaData(TType.I64)));
102
    put(_Fields.RATINGS, new FieldMetaData("ratings", TFieldRequirementType.DEFAULT, 
103
        new MapMetaData(TType.MAP, 
104
            new EnumMetaData(TType.ENUM, RatingType.class), 
105
            new FieldValueMetaData(TType.DOUBLE))));
106
    put(_Fields.USER_ID, new FieldMetaData("user_id", TFieldRequirementType.DEFAULT, 
107
        new FieldValueMetaData(TType.I64)));
108
  }});
109
 
110
  static {
111
    FieldMetaData.addStructMetaDataMap(RatingsWidget.class, metaDataMap);
112
  }
113
 
114
  public RatingsWidget() {
115
  }
116
 
117
  public RatingsWidget(
118
    long catalog_item_id,
119
    Map<RatingType,Double> ratings,
120
    long user_id)
121
  {
122
    this();
123
    this.catalog_item_id = catalog_item_id;
124
    setCatalog_item_idIsSet(true);
125
    this.ratings = ratings;
126
    this.user_id = user_id;
127
    setUser_idIsSet(true);
128
  }
129
 
130
  /**
131
   * Performs a deep copy on <i>other</i>.
132
   */
133
  public RatingsWidget(RatingsWidget other) {
134
    __isset_bit_vector.clear();
135
    __isset_bit_vector.or(other.__isset_bit_vector);
136
    this.catalog_item_id = other.catalog_item_id;
137
    if (other.isSetRatings()) {
138
      Map<RatingType,Double> __this__ratings = new HashMap<RatingType,Double>();
139
      for (Map.Entry<RatingType, Double> other_element : other.ratings.entrySet()) {
140
 
141
        RatingType other_element_key = other_element.getKey();
142
        Double other_element_value = other_element.getValue();
143
 
144
        RatingType __this__ratings_copy_key = other_element_key;
145
 
146
        Double __this__ratings_copy_value = other_element_value;
147
 
148
        __this__ratings.put(__this__ratings_copy_key, __this__ratings_copy_value);
149
      }
150
      this.ratings = __this__ratings;
151
    }
152
    this.user_id = other.user_id;
153
  }
154
 
155
  public RatingsWidget deepCopy() {
156
    return new RatingsWidget(this);
157
  }
158
 
159
  @Deprecated
160
  public RatingsWidget clone() {
161
    return new RatingsWidget(this);
162
  }
163
 
164
  public long getCatalog_item_id() {
165
    return this.catalog_item_id;
166
  }
167
 
168
  public RatingsWidget setCatalog_item_id(long catalog_item_id) {
169
    this.catalog_item_id = catalog_item_id;
170
    setCatalog_item_idIsSet(true);
171
    return this;
172
  }
173
 
174
  public void unsetCatalog_item_id() {
175
    __isset_bit_vector.clear(__CATALOG_ITEM_ID_ISSET_ID);
176
  }
177
 
178
  /** Returns true if field catalog_item_id is set (has been asigned a value) and false otherwise */
179
  public boolean isSetCatalog_item_id() {
180
    return __isset_bit_vector.get(__CATALOG_ITEM_ID_ISSET_ID);
181
  }
182
 
183
  public void setCatalog_item_idIsSet(boolean value) {
184
    __isset_bit_vector.set(__CATALOG_ITEM_ID_ISSET_ID, value);
185
  }
186
 
187
  public int getRatingsSize() {
188
    return (this.ratings == null) ? 0 : this.ratings.size();
189
  }
190
 
191
  public void putToRatings(RatingType key, double val) {
192
    if (this.ratings == null) {
193
      this.ratings = new HashMap<RatingType,Double>();
194
    }
195
    this.ratings.put(key, val);
196
  }
197
 
198
  public Map<RatingType,Double> getRatings() {
199
    return this.ratings;
200
  }
201
 
202
  public RatingsWidget setRatings(Map<RatingType,Double> ratings) {
203
    this.ratings = ratings;
204
    return this;
205
  }
206
 
207
  public void unsetRatings() {
208
    this.ratings = null;
209
  }
210
 
211
  /** Returns true if field ratings is set (has been asigned a value) and false otherwise */
212
  public boolean isSetRatings() {
213
    return this.ratings != null;
214
  }
215
 
216
  public void setRatingsIsSet(boolean value) {
217
    if (!value) {
218
      this.ratings = null;
219
    }
220
  }
221
 
222
  public long getUser_id() {
223
    return this.user_id;
224
  }
225
 
226
  public RatingsWidget setUser_id(long user_id) {
227
    this.user_id = user_id;
228
    setUser_idIsSet(true);
229
    return this;
230
  }
231
 
232
  public void unsetUser_id() {
233
    __isset_bit_vector.clear(__USER_ID_ISSET_ID);
234
  }
235
 
236
  /** Returns true if field user_id is set (has been asigned a value) and false otherwise */
237
  public boolean isSetUser_id() {
238
    return __isset_bit_vector.get(__USER_ID_ISSET_ID);
239
  }
240
 
241
  public void setUser_idIsSet(boolean value) {
242
    __isset_bit_vector.set(__USER_ID_ISSET_ID, value);
243
  }
244
 
245
  public void setFieldValue(_Fields field, Object value) {
246
    switch (field) {
247
    case CATALOG_ITEM_ID:
248
      if (value == null) {
249
        unsetCatalog_item_id();
250
      } else {
251
        setCatalog_item_id((Long)value);
252
      }
253
      break;
254
 
255
    case RATINGS:
256
      if (value == null) {
257
        unsetRatings();
258
      } else {
259
        setRatings((Map<RatingType,Double>)value);
260
      }
261
      break;
262
 
263
    case USER_ID:
264
      if (value == null) {
265
        unsetUser_id();
266
      } else {
267
        setUser_id((Long)value);
268
      }
269
      break;
270
 
271
    }
272
  }
273
 
274
  public void setFieldValue(int fieldID, Object value) {
275
    setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value);
276
  }
277
 
278
  public Object getFieldValue(_Fields field) {
279
    switch (field) {
280
    case CATALOG_ITEM_ID:
281
      return new Long(getCatalog_item_id());
282
 
283
    case RATINGS:
284
      return getRatings();
285
 
286
    case USER_ID:
287
      return new Long(getUser_id());
288
 
289
    }
290
    throw new IllegalStateException();
291
  }
292
 
293
  public Object getFieldValue(int fieldId) {
294
    return getFieldValue(_Fields.findByThriftIdOrThrow(fieldId));
295
  }
296
 
297
  /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
298
  public boolean isSet(_Fields field) {
299
    switch (field) {
300
    case CATALOG_ITEM_ID:
301
      return isSetCatalog_item_id();
302
    case RATINGS:
303
      return isSetRatings();
304
    case USER_ID:
305
      return isSetUser_id();
306
    }
307
    throw new IllegalStateException();
308
  }
309
 
310
  public boolean isSet(int fieldID) {
311
    return isSet(_Fields.findByThriftIdOrThrow(fieldID));
312
  }
313
 
314
  @Override
315
  public boolean equals(Object that) {
316
    if (that == null)
317
      return false;
318
    if (that instanceof RatingsWidget)
319
      return this.equals((RatingsWidget)that);
320
    return false;
321
  }
322
 
323
  public boolean equals(RatingsWidget that) {
324
    if (that == null)
325
      return false;
326
 
327
    boolean this_present_catalog_item_id = true;
328
    boolean that_present_catalog_item_id = true;
329
    if (this_present_catalog_item_id || that_present_catalog_item_id) {
330
      if (!(this_present_catalog_item_id && that_present_catalog_item_id))
331
        return false;
332
      if (this.catalog_item_id != that.catalog_item_id)
333
        return false;
334
    }
335
 
336
    boolean this_present_ratings = true && this.isSetRatings();
337
    boolean that_present_ratings = true && that.isSetRatings();
338
    if (this_present_ratings || that_present_ratings) {
339
      if (!(this_present_ratings && that_present_ratings))
340
        return false;
341
      if (!this.ratings.equals(that.ratings))
342
        return false;
343
    }
344
 
345
    boolean this_present_user_id = true;
346
    boolean that_present_user_id = true;
347
    if (this_present_user_id || that_present_user_id) {
348
      if (!(this_present_user_id && that_present_user_id))
349
        return false;
350
      if (this.user_id != that.user_id)
351
        return false;
352
    }
353
 
354
    return true;
355
  }
356
 
357
  @Override
358
  public int hashCode() {
359
    return 0;
360
  }
361
 
362
  public void read(TProtocol iprot) throws TException {
363
    TField field;
364
    iprot.readStructBegin();
365
    while (true)
366
    {
367
      field = iprot.readFieldBegin();
368
      if (field.type == TType.STOP) { 
369
        break;
370
      }
371
      _Fields fieldId = _Fields.findByThriftId(field.id);
372
      if (fieldId == null) {
373
        TProtocolUtil.skip(iprot, field.type);
374
      } else {
375
        switch (fieldId) {
376
          case CATALOG_ITEM_ID:
377
            if (field.type == TType.I64) {
378
              this.catalog_item_id = iprot.readI64();
379
              setCatalog_item_idIsSet(true);
380
            } else { 
381
              TProtocolUtil.skip(iprot, field.type);
382
            }
383
            break;
384
          case RATINGS:
385
            if (field.type == TType.MAP) {
386
              {
571 rajveer 387
                TMap _map12 = iprot.readMapBegin();
388
                this.ratings = new HashMap<RatingType,Double>(2*_map12.size);
389
                for (int _i13 = 0; _i13 < _map12.size; ++_i13)
553 chandransh 390
                {
571 rajveer 391
                  RatingType _key14;
392
                  double _val15;
393
                  _key14 = RatingType.findByValue(iprot.readI32());
394
                  _val15 = iprot.readDouble();
395
                  this.ratings.put(_key14, _val15);
553 chandransh 396
                }
397
                iprot.readMapEnd();
398
              }
399
            } else { 
400
              TProtocolUtil.skip(iprot, field.type);
401
            }
402
            break;
403
          case USER_ID:
404
            if (field.type == TType.I64) {
405
              this.user_id = iprot.readI64();
406
              setUser_idIsSet(true);
407
            } else { 
408
              TProtocolUtil.skip(iprot, field.type);
409
            }
410
            break;
411
        }
412
        iprot.readFieldEnd();
413
      }
414
    }
415
    iprot.readStructEnd();
416
    validate();
417
  }
418
 
419
  public void write(TProtocol oprot) throws TException {
420
    validate();
421
 
422
    oprot.writeStructBegin(STRUCT_DESC);
423
    oprot.writeFieldBegin(CATALOG_ITEM_ID_FIELD_DESC);
424
    oprot.writeI64(this.catalog_item_id);
425
    oprot.writeFieldEnd();
426
    if (this.ratings != null) {
427
      oprot.writeFieldBegin(RATINGS_FIELD_DESC);
428
      {
429
        oprot.writeMapBegin(new TMap(TType.I32, TType.DOUBLE, this.ratings.size()));
571 rajveer 430
        for (Map.Entry<RatingType, Double> _iter16 : this.ratings.entrySet())
553 chandransh 431
        {
571 rajveer 432
          oprot.writeI32(_iter16.getKey().getValue());
433
          oprot.writeDouble(_iter16.getValue());
553 chandransh 434
        }
435
        oprot.writeMapEnd();
436
      }
437
      oprot.writeFieldEnd();
438
    }
439
    oprot.writeFieldBegin(USER_ID_FIELD_DESC);
440
    oprot.writeI64(this.user_id);
441
    oprot.writeFieldEnd();
442
    oprot.writeFieldStop();
443
    oprot.writeStructEnd();
444
  }
445
 
446
  @Override
447
  public String toString() {
448
    StringBuilder sb = new StringBuilder("RatingsWidget(");
449
    boolean first = true;
450
 
451
    sb.append("catalog_item_id:");
452
    sb.append(this.catalog_item_id);
453
    first = false;
454
    if (!first) sb.append(", ");
455
    sb.append("ratings:");
456
    if (this.ratings == null) {
457
      sb.append("null");
458
    } else {
459
      sb.append(this.ratings);
460
    }
461
    first = false;
462
    if (!first) sb.append(", ");
463
    sb.append("user_id:");
464
    sb.append(this.user_id);
465
    first = false;
466
    sb.append(")");
467
    return sb.toString();
468
  }
469
 
470
  public void validate() throws TException {
471
    // check for required fields
472
  }
473
 
474
}
475