/** * 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 TripParameters implements org.apache.thrift.TBase<TripParameters, TripParameters._Fields>, java.io.Serializable, Cloneable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TripParameters"); private static final org.apache.thrift.protocol.TField ORIGIN_FIELD_DESC = new org.apache.thrift.protocol.TField("origin", org.apache.thrift.protocol.TType.STRUCT, (short)1); private static final org.apache.thrift.protocol.TField DESTINATION_FIELD_DESC = new org.apache.thrift.protocol.TField("destination", org.apache.thrift.protocol.TType.STRUCT, (short)2); private static final org.apache.thrift.protocol.TField START_TIME_FIELD_DESC = new org.apache.thrift.protocol.TField("start_time", org.apache.thrift.protocol.TType.I64, (short)3); private static final org.apache.thrift.protocol.TField ARRIVE_BY_FIELD_DESC = new org.apache.thrift.protocol.TField("arrive_by", org.apache.thrift.protocol.TType.I64, (short)4); private static final org.apache.thrift.protocol.TField ALLOWED_MODES_FIELD_DESC = new org.apache.thrift.protocol.TField("allowed_modes", org.apache.thrift.protocol.TType.SET, (short)5); private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>(); static { schemes.put(StandardScheme.class, new TripParametersStandardSchemeFactory()); schemes.put(TupleScheme.class, new TripParametersTupleSchemeFactory()); } private org.opentripplanner.api.thrift.definition.Location origin; // required private org.opentripplanner.api.thrift.definition.Location destination; // required private long start_time; // optional private long arrive_by; // optional private Set<TravelMode> allowed_modes; // 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 { ORIGIN((short)1, "origin"), DESTINATION((short)2, "destination"), START_TIME((short)3, "start_time"), ARRIVE_BY((short)4, "arrive_by"), ALLOWED_MODES((short)5, "allowed_modes"); 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: // ORIGIN return ORIGIN; case 2: // DESTINATION return DESTINATION; case 3: // START_TIME return START_TIME; case 4: // ARRIVE_BY return ARRIVE_BY; case 5: // ALLOWED_MODES return ALLOWED_MODES; 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 __START_TIME_ISSET_ID = 0; private static final int __ARRIVE_BY_ISSET_ID = 1; private BitSet __isset_bit_vector = new BitSet(2); private _Fields optionals[] = {_Fields.START_TIME,_Fields.ARRIVE_BY,_Fields.ALLOWED_MODES}; 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.ORIGIN, new org.apache.thrift.meta_data.FieldMetaData("origin", org.apache.thrift.TFieldRequirementType.REQUIRED, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT , "Location"))); tmpMap.put(_Fields.DESTINATION, new org.apache.thrift.meta_data.FieldMetaData("destination", org.apache.thrift.TFieldRequirementType.REQUIRED, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT , "Location"))); tmpMap.put(_Fields.START_TIME, new org.apache.thrift.meta_data.FieldMetaData("start_time", org.apache.thrift.TFieldRequirementType.OPTIONAL, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64))); tmpMap.put(_Fields.ARRIVE_BY, new org.apache.thrift.meta_data.FieldMetaData("arrive_by", org.apache.thrift.TFieldRequirementType.OPTIONAL, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64))); tmpMap.put(_Fields.ALLOWED_MODES, new org.apache.thrift.meta_data.FieldMetaData("allowed_modes", org.apache.thrift.TFieldRequirementType.OPTIONAL, new org.apache.thrift.meta_data.SetMetaData(org.apache.thrift.protocol.TType.SET, new org.apache.thrift.meta_data.EnumMetaData(org.apache.thrift.protocol.TType.ENUM, TravelMode.class)))); metaDataMap = Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TripParameters.class, metaDataMap); } public TripParameters() { } public TripParameters( org.opentripplanner.api.thrift.definition.Location origin, org.opentripplanner.api.thrift.definition.Location destination) { this(); this.origin = origin; this.destination = destination; } /** * Performs a deep copy on <i>other</i>. */ public TripParameters(TripParameters other) { __isset_bit_vector.clear(); __isset_bit_vector.or(other.__isset_bit_vector); if (other.isSetOrigin()) { this.origin = other.origin; } if (other.isSetDestination()) { this.destination = other.destination; } this.start_time = other.start_time; this.arrive_by = other.arrive_by; if (other.isSetAllowed_modes()) { Set<TravelMode> __this__allowed_modes = new HashSet<TravelMode>(); for (TravelMode other_element : other.allowed_modes) { __this__allowed_modes.add(other_element); } this.allowed_modes = __this__allowed_modes; } } public TripParameters deepCopy() { return new TripParameters(this); } @Override public void clear() { this.origin = null; this.destination = null; setStart_timeIsSet(false); this.start_time = 0; setArrive_byIsSet(false); this.arrive_by = 0; this.allowed_modes = null; } public org.opentripplanner.api.thrift.definition.Location getOrigin() { return this.origin; } public void setOrigin(org.opentripplanner.api.thrift.definition.Location origin) { this.origin = origin; } public void unsetOrigin() { this.origin = null; } /** Returns true if field origin is set (has been assigned a value) and false otherwise */ public boolean isSetOrigin() { return this.origin != null; } public void setOriginIsSet(boolean value) { if (!value) { this.origin = null; } } public org.opentripplanner.api.thrift.definition.Location getDestination() { return this.destination; } public void setDestination(org.opentripplanner.api.thrift.definition.Location destination) { this.destination = destination; } public void unsetDestination() { this.destination = null; } /** Returns true if field destination is set (has been assigned a value) and false otherwise */ public boolean isSetDestination() { return this.destination != null; } public void setDestinationIsSet(boolean value) { if (!value) { this.destination = null; } } public long getStart_time() { return this.start_time; } public void setStart_time(long start_time) { this.start_time = start_time; setStart_timeIsSet(true); } public void unsetStart_time() { __isset_bit_vector.clear(__START_TIME_ISSET_ID); } /** Returns true if field start_time is set (has been assigned a value) and false otherwise */ public boolean isSetStart_time() { return __isset_bit_vector.get(__START_TIME_ISSET_ID); } public void setStart_timeIsSet(boolean value) { __isset_bit_vector.set(__START_TIME_ISSET_ID, value); } public long getArrive_by() { return this.arrive_by; } public void setArrive_by(long arrive_by) { this.arrive_by = arrive_by; setArrive_byIsSet(true); } public void unsetArrive_by() { __isset_bit_vector.clear(__ARRIVE_BY_ISSET_ID); } /** Returns true if field arrive_by is set (has been assigned a value) and false otherwise */ public boolean isSetArrive_by() { return __isset_bit_vector.get(__ARRIVE_BY_ISSET_ID); } public void setArrive_byIsSet(boolean value) { __isset_bit_vector.set(__ARRIVE_BY_ISSET_ID, value); } public int getAllowed_modesSize() { return (this.allowed_modes == null) ? 0 : this.allowed_modes.size(); } public java.util.Iterator<TravelMode> getAllowed_modesIterator() { return (this.allowed_modes == null) ? null : this.allowed_modes.iterator(); } public void addToAllowed_modes(TravelMode elem) { if (this.allowed_modes == null) { this.allowed_modes = new HashSet<TravelMode>(); } this.allowed_modes.add(elem); } public Set<TravelMode> getAllowed_modes() { return this.allowed_modes; } public void setAllowed_modes(Set<TravelMode> allowed_modes) { this.allowed_modes = allowed_modes; } public void unsetAllowed_modes() { this.allowed_modes = null; } /** Returns true if field allowed_modes is set (has been assigned a value) and false otherwise */ public boolean isSetAllowed_modes() { return this.allowed_modes != null; } public void setAllowed_modesIsSet(boolean value) { if (!value) { this.allowed_modes = null; } } public void setFieldValue(_Fields field, Object value) { switch (field) { case ORIGIN: if (value == null) { unsetOrigin(); } else { setOrigin((org.opentripplanner.api.thrift.definition.Location)value); } break; case DESTINATION: if (value == null) { unsetDestination(); } else { setDestination((org.opentripplanner.api.thrift.definition.Location)value); } break; case START_TIME: if (value == null) { unsetStart_time(); } else { setStart_time((Long)value); } break; case ARRIVE_BY: if (value == null) { unsetArrive_by(); } else { setArrive_by((Long)value); } break; case ALLOWED_MODES: if (value == null) { unsetAllowed_modes(); } else { setAllowed_modes((Set<TravelMode>)value); } break; } } public Object getFieldValue(_Fields field) { switch (field) { case ORIGIN: return getOrigin(); case DESTINATION: return getDestination(); case START_TIME: return Long.valueOf(getStart_time()); case ARRIVE_BY: return Long.valueOf(getArrive_by()); case ALLOWED_MODES: return getAllowed_modes(); } 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 ORIGIN: return isSetOrigin(); case DESTINATION: return isSetDestination(); case START_TIME: return isSetStart_time(); case ARRIVE_BY: return isSetArrive_by(); case ALLOWED_MODES: return isSetAllowed_modes(); } throw new IllegalStateException(); } @Override public boolean equals(Object that) { if (that == null) return false; if (that instanceof TripParameters) return this.equals((TripParameters)that); return false; } public boolean equals(TripParameters that) { if (that == null) return false; boolean this_present_origin = true && this.isSetOrigin(); boolean that_present_origin = true && that.isSetOrigin(); if (this_present_origin || that_present_origin) { if (!(this_present_origin && that_present_origin)) return false; if (!this.origin.equals(that.origin)) return false; } boolean this_present_destination = true && this.isSetDestination(); boolean that_present_destination = true && that.isSetDestination(); if (this_present_destination || that_present_destination) { if (!(this_present_destination && that_present_destination)) return false; if (!this.destination.equals(that.destination)) return false; } boolean this_present_start_time = true && this.isSetStart_time(); boolean that_present_start_time = true && that.isSetStart_time(); if (this_present_start_time || that_present_start_time) { if (!(this_present_start_time && that_present_start_time)) return false; if (this.start_time != that.start_time) return false; } boolean this_present_arrive_by = true && this.isSetArrive_by(); boolean that_present_arrive_by = true && that.isSetArrive_by(); if (this_present_arrive_by || that_present_arrive_by) { if (!(this_present_arrive_by && that_present_arrive_by)) return false; if (this.arrive_by != that.arrive_by) return false; } boolean this_present_allowed_modes = true && this.isSetAllowed_modes(); boolean that_present_allowed_modes = true && that.isSetAllowed_modes(); if (this_present_allowed_modes || that_present_allowed_modes) { if (!(this_present_allowed_modes && that_present_allowed_modes)) return false; if (!this.allowed_modes.equals(that.allowed_modes)) return false; } return true; } @Override public int hashCode() { return 0; } public int compareTo(TripParameters other) { if (!getClass().equals(other.getClass())) { return getClass().getName().compareTo(other.getClass().getName()); } int lastComparison = 0; TripParameters typedOther = (TripParameters)other; lastComparison = Boolean.valueOf(isSetOrigin()).compareTo(typedOther.isSetOrigin()); if (lastComparison != 0) { return lastComparison; } if (isSetOrigin()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.origin, typedOther.origin); if (lastComparison != 0) { return lastComparison; } } lastComparison = Boolean.valueOf(isSetDestination()).compareTo(typedOther.isSetDestination()); if (lastComparison != 0) { return lastComparison; } if (isSetDestination()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.destination, typedOther.destination); if (lastComparison != 0) { return lastComparison; } } lastComparison = Boolean.valueOf(isSetStart_time()).compareTo(typedOther.isSetStart_time()); if (lastComparison != 0) { return lastComparison; } if (isSetStart_time()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.start_time, typedOther.start_time); if (lastComparison != 0) { return lastComparison; } } lastComparison = Boolean.valueOf(isSetArrive_by()).compareTo(typedOther.isSetArrive_by()); if (lastComparison != 0) { return lastComparison; } if (isSetArrive_by()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.arrive_by, typedOther.arrive_by); if (lastComparison != 0) { return lastComparison; } } lastComparison = Boolean.valueOf(isSetAllowed_modes()).compareTo(typedOther.isSetAllowed_modes()); if (lastComparison != 0) { return lastComparison; } if (isSetAllowed_modes()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.allowed_modes, typedOther.allowed_modes); 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("TripParameters("); boolean first = true; sb.append("origin:"); if (this.origin == null) { sb.append("null"); } else { sb.append(this.origin); } first = false; if (!first) sb.append(", "); sb.append("destination:"); if (this.destination == null) { sb.append("null"); } else { sb.append(this.destination); } first = false; if (isSetStart_time()) { if (!first) sb.append(", "); sb.append("start_time:"); sb.append(this.start_time); first = false; } if (isSetArrive_by()) { if (!first) sb.append(", "); sb.append("arrive_by:"); sb.append(this.arrive_by); first = false; } if (isSetAllowed_modes()) { if (!first) sb.append(", "); sb.append("allowed_modes:"); if (this.allowed_modes == null) { sb.append("null"); } else { sb.append(this.allowed_modes); } first = false; } sb.append(")"); return sb.toString(); } public void validate() throws org.apache.thrift.TException { // check for required fields if (!isSetOrigin()) { throw new org.apache.thrift.protocol.TProtocolException("Required field 'origin' is unset! Struct:" + toString()); } if (!isSetDestination()) { throw new org.apache.thrift.protocol.TProtocolException("Required field 'destination' 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 TripParametersStandardSchemeFactory implements SchemeFactory { public TripParametersStandardScheme getScheme() { return new TripParametersStandardScheme(); } } private static class TripParametersStandardScheme extends StandardScheme<TripParameters> { public void read(org.apache.thrift.protocol.TProtocol iprot, TripParameters 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: // ORIGIN if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { struct.origin = new org.opentripplanner.api.thrift.definition.Location(); struct.origin.read(iprot); struct.setOriginIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 2: // DESTINATION if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { struct.destination = new org.opentripplanner.api.thrift.definition.Location(); struct.destination.read(iprot); struct.setDestinationIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 3: // START_TIME if (schemeField.type == org.apache.thrift.protocol.TType.I64) { struct.start_time = iprot.readI64(); struct.setStart_timeIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 4: // ARRIVE_BY if (schemeField.type == org.apache.thrift.protocol.TType.I64) { struct.arrive_by = iprot.readI64(); struct.setArrive_byIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 5: // ALLOWED_MODES if (schemeField.type == org.apache.thrift.protocol.TType.SET) { { org.apache.thrift.protocol.TSet _set16 = iprot.readSetBegin(); struct.allowed_modes = new HashSet<TravelMode>(2*_set16.size); for (int _i17 = 0; _i17 < _set16.size; ++_i17) { TravelMode _elem18; // required _elem18 = TravelMode.findByValue(iprot.readI32()); struct.allowed_modes.add(_elem18); } iprot.readSetEnd(); } struct.setAllowed_modesIsSet(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, TripParameters struct) throws org.apache.thrift.TException { struct.validate(); oprot.writeStructBegin(STRUCT_DESC); if (struct.origin != null) { oprot.writeFieldBegin(ORIGIN_FIELD_DESC); struct.origin.write(oprot); oprot.writeFieldEnd(); } if (struct.destination != null) { oprot.writeFieldBegin(DESTINATION_FIELD_DESC); struct.destination.write(oprot); oprot.writeFieldEnd(); } if (struct.isSetStart_time()) { oprot.writeFieldBegin(START_TIME_FIELD_DESC); oprot.writeI64(struct.start_time); oprot.writeFieldEnd(); } if (struct.isSetArrive_by()) { oprot.writeFieldBegin(ARRIVE_BY_FIELD_DESC); oprot.writeI64(struct.arrive_by); oprot.writeFieldEnd(); } if (struct.allowed_modes != null) { if (struct.isSetAllowed_modes()) { oprot.writeFieldBegin(ALLOWED_MODES_FIELD_DESC); { oprot.writeSetBegin(new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.I32, struct.allowed_modes.size())); for (TravelMode _iter19 : struct.allowed_modes) { oprot.writeI32(_iter19.getValue()); } oprot.writeSetEnd(); } oprot.writeFieldEnd(); } } oprot.writeFieldStop(); oprot.writeStructEnd(); } } private static class TripParametersTupleSchemeFactory implements SchemeFactory { public TripParametersTupleScheme getScheme() { return new TripParametersTupleScheme(); } } private static class TripParametersTupleScheme extends TupleScheme<TripParameters> { @Override public void write(org.apache.thrift.protocol.TProtocol prot, TripParameters struct) throws org.apache.thrift.TException { TTupleProtocol oprot = (TTupleProtocol) prot; struct.origin.write(oprot); struct.destination.write(oprot); BitSet optionals = new BitSet(); if (struct.isSetStart_time()) { optionals.set(0); } if (struct.isSetArrive_by()) { optionals.set(1); } if (struct.isSetAllowed_modes()) { optionals.set(2); } oprot.writeBitSet(optionals, 3); if (struct.isSetStart_time()) { oprot.writeI64(struct.start_time); } if (struct.isSetArrive_by()) { oprot.writeI64(struct.arrive_by); } if (struct.isSetAllowed_modes()) { { oprot.writeI32(struct.allowed_modes.size()); for (TravelMode _iter20 : struct.allowed_modes) { oprot.writeI32(_iter20.getValue()); } } } } @Override public void read(org.apache.thrift.protocol.TProtocol prot, TripParameters struct) throws org.apache.thrift.TException { TTupleProtocol iprot = (TTupleProtocol) prot; struct.origin = new org.opentripplanner.api.thrift.definition.Location(); struct.origin.read(iprot); struct.setOriginIsSet(true); struct.destination = new org.opentripplanner.api.thrift.definition.Location(); struct.destination.read(iprot); struct.setDestinationIsSet(true); BitSet incoming = iprot.readBitSet(3); if (incoming.get(0)) { struct.start_time = iprot.readI64(); struct.setStart_timeIsSet(true); } if (incoming.get(1)) { struct.arrive_by = iprot.readI64(); struct.setArrive_byIsSet(true); } if (incoming.get(2)) { { org.apache.thrift.protocol.TSet _set21 = new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.I32, iprot.readI32()); struct.allowed_modes = new HashSet<TravelMode>(2*_set21.size); for (int _i22 = 0; _i22 < _set21.size; ++_i22) { TravelMode _elem23; // required _elem23 = TravelMode.findByValue(iprot.readI32()); struct.allowed_modes.add(_elem23); } } struct.setAllowed_modesIsSet(true); } } } }