Subversion Repositories SmartDukaan

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
68 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.order;
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 PaymentInfo implements TBase<PaymentInfo._Fields>, java.io.Serializable, Cloneable {
27
  private static final TStruct STRUCT_DESC = new TStruct("PaymentInfo");
28
 
29
  private static final TField ID_FIELD_DESC = new TField("id", TType.I64, (short)1);
30
  private static final TField PAYMENTS_FIELD_DESC = new TField("payments", TType.MAP, (short)2);
31
 
32
  private long id;
33
  private Map<Long,Payment> payments;
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
    PAYMENTS((short)2, "payments");
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.PAYMENTS, new FieldMetaData("payments", TFieldRequirementType.DEFAULT, 
99
        new MapMetaData(TType.MAP, 
100
            new FieldValueMetaData(TType.I64), 
101
            new StructMetaData(TType.STRUCT, Payment.class))));
102
  }});
103
 
104
  static {
105
    FieldMetaData.addStructMetaDataMap(PaymentInfo.class, metaDataMap);
106
  }
107
 
108
  public PaymentInfo() {
109
  }
110
 
111
  public PaymentInfo(
112
    long id,
113
    Map<Long,Payment> payments)
114
  {
115
    this();
116
    this.id = id;
117
    setIdIsSet(true);
118
    this.payments = payments;
119
  }
120
 
121
  /**
122
   * Performs a deep copy on <i>other</i>.
123
   */
124
  public PaymentInfo(PaymentInfo other) {
125
    __isset_bit_vector.clear();
126
    __isset_bit_vector.or(other.__isset_bit_vector);
127
    this.id = other.id;
128
    if (other.isSetPayments()) {
129
      Map<Long,Payment> __this__payments = new HashMap<Long,Payment>();
130
      for (Map.Entry<Long, Payment> other_element : other.payments.entrySet()) {
131
 
132
        Long other_element_key = other_element.getKey();
133
        Payment other_element_value = other_element.getValue();
134
 
135
        Long __this__payments_copy_key = other_element_key;
136
 
137
        Payment __this__payments_copy_value = new Payment(other_element_value);
138
 
139
        __this__payments.put(__this__payments_copy_key, __this__payments_copy_value);
140
      }
141
      this.payments = __this__payments;
142
    }
143
  }
144
 
145
  public PaymentInfo deepCopy() {
146
    return new PaymentInfo(this);
147
  }
148
 
149
  @Deprecated
150
  public PaymentInfo clone() {
151
    return new PaymentInfo(this);
152
  }
153
 
154
  public long getId() {
155
    return this.id;
156
  }
157
 
158
  public PaymentInfo setId(long id) {
159
    this.id = id;
160
    setIdIsSet(true);
161
    return this;
162
  }
163
 
164
  public void unsetId() {
165
    __isset_bit_vector.clear(__ID_ISSET_ID);
166
  }
167
 
168
  /** Returns true if field id is set (has been asigned a value) and false otherwise */
169
  public boolean isSetId() {
170
    return __isset_bit_vector.get(__ID_ISSET_ID);
171
  }
172
 
173
  public void setIdIsSet(boolean value) {
174
    __isset_bit_vector.set(__ID_ISSET_ID, value);
175
  }
176
 
177
  public int getPaymentsSize() {
178
    return (this.payments == null) ? 0 : this.payments.size();
179
  }
180
 
181
  public void putToPayments(long key, Payment val) {
182
    if (this.payments == null) {
183
      this.payments = new HashMap<Long,Payment>();
184
    }
185
    this.payments.put(key, val);
186
  }
187
 
188
  public Map<Long,Payment> getPayments() {
189
    return this.payments;
190
  }
191
 
192
  public PaymentInfo setPayments(Map<Long,Payment> payments) {
193
    this.payments = payments;
194
    return this;
195
  }
196
 
197
  public void unsetPayments() {
198
    this.payments = null;
199
  }
200
 
201
  /** Returns true if field payments is set (has been asigned a value) and false otherwise */
202
  public boolean isSetPayments() {
203
    return this.payments != null;
204
  }
205
 
206
  public void setPaymentsIsSet(boolean value) {
207
    if (!value) {
208
      this.payments = null;
209
    }
210
  }
211
 
212
  public void setFieldValue(_Fields field, Object value) {
213
    switch (field) {
214
    case ID:
215
      if (value == null) {
216
        unsetId();
217
      } else {
218
        setId((Long)value);
219
      }
220
      break;
221
 
222
    case PAYMENTS:
223
      if (value == null) {
224
        unsetPayments();
225
      } else {
226
        setPayments((Map<Long,Payment>)value);
227
      }
228
      break;
229
 
230
    }
231
  }
232
 
233
  public void setFieldValue(int fieldID, Object value) {
234
    setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value);
235
  }
236
 
237
  public Object getFieldValue(_Fields field) {
238
    switch (field) {
239
    case ID:
240
      return new Long(getId());
241
 
242
    case PAYMENTS:
243
      return getPayments();
244
 
245
    }
246
    throw new IllegalStateException();
247
  }
