/**
* Autogenerated by Thrift Compiler (0.8.0)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
package org.riksa.bombah.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 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;
/**
* Fine grained controller
*/
public class ControllerState implements org.apache.thrift.TBase<ControllerState, ControllerState._Fields>, java.io.Serializable, Cloneable {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("ControllerState");
private static final org.apache.thrift.protocol.TField DIRECTION_PAD_DOWN_FIELD_DESC = new org.apache.thrift.protocol.TField("directionPadDown", org.apache.thrift.protocol.TType.BOOL, (short)1);
private static final org.apache.thrift.protocol.TField DIRECTION_FIELD_DESC = new org.apache.thrift.protocol.TField("direction", org.apache.thrift.protocol.TType.I32, (short)2);
private static final org.apache.thrift.protocol.TField KEY1_DOWN_FIELD_DESC = new org.apache.thrift.protocol.TField("key1Down", org.apache.thrift.protocol.TType.BOOL, (short)3);
private static final org.apache.thrift.protocol.TField KEY2_DOWN_FIELD_DESC = new org.apache.thrift.protocol.TField("key2Down", org.apache.thrift.protocol.TType.BOOL, (short)4);
private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
static {
schemes.put(StandardScheme.class, new ControllerStateStandardSchemeFactory());
schemes.put(TupleScheme.class, new ControllerStateTupleSchemeFactory());
}
public boolean directionPadDown; // required
/**
*
* @see Direction
*/
public Direction direction; // required
public boolean key1Down; // required
public boolean key2Down; // 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 {
DIRECTION_PAD_DOWN((short)1, "directionPadDown"),
/**
*
* @see Direction
*/
DIRECTION((short)2, "direction"),
KEY1_DOWN((short)3, "key1Down"),
KEY2_DOWN((short)4, "key2Down");
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: // DIRECTION_PAD_DOWN
return DIRECTION_PAD_DOWN;
case 2: // DIRECTION
return DIRECTION;
case 3: // KEY1_DOWN
return KEY1_DOWN;
case 4: // KEY2_DOWN
return KEY2_DOWN;
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 __DIRECTIONPADDOWN_ISSET_ID = 0;
private static final int __KEY1DOWN_ISSET_ID = 1;
private static final int __KEY2DOWN_ISSET_ID = 2;
private BitSet __isset_bit_vector = new BitSet(3);
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.DIRECTION_PAD_DOWN, new org.apache.thrift.meta_data.FieldMetaData("directionPadDown", org.apache.thrift.TFieldRequirementType.DEFAULT,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL)));
tmpMap.put(_Fields.DIRECTION, new org.apache.thrift.meta_data.FieldMetaData("direction", org.apache.thrift.TFieldRequirementType.DEFAULT,
new org.apache.thrift.meta_data.EnumMetaData(org.apache.thrift.protocol.TType.ENUM, Direction.class)));
tmpMap.put(_Fields.KEY1_DOWN, new org.apache.thrift.meta_data.FieldMetaData("key1Down", org.apache.thrift.TFieldRequirementType.DEFAULT,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL)));
tmpMap.put(_Fields.KEY2_DOWN, new org.apache.thrift.meta_data.FieldMetaData("key2Down", org.apache.thrift.TFieldRequirementType.DEFAULT,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL)));
metaDataMap = Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(ControllerState.class, metaDataMap);
}
public ControllerState() {
}
public ControllerState(
boolean directionPadDown,
Direction direction,
boolean key1Down,
boolean key2Down)
{
this();
this.directionPadDown = directionPadDown;
setDirectionPadDownIsSet(true);
this.direction = direction;
this.key1Down = key1Down;
setKey1DownIsSet(true);
this.key2Down = key2Down;
setKey2DownIsSet(true);
}
/**
* Performs a deep copy on <i>other</i>.
*/
public ControllerState(ControllerState other) {
__isset_bit_vector.clear();
__isset_bit_vector.or(other.__isset_bit_vector);
this.directionPadDown = other.directionPadDown;
if (other.isSetDirection()) {
this.direction = other.direction;
}
this.key1Down = other.key1Down;
this.key2Down = other.key2Down;
}
public ControllerState deepCopy() {
return new ControllerState(this);
}
@Override
public void clear() {
setDirectionPadDownIsSet(false);
this.directionPadDown = false;
this.direction = null;
setKey1DownIsSet(false);
this.key1Down = false;
setKey2DownIsSet(false);
this.key2Down = false;
}
public boolean isDirectionPadDown() {
return this.directionPadDown;
}
public ControllerState setDirectionPadDown(boolean directionPadDown) {
this.directionPadDown = directionPadDown;
setDirectionPadDownIsSet(true);
return this;
}
public void unsetDirectionPadDown() {
__isset_bit_vector.clear(__DIRECTIONPADDOWN_ISSET_ID);
}
/** Returns true if field directionPadDown is set (has been assigned a value) and false otherwise */
public boolean isSetDirectionPadDown() {
return __isset_bit_vector.get(__DIRECTIONPADDOWN_ISSET_ID);
}
public void setDirectionPadDownIsSet(boolean value) {
__isset_bit_vector.set(__DIRECTIONPADDOWN_ISSET_ID, value);
}
/**
*
* @see Direction
*/
public Direction getDirection() {
return this.direction;
}
/**
*
* @see Direction
*/
public ControllerState setDirection(Direction direction) {
this.direction = direction;
return this;
}
public void unsetDirection() {
this.direction = null;
}
/** Returns true if field direction is set (has been assigned a value) and false otherwise */
public boolean isSetDirection() {
return this.direction != null;
}
public void setDirectionIsSet(boolean value) {
if (!value) {
this.direction = null;
}
}
public boolean isKey1Down() {
return this.key1Down;
}
public ControllerState setKey1Down(boolean key1Down) {
this.key1Down = key1Down;
setKey1DownIsSet(true);
return this;
}
public void unsetKey1Down() {
__isset_bit_vector.clear(__KEY1DOWN_ISSET_ID);
}
/** Returns true if field key1Down is set (has been assigned a value) and false otherwise */
public boolean isSetKey1Down() {
return __isset_bit_vector.get(__KEY1DOWN_ISSET_ID);
}
public void setKey1DownIsSet(boolean value) {
__isset_bit_vector.set(__KEY1DOWN_ISSET_ID, value);
}
public boolean isKey2Down() {
return this.key2Down;
}
public ControllerState setKey2Down(boolean key2Down) {
this.key2Down = key2Down;
setKey2DownIsSet(true);
return this;
}
public void unsetKey2Down() {
__isset_bit_vector.clear(__KEY2DOWN_ISSET_ID);
}
/** Returns true if field key2Down is set (has been assigned a value) and false otherwise */
public boolean isSetKey2Down() {
return __isset_bit_vector.get(__KEY2DOWN_ISSET_ID);
}
public void setKey2DownIsSet(boolean value) {
__isset_bit_vector.set(__KEY2DOWN_ISSET_ID, value);
}
public void setFieldValue(_Fields field, Object value) {
switch (field) {
case DIRECTION_PAD_DOWN:
if (value == null) {
unsetDirectionPadDown();
} else {
setDirectionPadDown((Boolean)value);
}
break;
case DIRECTION:
if (value == null) {
unsetDirection();
} else {
setDirection((Direction)value);
}
break;
case KEY1_DOWN:
if (value == null) {
unsetKey1Down();
} else {
setKey1Down((Boolean)value);
}
break;
case KEY2_DOWN:
if (value == null) {
unsetKey2Down();
} else {
setKey2Down((Boolean)value);
}
break;
}
}
public Object getFieldValue(_Fields field) {
switch (field) {
case DIRECTION_PAD_DOWN:
return Boolean.valueOf(isDirectionPadDown());
case DIRECTION:
return getDirection();
case KEY1_DOWN:
return Boolean.valueOf(isKey1Down());
case KEY2_DOWN:
return Boolean.valueOf(isKey2Down());
}
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 DIRECTION_PAD_DOWN:
return isSetDirectionPadDown();
case DIRECTION:
return isSetDirection();
case KEY1_DOWN:
return isSetKey1Down();
case KEY2_DOWN:
return isSetKey2Down();
}
throw new IllegalStateException();
}
@Override
public boolean equals(Object that) {
if (that == null)
return false;
if (that instanceof ControllerState)
return this.equals((ControllerState)that);
return false;
}
public boolean equals(ControllerState that) {
if (that == null)
return false;
boolean this_present_directionPadDown = true;
boolean that_present_directionPadDown = true;
if (this_present_directionPadDown || that_present_directionPadDown) {
if (!(this_present_directionPadDown && that_present_directionPadDown))
return false;
if (this.directionPadDown != that.directionPadDown)
return false;
}
boolean this_present_direction = true && this.isSetDirection();
boolean that_present_direction = true && that.isSetDirection();
if (this_present_direction || that_present_direction) {
if (!(this_present_direction && that_present_direction))
return false;
if (!this.direction.equals(that.direction))
return false;
}
boolean this_present_key1Down = true;
boolean that_present_key1Down = true;
if (this_present_key1Down || that_present_key1Down) {
if (!(this_present_key1Down && that_present_key1Down))
return false;
if (this.key1Down != that.key1Down)
return false;
}
boolean this_present_key2Down = true;
boolean that_present_key2Down = true;
if (this_present_key2Down || that_present_key2Down) {
if (!(this_present_key2Down && that_present_key2Down))
return false;
if (this.key2Down != that.key2Down)
return false;
}
return true;
}
@Override
public int hashCode() {
return 0;
}
public int compareTo(ControllerState other) {
if (!getClass().equals(other.getClass())) {
return getClass().getName().compareTo(other.getClass().getName());
}
int lastComparison = 0;
ControllerState typedOther = (ControllerState)other;
lastComparison = Boolean.valueOf(isSetDirectionPadDown()).compareTo(typedOther.isSetDirectionPadDown());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetDirectionPadDown()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.directionPadDown, typedOther.directionPadDown);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetDirection()).compareTo(typedOther.isSetDirection());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetDirection()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.direction, typedOther.direction);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetKey1Down()).compareTo(typedOther.isSetKey1Down());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetKey1Down()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.key1Down, typedOther.key1Down);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetKey2Down()).compareTo(typedOther.isSetKey2Down());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetKey2Down()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.key2Down, typedOther.key2Down);
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("ControllerState(");
boolean first = true;
sb.append("directionPadDown:");
sb.append(this.directionPadDown);
first = false;
if (!first) sb.append(", ");
sb.append("direction:");
if (this.direction == null) {
sb.append("null");
} else {
sb.append(this.direction);
}
first = false;
if (!first) sb.append(", ");
sb.append("key1Down:");
sb.append(this.key1Down);
first = false;
if (!first) sb.append(", ");
sb.append("key2Down:");
sb.append(this.key2Down);
first = false;
sb.append(")");
return sb.toString();
}
public void validate() throws org.apache.thrift.TException {
// check for required fields
}
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_bit_vector = new BitSet(1);
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 ControllerStateStandardSchemeFactory implements SchemeFactory {
public ControllerStateStandardScheme getScheme() {
return new ControllerStateStandardScheme();
}
}
private static class ControllerStateStandardScheme extends StandardScheme<ControllerState> {
public void read(org.apache.thrift.protocol.TProtocol iprot, ControllerState 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: // DIRECTION_PAD_DOWN
if (schemeField.type == org.apache.thrift.protocol.TType.BOOL) {
struct.directionPadDown = iprot.readBool();
struct.setDirectionPadDownIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 2: // DIRECTION
if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
struct.direction = Direction.findByValue(iprot.readI32());
struct.setDirectionIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 3: // KEY1_DOWN
if (schemeField.type == org.apache.thrift.protocol.TType.BOOL) {
struct.key1Down = iprot.readBool();
struct.setKey1DownIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 4: // KEY2_DOWN
if (schemeField.type == org.apache.thrift.protocol.TType.BOOL) {
struct.key2Down = iprot.readBool();
struct.setKey2DownIsSet(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
struct.validate();
}
public void write(org.apache.thrift.protocol.TProtocol oprot, ControllerState struct) throws org.apache.thrift.TException {
struct.validate();
oprot.writeStructBegin(STRUCT_DESC);
oprot.writeFieldBegin(DIRECTION_PAD_DOWN_FIELD_DESC);
oprot.writeBool(struct.directionPadDown);
oprot.writeFieldEnd();
if (struct.direction != null) {
oprot.writeFieldBegin(DIRECTION_FIELD_DESC);
oprot.writeI32(struct.direction.getValue());
oprot.writeFieldEnd();
}
oprot.writeFieldBegin(KEY1_DOWN_FIELD_DESC);
oprot.writeBool(struct.key1Down);
oprot.writeFieldEnd();
oprot.writeFieldBegin(KEY2_DOWN_FIELD_DESC);
oprot.writeBool(struct.key2Down);
oprot.writeFieldEnd();
oprot.writeFieldStop();
oprot.writeStructEnd();
}
}
private static class ControllerStateTupleSchemeFactory implements SchemeFactory {
public ControllerStateTupleScheme getScheme() {
return new ControllerStateTupleScheme();
}
}
private static class ControllerStateTupleScheme extends TupleScheme<ControllerState> {
@Override
public void write(org.apache.thrift.protocol.TProtocol prot, ControllerState struct) throws org.apache.thrift.TException {
TTupleProtocol oprot = (TTupleProtocol) prot;
BitSet optionals = new BitSet();
if (struct.isSetDirectionPadDown()) {
optionals.set(0);
}
if (struct.isSetDirection()) {
optionals.set(1);
}
if (struct.isSetKey1Down()) {
optionals.set(2);
}
if (struct.isSetKey2Down()) {
optionals.set(3);
}
oprot.writeBitSet(optionals, 4);
if (struct.isSetDirectionPadDown()) {
oprot.writeBool(struct.directionPadDown);
}
if (struct.isSetDirection()) {
oprot.writeI32(struct.direction.getValue());
}
if (struct.isSetKey1Down()) {
oprot.writeBool(struct.key1Down);
}
if (struct.isSetKey2Down()) {
oprot.writeBool(struct.key2Down);
}
}
@Override
public void read(org.apache.thrift.protocol.TProtocol prot, ControllerState struct) throws org.apache.thrift.TException {
TTupleProtocol iprot = (TTupleProtocol) prot;
BitSet incoming = iprot.readBitSet(4);
if (incoming.get(0)) {
struct.directionPadDown = iprot.readBool();
struct.setDirectionPadDownIsSet(true);
}
if (incoming.get(1)) {
struct.direction = Direction.findByValue(iprot.readI32());
struct.setDirectionIsSet(true);
}
if (incoming.get(2)) {
struct.key1Down = iprot.readBool();
struct.setKey1DownIsSet(true);
}
if (incoming.get(3)) {
struct.key2Down = iprot.readBool();
struct.setKey2DownIsSet(true);
}
}
}
}