/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * Autogenerated by Thrift Compiler (0.9.1) * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated */ package cgl.iotcloud.core.api.thrift; 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; @SuppressWarnings("all") public class TSite implements org.apache.thrift.TBase<TSite, TSite._Fields>, java.io.Serializable, Cloneable, Comparable<TSite> { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TSite"); private static final org.apache.thrift.protocol.TField SITE_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("siteId", org.apache.thrift.protocol.TType.STRING, (short)1); private static final org.apache.thrift.protocol.TField PORT_FIELD_DESC = new org.apache.thrift.protocol.TField("port", org.apache.thrift.protocol.TType.I32, (short)2); 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)3); private static final org.apache.thrift.protocol.TField METADATA_FIELD_DESC = new org.apache.thrift.protocol.TField("metadata", org.apache.thrift.protocol.TType.STRING, (short)4); private static final org.apache.thrift.protocol.TField BROKERS_FIELD_DESC = new org.apache.thrift.protocol.TField("brokers", org.apache.thrift.protocol.TType.LIST, (short)5); private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>(); static { schemes.put(StandardScheme.class, new TSiteStandardSchemeFactory()); schemes.put(TupleScheme.class, new TSiteTupleSchemeFactory()); } public String siteId; // required public int port; // required public String host; // required public ByteBuffer metadata; // optional public List<TBroker> brokers; // optional /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ @SuppressWarnings("all") public enum _Fields implements org.apache.thrift.TFieldIdEnum { SITE_ID((short)1, "siteId"), PORT((short)2, "port"), HOST((short)3, "host"), METADATA((short)4, "metadata"), BROKERS((short)5, "brokers"); 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: // SITE_ID return SITE_ID; case 2: // PORT return PORT; case 3: // HOST return HOST; case 4: // METADATA return METADATA; case 5: // BROKERS return BROKERS; 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 __PORT_ISSET_ID = 0; private byte __isset_bitfield = 0; private _Fields optionals[] = {_Fields.METADATA,_Fields.BROKERS}; 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.SITE_ID, new org.apache.thrift.meta_data.FieldMetaData("siteId", org.apache.thrift.TFieldRequirementType.REQUIRED, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); tmpMap.put(_Fields.PORT, new org.apache.thrift.meta_data.FieldMetaData("port", org.apache.thrift.TFieldRequirementType.REQUIRED, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32))); 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.METADATA, new org.apache.thrift.meta_data.FieldMetaData("metadata", org.apache.thrift.TFieldRequirementType.OPTIONAL, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING , true))); tmpMap.put(_Fields.BROKERS, new org.apache.thrift.meta_data.FieldMetaData("brokers", org.apache.thrift.TFieldRequirementType.OPTIONAL, new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TBroker.class)))); metaDataMap = Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TSite.class, metaDataMap); } public TSite() { } public TSite( String siteId, int port, String host) { this(); this.siteId = siteId; this.port = port; setPortIsSet(true); this.host = host; } /** * Performs a deep copy on <i>other</i>. */ public TSite(TSite other) { __isset_bitfield = other.__isset_bitfield; if (other.isSetSiteId()) { this.siteId = other.siteId; } this.port = other.port; if (other.isSetHost()) { this.host = other.host; } if (other.isSetMetadata()) { this.metadata = org.apache.thrift.TBaseHelper.copyBinary(other.metadata); ; } if (other.isSetBrokers()) { List<TBroker> __this__brokers = new ArrayList<TBroker>(other.brokers.size()); for (TBroker other_element : other.brokers) { __this__brokers.add(new TBroker(other_element)); } this.brokers = __this__brokers; } } public TSite deepCopy() { return new TSite(this); } @Override public void clear() { this.siteId = null; setPortIsSet(false); this.port = 0; this.host = null; this.metadata = null; this.brokers = null; } public String getSiteId() { return this.siteId; } public TSite setSiteId(String siteId) { this.siteId = siteId; return this; } public void unsetSiteId() { this.siteId = null; } /** Returns true if field siteId is set (has been assigned a value) and false otherwise */ public boolean isSetSiteId() { return this.siteId != null; } public void setSiteIdIsSet(boolean value) { if (!value) { this.siteId = null; } } public int getPort() { return this.port; } public TSite setPort(int port) { this.port = port; setPortIsSet(true); return this; } public void unsetPort() { __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __PORT_ISSET_ID); } /** Returns true if field port is set (has been assigned a value) and false otherwise */ public boolean isSetPort() { return EncodingUtils.testBit(__isset_bitfield, __PORT_ISSET_ID); } public void setPortIsSet(boolean value) { __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __PORT_ISSET_ID, value); } public String getHost() { return this.host; } public TSite setHost(String host) { this.host = host; return this; } public void unsetHost() { this.host = null; } /** Returns true if field host is set (has been assigned a value) and false otherwise */ public boolean isSetHost() { return this.host != null; } public void setHostIsSet(boolean value) { if (!value) { this.host = null; } } public byte[] getMetadata() { setMetadata(org.apache.thrift.TBaseHelper.rightSize(metadata)); return metadata == null ? null : metadata.array(); } public ByteBuffer bufferForMetadata() { return metadata; } public TSite setMetadata(byte[] metadata) { setMetadata(metadata == null ? (ByteBuffer)null : ByteBuffer.wrap(metadata)); return this; } public TSite setMetadata(ByteBuffer metadata) { this.metadata = metadata; return this; } public void unsetMetadata() { this.metadata = null; } /** Returns true if field metadata is set (has been assigned a value) and false otherwise */ public boolean isSetMetadata() { return this.metadata != null; } public void setMetadataIsSet(boolean value) { if (!value) { this.metadata = null; } } public int getBrokersSize() { return (this.brokers == null) ? 0 : this.brokers.size(); } public java.util.Iterator<TBroker> getBrokersIterator() { return (this.brokers == null) ? null : this.brokers.iterator(); } public void addToBrokers(TBroker elem) { if (this.brokers == null) { this.brokers = new ArrayList<TBroker>(); } this.brokers.add(elem); } public List<TBroker> getBrokers() { return this.brokers; } public TSite setBrokers(List<TBroker> brokers) { this.brokers = brokers; return this; } public void unsetBrokers() { this.brokers = null; } /** Returns true if field brokers is set (has been assigned a value) and false otherwise */ public boolean isSetBrokers() { return this.brokers != null; } public void setBrokersIsSet(boolean value) { if (!value) { this.brokers = null; } } public void setFieldValue(_Fields field, Object value) { switch (field) { case SITE_ID: if (value == null) { unsetSiteId(); } else { setSiteId((String)value); } break; case PORT: if (value == null) { unsetPort(); } else { setPort((Integer)value); } break; case HOST: if (value == null) { unsetHost(); } else { setHost((String)value); } break; case METADATA: if (value == null) { unsetMetadata(); } else { setMetadata((ByteBuffer)value); } break; case BROKERS: if (value == null) { unsetBrokers(); } else { setBrokers((List<TBroker>)value); } break; } } public Object getFieldValue(_Fields field) { switch (field) { case SITE_ID: return getSiteId(); case PORT: return Integer.valueOf(getPort()); case HOST: return getHost(); case METADATA: return getMetadata(); case BROKERS: return getBrokers(); } 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 SITE_ID: return isSetSiteId(); case PORT: return isSetPort(); case HOST: return isSetHost(); case METADATA: return isSetMetadata(); case BROKERS: return isSetBrokers(); } throw new IllegalStateException(); } @Override public boolean equals(Object that) { if (that == null) return false; if (that instanceof TSite) return this.equals((TSite)that); return false; } public boolean equals(TSite that) { if (that == null) return false; boolean this_present_siteId = true && this.isSetSiteId(); boolean that_present_siteId = true && that.isSetSiteId(); if (this_present_siteId || that_present_siteId) { if (!(this_present_siteId && that_present_siteId)) return false; if (!this.siteId.equals(that.siteId)) return false; } boolean this_present_port = true; boolean that_present_port = true; if (this_present_port || that_present_port) { if (!(this_present_port && that_present_port)) return false; if (this.port != that.port) return false; } boolean this_present_host = true && this.isSetHost(); boolean that_present_host = true && that.isSetHost(); 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_metadata = true && this.isSetMetadata(); boolean that_present_metadata = true && that.isSetMetadata(); if (this_present_metadata || that_present_metadata) { if (!(this_present_metadata && that_present_metadata)) return false; if (!this.metadata.equals(that.metadata)) return false; } boolean this_present_brokers = true && this.isSetBrokers(); boolean that_present_brokers = true && that.isSetBrokers(); if (this_present_brokers || that_present_brokers) { if (!(this_present_brokers && that_present_brokers)) return false; if (!this.brokers.equals(that.brokers)) return false; } return true; } @Override public int hashCode() { return 0; } @Override public int compareTo(TSite other) { if (!getClass().equals(other.getClass())) { return getClass().getName().compareTo(other.getClass().getName()); } int lastComparison = 0; lastComparison = Boolean.valueOf(isSetSiteId()).compareTo(other.isSetSiteId()); if (lastComparison != 0) { return lastComparison; } if (isSetSiteId()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.siteId, other.siteId); if (lastComparison != 0) { return lastComparison; } } lastComparison = Boolean.valueOf(isSetPort()).compareTo(other.isSetPort()); if (lastComparison != 0) { return lastComparison; } if (isSetPort()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.port, other.port); if (lastComparison != 0) { return lastComparison; } } lastComparison = Boolean.valueOf(isSetHost()).compareTo(other.isSetHost()); if (lastComparison != 0) { return lastComparison; } if (isSetHost()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.host, other.host); if (lastComparison != 0) { return lastComparison; } } lastComparison = Boolean.valueOf(isSetMetadata()).compareTo(other.isSetMetadata()); if (lastComparison != 0) { return lastComparison; } if (isSetMetadata()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.metadata, other.metadata); if (lastComparison != 0) { return lastComparison; } } lastComparison = Boolean.valueOf(isSetBrokers()).compareTo(other.isSetBrokers()); if (lastComparison != 0) { return lastComparison; } if (isSetBrokers()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.brokers, other.brokers); 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("TSite("); boolean first = true; sb.append("siteId:"); if (this.siteId == null) { sb.append("null"); } else { sb.append(this.siteId); } first = false; if (!first) sb.append(", "); sb.append("port:"); sb.append(this.port); first = false; if (!first) sb.append(", "); sb.append("host:"); if (this.host == null) { sb.append("null"); } else { sb.append(this.host); } first = false; if (isSetMetadata()) { if (!first) sb.append(", "); sb.append("metadata:"); if (this.metadata == null) { sb.append("null"); } else { org.apache.thrift.TBaseHelper.toString(this.metadata, sb); } first = false; } if (isSetBrokers()) { if (!first) sb.append(", "); sb.append("brokers:"); if (this.brokers == null) { sb.append("null"); } else { sb.append(this.brokers); } first = false; } sb.append(")"); return sb.toString(); } public void validate() throws org.apache.thrift.TException { // check for required fields if (siteId == null) { throw new org.apache.thrift.protocol.TProtocolException("Required field 'siteId' was not present! Struct: " + toString()); } // alas, we cannot check 'port' because it's a primitive and you chose the non-beans generator. if (host == null) { throw new org.apache.thrift.protocol.TProtocolException("Required field 'host' 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 TSiteStandardSchemeFactory implements SchemeFactory { public TSiteStandardScheme getScheme() { return new TSiteStandardScheme(); } } private static class TSiteStandardScheme extends StandardScheme<TSite> { public void read(org.apache.thrift.protocol.TProtocol iprot, TSite 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: // SITE_ID if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { struct.siteId = iprot.readString(); struct.setSiteIdIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 2: // PORT if (schemeField.type == org.apache.thrift.protocol.TType.I32) { struct.port = iprot.readI32(); struct.setPortIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 3: // HOST if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { struct.host = iprot.readString(); struct.setHostIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 4: // METADATA if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { struct.metadata = iprot.readBinary(); struct.setMetadataIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 5: // BROKERS if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { { org.apache.thrift.protocol.TList _list28 = iprot.readListBegin(); struct.brokers = new ArrayList<TBroker>(_list28.size); for (int _i29 = 0; _i29 < _list28.size; ++_i29) { TBroker _elem30; _elem30 = new TBroker(); _elem30.read(iprot); struct.brokers.add(_elem30); } iprot.readListEnd(); } struct.setBrokersIsSet(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.isSetPort()) { throw new org.apache.thrift.protocol.TProtocolException("Required field 'port' was not found in serialized data! Struct: " + toString()); } struct.validate(); } public void write(org.apache.thrift.protocol.TProtocol oprot, TSite struct) throws org.apache.thrift.TException { struct.validate(); oprot.writeStructBegin(STRUCT_DESC); if (struct.siteId != null) { oprot.writeFieldBegin(SITE_ID_FIELD_DESC); oprot.writeString(struct.siteId); oprot.writeFieldEnd(); } oprot.writeFieldBegin(PORT_FIELD_DESC); oprot.writeI32(struct.port); oprot.writeFieldEnd(); if (struct.host != null) { oprot.writeFieldBegin(HOST_FIELD_DESC); oprot.writeString(struct.host); oprot.writeFieldEnd(); } if (struct.metadata != null) { if (struct.isSetMetadata()) { oprot.writeFieldBegin(METADATA_FIELD_DESC); oprot.writeBinary(struct.metadata); oprot.writeFieldEnd(); } } if (struct.brokers != null) { if (struct.isSetBrokers()) { oprot.writeFieldBegin(BROKERS_FIELD_DESC); { oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.brokers.size())); for (TBroker _iter31 : struct.brokers) { _iter31.write(oprot); } oprot.writeListEnd(); } oprot.writeFieldEnd(); } } oprot.writeFieldStop(); oprot.writeStructEnd(); } } private static class TSiteTupleSchemeFactory implements SchemeFactory { public TSiteTupleScheme getScheme() { return new TSiteTupleScheme(); } } private static class TSiteTupleScheme extends TupleScheme<TSite> { @Override public void write(org.apache.thrift.protocol.TProtocol prot, TSite struct) throws org.apache.thrift.TException { TTupleProtocol oprot = (TTupleProtocol) prot; oprot.writeString(struct.siteId); oprot.writeI32(struct.port); oprot.writeString(struct.host); BitSet optionals = new BitSet(); if (struct.isSetMetadata()) { optionals.set(0); } if (struct.isSetBrokers()) { optionals.set(1); } oprot.writeBitSet(optionals, 2); if (struct.isSetMetadata()) { oprot.writeBinary(struct.metadata); } if (struct.isSetBrokers()) { { oprot.writeI32(struct.brokers.size()); for (TBroker _iter32 : struct.brokers) { _iter32.write(oprot); } } } } @Override public void read(org.apache.thrift.protocol.TProtocol prot, TSite struct) throws org.apache.thrift.TException { TTupleProtocol iprot = (TTupleProtocol) prot; struct.siteId = iprot.readString(); struct.setSiteIdIsSet(true); struct.port = iprot.readI32(); struct.setPortIsSet(true); struct.host = iprot.readString(); struct.setHostIsSet(true); BitSet incoming = iprot.readBitSet(2); if (incoming.get(0)) { struct.metadata = iprot.readBinary(); struct.setMetadataIsSet(true); } if (incoming.get(1)) { { org.apache.thrift.protocol.TList _list33 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); struct.brokers = new ArrayList<TBroker>(_list33.size); for (int _i34 = 0; _i34 < _list33.size; ++_i34) { TBroker _elem35; _elem35 = new TBroker(); _elem35.read(iprot); struct.brokers.add(_elem35); } } struct.setBrokersIsSet(true); } } } }