1 /**
2  * Autogenerated by Thrift
3  *
4  * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
5  *  @generated
6  */
7 import java.util.List;
8 import java.util.ArrayList;
9 import java.util.Map;
10 import java.util.HashMap;
11 import java.util.Set;
12 import java.util.HashSet;
13 import java.util.Collections;
14 import java.util.BitSet;
15 import java.util.Arrays;
16 import com.facebook.thrift.*;
17 import com.facebook.thrift.annotations.*;
18 import com.facebook.thrift.async.*;
19 import com.facebook.thrift.meta_data.*;
20 import com.facebook.thrift.server.*;
21 import com.facebook.thrift.transport.*;
22 import com.facebook.thrift.protocol.*;
23 
24 @SuppressWarnings({ "unused", "serial", "unchecked" })
25 public class ListUnion extends TUnion<ListUnion> {
26   private static final TStruct STRUCT_DESC = new TStruct("ListUnion");
27   private static final TField INT_LIST_VALUE_FIELD_DESC = new TField("intListValue", TType.LIST, (short)2);
28   private static final TField STRING_LIST_VALUE_FIELD_DESC = new TField("stringListValue", TType.LIST, (short)3);
29 
30   public static final int INTLISTVALUE = 2;
31   public static final int STRINGLISTVALUE = 3;
32 
33   public static final Map<Integer, FieldMetaData> metaDataMap = new HashMap<>();
34 
ListUnion()35   public ListUnion() {
36     super();
37   }
38 
ListUnion(int setField, Object __value)39   public ListUnion(int setField, Object __value) {
40     super(setField, __value);
41   }
42 
ListUnion(ListUnion other)43   public ListUnion(ListUnion other) {
44     super(other);
45   }
46 
deepCopy()47   public ListUnion deepCopy() {
48     return new ListUnion(this);
49   }
50 
intListValue(List<Long> __value)51   public static ListUnion intListValue(List<Long> __value) {
52     ListUnion x = new ListUnion();
53     x.setIntListValue(__value);
54     return x;
55   }
56 
stringListValue(List<String> __value)57   public static ListUnion stringListValue(List<String> __value) {
58     ListUnion x = new ListUnion();
59     x.setStringListValue(__value);
60     return x;
61   }
62 
63 
64   @Override
readValue(TProtocol iprot, TField __field)65   protected Object readValue(TProtocol iprot, TField __field) throws TException {
66     switch (__field.id) {
67       case INTLISTVALUE:
68         if (__field.type == INT_LIST_VALUE_FIELD_DESC.type) {
69           List<Long> intListValue;
70           {
71             TList _list13 = iprot.readListBegin();
72             intListValue = new ArrayList<Long>(Math.max(0, _list13.size));
73             for (int _i14 = 0;
74                  (_list13.size < 0) ? iprot.peekList() : (_i14 < _list13.size);
75                  ++_i14)
76             {
77               Long _elem15;
78               _elem15 = iprot.readI64();
79               intListValue.add(_elem15);
80             }
81             iprot.readListEnd();
82           }
83           return intListValue;
84         }
85         break;
86       case STRINGLISTVALUE:
87         if (__field.type == STRING_LIST_VALUE_FIELD_DESC.type) {
88           List<String> stringListValue;
89           {
90             TList _list16 = iprot.readListBegin();
91             stringListValue = new ArrayList<String>(Math.max(0, _list16.size));
92             for (int _i17 = 0;
93                  (_list16.size < 0) ? iprot.peekList() : (_i17 < _list16.size);
94                  ++_i17)
95             {
96               String _elem18;
97               _elem18 = iprot.readString();
98               stringListValue.add(_elem18);
99             }
100             iprot.readListEnd();
101           }
102           return stringListValue;
103         }
104         break;
105     }
106     TProtocolUtil.skip(iprot, __field.type);
107     return null;
108   }
109 
110   @Override
writeValue(TProtocol oprot, short setField, Object __value)111   protected void writeValue(TProtocol oprot, short setField, Object __value) throws TException {
112     switch (setField) {
113       case INTLISTVALUE:
114         List<Long> intListValue = (List<Long>)getFieldValue();
115         {
116           oprot.writeListBegin(new TList(TType.I64, intListValue.size()));
117           for (Long _iter19 : intListValue)          {
118             oprot.writeI64(_iter19);
119           }
120           oprot.writeListEnd();
121         }
122         return;
123       case STRINGLISTVALUE:
124         List<String> stringListValue = (List<String>)getFieldValue();
125         {
126           oprot.writeListBegin(new TList(TType.STRING, stringListValue.size()));
127           for (String _iter20 : stringListValue)          {
128             oprot.writeString(_iter20);
129           }
130           oprot.writeListEnd();
131         }
132         return;
133       default:
134         throw new IllegalStateException("Cannot write union with unknown field " + setField);
135     }
136   }
137 
138   @Override
getFieldDesc(int setField)139   protected TField getFieldDesc(int setField) {
140     switch (setField) {
141       case INTLISTVALUE:
142         return INT_LIST_VALUE_FIELD_DESC;
143       case STRINGLISTVALUE:
144         return STRING_LIST_VALUE_FIELD_DESC;
145       default:
146         throw new IllegalArgumentException("Unknown field id " + setField);
147     }
148   }
149 
150   @Override
getStructDesc()151   protected TStruct getStructDesc() {
152     return STRUCT_DESC;
153   }
154 
155   @Override
getMetaDataMap()156   protected Map<Integer, FieldMetaData> getMetaDataMap() { return metaDataMap; }
157 
__getValue(int expectedFieldId)158   private Object __getValue(int expectedFieldId) {
159     if (getSetField() == expectedFieldId) {
160       return getFieldValue();
161     } else {
162       throw new RuntimeException("Cannot get field '" + getFieldDesc(expectedFieldId).name + "' because union is currently set to " + getFieldDesc(getSetField()).name);
163     }
164   }
165 
__setValue(int fieldId, Object __value)166   private void __setValue(int fieldId, Object __value) {
167     if (__value == null) throw new NullPointerException();
168     setField_ = fieldId;
169     value_ = __value;
170   }
171 
getIntListValue()172   public List<Long> getIntListValue() {
173     return (List<Long>) __getValue(INTLISTVALUE);
174   }
175 
setIntListValue(List<Long> __value)176   public void setIntListValue(List<Long> __value) {
177     __setValue(INTLISTVALUE, __value);
178   }
179 
getStringListValue()180   public List<String> getStringListValue() {
181     return (List<String>) __getValue(STRINGLISTVALUE);
182   }
183 
setStringListValue(List<String> __value)184   public void setStringListValue(List<String> __value) {
185     __setValue(STRINGLISTVALUE, __value);
186   }
187 
equals(Object other)188   public boolean equals(Object other) {
189     if (other instanceof ListUnion) {
190       return equals((ListUnion)other);
191     } else {
192       return false;
193     }
194   }
195 
equals(ListUnion other)196   public boolean equals(ListUnion other) {
197     return equalsNobinaryImpl(other);
198   }
199 
200 
201   @Override
hashCode()202   public int hashCode() {
203     return Arrays.deepHashCode(new Object[] {getSetField(), getFieldValue()});
204   }
205 
206 }
207