View Javadoc

1   /**
2    * Autogenerated by Thrift Compiler (0.7.0)
3    *
4    * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
5    */
6   package org.apache.hadoop.hbase.thrift.generated;
7   
8   import java.util.List;
9   import java.util.ArrayList;
10  import java.util.Map;
11  import java.util.HashMap;
12  import java.util.EnumMap;
13  import java.util.Set;
14  import java.util.HashSet;
15  import java.util.EnumSet;
16  import java.util.Collections;
17  import java.util.BitSet;
18  import java.nio.ByteBuffer;
19  import java.util.Arrays;
20  import org.slf4j.Logger;
21  import org.slf4j.LoggerFactory;
22  
23  /**
24   * A Mutation object is used to either update or delete a column-value.
25   */
26  public class Mutation implements org.apache.thrift.TBase<Mutation, Mutation._Fields>, java.io.Serializable, Cloneable {
27    private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("Mutation");
28  
29    private static final org.apache.thrift.protocol.TField IS_DELETE_FIELD_DESC = new org.apache.thrift.protocol.TField("isDelete", org.apache.thrift.protocol.TType.BOOL, (short)1);
30    private static final org.apache.thrift.protocol.TField COLUMN_FIELD_DESC = new org.apache.thrift.protocol.TField("column", org.apache.thrift.protocol.TType.STRING, (short)2);
31    private static final org.apache.thrift.protocol.TField VALUE_FIELD_DESC = new org.apache.thrift.protocol.TField("value", org.apache.thrift.protocol.TType.STRING, (short)3);
32  
33    public boolean isDelete; // required
34    public ByteBuffer column; // required
35    public ByteBuffer value; // required
36  
37    /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
38    public enum _Fields implements org.apache.thrift.TFieldIdEnum {
39      IS_DELETE((short)1, "isDelete"),
40      COLUMN((short)2, "column"),
41      VALUE((short)3, "value");
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: // IS_DELETE
57            return IS_DELETE;
58          case 2: // COLUMN
59            return COLUMN;
60          case 3: // VALUE
61            return VALUE;
62          default:
63            return null;
64        }
65      }
66  
67      /**
68       * Find the _Fields constant that matches fieldId, throwing an exception
69       * if it is not found.
70       */
71      public static _Fields findByThriftIdOrThrow(int fieldId) {
72        _Fields fields = findByThriftId(fieldId);
73        if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
74        return fields;
75      }
76  
77      /**
78       * Find the _Fields constant that matches name, or null if its not found.
79       */
80      public static _Fields findByName(String name) {
81        return byName.get(name);
82      }
83  
84      private final short _thriftId;
85      private final String _fieldName;
86  
87      _Fields(short thriftId, String fieldName) {
88        _thriftId = thriftId;
89        _fieldName = fieldName;
90      }
91  
92      public short getThriftFieldId() {
93        return _thriftId;
94      }
95  
96      public String getFieldName() {
97        return _fieldName;
98      }
99    }
100 
101   // isset id assignments
102   private static final int __ISDELETE_ISSET_ID = 0;
103   private BitSet __isset_bit_vector = new BitSet(1);
104 
105   public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
106   static {
107     Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
108     tmpMap.put(_Fields.IS_DELETE, new org.apache.thrift.meta_data.FieldMetaData("isDelete", org.apache.thrift.TFieldRequirementType.DEFAULT, 
109         new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL)));
110     tmpMap.put(_Fields.COLUMN, new org.apache.thrift.meta_data.FieldMetaData("column", org.apache.thrift.TFieldRequirementType.DEFAULT, 
111         new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING        , "Text")));
112     tmpMap.put(_Fields.VALUE, new org.apache.thrift.meta_data.FieldMetaData("value", org.apache.thrift.TFieldRequirementType.DEFAULT, 
113         new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING        , "Text")));
114     metaDataMap = Collections.unmodifiableMap(tmpMap);
115     org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(Mutation.class, metaDataMap);
116   }
117 
118   public Mutation() {
119     this.isDelete = false;
120 
121   }
122 
123   public Mutation(
124     boolean isDelete,
125     ByteBuffer column,
126     ByteBuffer value)
127   {
128     this();
129     this.isDelete = isDelete;
130     setIsDeleteIsSet(true);
131     this.column = column;
132     this.value = value;
133   }
134 
135   /**
136    * Performs a deep copy on <i>other</i>.
137    */
138   public Mutation(Mutation other) {
139     __isset_bit_vector.clear();
140     __isset_bit_vector.or(other.__isset_bit_vector);
141     this.isDelete = other.isDelete;
142     if (other.isSetColumn()) {
143       this.column = other.column;
144     }
145     if (other.isSetValue()) {
146       this.value = other.value;
147     }
148   }
149 
150   public Mutation deepCopy() {
151     return new Mutation(this);
152   }
153 
154   @Override
155   public void clear() {
156     this.isDelete = false;
157 
158     this.column = null;
159     this.value = null;
160   }
161 
162   public boolean isIsDelete() {
163     return this.isDelete;
164   }
165 
166   public Mutation setIsDelete(boolean isDelete) {
167     this.isDelete = isDelete;
168     setIsDeleteIsSet(true);
169     return this;
170   }
171 
172   public void unsetIsDelete() {
173     __isset_bit_vector.clear(__ISDELETE_ISSET_ID);
174   }
175 
176   /** Returns true if field isDelete is set (has been assigned a value) and false otherwise */
177   public boolean isSetIsDelete() {
178     return __isset_bit_vector.get(__ISDELETE_ISSET_ID);
179   }
180 
181   public void setIsDeleteIsSet(boolean value) {
182     __isset_bit_vector.set(__ISDELETE_ISSET_ID, value);
183   }
184 
185   public byte[] getColumn() {
186     setColumn(org.apache.thrift.TBaseHelper.rightSize(column));
187     return column == null ? null : column.array();
188   }
189 
190   public ByteBuffer bufferForColumn() {
191     return column;
192   }
193 
194   public Mutation setColumn(byte[] column) {
195     setColumn(column == null ? (ByteBuffer)null : ByteBuffer.wrap(column));
196     return this;
197   }
198 
199   public Mutation setColumn(ByteBuffer column) {
200     this.column = column;
201     return this;
202   }
203 
204   public void unsetColumn() {
205     this.column = null;
206   }
207 
208   /** Returns true if field column is set (has been assigned a value) and false otherwise */
209   public boolean isSetColumn() {
210     return this.column != null;
211   }
212 
213   public void setColumnIsSet(boolean value) {
214     if (!value) {
215       this.column = null;
216     }
217   }
218 
219   public byte[] getValue() {
220     setValue(org.apache.thrift.TBaseHelper.rightSize(value));
221     return value == null ? null : value.array();
222   }
223 
224   public ByteBuffer bufferForValue() {
225     return value;
226   }
227 
228   public Mutation setValue(byte[] value) {
229     setValue(value == null ? (ByteBuffer)null : ByteBuffer.wrap(value));
230     return this;
231   }
232 
233   public Mutation setValue(ByteBuffer value) {
234     this.value = value;
235     return this;
236   }
237 
238   public void unsetValue() {
239     this.value = null;
240   }
241 
242   /** Returns true if field value is set (has been assigned a value) and false otherwise */
243   public boolean isSetValue() {
244     return this.value != null;
245   }
246 
247   public void setValueIsSet(boolean value) {
248     if (!value) {
249       this.value = null;
250     }
251   }
252 
253   public void setFieldValue(_Fields field, Object value) {
254     switch (field) {
255     case IS_DELETE:
256       if (value == null) {
257         unsetIsDelete();
258       } else {
259         setIsDelete((Boolean)value);
260       }
261       break;
262 
263     case COLUMN:
264       if (value == null) {
265         unsetColumn();
266       } else {
267         setColumn((ByteBuffer)value);
268       }
269       break;
270 
271     case VALUE:
272       if (value == null) {
273         unsetValue();
274       } else {
275         setValue((ByteBuffer)value);
276       }
277       break;
278 
279     }
280   }
281 
282   public Object getFieldValue(_Fields field) {
283     switch (field) {
284     case IS_DELETE:
285       return Boolean.valueOf(isIsDelete());
286 
287     case COLUMN:
288       return getColumn();
289 
290     case VALUE:
291       return getValue();
292 
293     }
294     throw new IllegalStateException();
295   }
296 
297   /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
298   public boolean isSet(_Fields field) {
299     if (field == null) {
300       throw new IllegalArgumentException();
301     }
302 
303     switch (field) {
304     case IS_DELETE:
305       return isSetIsDelete();
306     case COLUMN:
307       return isSetColumn();
308     case VALUE:
309       return isSetValue();
310     }
311     throw new IllegalStateException();
312   }
313 
314   @Override
315   public boolean equals(Object that) {
316     if (that == null)
317       return false;
318     if (that instanceof Mutation)
319       return this.equals((Mutation)that);
320     return false;
321   }
322 
323   public boolean equals(Mutation that) {
324     if (that == null)
325       return false;
326 
327     boolean this_present_isDelete = true;
328     boolean that_present_isDelete = true;
329     if (this_present_isDelete || that_present_isDelete) {
330       if (!(this_present_isDelete && that_present_isDelete))
331         return false;
332       if (this.isDelete != that.isDelete)
333         return false;
334     }
335 
336     boolean this_present_column = true && this.isSetColumn();
337     boolean that_present_column = true && that.isSetColumn();
338     if (this_present_column || that_present_column) {
339       if (!(this_present_column && that_present_column))
340         return false;
341       if (!this.column.equals(that.column))
342         return false;
343     }
344 
345     boolean this_present_value = true && this.isSetValue();
346     boolean that_present_value = true && that.isSetValue();
347     if (this_present_value || that_present_value) {
348       if (!(this_present_value && that_present_value))
349         return false;
350       if (!this.value.equals(that.value))
351         return false;
352     }
353 
354     return true;
355   }
356 
357   @Override
358   public int hashCode() {
359     return 0;
360   }
361 
362   public int compareTo(Mutation other) {
363     if (!getClass().equals(other.getClass())) {
364       return getClass().getName().compareTo(other.getClass().getName());
365     }
366 
367     int lastComparison = 0;
368     Mutation typedOther = (Mutation)other;
369 
370     lastComparison = Boolean.valueOf(isSetIsDelete()).compareTo(typedOther.isSetIsDelete());
371     if (lastComparison != 0) {
372       return lastComparison;
373     }
374     if (isSetIsDelete()) {
375       lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.isDelete, typedOther.isDelete);
376       if (lastComparison != 0) {
377         return lastComparison;
378       }
379     }
380     lastComparison = Boolean.valueOf(isSetColumn()).compareTo(typedOther.isSetColumn());
381     if (lastComparison != 0) {
382       return lastComparison;
383     }
384     if (isSetColumn()) {
385       lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.column, typedOther.column);
386       if (lastComparison != 0) {
387         return lastComparison;
388       }
389     }
390     lastComparison = Boolean.valueOf(isSetValue()).compareTo(typedOther.isSetValue());
391     if (lastComparison != 0) {
392       return lastComparison;
393     }
394     if (isSetValue()) {
395       lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.value, typedOther.value);
396       if (lastComparison != 0) {
397         return lastComparison;
398       }
399     }
400     return 0;
401   }
402 
403   public _Fields fieldForId(int fieldId) {
404     return _Fields.findByThriftId(fieldId);
405   }
406 
407   public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
408     org.apache.thrift.protocol.TField field;
409     iprot.readStructBegin();
410     while (true)
411     {
412       field = iprot.readFieldBegin();
413       if (field.type == org.apache.thrift.protocol.TType.STOP) { 
414         break;
415       }
416       switch (field.id) {
417         case 1: // IS_DELETE
418           if (field.type == org.apache.thrift.protocol.TType.BOOL) {
419             this.isDelete = iprot.readBool();
420             setIsDeleteIsSet(true);
421           } else { 
422             org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
423           }
424           break;
425         case 2: // COLUMN
426           if (field.type == org.apache.thrift.protocol.TType.STRING) {
427             this.column = iprot.readBinary();
428           } else { 
429             org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
430           }
431           break;
432         case 3: // VALUE
433           if (field.type == org.apache.thrift.protocol.TType.STRING) {
434             this.value = iprot.readBinary();
435           } else { 
436             org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
437           }
438           break;
439         default:
440           org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
441       }
442       iprot.readFieldEnd();
443     }
444     iprot.readStructEnd();
445 
446     // check for required fields of primitive type, which can't be checked in the validate method
447     validate();
448   }
449 
450   public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
451     validate();
452 
453     oprot.writeStructBegin(STRUCT_DESC);
454     oprot.writeFieldBegin(IS_DELETE_FIELD_DESC);
455     oprot.writeBool(this.isDelete);
456     oprot.writeFieldEnd();
457     if (this.column != null) {
458       oprot.writeFieldBegin(COLUMN_FIELD_DESC);
459       oprot.writeBinary(this.column);
460       oprot.writeFieldEnd();
461     }
462     if (this.value != null) {
463       oprot.writeFieldBegin(VALUE_FIELD_DESC);
464       oprot.writeBinary(this.value);
465       oprot.writeFieldEnd();
466     }
467     oprot.writeFieldStop();
468     oprot.writeStructEnd();
469   }
470 
471   @Override
472   public String toString() {
473     StringBuilder sb = new StringBuilder("Mutation(");
474     boolean first = true;
475 
476     sb.append("isDelete:");
477     sb.append(this.isDelete);
478     first = false;
479     if (!first) sb.append(", ");
480     sb.append("column:");
481     if (this.column == null) {
482       sb.append("null");
483     } else {
484       sb.append(this.column);
485     }
486     first = false;
487     if (!first) sb.append(", ");
488     sb.append("value:");
489     if (this.value == null) {
490       sb.append("null");
491     } else {
492       sb.append(this.value);
493     }
494     first = false;
495     sb.append(")");
496     return sb.toString();
497   }
498 
499   public void validate() throws org.apache.thrift.TException {
500     // check for required fields
501   }
502 
503   private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
504     try {
505       write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
506     } catch (org.apache.thrift.TException te) {
507       throw new java.io.IOException(te);
508     }
509   }
510 
511   private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
512     try {
513       // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor.
514       __isset_bit_vector = new BitSet(1);
515       read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
516     } catch (org.apache.thrift.TException te) {
517       throw new java.io.IOException(te);
518     }
519   }
520 
521 }
522