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.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   * An AlreadyExists exceptions signals that a table with the specified
33   * name already exists
34   */
35  public class AlreadyExists extends Exception implements org.apache.thrift.TBase<AlreadyExists, AlreadyExists._Fields>, java.io.Serializable, Cloneable {
36    private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("AlreadyExists");
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 AlreadyExistsStandardSchemeFactory());
43      schemes.put(TupleScheme.class, new AlreadyExistsTupleSchemeFactory());
44    }
45  
46    public String message; // required
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   public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
108   static {
109     Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
110     tmpMap.put(_Fields.MESSAGE, new org.apache.thrift.meta_data.FieldMetaData("message", org.apache.thrift.TFieldRequirementType.DEFAULT, 
111         new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
112     metaDataMap = Collections.unmodifiableMap(tmpMap);
113     org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(AlreadyExists.class, metaDataMap);
114   }
115 
116   public AlreadyExists() {
117   }
118 
119   public AlreadyExists(
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 AlreadyExists(AlreadyExists other) {
130     if (other.isSetMessage()) {
131       this.message = other.message;
132     }
133   }
134 
135   public AlreadyExists deepCopy() {
136     return new AlreadyExists(this);
137   }
138 
139   @Override
140   public void clear() {
141     this.message = null;
142   }
143 
144   public String getMessage() {
145     return this.message;
146   }
147 
148   public AlreadyExists 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 assigned 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 Object getFieldValue(_Fields field) {
182     switch (field) {
183     case MESSAGE:
184       return getMessage();
185 
186     }
187     throw new IllegalStateException();
188   }
189 
190   /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
191   public boolean isSet(_Fields field) {
192     if (field == null) {
193       throw new IllegalArgumentException();
194     }
195 
196     switch (field) {
197     case MESSAGE:
198       return isSetMessage();
199     }
200     throw new IllegalStateException();
201   }
202 
203   @Override
204   public boolean equals(Object that) {
205     if (that == null)
206       return false;
207     if (that instanceof AlreadyExists)
208       return this.equals((AlreadyExists)that);
209     return false;
210   }
211 
212   public boolean equals(AlreadyExists that) {
213     if (that == null)
214       return false;
215 
216     boolean this_present_message = true && this.isSetMessage();
217     boolean that_present_message = true && that.isSetMessage();
218     if (this_present_message || that_present_message) {
219       if (!(this_present_message && that_present_message))
220         return false;
221       if (!this.message.equals(that.message))
222         return false;
223     }
224 
225     return true;
226   }
227 
228   @Override
229   public int hashCode() {
230     HashCodeBuilder builder = new HashCodeBuilder();
231 
232     boolean present_message = true && (isSetMessage());
233     builder.append(present_message);
234     if (present_message)
235       builder.append(message);
236 
237     return builder.toHashCode();
238   }
239 
240   public int compareTo(AlreadyExists other) {
241     if (!getClass().equals(other.getClass())) {
242       return getClass().getName().compareTo(other.getClass().getName());
243     }
244 
245     int lastComparison = 0;
246     AlreadyExists typedOther = (AlreadyExists)other;
247 
248     lastComparison = Boolean.valueOf(isSetMessage()).compareTo(typedOther.isSetMessage());
249     if (lastComparison != 0) {
250       return lastComparison;
251     }
252     if (isSetMessage()) {
253       lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.message, typedOther.message);
254       if (lastComparison != 0) {
255         return lastComparison;
256       }
257     }
258     return 0;
259   }
260 
261   public _Fields fieldForId(int fieldId) {
262     return _Fields.findByThriftId(fieldId);
263   }
264 
265   public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
266     schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
267   }
268 
269   public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
270     schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
271   }
272 
273   @Override
274   public String toString() {
275     StringBuilder sb = new StringBuilder("AlreadyExists(");
276     boolean first = true;
277 
278     sb.append("message:");
279     if (this.message == null) {
280       sb.append("null");
281     } else {
282       sb.append(this.message);
283     }
284     first = false;
285     sb.append(")");
286     return sb.toString();
287   }
288 
289   public void validate() throws org.apache.thrift.TException {
290     // check for required fields
291   }
292 
293   private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
294     try {
295       write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
296     } catch (org.apache.thrift.TException te) {
297       throw new java.io.IOException(te);
298     }
299   }
300 
301   private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
302     try {
303       read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
304     } catch (org.apache.thrift.TException te) {
305       throw new java.io.IOException(te);
306     }
307   }
308 
309   private static class AlreadyExistsStandardSchemeFactory implements SchemeFactory {
310     public AlreadyExistsStandardScheme getScheme() {
311       return new AlreadyExistsStandardScheme();
312     }
313   }
314 
315   private static class AlreadyExistsStandardScheme extends StandardScheme<AlreadyExists> {
316 
317     public void read(org.apache.thrift.protocol.TProtocol iprot, AlreadyExists struct) throws org.apache.thrift.TException {
318       org.apache.thrift.protocol.TField schemeField;
319       iprot.readStructBegin();
320       while (true)
321       {
322         schemeField = iprot.readFieldBegin();
323         if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { 
324           break;
325         }
326         switch (schemeField.id) {
327           case 1: // MESSAGE
328             if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
329               struct.message = iprot.readString();
330               struct.setMessageIsSet(true);
331             } else { 
332               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
333             }
334             break;
335           default:
336             org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
337         }
338         iprot.readFieldEnd();
339       }
340       iprot.readStructEnd();
341 
342       // check for required fields of primitive type, which can't be checked in the validate method
343       struct.validate();
344     }
345 
346     public void write(org.apache.thrift.protocol.TProtocol oprot, AlreadyExists struct) throws org.apache.thrift.TException {
347       struct.validate();
348 
349       oprot.writeStructBegin(STRUCT_DESC);
350       if (struct.message != null) {
351         oprot.writeFieldBegin(MESSAGE_FIELD_DESC);
352         oprot.writeString(struct.message);
353         oprot.writeFieldEnd();
354       }
355       oprot.writeFieldStop();
356       oprot.writeStructEnd();
357     }
358 
359   }
360 
361   private static class AlreadyExistsTupleSchemeFactory implements SchemeFactory {
362     public AlreadyExistsTupleScheme getScheme() {
363       return new AlreadyExistsTupleScheme();
364     }
365   }
366 
367   private static class AlreadyExistsTupleScheme extends TupleScheme<AlreadyExists> {
368 
369     @Override
370     public void write(org.apache.thrift.protocol.TProtocol prot, AlreadyExists struct) throws org.apache.thrift.TException {
371       TTupleProtocol oprot = (TTupleProtocol) prot;
372       BitSet optionals = new BitSet();
373       if (struct.isSetMessage()) {
374         optionals.set(0);
375       }
376       oprot.writeBitSet(optionals, 1);
377       if (struct.isSetMessage()) {
378         oprot.writeString(struct.message);
379       }
380     }
381 
382     @Override
383     public void read(org.apache.thrift.protocol.TProtocol prot, AlreadyExists struct) throws org.apache.thrift.TException {
384       TTupleProtocol iprot = (TTupleProtocol) prot;
385       BitSet incoming = iprot.readBitSet(1);
386       if (incoming.get(0)) {
387         struct.message = iprot.readString();
388         struct.setMessageIsSet(true);
389       }
390     }
391   }
392 
393 }
394