Skip to content

Commit

Permalink
Re-enable file loader for SIRI-SX
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardehrenfried committed Dec 18, 2024
1 parent defdf5f commit de1e23d
Showing 1 changed file with 19 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,26 @@ public static SiriSXUpdater createSiriSXUpdater(
return new SiriSXUpdater(params, timetableRepository, createLoader(params));
}

private static EstimatedTimetableSource createSource(SiriETUpdater.Parameters params) {
return switch (params) {
case SiriETUpdaterParameters p -> new SiriETHttpTripUpdateSource(
p.sourceParameters(),
createLoader(params)
);
case SiriETLiteUpdaterParameters p -> new SiriETLiteHttpTripUpdateSource(
p.sourceParameters(),
createLoader(params)
);
default -> throw new IllegalArgumentException("Unexpected value: " + params);
};
}

private static SiriLoader createLoader(SiriSXUpdater.Parameters params) {
// Load real-time updates from a file.
if (SiriFileLoader.matchesUrl(params.url())) {
return new SiriFileLoader(params.url());
}
// Fallback to default loader
return switch (params) {
case SiriSXUpdaterParameters p -> new SiriHttpLoader(
p.url(),
Expand All @@ -59,20 +78,6 @@ private static SiriLoader createLoader(SiriSXUpdater.Parameters params) {
};
}

private static EstimatedTimetableSource createSource(SiriETUpdater.Parameters params) {
return switch (params) {
case SiriETUpdaterParameters p -> new SiriETHttpTripUpdateSource(
p.sourceParameters(),
createLoader(params)
);
case SiriETLiteUpdaterParameters p -> new SiriETLiteHttpTripUpdateSource(
p.sourceParameters(),
createLoader(params)
);
default -> throw new IllegalArgumentException("Unexpected value: " + params);
};
}

private static SiriLoader createLoader(SiriETUpdater.Parameters params) {
// Load real-time updates from a file.
if (SiriFileLoader.matchesUrl(params.url())) {
Expand Down

0 comments on commit de1e23d

Please sign in to comment.