Subversion Repositories SmartDukaan

Rev

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

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