Subversion Repositories SmartDukaan

Rev

Rev 352 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
352 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.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 Message implements TBase<Message._Fields>, java.io.Serializable, Cloneable, Comparable<Message> {
27
  private static final TStruct STRUCT_DESC = new TStruct("Message");
28
 
29
  private static final TField ID_FIELD_DESC = new TField("id", TType.I64, (short)1);
30
  private static final TField MESSAGE_FIELD_DESC = new TField("message", TType.STRING, (short)2);
31
 
32
  private long id;
33
  private String message;
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
    ID((short)1, "id"),
38
    MESSAGE((short)2, "message");
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 __ID_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.ID, new FieldMetaData("id", TFieldRequirementType.DEFAULT, 
97
        new FieldValueMetaData(TType.I64)));
98
    put(_Fields.MESSAGE, new FieldMetaData("message", TFieldRequirementType.DEFAULT, 
99
        new FieldValueMetaData(TType.STRING)));
100
  }});
101
 
102
  static {
103
    FieldMetaData.addStructMetaDataMap(Message.class, metaDataMap);
104
  }
105
 
106
  public Message() {
107
  }
108
 
109
  public Message(
110
    long id,
111
    String message)
112
  {
113
    this();
114
    this.id = id;
115
    setIdIsSet(true);
116
    this.message = message;
117
  }
118
 
119
  /**
120
   * Performs a deep copy on <i>other</i>.
121
   */
122
  public Message(Message other) {
123
    __isset_bit_vector.clear();
124
    __isset_bit_vector.or(other.__isset_bit_vector);
125
    this.id = other.id;
126
    if (other.isSetMessage()) {
127
      this.message = other.message;
128
    }
129
  }
130
 
131
  public Message deepCopy() {
132
    return new Message(this);
133
  }
134
 
135
  @Deprecated
136
  public Message clone() {
137
    return new Message(this);
138
  }
139
 
140
  public long getId() {
141
    return this.id;
142
  }
143
 
144
  public Message setId(long id) {
145
    this.id = id;
146
    setIdIsSet(true);
147
    return this;
148
  }
149
 
150
  public void unsetId() {
151
    __isset_bit_vector.clear(__ID_ISSET_ID);
152
  }
153
 
154
  /** Returns true if field id is set (has been asigned a value) and false otherwise */
155
  public boolean isSetId() {
156
    return __isset_bit_vector.get(__ID_ISSET_ID);
157
  }
158
 
159
  public void setIdIsSet(boolean value) {
160
    __isset_bit_vector.set(__ID_ISSET_ID, value);
161
  }
162
 
163
  public String getMessage() {
164
    return this.message;
165
  }
166
 
167
  public Message setMessage(String message) {
168
    this.message = message;
169
    return this;
170
  }
171
 
172
  public void unsetMessage() {
173
    this.message = null;
174
  }
175
 
176
  /** Returns true if field message is set (has been asigned a value) and false otherwise */
177
  public boolean isSetMessage() {
178
    return this.message != null;
179
  }
180
 
181
  public void setMessageIsSet(boolean value) {
182
    if (!value) {
183
      this.message = null;
184
    }
185
  }
186
 
187
  public void setFieldValue(_Fields field, Object value) {
188
    switch (field) {
189
    case ID:
190
      if (value == null) {
191
        unsetId();
192
      } else {
193
        setId((Long)value);
194
      }
195
      break;
196
 
197
    case MESSAGE:
198
      if (value == null) {
199
        unsetMessage();
200
      } else {
201
        setMessage((String)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 ID:
215
      return new Long(getId());
216
 
217
    case MESSAGE:
218
      return getMessage();
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 ID:
232
      return isSetId();
233
    case MESSAGE:
234
      return isSetMessage();
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 Message)
248
      return this.equals((Message)that);
249
    return false;
250
  }
251
 
252
  public boolean equals(Message that) {
253
    if (that == null)
254
      return false;
255
 
256
    boolean this_present_id = true;
257
    boolean that_present_id = true;
258
    if (this_present_id || that_present_id) {
259
      if (!(this_present_id && that_present_id))
260
        return false;
261
      if (this.id != that.id)
262
        return false;
263
    }
264
 
265
    boolean this_present_message = true && this.isSetMessage();
266
    boolean that_present_message = true && that.isSetMessage();
267
    if (this_present_message || that_present_message) {
268
      if (!(this_present_message && that_present_message))
269
        return false;
270
      if (!this.message.equals(that.message))
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(Message other) {
283
    if (!getClass().equals(other.getClass())) {
284
      return getClass().getName().compareTo(other.getClass().getName());
285
    }
286
 
287
    int lastComparison = 0;
288
    Message typedOther = (Message)other;
289
 
290
    lastComparison = Boolean.valueOf(isSetId()).compareTo(isSetId());
291
    if (lastComparison != 0) {
292
      return lastComparison;
293
    }
294
    lastComparison = TBaseHelper.compareTo(id, typedOther.id);
295
    if (lastComparison != 0) {
296
      return lastComparison;
297
    }
298
    lastComparison = Boolean.valueOf(isSetMessage()).compareTo(isSetMessage());
299
    if (lastComparison != 0) {
300
      return lastComparison;
301
    }
302
    lastComparison = TBaseHelper.compareTo(message, typedOther.message);
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 ID:
324
            if (field.type == TType.I64) {
325
              this.id = iprot.readI64();
326
              setIdIsSet(true);
327
            } else { 
328
              TProtocolUtil.skip(iprot, field.type);
329
            }
330
            break;
331
          case MESSAGE:
332
            if (field.type == TType.STRING) {
333
              this.message = iprot.readString();
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
    oprot.writeFieldBegin(ID_FIELD_DESC);
351
    oprot.writeI64(this.id);
352
    oprot.writeFieldEnd();
353
    if (this.message != null) {
354
      oprot.writeFieldBegin(MESSAGE_FIELD_DESC);
355
      oprot.writeString(this.message);
356
      oprot.writeFieldEnd();
357
    }
358
    oprot.writeFieldStop();
359
    oprot.writeStructEnd();
360
  }
361
 
362
  @Override
363
  public String toString() {
364
    StringBuilder sb = new StringBuilder("Message(");
365
    boolean first = true;
366
 
367
    sb.append("id:");
368
    sb.append(this.id);
369
    first = false;
370
    if (!first) sb.append(", ");
371
    sb.append("message:");
372
    if (this.message == null) {
373
      sb.append("null");
374
    } else {
375
      sb.append(this.message);
376
    }
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