248
 
249
  public Object getFieldValue(int fieldId) {
250
    return getFieldValue(_Fields.findByThriftIdOrThrow(fieldId));
251
  }
252
 
253
  /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
254
  public boolean isSet(_Fields field) {
255
    switch (field) {
256
    case ID:
257
      return isSetId();
258
    case PAYMENTS:
259
      return isSetPayments();
260
    }
261
    throw new IllegalStateException();
262
  }
263
 
264
  public boolean isSet(int fieldID) {
265
    return isSet(_Fields.findByThriftIdOrThrow(fieldID));
266
  }
267
 
268
  @Override
269
  public boolean equals(Object that) {
270
    if (that == null)
271
      return false;
272
    if (that instanceof PaymentInfo)
273
      return this.equals((PaymentInfo)that);
274
    return false;
275
  }
276
 
277
  public boolean equals(PaymentInfo that) {
278
    if (that == null)
279
      return false;
280
 
281
    boolean this_present_id = true;
282
    boolean that_present_id = true;
283
    if (this_present_id || that_present_id) {
284
      if (!(this_present_id && that_present_id))
285
        return false;
286
      if (this.id != that.id)
287
        return false;
288
    }
289
 
290
    boolean this_present_payments = true && this.isSetPayments();
291
    boolean that_present_payments = true && that.isSetPayments();
292
    if (this_present_payments || that_present_payments) {
293
      if (!(this_present_payments && that_present_payments))
294
        return false;
295
      if (!this.payments.equals(that.payments))
296
        return false;
297
    }
298
 
299
    return true;
300
  }
301
 
302
  @Override
303
  public int hashCode() {
304
    return 0;
305
  }
306
 
307
  public void read(TProtocol iprot) throws TException {
308
    TField field;
309
    iprot.readStructBegin();
310
    while (true)
311
    {
312
      field = iprot.readFieldBegin();
313
      if (field.type == TType.STOP) { 
314
        break;
315
      }
316
      _Fields fieldId = _Fields.findByThriftId(field.id);
317
      if (fieldId == null) {
318
        TProtocolUtil.skip(iprot, field.type);
319
      } else {
320
        switch (fieldId) {
321
          case ID:
322
            if (field.type == TType.I64) {
323
              this.id = iprot.readI64();
324
              setIdIsSet(true);
325
            } else { 
326
              TProtocolUtil.skip(iprot, field.type);
327
            }
328
            break;
329
          case PAYMENTS:
330
            if (field.type == TType.MAP) {
331
              {
483 rajveer 332
                TMap _map0 = iprot.readMapBegin();
333
                this.payments = new HashMap<Long,Payment>(2*_map0.size);
334
                for (int _i1 = 0; _i1 < _map0.size; ++_i1)
68 ashish 335
                {
483 rajveer 336
                  long _key2;
337
                  Payment _val3;
338
                  _key2 = iprot.readI64();
339
                  _val3 = new Payment();
340
                  _val3.read(iprot);
341
                  this.payments.put(_key2, _val3);
68 ashish 342
                }
343
                iprot.readMapEnd();
344
              }
345
            } else { 
346
              TProtocolUtil.skip(iprot, field.type);
347
            }
348
            break;
349
        }
350
        iprot.readFieldEnd();
351
      }
352
    }
353
    iprot.readStructEnd();
354
    validate();
355
  }
356
 
357
  public void write(TProtocol oprot) throws TException {
358
    validate();
359
 
360
    oprot.writeStructBegin(STRUCT_DESC);
361
    oprot.writeFieldBegin(ID_FIELD_DESC);
362
    oprot.writeI64(this.id);
363
    oprot.writeFieldEnd();
364
    if (this.payments != null) {
365
      oprot.writeFieldBegin(PAYMENTS_FIELD_DESC);
366
      {
367
        oprot.writeMapBegin(new TMap(TType.I64, TType.STRUCT, this.payments.size()));
483 rajveer 368
        for (Map.Entry<Long, Payment> _iter4 : this.payments.entrySet())
68 ashish 369
        {
483 rajveer 370
          oprot.writeI64(_iter4.getKey());
371
          _iter4.getValue().write(oprot);
68 ashish 372
        }
373
        oprot.writeMapEnd();
374
      }
375
      oprot.writeFieldEnd();
376
    }
377
    oprot.writeFieldStop();
378
    oprot.writeStructEnd();
379
  }
380
 
381
  @Override
382
  public String toString() {
383
    StringBuilder sb = new StringBuilder("PaymentInfo(");
384
    boolean first = true;
385
 
386
    sb.append("id:");
387
    sb.append(this.id);
388
    first = false;
389
    if (!first) sb.append(", ");
390
    sb.append("payments:");
391
    if (this.payments == null) {
392
      sb.append("null");
393
    } else {
394
      sb.append(this.payments);
395
    }
396
    first = false;
397
    sb.append(")");
398
    return sb.toString();
399
  }
400
 
401
  public void validate() throws TException {
402
    // check for required fields
403
  }
404
 
405
}
406