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

org.opentripplanner.transit.raptor.api.path.AccessPathLeg 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.RaptorTransfer;
import org.opentripplanner.transit.raptor.api.transit.RaptorTripSchedule;

import java.util.Objects;

/**
 * Represent an access leg in a path. The access leg is the first leg from origin to the
 * first transit leg. The next leg must be a transit leg - no other legs are allowed.
 *
 * @param  The TripSchedule type defined by the user of the raptor API.
 */
public final class AccessPathLeg implements PathLeg {
    private final RaptorTransfer access;
    private final int fromTime;
    private final int toStop;
    private final int toTime;
    private final PathLeg next;


    public AccessPathLeg(RaptorTransfer access, int toStop, int fromTime, int toTime, PathLeg next) {
        this.access = access;
        this.fromTime = fromTime;
        this.toStop = toStop;
        this.toTime = toTime;
        this.next = next;
    }

    @Override
    public int fromTime() {
        return fromTime;
    }

    /**
     * The stop index where the leg end, also called arrival stop index.
     */
    public int toStop() {
        return toStop;
    }

    @Override
    public int toTime() {
        return toTime;
    }

    public RaptorTransfer access() {
        return access;
    }

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

    @Override
    public String toString() {
        return "Access " + asString(toStop);
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        AccessPathLeg that = (AccessPathLeg) o;
        return fromTime == that.fromTime &&
                toStop == that.toStop &&
                toTime == that.toTime &&
                next.equals(that.next);
    }

    @Override
    public int hashCode() {
        return Objects.hash(fromTime, toStop, toTime, next);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy