
org.opentripplanner.ext.siri.updater.AsyncEstimatedTimetableProcessor 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
The newest version!
package org.opentripplanner.ext.siri.updater;
import java.util.concurrent.Future;
import java.util.function.Consumer;
import org.opentripplanner.updater.spi.UpdateResult;
import org.opentripplanner.updater.spi.WriteToGraphCallback;
import org.opentripplanner.updater.trip.UpdateIncrementality;
import uk.org.siri.siri20.ServiceDelivery;
/**
* Apply asynchronously estimated timetable updates in the graph-writer thread and forward the
* result to an update result consumer.
*/
public class AsyncEstimatedTimetableProcessor {
private final EstimatedTimetableHandler estimatedTimetableHandler;
private final WriteToGraphCallback saveResultOnGraph;
private final Consumer updateResultConsumer;
public AsyncEstimatedTimetableProcessor(
EstimatedTimetableHandler estimatedTimetableHandler,
WriteToGraphCallback saveResultOnGraph,
Consumer updateResultConsumer
) {
this.estimatedTimetableHandler = estimatedTimetableHandler;
this.saveResultOnGraph = saveResultOnGraph;
this.updateResultConsumer = updateResultConsumer;
}
/**
* Apply the estimated timetables to the transit model.
* This method is non-blocking and applies the changes asynchronously.
* @return a future indicating when the changes are applied.
*/
public Future> processSiriData(ServiceDelivery serviceDelivery) {
return saveResultOnGraph.execute(context ->
updateResultConsumer.accept(
estimatedTimetableHandler.applyUpdate(
serviceDelivery.getEstimatedTimetableDeliveries(),
UpdateIncrementality.DIFFERENTIAL,
context
)
)
);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy