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