/** * 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 GraphVertex implements org.apache.thrift.TBase<GraphVertex, GraphVertex._Fields>, java.io.Serializable, Cloneable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("GraphVertex"); private static final org.apache.thrift.protocol.TField LABEL_FIELD_DESC = new org.apache.thrift.protocol.TField("label", org.apache.thrift.protocol.TType.STRING, (short)1); private static final org.apache.thrift.protocol.TField ID_FIELD_DESC = new org.apache.thrift.protocol.TField("id", org.apache.thrift.protocol.TType.I32, (short)2); private static final org.apache.thrift.protocol.TField LAT_LNG_FIELD_DESC = new org.apache.thrift.protocol.TField("lat_lng", org.apache.thrift.protocol.TType.STRUCT, (short)3); private static final org.apache.thrift.protocol.TField NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("name", org.apache.thrift.protocol.TType.STRING, (short)4); private static final org.apache.thrift.protocol.TField IN_DEGREE_FIELD_DESC = new org.apache.thrift.protocol.TField("in_degree", org.apache.thrift.protocol.TType.I32, (short)5); private static final org.apache.thrift.protocol.TField OUT_DEGREE_FIELD_DESC = new org.apache.thrift.protocol.TField("out_degree", org.apache.thrift.protocol.TType.I32, (short)6); private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>(); static { schemes.put(StandardScheme.class, new GraphVertexStandardSchemeFactory()); schemes.put(TupleScheme.class, new GraphVertexTupleSchemeFactory()); } private String label; // required private int id; // required private org.opentripplanner.api.thrift.definition.LatLng lat_lng; // optional private String name; // optional private int in_degree; // optional private int out_degree; // 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 { LABEL((short)1, "label"), ID((short)2, "id"), LAT_LNG((short)3, "lat_lng"), NAME((short)4, "name"), IN_DEGREE((short)5, "in_degree"), OUT_DEGREE((short)6, "out_degree"); 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: // LABEL return LABEL; case 2: // ID return ID; case 3: // LAT_LNG return LAT_LNG; case 4: // NAME return NAME; case 5: // IN_DEGREE return IN_DEGREE; case 6: // OUT_DEGREE return OUT_DEGREE; 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 __ID_ISSET_ID = 0; private static final int __IN_DEGREE_ISSET_ID = 1; private static final int __OUT_DEGREE_ISSET_ID = 2; private BitSet __isset_bit_vector = new BitSet(3); private _Fields optionals[] = {_Fields.LAT_LNG,_Fields.NAME,_Fields.IN_DEGREE,_Fields.OUT_DEGREE}; 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.LABEL, new org.apache.thrift.meta_data.FieldMetaData("label", org.apache.thrift.TFieldRequirementType.REQUIRED, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); tmpMap.put(_Fields.ID, new org.apache.thrift.meta_data.FieldMetaData("id", org.apache.thrift.TFieldRequirementType.REQUIRED, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32))); tmpMap.put(_Fields.LAT_LNG, new org.apache.thrift.meta_data.FieldMetaData("lat_lng", org.apache.thrift.TFieldRequirementType.OPTIONAL, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT , "LatLng"))); tmpMap.put(_Fields.NAME, new org.apache.thrift.meta_data.FieldMetaData("name", org.apache.thrift.TFieldRequirementType.OPTIONAL, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); tmpMap.put(_Fields.IN_DEGREE, new org.apache.thrift.meta_data.FieldMetaData("in_degree", org.apache.thrift.TFieldRequirementType.OPTIONAL, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32))); tmpMap.put(_Fields.OUT_DEGREE, new org.apache.thrift.meta_data.FieldMetaData("out_degree", org.apache.thrift.TFieldRequirementType.OPTIONAL, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32))); metaDataMap = Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(GraphVertex.class, metaDataMap); } public GraphVertex() { } public GraphVertex( String label, int id) { this(); this.label = label; this.id = id; setIdIsSet(true); } /** * Performs a deep copy on <i>other</i>. */ public GraphVertex(GraphVertex other) { __isset_bit_vector.clear(); __isset_bit_vector.or(other.__isset_bit_vector); if (other.isSetLabel()) { this.label = other.label; } this.id = other.id; if (other.isSetLat_lng()) { this.lat_lng = other.lat_lng; } if (other.isSetName()) { this.name = other.name; } this.in_degree = other.in_degree; this.out_degree = other.out_degree; } public GraphVertex deepCopy() { return new GraphVertex(this); } @Override public void clear() { this.label = null; setIdIsSet(false); this.id = 0; this.lat_lng = null; this.name = null; setIn_degreeIsSet(false); this.in_degree = 0; setOut_degreeIsSet(false); this.out_degree = 0; } public String getLabel() { return this.label; } public void setLabel(String label) { this.label = label; } public void unsetLabel() { this.label = null; } /** Returns true if field label is set (has been assigned a value) and false otherwise */ public boolean isSetLabel() { return this.label != null; } public void setLabelIsSet(boolean value) { if (!value) { this.label = null; } } public int getId() { return this.id; } public void setId(int id) { this.id = id; setIdIsSet(true); } public void unsetId() { __isset_bit_vector.clear(__ID_ISSET_ID); } /** Returns true if field id is set (has been assigned a value) and false otherwise */ public boolean isSetId() { return __isset_bit_vector.get(__ID_ISSET_ID); } public void setIdIsSet(boolean value) { __isset_bit_vector.set(__ID_ISSET_ID, value); } public org.opentripplanner.api.thrift.definition.LatLng getLat_lng() { return this.lat_lng; } public void setLat_lng(org.opentripplanner.api.thrift.definition.LatLng lat_lng) { this.lat_lng = lat_lng; } public void unsetLat_lng() { this.lat_lng = null; } /** Returns true if field lat_lng is set (has been assigned a value) and false otherwise */ public boolean isSetLat_lng() { return this.lat_lng != null; } public void setLat_lngIsSet(boolean value) { if (!value) { this.lat_lng = null; } } public String getName() { return this.name; } public void setName(String name) { this.name = name; } public void unsetName() { this.name = null; } /** Returns true if field name is set (has been assigned a value) and false otherwise */ public boolean isSetName() { return this.name != null; } public void setNameIsSet(boolean value) { if (!value) { this.name = null; } } public int getIn_degree() { return this.in_degree; } public void setIn_degree(int in_degree) { this.in_degree = in_degree; setIn_degreeIsSet(true); } public void unsetIn_degree() { __isset_bit_vector.clear(__IN_DEGREE_ISSET_ID); } /** Returns true if field in_degree is set (has been assigned a value) and false otherwise */ public boolean isSetIn_degree() { return __isset_bit_vector.get(__IN_DEGREE_ISSET_ID); } public void setIn_degreeIsSet(boolean value) { __isset_bit_vector.set(__IN_DEGREE_ISSET_ID, value); } public int getOut_degree() { return this.out_degree; } public void setOut_degree(int out_degree) { this.out_degree = out_degree; setOut_degreeIsSet(true); } public void unsetOut_degree() { __isset_bit_vector.clear(__OUT_DEGREE_ISSET_ID); } /** Returns true if field out_degree is set (has been assigned a value) and false otherwise */ public boolean isSetOut_degree() { return __isset_bit_vector.get(__OUT_DEGREE_ISSET_ID); } public void setOut_degreeIsSet(boolean value) { __isset_bit_vector.set(__OUT_DEGREE_ISSET_ID, value); } public void setFieldValue(_Fields field, Object value) { switch (field) { case LABEL: if (value == null) { unsetLabel(); } else { setLabel((String)value); } break; case ID: if (value == null) { unsetId(); } else { setId((Integer)value); } break; case LAT_LNG: if (value == null) { unsetLat_lng(); } else { setLat_lng((org.opentripplanner.api.thrift.definition.LatLng)value); } break; case NAME: if (value == null) { unsetName(); } else { setName((String)value); } break; case IN_DEGREE: if (value == null) { unsetIn_degree(); } else { setIn_degree((Integer)value); } break; case OUT_DEGREE: if (value == null) { unsetOut_degree(); } else { setOut_degree((Integer)value); } break; } } public Object getFieldValue(_Fields field) { switch (field) { case LABEL: return getLabel(); case ID: return Integer.valueOf(getId()); case LAT_LNG: return getLat_lng(); case NAME: return getName(); case IN_DEGREE: return Integer.valueOf(getIn_degree()); case OUT_DEGREE: return Integer.valueOf(getOut_degree()); } 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 LABEL: return isSetLabel(); case ID: return isSetId(); case LAT_LNG: return isSetLat_lng(); case NAME: return isSetName(); case IN_DEGREE: return isSetIn_degree(); case OUT_DEGREE: return isSetOut_degree(); } throw new IllegalStateException(); } @Override public boolean equals(Object that) { if (that == null) return false; if (that instanceof GraphVertex) return this.equals((GraphVertex)that); return false; } public boolean equals(GraphVertex that) { if (that == null) return false; boolean this_present_label = true && this.isSetLabel(); boolean that_present_label = true && that.isSetLabel(); if (this_present_label || that_present_label) { if (!(this_present_label && that_present_label)) return false; if (!this.label.equals(that.label)) return false; } boolean this_present_id = true; boolean that_present_id = true; if (this_present_id || that_present_id) { if (!(this_present_id && that_present_id)) return false; if (this.id != that.id) return false; } boolean this_present_lat_lng = true && this.isSetLat_lng(); boolean that_present_lat_lng = true && that.isSetLat_lng(); if (this_present_lat_lng || that_present_lat_lng) { if (!(this_present_lat_lng && that_present_lat_lng)) return false; if (!this.lat_lng.equals(that.lat_lng)) return false; } boolean this_present_name = true && this.isSetName(); boolean that_present_name = true && that.isSetName(); if (this_present_name || that_present_name) { if (!(this_present_name && that_present_name)) return false; if (!this.name.equals(that.name)) return false; } boolean this_present_in_degree = true && this.isSetIn_degree(); boolean that_present_in_degree = true && that.isSetIn_degree(); if (this_present_in_degree || that_present_in_degree) { if (!(this_present_in_degree && that_present_in_degree)) return false; if (this.in_degree != that.in_degree) return false; } boolean this_present_out_degree = true && this.isSetOut_degree(); boolean that_present_out_degree = true && that.isSetOut_degree(); if (this_present_out_degree || that_present_out_degree) { if (!(this_present_out_degree && that_present_out_degree)) return false; if (this.out_degree != that.out_degree) return false; } return true; } @Override public int hashCode() { return 0; } public int compareTo(GraphVertex other) { if (!getClass().equals(other.getClass())) { return getClass().getName().compareTo(other.getClass().getName()); } int lastComparison = 0; GraphVertex typedOther = (GraphVertex)other; lastComparison = Boolean.valueOf(isSetLabel()).compareTo(typedOther.isSetLabel()); if (lastComparison != 0) { return lastComparison; } if (isSetLabel()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.label, typedOther.label); if (lastComparison != 0) { return lastComparison; } } lastComparison = Boolean.valueOf(isSetId()).compareTo(typedOther.isSetId()); if (lastComparison != 0) { return lastComparison; } if (isSetId()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.id, typedOther.id); if (lastComparison != 0) { return lastComparison; } } lastComparison = Boolean.valueOf(isSetLat_lng()).compareTo(typedOther.isSetLat_lng()); if (lastComparison != 0) { return lastComparison; } if (isSetLat_lng()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.lat_lng, typedOther.lat_lng); if (lastComparison != 0) { return lastComparison; } } lastComparison = Boolean.valueOf(isSetName()).compareTo(typedOther.isSetName()); if (lastComparison != 0) { return lastComparison; } if (isSetName()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.name, typedOther.name); if (lastComparison != 0) { return lastComparison; } } lastComparison = Boolean.valueOf(isSetIn_degree()).compareTo(typedOther.isSetIn_degree()); if (lastComparison != 0) { return lastComparison; } if (isSetIn_degree()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.in_degree, typedOther.in_degree); if (lastComparison != 0) { return lastComparison; } } lastComparison = Boolean.valueOf(isSetOut_degree()).compareTo(typedOther.isSetOut_degree()); if (lastComparison != 0) { return lastComparison; } if (isSetOut_degree()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.out_degree, typedOther.out_degree); 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("GraphVertex("); boolean first = true; sb.append("label:"); if (this.label == null) { sb.append("null"); } else { sb.append(this.label); } first = false; if (!first) sb.append(", "); sb.append("id:"); sb.append(this.id); first = false; if (isSetLat_lng()) { if (!first) sb.append(", "); sb.append("lat_lng:"); if (this.lat_lng == null) { sb.append("null"); } else { sb.append(this.lat_lng); } first = false; } if (isSetName()) { if (!first) sb.append(", "); sb.append("name:"); if (this.name == null) { sb.append("null"); } else { sb.append(this.name); } first = false; } if (isSetIn_degree()) { if (!first) sb.append(", "); sb.append("in_degree:"); sb.append(this.in_degree); first = false; } if (isSetOut_degree()) { if (!first) sb.append(", "); sb.append("out_degree:"); sb.append(this.out_degree); first = false; } sb.append(")"); return sb.toString(); } public void validate() throws org.apache.thrift.TException { // check for required fields if (!isSetLabel()) { throw new org.apache.thrift.protocol.TProtocolException("Required field 'label' is unset! Struct:" + toString()); } if (!isSetId()) { throw new org.apache.thrift.protocol.TProtocolException("Required field 'id' 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 GraphVertexStandardSchemeFactory implements SchemeFactory { public GraphVertexStandardScheme getScheme() { return new GraphVertexStandardScheme(); } } private static class GraphVertexStandardScheme extends StandardScheme<GraphVertex> { public void read(org.apache.thrift.protocol.TProtocol iprot, GraphVertex 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: // LABEL if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { struct.label = iprot.readString(); struct.setLabelIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 2: // ID if (schemeField.type == org.apache.thrift.protocol.TType.I32) { struct.id = iprot.readI32(); struct.setIdIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 3: // LAT_LNG if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { struct.lat_lng = new org.opentripplanner.api.thrift.definition.LatLng(); struct.lat_lng.read(iprot); struct.setLat_lngIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 4: // NAME if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { struct.name = iprot.readString(); struct.setNameIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 5: // IN_DEGREE if (schemeField.type == org.apache.thrift.protocol.TType.I32) { struct.in_degree = iprot.readI32(); struct.setIn_degreeIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 6: // OUT_DEGREE if (schemeField.type == org.apache.thrift.protocol.TType.I32) { struct.out_degree = iprot.readI32(); struct.setOut_degreeIsSet(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, GraphVertex struct) throws org.apache.thrift.TException { struct.validate(); oprot.writeStructBegin(STRUCT_DESC); if (struct.label != null) { oprot.writeFieldBegin(LABEL_FIELD_DESC); oprot.writeString(struct.label); oprot.writeFieldEnd(); } oprot.writeFieldBegin(ID_FIELD_DESC); oprot.writeI32(struct.id); oprot.writeFieldEnd(); if (struct.lat_lng != null) { if (struct.isSetLat_lng()) { oprot.writeFieldBegin(LAT_LNG_FIELD_DESC); struct.lat_lng.write(oprot); oprot.writeFieldEnd(); } } if (struct.name != null) { if (struct.isSetName()) { oprot.writeFieldBegin(NAME_FIELD_DESC); oprot.writeString(struct.name); oprot.writeFieldEnd(); } } if (struct.isSetIn_degree()) { oprot.writeFieldBegin(IN_DEGREE_FIELD_DESC); oprot.writeI32(struct.in_degree); oprot.writeFieldEnd(); } if (struct.isSetOut_degree()) { oprot.writeFieldBegin(OUT_DEGREE_FIELD_DESC); oprot.writeI32(struct.out_degree); oprot.writeFieldEnd(); } oprot.writeFieldStop(); oprot.writeStructEnd(); } } private static class GraphVertexTupleSchemeFactory implements SchemeFactory { public GraphVertexTupleScheme getScheme() { return new GraphVertexTupleScheme(); } } private static class GraphVertexTupleScheme extends TupleScheme<GraphVertex> { @Override public void write(org.apache.thrift.protocol.TProtocol prot, GraphVertex struct) throws org.apache.thrift.TException { TTupleProtocol oprot = (TTupleProtocol) prot; oprot.writeString(struct.label); oprot.writeI32(struct.id); BitSet optionals = new BitSet(); if (struct.isSetLat_lng()) { optionals.set(0); } if (struct.isSetName()) { optionals.set(1); } if (struct.isSetIn_degree()) { optionals.set(2); } if (struct.isSetOut_degree()) { optionals.set(3); } oprot.writeBitSet(optionals, 4); if (struct.isSetLat_lng()) { struct.lat_lng.write(oprot); } if (struct.isSetName()) { oprot.writeString(struct.name); } if (struct.isSetIn_degree()) { oprot.writeI32(struct.in_degree); } if (struct.isSetOut_degree()) { oprot.writeI32(struct.out_degree); } } @Override public void read(org.apache.thrift.protocol.TProtocol prot, GraphVertex struct) throws org.apache.thrift.TException { TTupleProtocol iprot = (TTupleProtocol) prot; struct.label = iprot.readString(); struct.setLabelIsSet(true); struct.id = iprot.readI32(); struct.setIdIsSet(true); BitSet incoming = iprot.readBitSet(4); if (incoming.get(0)) { struct.lat_lng = new org.opentripplanner.api.thrift.definition.LatLng(); struct.lat_lng.read(iprot); struct.setLat_lngIsSet(true); } if (incoming.get(1)) { struct.name = iprot.readString(); struct.setNameIsSet(true); } if (incoming.get(2)) { struct.in_degree = iprot.readI32(); struct.setIn_degreeIsSet(true); } if (incoming.get(3)) { struct.out_degree = iprot.readI32(); struct.setOut_degreeIsSet(true); } } } }