Skip to content

Commit 670b98c

Browse files
committed
refactor: Improve TimetableSnapshotUpdateListener documentation and parameter naming
1 parent 7b149dc commit 670b98c

5 files changed

Lines changed: 32 additions & 27 deletions

File tree

application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/RealTimeRaptorTransitDataUpdater.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import org.opentripplanner.transit.model.framework.FeedScopedId;
2020
import org.opentripplanner.transit.model.network.TripPattern;
2121
import org.opentripplanner.transit.model.timetable.Timetable;
22-
import org.opentripplanner.transit.model.timetable.TimetableSnapshotUpdateSucessListener;
22+
import org.opentripplanner.transit.model.timetable.TimetableSnapshotUpdateListener;
2323
import org.opentripplanner.transit.model.timetable.TripIdAndServiceDate;
2424
import org.opentripplanner.transit.model.timetable.TripTimes;
2525
import org.opentripplanner.transit.service.TimetableRepository;
@@ -38,7 +38,7 @@
3838
* incremental changes are applied to both the TimetableSnapshot and the RaptorTransitData and they are
3939
* published together.
4040
*/
41-
public class RealTimeRaptorTransitDataUpdater implements TimetableSnapshotUpdateSucessListener {
41+
public class RealTimeRaptorTransitDataUpdater implements TimetableSnapshotUpdateListener {
4242

4343
private static final Logger LOG = LoggerFactory.getLogger(RealTimeRaptorTransitDataUpdater.class);
4444

@@ -91,9 +91,6 @@ public RealTimeRaptorTransitDataUpdater(TimetableRepository timetableRepository)
9191
/// was for a scheduled trip, then the schedule should be restored.
9292
/// 3. Remove the `oldTripPatternsForDate` and add the `newTripPatternsForDate` to the
9393
/// [RaptorTransitData].
94-
///
95-
/// @param updatedTimetables that changed with the current snapshot
96-
/// @param timetables which are affected by real-time updates
9794
@Override
9895
public void update(
9996
Collection<Timetable> updatedTimetables,

application/src/main/java/org/opentripplanner/transit/model/timetable/TimetableSnapshot.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -301,8 +301,6 @@ public Collection<? extends TripOnServiceDate> listRealTimeAddedTripOnServiceDat
301301
* does not exist yet in the Timetable, add it. This method will make a protective copy of the
302302
* Timetable if such a copy has not already been made while building up this snapshot, handling
303303
* both cases where patterns were pre-existing in static data or created by realtime data.
304-
*
305-
* @return whether the update was actually applied
306304
*/
307305
public void update(RealTimeTripUpdate realTimeTripUpdate) {
308306
validateNotReadOnly();
@@ -368,7 +366,7 @@ public TimetableSnapshot commit() {
368366
}
369367

370368
public TimetableSnapshot commit(
371-
TimetableSnapshotUpdateSucessListener updatesEventListener,
369+
@Nullable TimetableSnapshotUpdateListener updatesEventListener,
372370
boolean force
373371
) {
374372
validateNotReadOnly();
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package org.opentripplanner.transit.model.timetable;
2+
3+
import java.util.Collection;
4+
import java.util.SortedSet;
5+
import java.util.function.Function;
6+
import org.opentripplanner.transit.model.framework.FeedScopedId;
7+
8+
/**
9+
* Listener interface for receiving notifications when a {@link TimetableSnapshot}
10+
* is updated with new real-time information.
11+
* <p>
12+
* Implement this interface and inject the listener into {@link TimetableSnapshot}
13+
* to receive events after the snapshot is updated.
14+
*/
15+
public interface TimetableSnapshotUpdateListener {
16+
/**
17+
* Called after the {@link TimetableSnapshot} has been updated and the commit method has completed.
18+
* <p>
19+
* This event allows the implementer to update its own state using the newly updated timetables.
20+
*
21+
* @param updatedTimetables a collection of timetables that have been updated
22+
* @param timetablesForTripPatternId a function to retrieve all timetables for a given trip pattern
23+
*/
24+
void update(
25+
Collection<Timetable> updatedTimetables,
26+
Function<FeedScopedId, SortedSet<Timetable>> timetablesForTripPatternId
27+
);
28+
}

application/src/main/java/org/opentripplanner/transit/model/timetable/TimetableSnapshotUpdateSucessListener.java

Lines changed: 0 additions & 18 deletions
This file was deleted.

application/src/test/java/org/opentripplanner/transit/model/timetable/TimetableSnapshotTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ void testUniqueDirtyTimetablesAfterMultipleUpdates() {
8484

8585
AtomicBoolean updateIsCalled = new AtomicBoolean();
8686

87-
var updateListener = new TimetableSnapshotUpdateSucessListener() {
87+
var updateListener = new TimetableSnapshotUpdateListener() {
8888
@Override
8989
public void update(
9090
Collection<Timetable> updatedTimetables,

0 commit comments

Comments
 (0)