blob: 206c7c18cd6809b044e97ac68841d690a88433ca [file] [log] [blame]
/**
* Autogenerated by Thrift
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
*/
package backtype.storm.generated;
import org.apache.commons.lang.builder.HashCodeBuilder;
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.util.Arrays;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.thrift.*;
import org.apache.thrift.async.*;
import org.apache.thrift.meta_data.*;
import org.apache.thrift.transport.*;
import org.apache.thrift.protocol.*;
public class ComponentCommon implements TBase<ComponentCommon, ComponentCommon._Fields>, java.io.Serializable, Cloneable {
private static final TStruct STRUCT_DESC = new TStruct("ComponentCommon");
private static final TField STREAMS_FIELD_DESC = new TField("streams", TType.MAP, (short)1);
private static final TField PARALLELISM_HINT_FIELD_DESC = new TField("parallelism_hint", TType.I32, (short)2);
private Map<Integer,StreamInfo> streams;
private int parallelism_hint;
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
public enum _Fields implements TFieldIdEnum {
STREAMS((short)1, "streams"),
PARALLELISM_HINT((short)2, "parallelism_hint");
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: // STREAMS
return STREAMS;
case 2: // PARALLELISM_HINT
return PARALLELISM_HINT;
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 __PARALLELISM_HINT_ISSET_ID = 0;
private BitSet __isset_bit_vector = new BitSet(1);
public static final Map<_Fields, FieldMetaData> metaDataMap;
static {
Map<_Fields, FieldMetaData> tmpMap = new EnumMap<_Fields, FieldMetaData>(_Fields.class);
tmpMap.put(_Fields.STREAMS, new FieldMetaData("streams", TFieldRequirementType.REQUIRED,
new MapMetaData(TType.MAP,
new FieldValueMetaData(TType.I32),
new StructMetaData(TType.STRUCT, StreamInfo.class))));
tmpMap.put(_Fields.PARALLELISM_HINT, new FieldMetaData("parallelism_hint", TFieldRequirementType.OPTIONAL,
new FieldValueMetaData(TType.I32)));
metaDataMap = Collections.unmodifiableMap(tmpMap);
FieldMetaData.addStructMetaDataMap(ComponentCommon.class, metaDataMap);
}
public ComponentCommon() {
}
public ComponentCommon(
Map<Integer,StreamInfo> streams)
{
this();
this.streams = streams;
}
/**
* Performs a deep copy on <i>other</i>.
*/
public ComponentCommon(ComponentCommon other) {
__isset_bit_vector.clear();
__isset_bit_vector.or(other.__isset_bit_vector);
if (other.is_set_streams()) {
Map<Integer,StreamInfo> __this__streams = new HashMap<Integer,StreamInfo>();
for (Map.Entry<Integer, StreamInfo> other_element : other.streams.entrySet()) {
Integer other_element_key = other_element.getKey();
StreamInfo other_element_value = other_element.getValue();
Integer __this__streams_copy_key = other_element_key;
StreamInfo __this__streams_copy_value = new StreamInfo(other_element_value);
__this__streams.put(__this__streams_copy_key, __this__streams_copy_value);
}
this.streams = __this__streams;
}
this.parallelism_hint = other.parallelism_hint;
}
public ComponentCommon deepCopy() {
return new ComponentCommon(this);
}
@Deprecated
public ComponentCommon clone() {
return new ComponentCommon(this);
}
public int get_streams_size() {
return (this.streams == null) ? 0 : this.streams.size();
}
public void put_to_streams(int key, StreamInfo val) {
if (this.streams == null) {
this.streams = new HashMap<Integer,StreamInfo>();
}
this.streams.put(key, val);
}
public Map<Integer,StreamInfo> get_streams() {
return this.streams;
}
public void set_streams(Map<Integer,StreamInfo> streams) {
this.streams = streams;
}
public void unset_streams() {
this.streams = null;
}
/** Returns true if field streams is set (has been asigned a value) and false otherwise */
public boolean is_set_streams() {
return this.streams != null;
}
public void set_streams_isSet(boolean value) {
if (!value) {
this.streams = null;
}
}
public int get_parallelism_hint() {
return this.parallelism_hint;
}
public void set_parallelism_hint(int parallelism_hint) {
this.parallelism_hint = parallelism_hint;
set_parallelism_hint_isSet(true);
}
public void unset_parallelism_hint() {
__isset_bit_vector.clear(__PARALLELISM_HINT_ISSET_ID);
}
/** Returns true if field parallelism_hint is set (has been asigned a value) and false otherwise */
public boolean is_set_parallelism_hint() {
return __isset_bit_vector.get(__PARALLELISM_HINT_ISSET_ID);
}
public void set_parallelism_hint_isSet(boolean value) {
__isset_bit_vector.set(__PARALLELISM_HINT_ISSET_ID, value);
}
public void setFieldValue(_Fields field, Object value) {
switch (field) {
case STREAMS:
if (value == null) {
unset_streams();
} else {
set_streams((Map<Integer,StreamInfo>)value);
}
break;
case PARALLELISM_HINT:
if (value == null) {
unset_parallelism_hint();
} else {
set_parallelism_hint((Integer)value);
}
break;
}
}
public void setFieldValue(int fieldID, Object value) {
setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value);
}
public Object getFieldValue(_Fields field) {
switch (field) {
case STREAMS:
return get_streams();
case PARALLELISM_HINT:
return new Integer(get_parallelism_hint());
}
throw new IllegalStateException();
}
public Object getFieldValue(int fieldId) {
return getFieldValue(_Fields.findByThriftIdOrThrow(fieldId));
}
/** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
public boolean isSet(_Fields field) {
switch (field) {
case STREAMS:
return is_set_streams();
case PARALLELISM_HINT:
return is_set_parallelism_hint();
}
throw new IllegalStateException();
}
public boolean isSet(int fieldID) {
return isSet(_Fields.findByThriftIdOrThrow(fieldID));
}
@Override
public boolean equals(Object that) {
if (that == null)
return false;
if (that instanceof ComponentCommon)
return this.equals((ComponentCommon)that);
return false;
}
public boolean equals(ComponentCommon that) {
if (that == null)
return false;
boolean this_present_streams = true && this.is_set_streams();
boolean that_present_streams = true && that.is_set_streams();
if (this_present_streams || that_present_streams) {
if (!(this_present_streams && that_present_streams))
return false;
if (!this.streams.equals(that.streams))
return false;
}
boolean this_present_parallelism_hint = true && this.is_set_parallelism_hint();
boolean that_present_parallelism_hint = true && that.is_set_parallelism_hint();
if (this_present_parallelism_hint || that_present_parallelism_hint) {
if (!(this_present_parallelism_hint && that_present_parallelism_hint))
return false;
if (this.parallelism_hint != that.parallelism_hint)
return false;
}
return true;
}
@Override
public int hashCode() {
HashCodeBuilder builder = new HashCodeBuilder();
boolean present_streams = true && (is_set_streams());
builder.append(present_streams);
if (present_streams)
builder.append(streams);
boolean present_parallelism_hint = true && (is_set_parallelism_hint());
builder.append(present_parallelism_hint);
if (present_parallelism_hint)
builder.append(parallelism_hint);
return builder.toHashCode();
}
public int compareTo(ComponentCommon other) {
if (!getClass().equals(other.getClass())) {
return getClass().getName().compareTo(other.getClass().getName());
}
int lastComparison = 0;
ComponentCommon typedOther = (ComponentCommon)other;
lastComparison = Boolean.valueOf(is_set_streams()).compareTo(typedOther.is_set_streams());
if (lastComparison != 0) {
return lastComparison;
}
if (is_set_streams()) { lastComparison = TBaseHelper.compareTo(this.streams, typedOther.streams);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(is_set_parallelism_hint()).compareTo(typedOther.is_set_parallelism_hint());
if (lastComparison != 0) {
return lastComparison;
}
if (is_set_parallelism_hint()) { lastComparison = TBaseHelper.compareTo(this.parallelism_hint, typedOther.parallelism_hint);
if (lastComparison != 0) {
return lastComparison;
}
}
return 0;
}
public void read(TProtocol iprot) throws TException {
TField field;
iprot.readStructBegin();
while (true)
{
field = iprot.readFieldBegin();
if (field.type == TType.STOP) {
break;
}
switch (field.id) {
case 1: // STREAMS
if (field.type == TType.MAP) {
{
TMap _map8 = iprot.readMapBegin();
this.streams = new HashMap<Integer,StreamInfo>(2*_map8.size);
for (int _i9 = 0; _i9 < _map8.size; ++_i9)
{
int _key10;
StreamInfo _val11;
_key10 = iprot.readI32();
_val11 = new StreamInfo();
_val11.read(iprot);
this.streams.put(_key10, _val11);
}
iprot.readMapEnd();
}
} else {
TProtocolUtil.skip(iprot, field.type);
}
break;
case 2: // PARALLELISM_HINT
if (field.type == TType.I32) {
this.parallelism_hint = iprot.readI32();
set_parallelism_hint_isSet(true);
} else {
TProtocolUtil.skip(iprot, field.type);
}
break;
default:
TProtocolUtil.skip(iprot, field.type);
}
iprot.readFieldEnd();
}
iprot.readStructEnd();
validate();
}
public void write(TProtocol oprot) throws TException {
validate();
oprot.writeStructBegin(STRUCT_DESC);
if (this.streams != null) {
oprot.writeFieldBegin(STREAMS_FIELD_DESC);
{
oprot.writeMapBegin(new TMap(TType.I32, TType.STRUCT, this.streams.size()));
for (Map.Entry<Integer, StreamInfo> _iter12 : this.streams.entrySet())
{
oprot.writeI32(_iter12.getKey());
_iter12.getValue().write(oprot);
}
oprot.writeMapEnd();
}
oprot.writeFieldEnd();
}
if (is_set_parallelism_hint()) {
oprot.writeFieldBegin(PARALLELISM_HINT_FIELD_DESC);
oprot.writeI32(this.parallelism_hint);
oprot.writeFieldEnd();
}
oprot.writeFieldStop();
oprot.writeStructEnd();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("ComponentCommon(");
boolean first = true;
sb.append("streams:");
if (this.streams == null) {
sb.append("null");
} else {
sb.append(this.streams);
}
first = false;
if (is_set_parallelism_hint()) {
if (!first) sb.append(", ");
sb.append("parallelism_hint:");
sb.append(this.parallelism_hint);
first = false;
}
sb.append(")");
return sb.toString();
}
public void validate() throws TException {
// check for required fields
if (!is_set_streams()) {
throw new TProtocolException("Required field 'streams' is unset! Struct:" + toString());
}
}
}