org.apache.distributedlog.thrift.service.ServerInfo Maven / Gradle / Ivy
The newest version!
/**
* Autogenerated by Thrift
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
*/
package org.apache.distributedlog.thrift.service;
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.nio.ByteBuffer;
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.*;
// No additional import required for struct/union.
public class ServerInfo implements TBase, java.io.Serializable, Cloneable {
private static final TStruct STRUCT_DESC = new TStruct("ServerInfo");
private static final TField OWNERSHIPS_FIELD_DESC = new TField("ownerships", TType.MAP, (short)1);
private static final TField SERVER_STATUS_FIELD_DESC = new TField("serverStatus", TType.I32, (short)2);
public Map ownerships;
public ServerStatus serverStatus;
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
public enum _Fields implements TFieldIdEnum {
OWNERSHIPS((short)1, "ownerships"),
SERVER_STATUS((short)2, "serverStatus");
private static final Map byName = new HashMap();
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: // OWNERSHIPS
return OWNERSHIPS;
case 2: // SERVER_STATUS
return SERVER_STATUS;
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, FieldMetaData> metaDataMap;
static {
Map<_Fields, FieldMetaData> tmpMap = new EnumMap<_Fields, FieldMetaData>(_Fields.class);
tmpMap.put(_Fields.OWNERSHIPS, new FieldMetaData("ownerships", TFieldRequirementType.OPTIONAL,
new MapMetaData(TType.MAP,
new FieldValueMetaData(TType.STRING),
new FieldValueMetaData(TType.STRING))));
tmpMap.put(_Fields.SERVER_STATUS, new FieldMetaData("serverStatus", TFieldRequirementType.OPTIONAL,
new EnumMetaData(TType.ENUM, ServerStatus.class)));
metaDataMap = Collections.unmodifiableMap(tmpMap);
FieldMetaData.addStructMetaDataMap(ServerInfo.class, metaDataMap);
}
public ServerInfo() {
}
/**
* Performs a deep copy on other.
*/
public ServerInfo(ServerInfo other) {
if (other.isSetOwnerships()) {
Map __this__ownerships = new HashMap();
for (Map.Entry other_element : other.ownerships.entrySet()) {
String other_element_key = other_element.getKey();
String other_element_value = other_element.getValue();
String __this__ownerships_copy_key = other_element_key;
String __this__ownerships_copy_value = other_element_value;
__this__ownerships.put(__this__ownerships_copy_key, __this__ownerships_copy_value);
}
this.ownerships = __this__ownerships;
}
if (other.isSetServerStatus()) {
this.serverStatus = other.serverStatus;
}
}
public ServerInfo deepCopy() {
return new ServerInfo(this);
}
@Override
public void clear() {
this.ownerships = null;
this.serverStatus = null;
}
public int getOwnershipsSize() {
return (this.ownerships == null) ? 0 : this.ownerships.size();
}
public void putToOwnerships(String key, String val) {
if (this.ownerships == null) {
this.ownerships = new HashMap();
}
this.ownerships.put(key, val);
}
public Map getOwnerships() {
return this.ownerships;
}
public ServerInfo setOwnerships(Map ownerships) {
this.ownerships = ownerships;
return this;
}
public void unsetOwnerships() {
this.ownerships = null;
}
/** Returns true if field ownerships is set (has been asigned a value) and false otherwise */
public boolean isSetOwnerships() {
return this.ownerships != null;
}
public void setOwnershipsIsSet(boolean value) {
if (!value) {
this.ownerships = null;
}
}
public ServerStatus getServerStatus() {
return this.serverStatus;
}
public ServerInfo setServerStatus(ServerStatus serverStatus) {
this.serverStatus = serverStatus;
return this;
}
public void unsetServerStatus() {
this.serverStatus = null;
}
/** Returns true if field serverStatus is set (has been asigned a value) and false otherwise */
public boolean isSetServerStatus() {
return this.serverStatus != null;
}
public void setServerStatusIsSet(boolean value) {
if (!value) {
this.serverStatus = null;
}
}
public void setFieldValue(_Fields field, Object value) {
switch (field) {
case OWNERSHIPS:
if (value == null) {
unsetOwnerships();
} else {
setOwnerships((Map)value);
}
break;
case SERVER_STATUS:
if (value == null) {
unsetServerStatus();
} else {
setServerStatus((ServerStatus)value);
}
break;
}
}
public Object getFieldValue(_Fields field) {
switch (field) {
case OWNERSHIPS:
return getOwnerships();
case SERVER_STATUS:
return getServerStatus();
}
throw new IllegalStateException();
}
/** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
public boolean isSet(_Fields field) {
if (field == null) {
throw new IllegalArgumentException();
}
switch (field) {
case OWNERSHIPS:
return isSetOwnerships();
case SERVER_STATUS:
return isSetServerStatus();
}
throw new IllegalStateException();
}
@Override
public boolean equals(Object that) {
if (that == null)
return false;
if (that instanceof ServerInfo)
return this.equals((ServerInfo)that);
return false;
}
public boolean equals(ServerInfo that) {
if (that == null)
return false;
boolean this_present_ownerships = true && this.isSetOwnerships();
boolean that_present_ownerships = true && that.isSetOwnerships();
if (this_present_ownerships || that_present_ownerships) {
if (!(this_present_ownerships && that_present_ownerships))
return false;
if (!this.ownerships.equals(that.ownerships))
return false;
}
boolean this_present_serverStatus = true && this.isSetServerStatus();
boolean that_present_serverStatus = true && that.isSetServerStatus();
if (this_present_serverStatus || that_present_serverStatus) {
if (!(this_present_serverStatus && that_present_serverStatus))
return false;
if (!this.serverStatus.equals(that.serverStatus))
return false;
}
return true;
}
@Override
public int hashCode() {
HashCodeBuilder builder = new HashCodeBuilder();
boolean present_ownerships = true && (isSetOwnerships());
builder.append(present_ownerships);
if (present_ownerships)
builder.append(ownerships);
boolean present_serverStatus = true && (isSetServerStatus());
builder.append(present_serverStatus);
if (present_serverStatus)
builder.append(serverStatus.getValue());
return builder.toHashCode();
}
public int compareTo(ServerInfo other) {
if (!getClass().equals(other.getClass())) {
return getClass().getName().compareTo(other.getClass().getName());
}
int lastComparison = 0;
ServerInfo typedOther = (ServerInfo)other;
lastComparison = Boolean.valueOf(isSetOwnerships()).compareTo(typedOther.isSetOwnerships());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetOwnerships()) {
lastComparison = TBaseHelper.compareTo(this.ownerships, typedOther.ownerships);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetServerStatus()).compareTo(typedOther.isSetServerStatus());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetServerStatus()) {
lastComparison = TBaseHelper.compareTo(this.serverStatus, typedOther.serverStatus);
if (lastComparison != 0) {
return lastComparison;
}
}
return 0;
}
public _Fields fieldForId(int fieldId) {
return _Fields.findByThriftId(fieldId);
}
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: // OWNERSHIPS
if (field.type == TType.MAP) {
{
TMap _map8 = iprot.readMapBegin();
this.ownerships = new HashMap(2*_map8.size);
for (int _i9 = 0; _i9 < _map8.size; ++_i9)
{
String _key10;
String _val11;
_key10 = iprot.readString();
_val11 = iprot.readString();
this.ownerships.put(_key10, _val11);
}
iprot.readMapEnd();
}
} else {
TProtocolUtil.skip(iprot, field.type);
}
break;
case 2: // SERVER_STATUS
if (field.type == TType.I32) {
this.serverStatus = ServerStatus.findByValue(iprot.readI32());
} else {
TProtocolUtil.skip(iprot, field.type);
}
break;
default:
TProtocolUtil.skip(iprot, field.type);
}
iprot.readFieldEnd();
}
iprot.readStructEnd();
// check for required fields of primitive type, which can't be checked in the validate method
validate();
}
public void write(TProtocol oprot) throws TException {
validate();
oprot.writeStructBegin(STRUCT_DESC);
if (this.ownerships != null) {
if (isSetOwnerships()) {
oprot.writeFieldBegin(OWNERSHIPS_FIELD_DESC);
{
oprot.writeMapBegin(new TMap(TType.STRING, TType.STRING, this.ownerships.size()));
for (Map.Entry _iter12 : this.ownerships.entrySet())
{
oprot.writeString(_iter12.getKey());
oprot.writeString(_iter12.getValue());
}
oprot.writeMapEnd();
}
oprot.writeFieldEnd();
}
}
if (this.serverStatus != null) {
if (isSetServerStatus()) {
oprot.writeFieldBegin(SERVER_STATUS_FIELD_DESC);
oprot.writeI32(this.serverStatus.getValue());
oprot.writeFieldEnd();
}
}
oprot.writeFieldStop();
oprot.writeStructEnd();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("ServerInfo(");
boolean first = true;
if (isSetOwnerships()) {
sb.append("ownerships:");
if (this.ownerships == null) {
sb.append("null");
} else {
sb.append(this.ownerships);
}
first = false;
}
if (isSetServerStatus()) {
if (!first) sb.append(", ");
sb.append("serverStatus:");
if (this.serverStatus == null) {
sb.append("null");
} else {
sb.append(this.serverStatus);
}
first = false;
}
sb.append(")");
return sb.toString();
}
public void validate() throws TException {
// check for required fields
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy