From 15cbba93a076fae3ebafd53777f03a3ec818c3ef Mon Sep 17 00:00:00 2001 From: Leonard Ehrenfried Date: Thu, 21 Sep 2023 13:13:41 +0200 Subject: [PATCH 1/3] Fix values for bikesAllowed --- .../mapping/BikeAccessMapperTest.java | 21 ++++++++++ .../gtfsgraphqlapi/expectations/routes.json | 42 ++++++++++++------- .../gtfsgraphqlapi/queries/routes.graphql | 1 + .../datafetchers/RouteImpl.java | 10 ++--- .../gtfsgraphqlapi/datafetchers/TripImpl.java | 10 ++--- .../generated/GraphQLDataFetchers.java | 14 ++++--- .../generated/graphql-codegen.yml | 2 +- .../mapping/BikeAccessMapper.java | 16 +++++++ 8 files changed, 84 insertions(+), 32 deletions(-) create mode 100644 src/ext-test/java/org/opentripplanner/ext/gtfsgraphqlapi/mapping/BikeAccessMapperTest.java create mode 100644 src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/mapping/BikeAccessMapper.java diff --git a/src/ext-test/java/org/opentripplanner/ext/gtfsgraphqlapi/mapping/BikeAccessMapperTest.java b/src/ext-test/java/org/opentripplanner/ext/gtfsgraphqlapi/mapping/BikeAccessMapperTest.java new file mode 100644 index 00000000000..424de522739 --- /dev/null +++ b/src/ext-test/java/org/opentripplanner/ext/gtfsgraphqlapi/mapping/BikeAccessMapperTest.java @@ -0,0 +1,21 @@ +package org.opentripplanner.ext.gtfsgraphqlapi.mapping; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.util.Arrays; +import org.junit.jupiter.api.Test; +import org.opentripplanner.transit.model.network.BikeAccess; + +class BikeAccessMapperTest { + + @Test + void mapping() { + Arrays + .stream(BikeAccess.values()).filter(ba -> ba != BikeAccess.UNKNOWN) + .forEach(d -> { + var mapped = BikeAccessMapper.map(d); + assertEquals(d.toString(), mapped.toString()); + }); + } + +} \ No newline at end of file diff --git a/src/ext-test/resources/gtfsgraphqlapi/expectations/routes.json b/src/ext-test/resources/gtfsgraphqlapi/expectations/routes.json index e2bdb289c32..d6cb1b481ed 100644 --- a/src/ext-test/resources/gtfsgraphqlapi/expectations/routes.json +++ b/src/ext-test/resources/gtfsgraphqlapi/expectations/routes.json @@ -9,7 +9,8 @@ "gtfsId" : "F:A1", "name" : "Agency Test" }, - "mode" : "CARPOOL" + "mode" : "CARPOOL", + "bikesAllowed" : "NO_INFORMATION" }, { "longName" : "Long name for SUBWAY", @@ -19,7 +20,8 @@ "gtfsId" : "F:A1", "name" : "Agency Test" }, - "mode" : "SUBWAY" + "mode" : "SUBWAY", + "bikesAllowed" : "NO_INFORMATION" }, { "longName" : "Long name for BUS", @@ -29,7 +31,8 @@ "gtfsId" : "F:A1", "name" : "Agency Test" }, - "mode" : "BUS" + "mode" : "BUS", + "bikesAllowed" : "NO_INFORMATION" }, { "longName" : "Long name for FERRY", @@ -39,7 +42,8 @@ "gtfsId" : "F:A1", "name" : "Agency Test" }, - "mode" : "FERRY" + "mode" : "FERRY", + "bikesAllowed" : "NO_INFORMATION" }, { "longName" : "Long name for COACH", @@ -49,7 +53,8 @@ "gtfsId" : "F:A1", "name" : "Agency Test" }, - "mode" : "COACH" + "mode" : "COACH", + "bikesAllowed" : "NO_INFORMATION" }, { "longName" : "Long name for TRAM", @@ -59,7 +64,8 @@ "gtfsId" : "F:A1", "name" : "Agency Test" }, - "mode" : "TRAM" + "mode" : "TRAM", + "bikesAllowed" : "NO_INFORMATION" }, { "longName" : "Long name for CABLE_CAR", @@ -69,7 +75,8 @@ "gtfsId" : "F:A1", "name" : "Agency Test" }, - "mode" : "CABLE_CAR" + "mode" : "CABLE_CAR", + "bikesAllowed" : "NO_INFORMATION" }, { "longName" : "Long name for FUNICULAR", @@ -79,7 +86,8 @@ "gtfsId" : "F:A1", "name" : "Agency Test" }, - "mode" : "FUNICULAR" + "mode" : "FUNICULAR", + "bikesAllowed" : "NO_INFORMATION" }, { "longName" : "Long name for RAIL", @@ -89,7 +97,8 @@ "gtfsId" : "F:A1", "name" : "Agency Test" }, - "mode" : "RAIL" + "mode" : "RAIL", + "bikesAllowed" : "NO_INFORMATION" }, { "longName" : "Long name for MONORAIL", @@ -99,7 +108,8 @@ "gtfsId" : "F:A1", "name" : "Agency Test" }, - "mode" : "MONORAIL" + "mode" : "MONORAIL", + "bikesAllowed" : "NO_INFORMATION" }, { "longName" : "Long name for GONDOLA", @@ -109,7 +119,8 @@ "gtfsId" : "F:A1", "name" : "Agency Test" }, - "mode" : "GONDOLA" + "mode" : "GONDOLA", + "bikesAllowed" : "NO_INFORMATION" }, { "longName" : "Long name for TROLLEYBUS", @@ -119,7 +130,8 @@ "gtfsId" : "F:A1", "name" : "Agency Test" }, - "mode" : "TROLLEYBUS" + "mode" : "TROLLEYBUS", + "bikesAllowed" : "NO_INFORMATION" }, { "longName" : "Long name for AIRPLANE", @@ -129,7 +141,8 @@ "gtfsId" : "F:A1", "name" : "Agency Test" }, - "mode" : "AIRPLANE" + "mode" : "AIRPLANE", + "bikesAllowed" : "NO_INFORMATION" }, { "longName" : "Long name for TAXI", @@ -139,7 +152,8 @@ "gtfsId" : "F:A1", "name" : "Agency Test" }, - "mode" : "TAXI" + "mode" : "TAXI", + "bikesAllowed" : "NO_INFORMATION" } ] } diff --git a/src/ext-test/resources/gtfsgraphqlapi/queries/routes.graphql b/src/ext-test/resources/gtfsgraphqlapi/queries/routes.graphql index 66d7f370c3f..38585d6a836 100644 --- a/src/ext-test/resources/gtfsgraphqlapi/queries/routes.graphql +++ b/src/ext-test/resources/gtfsgraphqlapi/queries/routes.graphql @@ -8,5 +8,6 @@ name } mode + bikesAllowed } } \ No newline at end of file diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/RouteImpl.java b/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/RouteImpl.java index c61020db759..2f484a9b90d 100644 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/RouteImpl.java +++ b/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/RouteImpl.java @@ -11,7 +11,9 @@ import org.opentripplanner.ext.gtfsgraphqlapi.GraphQLUtils; import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLDataFetchers; import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes; +import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes.GraphQLBikesAllowed; import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes.GraphQLTransitMode; +import org.opentripplanner.ext.gtfsgraphqlapi.mapping.BikeAccessMapper; import org.opentripplanner.routing.alertpatch.EntitySelector; import org.opentripplanner.routing.alertpatch.TransitAlert; import org.opentripplanner.routing.services.TransitAlertService; @@ -131,13 +133,9 @@ public DataFetcher> alerts() { } @Override - public DataFetcher bikesAllowed() { + public DataFetcher bikesAllowed() { return environment -> - switch (getSource(environment).getBikesAllowed()) { - case UNKNOWN -> "NO_INFORMATION"; - case ALLOWED -> "POSSIBLE"; - case NOT_ALLOWED -> "NOT_POSSIBLE"; - }; + BikeAccessMapper.map(getSource(environment).getBikesAllowed()); } @Override diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/TripImpl.java b/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/TripImpl.java index a12cedff82c..8c7c3f3c1dc 100644 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/TripImpl.java +++ b/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/TripImpl.java @@ -20,7 +20,9 @@ import org.opentripplanner.ext.gtfsgraphqlapi.GraphQLUtils; import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLDataFetchers; import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes; +import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes.GraphQLBikesAllowed; import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes.GraphQLWheelchairBoarding; +import org.opentripplanner.ext.gtfsgraphqlapi.mapping.BikeAccessMapper; import org.opentripplanner.framework.time.ServiceDateUtils; import org.opentripplanner.model.Timetable; import org.opentripplanner.model.TripTimeOnDate; @@ -165,13 +167,9 @@ public DataFetcher arrivalStoptime() { } @Override - public DataFetcher bikesAllowed() { + public DataFetcher bikesAllowed() { return environment -> - switch (getSource(environment).getBikesAllowed()) { - case UNKNOWN -> "NO_INFORMATION"; - case ALLOWED -> "POSSIBLE"; - case NOT_ALLOWED -> "NOT_POSSIBLE"; - }; + BikeAccessMapper.map(getSource(environment).getBikesAllowed()); } @Override diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/generated/GraphQLDataFetchers.java b/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/generated/GraphQLDataFetchers.java index 318c4fc2a11..171e648dbcd 100644 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/generated/GraphQLDataFetchers.java +++ b/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/generated/GraphQLDataFetchers.java @@ -15,6 +15,7 @@ import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes.GraphQLAlertCauseType; import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes.GraphQLAlertEffectType; import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes.GraphQLAlertSeverityLevelType; +import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes.GraphQLBikesAllowed; import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes.GraphQLInputField; import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes.GraphQLRelativeDirection; import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes.GraphQLRoutingErrorCode; @@ -309,9 +310,12 @@ public interface GraphQLDefaultFareProduct { } /** - * Departure row is a location, which lists departures of a certain pattern from a - * stop. Departure rows are identified with the pattern, so querying departure rows - * will return only departures from one stop per pattern + * Departure row is a combination of a pattern and a stop of that pattern. + * + * They are de-duplicated so for each pattern there will only be a single departure row. + * + * This is useful if you want to show a list of stop/pattern combinations but want each pattern to be + * listed only once. */ public interface GraphQLDepartureRow { public DataFetcher id(); @@ -789,7 +793,7 @@ public interface GraphQLRoute { public DataFetcher> alerts(); - public DataFetcher bikesAllowed(); + public DataFetcher bikesAllowed(); public DataFetcher color(); @@ -1015,7 +1019,7 @@ public interface GraphQLTrip { public DataFetcher arrivalStoptime(); - public DataFetcher bikesAllowed(); + public DataFetcher bikesAllowed(); public DataFetcher blockId(); diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/generated/graphql-codegen.yml b/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/generated/graphql-codegen.yml index 7408e72cbca..6605044b36a 100644 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/generated/graphql-codegen.yml +++ b/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/generated/graphql-codegen.yml @@ -40,7 +40,7 @@ config: VehicleRentalStation: org.opentripplanner.service.vehiclerental.model.VehicleRentalStation#VehicleRentalStation RentalVehicle: org.opentripplanner.service.vehiclerental.model.VehicleRentalVehicle#VehicleRentalVehicle VehicleRentalUris: org.opentripplanner.service.vehiclerental.model.VehicleRentalStationUris#VehicleRentalStationUris - BikesAllowed: String + BikesAllowed: org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes.GraphQLBikesAllowed#GraphQLBikesAllowed BookingInfo: org.opentripplanner.model.BookingInfo BookingTime: org.opentripplanner.model.BookingTime CarPark: org.opentripplanner.routing.vehicle_parking.VehicleParking#VehicleParking diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/mapping/BikeAccessMapper.java b/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/mapping/BikeAccessMapper.java new file mode 100644 index 00000000000..04ccaa86e06 --- /dev/null +++ b/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/mapping/BikeAccessMapper.java @@ -0,0 +1,16 @@ +package org.opentripplanner.ext.gtfsgraphqlapi.mapping; + +import javax.annotation.Nonnull; +import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes; +import org.opentripplanner.transit.model.network.BikeAccess; + +public class BikeAccessMapper { + @Nonnull + public static GraphQLTypes.GraphQLBikesAllowed map(BikeAccess bikesAllowed) { + return switch (bikesAllowed) { + case UNKNOWN -> GraphQLTypes.GraphQLBikesAllowed.NO_INFORMATION; + case ALLOWED -> GraphQLTypes.GraphQLBikesAllowed.ALLOWED; + case NOT_ALLOWED -> GraphQLTypes.GraphQLBikesAllowed.NOT_ALLOWED; + }; + } +} From 6138851f6ac825e7ae5ffab5ca425d9c0e261daa Mon Sep 17 00:00:00 2001 From: Leonard Ehrenfried Date: Thu, 21 Sep 2023 13:26:46 +0200 Subject: [PATCH 2/3] Fix value mapping for bikesAllowed --- docs/GraphQL-Tutorial.md | 1 + .../ext/gtfsgraphqlapi/mapping/BikeAccessMapperTest.java | 6 +++--- .../ext/gtfsgraphqlapi/datafetchers/RouteImpl.java | 3 +-- .../ext/gtfsgraphqlapi/datafetchers/TripImpl.java | 3 +-- .../ext/gtfsgraphqlapi/mapping/BikeAccessMapper.java | 1 + 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/GraphQL-Tutorial.md b/docs/GraphQL-Tutorial.md index 73fba7d743e..e70294fcebd 100644 --- a/docs/GraphQL-Tutorial.md +++ b/docs/GraphQL-Tutorial.md @@ -41,6 +41,7 @@ GraphQL query in the left hand panel of the page: name } mode + bikesAllowed } } ``` diff --git a/src/ext-test/java/org/opentripplanner/ext/gtfsgraphqlapi/mapping/BikeAccessMapperTest.java b/src/ext-test/java/org/opentripplanner/ext/gtfsgraphqlapi/mapping/BikeAccessMapperTest.java index 424de522739..75bd5ef3007 100644 --- a/src/ext-test/java/org/opentripplanner/ext/gtfsgraphqlapi/mapping/BikeAccessMapperTest.java +++ b/src/ext-test/java/org/opentripplanner/ext/gtfsgraphqlapi/mapping/BikeAccessMapperTest.java @@ -11,11 +11,11 @@ class BikeAccessMapperTest { @Test void mapping() { Arrays - .stream(BikeAccess.values()).filter(ba -> ba != BikeAccess.UNKNOWN) + .stream(BikeAccess.values()) + .filter(ba -> ba != BikeAccess.UNKNOWN) .forEach(d -> { var mapped = BikeAccessMapper.map(d); assertEquals(d.toString(), mapped.toString()); }); } - -} \ No newline at end of file +} diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/RouteImpl.java b/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/RouteImpl.java index 2f484a9b90d..96a4d8dea1c 100644 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/RouteImpl.java +++ b/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/RouteImpl.java @@ -134,8 +134,7 @@ public DataFetcher> alerts() { @Override public DataFetcher bikesAllowed() { - return environment -> - BikeAccessMapper.map(getSource(environment).getBikesAllowed()); + return environment -> BikeAccessMapper.map(getSource(environment).getBikesAllowed()); } @Override diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/TripImpl.java b/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/TripImpl.java index 8c7c3f3c1dc..ccb659e39dc 100644 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/TripImpl.java +++ b/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/TripImpl.java @@ -168,8 +168,7 @@ public DataFetcher arrivalStoptime() { @Override public DataFetcher bikesAllowed() { - return environment -> - BikeAccessMapper.map(getSource(environment).getBikesAllowed()); + return environment -> BikeAccessMapper.map(getSource(environment).getBikesAllowed()); } @Override diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/mapping/BikeAccessMapper.java b/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/mapping/BikeAccessMapper.java index 04ccaa86e06..31de1955792 100644 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/mapping/BikeAccessMapper.java +++ b/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/mapping/BikeAccessMapper.java @@ -5,6 +5,7 @@ import org.opentripplanner.transit.model.network.BikeAccess; public class BikeAccessMapper { + @Nonnull public static GraphQLTypes.GraphQLBikesAllowed map(BikeAccess bikesAllowed) { return switch (bikesAllowed) { From 0abf7f39cdf2831cc363d5995f20e6ae125a36c8 Mon Sep 17 00:00:00 2001 From: Leonard Ehrenfried Date: Thu, 21 Sep 2023 16:57:29 +0200 Subject: [PATCH 3/3] Rename mapper to BikesAllowedMapper --- ...perTest.java => BikesAllowedMapperTest.java} | 4 ++-- .../gtfsgraphqlapi/datafetchers/RouteImpl.java | 4 ++-- .../gtfsgraphqlapi/datafetchers/TripImpl.java | 4 ++-- .../mapping/BikeAccessMapper.java | 17 ----------------- .../mapping/BikesAllowedMapper.java | 17 +++++++++++++++++ 5 files changed, 23 insertions(+), 23 deletions(-) rename src/ext-test/java/org/opentripplanner/ext/gtfsgraphqlapi/mapping/{BikeAccessMapperTest.java => BikesAllowedMapperTest.java} (85%) delete mode 100644 src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/mapping/BikeAccessMapper.java create mode 100644 src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/mapping/BikesAllowedMapper.java diff --git a/src/ext-test/java/org/opentripplanner/ext/gtfsgraphqlapi/mapping/BikeAccessMapperTest.java b/src/ext-test/java/org/opentripplanner/ext/gtfsgraphqlapi/mapping/BikesAllowedMapperTest.java similarity index 85% rename from src/ext-test/java/org/opentripplanner/ext/gtfsgraphqlapi/mapping/BikeAccessMapperTest.java rename to src/ext-test/java/org/opentripplanner/ext/gtfsgraphqlapi/mapping/BikesAllowedMapperTest.java index 75bd5ef3007..ba1b6a2a5f8 100644 --- a/src/ext-test/java/org/opentripplanner/ext/gtfsgraphqlapi/mapping/BikeAccessMapperTest.java +++ b/src/ext-test/java/org/opentripplanner/ext/gtfsgraphqlapi/mapping/BikesAllowedMapperTest.java @@ -6,7 +6,7 @@ import org.junit.jupiter.api.Test; import org.opentripplanner.transit.model.network.BikeAccess; -class BikeAccessMapperTest { +class BikesAllowedMapperTest { @Test void mapping() { @@ -14,7 +14,7 @@ void mapping() { .stream(BikeAccess.values()) .filter(ba -> ba != BikeAccess.UNKNOWN) .forEach(d -> { - var mapped = BikeAccessMapper.map(d); + var mapped = BikesAllowedMapper.map(d); assertEquals(d.toString(), mapped.toString()); }); } diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/RouteImpl.java b/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/RouteImpl.java index 96a4d8dea1c..2453257cdf6 100644 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/RouteImpl.java +++ b/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/RouteImpl.java @@ -13,7 +13,7 @@ import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes; import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes.GraphQLBikesAllowed; import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes.GraphQLTransitMode; -import org.opentripplanner.ext.gtfsgraphqlapi.mapping.BikeAccessMapper; +import org.opentripplanner.ext.gtfsgraphqlapi.mapping.BikesAllowedMapper; import org.opentripplanner.routing.alertpatch.EntitySelector; import org.opentripplanner.routing.alertpatch.TransitAlert; import org.opentripplanner.routing.services.TransitAlertService; @@ -134,7 +134,7 @@ public DataFetcher> alerts() { @Override public DataFetcher bikesAllowed() { - return environment -> BikeAccessMapper.map(getSource(environment).getBikesAllowed()); + return environment -> BikesAllowedMapper.map(getSource(environment).getBikesAllowed()); } @Override diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/TripImpl.java b/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/TripImpl.java index ccb659e39dc..adab6fe169d 100644 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/TripImpl.java +++ b/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/TripImpl.java @@ -22,7 +22,7 @@ import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes; import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes.GraphQLBikesAllowed; import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes.GraphQLWheelchairBoarding; -import org.opentripplanner.ext.gtfsgraphqlapi.mapping.BikeAccessMapper; +import org.opentripplanner.ext.gtfsgraphqlapi.mapping.BikesAllowedMapper; import org.opentripplanner.framework.time.ServiceDateUtils; import org.opentripplanner.model.Timetable; import org.opentripplanner.model.TripTimeOnDate; @@ -168,7 +168,7 @@ public DataFetcher arrivalStoptime() { @Override public DataFetcher bikesAllowed() { - return environment -> BikeAccessMapper.map(getSource(environment).getBikesAllowed()); + return environment -> BikesAllowedMapper.map(getSource(environment).getBikesAllowed()); } @Override diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/mapping/BikeAccessMapper.java b/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/mapping/BikeAccessMapper.java deleted file mode 100644 index 31de1955792..00000000000 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/mapping/BikeAccessMapper.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.opentripplanner.ext.gtfsgraphqlapi.mapping; - -import javax.annotation.Nonnull; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes; -import org.opentripplanner.transit.model.network.BikeAccess; - -public class BikeAccessMapper { - - @Nonnull - public static GraphQLTypes.GraphQLBikesAllowed map(BikeAccess bikesAllowed) { - return switch (bikesAllowed) { - case UNKNOWN -> GraphQLTypes.GraphQLBikesAllowed.NO_INFORMATION; - case ALLOWED -> GraphQLTypes.GraphQLBikesAllowed.ALLOWED; - case NOT_ALLOWED -> GraphQLTypes.GraphQLBikesAllowed.NOT_ALLOWED; - }; - } -} diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/mapping/BikesAllowedMapper.java b/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/mapping/BikesAllowedMapper.java new file mode 100644 index 00000000000..ad7019ac343 --- /dev/null +++ b/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/mapping/BikesAllowedMapper.java @@ -0,0 +1,17 @@ +package org.opentripplanner.ext.gtfsgraphqlapi.mapping; + +import javax.annotation.Nonnull; +import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes.GraphQLBikesAllowed; +import org.opentripplanner.transit.model.network.BikeAccess; + +public class BikesAllowedMapper { + + @Nonnull + public static GraphQLBikesAllowed map(@Nonnull BikeAccess bikesAllowed) { + return switch (bikesAllowed) { + case UNKNOWN -> GraphQLBikesAllowed.NO_INFORMATION; + case ALLOWED -> GraphQLBikesAllowed.ALLOWED; + case NOT_ALLOWED -> GraphQLBikesAllowed.NOT_ALLOWED; + }; + } +}