/** * Autogenerated by Thrift * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated */ import java.util.List; import java.util.ArrayList; import java.util.Map; import java.util.HashMap; import java.util.Set; import java.util.HashSet; import java.util.Collections; import java.util.BitSet; import java.util.Arrays; import com.facebook.thrift.*; import com.facebook.thrift.annotations.*; import com.facebook.thrift.async.*; import com.facebook.thrift.meta_data.*; import com.facebook.thrift.server.*; import com.facebook.thrift.transport.*; import com.facebook.thrift.protocol.*; @SuppressWarnings({ "unused", "serial", "unchecked" }) public class NonTriviallyDestructibleUnion extends TUnion implements Comparable { private static final TStruct STRUCT_DESC = new TStruct("NonTriviallyDestructibleUnion"); private static final TField INT_FIELD_FIELD_DESC = new TField("int_field", TType.I32, (short)1); public static final int INT_FIELD = 1; public static final Map metaDataMap; static { Map tmpMetaDataMap = new HashMap(); tmpMetaDataMap.put(INT_FIELD, new FieldMetaData("int_field", TFieldRequirementType.DEFAULT, new FieldValueMetaData(TType.I32))); metaDataMap = Collections.unmodifiableMap(tmpMetaDataMap); } public NonTriviallyDestructibleUnion() { super(); } public NonTriviallyDestructibleUnion(int setField, Object __value) { super(setField, __value); } public NonTriviallyDestructibleUnion(NonTriviallyDestructibleUnion other) { super(other); } public NonTriviallyDestructibleUnion deepCopy() { return new NonTriviallyDestructibleUnion(this); } public static NonTriviallyDestructibleUnion int_field(int __value) { NonTriviallyDestructibleUnion x = new NonTriviallyDestructibleUnion(); x.setInt_field(__value); return x; } @Override protected void checkType(short setField, Object __value) throws ClassCastException { switch (setField) { case INT_FIELD: if (__value instanceof Integer) { break; } throw new ClassCastException("Was expecting value of type Integer for field 'int_field', but got " + __value.getClass().getSimpleName()); default: throw new IllegalArgumentException("Unknown field id " + setField); } } @Override public void read(TProtocol iprot) throws TException { setField_ = 0; value_ = null; iprot.readStructBegin(metaDataMap); TField __field = iprot.readFieldBegin(); if (__field.type != TType.STOP) { value_ = readValue(iprot, __field); if (value_ != null) { switch (__field.id) { case INT_FIELD: if (__field.type == INT_FIELD_FIELD_DESC.type) { setField_ = __field.id; } break; } } iprot.readFieldEnd(); TField __stopField = iprot.readFieldBegin(); if (__stopField.type != TType.STOP) { throw new TProtocolException(TProtocolException.INVALID_DATA, "Union 'NonTriviallyDestructibleUnion' is missing a STOP byte"); } } iprot.readStructEnd(); } @Override protected Object readValue(TProtocol iprot, TField __field) throws TException { switch (__field.id) { case INT_FIELD: if (__field.type == INT_FIELD_FIELD_DESC.type) { Integer int_field; int_field = iprot.readI32(); return int_field; } break; } TProtocolUtil.skip(iprot, __field.type); return null; } @Override protected void writeValue(TProtocol oprot, short setField, Object __value) throws TException { switch (setField) { case INT_FIELD: Integer int_field = (Integer)getFieldValue(); oprot.writeI32(int_field); return; default: throw new IllegalStateException("Cannot write union with unknown field " + setField); } } @Override protected TField getFieldDesc(int setField) { switch (setField) { case INT_FIELD: return INT_FIELD_FIELD_DESC; default: throw new IllegalArgumentException("Unknown field id " + setField); } } @Override protected TStruct getStructDesc() { return STRUCT_DESC; } @Override protected Map getMetaDataMap() { return metaDataMap; } private Object __getValue(int expectedFieldId) { if (getSetField() == expectedFieldId) { return getFieldValue(); } else { throw new RuntimeException("Cannot get field '" + getFieldDesc(expectedFieldId).name + "' because union is currently set to " + getFieldDesc(getSetField()).name); } } private void __setValue(int fieldId, Object __value) { if (__value == null) throw new NullPointerException(); setField_ = fieldId; value_ = __value; } public int getInt_field() { return (Integer) __getValue(INT_FIELD); } public void setInt_field(int __value) { setField_ = INT_FIELD; value_ = __value; } public boolean equals(Object other) { if (other instanceof NonTriviallyDestructibleUnion) { return equals((NonTriviallyDestructibleUnion)other); } else { return false; } } public boolean equals(NonTriviallyDestructibleUnion other) { return equalsNobinaryImpl(other); } @Override public int compareTo(NonTriviallyDestructibleUnion other) { return compareToImpl(other); } @Override public int hashCode() { return Arrays.deepHashCode(new Object[] {getSetField(), getFieldValue()}); } }