-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from naviqore/review/NAV-52-define-interfaces-…
…for-service REFACTOR: NAV-52 - Remove redundancy in public transit service interface
- Loading branch information
Showing
27 changed files
with
265 additions
and
156 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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,30 +1,12 @@ | ||
package ch.naviqore.service; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* A connection in a public transit schedule, consisting of multiple public transit legs and walks. | ||
*/ | ||
public interface Connection { | ||
@NotNull List<Leg> getLegs(); | ||
|
||
@NotNull Location getStartLocation(); | ||
|
||
@NotNull Location getEndLocation(); | ||
|
||
@Nullable Stop getStartStop(); | ||
|
||
@Nullable Stop getEndStop(); | ||
|
||
@NotNull ArrivalTime getArrivalTime(); | ||
|
||
@NotNull DepartureTime getDepartureTime(); | ||
|
||
int getDuration(); | ||
|
||
int getBeeLineDistance(); | ||
|
||
int getNumTransfers(); | ||
List<Leg> getLegs(); | ||
|
||
int getWalkingDistance(); | ||
} |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,22 +1,38 @@ | ||
package ch.naviqore.service; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
/** | ||
* Represents a leg of a connection, including its order, distance, and duration. | ||
*/ | ||
public interface Leg { | ||
@NotNull Location getDepartureLocation(); | ||
|
||
@NotNull Location getArrivalLocation(); | ||
LegType getLegType(); | ||
|
||
Location getSourceLocation(); | ||
|
||
Location getTargetLocation(); | ||
|
||
LocalDateTime getArrivalTime(); | ||
|
||
@Nullable Stop getDepartureStop(); | ||
LocalDateTime getDepartureTime(); | ||
|
||
@Nullable Stop getArrivalStop(); | ||
int getDistance(); | ||
|
||
@NotNull DepartureTime getDepartureTime(); | ||
int getDuration(); | ||
|
||
@NotNull ArrivalTime getArrivalTime(); | ||
/** | ||
* The target public transit stop, if walk starts at a stop. | ||
*/ | ||
@Nullable | ||
Stop getSourceStop(); | ||
|
||
@Nullable Trip getTrip(); | ||
/** | ||
* The target public transit stop, if walk ends at a stop. | ||
*/ | ||
@Nullable | ||
Stop getTargetStop(); | ||
|
||
@Nullable Walk getWalk(); | ||
} |
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,6 @@ | ||
package ch.naviqore.service; | ||
|
||
public enum LegType { | ||
PUBLIC_TRANSIT, | ||
WALK | ||
} |
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 |
---|---|---|
@@ -1,7 +1,9 @@ | ||
package ch.naviqore.service; | ||
|
||
public interface Location { | ||
|
||
double getLatitude(); | ||
|
||
double getLongitude(); | ||
|
||
} |
This file was deleted.
Oops, something went wrong.
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,19 @@ | ||
package ch.naviqore.service; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
public interface PublicTransitLeg extends Leg { | ||
|
||
StopTime getArrival(); | ||
|
||
StopTime getDeparture(); | ||
|
||
@Override | ||
@NotNull | ||
Stop getSourceStop(); | ||
|
||
@Override | ||
@NotNull | ||
Stop getTargetStop(); | ||
|
||
} |
109 changes: 109 additions & 0 deletions
109
src/main/java/ch/naviqore/service/PublicTransitService.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,109 @@ | ||
package ch.naviqore.service; | ||
|
||
import ch.naviqore.service.config.ConnectionQueryConfig; | ||
import ch.naviqore.service.exception.RouteNotFoundException; | ||
import ch.naviqore.service.exception.StopNotFoundException; | ||
import ch.naviqore.service.exception.TripNotFoundException; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.time.LocalDate; | ||
import java.time.LocalDateTime; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
/** | ||
* Public transit service with methods to retrieve stops, trips, routes, and connections. | ||
*/ | ||
public interface PublicTransitService { | ||
|
||
/** | ||
* Searches for stops by name. | ||
* | ||
* @param like the search term to match against stop names | ||
* @param searchType the type of search to perform (STARTS_WITH, ENDS_WITH, CONTAINS, EXACT) | ||
* @return a list of stops matching the search criteria | ||
*/ | ||
List<Stop> getStops(String like, SearchType searchType); | ||
|
||
/** | ||
* Retrieves the nearest stop to a given location. | ||
* | ||
* @param location the location to search around | ||
* @return the nearest stop to the specified location, or null if no stop is found | ||
*/ | ||
@Nullable | ||
Stop getNearestStop(Location location); | ||
|
||
/** | ||
* Retrieves the nearest stops to a given location within a specified radius. | ||
* | ||
* @param location the location to search around | ||
* @param radius the radius to search within, in meters | ||
* @param limit the maximum number of stops to retrieve | ||
* @return a list of the nearest stops to the specified location within the given radius | ||
*/ | ||
List<Stop> getNearestStops(Location location, int radius, int limit); | ||
|
||
/** | ||
* Retrieves the next departures from a specific stop within a given date range. | ||
* | ||
* @param stop the stop for which to retrieve departures | ||
* @param from the start date for the departures | ||
* @param until the end date for the departures (nullable) | ||
* @param limit the maximum number of departures to retrieve | ||
* @return a list of upcoming departures from the specified stop | ||
*/ | ||
List<StopTime> getNextDepartures(Stop stop, LocalDate from, @Nullable LocalDate until, int limit); | ||
|
||
/** | ||
* Retrieves possible connections between two locations at a specified time. | ||
* | ||
* @param source the starting location | ||
* @param target the destination location | ||
* @param time the time of departure or arrival | ||
* @param timeType the type of time specified (departure or arrival) | ||
* @param config additional configuration for the query | ||
* @return a list of possible connections between the source and target locations | ||
*/ | ||
List<Connection> getConnections(Location source, Location target, LocalDateTime time, TimeType timeType, | ||
ConnectionQueryConfig config); | ||
|
||
/** | ||
* Retrieves the shortest possible connection to each stop from a given departure location and time within a given | ||
* time budget or a maximum number of transfers. | ||
* | ||
* @param source the location to start the journey from | ||
* @param departureTime the time of departure | ||
* @param config additional configuration for the query | ||
* @return a map of stops to the shortest possible connection to each stop from the departure location | ||
*/ | ||
Map<Stop, Connection> isoline(Location source, LocalDateTime departureTime, ConnectionQueryConfig config); | ||
|
||
/** | ||
* Retrieves a stop by its ID. | ||
* | ||
* @param stopId the ID of the stop to retrieve | ||
* @return the stop with the specified ID | ||
* @throws StopNotFoundException if no stop with the specified ID is found | ||
*/ | ||
Stop getStopById(String stopId) throws StopNotFoundException; | ||
|
||
/** | ||
* Retrieves a trip by its ID. | ||
* | ||
* @param tripId the ID of the trip to retrieve | ||
* @return the trip with the specified ID | ||
* @throws TripNotFoundException if no trip with the specified ID is found | ||
*/ | ||
Trip getTripById(String tripId) throws TripNotFoundException; | ||
|
||
/** | ||
* Retrieves a route by its ID. | ||
* | ||
* @param routeId the ID of the route to retrieve | ||
* @return the route with the specified ID | ||
* @throws RouteNotFoundException if no route with the specified ID is found | ||
*/ | ||
Route getRouteById(String routeId) throws RouteNotFoundException; | ||
|
||
} |
31 changes: 0 additions & 31 deletions
31
src/main/java/ch/naviqore/service/PublicTransportService.java
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,12 +1,20 @@ | ||
package ch.naviqore.service; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
/** | ||
* A public transit route (also called transit line). | ||
*/ | ||
public interface Route { | ||
@NotNull String getRouteId(); | ||
@NotNull String getRouteName(); | ||
@NotNull String getRouteShortName(); | ||
@NotNull String getRouteDescription(); | ||
@NotNull String getRouteType(); | ||
@NotNull String getAgency(); | ||
|
||
String getId(); | ||
|
||
String getName(); | ||
|
||
String getShortName(); | ||
|
||
String getDescription(); | ||
|
||
String getRouteType(); | ||
|
||
String getAgency(); | ||
|
||
} |
4 changes: 0 additions & 4 deletions
4
src/main/java/ch/naviqore/service/RouteNotFoundException.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.