Subversion Repositories SmartDukaan

Rev

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

Rev Author Line No. Line
412 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.logistics;
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
 
3044 chandransh 26
public class Provider implements TBase<Provider._Fields>, java.io.Serializable, Cloneable {
412 ashish 27
  private static final TStruct STRUCT_DESC = new TStruct("Provider");
28
 
29
  private static final TField ID_FIELD_DESC = new TField("id", TType.I64, (short)1);
30
  private static final TField NAME_FIELD_DESC = new TField("name", TType.STRING, (short)2);
3044 chandransh 31
  private static final TField DETAILS_FIELD_DESC = new TField("details", TType.MAP, (short)3);
412 ashish 32
 
33
  private long id;
34
  private String name;
3044 chandransh 35
  private Map<DeliveryType,ProviderDetails> details;
412 ashish 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
    ID((short)1, "id"),
668 chandransh 40
    NAME((short)2, "name"),
3044 chandransh 41
    DETAILS((short)3, "details");
412 ashish 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 __ID_ISSET_ID = 0;
96
  private BitSet __isset_bit_vector = new BitSet(1);
97
 
98
  public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
99
    put(_Fields.ID, new FieldMetaData("id", TFieldRequirementType.DEFAULT, 
100
        new FieldValueMetaData(TType.I64)));
101
    put(_Fields.NAME, new FieldMetaData("name", TFieldRequirementType.DEFAULT, 
102
        new FieldValueMetaData(TType.STRING)));
3044 chandransh 103
    put(_Fields.DETAILS, new FieldMetaData("details", TFieldRequirementType.DEFAULT, 
104
        new MapMetaData(TType.MAP, 
105
            new EnumMetaData(TType.ENUM, DeliveryType.class), 
106
            new StructMetaData(TType.STRUCT, ProviderDetails.class))));
412 ashish 107
  }});
108
 
109
  static {
110
    FieldMetaData.addStructMetaDataMap(Provider.class, metaDataMap);
111
  }
112
 
113
  public Provider() {
114
  }
115
 
116
  public Provider(
117
    long id,
668 chandransh 118
    String name,
3044 chandransh 119
    Map<DeliveryType,ProviderDetails> details)
412 ashish 120
  {
121
    this();
122
    this.id = id;
123
    setIdIsSet(true);
124
    this.name = name;
3044 chandransh 125
    this.details = details;
412 ashish 126
  }
127
 
128
  /**
129
   * Performs a deep copy on <i>other</i>.
130
   */
131
  public Provider(Provider other) {
132
    __isset_bit_vector.clear();
133
    __isset_bit_vector.or(other.__isset_bit_vector);
134
    this.id = other.id;
135
    if (other.isSetName()) {
136
      this.name = other.name;
137
    }
3044 chandransh 138
    if (other.isSetDetails()) {
139
      Map<DeliveryType,ProviderDetails> __this__details = new HashMap<DeliveryType,ProviderDetails>();
140
      for (Map.Entry<DeliveryType, ProviderDetails> other_element : other.details.entrySet()) {
141
 
142
        DeliveryType other_element_key = other_element.getKey();
143
        ProviderDetails other_element_value = other_element.getValue();
144
 
145
        DeliveryType __this__details_copy_key = other_element_key;
146
 
147
        ProviderDetails __this__details_copy_value = new ProviderDetails(other_element_value);
148
 
149
        __this__details.put(__this__details_copy_key, __this__details_copy_value);
150
      }
151
      this.details = __this__details;
668 chandransh 152
    }
412 ashish 153
  }
154
 
155
  public Provider deepCopy() {
156
    return new Provider(this);
157
  }
158
 
159
  @Deprecated
160
  public Provider clone() {
161
    return new Provider(this);
162
  }
163
 
164
  public long getId() {
165
    return this.id;
166
  }
167
 
168
  public Provider setId(long id) {
169
    this.id = id;
170
    setIdIsSet(true);
171
    return this;
172
  }
173
 
174
  public void unsetId() {
175
    __isset_bit_vector.clear(__ID_ISSET_ID);
176
  }
177
 
178
  /** Returns true if field id is set (has been asigned a value) and false otherwise */
179
  public boolean isSetId() {
180
    return __isset_bit_vector.get(__ID_ISSET_ID);
181
  }
182
 
183
  public void setIdIsSet(boolean value) {
184
    __isset_bit_vector.set(__ID_ISSET_ID, value);
185
  }
186
 
187
  public String getName() {
188
    return this.name;
189
  }
190
 
191
  public Provider setName(String name) {
192
    this.name = name;
193
    return this;
194
  }
195
 
