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