org.opentripplanner.transit.raptor.rangeraptor.debug.DebugHandlerStopArrivalAdapter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of otp Show documentation
Show all versions of otp Show documentation
The OpenTripPlanner multimodal journey planning system
package org.opentripplanner.transit.raptor.rangeraptor.debug;
import org.opentripplanner.transit.raptor.api.request.DebugRequest;
import org.opentripplanner.transit.raptor.api.view.ArrivalView;
import org.opentripplanner.transit.raptor.rangeraptor.WorkerLifeCycle;
import java.util.LinkedList;
final class DebugHandlerStopArrivalAdapter extends AbstractDebugHandlerAdapter> {
DebugHandlerStopArrivalAdapter(DebugRequest debug, WorkerLifeCycle lifeCycle) {
super(debug, debug.stopArrivalListener(), lifeCycle);
}
@Override
protected int stop(ArrivalView arrival) {
return arrival.stop();
}
@Override
protected Iterable stopsVisited(ArrivalView arrival) {
return listStopsForDebugging(arrival);
}
/**
* List all stops used to arrive at current stop arrival. This method can be SLOW,
* should only be used in code that does not need to be fast, like debugging.
*/
private Iterable listStopsForDebugging(ArrivalView it) {
LinkedList stops = new LinkedList<>();
while (!it.arrivedByAccess()) {
stops.addFirst(it.stop());
it = it.previous();
}
stops.addFirst(it.stop());
return stops;
}
}