196
  public void unsetName() {
197
    this.name = null;
198
  }
199
 
200
  /** Returns true if field name is set (has been asigned a value) and false otherwise */
201
  public boolean isSetName() {
202
    return this.name != null;
203
  }
204
 
205
  public void setNameIsSet(boolean value) {
206
    if (!value) {
207
      this.name = null;
208
    }
209
  }
210
 
3044 chandransh 211
  public int getDetailsSize() {
212
    return (this.details == null) ? 0 : this.details.size();
668 chandransh 213
  }
214
 
3044 chandransh 215
  public void putToDetails(DeliveryType key, ProviderDetails val) {
216
    if (this.details == null) {
217
      this.details = new HashMap<DeliveryType,ProviderDetails>();
668 chandransh 218
    }
3044 chandransh 219
    this.details.put(key, val);
668 chandransh 220
  }
221
 
3044 chandransh 222
  public Map<DeliveryType,ProviderDetails> getDetails() {
223
    return this.details;
2515 chandransh 224
  }
225
 
3044 chandransh 226
  public Provider setDetails(Map<DeliveryType,ProviderDetails> details) {
227
    this.details = details;
2515 chandransh 228
    return this;
229
  }
230
 
3044 chandransh 231
  public void unsetDetails() {
232
    this.details = null;
2515 chandransh 233
  }
234
 
3044 chandransh 235
  /** Returns true if field details is set (has been asigned a value) and false otherwise */
236
  public boolean isSetDetails() {
237
    return this.details != null;
2515 chandransh 238
  }
239
 
3044 chandransh 240
  public void setDetailsIsSet(boolean value) {
2515 chandransh 241
    if (!value) {
3044 chandransh 242
      this.details = null;
2515 chandransh 243
    }
244
  }
245
 
412 ashish 246
  public void setFieldValue(_Fields field, Object value) {
247
    switch (field) {
248
    case ID:
249
      if (value == null) {
250
        unsetId();
251
      } else {
252
        setId((Long)value);
253
      }
254
      break;
255
 
256
    case NAME:
257
      if (value == null) {
258
        unsetName();
259
      } else {
260
        setName((String)value);
261
      }
262
      break;
263
 
3044 chandransh 264
    case DETAILS:
668 chandransh 265
      if (value == null) {
3044 chandransh 266
        unsetDetails();
668 chandransh 267
      } else {
3044 chandransh 268
        setDetails((Map<DeliveryType,ProviderDetails>)value);
668 chandransh 269
      }
270
      break;
271
 
412 ashish 272
    }
273
  }
274
 
275
  public void setFieldValue(int fieldID, Object value) {
276
    setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value);
277
  }
278
 
279
  public Object getFieldValue(_Fields field) {
280
    switch (field) {
281
    case ID:
282
      return new Long(getId());
283
 
284
    case NAME:
285
      return getName();
286
 
3044 chandransh 287
    case DETAILS:
288
      return getDetails();
668 chandransh 289
 
412 ashish 290
    }
291
    throw new IllegalStateException();
292
  }
293
 
294
  public Object getFieldValue(int fieldId) {
295
    return getFieldValue(_Fields.findByThriftIdOrThrow(fieldId));
296
  }
297
 
298
  /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
299
  public boolean isSet(_Fields field) {
300
    switch (field) {
301
    case ID:
302
      return isSetId();
303
    case NAME:
304
      return isSetName();
3044 chandransh 305
    case DETAILS:
306
      return isSetDetails();
412 ashish 307
    }
308
    throw new IllegalStateException();
309
  }
310
 
311
  public boolean isSet(int fieldID) {
312
    return isSet(_Fields.findByThriftIdOrThrow(fieldID));
313
  }
314
 
315
  @Override
316
  public boolean equals(Object that) {
317
    if (that == null)
318
      return false;
319
    if (that instanceof Provider)
320
      return this.equals((Provider)that);
321
    return false;
322
  }
323
 
324
  public boolean equals(Provider that) {
325
    if (that == null)
326
      return false;
327
 
328
    boolean this_present_id = true;
329
    boolean that_present_id = true;
330
    if (this_present_id || that_present_id) {
331
      if (!(this_present_id && that_present_id))
332
        return false;
333
      if (this.id != that.id)
334
        return false;
335
    }
336
 
337
    boolean this_present_name = true && this.isSetName();
338
    boolean that_present_name = true && that.isSetName();
339
    if (this_present_name || that_present_name) {
340
      if (!(this_present_name && that_present_name))
341
        return false;
342
      if (!this.name.equals(that.name))
343
        return false;
344
    }
345
 
3044 chandransh 346
    boolean this_present_details = true && this.isSetDetails();
347
    boolean that_present_details = true && that.isSetDetails();
348
    if (this_present_details || that_present_details) {
349
      if (!(this_present_details && that_present_details))
668 chandransh 350
        return false;
3044 chandransh 351
      if (!this.details.equals(that.details))
668 chandransh 352
        return false;
353
    }
354
 
412 ashish 355
    return true;
356
  }
