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