/** * 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 VirtualComplexUnion extends TUnion { private static final TStruct STRUCT_DESC = new TStruct("VirtualComplexUnion"); private static final TField THING_ONE_FIELD_DESC = new TField("thingOne", TType.STRING, (short)1); private static final TField THING_TWO_FIELD_DESC = new TField("thingTwo", TType.STRING, (short)2); public static final int THINGONE = 1; public static final int THINGTWO = 2; public static final Map metaDataMap = new HashMap<>(); public VirtualComplexUnion() { super(); } public VirtualComplexUnion(int setField, Object __value) { super(setField, __value); } public VirtualComplexUnion(VirtualComplexUnion other) { super(other); } public VirtualComplexUnion deepCopy() { return new VirtualComplexUnion(this); } public static VirtualComplexUnion thingOne(String __value) { VirtualComplexUnion x = new VirtualComplexUnion(); x.setThingOne(__value); return x; } public static VirtualComplexUnion thingTwo(String __value) { VirtualComplexUnion x = new VirtualComplexUnion(); x.setThingTwo(__value); return x; } @Override protected Object readValue(TProtocol iprot, TField __field) throws TException { switch (__field.id) { case THINGONE: if (__field.type == THING_ONE_FIELD_DESC.type) { String thingOne; thingOne = iprot.readString(); return thingOne; } break; case THINGTWO: if (__field.type == THING_TWO_FIELD_DESC.type) { String thingTwo; thingTwo = iprot.readString(); return thingTwo; } break; } TProtocolUtil.skip(iprot, __field.type); return null; } @Override protected void writeValue(TProtocol oprot, short setField, Object __value) throws TException { switch (setField) { case THINGONE: String thingOne = (String)getFieldValue(); oprot.writeString(thingOne); return; case THINGTWO: String thingTwo = (String)getFieldValue(); oprot.writeString(thingTwo); return; default: throw new IllegalStateException("Cannot write union with unknown field " + setField); } } @Override protected TField getFieldDesc(int setField) { switch (setField) { case THINGONE: return THING_ONE_FIELD_DESC; case THINGTWO: return THING_TWO_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 String getThingOne() { return (String) __getValue(THINGONE); } public void setThingOne(String __value) { __setValue(THINGONE, __value); } public String getThingTwo() { return (String) __getValue(THINGTWO); } public void setThingTwo(String __value) { __setValue(THINGTWO, __value); } public boolean equals(Object other) { if (other instanceof VirtualComplexUnion) { return equals((VirtualComplexUnion)other); } else { return false; } } public boolean equals(VirtualComplexUnion other) { return equalsNobinaryImpl(other); } @Override public int hashCode() { return Arrays.deepHashCode(new Object[] {getSetField(), getFieldValue()}); } }