All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.opentripplanner.transit.raptor.api.path.TransitPathLeg Maven / Gradle / Ivy

There is a newer version: 2.5.0
Show newest version
package org.opentripplanner.transit.raptor.api.path;

import org.opentripplanner.transit.raptor.api.transit.RaptorTripSchedule;

import java.util.Objects;

/**
 * Represent a transit leg in a path.
 *
 * @param  The TripSchedule type defined by the user of the raptor API.
 */
public final class TransitPathLeg extends IntermediatePathLeg {

    private final PathLeg next;
    private final T trip;

    public TransitPathLeg(int fromStop, int fromTime, int toStop, int toTime, T trip, PathLeg next) {
        super(fromStop, fromTime, toStop, toTime);
        this.next = next;
        this.trip = trip;
    }

    /**
     * The trip schedule info object passed into Raptor routing algorithm. 
     */
    public T trip() {
        return trip;
    }

    @Override
    public final boolean isTransitLeg() {
        return true;
    }

    @Override
    public final PathLeg nextLeg() {
        return next;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!super.equals(o)) return false;
        TransitPathLeg that = (TransitPathLeg) o;
        return trip.equals(that.trip) && next.equals(that.next);
    }

    @Override
    public int hashCode() {
        return Objects.hash(super.hashCode(), next, trip);
    }

    @Override
    public String toString() {
        return trip.pattern().debugInfo() + " " + asString(toStop());
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy