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