package com.jsoniter.demo.object_with_5_fields; /** * Autogenerated by Thrift Compiler (0.9.1) * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated */ import org.apache.thrift.scheme.IScheme; import org.apache.thrift.scheme.SchemeFactory; import org.apache.thrift.scheme.StandardScheme; import org.apache.thrift.scheme.TupleScheme; import org.apache.thrift.protocol.TTupleProtocol; import org.apache.thrift.protocol.TProtocolException; import org.apache.thrift.EncodingUtils; import org.apache.thrift.TException; import org.apache.thrift.async.AsyncMethodCallback; import org.apache.thrift.server.AbstractNonblockingServer.*; import java.util.List; import java.util.ArrayList; import java.util.Map; import java.util.HashMap; import java.util.EnumMap; import java.util.Set; import java.util.HashSet; import java.util.EnumSet; import java.util.Collections; import java.util.BitSet; import java.nio.ByteBuffer; import java.util.Arrays; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class ThriftTestObject implements org.apache.thrift.TBase<ThriftTestObject, ThriftTestObject._Fields>, java.io.Serializable, Cloneable, Comparable<ThriftTestObject> { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("ThriftTestObject"); private static final org.apache.thrift.protocol.TField FIELD1_FIELD_DESC = new org.apache.thrift.protocol.TField("field1", org.apache.thrift.protocol.TType.STRING, (short)1); private static final org.apache.thrift.protocol.TField FIELD2_FIELD_DESC = new org.apache.thrift.protocol.TField("field2", org.apache.thrift.protocol.TType.STRING, (short)2); private static final org.apache.thrift.protocol.TField FIELD3_FIELD_DESC = new org.apache.thrift.protocol.TField("field3", org.apache.thrift.protocol.TType.STRING, (short)3); private static final org.apache.thrift.protocol.TField FIELD4_FIELD_DESC = new org.apache.thrift.protocol.TField("field4", org.apache.thrift.protocol.TType.STRING, (short)4); private static final org.apache.thrift.protocol.TField FIELD5_FIELD_DESC = new org.apache.thrift.protocol.TField("field5", org.apache.thrift.protocol.TType.STRING, (short)5); private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>(); static { schemes.put(StandardScheme.class, new ThriftTestObjectStandardSchemeFactory()); schemes.put(TupleScheme.class, new ThriftTestObjectTupleSchemeFactory()); } public String field1; // required public String field2; // required public String field3; // required public String field4; // required public String field5; // required /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements org.apache.thrift.TFieldIdEnum { FIELD1((short)1, "field1"), FIELD2((short)2, "field2"), FIELD3((short)3, "field3"), FIELD4((short)4, "field4"), FIELD5((short)5, "field5"); private static final Map<String, _Fields> byName = new HashMap<String, _Fields>(); static { for (_Fields field : EnumSet.allOf(_Fields.class)) { byName.put(field.getFieldName(), field); } } /** * Find the _Fields constant that matches fieldId, or null if its not found. */ public static _Fields findByThriftId(int fieldId) { switch(fieldId) { case 1: // FIELD1 return FIELD1; case 2: // FIELD2 return FIELD2; case 3: // FIELD3 return FIELD3; case 4: // FIELD4 return FIELD4; case 5: // FIELD5 return FIELD5; default: return null; } } /** * Find the _Fields constant that matches fieldId, throwing an exception * if it is not found. */ public static _Fields findByThriftIdOrThrow(int fieldId) { _Fields fields = findByThriftId(fieldId); if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); return fields; } /** * Find the _Fields constant that matches name, or null if its not found. */ public static _Fields findByName(String name) { return byName.get(name); } private final short _thriftId; private final String _fieldName; _Fields(short thriftId, String fieldName) { _thriftId = thriftId; _fieldName = fieldName; } public short getThriftFieldId() { return _thriftId; } public String getFieldName() { return _fieldName; } } // isset id assignments public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; static { Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); tmpMap.put(_Fields.FIELD1, new org.apache.thrift.meta_data.FieldMetaData("field1", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); tmpMap.put(_Fields.FIELD2, new org.apache.thrift.meta_data.FieldMetaData("field2", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); tmpMap.put(_Fields.FIELD3, new org.apache.thrift.meta_data.FieldMetaData("field3", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); tmpMap.put(_Fields.FIELD4, new org.apache.thrift.meta_data.FieldMetaData("field4", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); tmpMap.put(_Fields.FIELD5, new org.apache.thrift.meta_data.FieldMetaData("field5", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); metaDataMap = Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(ThriftTestObject.class, metaDataMap); } public ThriftTestObject() { } public ThriftTestObject( String field1, String field2, String field3, String field4, String field5) { this(); this.field1 = field1; this.field2 = field2; this.field3 = field3; this.field4 = field4; this.field5 = field5; } /** * Performs a deep copy on <i>other</i>. */ public ThriftTestObject(ThriftTestObject other) { if (other.isSetField1()) { this.field1 = other.field1; } if (other.isSetField2()) { this.field2 = other.field2; } if (other.isSetField3()) { this.field3 = other.field3; } if (other.isSetField4()) { this.field4 = other.field4; } if (other.isSetField5()) { this.field5 = other.field5; } } public ThriftTestObject deepCopy() { return new ThriftTestObject(this); } @Override public void clear() { this.field1 = null; this.field2 = null; this.field3 = null; this.field4 = null; this.field5 = null; } public String getField1() { return this.field1; } public ThriftTestObject setField1(String field1) { this.field1 = field1; return this; } public void unsetField1() { this.field1 = null; } /** Returns true if field field1 is set (has been assigned a value) and false otherwise */ public boolean isSetField1() { return this.field1 != null; } public void setField1IsSet(boolean value) { if (!value) { this.field1 = null; } } public String getField2() { return this.field2; } public ThriftTestObject setField2(String field2) { this.field2 = field2; return this; } public void unsetField2() { this.field2 = null; } /** Returns true if field field2 is set (has been assigned a value) and false otherwise */ public boolean isSetField2() { return this.field2 != null; } public void setField2IsSet(boolean value) { if (!value) { this.field2 = null; } } public String getField3() { return this.field3; } public ThriftTestObject setField3(String field3) { this.field3 = field3; return this; } public void unsetField3() { this.field3 = null; } /** Returns true if field field3 is set (has been assigned a value) and false otherwise */ public boolean isSetField3() { return this.field3 != null; } public void setField3IsSet(boolean value) { if (!value) { this.field3 = null; } } public String getField4() { return this.field4; } public ThriftTestObject setField4(String field4) { this.field4 = field4; return this; } public void unsetField4() { this.field4 = null; } /** Returns true if field field4 is set (has been assigned a value) and false otherwise */ public boolean isSetField4() { return this.field4 != null; } public void setField4IsSet(boolean value) { if (!value) { this.field4 = null; } } public String getField5() { return this.field5; } public ThriftTestObject setField5(String field5) { this.field5 = field5; return this; } public void unsetField5() { this.field5 = null; } /** Returns true if field field5 is set (has been assigned a value) and false otherwise */ public boolean isSetField5() { return this.field5 != null; } public void setField5IsSet(boolean value) { if (!value) { this.field5 = null; } } public void setFieldValue(_Fields field, Object value) { switch (field) { case FIELD1: if (value == null) { unsetField1(); } else { setField1((String)value); } break; case FIELD2: if (value == null) { unsetField2(); } else { setField2((String)value); } break; case FIELD3: if (value == null) { unsetField3(); } else { setField3((String)value); } break; case FIELD4: if (value == null) { unsetField4(); } else { setField4((String)value); } break; case FIELD5: if (value == null) { unsetField5(); } else { setField5((String)value); } break; } } public Object getFieldValue(_Fields field) { switch (field) { case FIELD1: return getField1(); case FIELD2: return getField2(); case FIELD3: return getField3(); case FIELD4: return getField4(); case FIELD5: return getField5(); } throw new IllegalStateException(); } /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ public boolean isSet(_Fields field) { if (field == null) { throw new IllegalArgumentException(); } switch (field) { case FIELD1: return isSetField1(); case FIELD2: return isSetField2(); case FIELD3: return isSetField3(); case FIELD4: return isSetField4(); case FIELD5: return isSetField5(); } throw new IllegalStateException(); } @Override public boolean equals(Object that) { if (that == null) return false; if (that instanceof ThriftTestObject) return this.equals((ThriftTestObject)that); return false; } public boolean equals(ThriftTestObject that) { if (that == null) return false; boolean this_present_field1 = true && this.isSetField1(); boolean that_present_field1 = true && that.isSetField1(); if (this_present_field1 || that_present_field1) { if (!(this_present_field1 && that_present_field1)) return false; if (!this.field1.equals(that.field1)) return false; } boolean this_present_field2 = true && this.isSetField2(); boolean that_present_field2 = true && that.isSetField2(); if (this_present_field2 || that_present_field2) { if (!(this_present_field2 && that_present_field2)) return false; if (!this.field2.equals(that.field2)) return false; } boolean this_present_field3 = true && this.isSetField3(); boolean that_present_field3 = true && that.isSetField3(); if (this_present_field3 || that_present_field3) { if (!(this_present_field3 && that_present_field3)) return false; if (!this.field3.equals(that.field3)) return false; } boolean this_present_field4 = true && this.isSetField4(); boolean that_present_field4 = true && that.isSetField4(); if (this_present_field4 || that_present_field4) { if (!(this_present_field4 && that_present_field4)) return false; if (!this.field4.equals(that.field4)) return false; } boolean this_present_field5 = true && this.isSetField5(); boolean that_present_field5 = true && that.isSetField5(); if (this_present_field5 || that_present_field5) { if (!(this_present_field5 && that_present_field5)) return false; if (!this.field5.equals(that.field5)) return false; } return true; } @Override public int hashCode() { return 0; } @Override public int compareTo(ThriftTestObject other) { if (!getClass().equals(other.getClass())) { return getClass().getName().compareTo(other.getClass().getName()); } int lastComparison = 0; lastComparison = Boolean.valueOf(isSetField1()).compareTo(other.isSetField1()); if (lastComparison != 0) { return lastComparison; } if (isSetField1()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.field1, other.field1); if (lastComparison != 0) { return lastComparison; } } lastComparison = Boolean.valueOf(isSetField2()).compareTo(other.isSetField2()); if (lastComparison != 0) { return lastComparison; } if (isSetField2()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.field2, other.field2); if (lastComparison != 0) { return lastComparison; } } lastComparison = Boolean.valueOf(isSetField3()).compareTo(other.isSetField3()); if (lastComparison != 0) { return lastComparison; } if (isSetField3()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.field3, other.field3); if (lastComparison != 0) { return lastComparison; } } lastComparison = Boolean.valueOf(isSetField4()).compareTo(other.isSetField4()); if (lastComparison != 0) { return lastComparison; } if (isSetField4()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.field4, other.field4); if (lastComparison != 0) { return lastComparison; } } lastComparison = Boolean.valueOf(isSetField5()).compareTo(other.isSetField5()); if (lastComparison != 0) { return lastComparison; } if (isSetField5()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.field5, other.field5); if (lastComparison != 0) { return lastComparison; } } return 0; } public _Fields fieldForId(int fieldId) { return _Fields.findByThriftId(fieldId); } public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { schemes.get(iprot.getScheme()).getScheme().read(iprot, this); } public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { schemes.get(oprot.getScheme()).getScheme().write(oprot, this); } @Override public String toString() { StringBuilder sb = new StringBuilder("ThriftTestObject("); boolean first = true; sb.append("field1:"); if (this.field1 == null) { sb.append("null"); } else { sb.append(this.field1); } first = false; if (!first) sb.append(", "); sb.append("field2:"); if (this.field2 == null) { sb.append("null"); } else { sb.append(this.field2); } first = false; if (!first) sb.append(", "); sb.append("field3:"); if (this.field3 == null) { sb.append("null"); } else { sb.append(this.field3); } first = false; if (!first) sb.append(", "); sb.append("field4:"); if (this.field4 == null) { sb.append("null"); } else { sb.append(this.field4); } first = false; if (!first) sb.append(", "); sb.append("field5:"); if (this.field5 == null) { sb.append("null"); } else { sb.append(this.field5); } first = false; sb.append(")"); return sb.toString(); } public void validate() throws org.apache.thrift.TException { // check for required fields // check for sub-struct validity } private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { try { write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { try { read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private static class ThriftTestObjectStandardSchemeFactory implements SchemeFactory { public ThriftTestObjectStandardScheme getScheme() { return new ThriftTestObjectStandardScheme(); } } private static class ThriftTestObjectStandardScheme extends StandardScheme<ThriftTestObject> { public void read(org.apache.thrift.protocol.TProtocol iprot, ThriftTestObject struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TField schemeField; iprot.readStructBegin(); while (true) { schemeField = iprot.readFieldBegin(); if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { break; } switch (schemeField.id) { case 1: // FIELD1 if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { struct.field1 = iprot.readString(); struct.setField1IsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 2: // FIELD2 if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { struct.field2 = iprot.readString(); struct.setField2IsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 3: // FIELD3 if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { struct.field3 = iprot.readString(); struct.setField3IsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 4: // FIELD4 if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { struct.field4 = iprot.readString(); struct.setField4IsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 5: // FIELD5 if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { struct.field5 = iprot.readString(); struct.setField5IsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; default: org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } iprot.readFieldEnd(); } iprot.readStructEnd(); // check for required fields of primitive type, which can't be checked in the validate method struct.validate(); } public void write(org.apache.thrift.protocol.TProtocol oprot, ThriftTestObject struct) throws org.apache.thrift.TException { struct.validate(); oprot.writeStructBegin(STRUCT_DESC); if (struct.field1 != null) { oprot.writeFieldBegin(FIELD1_FIELD_DESC); oprot.writeString(struct.field1); oprot.writeFieldEnd(); } if (struct.field2 != null) { oprot.writeFieldBegin(FIELD2_FIELD_DESC); oprot.writeString(struct.field2); oprot.writeFieldEnd(); } if (struct.field3 != null) { oprot.writeFieldBegin(FIELD3_FIELD_DESC); oprot.writeString(struct.field3); oprot.writeFieldEnd(); } if (struct.field4 != null) { oprot.writeFieldBegin(FIELD4_FIELD_DESC); oprot.writeString(struct.field4); oprot.writeFieldEnd(); } if (struct.field5 != null) { oprot.writeFieldBegin(FIELD5_FIELD_DESC); oprot.writeString(struct.field5); oprot.writeFieldEnd(); } oprot.writeFieldStop(); oprot.writeStructEnd(); } } private static class ThriftTestObjectTupleSchemeFactory implements SchemeFactory { public ThriftTestObjectTupleScheme getScheme() { return new ThriftTestObjectTupleScheme(); } } private static class ThriftTestObjectTupleScheme extends TupleScheme<ThriftTestObject> { @Override public void write(org.apache.thrift.protocol.TProtocol prot, ThriftTestObject struct) throws org.apache.thrift.TException { TTupleProtocol oprot = (TTupleProtocol) prot; BitSet optionals = new BitSet(); if (struct.isSetField1()) { optionals.set(0); } if (struct.isSetField2()) { optionals.set(1); } if (struct.isSetField3()) { optionals.set(2); } if (struct.isSetField4()) { optionals.set(3); } if (struct.isSetField5()) { optionals.set(4); } oprot.writeBitSet(optionals, 5); if (struct.isSetField1()) { oprot.writeString(struct.field1); } if (struct.isSetField2()) { oprot.writeString(struct.field2); } if (struct.isSetField3()) { oprot.writeString(struct.field3); } if (struct.isSetField4()) { oprot.writeString(struct.field4); } if (struct.isSetField5()) { oprot.writeString(struct.field5); } } @Override public void read(org.apache.thrift.protocol.TProtocol prot, ThriftTestObject struct) throws org.apache.thrift.TException { TTupleProtocol iprot = (TTupleProtocol) prot; BitSet incoming = iprot.readBitSet(5); if (incoming.get(0)) { struct.field1 = iprot.readString(); struct.setField1IsSet(true); } if (incoming.get(1)) { struct.field2 = iprot.readString(); struct.setField2IsSet(true); } if (incoming.get(2)) { struct.field3 = iprot.readString(); struct.setField3IsSet(true); } if (incoming.get(3)) { struct.field4 = iprot.readString(); struct.setField4IsSet(true); } if (incoming.get(4)) { struct.field5 = iprot.readString(); struct.setField5IsSet(true); } } } }