357
 
358
  @Override
359
  public int hashCode() {
360
    return 0;
361
  }
362
 
363
  public void read(TProtocol iprot) throws TException {
364
    TField field;
365
    iprot.readStructBegin();
366
    while (true)
367
    {
368
      field = iprot.readFieldBegin();
369
      if (field.type == TType.STOP) { 
370
        break;
371
      }
372
      _Fields fieldId = _Fields.findByThriftId(field.id);
373
      if (fieldId == null) {
374
        TProtocolUtil.skip(iprot, field.type);
375
      } else {
376
        switch (fieldId) {
377
          case ID:
378
            if (field.type == TType.I64) {
379
              this.id = iprot.readI64();
380
              setIdIsSet(true);
381
            } else { 
382
              TProtocolUtil.skip(iprot, field.type);
383
            }
384
            break;
385
          case NAME:
386
            if (field.type == TType.STRING) {
387
              this.name = iprot.readString();
388
            } else { 
389
              TProtocolUtil.skip(iprot, field.type);
390
            }
391
            break;
3044 chandransh 392
          case DETAILS:
393
            if (field.type == TType.MAP) {
394
              {
395
                TMap _map0 = iprot.readMapBegin();
396
                this.details = new HashMap<DeliveryType,ProviderDetails>(2*_map0.size);
397
                for (int _i1 = 0; _i1 < _map0.size; ++_i1)
398
                {
399
                  DeliveryType _key2;
400
                  ProviderDetails _val3;
401
                  _key2 = DeliveryType.findByValue(iprot.readI32());
402
                  _val3 = new ProviderDetails();
403
                  _val3.read(iprot);
404
                  this.details.put(_key2, _val3);
405
                }
406
                iprot.readMapEnd();
407
              }
668 chandransh 408
            } else { 
409
              TProtocolUtil.skip(iprot, field.type);
410
            }
411
            break;
412 ashish 412
        }
413
        iprot.readFieldEnd();
414
      }
415
    }
416
    iprot.readStructEnd();
417
    validate();
418
  }
419
 
420
  public void write(TProtocol oprot) throws TException {
421
    validate();
422
 
423
    oprot.writeStructBegin(STRUCT_DESC);
424
    oprot.writeFieldBegin(ID_FIELD_DESC);
425
    oprot.writeI64(this.id);
426
    oprot.writeFieldEnd();
427
    if (this.name != null) {
428
      oprot.writeFieldBegin(NAME_FIELD_DESC);
429
      oprot.writeString(this.name);
430
      oprot.writeFieldEnd();
431
    }
3044 chandransh 432
    if (this.details != null) {
433
      oprot.writeFieldBegin(DETAILS_FIELD_DESC);
434
      {
435
        oprot.writeMapBegin(new TMap(TType.I32, TType.STRUCT, this.details.size()));
436
        for (Map.Entry<DeliveryType, ProviderDetails> _iter4 : this.details.entrySet())
437
        {
438
          oprot.writeI32(_iter4.getKey().getValue());
439
          _iter4.getValue().write(oprot);
440
        }
441
        oprot.writeMapEnd();
442
      }
668 chandransh 443
      oprot.writeFieldEnd();
444
    }
412 ashish 445
    oprot.writeFieldStop();
446
    oprot.writeStructEnd();
447
  }
448
 
449
  @Override
450
  public String toString() {
451
    StringBuilder sb = new StringBuilder("Provider(");
452
    boolean first = true;
453
 
454
    sb.append("id:");
455
    sb.append(this.id);
456
    first = false;
457
    if (!first) sb.append(", ");
458
    sb.append("name:");
459
    if (this.name == null) {
460
      sb.append("null");
461
    } else {
462
      sb.append(this.name);
463
    }
464
    first = false;
668 chandransh 465
    if (!first) sb.append(", ");
3044 chandransh 466
    sb.append("details:");
467
    if (this.details == null) {
668 chandransh 468
      sb.append("null");
469
    } else {
3044 chandransh 470
      sb.append(this.details);
668 chandransh 471
    }
472
    first = false;
412 ashish 473
    sb.append(")");
474
    return sb.toString();
475
  }
476
 
477
  public void validate() throws TException {
478
    // check for required fields
479
  }
480
 
481
}
482