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