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