View Javadoc

1   /**
2    * Autogenerated by Thrift Compiler (0.8.0)
3    *
4    * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
5    *  @generated
6    */
7   package org.apache.hadoop.hbase.thrift2.generated;
8   
9   import org.apache.commons.lang.builder.HashCodeBuilder;
10  import org.apache.thrift.scheme.IScheme;
11  import org.apache.thrift.scheme.SchemeFactory;
12  import org.apache.thrift.scheme.StandardScheme;
13  
14  import org.apache.thrift.scheme.TupleScheme;
15  import org.apache.thrift.protocol.TTupleProtocol;
16  import java.util.List;
17  import java.util.ArrayList;
18  import java.util.Map;
19  import java.util.HashMap;
20  import java.util.EnumMap;
21  import java.util.Set;
22  import java.util.HashSet;
23  import java.util.EnumSet;
24  import java.util.Collections;
25  import java.util.BitSet;
26  import java.nio.ByteBuffer;
27  import java.util.Arrays;
28  import org.slf4j.Logger;
29  import org.slf4j.LoggerFactory;
30  
31  public class TTimeRange implements org.apache.thrift.TBase<TTimeRange, TTimeRange._Fields>, java.io.Serializable, Cloneable {
32    private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TTimeRange");
33  
34    private static final org.apache.thrift.protocol.TField MIN_STAMP_FIELD_DESC = new org.apache.thrift.protocol.TField("minStamp", org.apache.thrift.protocol.TType.I64, (short)1);
35    private static final org.apache.thrift.protocol.TField MAX_STAMP_FIELD_DESC = new org.apache.thrift.protocol.TField("maxStamp", org.apache.thrift.protocol.TType.I64, (short)2);
36  
37    private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
38    static {
39      schemes.put(StandardScheme.class, new TTimeRangeStandardSchemeFactory());
40      schemes.put(TupleScheme.class, new TTimeRangeTupleSchemeFactory());
41    }
42  
43    public long minStamp; // required
44    public long maxStamp; // required
45  
46    /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
47    public enum _Fields implements org.apache.thrift.TFieldIdEnum {
48      MIN_STAMP((short)1, "minStamp"),
49      MAX_STAMP((short)2, "maxStamp");
50  
51      private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
52  
53      static {
54        for (_Fields field : EnumSet.allOf(_Fields.class)) {
55          byName.put(field.getFieldName(), field);
56        }
57      }
58  
59      /**
60       * Find the _Fields constant that matches fieldId, or null if its not found.
61       */
62      public static _Fields findByThriftId(int fieldId) {
63        switch(fieldId) {
64          case 1: // MIN_STAMP
65            return MIN_STAMP;
66          case 2: // MAX_STAMP
67            return MAX_STAMP;
68          default:
69            return null;
70        }
71      }
72  
73      /**
74       * Find the _Fields constant that matches fieldId, throwing an exception
75       * if it is not found.
76       */
77      public static _Fields findByThriftIdOrThrow(int fieldId) {
78        _Fields fields = findByThriftId(fieldId);
79        if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
80        return fields;
81      }
82  
83      /**
84       * Find the _Fields constant that matches name, or null if its not found.
85       */
86      public static _Fields findByName(String name) {
87        return byName.get(name);
88      }
89  
90      private final short _thriftId;
91      private final String _fieldName;
92  
93      _Fields(short thriftId, String fieldName) {
94        _thriftId = thriftId;
95        _fieldName = fieldName;
96      }
97  
98      public short getThriftFieldId() {
99        return _thriftId;
100     }
101 
102     public String getFieldName() {
103       return _fieldName;
104     }
105   }
106 
107   // isset id assignments
108   private static final int __MINSTAMP_ISSET_ID = 0;
109   private static final int __MAXSTAMP_ISSET_ID = 1;
110   private BitSet __isset_bit_vector = new BitSet(2);
111   public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
112   static {
113     Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
114     tmpMap.put(_Fields.MIN_STAMP, new org.apache.thrift.meta_data.FieldMetaData("minStamp", org.apache.thrift.TFieldRequirementType.REQUIRED, 
115         new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)));
116     tmpMap.put(_Fields.MAX_STAMP, new org.apache.thrift.meta_data.FieldMetaData("maxStamp", org.apache.thrift.TFieldRequirementType.REQUIRED, 
117         new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)));
118     metaDataMap = Collections.unmodifiableMap(tmpMap);
119     org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TTimeRange.class, metaDataMap);
120   }
121 
122   public TTimeRange() {
123   }
124 
125   public TTimeRange(
126     long minStamp,
127     long maxStamp)
128   {
129     this();
130     this.minStamp = minStamp;
131     setMinStampIsSet(true);
132     this.maxStamp = maxStamp;
133     setMaxStampIsSet(true);
134   }
135 
136   /**
137    * Performs a deep copy on <i>other</i>.
138    */
139   public TTimeRange(TTimeRange other) {
140     __isset_bit_vector.clear();
141     __isset_bit_vector.or(other.__isset_bit_vector);
142     this.minStamp = other.minStamp;
143     this.maxStamp = other.maxStamp;
144   }
145 
146   public TTimeRange deepCopy() {
147     return new TTimeRange(this);
148   }
149 
150   @Override
151   public void clear() {
152     setMinStampIsSet(false);
153     this.minStamp = 0;
154     setMaxStampIsSet(false);
155     this.maxStamp = 0;
156   }
157 
158   public long getMinStamp() {
159     return this.minStamp;
160   }
161 
162   public TTimeRange setMinStamp(long minStamp) {
163     this.minStamp = minStamp;
164     setMinStampIsSet(true);
165     return this;
166   }
167 
168   public void unsetMinStamp() {
169     __isset_bit_vector.clear(__MINSTAMP_ISSET_ID);
170   }
171 
172   /** Returns true if field minStamp is set (has been assigned a value) and false otherwise */
173   public boolean isSetMinStamp() {
174     return __isset_bit_vector.get(__MINSTAMP_ISSET_ID);
175   }
176 
177   public void setMinStampIsSet(boolean value) {
178     __isset_bit_vector.set(__MINSTAMP_ISSET_ID, value);
179   }
180 
181   public long getMaxStamp() {
182     return this.maxStamp;
183   }
184 
185   public TTimeRange setMaxStamp(long maxStamp) {
186     this.maxStamp = maxStamp;
187     setMaxStampIsSet(true);
188     return this;
189   }
190 
191   public void unsetMaxStamp() {
192     __isset_bit_vector.clear(__MAXSTAMP_ISSET_ID);
193   }
194 
195   /** Returns true if field maxStamp is set (has been assigned a value) and false otherwise */
196   public boolean isSetMaxStamp() {
197     return __isset_bit_vector.get(__MAXSTAMP_ISSET_ID);
198   }
199 
200   public void setMaxStampIsSet(boolean value) {
201     __isset_bit_vector.set(__MAXSTAMP_ISSET_ID, value);
202   }
203 
204   public void setFieldValue(_Fields field, Object value) {
205     switch (field) {
206     case MIN_STAMP:
207       if (value == null) {
208         unsetMinStamp();
209       } else {
210         setMinStamp((Long)value);
211       }
212       break;
213 
214     case MAX_STAMP:
215       if (value == null) {
216         unsetMaxStamp();
217       } else {
218         setMaxStamp((Long)value);
219       }
220       break;
221 
222     }
223   }
224 
225   public Object getFieldValue(_Fields field) {
226     switch (field) {
227     case MIN_STAMP:
228       return Long.valueOf(getMinStamp());
229 
230     case MAX_STAMP:
231       return Long.valueOf(getMaxStamp());
232 
233     }
234     throw new IllegalStateException();
235   }
236 
237   /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
238   public boolean isSet(_Fields field) {
239     if (field == null) {
240       throw new IllegalArgumentException();
241     }
242 
243     switch (field) {
244     case MIN_STAMP:
245       return isSetMinStamp();
246     case MAX_STAMP:
247       return isSetMaxStamp();
248     }
249     throw new IllegalStateException();
250   }
251 
252   @Override
253   public boolean equals(Object that) {
254     if (that == null)
255       return false;
256     if (that instanceof TTimeRange)
257       return this.equals((TTimeRange)that);
258     return false;
259   }
260 
261   public boolean equals(TTimeRange that) {
262     if (that == null)
263       return false;
264 
265     boolean this_present_minStamp = true;
266     boolean that_present_minStamp = true;
267     if (this_present_minStamp || that_present_minStamp) {
268       if (!(this_present_minStamp && that_present_minStamp))
269         return false;
270       if (this.minStamp != that.minStamp)
271         return false;
272     }
273 
274     boolean this_present_maxStamp = true;
275     boolean that_present_maxStamp = true;
276     if (this_present_maxStamp || that_present_maxStamp) {
277       if (!(this_present_maxStamp && that_present_maxStamp))
278         return false;
279       if (this.maxStamp != that.maxStamp)
280         return false;
281     }
282 
283     return true;
284   }
285 
286   @Override
287   public int hashCode() {
288     HashCodeBuilder builder = new HashCodeBuilder();
289 
290     boolean present_minStamp = true;
291     builder.append(present_minStamp);
292     if (present_minStamp)
293       builder.append(minStamp);
294 
295     boolean present_maxStamp = true;
296     builder.append(present_maxStamp);
297     if (present_maxStamp)
298       builder.append(maxStamp);
299 
300     return builder.toHashCode();
301   }
302 
303   public int compareTo(TTimeRange other) {
304     if (!getClass().equals(other.getClass())) {
305       return getClass().getName().compareTo(other.getClass().getName());
306     }
307 
308     int lastComparison = 0;
309     TTimeRange typedOther = (TTimeRange)other;
310 
311     lastComparison = Boolean.valueOf(isSetMinStamp()).compareTo(typedOther.isSetMinStamp());
312     if (lastComparison != 0) {
313       return lastComparison;
314     }
315     if (isSetMinStamp()) {
316       lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.minStamp, typedOther.minStamp);
317       if (lastComparison != 0) {
318         return lastComparison;
319       }
320     }
321     lastComparison = Boolean.valueOf(isSetMaxStamp()).compareTo(typedOther.isSetMaxStamp());
322     if (lastComparison != 0) {
323       return lastComparison;
324     }
325     if (isSetMaxStamp()) {
326       lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.maxStamp, typedOther.maxStamp);
327       if (lastComparison != 0) {
328         return lastComparison;
329       }
330     }
331     return 0;
332   }
333 
334   public _Fields fieldForId(int fieldId) {
335     return _Fields.findByThriftId(fieldId);
336   }
337 
338   public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
339     schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
340   }
341 
342   public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
343     schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
344   }
345 
346   @Override
347   public String toString() {
348     StringBuilder sb = new StringBuilder("TTimeRange(");
349     boolean first = true;
350 
351     sb.append("minStamp:");
352     sb.append(this.minStamp);
353     first = false;
354     if (!first) sb.append(", ");
355     sb.append("maxStamp:");
356     sb.append(this.maxStamp);
357     first = false;
358     sb.append(")");
359     return sb.toString();
360   }
361 
362   public void validate() throws org.apache.thrift.TException {
363     // check for required fields
364     // alas, we cannot check 'minStamp' because it's a primitive and you chose the non-beans generator.
365     // alas, we cannot check 'maxStamp' because it's a primitive and you chose the non-beans generator.
366   }
367 
368   private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
369     try {
370       write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
371     } catch (org.apache.thrift.TException te) {
372       throw new java.io.IOException(te);
373     }
374   }
375 
376   private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
377     try {
378       // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor.
379       __isset_bit_vector = new BitSet(1);
380       read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
381     } catch (org.apache.thrift.TException te) {
382       throw new java.io.IOException(te);
383     }
384   }
385 
386   private static class TTimeRangeStandardSchemeFactory implements SchemeFactory {
387     public TTimeRangeStandardScheme getScheme() {
388       return new TTimeRangeStandardScheme();
389     }
390   }
391 
392   private static class TTimeRangeStandardScheme extends StandardScheme<TTimeRange> {
393 
394     public void read(org.apache.thrift.protocol.TProtocol iprot, TTimeRange struct) throws org.apache.thrift.TException {
395       org.apache.thrift.protocol.TField schemeField;
396       iprot.readStructBegin();
397       while (true)
398       {
399         schemeField = iprot.readFieldBegin();
400         if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { 
401           break;
402         }
403         switch (schemeField.id) {
404           case 1: // MIN_STAMP
405             if (schemeField.type == org.apache.thrift.protocol.TType.I64) {
406               struct.minStamp = iprot.readI64();
407               struct.setMinStampIsSet(true);
408             } else { 
409               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
410             }
411             break;
412           case 2: // MAX_STAMP
413             if (schemeField.type == org.apache.thrift.protocol.TType.I64) {
414               struct.maxStamp = iprot.readI64();
415               struct.setMaxStampIsSet(true);
416             } else { 
417               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
418             }
419             break;
420           default:
421             org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
422         }
423         iprot.readFieldEnd();
424       }
425       iprot.readStructEnd();
426 
427       // check for required fields of primitive type, which can't be checked in the validate method
428       if (!struct.isSetMinStamp()) {
429         throw new org.apache.thrift.protocol.TProtocolException("Required field 'minStamp' was not found in serialized data! Struct: " + toString());
430       }
431       if (!struct.isSetMaxStamp()) {
432         throw new org.apache.thrift.protocol.TProtocolException("Required field 'maxStamp' was not found in serialized data! Struct: " + toString());
433       }
434       struct.validate();
435     }
436 
437     public void write(org.apache.thrift.protocol.TProtocol oprot, TTimeRange struct) throws org.apache.thrift.TException {
438       struct.validate();
439 
440       oprot.writeStructBegin(STRUCT_DESC);
441       oprot.writeFieldBegin(MIN_STAMP_FIELD_DESC);
442       oprot.writeI64(struct.minStamp);
443       oprot.writeFieldEnd();
444       oprot.writeFieldBegin(MAX_STAMP_FIELD_DESC);
445       oprot.writeI64(struct.maxStamp);
446       oprot.writeFieldEnd();
447       oprot.writeFieldStop();
448       oprot.writeStructEnd();
449     }
450 
451   }
452 
453   private static class TTimeRangeTupleSchemeFactory implements SchemeFactory {
454     public TTimeRangeTupleScheme getScheme() {
455       return new TTimeRangeTupleScheme();
456     }
457   }
458 
459   private static class TTimeRangeTupleScheme extends TupleScheme<TTimeRange> {
460 
461     @Override
462     public void write(org.apache.thrift.protocol.TProtocol prot, TTimeRange struct) throws org.apache.thrift.TException {
463       TTupleProtocol oprot = (TTupleProtocol) prot;
464       oprot.writeI64(struct.minStamp);
465       oprot.writeI64(struct.maxStamp);
466     }
467 
468     @Override
469     public void read(org.apache.thrift.protocol.TProtocol prot, TTimeRange struct) throws org.apache.thrift.TException {
470       TTupleProtocol iprot = (TTupleProtocol) prot;
471       struct.minStamp = iprot.readI64();
472       struct.setMinStampIsSet(true);
473       struct.maxStamp = iprot.readI64();
474       struct.setMaxStampIsSet(true);
475     }
476   }
477 
478 }
479