/** * Autogenerated by Thrift Compiler (0.9.1) * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated */ package edu.usc.pgroup.floe.thriftgen; import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.thrift.protocol.TTupleProtocol; 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 java.nio.ByteBuffer; import java.util.Collections; import java.util.EnumMap; import java.util.EnumSet; import java.util.HashMap; import java.util.Map; public class TSignal implements org.apache.thrift.TBase<TSignal, TSignal._Fields>, java.io.Serializable, Cloneable, Comparable<TSignal> { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TSignal"); private static final org.apache.thrift.protocol.TField DEST_APP_FIELD_DESC = new org.apache.thrift.protocol.TField("destApp", org.apache.thrift.protocol.TType.STRING, (short)1); private static final org.apache.thrift.protocol.TField DEST_PELLET_FIELD_DESC = new org.apache.thrift.protocol.TField("destPellet", org.apache.thrift.protocol.TType.STRING, (short)2); private static final org.apache.thrift.protocol.TField DATA_FIELD_DESC = new org.apache.thrift.protocol.TField("data", org.apache.thrift.protocol.TType.STRING, (short)3); private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>(); static { schemes.put(StandardScheme.class, new TSignalStandardSchemeFactory()); schemes.put(TupleScheme.class, new TSignalTupleSchemeFactory()); } private String destApp; // required private String destPellet; // required private ByteBuffer data; // 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 { DEST_APP((short)1, "destApp"), DEST_PELLET((short)2, "destPellet"), DATA((short)3, "data"); 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: // DEST_APP return DEST_APP; case 2: // DEST_PELLET return DEST_PELLET; case 3: // DATA return DATA; 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.DEST_APP, new org.apache.thrift.meta_data.FieldMetaData("destApp", org.apache.thrift.TFieldRequirementType.REQUIRED, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); tmpMap.put(_Fields.DEST_PELLET, new org.apache.thrift.meta_data.FieldMetaData("destPellet", org.apache.thrift.TFieldRequirementType.REQUIRED, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); tmpMap.put(_Fields.DATA, new org.apache.thrift.meta_data.FieldMetaData("data", org.apache.thrift.TFieldRequirementType.REQUIRED, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING , true))); metaDataMap = Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TSignal.class, metaDataMap); } public TSignal() { } public TSignal( String destApp, String destPellet, ByteBuffer data) { this(); this.destApp = destApp; this.destPellet = destPellet; this.data = data; } /** * Performs a deep copy on <i>other</i>. */ public TSignal(TSignal other) { if (other.is_set_destApp()) { this.destApp = other.destApp; } if (other.is_set_destPellet()) { this.destPellet = other.destPellet; } if (other.is_set_data()) { this.data = org.apache.thrift.TBaseHelper.copyBinary(other.data); ; } } public TSignal deepCopy() { return new TSignal(this); } @Override public void clear() { this.destApp = null; this.destPellet = null; this.data = null; } public String get_destApp() { return this.destApp; } public void set_destApp(String destApp) { this.destApp = destApp; } public void unset_destApp() { this.destApp = null; } /** Returns true if field destApp is set (has been assigned a value) and false otherwise */ public boolean is_set_destApp() { return this.destApp != null; } public void set_destApp_isSet(boolean value) { if (!value) { this.destApp = null; } } public String get_destPellet() { return this.destPellet; } public void set_destPellet(String destPellet) { this.destPellet = destPellet; } public void unset_destPellet() { this.destPellet = null; } /** Returns true if field destPellet is set (has been assigned a value) and false otherwise */ public boolean is_set_destPellet() { return this.destPellet != null; } public void set_destPellet_isSet(boolean value) { if (!value) { this.destPellet = null; } } public byte[] get_data() { set_data(org.apache.thrift.TBaseHelper.rightSize(data)); return data == null ? null : data.array(); } public ByteBuffer buffer_for_data() { return data; } public void set_data(byte[] data) { set_data(data == null ? (ByteBuffer)null : ByteBuffer.wrap(data)); } public void set_data(ByteBuffer data) { this.data = data; } public void unset_data() { this.data = null; } /** Returns true if field data is set (has been assigned a value) and false otherwise */ public boolean is_set_data() { return this.data != null; } public void set_data_isSet(boolean value) { if (!value) { this.data = null; } } public void setFieldValue(_Fields field, Object value) { switch (field) { case DEST_APP: if (value == null) { unset_destApp(); } else { set_destApp((String)value); } break; case DEST_PELLET: if (value == null) { unset_destPellet(); } else { set_destPellet((String)value); } break; case DATA: if (value == null) { unset_data(); } else { set_data((ByteBuffer)value); } break; } } public Object getFieldValue(_Fields field) { switch (field) { case DEST_APP: return get_destApp(); case DEST_PELLET: return get_destPellet(); case DATA: return get_data(); } 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 DEST_APP: return is_set_destApp(); case DEST_PELLET: return is_set_destPellet(); case DATA: return is_set_data(); } throw new IllegalStateException(); } @Override public boolean equals(Object that) { if (that == null) return false; if (that instanceof TSignal) return this.equals((TSignal)that); return false; } public boolean equals(TSignal that) { if (that == null) return false; boolean this_present_destApp = true && this.is_set_destApp(); boolean that_present_destApp = true && that.is_set_destApp(); if (this_present_destApp || that_present_destApp) { if (!(this_present_destApp && that_present_destApp)) return false; if (!this.destApp.equals(that.destApp)) return false; } boolean this_present_destPellet = true && this.is_set_destPellet(); boolean that_present_destPellet = true && that.is_set_destPellet(); if (this_present_destPellet || that_present_destPellet) { if (!(this_present_destPellet && that_present_destPellet)) return false; if (!this.destPellet.equals(that.destPellet)) return false; } boolean this_present_data = true && this.is_set_data(); boolean that_present_data = true && that.is_set_data(); if (this_present_data || that_present_data) { if (!(this_present_data && that_present_data)) return false; if (!this.data.equals(that.data)) return false; } return true; } @Override public int hashCode() { HashCodeBuilder builder = new HashCodeBuilder(); boolean present_destApp = true && (is_set_destApp()); builder.append(present_destApp); if (present_destApp) builder.append(destApp); boolean present_destPellet = true && (is_set_destPellet()); builder.append(present_destPellet); if (present_destPellet) builder.append(destPellet); boolean present_data = true && (is_set_data()); builder.append(present_data); if (present_data) builder.append(data); return builder.toHashCode(); } @Override public int compareTo(TSignal other) { if (!getClass().equals(other.getClass())) { return getClass().getName().compareTo(other.getClass().getName()); } int lastComparison = 0; lastComparison = Boolean.valueOf(is_set_destApp()).compareTo(other.is_set_destApp()); if (lastComparison != 0) { return lastComparison; } if (is_set_destApp()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.destApp, other.destApp); if (lastComparison != 0) { return lastComparison; } } lastComparison = Boolean.valueOf(is_set_destPellet()).compareTo(other.is_set_destPellet()); if (lastComparison != 0) { return lastComparison; } if (is_set_destPellet()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.destPellet, other.destPellet); if (lastComparison != 0) { return lastComparison; } } lastComparison = Boolean.valueOf(is_set_data()).compareTo(other.is_set_data()); if (lastComparison != 0) { return lastComparison; } if (is_set_data()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.data, other.data); 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("TSignal("); boolean first = true; sb.append("destApp:"); if (this.destApp == null) { sb.append("null"); } else { sb.append(this.destApp); } first = false; if (!first) sb.append(", "); sb.append("destPellet:"); if (this.destPellet == null) { sb.append("null"); } else { sb.append(this.destPellet); } first = false; if (!first) sb.append(", "); sb.append("data:"); if (this.data == null) { sb.append("null"); } else { org.apache.thrift.TBaseHelper.toString(this.data, sb); } first = false; sb.append(")"); return sb.toString(); } public void validate() throws org.apache.thrift.TException { // check for required fields if (!is_set_destApp()) { throw new org.apache.thrift.protocol.TProtocolException("Required field 'destApp' is unset! Struct:" + toString()); } if (!is_set_destPellet()) { throw new org.apache.thrift.protocol.TProtocolException("Required field 'destPellet' is unset! Struct:" + toString()); } if (!is_set_data()) { throw new org.apache.thrift.protocol.TProtocolException("Required field 'data' is unset! Struct:" + toString()); } // 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 TSignalStandardSchemeFactory implements SchemeFactory { public TSignalStandardScheme getScheme() { return new TSignalStandardScheme(); } } private static class TSignalStandardScheme extends StandardScheme<TSignal> { public void read(org.apache.thrift.protocol.TProtocol iprot, TSignal 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: // DEST_APP if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { struct.destApp = iprot.readString(); struct.set_destApp_isSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 2: // DEST_PELLET if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { struct.destPellet = iprot.readString(); struct.set_destPellet_isSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 3: // DATA if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { struct.data = iprot.readBinary(); struct.set_data_isSet(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(); struct.validate(); } public void write(org.apache.thrift.protocol.TProtocol oprot, TSignal struct) throws org.apache.thrift.TException { struct.validate(); oprot.writeStructBegin(STRUCT_DESC); if (struct.destApp != null) { oprot.writeFieldBegin(DEST_APP_FIELD_DESC); oprot.writeString(struct.destApp); oprot.writeFieldEnd(); } if (struct.destPellet != null) { oprot.writeFieldBegin(DEST_PELLET_FIELD_DESC); oprot.writeString(struct.destPellet); oprot.writeFieldEnd(); } if (struct.data != null) { oprot.writeFieldBegin(DATA_FIELD_DESC); oprot.writeBinary(struct.data); oprot.writeFieldEnd(); } oprot.writeFieldStop(); oprot.writeStructEnd(); } } private static class TSignalTupleSchemeFactory implements SchemeFactory { public TSignalTupleScheme getScheme() { return new TSignalTupleScheme(); } } private static class TSignalTupleScheme extends TupleScheme<TSignal> { @Override public void write(org.apache.thrift.protocol.TProtocol prot, TSignal struct) throws org.apache.thrift.TException { TTupleProtocol oprot = (TTupleProtocol) prot; oprot.writeString(struct.destApp); oprot.writeString(struct.destPellet); oprot.writeBinary(struct.data); } @Override public void read(org.apache.thrift.protocol.TProtocol prot, TSignal struct) throws org.apache.thrift.TException { TTupleProtocol iprot = (TTupleProtocol) prot; struct.destApp = iprot.readString(); struct.set_destApp_isSet(true); struct.destPellet = iprot.readString(); struct.set_destPellet_isSet(true); struct.data = iprot.readBinary(); struct.set_data_isSet(true); } } }