/**
* 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 HankException extends org.apache.thrift.TUnion<HankException, HankException._Fields> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("HankException");
private static final org.apache.thrift.protocol.TField WRONG_HOST_FIELD_DESC = new org.apache.thrift.protocol.TField("wrong_host", org.apache.thrift.protocol.TType.BOOL, (short)1);
private static final org.apache.thrift.protocol.TField NO_SUCH_DOMAIN_FIELD_DESC = new org.apache.thrift.protocol.TField("no_such_domain", org.apache.thrift.protocol.TType.BOOL, (short)2);
private static final org.apache.thrift.protocol.TField NO_REPLICA_FIELD_DESC = new org.apache.thrift.protocol.TField("no_replica", org.apache.thrift.protocol.TType.BOOL, (short)3);
private static final org.apache.thrift.protocol.TField NO_CONNECTION_AVAILABLE_FIELD_DESC = new org.apache.thrift.protocol.TField("no_connection_available", org.apache.thrift.protocol.TType.BOOL, (short)4);
private static final org.apache.thrift.protocol.TField FAILED_RETRIES_FIELD_DESC = new org.apache.thrift.protocol.TField("failed_retries", org.apache.thrift.protocol.TType.I32, (short)5);
private static final org.apache.thrift.protocol.TField INTERNAL_ERROR_FIELD_DESC = new org.apache.thrift.protocol.TField("internal_error", org.apache.thrift.protocol.TType.STRING, (short)6);
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
public enum _Fields implements org.apache.thrift.TFieldIdEnum {
/**
* The host queried is not assigned the key that was requested
*/
WRONG_HOST((short)1, "wrong_host"),
/**
* The domain passed in the request does not correspond to a valid domain
*/
NO_SUCH_DOMAIN((short)2, "no_such_domain"),
/**
* There was no replica for a given partition
*/
NO_REPLICA((short)3, "no_replica"),
/**
* There were no available connections for a given partition
*/
NO_CONNECTION_AVAILABLE((short)4, "no_connection_available"),
/**
* Failed to perform query after a specified number of retries
*/
FAILED_RETRIES((short)5, "failed_retries"),
/**
* There was some internal error in the server. This is pretty bad.
*/
INTERNAL_ERROR((short)6, "internal_error");
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: // WRONG_HOST
return WRONG_HOST;
case 2: // NO_SUCH_DOMAIN
return NO_SUCH_DOMAIN;
case 3: // NO_REPLICA
return NO_REPLICA;
case 4: // NO_CONNECTION_AVAILABLE
return NO_CONNECTION_AVAILABLE;
case 5: // FAILED_RETRIES
return FAILED_RETRIES;
case 6: // INTERNAL_ERROR
return INTERNAL_ERROR;
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;
}
}
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.WRONG_HOST, new org.apache.thrift.meta_data.FieldMetaData("wrong_host", org.apache.thrift.TFieldRequirementType.DEFAULT,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL)));
tmpMap.put(_Fields.NO_SUCH_DOMAIN, new org.apache.thrift.meta_data.FieldMetaData("no_such_domain", org.apache.thrift.TFieldRequirementType.DEFAULT,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL)));
tmpMap.put(_Fields.NO_REPLICA, new org.apache.thrift.meta_data.FieldMetaData("no_replica", org.apache.thrift.TFieldRequirementType.DEFAULT,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL)));
tmpMap.put(_Fields.NO_CONNECTION_AVAILABLE, new org.apache.thrift.meta_data.FieldMetaData("no_connection_available", org.apache.thrift.TFieldRequirementType.DEFAULT,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL)));
tmpMap.put(_Fields.FAILED_RETRIES, new org.apache.thrift.meta_data.FieldMetaData("failed_retries", org.apache.thrift.TFieldRequirementType.DEFAULT,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)));
tmpMap.put(_Fields.INTERNAL_ERROR, new org.apache.thrift.meta_data.FieldMetaData("internal_error", org.apache.thrift.TFieldRequirementType.DEFAULT,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
metaDataMap = Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(HankException.class, metaDataMap);
}
public HankException() {
super();
}
public HankException(_Fields setField, Object value) {
super(setField, value);
}
public HankException(HankException other) {
super(other);
}
public HankException deepCopy() {
return new HankException(this);
}
public static HankException wrong_host(boolean value) {
HankException x = new HankException();
x.set_wrong_host(value);
return x;
}
public static HankException no_such_domain(boolean value) {
HankException x = new HankException();
x.set_no_such_domain(value);
return x;
}
public static HankException no_replica(boolean value) {
HankException x = new HankException();
x.set_no_replica(value);
return x;
}
public static HankException no_connection_available(boolean value) {
HankException x = new HankException();
x.set_no_connection_available(value);
return x;
}
public static HankException failed_retries(int value) {
HankException x = new HankException();
x.set_failed_retries(value);
return x;
}
public static HankException internal_error(String value) {
HankException x = new HankException();
x.set_internal_error(value);
return x;
}
@Override
protected void checkType(_Fields setField, Object value) throws ClassCastException {
switch (setField) {
case WRONG_HOST:
if (value instanceof Boolean) {
break;
}
throw new ClassCastException("Was expecting value of type Boolean for field 'wrong_host', but got " + value.getClass().getSimpleName());
case NO_SUCH_DOMAIN:
if (value instanceof Boolean) {
break;
}
throw new ClassCastException("Was expecting value of type Boolean for field 'no_such_domain', but got " + value.getClass().getSimpleName());
case NO_REPLICA:
if (value instanceof Boolean) {
break;
}
throw new ClassCastException("Was expecting value of type Boolean for field 'no_replica', but got " + value.getClass().getSimpleName());
case NO_CONNECTION_AVAILABLE:
if (value instanceof Boolean) {
break;
}
throw new ClassCastException("Was expecting value of type Boolean for field 'no_connection_available', but got " + value.getClass().getSimpleName());
case FAILED_RETRIES:
if (value instanceof Integer) {
break;
}
throw new ClassCastException("Was expecting value of type Integer for field 'failed_retries', but got " + value.getClass().getSimpleName());
case INTERNAL_ERROR:
if (value instanceof String) {
break;
}
throw new ClassCastException("Was expecting value of type String for field 'internal_error', but got " + value.getClass().getSimpleName());
default:
throw new IllegalArgumentException("Unknown field id " + setField);
}
}
@Override
protected Object standardSchemeReadValue(org.apache.thrift.protocol.TProtocol iprot, org.apache.thrift.protocol.TField field) throws org.apache.thrift.TException {
_Fields setField = _Fields.findByThriftId(field.id);
if (setField != null) {
switch (setField) {
case WRONG_HOST:
if (field.type == WRONG_HOST_FIELD_DESC.type) {
Boolean wrong_host;
wrong_host = iprot.readBool();
return wrong_host;
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
return null;
}
case NO_SUCH_DOMAIN:
if (field.type == NO_SUCH_DOMAIN_FIELD_DESC.type) {
Boolean no_such_domain;
no_such_domain = iprot.readBool();
return no_such_domain;
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
return null;
}
case NO_REPLICA:
if (field.type == NO_REPLICA_FIELD_DESC.type) {
Boolean no_replica;
no_replica = iprot.readBool();
return no_replica;
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
return null;
}
case NO_CONNECTION_AVAILABLE:
if (field.type == NO_CONNECTION_AVAILABLE_FIELD_DESC.type) {
Boolean no_connection_available;
no_connection_available = iprot.readBool();
return no_connection_available;
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
return null;
}
case FAILED_RETRIES:
if (field.type == FAILED_RETRIES_FIELD_DESC.type) {
Integer failed_retries;
failed_retries = iprot.readI32();
return failed_retries;
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
return null;
}
case INTERNAL_ERROR:
if (field.type == INTERNAL_ERROR_FIELD_DESC.type) {
String internal_error;
internal_error = iprot.readString();
return internal_error;
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
return null;
}
default:
throw new IllegalStateException("setField wasn't null, but didn't match any of the case statements!");
}
} else {
return null;
}
}
@Override
protected void standardSchemeWriteValue(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
switch (setField_) {
case WRONG_HOST:
Boolean wrong_host = (Boolean)value_;
oprot.writeBool(wrong_host);
return;
case NO_SUCH_DOMAIN:
Boolean no_such_domain = (Boolean)value_;
oprot.writeBool(no_such_domain);
return;
case NO_REPLICA:
Boolean no_replica = (Boolean)value_;
oprot.writeBool(no_replica);
return;
case NO_CONNECTION_AVAILABLE:
Boolean no_connection_available = (Boolean)value_;
oprot.writeBool(no_connection_available);
return;
case FAILED_RETRIES:
Integer failed_retries = (Integer)value_;
oprot.writeI32(failed_retries);
return;
case INTERNAL_ERROR:
String internal_error = (String)value_;
oprot.writeString(internal_error);
return;
default:
throw new IllegalStateException("Cannot write union with unknown field " + setField_);
}
}
@Override
protected Object tupleSchemeReadValue(org.apache.thrift.protocol.TProtocol iprot, short fieldID) throws org.apache.thrift.TException {
_Fields setField = _Fields.findByThriftId(fieldID);
if (setField != null) {
switch (setField) {
case WRONG_HOST:
Boolean wrong_host;
wrong_host = iprot.readBool();
return wrong_host;
case NO_SUCH_DOMAIN:
Boolean no_such_domain;
no_such_domain = iprot.readBool();
return no_such_domain;
case NO_REPLICA:
Boolean no_replica;
no_replica = iprot.readBool();
return no_replica;
case NO_CONNECTION_AVAILABLE:
Boolean no_connection_available;
no_connection_available = iprot.readBool();
return no_connection_available;
case FAILED_RETRIES:
Integer failed_retries;
failed_retries = iprot.readI32();
return failed_retries;
case INTERNAL_ERROR:
String internal_error;
internal_error = iprot.readString();
return internal_error;
default:
throw new IllegalStateException("setField wasn't null, but didn't match any of the case statements!");
}
} else {
throw new TProtocolException("Couldn't find a field with field id " + fieldID);
}
}
@Override
protected void tupleSchemeWriteValue(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
switch (setField_) {
case WRONG_HOST:
Boolean wrong_host = (Boolean)value_;
oprot.writeBool(wrong_host);
return;
case NO_SUCH_DOMAIN:
Boolean no_such_domain = (Boolean)value_;
oprot.writeBool(no_such_domain);
return;
case NO_REPLICA:
Boolean no_replica = (Boolean)value_;
oprot.writeBool(no_replica);
return;
case NO_CONNECTION_AVAILABLE:
Boolean no_connection_available = (Boolean)value_;
oprot.writeBool(no_connection_available);
return;
case FAILED_RETRIES:
Integer failed_retries = (Integer)value_;
oprot.writeI32(failed_retries);
return;
case INTERNAL_ERROR:
String internal_error = (String)value_;
oprot.writeString(internal_error);
return;
default:
throw new IllegalStateException("Cannot write union with unknown field " + setField_);
}
}
@Override
protected org.apache.thrift.protocol.TField getFieldDesc(_Fields setField) {
switch (setField) {
case WRONG_HOST:
return WRONG_HOST_FIELD_DESC;
case NO_SUCH_DOMAIN:
return NO_SUCH_DOMAIN_FIELD_DESC;
case NO_REPLICA:
return NO_REPLICA_FIELD_DESC;
case NO_CONNECTION_AVAILABLE:
return NO_CONNECTION_AVAILABLE_FIELD_DESC;
case FAILED_RETRIES:
return FAILED_RETRIES_FIELD_DESC;
case INTERNAL_ERROR:
return INTERNAL_ERROR_FIELD_DESC;
default:
throw new IllegalArgumentException("Unknown field id " + setField);
}
}
@Override
protected org.apache.thrift.protocol.TStruct getStructDesc() {
return STRUCT_DESC;
}
@Override
protected _Fields enumForId(short id) {
return _Fields.findByThriftIdOrThrow(id);
}
public _Fields fieldForId(int fieldId) {
return _Fields.findByThriftId(fieldId);
}
/**
* The host queried is not assigned the key that was requested
*/
public boolean get_wrong_host() {
if (getSetField() == _Fields.WRONG_HOST) {
return (Boolean)getFieldValue();
} else {
throw new RuntimeException("Cannot get field 'wrong_host' because union is currently set to " + getFieldDesc(getSetField()).name);
}
}
/**
* The host queried is not assigned the key that was requested
*/
public void set_wrong_host(boolean value) {
setField_ = _Fields.WRONG_HOST;
value_ = value;
}
/**
* The domain passed in the request does not correspond to a valid domain
*/
public boolean get_no_such_domain() {
if (getSetField() == _Fields.NO_SUCH_DOMAIN) {
return (Boolean)getFieldValue();
} else {
throw new RuntimeException("Cannot get field 'no_such_domain' because union is currently set to " + getFieldDesc(getSetField()).name);
}
}
/**
* The domain passed in the request does not correspond to a valid domain
*/
public void set_no_such_domain(boolean value) {
setField_ = _Fields.NO_SUCH_DOMAIN;
value_ = value;
}
/**
* There was no replica for a given partition
*/
public boolean get_no_replica() {
if (getSetField() == _Fields.NO_REPLICA) {
return (Boolean)getFieldValue();
} else {
throw new RuntimeException("Cannot get field 'no_replica' because union is currently set to " + getFieldDesc(getSetField()).name);
}
}
/**
* There was no replica for a given partition
*/
public void set_no_replica(boolean value) {
setField_ = _Fields.NO_REPLICA;
value_ = value;
}
/**
* There were no available connections for a given partition
*/
public boolean get_no_connection_available() {
if (getSetField() == _Fields.NO_CONNECTION_AVAILABLE) {
return (Boolean)getFieldValue();
} else {
throw new RuntimeException("Cannot get field 'no_connection_available' because union is currently set to " + getFieldDesc(getSetField()).name);
}
}
/**
* There were no available connections for a given partition
*/
public void set_no_connection_available(boolean value) {
setField_ = _Fields.NO_CONNECTION_AVAILABLE;
value_ = value;
}
/**
* Failed to perform query after a specified number of retries
*/
public int get_failed_retries() {
if (getSetField() == _Fields.FAILED_RETRIES) {
return (Integer)getFieldValue();
} else {
throw new RuntimeException("Cannot get field 'failed_retries' because union is currently set to " + getFieldDesc(getSetField()).name);
}
}
/**
* Failed to perform query after a specified number of retries
*/
public void set_failed_retries(int value) {
setField_ = _Fields.FAILED_RETRIES;
value_ = value;
}
/**
* There was some internal error in the server. This is pretty bad.
*/
public String get_internal_error() {
if (getSetField() == _Fields.INTERNAL_ERROR) {
return (String)getFieldValue();
} else {
throw new RuntimeException("Cannot get field 'internal_error' because union is currently set to " + getFieldDesc(getSetField()).name);
}
}
/**
* There was some internal error in the server. This is pretty bad.
*/
public void set_internal_error(String value) {
if (value == null) throw new NullPointerException();
setField_ = _Fields.INTERNAL_ERROR;
value_ = value;
}
public boolean is_set_wrong_host() {
return setField_ == _Fields.WRONG_HOST;
}
public boolean is_set_no_such_domain() {
return setField_ == _Fields.NO_SUCH_DOMAIN;
}
public boolean is_set_no_replica() {
return setField_ == _Fields.NO_REPLICA;
}
public boolean is_set_no_connection_available() {
return setField_ == _Fields.NO_CONNECTION_AVAILABLE;
}
public boolean is_set_failed_retries() {
return setField_ == _Fields.FAILED_RETRIES;
}
public boolean is_set_internal_error() {
return setField_ == _Fields.INTERNAL_ERROR;
}
public boolean equals(Object other) {
if (other instanceof HankException) {
return equals((HankException)other);
} else {
return false;
}
}
public boolean equals(HankException other) {
return other != null && getSetField() == other.getSetField() && getFieldValue().equals(other.getFieldValue());
}
@Override
public int compareTo(HankException other) {
int lastComparison = org.apache.thrift.TBaseHelper.compareTo(getSetField(), other.getSetField());
if (lastComparison == 0) {
return org.apache.thrift.TBaseHelper.compareTo(getFieldValue(), other.getFieldValue());
}
return lastComparison;
}
@Override
public int hashCode() {
HashCodeBuilder hcb = new HashCodeBuilder();
hcb.append(this.getClass().getName());
org.apache.thrift.TFieldIdEnum setField = getSetField();
if (setField != null) {
hcb.append(setField.getThriftFieldId());
Object value = getFieldValue();
if (value instanceof org.apache.thrift.TEnum) {
hcb.append(((org.apache.thrift.TEnum)getFieldValue()).getValue());
} else {
hcb.append(value);
}
}
return hcb.toHashCode();
}
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);
}
}
}