/** * Autogenerated by Thrift Compiler (1.0.0-dev) * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated */ package com.liveramp.hank.generated; import org.apache.commons.lang.builder.HashCodeBuilder; 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 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 ClientMetadata implements org.apache.thrift.TBase<ClientMetadata, ClientMetadata._Fields>, java.io.Serializable, Cloneable, Comparable<ClientMetadata> { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("ClientMetadata"); private static final org.apache.thrift.protocol.TField HOST_FIELD_DESC = new org.apache.thrift.protocol.TField("host", org.apache.thrift.protocol.TType.STRING, (short)1); private static final org.apache.thrift.protocol.TField CONNECTED_AT_FIELD_DESC = new org.apache.thrift.protocol.TField("connected_at", org.apache.thrift.protocol.TType.I64, (short)2); private static final org.apache.thrift.protocol.TField TYPE_FIELD_DESC = new org.apache.thrift.protocol.TField("type", org.apache.thrift.protocol.TType.STRING, (short)3); private static final org.apache.thrift.protocol.TField VERSION_FIELD_DESC = new org.apache.thrift.protocol.TField("version", org.apache.thrift.protocol.TType.STRING, (short)4); private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>(); static { schemes.put(StandardScheme.class, new ClientMetadataStandardSchemeFactory()); schemes.put(TupleScheme.class, new ClientMetadataTupleSchemeFactory()); } public String host; // required public long connected_at; // required public String type; // required public String version; // 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 { HOST((short)1, "host"), CONNECTED_AT((short)2, "connected_at"), TYPE((short)3, "type"), VERSION((short)4, "version"); 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: // HOST return HOST; case 2: // CONNECTED_AT return CONNECTED_AT; case 3: // TYPE return TYPE; case 4: // VERSION return VERSION; 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 private static final int __CONNECTED_AT_ISSET_ID = 0; private byte __isset_bitfield = 0; 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.HOST, new org.apache.thrift.meta_data.FieldMetaData("host", org.apache.thrift.TFieldRequirementType.REQUIRED, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); tmpMap.put(_Fields.CONNECTED_AT, new org.apache.thrift.meta_data.FieldMetaData("connected_at", org.apache.thrift.TFieldRequirementType.REQUIRED, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64))); tmpMap.put(_Fields.TYPE, new org.apache.thrift.meta_data.FieldMetaData("type", org.apache.thrift.TFieldRequirementType.REQUIRED, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); tmpMap.put(_Fields.VERSION, new org.apache.thrift.meta_data.FieldMetaData("version", org.apache.thrift.TFieldRequirementType.REQUIRED, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); metaDataMap = Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(ClientMetadata.class, metaDataMap); } public ClientMetadata() { } public ClientMetadata( String host, long connected_at, String type, String version) { this(); this.host = host; this.connected_at = connected_at; set_connected_at_isSet(true); this.type = type; this.version = version; } /** * Performs a deep copy on <i>other</i>. */ public ClientMetadata(ClientMetadata other) { __isset_bitfield = other.__isset_bitfield; if (other.is_set_host()) { this.host = other.host; } this.connected_at = other.connected_at; if (other.is_set_type()) { this.type = other.type; } if (other.is_set_version()) { this.version = other.version; } } public ClientMetadata deepCopy() { return new ClientMetadata(this); } @Override public void clear() { this.host = null; set_connected_at_isSet(false); this.connected_at = 0; this.type = null; this.version = null; } public String get_host() { return this.host; } public ClientMetadata set_host(String host) { this.host = host; return this; } public void unset_host() { this.host = null; } /** Returns true if field host is set (has been assigned a value) and false otherwise */ public boolean is_set_host() { return this.host != null; } public void set_host_isSet(boolean value) { if (!value) { this.host = null; } } public long get_connected_at() { return this.connected_at; } public ClientMetadata set_connected_at(long connected_at) { this.connected_at = connected_at; set_connected_at_isSet(true); return this; } public void unset_connected_at() { __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __CONNECTED_AT_ISSET_ID); } /** Returns true if field connected_at is set (has been assigned a value) and false otherwise */ public boolean is_set_connected_at() { return EncodingUtils.testBit(__isset_bitfield, __CONNECTED_AT_ISSET_ID); } public void set_connected_at_isSet(boolean value) { __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __CONNECTED_AT_ISSET_ID, value); } public String get_type() { return this.type; } public ClientMetadata set_type(String type) { this.type = type; return this; } public void unset_type() { this.type = null; } /** Returns true if field type is set (has been assigned a value) and false otherwise */ public boolean is_set_type() { return this.type != null; } public void set_type_isSet(boolean value) { if (!value) { this.type = null; } } public String get_version() { return this.version; } public ClientMetadata set_version(String version) { this.version = version; return this; } public void unset_version() { this.version = null; } /** Returns true if field version is set (has been assigned a value) and false otherwise */ public boolean is_set_version() { return this.version != null; } public void set_version_isSet(boolean value) { if (!value) { this.version = null; } } public void setFieldValue(_Fields field, Object value) { switch (field) { case HOST: if (value == null) { unset_host(); } else { set_host((String)value); } break; case CONNECTED_AT: if (value == null) { unset_connected_at(); } else { set_connected_at((Long)value); } break; case TYPE: if (value == null) { unset_type(); } else { set_type((String)value); } break; case VERSION: if (value == null) { unset_version(); } else { set_version((String)value); } break; } } public Object getFieldValue(_Fields field) { switch (field) { case HOST: return get_host(); case CONNECTED_AT: return Long.valueOf(get_connected_at()); case TYPE: return get_type(); case VERSION: return get_version(); } 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 HOST: return is_set_host(); case CONNECTED_AT: return is_set_connected_at(); case TYPE: return is_set_type(); case VERSION: return is_set_version(); } throw new IllegalStateException(); } @Override public boolean equals(Object that) { if (that == null) return false; if (that instanceof ClientMetadata) return this.equals((ClientMetadata)that); return false; } public boolean equals(ClientMetadata that) { if (that == null) return false; boolean this_present_host = true && this.is_set_host(); boolean that_present_host = true && that.is_set_host(); if (this_present_host || that_present_host) { if (!(this_present_host && that_present_host)) return false; if (!this.host.equals(that.host)) return false; } boolean this_present_connected_at = true; boolean that_present_connected_at = true; if (this_present_connected_at || that_present_connected_at) { if (!(this_present_connected_at && that_present_connected_at)) return false; if (this.connected_at != that.connected_at) return false; } boolean this_present_type = true && this.is_set_type(); boolean that_present_type = true && that.is_set_type(); if (this_present_type || that_present_type) { if (!(this_present_type && that_present_type)) return false; if (!this.type.equals(that.type)) return false; } boolean this_present_version = true && this.is_set_version(); boolean that_present_version = true && that.is_set_version(); if (this_present_version || that_present_version) { if (!(this_present_version && that_present_version)) return false; if (!this.version.equals(that.version)) return false; } return true; } @Override public int hashCode() { HashCodeBuilder builder = new HashCodeBuilder(); boolean present_host = true && (is_set_host()); builder.append(present_host); if (present_host) builder.append(host); boolean present_connected_at = true; builder.append(present_connected_at); if (present_connected_at) builder.append(connected_at); boolean present_type = true && (is_set_type()); builder.append(present_type); if (present_type) builder.append(type); boolean present_version = true && (is_set_version()); builder.append(present_version); if (present_version) builder.append(version); return builder.toHashCode(); } @Override public int compareTo(ClientMetadata other) { if (!getClass().equals(other.getClass())) { return getClass().getName().compareTo(other.getClass().getName()); } int lastComparison = 0; lastComparison = Boolean.valueOf(is_set_host()).compareTo(other.is_set_host()); if (lastComparison != 0) { return lastComparison; } if (is_set_host()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.host, other.host); if (lastComparison != 0) { return lastComparison; } } lastComparison = Boolean.valueOf(is_set_connected_at()).compareTo(other.is_set_connected_at()); if (lastComparison != 0) { return lastComparison; } if (is_set_connected_at()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.connected_at, other.connected_at); if (lastComparison != 0) { return lastComparison; } } lastComparison = Boolean.valueOf(is_set_type()).compareTo(other.is_set_type()); if (lastComparison != 0) { return lastComparison; } if (is_set_type()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.type, other.type); if (lastComparison != 0) { return lastComparison; } } lastComparison = Boolean.valueOf(is_set_version()).compareTo(other.is_set_version()); if (lastComparison != 0) { return lastComparison; } if (is_set_version()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.version, other.version); 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("ClientMetadata("); boolean first = true; sb.append("host:"); if (this.host == null) { sb.append("null"); } else { sb.append(this.host); } first = false; if (!first) sb.append(", "); sb.append("connected_at:"); sb.append(this.connected_at); first = false; if (!first) sb.append(", "); sb.append("type:"); if (this.type == null) { sb.append("null"); } else { sb.append(this.type); } first = false; if (!first) sb.append(", "); sb.append("version:"); if (this.version == null) { sb.append("null"); } else { sb.append(this.version); } first = false; sb.append(")"); return sb.toString(); } public void validate() throws org.apache.thrift.TException { // check for required fields if (host == null) { throw new org.apache.thrift.protocol.TProtocolException("Required field 'host' was not present! Struct: " + toString()); } // alas, we cannot check 'connected_at' because it's a primitive and you chose the non-beans generator. if (type == null) { throw new org.apache.thrift.protocol.TProtocolException("Required field 'type' was not present! Struct: " + toString()); } if (version == null) { throw new org.apache.thrift.protocol.TProtocolException("Required field 'version' was not present! 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 { // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor. __isset_bitfield = 0; 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 ClientMetadataStandardSchemeFactory implements SchemeFactory { public ClientMetadataStandardScheme getScheme() { return new ClientMetadataStandardScheme(); } } private static class ClientMetadataStandardScheme extends StandardScheme<ClientMetadata> { public void read(org.apache.thrift.protocol.TProtocol iprot, ClientMetadata 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: // HOST if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { struct.host = iprot.readString(); struct.set_host_isSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 2: // CONNECTED_AT if (schemeField.type == org.apache.thrift.protocol.TType.I64) { struct.connected_at = iprot.readI64(); struct.set_connected_at_isSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 3: // TYPE if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { struct.type = iprot.readString(); struct.set_type_isSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 4: // VERSION if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { struct.version = iprot.readString(); struct.set_version_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(); // check for required fields of primitive type, which can't be checked in the validate method if (!struct.is_set_connected_at()) { throw new org.apache.thrift.protocol.TProtocolException("Required field 'connected_at' was not found in serialized data! Struct: " + toString()); } struct.validate(); } public void write(org.apache.thrift.protocol.TProtocol oprot, ClientMetadata struct) throws org.apache.thrift.TException { struct.validate(); oprot.writeStructBegin(STRUCT_DESC); if (struct.host != null) { oprot.writeFieldBegin(HOST_FIELD_DESC); oprot.writeString(struct.host); oprot.writeFieldEnd(); } oprot.writeFieldBegin(CONNECTED_AT_FIELD_DESC); oprot.writeI64(struct.connected_at); oprot.writeFieldEnd(); if (struct.type != null) { oprot.writeFieldBegin(TYPE_FIELD_DESC); oprot.writeString(struct.type); oprot.writeFieldEnd(); } if (struct.version != null) { oprot.writeFieldBegin(VERSION_FIELD_DESC); oprot.writeString(struct.version); oprot.writeFieldEnd(); } oprot.writeFieldStop(); oprot.writeStructEnd(); } } private static class ClientMetadataTupleSchemeFactory implements SchemeFactory { public ClientMetadataTupleScheme getScheme() { return new ClientMetadataTupleScheme(); } } private static class ClientMetadataTupleScheme extends TupleScheme<ClientMetadata> { @Override public void write(org.apache.thrift.protocol.TProtocol prot, ClientMetadata struct) throws org.apache.thrift.TException { TTupleProtocol oprot = (TTupleProtocol) prot; oprot.writeString(struct.host); oprot.writeI64(struct.connected_at); oprot.writeString(struct.type); oprot.writeString(struct.version); } @Override public void read(org.apache.thrift.protocol.TProtocol prot, ClientMetadata struct) throws org.apache.thrift.TException { TTupleProtocol iprot = (TTupleProtocol) prot; struct.host = iprot.readString(); struct.set_host_isSet(true); struct.connected_at = iprot.readI64(); struct.set_connected_at_isSet(true); struct.type = iprot.readString(); struct.set_type_isSet(true); struct.version = iprot.readString(); struct.set_version_isSet(true); } } }