-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Build SIRI loader in factory, inject into source
- Loading branch information
1 parent
71fae3d
commit 790bdc6
Showing
5 changed files
with
51 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
application/src/main/java/org/opentripplanner/updater/siri/updater/SiriLoaderFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package org.opentripplanner.updater.siri.updater; | ||
|
||
import org.opentripplanner.updater.siri.updater.lite.SiriETLiteUpdaterParameters; | ||
import org.opentripplanner.updater.siri.updater.lite.SiriLiteHttpLoader; | ||
|
||
/** | ||
* Constructs a SiriLoader from the parameters of the updater. | ||
*/ | ||
public class SiriLoaderFactory { | ||
|
||
public static SiriLoader createLoader(SiriETUpdater.Parameters parameters) { | ||
// Load real-time updates from a file. | ||
if (SiriFileLoader.matchesUrl(parameters.url())) { | ||
return new SiriFileLoader(parameters.url()); | ||
} | ||
// Fallback to default loader | ||
else { | ||
return switch (parameters) { | ||
case SiriETUpdaterParameters p -> new SiriHttpLoader( | ||
p.url(), | ||
p.timeout(), | ||
p.httpRequestHeaders(), | ||
p.previewInterval() | ||
); | ||
case SiriETLiteUpdaterParameters p -> new SiriLiteHttpLoader( | ||
p.uri(), | ||
p.timeout(), | ||
p.httpRequestHeaders() | ||
); | ||
default -> throw new IllegalArgumentException("Unexpected value: " + parameters); | ||
}; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters