From 45e1ed1890fb7462b8529b0f5724b15c8a12f2ff Mon Sep 17 00:00:00 2001 From: Merlin Unterfinger Date: Tue, 7 May 2024 15:11:27 +0200 Subject: [PATCH] STYLE: NAV-18 - Add blank lines after class headers --- .../java/ch/naviqore/gtfs/schedule/GtfsScheduleReader.java | 2 ++ src/main/java/ch/naviqore/gtfs/schedule/model/Route.java | 1 + src/main/java/ch/naviqore/gtfs/schedule/model/Stop.java | 1 + src/main/java/ch/naviqore/gtfs/schedule/model/Transfer.java | 1 + src/main/java/ch/naviqore/gtfs/schedule/model/Trip.java | 1 + src/main/java/ch/naviqore/gtfs/schedule/type/RouteType.java | 1 - src/main/java/ch/naviqore/raptor/GtfsRoutePartitioner.java | 4 ++++ src/test/java/ch/naviqore/BenchmarkData.java | 1 + 8 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/java/ch/naviqore/gtfs/schedule/GtfsScheduleReader.java b/src/main/java/ch/naviqore/gtfs/schedule/GtfsScheduleReader.java index d8aa3908..cb8e4480 100644 --- a/src/main/java/ch/naviqore/gtfs/schedule/GtfsScheduleReader.java +++ b/src/main/java/ch/naviqore/gtfs/schedule/GtfsScheduleReader.java @@ -38,6 +38,7 @@ public class GtfsScheduleReader { private static void readFromDirectory(File directory, GtfsScheduleParser parser) throws IOException { for (GtfsScheduleFile fileType : GtfsScheduleFile.values()) { File csvFile = new File(directory, fileType.getFileName()); + if (csvFile.exists()) { log.info("Reading GTFS CSV file: {}", csvFile.getAbsolutePath()); readCsvFile(csvFile, parser, fileType); @@ -51,6 +52,7 @@ private static void readFromZip(File zipFile, GtfsScheduleParser parser) throws try (ZipFile zf = new ZipFile(zipFile, StandardCharsets.UTF_8)) { for (GtfsScheduleFile fileType : GtfsScheduleFile.values()) { ZipEntry entry = zf.getEntry(fileType.getFileName()); + if (entry != null) { log.info("Reading GTFS file from ZIP: {}", entry.getName()); try (InputStreamReader reader = new InputStreamReader(BOMInputStream.builder() diff --git a/src/main/java/ch/naviqore/gtfs/schedule/model/Route.java b/src/main/java/ch/naviqore/gtfs/schedule/model/Route.java index c78b083b..1202d357 100644 --- a/src/main/java/ch/naviqore/gtfs/schedule/model/Route.java +++ b/src/main/java/ch/naviqore/gtfs/schedule/model/Route.java @@ -13,6 +13,7 @@ @RequiredArgsConstructor(access = AccessLevel.PACKAGE) @Getter public final class Route implements Initializable { + private final String id; private final Agency agency; private final String shortName; diff --git a/src/main/java/ch/naviqore/gtfs/schedule/model/Stop.java b/src/main/java/ch/naviqore/gtfs/schedule/model/Stop.java index 5012f85e..57918631 100644 --- a/src/main/java/ch/naviqore/gtfs/schedule/model/Stop.java +++ b/src/main/java/ch/naviqore/gtfs/schedule/model/Stop.java @@ -13,6 +13,7 @@ @RequiredArgsConstructor(access = AccessLevel.PACKAGE) @Getter public final class Stop implements Initializable { + private final String id; private final String name; private final Coordinate coordinate; diff --git a/src/main/java/ch/naviqore/gtfs/schedule/model/Transfer.java b/src/main/java/ch/naviqore/gtfs/schedule/model/Transfer.java index 5b618e5b..dcafa1d5 100644 --- a/src/main/java/ch/naviqore/gtfs/schedule/model/Transfer.java +++ b/src/main/java/ch/naviqore/gtfs/schedule/model/Transfer.java @@ -12,6 +12,7 @@ @RequiredArgsConstructor(access = AccessLevel.PACKAGE) @Getter public class Transfer { + private final Stop fromStop; private final Stop toStop; private final TransferType transferType; diff --git a/src/main/java/ch/naviqore/gtfs/schedule/model/Trip.java b/src/main/java/ch/naviqore/gtfs/schedule/model/Trip.java index 3735c3bb..b2d24da5 100644 --- a/src/main/java/ch/naviqore/gtfs/schedule/model/Trip.java +++ b/src/main/java/ch/naviqore/gtfs/schedule/model/Trip.java @@ -11,6 +11,7 @@ @RequiredArgsConstructor @Getter public final class Trip implements Comparable, Initializable { + private final String id; private final Route route; private final Calendar calendar; diff --git a/src/main/java/ch/naviqore/gtfs/schedule/type/RouteType.java b/src/main/java/ch/naviqore/gtfs/schedule/type/RouteType.java index 043fe6ee..a5b8456f 100644 --- a/src/main/java/ch/naviqore/gtfs/schedule/type/RouteType.java +++ b/src/main/java/ch/naviqore/gtfs/schedule/type/RouteType.java @@ -17,7 +17,6 @@ public interface RouteType { * @throws NumberFormatException if the code is not a valid integer * @throws IllegalArgumentException if the code is negative or invalid */ - static RouteType parse(String code) { return parse(Integer.parseInt(code)); } diff --git a/src/main/java/ch/naviqore/raptor/GtfsRoutePartitioner.java b/src/main/java/ch/naviqore/raptor/GtfsRoutePartitioner.java index 466b1217..d1dd2810 100644 --- a/src/main/java/ch/naviqore/raptor/GtfsRoutePartitioner.java +++ b/src/main/java/ch/naviqore/raptor/GtfsRoutePartitioner.java @@ -18,6 +18,7 @@ */ @Log4j2 public class GtfsRoutePartitioner { + private final Map> subRoutes = new HashMap<>(); public GtfsRoutePartitioner(GtfsSchedule schedule) { @@ -48,6 +49,7 @@ private List extractStopSequence(Trip trip) { for (StopTime stopTime : trip.getStopTimes()) { sequence.add(stopTime.stop()); } + return sequence; } @@ -56,6 +58,7 @@ public List getSubRoutes(Route route) { if (currentSubRoutes == null) { throw new IllegalArgumentException("Route " + route.getId() + " not found in schedule"); } + return new ArrayList<>(currentSubRoutes.values()); } @@ -65,6 +68,7 @@ public SubRoute getSubRoute(Trip trip) { throw new IllegalArgumentException("Trip " + trip.getId() + " not found in schedule"); } String key = generateStopSequenceKey(trip); + return currentSubRoutes.get(key); } diff --git a/src/test/java/ch/naviqore/BenchmarkData.java b/src/test/java/ch/naviqore/BenchmarkData.java index acaada2e..d468c42b 100644 --- a/src/test/java/ch/naviqore/BenchmarkData.java +++ b/src/test/java/ch/naviqore/BenchmarkData.java @@ -22,6 +22,7 @@ @NoArgsConstructor(access = AccessLevel.PRIVATE) @Log4j2 final class BenchmarkData { + private static final Path DATA_DIRECTORY = Path.of("benchmark/input"); private static final HttpClient httpClient = HttpClient.newBuilder() .followRedirects(HttpClient.Redirect.ALWAYS)