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.thrift2.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 java.util.List;
16  import java.util.ArrayList;
17  import java.util.Map;
18  import java.util.HashMap;
19  import java.util.EnumMap;
20  import java.util.Set;
21  import java.util.HashSet;
22  import java.util.EnumSet;
23  import java.util.Collections;
24  import java.util.BitSet;
25  import java.nio.ByteBuffer;
26  import java.util.Arrays;
27  import org.slf4j.Logger;
28  import org.slf4j.LoggerFactory;
29  
30  /**
31   * Atomic mutation for the specified row. It can be either Put or Delete.
32   */
33  public class TMutation extends org.apache.thrift.TUnion<TMutation, TMutation._Fields> {
34    private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TMutation");
35    private static final org.apache.thrift.protocol.TField PUT_FIELD_DESC = new org.apache.thrift.protocol.TField("put", org.apache.thrift.protocol.TType.STRUCT, (short)1);
36    private static final org.apache.thrift.protocol.TField DELETE_SINGLE_FIELD_DESC = new org.apache.thrift.protocol.TField("deleteSingle", org.apache.thrift.protocol.TType.STRUCT, (short)2);
37  
38    /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
39    public enum _Fields implements org.apache.thrift.TFieldIdEnum {
40      PUT((short)1, "put"),
41      DELETE_SINGLE((short)2, "deleteSingle");
42  
43      private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
44  
45      static {
46        for (_Fields field : EnumSet.allOf(_Fields.class)) {
47          byName.put(field.getFieldName(), field);
48        }
49      }
50  
51      /**
52       * Find the _Fields constant that matches fieldId, or null if its not found.
53       */
54      public static _Fields findByThriftId(int fieldId) {
55        switch(fieldId) {
56          case 1: // PUT
57            return PUT;
58          case 2: // DELETE_SINGLE
59            return DELETE_SINGLE;
60          default:
61            return null;
62        }
63      }
64  
65      /**
66       * Find the _Fields constant that matches fieldId, throwing an exception
67       * if it is not found.
68       */
69      public static _Fields findByThriftIdOrThrow(int fieldId) {
70        _Fields fields = findByThriftId(fieldId);
71        if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
72        return fields;
73      }
74  
75      /**
76       * Find the _Fields constant that matches name, or null if its not found.
77       */
78      public static _Fields findByName(String name) {
79        return byName.get(name);
80      }
81  
82      private final short _thriftId;
83      private final String _fieldName;
84  
85      _Fields(short thriftId, String fieldName) {
86        _thriftId = thriftId;
87        _fieldName = fieldName;
88      }
89  
90      public short getThriftFieldId() {
91        return _thriftId;
92      }
93  
94      public String getFieldName() {
95        return _fieldName;
96      }
97    }
98  
99    public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
100   static {
101     Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
102     tmpMap.put(_Fields.PUT, new org.apache.thrift.meta_data.FieldMetaData("put", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
103         new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TPut.class)));
104     tmpMap.put(_Fields.DELETE_SINGLE, new org.apache.thrift.meta_data.FieldMetaData("deleteSingle", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
105         new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TDelete.class)));
106     metaDataMap = Collections.unmodifiableMap(tmpMap);
107     org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TMutation.class, metaDataMap);
108   }
109 
110   public TMutation() {
111     super();
112   }
113 
114   public TMutation(_Fields setField, Object value) {
115     super(setField, value);
116   }
117 
118   public TMutation(TMutation other) {
119     super(other);
120   }
121   public TMutation deepCopy() {
122     return new TMutation(this);
123   }
124 
125   public static TMutation put(TPut value) {
126     TMutation x = new TMutation();
127     x.setPut(value);
128     return x;
129   }
130 
131   public static TMutation deleteSingle(TDelete value) {
132     TMutation x = new TMutation();
133     x.setDeleteSingle(value);
134     return x;
135   }
136 
137 
138   @Override
139   protected void checkType(_Fields setField, Object value) throws ClassCastException {
140     switch (setField) {
141       case PUT:
142         if (value instanceof TPut) {
143           break;
144         }
145         throw new ClassCastException("Was expecting value of type TPut for field 'put', but got " + value.getClass().getSimpleName());
146       case DELETE_SINGLE:
147         if (value instanceof TDelete) {
148           break;
149         }
150         throw new ClassCastException("Was expecting value of type TDelete for field 'deleteSingle', but got " + value.getClass().getSimpleName());
151       default:
152         throw new IllegalArgumentException("Unknown field id " + setField);
153     }
154   }
155 
156   @Override
157   protected Object standardSchemeReadValue(org.apache.thrift.protocol.TProtocol iprot, org.apache.thrift.protocol.TField field) throws org.apache.thrift.TException {
158     _Fields setField = _Fields.findByThriftId(field.id);
159     if (setField != null) {
160       switch (setField) {
161         case PUT:
162           if (field.type == PUT_FIELD_DESC.type) {
163             TPut put;
164             put = new TPut();
165             put.read(iprot);
166             return put;
167           } else {
168             org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
169             return null;
170           }
171         case DELETE_SINGLE:
172           if (field.type == DELETE_SINGLE_FIELD_DESC.type) {
173             TDelete deleteSingle;
174             deleteSingle = new TDelete();
175             deleteSingle.read(iprot);
176             return deleteSingle;
177           } else {
178             org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
179             return null;
180           }
181         default:
182           throw new IllegalStateException("setField wasn't null, but didn't match any of the case statements!");
183       }
184     } else {
185       return null;
186     }
187   }
188 
189   @Override
190   protected void standardSchemeWriteValue(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
191     switch (setField_) {
192       case PUT:
193         TPut put = (TPut)value_;
194         put.write(oprot);
195         return;
196       case DELETE_SINGLE:
197         TDelete deleteSingle = (TDelete)value_;
198         deleteSingle.write(oprot);
199         return;
200       default:
201         throw new IllegalStateException("Cannot write union with unknown field " + setField_);
202     }
203   }
204 
205   @Override
206   protected Object tupleSchemeReadValue(org.apache.thrift.protocol.TProtocol iprot, short fieldID) throws org.apache.thrift.TException {
207     _Fields setField = _Fields.findByThriftId(fieldID);
208     if (setField != null) {
209       switch (setField) {
210         case PUT:
211           TPut put;
212           put = new TPut();
213           put.read(iprot);
214           return put;
215         case DELETE_SINGLE:
216           TDelete deleteSingle;
217           deleteSingle = new TDelete();
218           deleteSingle.read(iprot);
219           return deleteSingle;
220         default:
221           throw new IllegalStateException("setField wasn't null, but didn't match any of the case statements!");
222       }
223     } else {
224       return null;
225     }
226   }
227 
228   @Override
229   protected void tupleSchemeWriteValue(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
230     switch (setField_) {
231       case PUT:
232         TPut put = (TPut)value_;
233         put.write(oprot);
234         return;
235       case DELETE_SINGLE:
236         TDelete deleteSingle = (TDelete)value_;
237         deleteSingle.write(oprot);
238         return;
239       default:
240         throw new IllegalStateException("Cannot write union with unknown field " + setField_);
241     }
242   }
243 
244   @Override
245   protected org.apache.thrift.protocol.TField getFieldDesc(_Fields setField) {
246     switch (setField) {
247       case PUT:
248         return PUT_FIELD_DESC;
249       case DELETE_SINGLE:
250         return DELETE_SINGLE_FIELD_DESC;
251       default:
252         throw new IllegalArgumentException("Unknown field id " + setField);
253     }
254   }
255 
256   @Override
257   protected org.apache.thrift.protocol.TStruct getStructDesc() {
258     return STRUCT_DESC;
259   }
260 
261   @Override
262   protected _Fields enumForId(short id) {
263     return _Fields.findByThriftIdOrThrow(id);
264   }
265 
266   public _Fields fieldForId(int fieldId) {
267     return _Fields.findByThriftId(fieldId);
268   }
269 
270 
271   public TPut getPut() {
272     if (getSetField() == _Fields.PUT) {
273       return (TPut)getFieldValue();
274     } else {
275       throw new RuntimeException("Cannot get field 'put' because union is currently set to " + getFieldDesc(getSetField()).name);
276     }
277   }
278 
279   public void setPut(TPut value) {
280     if (value == null) throw new NullPointerException();
281     setField_ = _Fields.PUT;
282     value_ = value;
283   }
284 
285   public TDelete getDeleteSingle() {
286     if (getSetField() == _Fields.DELETE_SINGLE) {
287       return (TDelete)getFieldValue();
288     } else {
289       throw new RuntimeException("Cannot get field 'deleteSingle' because union is currently set to " + getFieldDesc(getSetField()).name);
290     }
291   }
292 
293   public void setDeleteSingle(TDelete value) {
294     if (value == null) throw new NullPointerException();
295     setField_ = _Fields.DELETE_SINGLE;
296     value_ = value;
297   }
298 
299   public boolean isSetPut() {
300     return setField_ == _Fields.PUT;
301   }
302 
303 
304   public boolean isSetDeleteSingle() {
305     return setField_ == _Fields.DELETE_SINGLE;
306   }
307 
308 
309   public boolean equals(Object other) {
310     if (other instanceof TMutation) {
311       return equals((TMutation)other);
312     } else {
313       return false;
314     }
315   }
316 
317   public boolean equals(TMutation other) {
318     return other != null && getSetField() == other.getSetField() && getFieldValue().equals(other.getFieldValue());
319   }
320 
321   @Override
322   public int compareTo(TMutation other) {
323     int lastComparison = org.apache.thrift.TBaseHelper.compareTo(getSetField(), other.getSetField());
324     if (lastComparison == 0) {
325       return org.apache.thrift.TBaseHelper.compareTo(getFieldValue(), other.getFieldValue());
326     }
327     return lastComparison;
328   }
329 
330 
331   /**
332    * If you'd like this to perform more respectably, use the hashcode generator option.
333    */
334   @Override
335   public int hashCode() {
336     return 0;
337   }
338 
339   private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
340     try {
341       write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
342     } catch (org.apache.thrift.TException te) {
343       throw new java.io.IOException(te);
344     }
345   }
346 
347 
348   private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
349     try {
350       read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
351     } catch (org.apache.thrift.TException te) {
352       throw new java.io.IOException(te);
353     }
354   }
355 
356 
357 }