/** * 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 EdgeMatch implements org.apache.thrift.TBase<EdgeMatch, EdgeMatch._Fields>, java.io.Serializable, Cloneable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("EdgeMatch"); private static final org.apache.thrift.protocol.TField EDGE_FIELD_DESC = new org.apache.thrift.protocol.TField("edge", org.apache.thrift.protocol.TType.STRUCT, (short)1); private static final org.apache.thrift.protocol.TField CLOSEST_POINT_FIELD_DESC = new org.apache.thrift.protocol.TField("closest_point", org.apache.thrift.protocol.TType.STRUCT, (short)2); private static final org.apache.thrift.protocol.TField SCORE_FIELD_DESC = new org.apache.thrift.protocol.TField("score", org.apache.thrift.protocol.TType.DOUBLE, (short)3); private static final org.apache.thrift.protocol.TField DISTANCE_FROM_QUERY_FIELD_DESC = new org.apache.thrift.protocol.TField("distance_from_query", org.apache.thrift.protocol.TType.DOUBLE, (short)4); private static final org.apache.thrift.protocol.TField HEADING_AT_CLOSEST_POINT_FIELD_DESC = new org.apache.thrift.protocol.TField("heading_at_closest_point", org.apache.thrift.protocol.TType.DOUBLE, (short)5); private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>(); static { schemes.put(StandardScheme.class, new EdgeMatchStandardSchemeFactory()); schemes.put(TupleScheme.class, new EdgeMatchTupleSchemeFactory()); } private org.opentripplanner.api.thrift.definition.GraphEdge edge; // required private org.opentripplanner.api.thrift.definition.LatLng closest_point; // required private double score; // required private double distance_from_query; // optional private double heading_at_closest_point; // 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 { EDGE((short)1, "edge"), CLOSEST_POINT((short)2, "closest_point"), SCORE((short)3, "score"), DISTANCE_FROM_QUERY((short)4, "distance_from_query"), HEADING_AT_CLOSEST_POINT((short)5, "heading_at_closest_point"); 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: // EDGE return EDGE; case 2: // CLOSEST_POINT return CLOSEST_POINT; case 3: // SCORE return SCORE; case 4: // DISTANCE_FROM_QUERY return DISTANCE_FROM_QUERY; case 5: // HEADING_AT_CLOSEST_POINT return HEADING_AT_CLOSEST_POINT; 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 __SCORE_ISSET_ID = 0; private static final int __DISTANCE_FROM_QUERY_ISSET_ID = 1; private static final int __HEADING_AT_CLOSEST_POINT_ISSET_ID = 2; private BitSet __isset_bit_vector = new BitSet(3); private _Fields optionals[] = {_Fields.DISTANCE_FROM_QUERY,_Fields.HEADING_AT_CLOSEST_POINT}; 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.EDGE, new org.apache.thrift.meta_data.FieldMetaData("edge", org.apache.thrift.TFieldRequirementType.REQUIRED, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT , "GraphEdge"))); tmpMap.put(_Fields.CLOSEST_POINT, new org.apache.thrift.meta_data.FieldMetaData("closest_point", org.apache.thrift.TFieldRequirementType.REQUIRED, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT , "LatLng"))); tmpMap.put(_Fields.SCORE, new org.apache.thrift.meta_data.FieldMetaData("score", org.apache.thrift.TFieldRequirementType.REQUIRED, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.DOUBLE))); tmpMap.put(_Fields.DISTANCE_FROM_QUERY, new org.apache.thrift.meta_data.FieldMetaData("distance_from_query", org.apache.thrift.TFieldRequirementType.OPTIONAL, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.DOUBLE))); tmpMap.put(_Fields.HEADING_AT_CLOSEST_POINT, new org.apache.thrift.meta_data.FieldMetaData("heading_at_closest_point", org.apache.thrift.TFieldRequirementType.OPTIONAL, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.DOUBLE))); metaDataMap = Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(EdgeMatch.class, metaDataMap); } public EdgeMatch() { } public EdgeMatch( org.opentripplanner.api.thrift.definition.GraphEdge edge, org.opentripplanner.api.thrift.definition.LatLng closest_point, double score) { this(); this.edge = edge; this.closest_point = closest_point; this.score = score; setScoreIsSet(true); } /** * Performs a deep copy on <i>other</i>. */ public EdgeMatch(EdgeMatch other) { __isset_bit_vector.clear(); __isset_bit_vector.or(other.__isset_bit_vector); if (other.isSetEdge()) { this.edge = other.edge; } if (other.isSetClosest_point()) { this.closest_point = other.closest_point; } this.score = other.score; this.distance_from_query = other.distance_from_query; this.heading_at_closest_point = other.heading_at_closest_point; } public EdgeMatch deepCopy() { return new EdgeMatch(this); } @Override public void clear() { this.edge = null; this.closest_point = null; setScoreIsSet(false); this.score = 0.0; setDistance_from_queryIsSet(false); this.distance_from_query = 0.0; setHeading_at_closest_pointIsSet(false); this.heading_at_closest_point = 0.0; } public org.opentripplanner.api.thrift.definition.GraphEdge getEdge() { return this.edge; } public void setEdge(org.opentripplanner.api.thrift.definition.GraphEdge edge) { this.edge = edge; } public void unsetEdge() { this.edge = null; } /** Returns true if field edge is set (has been assigned a value) and false otherwise */ public boolean isSetEdge() { return this.edge != null; } public void setEdgeIsSet(boolean value) { if (!value) { this.edge = null; } } public org.opentripplanner.api.thrift.definition.LatLng getClosest_point() { return this.closest_point; } public void setClosest_point(org.opentripplanner.api.thrift.definition.LatLng closest_point) { this.closest_point = closest_point; } public void unsetClosest_point() { this.closest_point = null; } /** Returns true if field closest_point is set (has been assigned a value) and false otherwise */ public boolean isSetClosest_point() { return this.closest_point != null; } public void setClosest_pointIsSet(boolean value) { if (!value) { this.closest_point = null; } } public double getScore() { return this.score; } public void setScore(double score) { this.score = score; setScoreIsSet(true); } public void unsetScore() { __isset_bit_vector.clear(__SCORE_ISSET_ID); } /** Returns true if field score is set (has been assigned a value) and false otherwise */ public boolean isSetScore() { return __isset_bit_vector.get(__SCORE_ISSET_ID); } public void setScoreIsSet(boolean value) { __isset_bit_vector.set(__SCORE_ISSET_ID, value); } public double getDistance_from_query() { return this.distance_from_query; } public void setDistance_from_query(double distance_from_query) { this.distance_from_query = distance_from_query; setDistance_from_queryIsSet(true); } public void unsetDistance_from_query() { __isset_bit_vector.clear(__DISTANCE_FROM_QUERY_ISSET_ID); } /** Returns true if field distance_from_query is set (has been assigned a value) and false otherwise */ public boolean isSetDistance_from_query() { return __isset_bit_vector.get(__DISTANCE_FROM_QUERY_ISSET_ID); } public void setDistance_from_queryIsSet(boolean value) { __isset_bit_vector.set(__DISTANCE_FROM_QUERY_ISSET_ID, value); } public double getHeading_at_closest_point() { return this.heading_at_closest_point; } public void setHeading_at_closest_point(double heading_at_closest_point) { this.heading_at_closest_point = heading_at_closest_point; setHeading_at_closest_pointIsSet(true); } public void unsetHeading_at_closest_point() { __isset_bit_vector.clear(__HEADING_AT_CLOSEST_POINT_ISSET_ID); } /** Returns true if field heading_at_closest_point is set (has been assigned a value) and false otherwise */ public boolean isSetHeading_at_closest_point() { return __isset_bit_vector.get(__HEADING_AT_CLOSEST_POINT_ISSET_ID); } public void setHeading_at_closest_pointIsSet(boolean value) { __isset_bit_vector.set(__HEADING_AT_CLOSEST_POINT_ISSET_ID, value); } public void setFieldValue(_Fields field, Object value) { switch (field) { case EDGE: if (value == null) { unsetEdge(); } else { setEdge((org.opentripplanner.api.thrift.definition.GraphEdge)value); } break; case CLOSEST_POINT: if (value == null) { unsetClosest_point(); } else { setClosest_point((org.opentripplanner.api.thrift.definition.LatLng)value); } break; case SCORE: if (value == null) { unsetScore(); } else { setScore((Double)value); } break; case DISTANCE_FROM_QUERY: if (value == null) { unsetDistance_from_query(); } else { setDistance_from_query((Double)value); } break; case HEADING_AT_CLOSEST_POINT: if (value == null) { unsetHeading_at_closest_point(); } else { setHeading_at_closest_point((Double)value); } break; } } public Object getFieldValue(_Fields field) { switch (field) { case EDGE: return getEdge(); case CLOSEST_POINT: return getClosest_point(); case SCORE: return Double.valueOf(getScore()); case DISTANCE_FROM_QUERY: return Double.valueOf(getDistance_from_query()); case HEADING_AT_CLOSEST_POINT: return Double.valueOf(getHeading_at_closest_point()); } 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 EDGE: return isSetEdge(); case CLOSEST_POINT: return isSetClosest_point(); case SCORE: return isSetScore(); case DISTANCE_FROM_QUERY: return isSetDistance_from_query(); case HEADING_AT_CLOSEST_POINT: return isSetHeading_at_closest_point(); } throw new IllegalStateException(); } @Override public boolean equals(Object that) { if (that == null) return false; if (that instanceof EdgeMatch) return this.equals((EdgeMatch)that); return false; } public boolean equals(EdgeMatch that) { if (that == null) return false; boolean this_present_edge = true && this.isSetEdge(); boolean that_present_edge = true && that.isSetEdge(); if (this_present_edge || that_present_edge) { if (!(this_present_edge && that_present_edge)) return false; if (!this.edge.equals(that.edge)) return false; } boolean this_present_closest_point = true && this.isSetClosest_point(); boolean that_present_closest_point = true && that.isSetClosest_point(); if (this_present_closest_point || that_present_closest_point) { if (!(this_present_closest_point && that_present_closest_point)) return false; if (!this.closest_point.equals(that.closest_point)) return false; } boolean this_present_score = true; boolean that_present_score = true; if (this_present_score || that_present_score) { if (!(this_present_score && that_present_score)) return false; if (this.score != that.score) return false; } boolean this_present_distance_from_query = true && this.isSetDistance_from_query(); boolean that_present_distance_from_query = true && that.isSetDistance_from_query(); if (this_present_distance_from_query || that_present_distance_from_query) { if (!(this_present_distance_from_query && that_present_distance_from_query)) return false; if (this.distance_from_query != that.distance_from_query) return false; } boolean this_present_heading_at_closest_point = true && this.isSetHeading_at_closest_point(); boolean that_present_heading_at_closest_point = true && that.isSetHeading_at_closest_point(); if (this_present_heading_at_closest_point || that_present_heading_at_closest_point) { if (!(this_present_heading_at_closest_point && that_present_heading_at_closest_point)) return false; if (this.heading_at_closest_point != that.heading_at_closest_point) return false; } return true; } @Override public int hashCode() { return 0; } public int compareTo(EdgeMatch other) { if (!getClass().equals(other.getClass())) { return getClass().getName().compareTo(other.getClass().getName()); } int lastComparison = 0; EdgeMatch typedOther = (EdgeMatch)other; lastComparison = Boolean.valueOf(isSetEdge()).compareTo(typedOther.isSetEdge()); if (lastComparison != 0) { return lastComparison; } if (isSetEdge()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.edge, typedOther.edge); if (lastComparison != 0) { return lastComparison; } } lastComparison = Boolean.valueOf(isSetClosest_point()).compareTo(typedOther.isSetClosest_point()); if (lastComparison != 0) { return lastComparison; } if (isSetClosest_point()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.closest_point, typedOther.closest_point); if (lastComparison != 0) { return lastComparison; } } lastComparison = Boolean.valueOf(isSetScore()).compareTo(typedOther.isSetScore()); if (lastComparison != 0) { return lastComparison; } if (isSetScore()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.score, typedOther.score); if (lastComparison != 0) { return lastComparison; } } lastComparison = Boolean.valueOf(isSetDistance_from_query()).compareTo(typedOther.isSetDistance_from_query()); if (lastComparison != 0) { return lastComparison; } if (isSetDistance_from_query()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.distance_from_query, typedOther.distance_from_query); if (lastComparison != 0) { return lastComparison; } } lastComparison = Boolean.valueOf(isSetHeading_at_closest_point()).compareTo(typedOther.isSetHeading_at_closest_point()); if (lastComparison != 0) { return lastComparison; } if (isSetHeading_at_closest_point()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.heading_at_closest_point, typedOther.heading_at_closest_point); 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("EdgeMatch("); boolean first = true; sb.append("edge:"); if (this.edge == null) { sb.append("null"); } else { sb.append(this.edge); } first = false; if (!first) sb.append(", "); sb.append("closest_point:"); if (this.closest_point == null) { sb.append("null"); } else { sb.append(this.closest_point); } first = false; if (!first) sb.append(", "); sb.append("score:"); sb.append(this.score); first = false; if (isSetDistance_from_query()) { if (!first) sb.append(", "); sb.append("distance_from_query:"); sb.append(this.distance_from_query); first = false; } if (isSetHeading_at_closest_point()) { if (!first) sb.append(", "); sb.append("heading_at_closest_point:"); sb.append(this.heading_at_closest_point); first = false; } sb.append(")"); return sb.toString(); } public void validate() throws org.apache.thrift.TException { // check for required fields if (!isSetEdge()) { throw new org.apache.thrift.protocol.TProtocolException("Required field 'edge' is unset! Struct:" + toString()); } if (!isSetClosest_point()) { throw new org.apache.thrift.protocol.TProtocolException("Required field 'closest_point' is unset! Struct:" + toString()); } if (!isSetScore()) { throw new org.apache.thrift.protocol.TProtocolException("Required field 'score' 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 EdgeMatchStandardSchemeFactory implements SchemeFactory { public EdgeMatchStandardScheme getScheme() { return new EdgeMatchStandardScheme(); } } private static class EdgeMatchStandardScheme extends StandardScheme<EdgeMatch> { public void read(org.apache.thrift.protocol.TProtocol iprot, EdgeMatch 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: // EDGE if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { struct.edge = new org.opentripplanner.api.thrift.definition.GraphEdge(); struct.edge.read(iprot); struct.setEdgeIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 2: // CLOSEST_POINT if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { struct.closest_point = new org.opentripplanner.api.thrift.definition.LatLng(); struct.closest_point.read(iprot); struct.setClosest_pointIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 3: // SCORE if (schemeField.type == org.apache.thrift.protocol.TType.DOUBLE) { struct.score = iprot.readDouble(); struct.setScoreIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 4: // DISTANCE_FROM_QUERY if (schemeField.type == org.apache.thrift.protocol.TType.DOUBLE) { struct.distance_from_query = iprot.readDouble(); struct.setDistance_from_queryIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 5: // HEADING_AT_CLOSEST_POINT if (schemeField.type == org.apache.thrift.protocol.TType.DOUBLE) { struct.heading_at_closest_point = iprot.readDouble(); struct.setHeading_at_closest_pointIsSet(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, EdgeMatch struct) throws org.apache.thrift.TException { struct.validate(); oprot.writeStructBegin(STRUCT_DESC); if (struct.edge != null) { oprot.writeFieldBegin(EDGE_FIELD_DESC); struct.edge.write(oprot); oprot.writeFieldEnd(); } if (struct.closest_point != null) { oprot.writeFieldBegin(CLOSEST_POINT_FIELD_DESC); struct.closest_point.write(oprot); oprot.writeFieldEnd(); } oprot.writeFieldBegin(SCORE_FIELD_DESC); oprot.writeDouble(struct.score); oprot.writeFieldEnd(); if (struct.isSetDistance_from_query()) { oprot.writeFieldBegin(DISTANCE_FROM_QUERY_FIELD_DESC); oprot.writeDouble(struct.distance_from_query); oprot.writeFieldEnd(); } if (struct.isSetHeading_at_closest_point()) { oprot.writeFieldBegin(HEADING_AT_CLOSEST_POINT_FIELD_DESC); oprot.writeDouble(struct.heading_at_closest_point); oprot.writeFieldEnd(); } oprot.writeFieldStop(); oprot.writeStructEnd(); } } private static class EdgeMatchTupleSchemeFactory implements SchemeFactory { public EdgeMatchTupleScheme getScheme() { return new EdgeMatchTupleScheme(); } } private static class EdgeMatchTupleScheme extends TupleScheme<EdgeMatch> { @Override public void write(org.apache.thrift.protocol.TProtocol prot, EdgeMatch struct) throws org.apache.thrift.TException { TTupleProtocol oprot = (TTupleProtocol) prot; struct.edge.write(oprot); struct.closest_point.write(oprot); oprot.writeDouble(struct.score); BitSet optionals = new BitSet(); if (struct.isSetDistance_from_query()) { optionals.set(0); } if (struct.isSetHeading_at_closest_point()) { optionals.set(1); } oprot.writeBitSet(optionals, 2); if (struct.isSetDistance_from_query()) { oprot.writeDouble(struct.distance_from_query); } if (struct.isSetHeading_at_closest_point()) { oprot.writeDouble(struct.heading_at_closest_point); } } @Override public void read(org.apache.thrift.protocol.TProtocol prot, EdgeMatch struct) throws org.apache.thrift.TException { TTupleProtocol iprot = (TTupleProtocol) prot; struct.edge = new org.opentripplanner.api.thrift.definition.GraphEdge(); struct.edge.read(iprot); struct.setEdgeIsSet(true); struct.closest_point = new org.opentripplanner.api.thrift.definition.LatLng(); struct.closest_point.read(iprot); struct.setClosest_pointIsSet(true); struct.score = iprot.readDouble(); struct.setScoreIsSet(true); BitSet incoming = iprot.readBitSet(2); if (incoming.get(0)) { struct.distance_from_query = iprot.readDouble(); struct.setDistance_from_queryIsSet(true); } if (incoming.get(1)) { struct.heading_at_closest_point = iprot.readDouble(); struct.setHeading_at_closest_pointIsSet(true); } } } }