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
43
44
45 public class TCell implements TBase<TCell._Fields>, java.io.Serializable, Cloneable, Comparable<TCell> {
46 private static final TStruct STRUCT_DESC = new TStruct("TCell");
47
48 private static final TField VALUE_FIELD_DESC = new TField("value", TType.STRING, (short)1);
49 private static final TField TIMESTAMP_FIELD_DESC = new TField("timestamp", TType.I64, (short)2);
50
51 public byte[] value;
52 public long timestamp;
53
54
55 public enum _Fields implements TFieldIdEnum {
56 VALUE((short)1, "value"),
57 TIMESTAMP((short)2, "timestamp");
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 __TIMESTAMP_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.VALUE, new FieldMetaData("value", TFieldRequirementType.DEFAULT,
116 new FieldValueMetaData(TType.STRING)));
117 put(_Fields.TIMESTAMP, new FieldMetaData("timestamp", TFieldRequirementType.DEFAULT,
118 new FieldValueMetaData(TType.I64)));
119 }});
120
121 static {
122 FieldMetaData.addStructMetaDataMap(TCell.class, metaDataMap);
123 }
124
125 public TCell() {
126 }
127
128 public TCell(
129 byte[] value,
130 long timestamp)
131 {
132 this();
133 this.value = value;
134 this.timestamp = timestamp;
135 setTimestampIsSet(true);
136 }
137
138
139
140
141 public TCell(TCell other) {
142 __isset_bit_vector.clear();
143 __isset_bit_vector.or(other.__isset_bit_vector);
144 if (other.isSetValue()) {
145 this.value = other.value;
146 }
147 this.timestamp = other.timestamp;
148 }
149
150 public TCell deepCopy() {
151 return new TCell(this);
152 }
153
154 @Deprecated
155 public TCell clone() {
156 return new TCell(this);
157 }
158
159 public byte[] getValue() {
160 return this.value;
161 }
162
163 public TCell setValue(byte[] value) {
164 this.value = value;
165 return this;
166 }
167
168 public void unsetValue() {
169 this.value = null;
170 }
171
172
173 public boolean isSetValue() {
174 return this.value != null;
175 }
176
177 public void setValueIsSet(boolean value) {
178 if (!value) {
179 this.value = null;
180 }
181 }
182
183 public long getTimestamp() {
184 return this.timestamp;
185 }
186
187 public TCell setTimestamp(long timestamp) {
188 this.timestamp = timestamp;
189 setTimestampIsSet(true);
190 return this;
191 }
192
193 public void unsetTimestamp() {
194 __isset_bit_vector.clear(__TIMESTAMP_ISSET_ID);
195 }
196
197
198 public boolean isSetTimestamp() {
199 return __isset_bit_vector.get(__TIMESTAMP_ISSET_ID);
200 }
201
202 public void setTimestampIsSet(boolean value) {
203 __isset_bit_vector.set(__TIMESTAMP_ISSET_ID, value);
204 }
205
206 public void setFieldValue(_Fields field, Object value) {
207 switch (field) {
208 case VALUE:
209 if (value == null) {
210 unsetValue();
211 } else {
212 setValue((byte[])value);
213 }
214 break;
215
216 case TIMESTAMP:
217 if (value == null) {
218 unsetTimestamp();
219 } else {
220 setTimestamp((Long)value);
221 }
222 break;
223
224 }
225 }
226
227 public void setFieldValue(int fieldID, Object value) {
228 setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value);
229 }
230
231 public Object getFieldValue(_Fields field) {
232 switch (field) {
233 case VALUE:
234 return getValue();
235
236 case TIMESTAMP:
237 return new Long(getTimestamp());
238
239 }
240 throw new IllegalStateException();
241 }
242
243 public Object getFieldValue(int fieldId) {
244 return getFieldValue(_Fields.findByThriftIdOrThrow(fieldId));
245 }
246
247
248 public boolean isSet(_Fields field) {
249 switch (field) {
250 case VALUE:
251 return isSetValue();
252 case TIMESTAMP:
253 return isSetTimestamp();
254 }
255 throw new IllegalStateException();
256 }
257
258 public boolean isSet(int fieldID) {
259 return isSet(_Fields.findByThriftIdOrThrow(fieldID));
260 }
261
262 @Override
263 public boolean equals(Object that) {
264 if (that == null)
265 return false;
266 if (that instanceof TCell)
267 return this.equals((TCell)that);
268 return false;
269 }
270
271 public boolean equals(TCell that) {
272 if (that == null)
273 return false;
274
275 boolean this_present_value = true && this.isSetValue();
276 boolean that_present_value = true && that.isSetValue();
277 if (this_present_value || that_present_value) {
278 if (!(this_present_value && that_present_value))
279 return false;
280 if (!java.util.Arrays.equals(this.value, that.value))
281 return false;
282 }
283
284 boolean this_present_timestamp = true;
285 boolean that_present_timestamp = true;
286 if (this_present_timestamp || that_present_timestamp) {
287 if (!(this_present_timestamp && that_present_timestamp))
288 return false;
289 if (this.timestamp != that.timestamp)
290 return false;
291 }
292
293 return true;
294 }
295
296 @Override
297 public int hashCode() {
298 HashCodeBuilder builder = new HashCodeBuilder();
299
300 boolean present_value = true && (isSetValue());
301 builder.append(present_value);
302 if (present_value)
303 builder.append(value);
304
305 boolean present_timestamp = true;
306 builder.append(present_timestamp);
307 if (present_timestamp)
308 builder.append(timestamp);
309
310 return builder.toHashCode();
311 }
312
313 public int compareTo(TCell other) {
314 if (!getClass().equals(other.getClass())) {
315 return getClass().getName().compareTo(other.getClass().getName());
316 }
317
318 int lastComparison = 0;
319 TCell typedOther = (TCell)other;
320
321 lastComparison = Boolean.valueOf(isSetValue()).compareTo(isSetValue());
322 if (lastComparison != 0) {
323 return lastComparison;
324 }
325 lastComparison = TBaseHelper.compareTo(value, typedOther.value);
326 if (lastComparison != 0) {
327 return lastComparison;
328 }
329 lastComparison = Boolean.valueOf(isSetTimestamp()).compareTo(isSetTimestamp());
330 if (lastComparison != 0) {
331 return lastComparison;
332 }
333 lastComparison = TBaseHelper.compareTo(timestamp, typedOther.timestamp);
334 if (lastComparison != 0) {
335 return lastComparison;
336 }
337 return 0;
338 }
339
340 public void read(TProtocol iprot) throws TException {
341 TField field;
342 iprot.readStructBegin();
343 while (true)
344 {
345 field = iprot.readFieldBegin();
346 if (field.type == TType.STOP) {
347 break;
348 }
349 _Fields fieldId = _Fields.findByThriftId(field.id);
350 if (fieldId == null) {
351 TProtocolUtil.skip(iprot, field.type);
352 } else {
353 switch (fieldId) {
354 case VALUE:
355 if (field.type == TType.STRING) {
356 this.value = iprot.readBinary();
357 } else {
358 TProtocolUtil.skip(iprot, field.type);
359 }
360 break;
361 case TIMESTAMP:
362 if (field.type == TType.I64) {
363 this.timestamp = iprot.readI64();
364 setTimestampIsSet(true);
365 } else {
366 TProtocolUtil.skip(iprot, field.type);
367 }
368 break;
369 }
370 iprot.readFieldEnd();
371 }
372 }
373 iprot.readStructEnd();
374
375
376 validate();
377 }
378
379 public void write(TProtocol oprot) throws TException {
380 validate();
381
382 oprot.writeStructBegin(STRUCT_DESC);
383 if (this.value != null) {
384 oprot.writeFieldBegin(VALUE_FIELD_DESC);
385 oprot.writeBinary(this.value);
386 oprot.writeFieldEnd();
387 }
388 oprot.writeFieldBegin(TIMESTAMP_FIELD_DESC);
389 oprot.writeI64(this.timestamp);
390 oprot.writeFieldEnd();
391 oprot.writeFieldStop();
392 oprot.writeStructEnd();
393 }
394
395 @Override
396 public String toString() {
397 StringBuilder sb = new StringBuilder("TCell(");
398 boolean first = true;
399
400 sb.append("value:");
401 if (this.value == null) {
402 sb.append("null");
403 } else {
404 sb.append(this.value);
405 }
406 first = false;
407 if (!first) sb.append(", ");
408 sb.append("timestamp:");
409 sb.append(this.timestamp);
410 first = false;
411 sb.append(")");
412 return sb.toString();
413 }
414
415 public void validate() throws TException {
416
417 }
418
419 }
420