/**
* Autogenerated by Thrift Compiler (0.8.0)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
package org.opentripplanner.api.thrift.definition;
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;
public class TravelState implements org.apache.thrift.TBase<TravelState, TravelState._Fields>, java.io.Serializable, Cloneable {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TravelState");
private static final org.apache.thrift.protocol.TField ARRIVAL_TIME_FIELD_DESC = new org.apache.thrift.protocol.TField("arrival_time", org.apache.thrift.protocol.TType.I64, (short)1);
private static final org.apache.thrift.protocol.TField VERTEX_FIELD_DESC = new org.apache.thrift.protocol.TField("vertex", org.apache.thrift.protocol.TType.STRUCT, (short)2);
private static final org.apache.thrift.protocol.TField BACK_EDGE_FIELD_DESC = new org.apache.thrift.protocol.TField("back_edge", org.apache.thrift.protocol.TType.STRUCT, (short)3);
private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
static {
schemes.put(StandardScheme.class, new TravelStateStandardSchemeFactory());
schemes.put(TupleScheme.class, new TravelStateTupleSchemeFactory());
}
private long arrival_time; // required
private org.opentripplanner.api.thrift.definition.GraphVertex vertex; // required
private org.opentripplanner.api.thrift.definition.GraphEdge back_edge; // optional
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
public enum _Fields implements org.apache.thrift.TFieldIdEnum {
ARRIVAL_TIME((short)1, "arrival_time"),
VERTEX((short)2, "vertex"),
BACK_EDGE((short)3, "back_edge");
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: // ARRIVAL_TIME
return ARRIVAL_TIME;
case 2: // VERTEX
return VERTEX;
case 3: // BACK_EDGE
return BACK_EDGE;
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 __ARRIVAL_TIME_ISSET_ID = 0;
private BitSet __isset_bit_vector = new BitSet(1);
private _Fields optionals[] = {_Fields.BACK_EDGE};
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.ARRIVAL_TIME, new org.apache.thrift.meta_data.FieldMetaData("arrival_time", org.apache.thrift.TFieldRequirementType.REQUIRED,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)));
tmpMap.put(_Fields.VERTEX, new org.apache.thrift.meta_data.FieldMetaData("vertex", org.apache.thrift.TFieldRequirementType.REQUIRED,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT , "GraphVertex")));
tmpMap.put(_Fields.BACK_EDGE, new org.apache.thrift.meta_data.FieldMetaData("back_edge", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT , "GraphEdge")));
metaDataMap = Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TravelState.class, metaDataMap);
}
public TravelState() {
}
public TravelState(
long arrival_time,
org.opentripplanner.api.thrift.definition.GraphVertex vertex)
{
this();
this.arrival_time = arrival_time;
setArrival_timeIsSet(true);
this.vertex = vertex;
}
/**
* Performs a deep copy on <i>other</i>.
*/
public TravelState(TravelState other) {
__isset_bit_vector.clear();
__isset_bit_vector.or(other.__isset_bit_vector);
this.arrival_time = other.arrival_time;
if (other.isSetVertex()) {
this.vertex = other.vertex;
}
if (other.isSetBack_edge()) {
this.back_edge = other.back_edge;
}
}
public TravelState deepCopy() {
return new TravelState(this);
}
@Override
public void clear() {
setArrival_timeIsSet(false);
this.arrival_time = 0;
this.vertex = null;
this.back_edge = null;
}
public long getArrival_time() {
return this.arrival_time;
}
public void setArrival_time(long arrival_time) {
this.arrival_time = arrival_time;
setArrival_timeIsSet(true);
}
public void unsetArrival_time() {
__isset_bit_vector.clear(__ARRIVAL_TIME_ISSET_ID);
}
/** Returns true if field arrival_time is set (has been assigned a value) and false otherwise */
public boolean isSetArrival_time() {
return __isset_bit_vector.get(__ARRIVAL_TIME_ISSET_ID);
}
public void setArrival_timeIsSet(boolean value) {
__isset_bit_vector.set(__ARRIVAL_TIME_ISSET_ID, value);
}
public org.opentripplanner.api.thrift.definition.GraphVertex getVertex() {
return this.vertex;
}
public void setVertex(org.opentripplanner.api.thrift.definition.GraphVertex vertex) {
this.vertex = vertex;
}
public void unsetVertex() {
this.vertex = null;
}
/** Returns true if field vertex is set (has been assigned a value) and false otherwise */
public boolean isSetVertex() {
return this.vertex != null;
}
public void setVertexIsSet(boolean value) {
if (!value) {
this.vertex = null;
}
}
public org.opentripplanner.api.thrift.definition.GraphEdge getBack_edge() {
return this.back_edge;
}
public void setBack_edge(org.opentripplanner.api.thrift.definition.GraphEdge back_edge) {
this.back_edge = back_edge;
}
public void unsetBack_edge() {
this.back_edge = null;
}
/** Returns true if field back_edge is set (has been assigned a value) and false otherwise */
public boolean isSetBack_edge() {
return this.back_edge != null;
}
public void setBack_edgeIsSet(boolean value) {
if (!value) {
this.back_edge = null;
}
}
public void setFieldValue(_Fields field, Object value) {
switch (field) {
case ARRIVAL_TIME:
if (value == null) {
unsetArrival_time();
} else {
setArrival_time((Long)value);
}
break;
case VERTEX:
if (value == null) {
unsetVertex();
} else {
setVertex((org.opentripplanner.api.thrift.definition.GraphVertex)value);
}
break;
case BACK_EDGE:
if (value == null) {
unsetBack_edge();
} else {
setBack_edge((org.opentripplanner.api.thrift.definition.GraphEdge)value);
}
break;
}
}
public Object getFieldValue(_Fields field) {
switch (field) {
case ARRIVAL_TIME:
return Long.valueOf(getArrival_time());
case VERTEX:
return getVertex();
case BACK_EDGE:
return getBack_edge();
}
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 ARRIVAL_TIME:
return isSetArrival_time();
case VERTEX:
return isSetVertex();
case BACK_EDGE:
return isSetBack_edge();
}
throw new IllegalStateException();
}
@Override
public boolean equals(Object that) {
if (that == null)
return false;
if (that instanceof TravelState)
return this.equals((TravelState)that);
return false;
}
public boolean equals(TravelState that) {
if (that == null)
return false;
boolean this_present_arrival_time = true;
boolean that_present_arrival_time = true;
if (this_present_arrival_time || that_present_arrival_time) {
if (!(this_present_arrival_time && that_present_arrival_time))
return false;
if (this.arrival_time != that.arrival_time)
return false;
}
boolean this_present_vertex = true && this.isSetVertex();
boolean that_present_vertex = true && that.isSetVertex();
if (this_present_vertex || that_present_vertex) {
if (!(this_present_vertex && that_present_vertex))
return false;
if (!this.vertex.equals(that.vertex))
return false;
}
boolean this_present_back_edge = true && this.isSetBack_edge();
boolean that_present_back_edge = true && that.isSetBack_edge();
if (this_present_back_edge || that_present_back_edge) {
if (!(this_present_back_edge && that_present_back_edge))
return false;
if (!this.back_edge.equals(that.back_edge))
return false;
}
return true;
}
@Override
public int hashCode() {
return 0;
}
public int compareTo(TravelState other) {
if (!getClass().equals(other.getClass())) {
return getClass().getName().compareTo(other.getClass().getName());
}
int lastComparison = 0;
TravelState typedOther = (TravelState)other;
lastComparison = Boolean.valueOf(isSetArrival_time()).compareTo(typedOther.isSetArrival_time());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetArrival_time()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.arrival_time, typedOther.arrival_time);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetVertex()).compareTo(typedOther.isSetVertex());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetVertex()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.vertex, typedOther.vertex);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetBack_edge()).compareTo(typedOther.isSetBack_edge());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetBack_edge()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.back_edge, typedOther.back_edge);
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("TravelState(");
boolean first = true;
sb.append("arrival_time:");
sb.append(this.arrival_time);
first = false;
if (!first) sb.append(", ");
sb.append("vertex:");
if (this.vertex == null) {
sb.append("null");
} else {
sb.append(this.vertex);
}
first = false;
if (isSetBack_edge()) {
if (!first) sb.append(", ");
sb.append("back_edge:");
if (this.back_edge == null) {
sb.append("null");
} else {
sb.append(this.back_edge);
}
first = false;
}
sb.append(")");
return sb.toString();
}
public void validate() throws org.apache.thrift.TException {
// check for required fields
if (!isSetArrival_time()) {
throw new org.apache.thrift.protocol.TProtocolException("Required field 'arrival_time' is unset! Struct:" + toString());
}
if (!isSetVertex()) {
throw new org.apache.thrift.protocol.TProtocolException("Required field 'vertex' is unset! Struct:" + toString());
}
}
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 TravelStateStandardSchemeFactory implements SchemeFactory {
public TravelStateStandardScheme getScheme() {
return new TravelStateStandardScheme();
}
}
private static class TravelStateStandardScheme extends StandardScheme<TravelState> {
public void read(org.apache.thrift.protocol.TProtocol iprot, TravelState 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: // ARRIVAL_TIME
if (schemeField.type == org.apache.thrift.protocol.TType.I64) {
struct.arrival_time = iprot.readI64();
struct.setArrival_timeIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 2: // VERTEX
if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
struct.vertex = new org.opentripplanner.api.thrift.definition.GraphVertex();
struct.vertex.read(iprot);
struct.setVertexIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 3: // BACK_EDGE
if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
struct.back_edge = new org.opentripplanner.api.thrift.definition.GraphEdge();
struct.back_edge.read(iprot);
struct.setBack_edgeIsSet(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();
struct.validate();
}
public void write(org.apache.thrift.protocol.TProtocol oprot, TravelState struct) throws org.apache.thrift.TException {
struct.validate();
oprot.writeStructBegin(STRUCT_DESC);
oprot.writeFieldBegin(ARRIVAL_TIME_FIELD_DESC);
oprot.writeI64(struct.arrival_time);
oprot.writeFieldEnd();
if (struct.vertex != null) {
oprot.writeFieldBegin(VERTEX_FIELD_DESC);
struct.vertex.write(oprot);
oprot.writeFieldEnd();
}
if (struct.back_edge != null) {
if (struct.isSetBack_edge()) {
oprot.writeFieldBegin(BACK_EDGE_FIELD_DESC);
struct.back_edge.write(oprot);
oprot.writeFieldEnd();
}
}
oprot.writeFieldStop();
oprot.writeStructEnd();
}
}
private static class TravelStateTupleSchemeFactory implements SchemeFactory {
public TravelStateTupleScheme getScheme() {
return new TravelStateTupleScheme();
}
}
private static class TravelStateTupleScheme extends TupleScheme<TravelState> {
@Override
public void write(org.apache.thrift.protocol.TProtocol prot, TravelState struct) throws org.apache.thrift.TException {
TTupleProtocol oprot = (TTupleProtocol) prot;
oprot.writeI64(struct.arrival_time);
struct.vertex.write(oprot);
BitSet optionals = new BitSet();
if (struct.isSetBack_edge()) {
optionals.set(0);
}
oprot.writeBitSet(optionals, 1);
if (struct.isSetBack_edge()) {
struct.back_edge.write(oprot);
}
}
@Override
public void read(org.apache.thrift.protocol.TProtocol prot, TravelState struct) throws org.apache.thrift.TException {
TTupleProtocol iprot = (TTupleProtocol) prot;
struct.arrival_time = iprot.readI64();
struct.setArrival_timeIsSet(true);
struct.vertex = new org.opentripplanner.api.thrift.definition.GraphVertex();
struct.vertex.read(iprot);
struct.setVertexIsSet(true);
BitSet incoming = iprot.readBitSet(1);
if (incoming.get(0)) {
struct.back_edge = new org.opentripplanner.api.thrift.definition.GraphEdge();
struct.back_edge.read(iprot);
struct.setBack_edgeIsSet(true);
}
}
}
}