View Javadoc

1   /**
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *     http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  package org.apache.hadoop.hbase.thrift.generated;
19  
20  import org.apache.commons.lang.builder.HashCodeBuilder;
21  import java.util.List;
22  import java.util.ArrayList;
23  import java.util.Map;
24  import java.util.HashMap;
25  import java.util.EnumMap;
26  import java.util.Set;
27  import java.util.HashSet;
28  import java.util.EnumSet;
29  import java.util.Collections;
30  import java.util.BitSet;
31  import java.util.Arrays;
32  import org.slf4j.Logger;
33  import org.slf4j.LoggerFactory;
34  
35  import org.apache.thrift.*;
36  import org.apache.thrift.meta_data.*;
37  import org.apache.thrift.protocol.*;
38  
39  /**
40   * An IllegalArgument exception indicates an illegal or invalid
41   * argument was passed into a procedure.
42   */
43  public class IllegalArgument extends Exception implements TBase<IllegalArgument._Fields>, java.io.Serializable, Cloneable, Comparable<IllegalArgument> {
44    private static final TStruct STRUCT_DESC = new TStruct("IllegalArgument");
45  
46    private static final TField MESSAGE_FIELD_DESC = new TField("message", TType.STRING, (short)1);
47  
48    public String message;
49  
50    /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
51    public enum _Fields implements TFieldIdEnum {
52      MESSAGE((short)1, "message");
53  
54      private static final Map<Integer, _Fields> byId = new HashMap<Integer, _Fields>();
55      private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
56  
57      static {
58        for (_Fields field : EnumSet.allOf(_Fields.class)) {
59          byId.put((int)field._thriftId, field);
60          byName.put(field.getFieldName(), field);
61        }
62      }
63  
64      /**
65       * Find the _Fields constant that matches fieldId, or null if its not found.
66       */
67      public static _Fields findByThriftId(int fieldId) {
68        return byId.get(fieldId);
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 
107   public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
108     put(_Fields.MESSAGE, new FieldMetaData("message", TFieldRequirementType.DEFAULT,
109         new FieldValueMetaData(TType.STRING)));
110   }});
111 
112   static {
113     FieldMetaData.addStructMetaDataMap(IllegalArgument.class, metaDataMap);
114   }
115 
116   public IllegalArgument() {
117   }
118 
119   public IllegalArgument(
120     String message)
121   {
122     this();
123     this.message = message;
124   }
125 
126   /**
127    * Performs a deep copy on <i>other</i>.
128    */
129   public IllegalArgument(IllegalArgument other) {
130     if (other.isSetMessage()) {
131       this.message = other.message;
132     }
133   }
134 
135   public IllegalArgument deepCopy() {
136     return new IllegalArgument(this);
137   }
138 
139   @Deprecated
140   public IllegalArgument clone() {
141     return new IllegalArgument(this);
142   }
143 
144   public String getMessage() {
145     return this.message;
146   }
147 
148   public IllegalArgument setMessage(String message) {
149     this.message = message;
150     return this;
151   }
152 
153   public void unsetMessage() {
154     this.message = null;
155   }
156 
157   /** Returns true if field message is set (has been asigned a value) and false otherwise */
158   public boolean isSetMessage() {
159     return this.message != null;
160   }
161 
162   public void setMessageIsSet(boolean value) {
163     if (!value) {
164       this.message = null;
165     }
166   }
167 
168   public void setFieldValue(_Fields field, Object value) {
169     switch (field) {
170     case MESSAGE:
171       if (value == null) {
172         unsetMessage();
173       } else {
174         setMessage((String)value);
175       }
176       break;
177 
178     }
179   }
180 
181   public void setFieldValue(int fieldID, Object value) {
182     setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value);
183   }
184 
185   public Object getFieldValue(_Fields field) {
186     switch (field) {
187     case MESSAGE:
188       return getMessage();
189 
190     }
191     throw new IllegalStateException();
192   }
193 
194   public Object getFieldValue(int fieldId) {
195     return getFieldValue(_Fields.findByThriftIdOrThrow(fieldId));
196   }
197 
198   /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
199   public boolean isSet(_Fields field) {
200     switch (field) {
201     case MESSAGE:
202       return isSetMessage();
203     }
204     throw new IllegalStateException();
205   }
206 
207   public boolean isSet(int fieldID) {
208     return isSet(_Fields.findByThriftIdOrThrow(fieldID));
209   }
210 
211   @Override
212   public boolean equals(Object that) {
213     if (that == null)
214       return false;
215     if (that instanceof IllegalArgument)
216       return this.equals((IllegalArgument)that);
217     return false;
218   }
219 
220   public boolean equals(IllegalArgument that) {
221     if (that == null)
222       return false;
223 
224     boolean this_present_message = true && this.isSetMessage();
225     boolean that_present_message = true && that.isSetMessage();
226     if (this_present_message || that_present_message) {
227       if (!(this_present_message && that_present_message))
228         return false;
229       if (!this.message.equals(that.message))
230         return false;
231     }
232 
233     return true;
234   }
235 
236   @Override
237   public int hashCode() {
238     HashCodeBuilder builder = new HashCodeBuilder();
239 
240     boolean present_message = true && (isSetMessage());
241     builder.append(present_message);
242     if (present_message)
243       builder.append(message);
244 
245     return builder.toHashCode();
246   }
247 
248   public int compareTo(IllegalArgument other) {
249     if (!getClass().equals(other.getClass())) {
250       return getClass().getName().compareTo(other.getClass().getName());
251     }
252 
253     int lastComparison = 0;
254     IllegalArgument typedOther = (IllegalArgument)other;
255 
256     lastComparison = Boolean.valueOf(isSetMessage()).compareTo(isSetMessage());
257     if (lastComparison != 0) {
258       return lastComparison;
259     }
260     lastComparison = TBaseHelper.compareTo(message, typedOther.message);
261     if (lastComparison != 0) {
262       return lastComparison;
263     }
264     return 0;
265   }
266 
267   public void read(TProtocol iprot) throws TException {
268     TField field;
269     iprot.readStructBegin();
270     while (true)
271     {
272       field = iprot.readFieldBegin();
273       if (field.type == TType.STOP) {
274         break;
275       }
276       _Fields fieldId = _Fields.findByThriftId(field.id);
277       if (fieldId == null) {
278         TProtocolUtil.skip(iprot, field.type);
279       } else {
280         switch (fieldId) {
281           case MESSAGE:
282             if (field.type == TType.STRING) {
283               this.message = iprot.readString();
284             } else {
285               TProtocolUtil.skip(iprot, field.type);
286             }
287             break;
288         }
289         iprot.readFieldEnd();
290       }
291     }
292     iprot.readStructEnd();
293 
294     // check for required fields of primitive type, which can't be checked in the validate method
295     validate();
296   }
297 
298   public void write(TProtocol oprot) throws TException {
299     validate();
300 
301     oprot.writeStructBegin(STRUCT_DESC);
302     if (this.message != null) {
303       oprot.writeFieldBegin(MESSAGE_FIELD_DESC);
304       oprot.writeString(this.message);
305       oprot.writeFieldEnd();
306     }
307     oprot.writeFieldStop();
308     oprot.writeStructEnd();
309   }
310 
311   @Override
312   public String toString() {
313     StringBuilder sb = new StringBuilder("IllegalArgument(");
314     boolean first = true;
315 
316     sb.append("message:");
317     if (this.message == null) {
318       sb.append("null");
319     } else {
320       sb.append(this.message);
321     }
322     first = false;
323     sb.append(")");
324     return sb.toString();
325   }
326 
327   public void validate() throws TException {
328     // check for required fields
329   }
330 
331 }
332