/** * 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 ComplexUnion extends TUnion { private static final TStruct STRUCT_DESC = new TStruct("ComplexUnion"); private static final TField INT_VALUE_FIELD_DESC = new TField("intValue", TType.I64, (short)1); private static final TField STRING_VALUE_FIELD_DESC = new TField("stringValue", TType.STRING, (short)5); private static final TField INT_LIST_VALUE_FIELD_DESC = new TField("intListValue", TType.LIST, (short)2); private static final TField STRING_LIST_VALUE_FIELD_DESC = new TField("stringListValue", TType.LIST, (short)3); private static final TField TYPEDEF_VALUE_FIELD_DESC = new TField("typedefValue", TType.MAP, (short)9); private static final TField STRING_REF_FIELD_DESC = new TField("stringRef", TType.STRING, (short)14); public static final int INTVALUE = 1; public static final int STRINGVALUE = 5; public static final int INTLISTVALUE = 2; public static final int STRINGLISTVALUE = 3; public static final int TYPEDEFVALUE = 9; public static final int STRINGREF = 14; public static final Map metaDataMap = new HashMap<>(); public ComplexUnion() { super(); } public ComplexUnion(int setField, Object __value) { super(setField, __value); } public ComplexUnion(ComplexUnion other) { super(other); } public ComplexUnion deepCopy() { return new ComplexUnion(this); } public static ComplexUnion intValue(Long __value) { ComplexUnion x = new ComplexUnion(); x.setIntValue(__value); return x; } public static ComplexUnion stringValue(String __value) { ComplexUnion x = new ComplexUnion(); x.setStringValue(__value); return x; } public static ComplexUnion intListValue(List __value) { ComplexUnion x = new ComplexUnion(); x.setIntListValue(__value); return x; } public static ComplexUnion stringListValue(List __value) { ComplexUnion x = new ComplexUnion(); x.setStringListValue(__value); return x; } public static ComplexUnion typedefValue(Map __value) { ComplexUnion x = new ComplexUnion(); x.setTypedefValue(__value); return x; } public static ComplexUnion stringRef(String __value) { ComplexUnion x = new ComplexUnion(); x.setStringRef(__value); return x; } @Override protected Object readValue(TProtocol iprot, TField __field) throws TException { switch (__field.id) { case INTVALUE: if (__field.type == INT_VALUE_FIELD_DESC.type) { Long intValue; intValue = iprot.readI64(); return intValue; } break; case STRINGVALUE: if (__field.type == STRING_VALUE_FIELD_DESC.type) { String stringValue; stringValue = iprot.readString(); return stringValue; } break; case INTLISTVALUE: if (__field.type == INT_LIST_VALUE_FIELD_DESC.type) { List intListValue; { TList _list0 = iprot.readListBegin(); intListValue = new ArrayList(Math.max(0, _list0.size)); for (int _i1 = 0; (_list0.size < 0) ? iprot.peekList() : (_i1 < _list0.size); ++_i1) { Long _elem2; _elem2 = iprot.readI64(); intListValue.add(_elem2); } iprot.readListEnd(); } return intListValue; } break; case STRINGLISTVALUE: if (__field.type == STRING_LIST_VALUE_FIELD_DESC.type) { List stringListValue; { TList _list3 = iprot.readListBegin(); stringListValue = new ArrayList(Math.max(0, _list3.size)); for (int _i4 = 0; (_list3.size < 0) ? iprot.peekList() : (_i4 < _list3.size); ++_i4) { String _elem5; _elem5 = iprot.readString(); stringListValue.add(_elem5); } iprot.readListEnd(); } return stringListValue; } break; case TYPEDEFVALUE: if (__field.type == TYPEDEF_VALUE_FIELD_DESC.type) { Map typedefValue; { TMap _map6 = iprot.readMapBegin(); typedefValue = new HashMap(Math.max(0, 2*_map6.size)); for (int _i7 = 0; (_map6.size < 0) ? iprot.peekMap() : (_i7 < _map6.size); ++_i7) { Short _key8; String _val9; _key8 = iprot.readI16(); _val9 = iprot.readString(); typedefValue.put(_key8, _val9); } iprot.readMapEnd(); } return typedefValue; } break; case STRINGREF: if (__field.type == STRING_REF_FIELD_DESC.type) { String stringRef; stringRef = iprot.readString(); return stringRef; } break; } TProtocolUtil.skip(iprot, __field.type); return null; } @Override protected void writeValue(TProtocol oprot, short setField, Object __value) throws TException { switch (setField) { case INTVALUE: Long intValue = (Long)getFieldValue(); oprot.writeI64(intValue); return; case STRINGVALUE: String stringValue = (String)getFieldValue(); oprot.writeString(stringValue); return; case INTLISTVALUE: List intListValue = (List)getFieldValue(); { oprot.writeListBegin(new TList(TType.I64, intListValue.size())); for (Long _iter10 : intListValue) { oprot.writeI64(_iter10); } oprot.writeListEnd(); } return; case STRINGLISTVALUE: List stringListValue = (List)getFieldValue(); { oprot.writeListBegin(new TList(TType.STRING, stringListValue.size())); for (String _iter11 : stringListValue) { oprot.writeString(_iter11); } oprot.writeListEnd(); } return; case TYPEDEFVALUE: Map typedefValue = (Map)getFieldValue(); { oprot.writeMapBegin(new TMap(TType.I16, TType.STRING, typedefValue.size())); for (Map.Entry _iter12 : typedefValue.entrySet()) { oprot.writeI16(_iter12.getKey()); oprot.writeString(_iter12.getValue()); } oprot.writeMapEnd(); } return; case STRINGREF: String stringRef = (String)getFieldValue(); oprot.writeString(stringRef); return; default: throw new IllegalStateException("Cannot write union with unknown field " + setField); } } @Override protected TField getFieldDesc(int setField) { switch (setField) { case INTVALUE: return INT_VALUE_FIELD_DESC; case STRINGVALUE: return STRING_VALUE_FIELD_DESC; case INTLISTVALUE: return INT_LIST_VALUE_FIELD_DESC; case STRINGLISTVALUE: return STRING_LIST_VALUE_FIELD_DESC; case TYPEDEFVALUE: return TYPEDEF_VALUE_FIELD_DESC; case STRINGREF: return STRING_REF_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 Long getIntValue() { return (Long) __getValue(INTVALUE); } public void setIntValue(Long __value) { __setValue(INTVALUE, __value); } public String getStringValue() { return (String) __getValue(STRINGVALUE); } public void setStringValue(String __value) { __setValue(STRINGVALUE, __value); } public List getIntListValue() { return (List) __getValue(INTLISTVALUE); } public void setIntListValue(List __value) { __setValue(INTLISTVALUE, __value); } public List getStringListValue() { return (List) __getValue(STRINGLISTVALUE); } public void setStringListValue(List __value) { __setValue(STRINGLISTVALUE, __value); } public Map getTypedefValue() { return (Map) __getValue(TYPEDEFVALUE); } public void setTypedefValue(Map __value) { __setValue(TYPEDEFVALUE, __value); } public String getStringRef() { return (String) __getValue(STRINGREF); } public void setStringRef(String __value) { __setValue(STRINGREF, __value); } public boolean equals(Object other) { if (other instanceof ComplexUnion) { return equals((ComplexUnion)other); } else { return false; } } public boolean equals(ComplexUnion other) { return equalsNobinaryImpl(other); } @Override public int hashCode() { return Arrays.deepHashCode(new Object[] {getSetField(), getFieldValue()}); } }