Subversion Repositories SmartDukaan

Rev

Details | Last modification | View Log | RSS feed

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