View Javadoc

1   /**
2    * Autogenerated by Thrift Compiler (0.9.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.thrift.scheme.IScheme;
10  import org.apache.thrift.scheme.SchemeFactory;
11  import org.apache.thrift.scheme.StandardScheme;
12  
13  import org.apache.thrift.scheme.TupleScheme;
14  import org.apache.thrift.protocol.TTupleProtocol;
15  import org.apache.thrift.protocol.TProtocolException;
16  import org.apache.thrift.EncodingUtils;
17  import org.apache.thrift.TException;
18  import java.util.List;
19  import java.util.ArrayList;
20  import java.util.Map;
21  import java.util.HashMap;
22  import java.util.EnumMap;
23  import java.util.Set;
24  import java.util.HashSet;
25  import java.util.EnumSet;
26  import java.util.Collections;
27  import java.util.BitSet;
28  import java.nio.ByteBuffer;
29  import java.util.Arrays;
30  import org.slf4j.Logger;
31  import org.slf4j.LoggerFactory;
32  
33  /**
34   * A TIllegalArgument exception indicates an illegal or invalid
35   * argument was passed into a procedure.
36   */
37  public class TIllegalArgument extends TException implements org.apache.thrift.TBase<TIllegalArgument, TIllegalArgument._Fields>, java.io.Serializable, Cloneable {
38    private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TIllegalArgument");
39  
40    private static final org.apache.thrift.protocol.TField MESSAGE_FIELD_DESC = new org.apache.thrift.protocol.TField("message", org.apache.thrift.protocol.TType.STRING, (short)1);
41  
42    private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
43    static {
44      schemes.put(StandardScheme.class, new TIllegalArgumentStandardSchemeFactory());
45      schemes.put(TupleScheme.class, new TIllegalArgumentTupleSchemeFactory());
46    }
47  
48    public String message; // optional
49  
50    /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
51    public enum _Fields implements org.apache.thrift.TFieldIdEnum {
52      MESSAGE((short)1, "message");
53  
54      private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
55  
56      static {
57        for (_Fields field : EnumSet.allOf(_Fields.class)) {
58          byName.put(field.getFieldName(), field);
59        }
60      }
61  
62      /**
63       * Find the _Fields constant that matches fieldId, or null if its not found.
64       */
65      public static _Fields findByThriftId(int fieldId) {
66        switch(fieldId) {
67          case 1: // MESSAGE
68            return MESSAGE;
69          default:
70            return null;
71        }
72      }
73  
74      /**
75       * Find the _Fields constant that matches fieldId, throwing an exception
76       * if it is not found.
77       */
78      public static _Fields findByThriftIdOrThrow(int fieldId) {
79        _Fields fields = findByThriftId(fieldId);
80        if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
81        return fields;
82      }
83  
84      /**
85       * Find the _Fields constant that matches name, or null if its not found.
86       */
87      public static _Fields findByName(String name) {
88        return byName.get(name);
89      }
90  
91      private final short _thriftId;
92      private final String _fieldName;
93  
94      _Fields(short thriftId, String fieldName) {
95        _thriftId = thriftId;
96        _fieldName = fieldName;
97      }
98  
99      public short getThriftFieldId() {
100       return _thriftId;
101     }
102 
103     public String getFieldName() {
104       return _fieldName;
105     }
106   }
107 
108   // isset id assignments
109   private _Fields optionals[] = {_Fields.MESSAGE};
110   public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
111   static {
112     Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
113     tmpMap.put(_Fields.MESSAGE, new org.apache.thrift.meta_data.FieldMetaData("message", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
114         new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
115     metaDataMap = Collections.unmodifiableMap(tmpMap);
116     org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TIllegalArgument.class, metaDataMap);
117   }
118 
119   public TIllegalArgument() {
120   }
121 
122   /**
123    * Performs a deep copy on <i>other</i>.
124    */
125   public TIllegalArgument(TIllegalArgument other) {
126     if (other.isSetMessage()) {
127       this.message = other.message;
128     }
129   }
130 
131   public TIllegalArgument deepCopy() {
132     return new TIllegalArgument(this);
133   }
134 
135   @Override
136   public void clear() {
137     this.message = null;
138   }
139 
140   public String getMessage() {
141     return this.message;
142   }
143 
144   public TIllegalArgument setMessage(String message) {
145     this.message = message;
146     return this;
147   }
148 
149   public void unsetMessage() {
150     this.message = null;
151   }
152 
153   /** Returns true if field message is set (has been assigned a value) and false otherwise */
154   public boolean isSetMessage() {
155     return this.message != null;
156   }
157 
158   public void setMessageIsSet(boolean value) {
159     if (!value) {
160       this.message = null;
161     }
162   }
163 
164   public void setFieldValue(_Fields field, Object value) {
165     switch (field) {
166     case MESSAGE:
167       if (value == null) {
168         unsetMessage();
169       } else {
170         setMessage((String)value);
171       }
172       break;
173 
174     }
175   }
176 
177   public Object getFieldValue(_Fields field) {
178     switch (field) {
179     case MESSAGE:
180       return getMessage();
181 
182     }
183     throw new IllegalStateException();
184   }
185 
186   /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
187   public boolean isSet(_Fields field) {
188     if (field == null) {
189       throw new IllegalArgumentException();
190     }
191 
192     switch (field) {
193     case MESSAGE:
194       return isSetMessage();
195     }
196     throw new IllegalStateException();
197   }
198 
199   @Override
200   public boolean equals(Object that) {
201     if (that == null)
202       return false;
203     if (that instanceof TIllegalArgument)
204       return this.equals((TIllegalArgument)that);
205     return false;
206   }
207 
208   public boolean equals(TIllegalArgument that) {
209     if (that == null)
210       return false;
211 
212     boolean this_present_message = true && this.isSetMessage();
213     boolean that_present_message = true && that.isSetMessage();
214     if (this_present_message || that_present_message) {
215       if (!(this_present_message && that_present_message))
216         return false;
217       if (!this.message.equals(that.message))
218         return false;
219     }
220 
221     return true;
222   }
223 
224   @Override
225   public int hashCode() {
226     return 0;
227   }
228 
229   public int compareTo(TIllegalArgument other) {
230     if (!getClass().equals(other.getClass())) {
231       return getClass().getName().compareTo(other.getClass().getName());
232     }
233 
234     int lastComparison = 0;
235     TIllegalArgument typedOther = (TIllegalArgument)other;
236 
237     lastComparison = Boolean.valueOf(isSetMessage()).compareTo(typedOther.isSetMessage());
238     if (lastComparison != 0) {
239       return lastComparison;
240     }
241     if (isSetMessage()) {
242       lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.message, typedOther.message);
243       if (lastComparison != 0) {
244         return lastComparison;
245       }
246     }
247     return 0;
248   }
249 
250   public _Fields fieldForId(int fieldId) {
251     return _Fields.findByThriftId(fieldId);
252   }
253 
254   public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
255     schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
256   }
257 
258   public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
259     schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
260   }
261 
262   @Override
263   public String toString() {
264     StringBuilder sb = new StringBuilder("TIllegalArgument(");
265     boolean first = true;
266 
267     if (isSetMessage()) {
268       sb.append("message:");
269       if (this.message == null) {
270         sb.append("null");
271       } else {
272         sb.append(this.message);
273       }
274       first = false;
275     }
276     sb.append(")");
277     return sb.toString();
278   }
279 
280   public void validate() throws org.apache.thrift.TException {
281     // check for required fields
282     // check for sub-struct validity
283   }
284 
285   private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
286     try {
287       write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
288     } catch (org.apache.thrift.TException te) {
289       throw new java.io.IOException(te);
290     }
291   }
292 
293   private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
294     try {
295       read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
296     } catch (org.apache.thrift.TException te) {
297       throw new java.io.IOException(te);
298     }
299   }
300 
301   private static class TIllegalArgumentStandardSchemeFactory implements SchemeFactory {
302     public TIllegalArgumentStandardScheme getScheme() {
303       return new TIllegalArgumentStandardScheme();
304     }
305   }
306 
307   private static class TIllegalArgumentStandardScheme extends StandardScheme<TIllegalArgument> {
308 
309     public void read(org.apache.thrift.protocol.TProtocol iprot, TIllegalArgument struct) throws org.apache.thrift.TException {
310       org.apache.thrift.protocol.TField schemeField;
311       iprot.readStructBegin();
312       while (true)
313       {
314         schemeField = iprot.readFieldBegin();
315         if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { 
316           break;
317         }
318         switch (schemeField.id) {
319           case 1: // MESSAGE
320             if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
321               struct.message = iprot.readString();
322               struct.setMessageIsSet(true);
323             } else { 
324               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
325             }
326             break;
327           default:
328             org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
329         }
330         iprot.readFieldEnd();
331       }
332       iprot.readStructEnd();
333 
334       // check for required fields of primitive type, which can't be checked in the validate method
335       struct.validate();
336     }
337 
338     public void write(org.apache.thrift.protocol.TProtocol oprot, TIllegalArgument struct) throws org.apache.thrift.TException {
339       struct.validate();
340 
341       oprot.writeStructBegin(STRUCT_DESC);
342       if (struct.message != null) {
343         if (struct.isSetMessage()) {
344           oprot.writeFieldBegin(MESSAGE_FIELD_DESC);
345           oprot.writeString(struct.message);
346           oprot.writeFieldEnd();
347         }
348       }
349       oprot.writeFieldStop();
350       oprot.writeStructEnd();
351     }
352 
353   }
354 
355   private static class TIllegalArgumentTupleSchemeFactory implements SchemeFactory {
356     public TIllegalArgumentTupleScheme getScheme() {
357       return new TIllegalArgumentTupleScheme();
358     }
359   }
360 
361   private static class TIllegalArgumentTupleScheme extends TupleScheme<TIllegalArgument> {
362 
363     @Override
364     public void write(org.apache.thrift.protocol.TProtocol prot, TIllegalArgument struct) throws org.apache.thrift.TException {
365       TTupleProtocol oprot = (TTupleProtocol) prot;
366       BitSet optionals = new BitSet();
367       if (struct.isSetMessage()) {
368         optionals.set(0);
369       }
370       oprot.writeBitSet(optionals, 1);
371       if (struct.isSetMessage()) {
372         oprot.writeString(struct.message);
373       }
374     }
375 
376     @Override
377     public void read(org.apache.thrift.protocol.TProtocol prot, TIllegalArgument struct) throws org.apache.thrift.TException {
378       TTupleProtocol iprot = (TTupleProtocol) prot;
379       BitSet incoming = iprot.readBitSet(1);
380       if (incoming.get(0)) {
381         struct.message = iprot.readString();
382         struct.setMessageIsSet(true);
383       }
384     }
385   }
386 
387 }
388