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 org.apache.thrift.*;
22  import org.apache.thrift.meta_data.FieldMetaData;
23  import org.apache.thrift.meta_data.FieldValueMetaData;
24  import org.apache.thrift.protocol.*;
25  
26  import java.util.*;
27  
28  /**
29   * An AlreadyExists exceptions signals that a table with the specified
30   * name already exists
31   */
32  public class AlreadyExists extends Exception implements TBase<AlreadyExists._Fields>, java.io.Serializable, Cloneable, Comparable<AlreadyExists> {
33    private static final TStruct STRUCT_DESC = new TStruct("AlreadyExists");
34  
35    private static final TField MESSAGE_FIELD_DESC = new TField("message", TType.STRING, (short)1);
36  
37    public String message;
38  
39    /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
40    public enum _Fields implements TFieldIdEnum {
41      MESSAGE((short)1, "message");
42  
43      private static final Map<Integer, _Fields> byId = new HashMap<Integer, _Fields>();
44      private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
45  
46      static {
47        for (_Fields field : EnumSet.allOf(_Fields.class)) {
48          byId.put((int)field._thriftId, field);
49          byName.put(field.getFieldName(), field);
50        }
51      }
52  
53      /**
54       * Find the _Fields constant that matches fieldId, or null if its not found.
55       */
56      public static _Fields findByThriftId(int fieldId) {
57        return byId.get(fieldId);
58      }
59  
60      /**
61       * Find the _Fields constant that matches fieldId, throwing an exception
62       * if it is not found.
63       */
64      public static _Fields findByThriftIdOrThrow(int fieldId) {
65        _Fields fields = findByThriftId(fieldId);
66        if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
67        return fields;
68      }
69  
70      /**
71       * Find the _Fields constant that matches name, or null if its not found.
72       */
73      public static _Fields findByName(String name) {
74        return byName.get(name);
75      }
76  
77      private final short _thriftId;
78      private final String _fieldName;
79  
80      _Fields(short thriftId, String fieldName) {
81        _thriftId = thriftId;
82        _fieldName = fieldName;
83      }
84  
85      public short getThriftFieldId() {
86        return _thriftId;
87      }
88  
89      public String getFieldName() {
90        return _fieldName;
91      }
92    }
93  
94    // isset id assignments
95  
96    public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
97      put(_Fields.MESSAGE, new FieldMetaData("message", TFieldRequirementType.DEFAULT,
98          new FieldValueMetaData(TType.STRING)));
99    }});
100 
101   static {
102     FieldMetaData.addStructMetaDataMap(AlreadyExists.class, metaDataMap);
103   }
104 
105   public AlreadyExists() {
106   }
107 
108   public AlreadyExists(
109     String message)
110   {
111     this();
112     this.message = message;
113   }
114 
115   /**
116    * Performs a deep copy on <i>other</i>.
117    */
118   public AlreadyExists(AlreadyExists other) {
119     if (other.isSetMessage()) {
120       this.message = other.message;
121     }
122   }
123 
124   public AlreadyExists deepCopy() {
125     return new AlreadyExists(this);
126   }
127 
128   @Deprecated
129   public AlreadyExists clone() {
130     return new AlreadyExists(this);
131   }
132 
133   public String getMessage() {
134     return this.message;
135   }
136 
137   public AlreadyExists setMessage(String message) {
138     this.message = message;
139     return this;
140   }
141 
142   public void unsetMessage() {
143     this.message = null;
144   }
145 
146   /** Returns true if field message is set (has been asigned a value) and false otherwise */
147   public boolean isSetMessage() {
148     return this.message != null;
149   }
150 
151   public void setMessageIsSet(boolean value) {
152     if (!value) {
153       this.message = null;
154     }
155   }
156 
157   public void setFieldValue(_Fields field, Object value) {
158     switch (field) {
159     case MESSAGE:
160       if (value == null) {
161         unsetMessage();
162       } else {
163         setMessage((String)value);
164       }
165       break;
166 
167     }
168   }
169 
170   public void setFieldValue(int fieldID, Object value) {
171     setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value);
172   }
173 
174   public Object getFieldValue(_Fields field) {
175     switch (field) {
176     case MESSAGE:
177       return getMessage();
178 
179     }
180     throw new IllegalStateException();
181   }
182 
183   public Object getFieldValue(int fieldId) {
184     return getFieldValue(_Fields.findByThriftIdOrThrow(fieldId));
185   }
186 
187   /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
188   public boolean isSet(_Fields field) {
189     switch (field) {
190     case MESSAGE:
191       return isSetMessage();
192     }
193     throw new IllegalStateException();
194   }
195 
196   public boolean isSet(int fieldID) {
197     return isSet(_Fields.findByThriftIdOrThrow(fieldID));
198   }
199 
200   @Override
201   public boolean equals(Object that) {
202     if (that == null)
203       return false;
204     if (that instanceof AlreadyExists)
205       return this.equals((AlreadyExists)that);
206     return false;
207   }
208 
209   public boolean equals(AlreadyExists that) {
210     if (that == null)
211       return false;
212 
213     boolean this_present_message = true && this.isSetMessage();
214     boolean that_present_message = true && that.isSetMessage();
215     if (this_present_message || that_present_message) {
216       if (!(this_present_message && that_present_message))
217         return false;
218       if (!this.message.equals(that.message))
219         return false;
220     }
221 
222     return true;
223   }
224 
225   @Override
226   public int hashCode() {
227     HashCodeBuilder builder = new HashCodeBuilder();
228 
229     boolean present_message = true && (isSetMessage());
230     builder.append(present_message);
231     if (present_message)
232       builder.append(message);
233 
234     return builder.toHashCode();
235   }
236 
237   public int compareTo(AlreadyExists other) {
238     if (!getClass().equals(other.getClass())) {
239       return getClass().getName().compareTo(other.getClass().getName());
240     }
241 
242     int lastComparison = 0;
243     AlreadyExists typedOther = (AlreadyExists)other;
244 
245     lastComparison = Boolean.valueOf(isSetMessage()).compareTo(isSetMessage());
246     if (lastComparison != 0) {
247       return lastComparison;
248     }
249     lastComparison = TBaseHelper.compareTo(message, typedOther.message);
250     if (lastComparison != 0) {
251       return lastComparison;
252     }
253     return 0;
254   }
255 
256   public void read(TProtocol iprot) throws TException {
257     TField field;
258     iprot.readStructBegin();
259     while (true)
260     {
261       field = iprot.readFieldBegin();
262       if (field.type == TType.STOP) {
263         break;
264       }
265       _Fields fieldId = _Fields.findByThriftId(field.id);
266       if (fieldId == null) {
267         TProtocolUtil.skip(iprot, field.type);
268       } else {
269         switch (fieldId) {
270           case MESSAGE:
271             if (field.type == TType.STRING) {
272               this.message = iprot.readString();
273             } else {
274               TProtocolUtil.skip(iprot, field.type);
275             }
276             break;
277         }
278         iprot.readFieldEnd();
279       }
280     }
281     iprot.readStructEnd();
282 
283     // check for required fields of primitive type, which can't be checked in the validate method
284     validate();
285   }
286 
287   public void write(TProtocol oprot) throws TException {
288     validate();
289 
290     oprot.writeStructBegin(STRUCT_DESC);
291     if (this.message != null) {
292       oprot.writeFieldBegin(MESSAGE_FIELD_DESC);
293       oprot.writeString(this.message);
294       oprot.writeFieldEnd();
295     }
296     oprot.writeFieldStop();
297     oprot.writeStructEnd();
298   }
299 
300   @Override
301   public String toString() {
302     StringBuilder sb = new StringBuilder("AlreadyExists(");
303     boolean first = true;
304 
305     sb.append("message:");
306     if (this.message == null) {
307       sb.append("null");
308     } else {
309       sb.append(this.message);
310     }
311     first = false;
312     sb.append(")");
313     return sb.toString();
314   }
315 
316   public void validate() throws TException {
317     // check for required fields
318   }
319 
320 }
321