Subversion Repositories SmartDukaan

Rev

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

Rev Author Line No. Line
1891 ankur.sing 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.utils;
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 ReportUser implements TBase<ReportUser._Fields>, java.io.Serializable, Cloneable, Comparable<ReportUser> {
27
  private static final TStruct STRUCT_DESC = new TStruct("ReportUser");
28
 
29
  private static final TField USERNAME_FIELD_DESC = new TField("username", TType.STRING, (short)1);
30
  private static final TField ROLE_FIELD_DESC = new TField("role", TType.I64, (short)2);
31
 
32
  private String username;
33
  private long role;
34
 
35
  /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
36
  public enum _Fields implements TFieldIdEnum {
37
    USERNAME((short)1, "username"),
38
    ROLE((short)2, "role");
39
 
40
    private static final Map<Integer, _Fields> byId = new HashMap<Integer, _Fields>();
41
    private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
42
 
43
    static {
44
      for (_Fields field : EnumSet.allOf(_Fields.class)) {
45
        byId.put((int)field._thriftId, field);
46
        byName.put(field.getFieldName(), field);
47
      }
48
    }
49
 
50
    /**
51
     * Find the _Fields constant that matches fieldId, or null if its not found.
52
     */
53
    public static _Fields findByThriftId(int fieldId) {
54
      return byId.get(fieldId);
55
    }
56
 
57
    /**
58
     * Find the _Fields constant that matches fieldId, throwing an exception
59
     * if it is not found.
60
     */
61
    public static _Fields findByThriftIdOrThrow(int fieldId) {
62
      _Fields fields = findByThriftId(fieldId);
63
      if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
64
      return fields;
65
    }
66
 
67
    /**
68
     * Find the _Fields constant that matches name, or null if its not found.
69
     */
70
    public static _Fields findByName(String name) {
71
      return byName.get(name);
72
    }
73
 
74
    private final short _thriftId;
75
    private final String _fieldName;
76
 
77
    _Fields(short thriftId, String fieldName) {
78
      _thriftId = thriftId;
79
      _fieldName = fieldName;
80
    }
81
 
82
    public short getThriftFieldId() {
83
      return _thriftId;
84
    }
85
 
86
    public String getFieldName() {
87
      return _fieldName;
88
    }
89
  }
90
 
91
  // isset id assignments
92
  private static final int __ROLE_ISSET_ID = 0;
93
  private BitSet __isset_bit_vector = new BitSet(1);
94
 
95
  public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
96
    put(_Fields.USERNAME, new FieldMetaData("username", TFieldRequirementType.DEFAULT, 
97
        new FieldValueMetaData(TType.STRING)));
98
    put(_Fields.ROLE, new FieldMetaData("role", TFieldRequirementType.DEFAULT, 
99
        new FieldValueMetaData(TType.I64)));
100
  }});
101
 
102
  static {
103
    FieldMetaData.addStructMetaDataMap(ReportUser.class, metaDataMap);
104
  }
105
 
106
  public ReportUser() {
107
  }
108
 
109
  public ReportUser(
110
    String username,
111
    long role)
112
  {
113
    this();
114
    this.username = username;
115
    this.role = role;
116
    setRoleIsSet(true);
117
  }
118
 
119
  /**
120
   * Performs a deep copy on <i>other</i>.
121
   */
122
  public ReportUser(ReportUser other) {
123
    __isset_bit_vector.clear();
124
    __isset_bit_vector.or(other.__isset_bit_vector);
125
    if (other.isSetUsername()) {
126
      this.username = other.username;
127
    }
128
    this.role = other.role;
129
  }
130
 
131
  public ReportUser deepCopy() {
132
    return new ReportUser(this);
133
  }
134
 
135
  @Deprecated
136
  public ReportUser clone() {
137
    return new ReportUser(this);
138
  }
139
 
140
  public String getUsername() {
141
    return this.username;
142
  }
143
 
144
  public ReportUser setUsername(String username) {
145
    this.username = username;
146
    return this;
147
  }
148
 
149
  public void unsetUsername() {
150
    this.username = null;
151
  }
152
 
153
  /** Returns true if field username is set (has been asigned a value) and false otherwise */
154
  public boolean isSetUsername() {
155
    return this.username != null;
156
  }
157
 
158
  public void setUsernameIsSet(boolean value) {
159
    if (!value) {
160
      this.username = null;
161
    }
162
  }
163
 
164
  public long getRole() {
165
    return this.role;
166
  }
167
 
168
  public ReportUser setRole(long role) {
169
    this.role = role;
170
    setRoleIsSet(true);
171
    return this;
172
  }
173
 
174
  public void unsetRole() {
175
    __isset_bit_vector.clear(__ROLE_ISSET_ID);
176
  }
177
 
178
  /** Returns true if field role is set (has been asigned a value) and false otherwise */
179
  public boolean isSetRole() {
180
    return __isset_bit_vector.get(__ROLE_ISSET_ID);
181
  }
182
 
183
  public void setRoleIsSet(boolean value) {
184
    __isset_bit_vector.set(__ROLE_ISSET_ID, value);
185
  }
186
 
187
  public void setFieldValue(_Fields field, Object value) {
188
    switch (field) {
189
    case USERNAME:
190
      if (value == null) {
191
        unsetUsername();
192
      } else {
193
        setUsername((String)value);
194
      }
195
      break;
196
 
197
    case ROLE:
198
      if (value == null) {
199
        unsetRole();
200
      } else {
201
        setRole((Long)value);
202
      }
203
      break;
204
 
205
    }
206
  }
