/** * 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 SimpleStruct implements TBase, java.io.Serializable, Cloneable, Comparable { private static final TStruct STRUCT_DESC = new TStruct("SimpleStruct"); private static final TField AGE_FIELD_DESC = new TField("age", TType.I64, (short)1); private static final TField NAME_FIELD_DESC = new TField("name", TType.STRING, (short)2); public long age; public String name; public static final int AGE = 1; public static final int NAME = 2; // isset id assignments private static final int __AGE_ISSET_ID = 0; private BitSet __isset_bit_vector = new BitSet(1); public static final Map metaDataMap; static { Map tmpMetaDataMap = new HashMap(); tmpMetaDataMap.put(AGE, new FieldMetaData("age", TFieldRequirementType.DEFAULT, new FieldValueMetaData(TType.I64))); tmpMetaDataMap.put(NAME, new FieldMetaData("name", TFieldRequirementType.DEFAULT, new FieldValueMetaData(TType.STRING))); metaDataMap = Collections.unmodifiableMap(tmpMetaDataMap); } static { FieldMetaData.addStructMetaDataMap(SimpleStruct.class, metaDataMap); } public SimpleStruct() { this.age = 60L; this.name = "Batman"; } public SimpleStruct( long age, String name) { this(); this.age = age; setAgeIsSet(true); this.name = name; } public static class Builder { private long age; private String name; BitSet __optional_isset = new BitSet(1); public Builder() { } public Builder setAge(final long age) { this.age = age; __optional_isset.set(__AGE_ISSET_ID, true); return this; } public Builder setName(final String name) { this.name = name; return this; } public SimpleStruct build() { SimpleStruct result = new SimpleStruct(); if (__optional_isset.get(__AGE_ISSET_ID)) { result.setAge(this.age); } result.setName(this.name); return result; } } public static Builder builder() { return new Builder(); } /** * Performs a deep copy on other. */ public SimpleStruct(SimpleStruct other) { __isset_bit_vector.clear(); __isset_bit_vector.or(other.__isset_bit_vector); this.age = TBaseHelper.deepCopy(other.age); if (other.isSetName()) { this.name = TBaseHelper.deepCopy(other.name); } } public SimpleStruct deepCopy() { return new SimpleStruct(this); } public long getAge() { return this.age; } public SimpleStruct setAge(long age) { this.age = age; setAgeIsSet(true); return this; } public void unsetAge() { __isset_bit_vector.clear(__AGE_ISSET_ID); } // Returns true if field age is set (has been assigned a value) and false otherwise public boolean isSetAge() { return __isset_bit_vector.get(__AGE_ISSET_ID); } public void setAgeIsSet(boolean __value) { __isset_bit_vector.set(__AGE_ISSET_ID, __value); } public String getName() { return this.name; } public SimpleStruct setName(String name) { this.name = name; return this; } public void unsetName() { this.name = null; } // Returns true if field name is set (has been assigned a value) and false otherwise public boolean isSetName() { return this.name != null; } public void setNameIsSet(boolean __value) { if (!__value) { this.name = null; } } public void setFieldValue(int fieldID, Object __value) { switch (fieldID) { case AGE: if (__value == null) { unsetAge(); } else { setAge((Long)__value); } break; case NAME: if (__value == null) { unsetName(); } else { setName((String)__value); } break; default: throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!"); } } public Object getFieldValue(int fieldID) { switch (fieldID) { case AGE: return new Long(getAge()); case NAME: return getName(); 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 SimpleStruct)) return false; SimpleStruct that = (SimpleStruct)_that; if (!TBaseHelper.equalsNobinary(this.age, that.age)) { return false; } if (!TBaseHelper.equalsNobinary(this.isSetName(), that.isSetName(), this.name, that.name)) { return false; } return true; } @Override public int hashCode() { return Arrays.deepHashCode(new Object[] {age, name}); } @Override public int compareTo(SimpleStruct other) { if (other == null) { // See java.lang.Comparable docs throw new NullPointerException(); } if (other == this) { return 0; } int lastComparison = 0; lastComparison = Boolean.valueOf(isSetAge()).compareTo(other.isSetAge()); if (lastComparison != 0) { return lastComparison; } lastComparison = TBaseHelper.compareTo(age, other.age); if (lastComparison != 0) { return lastComparison; } lastComparison = Boolean.valueOf(isSetName()).compareTo(other.isSetName()); if (lastComparison != 0) { return lastComparison; } lastComparison = TBaseHelper.compareTo(name, other.name); 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 AGE: if (__field.type == TType.I64) { this.age = iprot.readI64(); setAgeIsSet(true); } else { TProtocolUtil.skip(iprot, __field.type); } break; case NAME: if (__field.type == TType.STRING) { this.name = iprot.readString(); } 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); oprot.writeFieldBegin(AGE_FIELD_DESC); oprot.writeI64(this.age); oprot.writeFieldEnd(); if (this.name != null) { oprot.writeFieldBegin(NAME_FIELD_DESC); oprot.writeString(this.name); 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("SimpleStruct"); sb.append(space); sb.append("("); sb.append(newLine); boolean first = true; sb.append(indentStr); sb.append("age"); sb.append(space); sb.append(":").append(space); sb.append(TBaseHelper.toString(this.getAge(), indent + 1, prettyPrint)); first = false; if (!first) sb.append("," + newLine); sb.append(indentStr); sb.append("name"); sb.append(space); sb.append(":").append(space); if (this.getName() == null) { sb.append("null"); } else { sb.append(TBaseHelper.toString(this.getName(), 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 } }