/** * 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" }) public class StructWithBox implements TBase, java.io.Serializable, Cloneable, Comparable { private static final TStruct STRUCT_DESC = new TStruct("StructWithBox"); private static final TField A_FIELD_DESC = new TField("a", TType.STRING, (short)1); private static final TField B_FIELD_DESC = new TField("b", TType.LIST, (short)2); private static final TField C_FIELD_DESC = new TField("c", TType.STRUCT, (short)3); public String a; public List b; public StructWithRef c; public static final int A = 1; public static final int B = 2; public static final int C = 3; // isset id assignments public static final Map metaDataMap; static { Map tmpMetaDataMap = new HashMap(); tmpMetaDataMap.put(A, new FieldMetaData("a", TFieldRequirementType.OPTIONAL, new FieldValueMetaData(TType.STRING))); tmpMetaDataMap.put(B, new FieldMetaData("b", TFieldRequirementType.OPTIONAL, new ListMetaData(TType.LIST, new FieldValueMetaData(TType.I64)))); tmpMetaDataMap.put(C, new FieldMetaData("c", TFieldRequirementType.OPTIONAL, new StructMetaData(TType.STRUCT, StructWithRef.class))); metaDataMap = Collections.unmodifiableMap(tmpMetaDataMap); } static { FieldMetaData.addStructMetaDataMap(StructWithBox.class, metaDataMap); } public StructWithBox() { } public StructWithBox( String a, List b, StructWithRef c) { this(); this.a = a; this.b = b; this.c = c; } public static class Builder { private String a; private List b; private StructWithRef c; public Builder() { } public Builder setA(final String a) { this.a = a; return this; } public Builder setB(final List b) { this.b = b; return this; } public Builder setC(final StructWithRef c) { this.c = c; return this; } public StructWithBox build() { StructWithBox result = new StructWithBox(); result.setA(this.a); result.setB(this.b); result.setC(this.c); return result; } } public static Builder builder() { return new Builder(); } /** * Performs a deep copy on other. */ public StructWithBox(StructWithBox other) { if (other.isSetA()) { this.a = TBaseHelper.deepCopy(other.a); } if (other.isSetB()) { this.b = TBaseHelper.deepCopy(other.b); } if (other.isSetC()) { this.c = TBaseHelper.deepCopy(other.c); } } public StructWithBox deepCopy() { return new StructWithBox(this); } public String getA() { return this.a; } public StructWithBox setA(String a) { this.a = a; return this; } public void unsetA() { this.a = null; } // Returns true if field a is set (has been assigned a value) and false otherwise public boolean isSetA() { return this.a != null; } public void setAIsSet(boolean __value) { if (!__value) { this.a = null; } } public List getB() { return this.b; } public StructWithBox setB(List b) { this.b = b; return this; } public void unsetB() { this.b = null; } // Returns true if field b is set (has been assigned a value) and false otherwise public boolean isSetB() { return this.b != null; } public void setBIsSet(boolean __value) { if (!__value) { this.b = null; } } public StructWithRef getC() { return this.c; } public StructWithBox setC(StructWithRef c) { this.c = c; return this; } public void unsetC() { this.c = null; } // Returns true if field c is set (has been assigned a value) and false otherwise public boolean isSetC() { return this.c != null; } public void setCIsSet(boolean __value) { if (!__value) { this.c = null; } } @SuppressWarnings("unchecked") public void setFieldValue(int fieldID, Object __value) { switch (fieldID) { case A: if (__value == null) { unsetA(); } else { setA((String)__value); } break; case B: if (__value == null) { unsetB(); } else { setB((List)__value); } break; case C: if (__value == null) { unsetC(); } else { setC((StructWithRef)__value); } break; default: throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!"); } } public Object getFieldValue(int fieldID) { switch (fieldID) { case A: return getA(); case B: return getB(); case C: return getC(); default: throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!"); } } @Override public boolean equals(Object _that) { if (_that == null) return false; if (this == _that) return true; if (!(_that instanceof StructWithBox)) return false; StructWithBox that = (StructWithBox)_that; if (!TBaseHelper.equalsNobinary(this.isSetA(), that.isSetA(), this.a, that.a)) { return false; } if (!TBaseHelper.equalsNobinary(this.isSetB(), that.isSetB(), this.b, that.b)) { return false; } if (!TBaseHelper.equalsNobinary(this.isSetC(), that.isSetC(), this.c, that.c)) { return false; } return true; } @Override public int hashCode() { return Arrays.deepHashCode(new Object[] {a, b, c}); } @Override public int compareTo(StructWithBox other) { if (other == null) { // See java.lang.Comparable docs throw new NullPointerException(); } if (other == this) { return 0; } int lastComparison = 0; lastComparison = Boolean.valueOf(isSetA()).compareTo(other.isSetA()); if (lastComparison != 0) { return lastComparison; } lastComparison = TBaseHelper.compareTo(a, other.a); if (lastComparison != 0) { return lastComparison; } lastComparison = Boolean.valueOf(isSetB()).compareTo(other.isSetB()); if (lastComparison != 0) { return lastComparison; } lastComparison = TBaseHelper.compareTo(b, other.b); if (lastComparison != 0) { return lastComparison; } lastComparison = Boolean.valueOf(isSetC()).compareTo(other.isSetC()); if (lastComparison != 0) { return lastComparison; } lastComparison = TBaseHelper.compareTo(c, other.c); if (lastComparison != 0) { return lastComparison; } return 0; } public void read(TProtocol iprot) throws TException { TField __field; iprot.readStructBegin(metaDataMap); while (true) { __field = iprot.readFieldBegin(); if (__field.type == TType.STOP) { break; } switch (__field.id) { case A: if (__field.type == TType.STRING) { this.a = iprot.readString(); } else { TProtocolUtil.skip(iprot, __field.type); } break; case B: if (__field.type == TType.LIST) { { TList _list41 = iprot.readListBegin(); this.b = new ArrayList(Math.max(0, _list41.size)); for (int _i42 = 0; (_list41.size < 0) ? iprot.peekList() : (_i42 < _list41.size); ++_i42) { long _elem43; _elem43 = iprot.readI64(); this.b.add(_elem43); } iprot.readListEnd(); } } else { TProtocolUtil.skip(iprot, __field.type); } break; case C: if (__field.type == TType.STRUCT) { this.c = new StructWithRef(); this.c.read(iprot); } else { TProtocolUtil.skip(iprot, __field.type); } break; default: TProtocolUtil.skip(iprot, __field.type); break; } iprot.readFieldEnd(); } iprot.readStructEnd(); // check for required fields of primitive type, which can't be checked in the validate method validate(); } public void write(TProtocol oprot) throws TException { validate(); oprot.writeStructBegin(STRUCT_DESC); if (this.a != null) { if (isSetA()) { oprot.writeFieldBegin(A_FIELD_DESC); oprot.writeString(this.a); oprot.writeFieldEnd(); } } if (this.b != null) { if (isSetB()) { oprot.writeFieldBegin(B_FIELD_DESC); { oprot.writeListBegin(new TList(TType.I64, this.b.size())); for (long _iter44 : this.b) { oprot.writeI64(_iter44); } oprot.writeListEnd(); } oprot.writeFieldEnd(); } } if (this.c != null) { if (isSetC()) { oprot.writeFieldBegin(C_FIELD_DESC); this.c.write(oprot); oprot.writeFieldEnd(); } } oprot.writeFieldStop(); oprot.writeStructEnd(); } @Override public String toString() { return toString(1, true); } @Override public String toString(int indent, boolean prettyPrint) { String indentStr = prettyPrint ? TBaseHelper.getIndentedString(indent) : ""; String newLine = prettyPrint ? "\n" : ""; String space = prettyPrint ? " " : ""; StringBuilder sb = new StringBuilder("StructWithBox"); sb.append(space); sb.append("("); sb.append(newLine); boolean first = true; if (isSetA()) { sb.append(indentStr); sb.append("a"); sb.append(space); sb.append(":").append(space); if (this.getA() == null) { sb.append("null"); } else { sb.append(TBaseHelper.toString(this.getA(), indent + 1, prettyPrint)); } first = false; } if (isSetB()) { if (!first) sb.append("," + newLine); sb.append(indentStr); sb.append("b"); sb.append(space); sb.append(":").append(space); if (this.getB() == null) { sb.append("null"); } else { sb.append(TBaseHelper.toString(this.getB(), indent + 1, prettyPrint)); } first = false; } if (isSetC()) { if (!first) sb.append("," + newLine); sb.append(indentStr); sb.append("c"); sb.append(space); sb.append(":").append(space); if (this.getC() == null) { sb.append("null"); } else { sb.append(TBaseHelper.toString(this.getC(), indent + 1, prettyPrint)); } first = false; } sb.append(newLine + TBaseHelper.reduceIndent(indentStr)); sb.append(")"); return sb.toString(); } public void validate() throws TException { // check for required fields } }