207
 
208
  public void setFieldValue(int fieldID, Object value) {
209
    setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value);
210
  }
211
 
212
  public Object getFieldValue(_Fields field) {
213
    switch (field) {
214
    case USERNAME:
215
      return getUsername();
216
 
217
    case ROLE:
218
      return new Long(getRole());
219
 
220
    }
221
    throw new IllegalStateException();
222
  }
223
 
224
  public Object getFieldValue(int fieldId) {
225
    return getFieldValue(_Fields.findByThriftIdOrThrow(fieldId));
226
  }
227
 
228
  /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
229
  public boolean isSet(_Fields field) {
230
    switch (field) {
231
    case USERNAME:
232
      return isSetUsername();
233
    case ROLE:
234
      return isSetRole();
235
    }
236
    throw new IllegalStateException();
237
  }
238
 
239
  public boolean isSet(int fieldID) {
240
    return isSet(_Fields.findByThriftIdOrThrow(fieldID));
241
  }
242
 
243
  @Override
244
  public boolean equals(Object that) {
245
    if (that == null)
246
      return false;
247
    if (that instanceof ReportUser)
248
      return this.equals((ReportUser)that);
249
    return false;
250
  }
251
 
252
  public boolean equals(ReportUser that) {
253
    if (that == null)
254
      return false;
255
 
256
    boolean this_present_username = true && this.isSetUsername();
257
    boolean that_present_username = true && that.isSetUsername();
258
    if (this_present_username || that_present_username) {
259
      if (!(this_present_username && that_present_username))
260
        return false;
261
      if (!this.username.equals(that.username))
262
        return false;
263
    }
264
 
265
    boolean this_present_role = true;
266
    boolean that_present_role = true;
267
    if (this_present_role || that_present_role) {
268
      if (!(this_present_role && that_present_role))
269
        return false;
270
      if (this.role != that.role)
271
        return false;
272
    }
273
 
274
    return true;
275
  }
276
 
277
  @Override
278
  public int hashCode() {
279
    return 0;
280
  }
281
 
282
  public int compareTo(ReportUser other) {
283
    if (!getClass().equals(other.getClass())) {
284
      return getClass().getName().compareTo(other.getClass().getName());
285
    }
286
 
287
    int lastComparison = 0;
288
    ReportUser typedOther = (ReportUser)other;
289
 
290
    lastComparison = Boolean.valueOf(isSetUsername()).compareTo(isSetUsername());
291
    if (lastComparison != 0) {
292
      return lastComparison;
293
    }
294
    lastComparison = TBaseHelper.compareTo(username, typedOther.username);
295
    if (lastComparison != 0) {
296
      return lastComparison;
297
    }
298
    lastComparison = Boolean.valueOf(isSetRole()).compareTo(isSetRole());
299
    if (lastComparison != 0) {
300
      return lastComparison;
301
    }
302
    lastComparison = TBaseHelper.compareTo(role, typedOther.role);
303
    if (lastComparison != 0) {
304
      return lastComparison;
305
    }
306
    return 0;
307
  }
308
 
309
  public void read(TProtocol iprot) throws TException {
310
    TField field;
311
    iprot.readStructBegin();
312
    while (true)
313
    {
314
      field = iprot.readFieldBegin();
315
      if (field.type == TType.STOP) { 
316
        break;
317
      }
318
      _Fields fieldId = _Fields.findByThriftId(field.id);
319
      if (fieldId == null) {
320
        TProtocolUtil.skip(iprot, field.type);
321
      } else {
322
        switch (fieldId) {
323
          case USERNAME:
324
            if (field.type == TType.STRING) {
325
              this.username = iprot.readString();
326
            } else { 
327
              TProtocolUtil.skip(iprot, field.type);
328
            }
329
            break;
330
          case ROLE:
331
            if (field.type == TType.I64) {
332
              this.role = iprot.readI64();
333
              setRoleIsSet(true);
334
            } else { 
335
              TProtocolUtil.skip(iprot, field.type);
336
            }
337
            break;
338
        }
339
        iprot.readFieldEnd();
340
      }
341
    }
342
    iprot.readStructEnd();
343
    validate();
344
  }
345
 
346
  public void write(TProtocol oprot) throws TException {
347
    validate();
348
 
349
    oprot.writeStructBegin(STRUCT_DESC);
350
    if (this.username != null) {
351
      oprot.writeFieldBegin(USERNAME_FIELD_DESC);
352
      oprot.writeString(this.username);
353
      oprot.writeFieldEnd();
354
    }
355
    oprot.writeFieldBegin(ROLE_FIELD_DESC);
356
    oprot.writeI64(this.role);
357
    oprot.writeFieldEnd();
358
    oprot.writeFieldStop();
359
    oprot.writeStructEnd();
360
  }
361
 
362
  @Override
363
  public String toString() {
364
    StringBuilder sb = new StringBuilder("ReportUser(");
365
    boolean first = true;
366
 
367
    sb.append("username:");
368
    if (this.username == null) {
369
      sb.append("null");
370
    } else {
371
      sb.append(this.username);
372
    }
373
    first = false;
374
    if (!first) sb.append(", ");
375
    sb.append("role:");
376
    sb.append(this.role);
377
    first = false;
378
    sb.append(")");
379
    return sb.toString();
380
  }
381
 
382
  public void validate() throws TException {
383
    // check for required fields
384
  }
385
 
386
}
387