From 7ed4ebdb50fb53a0a0a33994661bb43f8216cba4 Mon Sep 17 00:00:00 2001 From: Thomas Gran Date: Wed, 20 Nov 2024 18:12:40 +0100 Subject: [PATCH 01/69] refactor: Cleanup TemporaryStreetLocation. --- .../routing/graph/index/StreetIndex.java | 4 +- .../routing/linking/LinkingDirection.java | 19 ++++- .../routing/linking/VertexLinker.java | 15 +--- .../street/model/edge/TemporaryFreeEdge.java | 6 -- .../model/vertex/TemporarySplitterVertex.java | 15 +--- .../model/vertex/TemporaryStreetLocation.java | 83 ++++++++++++++----- .../street/model/vertex/TemporaryVertex.java | 2 - .../org/opentripplanner/astar/AStarTest.java | 20 ++--- .../routing/algorithm/GraphRoutingTest.java | 2 +- .../routing/graph/TemporaryConcreteEdge.java | 6 -- .../routing/linking/LinkingDirectionTest.java | 23 +++++ .../model/edge/StreetEdgeSplittingTest.java | 12 +-- .../vertex/TemporaryVertexDisposeTest.java | 5 -- 13 files changed, 123 insertions(+), 89 deletions(-) create mode 100644 application/src/test/java/org/opentripplanner/routing/linking/LinkingDirectionTest.java diff --git a/application/src/main/java/org/opentripplanner/routing/graph/index/StreetIndex.java b/application/src/main/java/org/opentripplanner/routing/graph/index/StreetIndex.java index b632cd5c3e9..8e070b9ccc8 100644 --- a/application/src/main/java/org/opentripplanner/routing/graph/index/StreetIndex.java +++ b/application/src/main/java/org/opentripplanner/routing/graph/index/StreetIndex.java @@ -102,7 +102,7 @@ public static TemporaryStreetLocation createTemporaryStreetLocationForTest( ) { boolean wheelchairAccessible = false; - TemporaryStreetLocation location = new TemporaryStreetLocation( + TemporaryStreetLocation location = TemporaryStreetLocation.originOrDestination( label, nearestPoint, name, @@ -377,7 +377,7 @@ private Vertex createVertexFromCoordinate( name = new NonLocalizedString(label); } - TemporaryStreetLocation temporaryStreetLocation = new TemporaryStreetLocation( + TemporaryStreetLocation temporaryStreetLocation = TemporaryStreetLocation.originOrDestination( UUID.randomUUID().toString(), coordinate, name, diff --git a/application/src/main/java/org/opentripplanner/routing/linking/LinkingDirection.java b/application/src/main/java/org/opentripplanner/routing/linking/LinkingDirection.java index 0167636c0d5..67df67648c1 100644 --- a/application/src/main/java/org/opentripplanner/routing/linking/LinkingDirection.java +++ b/application/src/main/java/org/opentripplanner/routing/linking/LinkingDirection.java @@ -13,5 +13,22 @@ public enum LinkingDirection { * From the main graph towards the new vertex */ OUTGOING, - BOTH_WAYS, + /** + * Link both ways + */ + BOTH_WAYS; + + /** + * Return {@code true} if either outgoing or both-ways. + */ + public boolean allowOutgoing() { + return this == OUTGOING || this == BOTH_WAYS; + } + + /** + * Return {@code true} if either incoming or both-ways. + */ + public boolean allowIncoming() { + return this == INCOMING || this == BOTH_WAYS; + } } diff --git a/application/src/main/java/org/opentripplanner/routing/linking/VertexLinker.java b/application/src/main/java/org/opentripplanner/routing/linking/VertexLinker.java index 8802c08dbe0..ba92e4636c9 100644 --- a/application/src/main/java/org/opentripplanner/routing/linking/VertexLinker.java +++ b/application/src/main/java/org/opentripplanner/routing/linking/VertexLinker.java @@ -431,7 +431,7 @@ else if ( if (vertex instanceof IntersectionVertex iv) { start = iv; } else { - start = splitVertex(aEdge, scope, direction, vertex.getLon(), vertex.getLat()); + start = splitVertex(aEdge, scope, vertex.getLon(), vertex.getLat()); } split = false; } @@ -477,7 +477,7 @@ private SplitterVertex split( // create the geometries Coordinate splitPoint = ll.getCoordinate(geometry); - SplitterVertex v = splitVertex(originalEdge, scope, direction, splitPoint.x, splitPoint.y); + SplitterVertex v = splitVertex(originalEdge, scope, splitPoint.x, splitPoint.y); // Split the 'edge' at 'v' in 2 new edges and connect these 2 edges to the // existing vertices @@ -508,13 +508,7 @@ private SplitterVertex split( return v; } - private SplitterVertex splitVertex( - StreetEdge originalEdge, - Scope scope, - LinkingDirection direction, - double x, - double y - ) { + private SplitterVertex splitVertex(StreetEdge originalEdge, Scope scope, double x, double y) { SplitterVertex v; String uniqueSplitLabel = "split_" + graph.nextSplitNumber++; @@ -523,8 +517,7 @@ private SplitterVertex splitVertex( uniqueSplitLabel, x, y, - originalEdge, - direction == LinkingDirection.OUTGOING + originalEdge ); tsv.setWheelchairAccessible(originalEdge.isWheelchairAccessible()); v = tsv; diff --git a/application/src/main/java/org/opentripplanner/street/model/edge/TemporaryFreeEdge.java b/application/src/main/java/org/opentripplanner/street/model/edge/TemporaryFreeEdge.java index 7b114cfeade..aba2dcc3ca7 100644 --- a/application/src/main/java/org/opentripplanner/street/model/edge/TemporaryFreeEdge.java +++ b/application/src/main/java/org/opentripplanner/street/model/edge/TemporaryFreeEdge.java @@ -9,16 +9,10 @@ public class TemporaryFreeEdge extends FreeEdge implements TemporaryEdge { private TemporaryFreeEdge(TemporaryVertex from, Vertex to) { super((Vertex) from, to); - if (from.isEndVertex()) { - throw new IllegalStateException("A temporary edge is directed away from an end vertex"); - } } private TemporaryFreeEdge(Vertex from, TemporaryVertex to) { super(from, (Vertex) to); - if (!to.isEndVertex()) { - throw new IllegalStateException("A temporary edge is directed towards a start vertex"); - } } public static TemporaryFreeEdge createTemporaryFreeEdge(TemporaryVertex from, Vertex to) { diff --git a/application/src/main/java/org/opentripplanner/street/model/vertex/TemporarySplitterVertex.java b/application/src/main/java/org/opentripplanner/street/model/vertex/TemporarySplitterVertex.java index f057956aad5..589a4db678c 100644 --- a/application/src/main/java/org/opentripplanner/street/model/vertex/TemporarySplitterVertex.java +++ b/application/src/main/java/org/opentripplanner/street/model/vertex/TemporarySplitterVertex.java @@ -10,18 +10,10 @@ */ public class TemporarySplitterVertex extends SplitterVertex implements TemporaryVertex { - private final boolean endVertex; private boolean wheelchairAccessible; - public TemporarySplitterVertex( - String label, - double x, - double y, - StreetEdge streetEdge, - boolean endVertex - ) { + public TemporarySplitterVertex(String label, double x, double y, StreetEdge streetEdge) { super(label, x, y, streetEdge.getName()); - this.endVertex = endVertex; this.wheelchairAccessible = streetEdge.isWheelchairAccessible(); } @@ -37,11 +29,6 @@ public void addIncoming(Edge edge) { super.addIncoming(edge); } - @Override - public boolean isEndVertex() { - return endVertex; - } - public boolean isWheelchairAccessible() { return wheelchairAccessible; } diff --git a/application/src/main/java/org/opentripplanner/street/model/vertex/TemporaryStreetLocation.java b/application/src/main/java/org/opentripplanner/street/model/vertex/TemporaryStreetLocation.java index 8af9474a7e7..7d2bdf52d11 100644 --- a/application/src/main/java/org/opentripplanner/street/model/vertex/TemporaryStreetLocation.java +++ b/application/src/main/java/org/opentripplanner/street/model/vertex/TemporaryStreetLocation.java @@ -2,53 +2,90 @@ import org.locationtech.jts.geom.Coordinate; import org.opentripplanner.framework.i18n.I18NString; +import org.opentripplanner.routing.linking.LinkingDirection; import org.opentripplanner.street.model.edge.Edge; import org.opentripplanner.street.model.edge.TemporaryEdge; public final class TemporaryStreetLocation extends StreetLocation implements TemporaryVertex { - private final boolean endVertex; + private final LinkingDirection linkingDirection; - public TemporaryStreetLocation( + private TemporaryStreetLocation( String id, Coordinate nearestPoint, I18NString name, - boolean endVertex + LinkingDirection linkingDirection ) { super(id, nearestPoint, name); - this.endVertex = endVertex; + this.linkingDirection = linkingDirection; + } + + public static TemporaryStreetLocation originOrDestination( + String id, + Coordinate nearestPoint, + I18NString name, + boolean destination + ) { + return destination ? destination(id, nearestPoint, name) : origin(id, nearestPoint, name); + } + + /** + * Create a temporary vertex witch can be used as the starting point - the origin of a search. + * The origin only has outgoing edges, an attempt to add incoming edges will fail. + */ + public static TemporaryStreetLocation origin( + String id, + Coordinate nearestPoint, + I18NString name + ) { + return new TemporaryStreetLocation(id, nearestPoint, name, LinkingDirection.OUTGOING); + } + + /** + * Create a temporary vertex witch can be used as the end point - the destination of a search. + * The destination only has incoming edges, an attempt to add outgoing edges will fail. + */ + public static TemporaryStreetLocation destination( + String id, + Coordinate nearestPoint, + I18NString name + ) { + return new TemporaryStreetLocation(id, nearestPoint, name, LinkingDirection.INCOMING); + } + + /** + * Create a temporary vertex witch can be used as either the origin or the destination + * in a nearby-search. This is used to route via a coordinate. + */ + public static TemporaryStreetLocation via(String id, Coordinate nearestPoint, I18NString name) { + return new TemporaryStreetLocation(id, nearestPoint, name, LinkingDirection.BOTH_WAYS); } @Override public void addOutgoing(Edge edge) { - if (edge instanceof TemporaryEdge) { - if (endVertex) { - throw new UnsupportedOperationException("Can't add outgoing edge to end vertex"); - } else { - addRentalRestriction(edge.getToVertex().rentalRestrictions()); - super.addOutgoing(edge); - } + assertConnectToTemporaryEdge(edge); + if (linkingDirection.allowOutgoing()) { + addRentalRestriction(edge.getToVertex().rentalRestrictions()); + super.addOutgoing(edge); } else { - throw new UnsupportedOperationException("Can't add permanent edge to temporary vertex"); + throw new UnsupportedOperationException("Can't add outgoing edge to end vertex"); } } @Override public void addIncoming(Edge edge) { - if (edge instanceof TemporaryEdge) { - if (endVertex) { - addRentalRestriction(edge.getFromVertex().rentalRestrictions()); - super.addIncoming(edge); - } else { - throw new UnsupportedOperationException("Can't add incoming edge to start vertex"); - } + assertConnectToTemporaryEdge(edge); + if (linkingDirection.allowIncoming()) { + super.addIncoming(edge); + addRentalRestriction(edge.getFromVertex().rentalRestrictions()); } else { - throw new UnsupportedOperationException("Can't add permanent edge to temporary vertex"); + throw new UnsupportedOperationException("Can't add incoming edge to start vertex"); } } - @Override - public boolean isEndVertex() { - return endVertex; + private static void assertConnectToTemporaryEdge(Edge edge) { + if (!(edge instanceof TemporaryEdge)) { + throw new UnsupportedOperationException("Can't add permanent edge to temporary vertex"); + } } } diff --git a/application/src/main/java/org/opentripplanner/street/model/vertex/TemporaryVertex.java b/application/src/main/java/org/opentripplanner/street/model/vertex/TemporaryVertex.java index 4bc891edb5f..17fa250e964 100644 --- a/application/src/main/java/org/opentripplanner/street/model/vertex/TemporaryVertex.java +++ b/application/src/main/java/org/opentripplanner/street/model/vertex/TemporaryVertex.java @@ -21,6 +21,4 @@ public interface TemporaryVertex { static void dispose(Vertex vertex) { TemporaryVertexDispose.dispose(vertex); } - - boolean isEndVertex(); } diff --git a/application/src/test/java/org/opentripplanner/astar/AStarTest.java b/application/src/test/java/org/opentripplanner/astar/AStarTest.java index 40310fedb7b..f2075f815da 100644 --- a/application/src/test/java/org/opentripplanner/astar/AStarTest.java +++ b/application/src/test/java/org/opentripplanner/astar/AStarTest.java @@ -163,19 +163,17 @@ public void testForwardExtraEdges() { request.withPreferences(pref -> pref.withWalk(w -> w.withSpeed(1.0))); - TemporaryStreetLocation from = new TemporaryStreetLocation( + TemporaryStreetLocation from = TemporaryStreetLocation.origin( "near_shilshole_22nd", new Coordinate(-122.385050, 47.666620), - new NonLocalizedString("near_shilshole_22nd"), - false + new NonLocalizedString("near_shilshole_22nd") ); TemporaryConcreteEdge.createTemporaryConcreteEdge(from, graph.getVertex("shilshole_22nd")); - TemporaryStreetLocation to = new TemporaryStreetLocation( + TemporaryStreetLocation to = TemporaryStreetLocation.destination( "near_56th_20th", new Coordinate(-122.382347, 47.669518), - new NonLocalizedString("near_56th_20th"), - true + new NonLocalizedString("near_56th_20th") ); TemporaryConcreteEdge.createTemporaryConcreteEdge(graph.getVertex("56th_20th"), to); @@ -211,19 +209,17 @@ public void testBackExtraEdges() { request.withPreferences(pref -> pref.withWalk(w -> w.withSpeed(1.0))); request.setArriveBy(true); - TemporaryStreetLocation from = new TemporaryStreetLocation( + TemporaryStreetLocation from = TemporaryStreetLocation.origin( "near_shilshole_22nd", new Coordinate(-122.385050, 47.666620), - new NonLocalizedString("near_shilshole_22nd"), - false + new NonLocalizedString("near_shilshole_22nd") ); TemporaryConcreteEdge.createTemporaryConcreteEdge(from, graph.getVertex("shilshole_22nd")); - TemporaryStreetLocation to = new TemporaryStreetLocation( + TemporaryStreetLocation to = TemporaryStreetLocation.destination( "near_56th_20th", new Coordinate(-122.382347, 47.669518), - new NonLocalizedString("near_56th_20th"), - true + new NonLocalizedString("near_56th_20th") ); TemporaryConcreteEdge.createTemporaryConcreteEdge(graph.getVertex("56th_20th"), to); diff --git a/application/src/test/java/org/opentripplanner/routing/algorithm/GraphRoutingTest.java b/application/src/test/java/org/opentripplanner/routing/algorithm/GraphRoutingTest.java index e283e4e9fa8..3fffc597c76 100644 --- a/application/src/test/java/org/opentripplanner/routing/algorithm/GraphRoutingTest.java +++ b/application/src/test/java/org/opentripplanner/routing/algorithm/GraphRoutingTest.java @@ -359,7 +359,7 @@ public TemporaryStreetLocation streetLocation( double longitude, boolean endVertex ) { - return new TemporaryStreetLocation( + return TemporaryStreetLocation.originOrDestination( name, new Coordinate(longitude, latitude), new NonLocalizedString(name), diff --git a/application/src/test/java/org/opentripplanner/routing/graph/TemporaryConcreteEdge.java b/application/src/test/java/org/opentripplanner/routing/graph/TemporaryConcreteEdge.java index 7f69f2a0a45..d3f4c06c3f7 100644 --- a/application/src/test/java/org/opentripplanner/routing/graph/TemporaryConcreteEdge.java +++ b/application/src/test/java/org/opentripplanner/routing/graph/TemporaryConcreteEdge.java @@ -14,16 +14,10 @@ public class TemporaryConcreteEdge extends Edge implements TemporaryEdge { private TemporaryConcreteEdge(TemporaryVertex v1, Vertex v2) { super((Vertex) v1, v2); - if (v1.isEndVertex()) { - throw new IllegalStateException("A temporary edge is directed away from an end vertex"); - } } private TemporaryConcreteEdge(Vertex v1, TemporaryVertex v2) { super(v1, (Vertex) v2); - if (!v2.isEndVertex()) { - throw new IllegalStateException("A temporary edge is directed towards a start vertex"); - } } public static TemporaryConcreteEdge createTemporaryConcreteEdge(TemporaryVertex v1, Vertex v2) { diff --git a/application/src/test/java/org/opentripplanner/routing/linking/LinkingDirectionTest.java b/application/src/test/java/org/opentripplanner/routing/linking/LinkingDirectionTest.java new file mode 100644 index 00000000000..7ed19855960 --- /dev/null +++ b/application/src/test/java/org/opentripplanner/routing/linking/LinkingDirectionTest.java @@ -0,0 +1,23 @@ +package org.opentripplanner.routing.linking; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import org.junit.jupiter.api.Test; + +class LinkingDirectionTest { + + @Test + void allowOutgoing() { + assertFalse(LinkingDirection.INCOMING.allowOutgoing()); + assertTrue(LinkingDirection.OUTGOING.allowOutgoing()); + assertTrue(LinkingDirection.BOTH_WAYS.allowOutgoing()); + } + + @Test + void allowIncoming() { + assertTrue(LinkingDirection.INCOMING.allowIncoming()); + assertFalse(LinkingDirection.OUTGOING.allowIncoming()); + assertTrue(LinkingDirection.BOTH_WAYS.allowIncoming()); + } +} diff --git a/application/src/test/java/org/opentripplanner/street/model/edge/StreetEdgeSplittingTest.java b/application/src/test/java/org/opentripplanner/street/model/edge/StreetEdgeSplittingTest.java index 171b979c036..0507d3d812b 100644 --- a/application/src/test/java/org/opentripplanner/street/model/edge/StreetEdgeSplittingTest.java +++ b/application/src/test/java/org/opentripplanner/street/model/edge/StreetEdgeSplittingTest.java @@ -70,7 +70,7 @@ public void turnRestrictionToEdgeSplit() { @Test public void turnRestrictionFromEdgeSplitWithTemporary() { - var splitVtx = new TemporarySplitterVertex("Split_Vertex", 1.0, 0.0, streetEdge1, true); + var splitVtx = new TemporarySplitterVertex("Split_Vertex", 1.0, 0.0, streetEdge1); var disposableEdgeCollection = new DisposableEdgeCollection(graph); var splitResult = streetEdge1.splitNonDestructively( @@ -91,7 +91,7 @@ public void turnRestrictionFromEdgeSplitWithTemporary() { @Test public void turnRestrictionToEdgeSplitTemporary() { - var splitVtx = new TemporarySplitterVertex("Split_Vertex", 1.0, 1.0, streetEdge2, false); + var splitVtx = new TemporarySplitterVertex("Split_Vertex", 1.0, 1.0, streetEdge2); var disposableEdgeCollection = new DisposableEdgeCollection(graph); var splitResult = streetEdge2.splitNonDestructively( @@ -110,7 +110,7 @@ public void turnRestrictionToEdgeSplitTemporary() { @Test public void turnRestrictionFromEdgeSplitWithToVertex() { - var splitVtx = new TemporarySplitterVertex("Split_Vertex", 1.0, 0.0, streetEdge1, true); + var splitVtx = new TemporarySplitterVertex("Split_Vertex", 1.0, 0.0, streetEdge1); var disposableEdgeCollection = new DisposableEdgeCollection(graph); var splitResult = streetEdge1.splitNonDestructively( @@ -129,7 +129,7 @@ public void turnRestrictionFromEdgeSplitWithToVertex() { @Test public void turnRestrictionToEdgeSplitWithToVertex() { - var splitVtx = new TemporarySplitterVertex("Split_Vertex", 1.0, 1.0, streetEdge2, true); + var splitVtx = new TemporarySplitterVertex("Split_Vertex", 1.0, 1.0, streetEdge2); var disposableEdgeCollection = new DisposableEdgeCollection(graph); var splitResult = streetEdge2.splitNonDestructively( @@ -150,7 +150,7 @@ public void turnRestrictionToEdgeSplitWithToVertex() { @Test public void turnRestrictionFromEdgeSplitWithFromVertex() { - var splitVtx = new TemporarySplitterVertex("Split_Vertex", 1.0, 0.0, streetEdge1, false); + var splitVtx = new TemporarySplitterVertex("Split_Vertex", 1.0, 0.0, streetEdge1); var disposableEdgeCollection = new DisposableEdgeCollection(graph); var splitResult = streetEdge1.splitNonDestructively( @@ -171,7 +171,7 @@ public void turnRestrictionFromEdgeSplitWithFromVertex() { @Test public void turnRestrictionToEdgeSplitWithFromVertex() { - var splitVtx = new TemporarySplitterVertex("Split_Vertex", 1.0, 1.0, streetEdge2, false); + var splitVtx = new TemporarySplitterVertex("Split_Vertex", 1.0, 1.0, streetEdge2); var disposableEdgeCollection = new DisposableEdgeCollection(graph); var splitResult = streetEdge2.splitNonDestructively( diff --git a/application/src/test/java/org/opentripplanner/street/model/vertex/TemporaryVertexDisposeTest.java b/application/src/test/java/org/opentripplanner/street/model/vertex/TemporaryVertexDisposeTest.java index e4880f891e2..acc9782099e 100644 --- a/application/src/test/java/org/opentripplanner/street/model/vertex/TemporaryVertexDisposeTest.java +++ b/application/src/test/java/org/opentripplanner/street/model/vertex/TemporaryVertexDisposeTest.java @@ -247,11 +247,6 @@ private static class TempVertex extends V implements TemporaryVertex { private TempVertex(String label) { super(label); } - - @Override - public boolean isEndVertex() { - throw new IllegalStateException("The `isEndVertex` is not used by dispose logic."); - } } private static class E extends FreeEdge { From 381e51a29142f4fd2ccf29beaad221b78c91d7da Mon Sep 17 00:00:00 2001 From: Thomas Gran Date: Wed, 27 Nov 2024 15:10:08 +0100 Subject: [PATCH 02/69] refactor: Cleanup CoordinateInputType and add unit-test --- .../model/framework/CoordinateInputType.java | 44 ++++++++++++++- .../framework/CoordinateInputTypeTest.java | 54 +++++++++++++++++++ 2 files changed, 96 insertions(+), 2 deletions(-) create mode 100644 application/src/test/java/org/opentripplanner/apis/transmodel/model/framework/CoordinateInputTypeTest.java diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/model/framework/CoordinateInputType.java b/application/src/main/java/org/opentripplanner/apis/transmodel/model/framework/CoordinateInputType.java index 32ed3b7927e..268f4b62318 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/model/framework/CoordinateInputType.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/model/framework/CoordinateInputType.java @@ -4,9 +4,17 @@ import graphql.schema.GraphQLInputObjectField; import graphql.schema.GraphQLInputObjectType; import graphql.schema.GraphQLNonNull; +import java.util.Map; +import java.util.Optional; +import org.opentripplanner.framework.geometry.WgsCoordinate; +@SuppressWarnings("unchecked") public class CoordinateInputType { + /* Constants are package local to be used in unit-tests */ + static final String LATITUDE = "latitude"; + static final String LONGITUDE = "longitude"; + public static final GraphQLInputObjectType INPUT_TYPE = GraphQLInputObjectType .newInputObject() .name("InputCoordinates") @@ -14,7 +22,7 @@ public class CoordinateInputType { .field( GraphQLInputObjectField .newInputObjectField() - .name("latitude") + .name(LATITUDE) .description("The latitude of the place.") .type(new GraphQLNonNull(Scalars.GraphQLFloat)) .build() @@ -22,10 +30,42 @@ public class CoordinateInputType { .field( GraphQLInputObjectField .newInputObjectField() - .name("longitude") + .name(LONGITUDE) .description("The longitude of the place.") .type(new GraphQLNonNull(Scalars.GraphQLFloat)) .build() ) .build(); + + public static Optional mapToWsgCoordinate( + String fieldName, + Map input + ) { + Map coordinate = (Map) input.get(fieldName); + + if (coordinate != null) { + return Optional.of( + new WgsCoordinate( + readCoordinateValue(LATITUDE, coordinate), + readCoordinateValue(LONGITUDE, coordinate) + ) + ); + } + return Optional.empty(); + } + + public static Map mapForTest(WgsCoordinate coordinate) { + return Map.ofEntries( + Map.entry(LATITUDE, coordinate.latitude()), + Map.entry(LONGITUDE, coordinate.longitude()) + ); + } + + private static Double readCoordinateValue(String fieldName, Map coordinate) { + var value = (Double) coordinate.get(fieldName); + if (value == null) { + throw new IllegalArgumentException("The '%s' parameter is required.".formatted(fieldName)); + } + return value; + } } diff --git a/application/src/test/java/org/opentripplanner/apis/transmodel/model/framework/CoordinateInputTypeTest.java b/application/src/test/java/org/opentripplanner/apis/transmodel/model/framework/CoordinateInputTypeTest.java new file mode 100644 index 00000000000..81d181194b8 --- /dev/null +++ b/application/src/test/java/org/opentripplanner/apis/transmodel/model/framework/CoordinateInputTypeTest.java @@ -0,0 +1,54 @@ +package org.opentripplanner.apis.transmodel.model.framework; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; + +import java.util.Map; +import org.junit.jupiter.api.Test; +import org.opentripplanner.framework.geometry.WgsCoordinate; + +class CoordinateInputTypeTest { + + private static final double LATITUDE_VALUE = 64.5; + private static final double LONGITUDE_VALUE = 11.0; + private static final WgsCoordinate COORDINATE = new WgsCoordinate( + LATITUDE_VALUE, + LONGITUDE_VALUE + ); + + @Test + void mapToWsgCoordinate() { + assertEquals( + new WgsCoordinate(LATITUDE_VALUE, LONGITUDE_VALUE), + CoordinateInputType + .mapToWsgCoordinate("c", Map.of("c", CoordinateInputType.mapForTest(COORDINATE))) + .get() + ); + } + + @Test + void mapToWsgCoordinateWithMissingLongitude() { + var ex = assertThrows( + IllegalArgumentException.class, + () -> + CoordinateInputType.mapToWsgCoordinate( + "c", + Map.of("c", Map.ofEntries(Map.entry(CoordinateInputType.LONGITUDE, LONGITUDE_VALUE))) + ) + ); + assertEquals("The 'latitude' parameter is required.", ex.getMessage()); + } + + @Test + void mapToWsgCoordinateWithMissingLatitude() { + var ex = assertThrows( + IllegalArgumentException.class, + () -> + CoordinateInputType.mapToWsgCoordinate( + "c", + Map.of("c", Map.ofEntries(Map.entry(CoordinateInputType.LATITUDE, LATITUDE_VALUE))) + ) + ); + assertEquals("The 'longitude' parameter is required.", ex.getMessage()); + } +} From 8aef71d29761a43ac9de4f616ed7758c0ffd0d37 Mon Sep 17 00:00:00 2001 From: Thomas Gran Date: Fri, 31 Jan 2025 15:43:13 +0100 Subject: [PATCH 03/69] feature: Add Coordinate to via-visit in transmodel API --- .../mapping/TripViaLocationMapper.java | 20 ++++++---- .../model/plan/ViaLocationInputType.java | 19 +++++---- .../request/via/PassThroughViaLocation.java | 2 +- .../apis/transmodel/schema.graphql | 4 +- .../mapping/TripViaLocationMapperTest.java | 39 +++++++++++-------- 5 files changed, 50 insertions(+), 34 deletions(-) diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/mapping/TripViaLocationMapper.java b/application/src/main/java/org/opentripplanner/apis/transmodel/mapping/TripViaLocationMapper.java index 5f572c89da0..3e3e79a8c7a 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/mapping/TripViaLocationMapper.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/mapping/TripViaLocationMapper.java @@ -8,14 +8,17 @@ import java.util.Map; import java.util.Objects; import javax.annotation.Nullable; +import org.opentripplanner.apis.transmodel.model.framework.CoordinateInputType; import org.opentripplanner.apis.transmodel.model.plan.TripQuery; import org.opentripplanner.apis.transmodel.model.plan.ViaLocationInputType; import org.opentripplanner.apis.transmodel.support.OneOfInputValidator; +import org.opentripplanner.framework.geometry.WgsCoordinate; import org.opentripplanner.routing.api.request.via.PassThroughViaLocation; import org.opentripplanner.routing.api.request.via.ViaLocation; import org.opentripplanner.routing.api.request.via.VisitViaLocation; import org.opentripplanner.transit.model.framework.FeedScopedId; +@SuppressWarnings("unchecked") class TripViaLocationMapper { static List mapToViaLocations(final List> via) { @@ -57,7 +60,8 @@ private static VisitViaLocation mapVisitViaLocation(Map inputMap var label = (String) inputMap.get(ViaLocationInputType.FIELD_LABEL); var minimumWaitTime = (Duration) inputMap.get(ViaLocationInputType.FIELD_MINIMUM_WAIT_TIME); var stopLocationIds = mapStopLocationIds(inputMap); - return new VisitViaLocation(label, minimumWaitTime, stopLocationIds, List.of()); + var coordinate = mapCoordinate(inputMap); + return new VisitViaLocation(label, minimumWaitTime, stopLocationIds, coordinate); } private static PassThroughViaLocation mapPassThroughViaLocation(Map inputMap) { @@ -68,14 +72,14 @@ private static PassThroughViaLocation mapPassThroughViaLocation(Map mapStopLocationIds(Map map) { var c = (Collection) map.get(ViaLocationInputType.FIELD_STOP_LOCATION_IDS); + return c == null ? List.of() : c.stream().map(TransitIdMapper::mapIDToDomain).toList(); + } - // When coordinates are added, we need to accept null here... - if (c == null) { - throw new IllegalArgumentException( - "'" + ViaLocationInputType.FIELD_STOP_LOCATION_IDS + "' is not set!" - ); - } - return c.stream().map(TransitIdMapper::mapIDToDomain).toList(); + private static List mapCoordinate(Map map) { + return CoordinateInputType + .mapToWsgCoordinate(ViaLocationInputType.FIELD_COORDINATE, map) + .map(List::of) + .orElseGet(List::of); } /** diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/ViaLocationInputType.java b/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/ViaLocationInputType.java index ef13f8db18e..33e0fe0d24e 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/ViaLocationInputType.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/ViaLocationInputType.java @@ -9,6 +9,7 @@ import graphql.schema.GraphQLList; import graphql.schema.GraphQLNonNull; import java.time.Duration; +import org.opentripplanner.apis.transmodel.model.framework.CoordinateInputType; import org.opentripplanner.apis.transmodel.model.framework.TransmodelScalars; public class ViaLocationInputType { @@ -44,9 +45,8 @@ be accepted. To visit a coordinate, the traveler must walk(bike or drive) to the public static final String FIELD_LABEL = "label"; public static final String FIELD_MINIMUM_WAIT_TIME = "minimumWaitTime"; public static final String FIELD_STOP_LOCATION_IDS = "stopLocationIds"; + public static final String FIELD_COORDINATE = "coordinate"; - // TODO : Add coordinates - //private static final String FIELD_COORDINATES = "coordinates"; public static final String FIELD_VISIT = "visit"; public static final String DOC_FIELD_VISIT = "Board or alight at a stop location or visit a coordinate."; @@ -68,6 +68,7 @@ be accepted. To visit a coordinate, the traveler must walk(bike or drive) to the stop place or a group of stop places. It is enough to visit ONE of the locations listed. """; + private static final String DOC_COORDINATE = "A coordinate to route through."; static final GraphQLInputObjectType VISIT_VIA_LOCATION_INPUT = GraphQLInputObjectType .newInputObject() @@ -85,11 +86,11 @@ be accepted. To visit a coordinate, the traveler must walk(bike or drive) to the b .name(FIELD_STOP_LOCATION_IDS) .description(DOC_STOP_LOCATION_IDS) - .type(requiredListOfNonNullStrings()) + .type(optionalListOfNonNullStrings()) + ) + .field(b -> + b.name(FIELD_COORDINATE).description(DOC_COORDINATE).type(CoordinateInputType.INPUT_TYPE) ) - /* - TODO: Add support for coordinates - */ .build(); static final GraphQLInputObjectType PASS_THROUGH_VIA_LOCATION_INPUT = GraphQLInputObjectType @@ -121,6 +122,10 @@ be accepted. To visit a coordinate, the traveler must walk(bike or drive) to the .build(); private static GraphQLInputType requiredListOfNonNullStrings() { - return new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(GraphQLString))); + return new GraphQLNonNull(optionalListOfNonNullStrings()); + } + + private static GraphQLInputType optionalListOfNonNullStrings() { + return new GraphQLList(new GraphQLNonNull(GraphQLString)); } } diff --git a/application/src/main/java/org/opentripplanner/routing/api/request/via/PassThroughViaLocation.java b/application/src/main/java/org/opentripplanner/routing/api/request/via/PassThroughViaLocation.java index 9da6ae5cd23..c570c18f62d 100644 --- a/application/src/main/java/org/opentripplanner/routing/api/request/via/PassThroughViaLocation.java +++ b/application/src/main/java/org/opentripplanner/routing/api/request/via/PassThroughViaLocation.java @@ -16,7 +16,7 @@ public PassThroughViaLocation(@Nullable String label, Collection s super(label, stopLocationIds); if (stopLocationIds.isEmpty()) { throw new IllegalArgumentException( - "A pass through via location must have at least one stop location." + + "A pass-through via-location must have at least one stop location." + (label == null ? "" : " Label: " + label) ); } diff --git a/application/src/main/resources/org/opentripplanner/apis/transmodel/schema.graphql b/application/src/main/resources/org/opentripplanner/apis/transmodel/schema.graphql index 0c107f1e5be..dd0c8535351 100644 --- a/application/src/main/resources/org/opentripplanner/apis/transmodel/schema.graphql +++ b/application/src/main/resources/org/opentripplanner/apis/transmodel/schema.graphql @@ -2262,6 +2262,8 @@ in the street network from a stop and back to another stop to join the transit n NOTE! Coordinates are NOT supported yet. """ input TripVisitViaLocationInput { + "A coordinate to route through." + coordinate: InputCoordinates "The label/name of the location. This is pass-through information and is not used in routing." label: String """ @@ -2274,7 +2276,7 @@ input TripVisitViaLocationInput { stop place or a group of stop places. It is enough to visit ONE of the locations listed. """ - stopLocationIds: [String!]! + stopLocationIds: [String!] } "Input format for specifying a location through either a place reference (id), coordinates or both. If both place and coordinates are provided the place ref will be used if found, coordinates will only be used if place is not known. The location also contain information about the minimum and maximum time the user is willing to stay at the via location." diff --git a/application/src/test/java/org/opentripplanner/apis/transmodel/mapping/TripViaLocationMapperTest.java b/application/src/test/java/org/opentripplanner/apis/transmodel/mapping/TripViaLocationMapperTest.java index 4e6cf067fb8..343ac5c5a0c 100644 --- a/application/src/test/java/org/opentripplanner/apis/transmodel/mapping/TripViaLocationMapperTest.java +++ b/application/src/test/java/org/opentripplanner/apis/transmodel/mapping/TripViaLocationMapperTest.java @@ -6,6 +6,7 @@ import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.opentripplanner.apis.transmodel.model.plan.ViaLocationInputType.FIELD_COORDINATE; import static org.opentripplanner.apis.transmodel.model.plan.ViaLocationInputType.FIELD_LABEL; import static org.opentripplanner.apis.transmodel.model.plan.ViaLocationInputType.FIELD_MINIMUM_WAIT_TIME; import static org.opentripplanner.apis.transmodel.model.plan.ViaLocationInputType.FIELD_PASS_THROUGH; @@ -18,9 +19,12 @@ import java.util.Map; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.opentripplanner.apis.transmodel.model.framework.CoordinateInputType; +import org.opentripplanner.framework.geometry.WgsCoordinate; class TripViaLocationMapperTest { + private static final Duration D1m = Duration.ofMinutes(1); private static final String LABEL = "TestLabel"; private static final Duration MIN_WAIT_TIME = Duration.ofMinutes(5); private static final List LIST_IDS_INPUT = List.of("F:ID1", "F:ID2"); @@ -39,7 +43,7 @@ void setup() { @Test void testMapToVisitViaLocations() { Map input = Map.ofEntries( - entry(FIELD_VISIT, visitInput(LABEL, MIN_WAIT_TIME, LIST_IDS_INPUT)) + entry(FIELD_VISIT, visitInput(LABEL, MIN_WAIT_TIME, LIST_IDS_INPUT, null)) ); var result = TripViaLocationMapper.mapToViaLocations(List.of(input)); @@ -69,13 +73,16 @@ void testMapToVisitViaLocationsWithBareMinimum() { } @Test - void testMapToVisitViaLocationsWithoutIds() { + void testMapToVisitViaLocationsWithoutIdsOrCoordinates() { Map input = mapOf(FIELD_VISIT, mapOf(FIELD_STOP_LOCATION_IDS, null)); var ex = assertThrows( IllegalArgumentException.class, () -> TripViaLocationMapper.mapToViaLocations(List.of(input)) ); - assertEquals("'stopLocationIds' is not set!", ex.getMessage()); + assertEquals( + "A via location must have at least one stop location or a coordinate.", + ex.getMessage() + ); } @Test @@ -120,16 +127,6 @@ void tetMapToPassThroughWithBareMinimum() { assertTrue(via.isPassThroughLocation()); } - @Test - void tetMapToPassThroughWithoutIds() { - Map input = mapOf(FIELD_PASS_THROUGH, mapOf(FIELD_STOP_LOCATION_IDS, null)); - var ex = assertThrows( - IllegalArgumentException.class, - () -> TripViaLocationMapper.mapToViaLocations(List.of(input)) - ); - assertEquals("'stopLocationIds' is not set!", ex.getMessage()); - } - @Test void testMapToPassThroughWithAnEmptyListOfIds() { Map input = mapOf( @@ -141,7 +138,7 @@ void testMapToPassThroughWithAnEmptyListOfIds() { () -> TripViaLocationMapper.mapToViaLocations(List.of(input)) ); assertEquals( - "A pass through via location must have at least one stop location.", + "A pass-through via-location must have at least one stop location.", ex.getMessage() ); } @@ -149,7 +146,7 @@ void testMapToPassThroughWithAnEmptyListOfIds() { @Test void testOneOf() { Map input = Map.ofEntries( - entry(FIELD_VISIT, visitInput("A", Duration.ofMinutes(1), List.of("F:99"))), + entry(FIELD_VISIT, visitInput("A", D1m, List.of("F:99"), null)), entry(FIELD_PASS_THROUGH, passThroughInput(LABEL, LIST_IDS_INPUT)) ); var ex = assertThrows( @@ -214,7 +211,12 @@ void testToLegacyPassThroughLocationsWithEmptyList() { assertTrue(result.isEmpty(), REASON_EMPTY_IDS_ALLOWED_PASS_THROUGH); } - private Map visitInput(String label, Duration minWaitTime, List ids) { + private Map visitInput( + String label, + Duration minWaitTime, + List ids, + WgsCoordinate coordinate + ) { var map = new HashMap(); if (label != null) { map.put(FIELD_LABEL, label); @@ -225,11 +227,14 @@ private Map visitInput(String label, Duration minWaitTime, List< if (ids != null) { map.put(FIELD_STOP_LOCATION_IDS, ids); } + if (coordinate != null) { + map.put(FIELD_COORDINATE, CoordinateInputType.mapForTest(coordinate)); + } return map; } private Map passThroughInput(String label, List ids) { - return visitInput(label, null, ids); + return visitInput(label, null, ids, null); } /** From 1d75868b0221a2c100b49b459f8f8e70cc0f7542 Mon Sep 17 00:00:00 2001 From: Thomas Gran Date: Fri, 21 Feb 2025 10:29:57 +0100 Subject: [PATCH 04/69] feature: Add ViaCoordinateTransfer generation to TransitRouter --- .../raptoradapter/router/TransitRouter.java | 4 + .../transit/mappers/RaptorRequestMapper.java | 24 ++- .../via/ViaCoordinateTransferFactory.java | 10 ++ .../routing/via/configure/ViaModule.java | 26 ++++ .../via/model/ViaCoordinateTransfer.java | 108 +++++++++++++ .../DefaultViaCoordinateTransferFactory.java | 147 ++++++++++++++++++ .../api/OtpServerRequestContext.java | 5 +- .../ConstructApplicationFactory.java | 13 +- .../configure/ConstructApplicationModule.java | 3 + .../server/DefaultServerRequestContext.java | 13 +- .../opentripplanner/TestServerContext.java | 11 ++ .../mappers/RaptorRequestMapperTest.java | 49 ++++++ .../transit/speed_test/SpeedTest.java | 1 + 13 files changed, 402 insertions(+), 12 deletions(-) create mode 100644 application/src/main/java/org/opentripplanner/routing/via/ViaCoordinateTransferFactory.java create mode 100644 application/src/main/java/org/opentripplanner/routing/via/configure/ViaModule.java create mode 100644 application/src/main/java/org/opentripplanner/routing/via/model/ViaCoordinateTransfer.java create mode 100644 application/src/main/java/org/opentripplanner/routing/via/service/DefaultViaCoordinateTransferFactory.java diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/router/TransitRouter.java b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/router/TransitRouter.java index e287da7110c..d71402129a2 100644 --- a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/router/TransitRouter.java +++ b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/router/TransitRouter.java @@ -43,6 +43,7 @@ import org.opentripplanner.routing.api.response.RoutingErrorCode; import org.opentripplanner.routing.error.RoutingValidationException; import org.opentripplanner.routing.framework.DebugTimingAggregator; +import org.opentripplanner.routing.via.ViaCoordinateTransferFactory; import org.opentripplanner.standalone.api.OtpServerRequestContext; import org.opentripplanner.street.search.TemporaryVerticesContainer; import org.opentripplanner.transit.model.framework.EntityNotFoundException; @@ -61,6 +62,7 @@ public class TransitRouter { private final ZonedDateTime transitSearchTimeZero; private final AdditionalSearchDays additionalSearchDays; private final TemporaryVerticesContainer temporaryVerticesContainer; + private final ViaCoordinateTransferFactory viaTransferResolver; private TransitRouter( RouteRequest request, @@ -77,6 +79,7 @@ private TransitRouter( this.additionalSearchDays = additionalSearchDays; this.debugTimingAggregator = debugTimingAggregator; this.temporaryVerticesContainer = createTemporaryVerticesContainer(request, serverContext); + this.viaTransferResolver = serverContext.viaTransferResolver(); } public static TransitRouterResult route( @@ -141,6 +144,7 @@ private TransitRouterResult route() { accessEgresses.getAccesses(), accessEgresses.getEgresses(), serverContext.meterRegistry(), + viaTransferResolver, this::listStopIndexes ); diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/RaptorRequestMapper.java b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/RaptorRequestMapper.java index c5a75b02bbc..0b5b01cb64c 100644 --- a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/RaptorRequestMapper.java +++ b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/RaptorRequestMapper.java @@ -7,7 +7,9 @@ import java.time.ZonedDateTime; import java.util.Collection; import java.util.List; +import java.util.Objects; import java.util.function.Predicate; +import javax.annotation.Nullable; import org.opentripplanner.framework.application.OTPFeature; import org.opentripplanner.raptor.api.model.GeneralizedCostRelaxFunction; import org.opentripplanner.raptor.api.model.RaptorAccessEgress; @@ -29,6 +31,7 @@ import org.opentripplanner.routing.api.request.framework.CostLinearFunction; import org.opentripplanner.routing.api.request.preference.TransitPreferences; import org.opentripplanner.routing.api.request.via.ViaLocation; +import org.opentripplanner.routing.via.ViaCoordinateTransferFactory; import org.opentripplanner.transit.model.network.grouppriority.DefaultTransitGroupPriorityCalculator; public class RaptorRequestMapper { @@ -39,6 +42,7 @@ public class RaptorRequestMapper { private final long transitSearchTimeZeroEpocSecond; private final boolean isMultiThreadedEnbled; private final MeterRegistry meterRegistry; + private final ViaCoordinateTransferFactory viaTransferResolver; private final LookupStopIndexCallback lookUpStopIndex; private RaptorRequestMapper( @@ -47,16 +51,18 @@ private RaptorRequestMapper( Collection accessPaths, Collection egressPaths, long transitSearchTimeZeroEpocSecond, - MeterRegistry meterRegistry, + @Nullable MeterRegistry meterRegistry, + ViaCoordinateTransferFactory viaTransferResolver, LookupStopIndexCallback lookUpStopIndex ) { - this.request = request; + this.request = Objects.requireNonNull(request); this.isMultiThreadedEnbled = isMultiThreaded; - this.accessPaths = accessPaths; - this.egressPaths = egressPaths; + this.accessPaths = Objects.requireNonNull(accessPaths); + this.egressPaths = Objects.requireNonNull(egressPaths); this.transitSearchTimeZeroEpocSecond = transitSearchTimeZeroEpocSecond; this.meterRegistry = meterRegistry; - this.lookUpStopIndex = lookUpStopIndex; + this.viaTransferResolver = Objects.requireNonNull(viaTransferResolver); + this.lookUpStopIndex = Objects.requireNonNull(lookUpStopIndex); } public static RaptorRequest mapRequest( @@ -66,6 +72,7 @@ public static RaptorRequest mapRequest( Collection accessPaths, Collection egressPaths, MeterRegistry meterRegistry, + ViaCoordinateTransferFactory viaTransferResolver, LookupStopIndexCallback lookUpStopIndex ) { return new RaptorRequestMapper( @@ -75,6 +82,7 @@ public static RaptorRequest mapRequest( egressPaths, transitSearchTimeZero.toEpochSecond(), meterRegistry, + viaTransferResolver, lookUpStopIndex ) .doMap(); @@ -242,6 +250,12 @@ private RaptorViaLocation mapViaLocation(ViaLocation input) { for (int stopIndex : lookUpStopIndex.lookupStopLocationIndexes(input.stopLocationIds())) { builder.addViaStop(stopIndex); } + for (var coordinate : input.coordinates()) { + var viaTransfers = viaTransferResolver.createViaTransfers(request, coordinate); + for (var it : viaTransfers) { + builder.addViaTransfer(it.fromStopIndex(), it); + } + } return builder.build(); } } diff --git a/application/src/main/java/org/opentripplanner/routing/via/ViaCoordinateTransferFactory.java b/application/src/main/java/org/opentripplanner/routing/via/ViaCoordinateTransferFactory.java new file mode 100644 index 00000000000..86cebca8408 --- /dev/null +++ b/application/src/main/java/org/opentripplanner/routing/via/ViaCoordinateTransferFactory.java @@ -0,0 +1,10 @@ +package org.opentripplanner.routing.via; + +import java.util.List; +import org.opentripplanner.framework.geometry.WgsCoordinate; +import org.opentripplanner.routing.api.request.RouteRequest; +import org.opentripplanner.routing.via.model.ViaCoordinateTransfer; + +public interface ViaCoordinateTransferFactory { + List createViaTransfers(RouteRequest request, WgsCoordinate coordinate); +} diff --git a/application/src/main/java/org/opentripplanner/routing/via/configure/ViaModule.java b/application/src/main/java/org/opentripplanner/routing/via/configure/ViaModule.java new file mode 100644 index 00000000000..c6088e7ca35 --- /dev/null +++ b/application/src/main/java/org/opentripplanner/routing/via/configure/ViaModule.java @@ -0,0 +1,26 @@ +package org.opentripplanner.routing.via.configure; + +import dagger.Module; +import dagger.Provides; +import org.opentripplanner.routing.graph.Graph; +import org.opentripplanner.routing.via.ViaCoordinateTransferFactory; +import org.opentripplanner.routing.via.service.DefaultViaCoordinateTransferFactory; +import org.opentripplanner.standalone.config.BuildConfig; +import org.opentripplanner.transit.service.TransitService; + +@Module +public abstract class ViaModule { + + @Provides + static ViaCoordinateTransferFactory providesViaTransferResolver( + BuildConfig buildConfig, + TransitService transitService, + Graph graph + ) { + return new DefaultViaCoordinateTransferFactory( + graph, + transitService, + buildConfig.maxTransferDuration + ); + } +} diff --git a/application/src/main/java/org/opentripplanner/routing/via/model/ViaCoordinateTransfer.java b/application/src/main/java/org/opentripplanner/routing/via/model/ViaCoordinateTransfer.java new file mode 100644 index 00000000000..6b5a4debec3 --- /dev/null +++ b/application/src/main/java/org/opentripplanner/routing/via/model/ViaCoordinateTransfer.java @@ -0,0 +1,108 @@ +package org.opentripplanner.routing.via.model; + +import java.util.List; +import org.opentripplanner.framework.geometry.WgsCoordinate; +import org.opentripplanner.raptor.api.model.RaptorCostConverter; +import org.opentripplanner.raptor.api.model.RaptorTransfer; +import org.opentripplanner.raptor.api.model.RaptorValueFormatter; +import org.opentripplanner.street.model.edge.Edge; +import org.opentripplanner.utils.time.DurationUtils; + +/** + * This class will act as a {@link RaptorTransfer} during the Raptor routing and carry enough + * information to create an itinerary after the routing is done. + *

+ * When routing via a coordinate, we need to generate transfers Raptor can use for all permutations + * of near-by-stops. This class is one such instance. We do NOT stitch the two sets of edges + * together because this will use unnecessary resource before we know if an instance is used + * in a Raptor Path. So this is left to the itinerary mapping. + */ +public class ViaCoordinateTransfer implements RaptorTransfer { + + private final WgsCoordinate coordinate; + private final int fromStopIndex; + private final int toStopIndex; + private final List fromEdges; + private final List toEdges; + private final int durationInSeconds; + private final int raptorCost; + + /** + * @param coordinate the coordinate of given via point. + * @param fromStopIndex The Raptor stop index to use for the arriving stop. + * @param toStopIndex The Raptor stop index to use for the boarding stop. + * @param fromEdges the street path FROM the alighting stop to the given via point. + * @param toEdges the street path TO the departing stop from the given via point. + * @param durationInSeconds How long it takes the traverse the from and to edges, exclusive + * via `minimum-wait-time`. + * @param generalizedCostInSeconds The total cost traversing the from and to edges in the OTP + * domain generalized-cost. The unit is equivalent to seconds. + * The cost will be converted to Raptor units and cashed for + * optimal performance. + */ + public ViaCoordinateTransfer( + WgsCoordinate coordinate, + int fromStopIndex, + int toStopIndex, + List fromEdges, + List toEdges, + int durationInSeconds, + double generalizedCostInSeconds + ) { + this.coordinate = coordinate; + this.fromStopIndex = fromStopIndex; + this.toStopIndex = toStopIndex; + this.fromEdges = fromEdges; + this.toEdges = toEdges; + this.durationInSeconds = durationInSeconds; + this.raptorCost = RaptorCostConverter.toRaptorCost(generalizedCostInSeconds); + } + + public WgsCoordinate coordinate() { + return coordinate; + } + + public int fromStopIndex() { + return fromStopIndex; + } + + public List fromEdges() { + return fromEdges; + } + + public List toEdges() { + return toEdges; + } + + @Override + public int stop() { + return toStopIndex; + } + + @Override + public int c1() { + return raptorCost; + } + + @Override + public int durationInSeconds() { + return durationInSeconds; + } + + @Override + public String toString() { + return ( + "{" + + coordinate + + " " + + fromStopIndex + + " ~ " + + toStopIndex + + " " + + DurationUtils.durationToStr(durationInSeconds) + + " " + + RaptorValueFormatter.formatC1(raptorCost) + + "}" + ); + } +} diff --git a/application/src/main/java/org/opentripplanner/routing/via/service/DefaultViaCoordinateTransferFactory.java b/application/src/main/java/org/opentripplanner/routing/via/service/DefaultViaCoordinateTransferFactory.java new file mode 100644 index 00000000000..6b7722f8d04 --- /dev/null +++ b/application/src/main/java/org/opentripplanner/routing/via/service/DefaultViaCoordinateTransferFactory.java @@ -0,0 +1,147 @@ +package org.opentripplanner.routing.via.service; + +import jakarta.inject.Inject; +import java.time.Duration; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; +import org.opentripplanner.framework.geometry.WgsCoordinate; +import org.opentripplanner.framework.i18n.I18NString; +import org.opentripplanner.graph_builder.module.nearbystops.NearbyStopFinder; +import org.opentripplanner.graph_builder.module.nearbystops.StraightLineNearbyStopFinder; +import org.opentripplanner.graph_builder.module.nearbystops.StreetNearbyStopFinder; +import org.opentripplanner.routing.api.request.RouteRequest; +import org.opentripplanner.routing.api.request.StreetMode; +import org.opentripplanner.routing.graph.Graph; +import org.opentripplanner.routing.graphfinder.NearbyStop; +import org.opentripplanner.routing.linking.DisposableEdgeCollection; +import org.opentripplanner.routing.linking.LinkingDirection; +import org.opentripplanner.routing.via.ViaCoordinateTransferFactory; +import org.opentripplanner.routing.via.model.ViaCoordinateTransfer; +import org.opentripplanner.street.model.edge.TemporaryFreeEdge; +import org.opentripplanner.street.model.vertex.TemporaryStreetLocation; +import org.opentripplanner.street.search.TraverseMode; +import org.opentripplanner.street.search.TraverseModeSet; +import org.opentripplanner.transit.service.TransitService; + +public class DefaultViaCoordinateTransferFactory implements ViaCoordinateTransferFactory { + + private final Graph graph; + private final TransitService transitService; + private final Duration radiusByDuration; + + @Inject + public DefaultViaCoordinateTransferFactory( + Graph graph, + TransitService transitService, + Duration radiusByDuration + ) { + this.graph = graph; + this.transitService = transitService; + // We divide the regular transfer radius by two, since we have two "transfers" after each + // other here. This reduces the number of possible transfers 4 times. The radius should + // probably have its own configuration setting. There are no algorithmic reasons for using + // the transfer radius here, any value can be used. + this.radiusByDuration = radiusByDuration.dividedBy(2); + } + + @Override + public List createViaTransfers( + RouteRequest request, + WgsCoordinate coordinate + ) { + DisposableEdgeCollection tempEdges = null; + try { + var nearbyStopFinder = createNearbyStopFinder(radiusByDuration); + + var viaVertex = TemporaryStreetLocation.via( + UUID.randomUUID().toString(), + coordinate.asJtsCoordinate(), + I18NString.of("Via " + coordinate) + ); + + var m = mapTransferMode(request.journey().modes().transferMode); + + tempEdges = + graph + .getLinker() + .linkVertexForRequest( + viaVertex, + new TraverseModeSet(m), + LinkingDirection.BOTH_WAYS, + (via, street) -> { + var v = (TemporaryStreetLocation) via; + return List.of( + TemporaryFreeEdge.createTemporaryFreeEdge(street, v), + TemporaryFreeEdge.createTemporaryFreeEdge(v, street) + ); + } + ); + + var toStops = nearbyStopFinder.findNearbyStops( + viaVertex, + request, + request.journey().transfer(), + false + ); + var fromStops = nearbyStopFinder.findNearbyStops( + viaVertex, + request, + request.journey().transfer(), + true + ); + + var transfers = new ArrayList(); + + for (NearbyStop from : fromStops) { + if (from.stop.transfersNotAllowed()) { + continue; + } + for (NearbyStop to : toStops) { + transfers.add( + new ViaCoordinateTransfer( + coordinate, + from.stop.getIndex(), + to.stop.getIndex(), + from.edges, + to.edges, + (int) (from.state.getElapsedTimeSeconds() + to.state.getElapsedTimeSeconds()), + from.state.getWeight() + to.state.getWeight() + ) + ); + } + } + return transfers; + } catch (RuntimeException ex) { + if (tempEdges != null) { + tempEdges.disposeEdges(); + } + throw ex; + } + } + + private static TraverseMode mapTransferMode(StreetMode txM) { + if (txM.includesBiking()) { + return TraverseMode.BICYCLE; + } + if (txM.includesScooter()) { + return TraverseMode.SCOOTER; + } + if (txM.includesWalking()) { + return TraverseMode.WALK; + } + throw new IllegalStateException("Mode not allowed for transfer: " + txM); + } + + /** + * Factory method for creating a NearbyStopFinder. The linker will use streets if they are + * available, or straight-line distance otherwise. + */ + private NearbyStopFinder createNearbyStopFinder(Duration radiusByDuration) { + if (!graph.hasStreets) { + return new StraightLineNearbyStopFinder(transitService, radiusByDuration); + } else { + return new StreetNearbyStopFinder(radiusByDuration, 0, null); + } + } +} diff --git a/application/src/main/java/org/opentripplanner/standalone/api/OtpServerRequestContext.java b/application/src/main/java/org/opentripplanner/standalone/api/OtpServerRequestContext.java index 650ce03c763..99b47c3bb28 100644 --- a/application/src/main/java/org/opentripplanner/standalone/api/OtpServerRequestContext.java +++ b/application/src/main/java/org/opentripplanner/standalone/api/OtpServerRequestContext.java @@ -22,6 +22,7 @@ import org.opentripplanner.routing.api.request.RouteRequest; import org.opentripplanner.routing.graph.Graph; import org.opentripplanner.routing.graphfinder.GraphFinder; +import org.opentripplanner.routing.via.ViaCoordinateTransferFactory; import org.opentripplanner.service.realtimevehicles.RealtimeVehicleService; import org.opentripplanner.service.vehicleparking.VehicleParkingService; import org.opentripplanner.service.vehiclerental.VehicleRentalService; @@ -62,6 +63,8 @@ */ @HttpRequestScoped public interface OtpServerRequestContext { + DebugUiConfig debugUiConfig(); + /** * A RouteRequest containing default parameters that will be cloned when handling each request. */ @@ -125,7 +128,7 @@ default GraphFinder graphFinder() { VectorTileConfig vectorTileConfig(); - DebugUiConfig debugUiConfig(); + ViaCoordinateTransferFactory viaTransferResolver(); /* Sandbox modules */ diff --git a/application/src/main/java/org/opentripplanner/standalone/configure/ConstructApplicationFactory.java b/application/src/main/java/org/opentripplanner/standalone/configure/ConstructApplicationFactory.java index 102b6312df9..acc550e3867 100644 --- a/application/src/main/java/org/opentripplanner/standalone/configure/ConstructApplicationFactory.java +++ b/application/src/main/java/org/opentripplanner/standalone/configure/ConstructApplicationFactory.java @@ -21,6 +21,8 @@ import org.opentripplanner.routing.algorithm.raptoradapter.transit.TripSchedule; import org.opentripplanner.routing.api.request.RouteRequest; import org.opentripplanner.routing.graph.Graph; +import org.opentripplanner.routing.via.ViaCoordinateTransferFactory; +import org.opentripplanner.routing.via.configure.ViaModule; import org.opentripplanner.service.realtimevehicles.RealtimeVehicleRepository; import org.opentripplanner.service.realtimevehicles.RealtimeVehicleService; import org.opentripplanner.service.realtimevehicles.configure.RealtimeVehicleRepositoryModule; @@ -62,14 +64,15 @@ RealtimeVehicleServiceModule.class, RealtimeVehicleRepositoryModule.class, RideHailingServicesModule.class, + SchemaModule.class, + SorlandsbanenNorwayModule.class, + StopConsolidationServiceModule.class, + StreetLimitationParametersServiceModule.class, TransitModule.class, VehicleParkingServiceModule.class, VehicleRentalRepositoryModule.class, VehicleRentalServiceModule.class, - SorlandsbanenNorwayModule.class, - SchemaModule.class, - StopConsolidationServiceModule.class, - StreetLimitationParametersServiceModule.class, + ViaModule.class, WorldEnvelopeServiceModule.class, } ) @@ -100,6 +103,8 @@ public interface ConstructApplicationFactory { MetricsLogging metricsLogging(); + ViaCoordinateTransferFactory viaTransferResolver(); + @Nullable StopConsolidationRepository stopConsolidationRepository(); diff --git a/application/src/main/java/org/opentripplanner/standalone/configure/ConstructApplicationModule.java b/application/src/main/java/org/opentripplanner/standalone/configure/ConstructApplicationModule.java index cfb58cbeac4..ed2f2d4bed4 100644 --- a/application/src/main/java/org/opentripplanner/standalone/configure/ConstructApplicationModule.java +++ b/application/src/main/java/org/opentripplanner/standalone/configure/ConstructApplicationModule.java @@ -16,6 +16,7 @@ import org.opentripplanner.raptor.configure.RaptorConfig; import org.opentripplanner.routing.algorithm.raptoradapter.transit.TripSchedule; import org.opentripplanner.routing.graph.Graph; +import org.opentripplanner.routing.via.ViaCoordinateTransferFactory; import org.opentripplanner.service.realtimevehicles.RealtimeVehicleService; import org.opentripplanner.service.vehicleparking.VehicleParkingService; import org.opentripplanner.service.vehiclerental.VehicleRentalService; @@ -43,6 +44,7 @@ OtpServerRequestContext providesServerContext( VehicleRentalService vehicleRentalService, VehicleParkingService vehicleParkingService, List rideHailingServices, + ViaCoordinateTransferFactory viaTransferResolver, @Nullable StopConsolidationService stopConsolidationService, StreetLimitationParametersService streetLimitationParametersService, @Nullable TraverseVisitor traverseVisitor, @@ -73,6 +75,7 @@ OtpServerRequestContext providesServerContext( vectorTileConfig, vehicleParkingService, vehicleRentalService, + viaTransferResolver, worldEnvelopeService, emissionsService, luceneIndex, diff --git a/application/src/main/java/org/opentripplanner/standalone/server/DefaultServerRequestContext.java b/application/src/main/java/org/opentripplanner/standalone/server/DefaultServerRequestContext.java index ba5aa8eda8c..a5ca86550d2 100644 --- a/application/src/main/java/org/opentripplanner/standalone/server/DefaultServerRequestContext.java +++ b/application/src/main/java/org/opentripplanner/standalone/server/DefaultServerRequestContext.java @@ -20,6 +20,7 @@ import org.opentripplanner.routing.api.request.RouteRequest; import org.opentripplanner.routing.graph.Graph; import org.opentripplanner.routing.service.DefaultRoutingService; +import org.opentripplanner.routing.via.ViaCoordinateTransferFactory; import org.opentripplanner.service.realtimevehicles.RealtimeVehicleService; import org.opentripplanner.service.vehicleparking.VehicleParkingService; import org.opentripplanner.service.vehiclerental.VehicleRentalService; @@ -52,6 +53,7 @@ public class DefaultServerRequestContext implements OtpServerRequestContext { private final VectorTileConfig vectorTileConfig; private final VehicleParkingService vehicleParkingService; private final VehicleRentalService vehicleRentalService; + private final ViaCoordinateTransferFactory viaTransferResolver; private final WorldEnvelopeService worldEnvelopeService; /* Optional fields */ @@ -98,6 +100,7 @@ public DefaultServerRequestContext( VectorTileConfig vectorTileConfig, VehicleParkingService vehicleParkingService, VehicleRentalService vehicleRentalService, + ViaCoordinateTransferFactory viaTransferResolver, WorldEnvelopeService worldEnvelopeService, @Nullable EmissionsService emissionsService, @Nullable LuceneIndex luceneIndex, @@ -120,6 +123,7 @@ public DefaultServerRequestContext( this.vectorTileConfig = vectorTileConfig; this.vehicleParkingService = vehicleParkingService; this.vehicleRentalService = vehicleRentalService; + this.viaTransferResolver = viaTransferResolver; this.worldEnvelopeService = worldEnvelopeService; // Optional fields @@ -131,6 +135,11 @@ public DefaultServerRequestContext( this.traverseVisitor = traverseVisitor; } + @Override + public DebugUiConfig debugUiConfig() { + return debugUiConfig; + } + @Override public RouteRequest defaultRouteRequest() { // Lazy initialize request-scoped request to avoid doing this when not needed @@ -240,8 +249,8 @@ public VectorTileConfig vectorTileConfig() { } @Override - public DebugUiConfig debugUiConfig() { - return debugUiConfig; + public ViaCoordinateTransferFactory viaTransferResolver() { + return viaTransferResolver; } @Nullable diff --git a/application/src/test/java/org/opentripplanner/TestServerContext.java b/application/src/test/java/org/opentripplanner/TestServerContext.java index fdae290cb2b..e89dc98392b 100644 --- a/application/src/test/java/org/opentripplanner/TestServerContext.java +++ b/application/src/test/java/org/opentripplanner/TestServerContext.java @@ -3,6 +3,7 @@ import static org.opentripplanner.standalone.configure.ConstructApplication.createRaptorTransitData; import io.micrometer.core.instrument.Metrics; +import java.time.Duration; import java.time.LocalDate; import java.util.List; import javax.annotation.Nullable; @@ -13,6 +14,8 @@ import org.opentripplanner.routing.algorithm.raptoradapter.transit.TripSchedule; import org.opentripplanner.routing.api.request.RouteRequest; import org.opentripplanner.routing.graph.Graph; +import org.opentripplanner.routing.via.ViaCoordinateTransferFactory; +import org.opentripplanner.routing.via.service.DefaultViaCoordinateTransferFactory; import org.opentripplanner.service.realtimevehicles.RealtimeVehicleService; import org.opentripplanner.service.realtimevehicles.internal.DefaultRealtimeVehicleService; import org.opentripplanner.service.vehicleparking.VehicleParkingService; @@ -97,6 +100,7 @@ public static OtpServerRequestContext createServerContext( routerConfig.vectorTileConfig(), createVehicleParkingService(), createVehicleRentalService(), + createViaTransferResolver(graph, transitService), createWorldEnvelopeService(), createEmissionsService(), null, @@ -138,4 +142,11 @@ public static EmissionsService createEmissionsService() { public static StreetLimitationParametersService createStreetLimitationParametersService() { return new DefaultStreetLimitationParametersService(new StreetLimitationParameters()); } + + public static ViaCoordinateTransferFactory createViaTransferResolver( + Graph graph, + TransitService transitService + ) { + return new DefaultViaCoordinateTransferFactory(graph, transitService, Duration.ofMinutes(30)); + } } diff --git a/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/RaptorRequestMapperTest.java b/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/RaptorRequestMapperTest.java index 9424a6b2d13..1c70c1c27d6 100644 --- a/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/RaptorRequestMapperTest.java +++ b/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/RaptorRequestMapperTest.java @@ -19,6 +19,7 @@ import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; +import org.opentripplanner.framework.geometry.WgsCoordinate; import org.opentripplanner.raptor.api.model.RaptorAccessEgress; import org.opentripplanner.raptor.api.request.RaptorRequest; import org.opentripplanner.raptorlegacy._data.transit.TestAccessEgress; @@ -27,6 +28,8 @@ import org.opentripplanner.routing.api.request.framework.CostLinearFunction; import org.opentripplanner.routing.api.request.via.PassThroughViaLocation; import org.opentripplanner.routing.api.request.via.VisitViaLocation; +import org.opentripplanner.routing.via.ViaCoordinateTransferFactory; +import org.opentripplanner.routing.via.model.ViaCoordinateTransfer; import org.opentripplanner.transit.model._data.TimetableRepositoryForTest; import org.opentripplanner.transit.model.framework.FeedScopedId; import org.opentripplanner.transit.model.site.StopLocation; @@ -46,8 +49,20 @@ class RaptorRequestMapperTest { List.of(STOP_A.getId()), List.of() ); + private static final int VIA_FROM_STOP_INDEX = 47; + private static final int VIA_TO_STOP_INDEX = 123; private static final List ACCESS = List.of(TestAccessEgress.walk(12, 45)); private static final List EGRESS = List.of(TestAccessEgress.walk(144, 54)); + private static final WgsCoordinate VIA_COORDINATE = WgsCoordinate.GREENWICH; + public static final ViaCoordinateTransfer VIA_TRANSFER = new ViaCoordinateTransfer( + VIA_COORDINATE, + VIA_FROM_STOP_INDEX, + VIA_TO_STOP_INDEX, + List.of(), + List.of(), + 10, + 12.0 + ); private static final CostLinearFunction R1 = CostLinearFunction.of("50 + 1.0x"); private static final CostLinearFunction R2 = CostLinearFunction.of("0 + 1.5x"); @@ -112,6 +127,26 @@ void testPassThroughPoints() { ); } + @Test + void testViaCoordinate() { + var req = new RouteRequest(); + Duration minimumWaitTime = Duration.ofMinutes(10); + + req.setViaLocations( + List.of( + new VisitViaLocation("Via coordinate", minimumWaitTime, List.of(), List.of(VIA_COORDINATE)) + ) + ); + + var result = map(req); + + assertFalse(result.searchParams().viaLocations().isEmpty()); + assertEquals( + "[Via{label: Via coordinate, minWaitTime: 10m, connections: [47~123 10m10s]}]", + result.searchParams().viaLocations().toString() + ); + } + @Test void testTransitGroupPriority() { var req = new RouteRequest(); @@ -231,6 +266,7 @@ private static RaptorRequest map(RouteRequest request) { ACCESS, EGRESS, null, + new DummyViaCoordinateTransferFactory(), id -> IntStream.of(STOPS_MAP.get(id).getIndex()) ); } @@ -303,4 +339,17 @@ enum RequestFeature { TRANSIT_GROUP_PRIORITY, RELAX_COST_DEST, } + + private static class DummyViaCoordinateTransferFactory implements ViaCoordinateTransferFactory { + + @Override + public List createViaTransfers( + RouteRequest request, + WgsCoordinate coordinate + ) { + // Make sure the input is the expected via-coordinate + assertEquals(VIA_COORDINATE, coordinate); + return List.of(VIA_TRANSFER); + } + } } diff --git a/application/src/test/java/org/opentripplanner/transit/speed_test/SpeedTest.java b/application/src/test/java/org/opentripplanner/transit/speed_test/SpeedTest.java index 545cda99249..758c3a2cb2f 100644 --- a/application/src/test/java/org/opentripplanner/transit/speed_test/SpeedTest.java +++ b/application/src/test/java/org/opentripplanner/transit/speed_test/SpeedTest.java @@ -127,6 +127,7 @@ public SpeedTest( VectorTileConfig.DEFAULT, TestServerContext.createVehicleParkingService(), TestServerContext.createVehicleRentalService(), + TestServerContext.createViaTransferResolver(graph, transitService), TestServerContext.createWorldEnvelopeService(), TestServerContext.createEmissionsService(), null, From a30af5e692f7e9aae4f214b6750d7d44148ce6cc Mon Sep 17 00:00:00 2001 From: Thomas Gran Date: Fri, 31 Jan 2025 11:08:23 +0100 Subject: [PATCH 05/69] refactor: Small cleanup to PlannerResource --- .../ext/restapi/resources/PlannerResource.java | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/application/src/ext/java/org/opentripplanner/ext/restapi/resources/PlannerResource.java b/application/src/ext/java/org/opentripplanner/ext/restapi/resources/PlannerResource.java index 9c58c1c719d..f160f0427b9 100644 --- a/application/src/ext/java/org/opentripplanner/ext/restapi/resources/PlannerResource.java +++ b/application/src/ext/java/org/opentripplanner/ext/restapi/resources/PlannerResource.java @@ -18,8 +18,6 @@ import org.opentripplanner.ext.restapi.model.ElevationMetadata; import org.opentripplanner.ext.restapi.model.TripPlannerResponse; import org.opentripplanner.framework.application.OTPRequestTimeoutException; -import org.opentripplanner.routing.api.request.RouteRequest; -import org.opentripplanner.routing.api.response.RoutingResponse; import org.opentripplanner.routing.error.RoutingValidationException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -62,14 +60,12 @@ public Response plan(@Context UriInfo uriInfo, @Context Request grizzlyRequest) // Create response object, containing a copy of all request parameters. Maybe they should be in the debug section of the response. TripPlannerResponse response = new TripPlannerResponse(uriInfo); - RouteRequest request = null; - RoutingResponse res = null; try { /* Fill in request fields from query parameters via shared superclass method, catching any errors. */ - request = super.buildRequest(uriInfo.getQueryParameters()); + var request = super.buildRequest(uriInfo.getQueryParameters()); // Route - res = serverContext.routingService().route(request); + var res = serverContext.routingService().route(request); // Map to API // TODO VIA (Leonard) - we should store the default showIntermediateStops somewhere From c8720bcf743be02f53c4db2a175e4ae53e384d25 Mon Sep 17 00:00:00 2001 From: Thomas Gran Date: Mon, 3 Feb 2025 16:48:37 +0100 Subject: [PATCH 06/69] feature: Include access and egress duration in "walk time" for path diff tool --- .../routing/algorithm/raptoradapter/path/PathDiff.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/path/PathDiff.java b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/path/PathDiff.java index d595c8abcff..1b14944a12f 100644 --- a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/path/PathDiff.java +++ b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/path/PathDiff.java @@ -11,7 +11,6 @@ import java.util.function.Consumer; import java.util.stream.Collectors; import org.opentripplanner.raptor.api.model.RaptorTripSchedule; -import org.opentripplanner.raptor.api.path.PathLeg; import org.opentripplanner.raptor.api.path.RaptorPath; import org.opentripplanner.routing.util.DiffEntry; import org.opentripplanner.routing.util.DiffTool; @@ -48,11 +47,11 @@ private PathDiff(RaptorPath path) { this.walkDuration = path .legStream() - .filter(PathLeg::isTransferLeg) + .filter(l -> l.isAccessLeg() || l.isTransferLeg() || l.isEgressLeg()) .mapToInt(l -> l.asTransferLeg().duration()) .sum(); this.routes.addAll( - path.transitLegs().map(l -> l.trip().pattern().debugInfo()).collect(Collectors.toList()) + path.transitLegs().map(l -> l.trip().pattern().debugInfo()).toList() ); this.stops.addAll(path.listStops()); } @@ -68,10 +67,12 @@ public static void logDiff( ) { var result = diff(left, right, skipCost); + // Walk* is access + transfer + egress time, independent of street mode - could be flex + // or bycycle as well. TableBuilder tbl = Table .of() .withAlights(Center, Right, Right, Right, Right, Right, Right, Left) - .withHeaders("STATUS", "TX", "Duration", "Cost", "Walk", "Start", "End", "Path"); + .withHeaders("STATUS", "TX", "Duration", "Cost", "Walk*", "Start", "End", "Path"); for (DiffEntry> e : result) { if (skipEquals && e.isEqual()) { From a1dcb9145c9d0619b8976f9541b12c3332606c8d Mon Sep 17 00:00:00 2001 From: Thomas Gran Date: Fri, 14 Feb 2025 19:09:31 +0100 Subject: [PATCH 07/69] fix: Avoid cast and use safe duration method in PathDiff --- .../routing/algorithm/raptoradapter/path/PathDiff.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/path/PathDiff.java b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/path/PathDiff.java index 1b14944a12f..a2e9a59f394 100644 --- a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/path/PathDiff.java +++ b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/path/PathDiff.java @@ -11,6 +11,7 @@ import java.util.function.Consumer; import java.util.stream.Collectors; import org.opentripplanner.raptor.api.model.RaptorTripSchedule; +import org.opentripplanner.raptor.api.path.PathLeg; import org.opentripplanner.raptor.api.path.RaptorPath; import org.opentripplanner.routing.util.DiffEntry; import org.opentripplanner.routing.util.DiffTool; @@ -48,11 +49,9 @@ private PathDiff(RaptorPath path) { path .legStream() .filter(l -> l.isAccessLeg() || l.isTransferLeg() || l.isEgressLeg()) - .mapToInt(l -> l.asTransferLeg().duration()) + .mapToInt(PathLeg::duration) .sum(); - this.routes.addAll( - path.transitLegs().map(l -> l.trip().pattern().debugInfo()).toList() - ); + this.routes.addAll(path.transitLegs().map(l -> l.trip().pattern().debugInfo()).toList()); this.stops.addAll(path.listStops()); } From 719cf5c92b9b08dca694f89981e973727117fc4e Mon Sep 17 00:00:00 2001 From: Thomas Gran Date: Mon, 3 Feb 2025 13:05:33 +0100 Subject: [PATCH 08/69] doc: Fix line break in RaptorViaConnection.java --- .../raptor/api/request/RaptorViaConnection.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/raptor/src/main/java/org/opentripplanner/raptor/api/request/RaptorViaConnection.java b/raptor/src/main/java/org/opentripplanner/raptor/api/request/RaptorViaConnection.java index a8359e6c5fa..489426af5e1 100644 --- a/raptor/src/main/java/org/opentripplanner/raptor/api/request/RaptorViaConnection.java +++ b/raptor/src/main/java/org/opentripplanner/raptor/api/request/RaptorViaConnection.java @@ -11,9 +11,8 @@ * A via-connection is used to define one of the physical locations in a via location Raptor must * visit. At least one connection in a {@link RaptorViaLocation} must be used. A connection can be * a single stop or a stop and a transfer to another stop. The last is useful if you want to use - * the connection to visit something other than a stop, like a street location. - * This is not an alternative to transfers. Raptor supports several use-cases - * through via-connections: + * the connection to visit something other than a stop, like a street location. This is not an + * alternative to transfers. Raptor supports several use-cases through via-connections: * *

Route via a pass-through-stop

* Raptor will allow a path to go through a pass-through-stop. The stop can be visited on-board From 8e3996f11c8f8e9632aad7c1ae5ed3c7c45d204f Mon Sep 17 00:00:00 2001 From: Thomas Gran Date: Mon, 17 Feb 2025 13:21:45 +0100 Subject: [PATCH 09/69] refactor: Applcation tests should use DefaultRaptorTransfer, not Raptor Test dummy. --- .../transit/DefaultRaptorTransfer.java | 71 ++++++++++++++++--- .../transit/RaptorTransferIndex.java | 2 +- .../raptoradapter/transit/Transfer.java | 29 +++++--- .../_data/api/TestPathBuilder.java | 3 +- .../_data/transit/TestTransfer.java | 52 ++++++-------- .../_data/transit/TestTransitData.java | 6 +- .../services/TransferGeneratorTest.java | 22 +++--- 7 files changed, 122 insertions(+), 63 deletions(-) diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/DefaultRaptorTransfer.java b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/DefaultRaptorTransfer.java index 3547a7ba05b..a88f2082946 100644 --- a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/DefaultRaptorTransfer.java +++ b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/DefaultRaptorTransfer.java @@ -1,15 +1,70 @@ package org.opentripplanner.routing.algorithm.raptoradapter.transit; +import java.util.Objects; import org.opentripplanner.raptor.api.model.RaptorTransfer; +import org.opentripplanner.utils.lang.OtpNumberFormat; +import org.opentripplanner.utils.time.DurationUtils; -public record DefaultRaptorTransfer(int stop, int durationInSeconds, int c1, Transfer transfer) - implements RaptorTransfer { - public static DefaultRaptorTransfer reverseOf(int fromStopIndex, RaptorTransfer transfer) { - return new DefaultRaptorTransfer( - fromStopIndex, - transfer.durationInSeconds(), - transfer.c1(), - transfer instanceof DefaultRaptorTransfer drt ? drt.transfer : null +public final class DefaultRaptorTransfer implements RaptorTransfer { + + private final int stop; + private final int durationInSeconds; + private final int c1; + private final Transfer transfer; + + public DefaultRaptorTransfer(int stop, int durationInSeconds, int c1, Transfer transfer) { + this.stop = stop; + this.durationInSeconds = durationInSeconds; + this.c1 = c1; + this.transfer = transfer; + } + + public int stop() { + return stop; + } + + public int durationInSeconds() { + return durationInSeconds; + } + + public int c1() { + return c1; + } + + public Transfer transfer() { + return transfer; + } + + public DefaultRaptorTransfer reverseOf(int fromStopIndex) { + return new DefaultRaptorTransfer(fromStopIndex, durationInSeconds, c1, transfer); + } + + @Override + public boolean equals(Object o) { + // Note! The 'transfer' is not part of the equals method, two paths with the same cost and + // dutation is equal, we should just pick one. + if (o == null || getClass() != o.getClass()) { + return false; + } + var that = (DefaultRaptorTransfer) o; + return stop == that.stop && durationInSeconds == that.durationInSeconds && c1 == that.c1; + } + + @Override + public int hashCode() { + // See implementation note in equals(..) + return Objects.hash(stop, durationInSeconds, c1); + } + + @Override + public String toString() { + String duration = DurationUtils.durationToStr(durationInSeconds()); + return String.format( + "%s %s %s ~ %d", + transfer.modesAsString(), + duration, + OtpNumberFormat.formatCostCenti(c1), + stop() ); } } diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/RaptorTransferIndex.java b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/RaptorTransferIndex.java index fa44d793664..3a3f9274d20 100644 --- a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/RaptorTransferIndex.java +++ b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/RaptorTransferIndex.java @@ -93,7 +93,7 @@ private static RaptorTransferIndex create( for (var forwardTransfer : forwardTransfers.get(fromStop)) { reversedTransfers .get(forwardTransfer.stop()) - .add(DefaultRaptorTransfer.reverseOf(fromStop, forwardTransfer)); + .add(((DefaultRaptorTransfer) forwardTransfer).reverseOf(fromStop)); } } return new RaptorTransferIndex(forwardTransfers, reversedTransfers); diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/Transfer.java b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/Transfer.java index 20a36376ae7..39922a63894 100644 --- a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/Transfer.java +++ b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/Transfer.java @@ -2,11 +2,9 @@ import java.util.ArrayList; import java.util.Arrays; -import java.util.Collections; import java.util.EnumSet; import java.util.List; import java.util.Optional; -import java.util.Set; import org.locationtech.jts.geom.Coordinate; import org.opentripplanner.raptor.api.model.RaptorCostConverter; import org.opentripplanner.raptor.api.model.RaptorTransfer; @@ -32,22 +30,24 @@ public class Transfer { private final int distanceMeters; - private final List edges; + /** EnumSet is modifiable, please do not modify or expose this outside the class */ + private final EnumSet modes; - private final Set modes; + private final List edges; - public Transfer(int toStop, List edges, EnumSet modes) { + private Transfer(int toStop, int distanceMeters, EnumSet modes, List edges) { this.toStop = toStop; + this.distanceMeters = distanceMeters; + this.modes = EnumSet.copyOf(modes); this.edges = edges; - this.distanceMeters = (int) edges.stream().mapToDouble(Edge::getDistanceMeters).sum(); - this.modes = Collections.unmodifiableSet(modes); + } + + public Transfer(int toStop, List edges, EnumSet modes) { + this(toStop, (int) edges.stream().mapToDouble(Edge::getDistanceMeters).sum(), modes, edges); } public Transfer(int toStopIndex, int distanceMeters, EnumSet modes) { - this.toStop = toStopIndex; - this.distanceMeters = distanceMeters; - this.edges = null; - this.modes = Collections.unmodifiableSet(modes); + this(toStopIndex, distanceMeters, modes, null); } public List getCoordinates() { @@ -112,6 +112,13 @@ public Optional asRaptorTransfer(StreetSearchRequest request) { ); } + /** + * This return "WALK" or "[BIKE, WALK]". Intended for debugging and logging, do not parse. + */ + public String modesAsString() { + return modes.size() == 1 ? modes.stream().findFirst().get().toString() : modes.toString(); + } + /** * Since transfer costs are not computed through a full A* with pruning they can incur an * absurdly high cost that overflows the integer cost inside RAPTOR diff --git a/application/src/test/java/org/opentripplanner/raptorlegacy/_data/api/TestPathBuilder.java b/application/src/test/java/org/opentripplanner/raptorlegacy/_data/api/TestPathBuilder.java index 8f0dbc65f42..699f9091ce4 100644 --- a/application/src/test/java/org/opentripplanner/raptorlegacy/_data/api/TestPathBuilder.java +++ b/application/src/test/java/org/opentripplanner/raptorlegacy/_data/api/TestPathBuilder.java @@ -16,6 +16,7 @@ import org.opentripplanner.raptorlegacy._data.transit.TestTransfer; import org.opentripplanner.raptorlegacy._data.transit.TestTripPattern; import org.opentripplanner.raptorlegacy._data.transit.TestTripSchedule; +import org.opentripplanner.routing.algorithm.raptoradapter.transit.DefaultRaptorTransfer; /** * Utility to help build paths for testing. The path builder is "reusable", every time the {@code @@ -87,7 +88,7 @@ public TestPathBuilder walk(int duration, int toStop) { return walk(TestTransfer.transfer(toStop, duration)); } - public TestPathBuilder walk(TestTransfer transfer) { + public TestPathBuilder walk(DefaultRaptorTransfer transfer) { builder.transfer(transfer, transfer.stop()); return this; } diff --git a/application/src/test/java/org/opentripplanner/raptorlegacy/_data/transit/TestTransfer.java b/application/src/test/java/org/opentripplanner/raptorlegacy/_data/transit/TestTransfer.java index 700376d7f06..c06bf145b30 100644 --- a/application/src/test/java/org/opentripplanner/raptorlegacy/_data/transit/TestTransfer.java +++ b/application/src/test/java/org/opentripplanner/raptorlegacy/_data/transit/TestTransfer.java @@ -2,20 +2,34 @@ import static org.opentripplanner.raptor.api.model.RaptorCostConverter.toRaptorCost; -import org.opentripplanner.raptor.api.model.RaptorTransfer; +import java.util.EnumSet; +import org.opentripplanner.routing.algorithm.raptoradapter.transit.DefaultRaptorTransfer; +import org.opentripplanner.routing.algorithm.raptoradapter.transit.Transfer; +import org.opentripplanner.routing.api.request.StreetMode; /** - * Simple implementation for {@link RaptorTransfer} for use in unit-tests. - * - * @deprecated This was earlier part of Raptor and should not be used outside the Raptor - * module. Use the OTP model entities instead. + * Simple factory to create {@link DefaultRaptorTransfer}s for unit-testing. + *

+ * Note! The created transfer does NOT have a AStar path (list of edges). */ -@Deprecated -public record TestTransfer(int stop, int durationInSeconds, int cost) implements RaptorTransfer { +public final class TestTransfer { + public static final double DEFAULT_WALK_RELUCTANCE = 2.0; - public static TestTransfer transfer(int stop, int durationInSeconds) { - return new TestTransfer(stop, durationInSeconds, walkCost(durationInSeconds)); + /** This is a utility class, should not be instansiated */ + private TestTransfer() {} + + public static DefaultRaptorTransfer transfer(int stop, int durationInSeconds, int cost) { + var tx = new Transfer( + stop, + (int) Math.round(durationInSeconds * 1.3), + EnumSet.of(StreetMode.WALK) + ); + return new DefaultRaptorTransfer(stop, durationInSeconds, cost, tx); + } + + public static DefaultRaptorTransfer transfer(int stop, int durationInSeconds) { + return transfer(stop, durationInSeconds, walkCost(durationInSeconds)); } public static int walkCost(int durationInSeconds) { @@ -25,24 +39,4 @@ public static int walkCost(int durationInSeconds) { public static int walkCost(int durationInSeconds, double reluctance) { return toRaptorCost(durationInSeconds * reluctance); } - - @Override - public int stop() { - return stop; - } - - @Override - public int c1() { - return cost; - } - - @Override - public int durationInSeconds() { - return durationInSeconds; - } - - @Override - public String toString() { - return asString(); - } } diff --git a/application/src/test/java/org/opentripplanner/raptorlegacy/_data/transit/TestTransitData.java b/application/src/test/java/org/opentripplanner/raptorlegacy/_data/transit/TestTransitData.java index 63d17c8cd2d..fdce4559b24 100644 --- a/application/src/test/java/org/opentripplanner/raptorlegacy/_data/transit/TestTransitData.java +++ b/application/src/test/java/org/opentripplanner/raptorlegacy/_data/transit/TestTransitData.java @@ -215,10 +215,12 @@ public TestTransitData withRoutes(TestRoute... routes) { return this; } - public TestTransitData withTransfer(int fromStop, TestTransfer transfer) { + public TestTransitData withTransfer(int fromStop, DefaultRaptorTransfer transfer) { expandNumOfStops(Math.max(fromStop, transfer.stop())); transfersFromStop.get(fromStop).add(transfer); - transfersToStop.get(transfer.stop()).add(DefaultRaptorTransfer.reverseOf(fromStop, transfer)); + transfersToStop + .get(transfer.stop()) + .add(((DefaultRaptorTransfer) transfer).reverseOf(fromStop)); return this; } diff --git a/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/services/TransferGeneratorTest.java b/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/services/TransferGeneratorTest.java index 640d7e53a64..a180a3d0756 100644 --- a/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/services/TransferGeneratorTest.java +++ b/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/services/TransferGeneratorTest.java @@ -140,7 +140,7 @@ void findGuaranteedTransferWithNoSlack() { "[[" + "TripToTripTransfer{from: [2 10:20 BUS L1], to: [2 10:20 BUS L2]}" + "], [" + - "TripToTripTransfer{from: [3 10:30 BUS L2], to: [4 10:31 BUS L3], transfer: On-Street 1m ~ 4}" + + "TripToTripTransfer{from: [3 10:30 BUS L2], to: [4 10:31 BUS L3], transfer: WALK 1m $120 ~ 4}" + "]]", result.toString() ); @@ -167,9 +167,9 @@ void findTransferForDifferentRoutes() { var result = subject.findAllPossibleTransfers(transitLegs); assertEquals( "[[" + - "TripToTripTransfer{from: [2 10:10 BUS L1], to: [5 10:12 BUS L2], transfer: On-Street 1m ~ 5}, " + + "TripToTripTransfer{from: [2 10:10 BUS L1], to: [5 10:12 BUS L2], transfer: WALK 1m $120 ~ 5}, " + "TripToTripTransfer{from: [3 10:20 BUS L1], to: [3 10:22 BUS L2]}, " + - "TripToTripTransfer{from: [4 10:30 BUS L1], to: [6 10:32 BUS L2], transfer: On-Street 20s ~ 6}" + + "TripToTripTransfer{from: [4 10:30 BUS L1], to: [6 10:32 BUS L2], transfer: WALK 20s $40 ~ 6}" + "]]", result.toString() ); @@ -226,8 +226,8 @@ void findTransfersForCircularLine2() { assertEquals( "[[" + - "TripToTripTransfer{from: [4 10:20 BUS L1], to: [5 10:30 BUS L2], transfer: On-Street 1m ~ 5}, " + - "TripToTripTransfer{from: [4 10:20 BUS L1], to: [5 10:50 BUS L2], transfer: On-Street 1m ~ 5}" + + "TripToTripTransfer{from: [4 10:20 BUS L1], to: [5 10:30 BUS L2], transfer: WALK 1m $120 ~ 5}, " + + "TripToTripTransfer{from: [4 10:20 BUS L1], to: [5 10:50 BUS L2], transfer: WALK 1m $120 ~ 5}" + "]]", result.toString() ); @@ -315,7 +315,7 @@ void findTransfersForCircularLine5() { // Only transfer on second visit // since first one is constrained assertEquals( - "[[TripToTripTransfer{from: [4 10:20 BUS L1], to: [5 10:50 BUS L2], transfer: On-Street 1m ~ 5}]]", + "[[TripToTripTransfer{from: [4 10:20 BUS L1], to: [5 10:50 BUS L2], transfer: WALK 1m $120 ~ 5}]]", result.toString() ); } @@ -397,7 +397,7 @@ void findTransferWithAlightingForbiddenAtSameStop() { // Transfer at B is not allowed assertEquals( "[[" + - "TripToTripTransfer{from: [3 10:20 BUS L1], to: [4 10:30 BUS L2], transfer: On-Street 1m ~ 4}" + + "TripToTripTransfer{from: [3 10:20 BUS L1], to: [4 10:30 BUS L2], transfer: WALK 1m $120 ~ 4}" + "]]", result.toString() ); @@ -430,7 +430,7 @@ void findTransferWithBoardingForbiddenAtSameStop() { // Transfer at B is not allowed assertEquals( "[[" + - "TripToTripTransfer{from: [3 10:20 BUS L1], to: [4 10:30 BUS L2], transfer: On-Street 1m ~ 4}" + + "TripToTripTransfer{from: [3 10:20 BUS L1], to: [4 10:30 BUS L2], transfer: WALK 1m $120 ~ 4}" + "]]", result.toString() ); @@ -585,9 +585,9 @@ void findDependedTransfersForThreeRoutes() { assertEquals( "[[" + "TripToTripTransfer{from: [2 10:10 BUS L1], to: [2 10:12 BUS L2]}, " + - "TripToTripTransfer{from: [3 10:20 BUS L1], to: [4 10:22 BUS L2], transfer: On-Street 30s ~ 4}" + + "TripToTripTransfer{from: [3 10:20 BUS L1], to: [4 10:22 BUS L2], transfer: WALK 30s $60 ~ 4}" + "], [" + - "TripToTripTransfer{from: [4 10:22 BUS L2], to: [6 10:24 BUS L3], transfer: On-Street 20s ~ 6}, " + + "TripToTripTransfer{from: [4 10:22 BUS L2], to: [6 10:24 BUS L3], transfer: WALK 20s $40 ~ 6}, " + "TripToTripTransfer{from: [5 10:32 BUS L2], to: [5 10:34 BUS L3]}" + "]]", result.toString() @@ -598,7 +598,7 @@ private void testThatThereIsNoTransferAtStopB(TransferConstraint transfer) { // given 3 possible expected transfers var expBxB = "TripToTripTransfer{from: [2 10:10 BUS L1], to: [2 10:20 BUS L2]}"; var expCxD = - "TripToTripTransfer{from: [3 10:20 BUS L1], to: [4 10:30 BUS L2], transfer: On-Street 1m ~ 4}"; + "TripToTripTransfer{from: [3 10:20 BUS L1], to: [4 10:30 BUS L2], transfer: WALK 1m $120 ~ 4}"; var expExE = "TripToTripTransfer{from: [5 10:30 BUS L1], to: [5 10:40 BUS L2]}"; var l1 = route("L1", STOP_A, STOP_B, STOP_C, STOP_E) From f5212c3783053fee9b4ec8d0e3ce99a5107b6d79 Mon Sep 17 00:00:00 2001 From: Thomas Gran Date: Mon, 17 Feb 2025 13:24:24 +0100 Subject: [PATCH 10/69] refactor: Rename factory TestTransfer to TestTransfers --- .../_data/api/TestPathBuilder.java | 4 +-- .../{TestTransfer.java => TestTransfers.java} | 4 +-- .../BasicPathTestCase.java | 8 +++--- .../services/TestTransferBuilder.java | 4 +-- .../services/TransferGeneratorTest.java | 26 +++++++++---------- 5 files changed, 23 insertions(+), 23 deletions(-) rename application/src/test/java/org/opentripplanner/raptorlegacy/_data/transit/{TestTransfer.java => TestTransfers.java} (95%) diff --git a/application/src/test/java/org/opentripplanner/raptorlegacy/_data/api/TestPathBuilder.java b/application/src/test/java/org/opentripplanner/raptorlegacy/_data/api/TestPathBuilder.java index 699f9091ce4..9259358f2d2 100644 --- a/application/src/test/java/org/opentripplanner/raptorlegacy/_data/api/TestPathBuilder.java +++ b/application/src/test/java/org/opentripplanner/raptorlegacy/_data/api/TestPathBuilder.java @@ -13,7 +13,7 @@ import org.opentripplanner.raptor.spi.RaptorSlackProvider; import org.opentripplanner.raptorlegacy._data.RaptorTestConstants; import org.opentripplanner.raptorlegacy._data.transit.TestAccessEgress; -import org.opentripplanner.raptorlegacy._data.transit.TestTransfer; +import org.opentripplanner.raptorlegacy._data.transit.TestTransfers; import org.opentripplanner.raptorlegacy._data.transit.TestTripPattern; import org.opentripplanner.raptorlegacy._data.transit.TestTripSchedule; import org.opentripplanner.routing.algorithm.raptoradapter.transit.DefaultRaptorTransfer; @@ -85,7 +85,7 @@ private TestPathBuilder access(int startTime, RaptorAccessEgress transfer) { } public TestPathBuilder walk(int duration, int toStop) { - return walk(TestTransfer.transfer(toStop, duration)); + return walk(TestTransfers.transfer(toStop, duration)); } public TestPathBuilder walk(DefaultRaptorTransfer transfer) { diff --git a/application/src/test/java/org/opentripplanner/raptorlegacy/_data/transit/TestTransfer.java b/application/src/test/java/org/opentripplanner/raptorlegacy/_data/transit/TestTransfers.java similarity index 95% rename from application/src/test/java/org/opentripplanner/raptorlegacy/_data/transit/TestTransfer.java rename to application/src/test/java/org/opentripplanner/raptorlegacy/_data/transit/TestTransfers.java index c06bf145b30..37ca0ffba29 100644 --- a/application/src/test/java/org/opentripplanner/raptorlegacy/_data/transit/TestTransfer.java +++ b/application/src/test/java/org/opentripplanner/raptorlegacy/_data/transit/TestTransfers.java @@ -12,12 +12,12 @@ *

* Note! The created transfer does NOT have a AStar path (list of edges). */ -public final class TestTransfer { +public final class TestTransfers { public static final double DEFAULT_WALK_RELUCTANCE = 2.0; /** This is a utility class, should not be instansiated */ - private TestTransfer() {} + private TestTransfers() {} public static DefaultRaptorTransfer transfer(int stop, int durationInSeconds, int cost) { var tx = new Transfer( diff --git a/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/BasicPathTestCase.java b/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/BasicPathTestCase.java index 02bf8c522c2..574e05c9c5e 100644 --- a/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/BasicPathTestCase.java +++ b/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/BasicPathTestCase.java @@ -16,7 +16,7 @@ import org.opentripplanner.raptor.spi.RaptorCostCalculator; import org.opentripplanner.raptorlegacy._data.RaptorTestConstants; import org.opentripplanner.raptorlegacy._data.transit.TestAccessEgress; -import org.opentripplanner.raptorlegacy._data.transit.TestTransfer; +import org.opentripplanner.raptorlegacy._data.transit.TestTransfers; import org.opentripplanner.raptorlegacy._data.transit.TestTripPattern; import org.opentripplanner.raptorlegacy._data.transit.TestTripSchedule; import org.opentripplanner.routing.algorithm.raptoradapter.transit.cost.DefaultCostCalculator; @@ -115,7 +115,7 @@ public class BasicPathTestCase implements RaptorTestConstants { private static final int TX_START = time("10:35:15"); private static final int TX_END = time("10:39:00"); public static final int TX_DURATION = TX_END - TX_START; - public static final RaptorTransfer TX_TRANSFER = TestTransfer.transfer(STOP_C, TX_DURATION); + public static final RaptorTransfer TX_TRANSFER = TestTransfers.transfer(STOP_C, TX_DURATION); public static final int TX_C1 = TX_TRANSFER.c1(); // Trip 2 (C ~ BUS L21 11:00 11:23 ~ D) @@ -231,7 +231,7 @@ public static RaptorPath basicTripAsPath() { LINE_21_C1, leg5 ); - var transfer = TestTransfer.transfer(STOP_C, TX_END - TX_START); + var transfer = TestTransfers.transfer(STOP_C, TX_END - TX_START); PathLeg leg3 = new TransferPathLeg<>( STOP_B, TX_START, @@ -262,7 +262,7 @@ public static RaptorPath basicTripAsPath() { public static RaptorPath flexTripAsPath() { PathLeg leg6 = new EgressPathLeg<>(FLEX, EGRESS_START, EGRESS_END, EGRESS_C1); - var transfer = TestTransfer.transfer(STOP_E, TX_END - TX_START); + var transfer = TestTransfers.transfer(STOP_E, TX_END - TX_START); PathLeg leg3 = new TransferPathLeg<>( STOP_B, TX_START, diff --git a/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/services/TestTransferBuilder.java b/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/services/TestTransferBuilder.java index f32b5366907..71257dd974c 100644 --- a/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/services/TestTransferBuilder.java +++ b/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/services/TestTransferBuilder.java @@ -7,7 +7,7 @@ import org.opentripplanner.model.transfer.TripTransferPoint; import org.opentripplanner.raptor.api.model.RaptorConstants; import org.opentripplanner.raptor.api.model.RaptorTripSchedule; -import org.opentripplanner.raptorlegacy._data.transit.TestTransfer; +import org.opentripplanner.raptorlegacy._data.transit.TestTransfers; import org.opentripplanner.routing.algorithm.transferoptimization.model.TripStopTime; import org.opentripplanner.routing.algorithm.transferoptimization.model.TripToTripTransfer; import org.opentripplanner.transit.model._data.TimetableRepositoryForTest; @@ -142,7 +142,7 @@ public TripToTripTransfer build() { var pathTransfer = fromStopIndex == toStopIndex ? null - : TestTransfer.transfer(toStopIndex, walkDurationSec); + : TestTransfers.transfer(toStopIndex, walkDurationSec); return new TripToTripTransfer<>( departure(fromTrip, fromStopIndex), diff --git a/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/services/TransferGeneratorTest.java b/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/services/TransferGeneratorTest.java index a180a3d0756..97efb583483 100644 --- a/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/services/TransferGeneratorTest.java +++ b/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/services/TransferGeneratorTest.java @@ -23,7 +23,7 @@ import org.opentripplanner.raptorlegacy._data.RaptorTestConstants; import org.opentripplanner.raptorlegacy._data.api.TestPathBuilder; import org.opentripplanner.raptorlegacy._data.transit.TestRoute; -import org.opentripplanner.raptorlegacy._data.transit.TestTransfer; +import org.opentripplanner.raptorlegacy._data.transit.TestTransfers; import org.opentripplanner.raptorlegacy._data.transit.TestTransitData; import org.opentripplanner.raptorlegacy._data.transit.TestTripPattern; import org.opentripplanner.raptorlegacy._data.transit.TestTripSchedule; @@ -118,7 +118,7 @@ void findGuaranteedTransferWithNoSlack() { var schedule3 = data.getRoute(2).getTripSchedule(0); data - .withTransfer(STOP_C, TestTransfer.transfer(STOP_D, D1m)) + .withTransfer(STOP_C, TestTransfers.transfer(STOP_D, D1m)) .withGuaranteedTransfer(schedule1, STOP_B, schedule2, STOP_B) .withGuaranteedTransfer(schedule2, STOP_C, schedule3, STOP_D); @@ -156,8 +156,8 @@ void findTransferForDifferentRoutes() { // S data .withRoutes(l1, l2) - .withTransfer(STOP_B, TestTransfer.transfer(STOP_E, D1m)) - .withTransfer(STOP_D, TestTransfer.transfer(STOP_F, D20s)); + .withTransfer(STOP_B, TestTransfers.transfer(STOP_E, D1m)) + .withTransfer(STOP_D, TestTransfers.transfer(STOP_F, D20s)); // The only possible place to transfer between A and D is stop C (no extra transfers): var transitLegs = transitLegsTwoRoutes(STOP_A, STOP_C, STOP_G); @@ -206,7 +206,7 @@ void findTransfersForCircularLine2() { var l2 = route("L2", STOP_E, STOP_F, STOP_E, STOP_G) .withTimetable(schedule("10:30 10:40 10:50 11:00")); - data.withRoutes(l1, l2).withTransfer(STOP_D, TestTransfer.transfer(STOP_E, D1m)); + data.withRoutes(l1, l2).withTransfer(STOP_D, TestTransfers.transfer(STOP_E, D1m)); var schedule1 = data.getRoute(0).getTripSchedule(0); var schedule2 = data.getRoute(1).getTripSchedule(0); @@ -290,7 +290,7 @@ void findTransfersForCircularLine5() { var l2 = route("L2", STOP_E, STOP_F, STOP_E, STOP_G) .withTimetable(schedule("10:30 10:40 10:50 11:00")); - data.withRoutes(l1, l2).withTransfer(STOP_D, TestTransfer.transfer(STOP_E, D1m)); + data.withRoutes(l1, l2).withTransfer(STOP_D, TestTransfers.transfer(STOP_E, D1m)); var schedule1 = data.getRoute(0).getTripSchedule(0); var schedule2 = data.getRoute(1).getTripSchedule(0); @@ -379,7 +379,7 @@ void findTransferWithAlightingForbiddenAtSameStop() { TestRoute l1 = route(p1).withTimetable(schedule("10:00 10:10 10:20")); TestRoute l2 = route("L2", STOP_B, STOP_D, STOP_E).withTimetable(schedule("10:20 10:30 10:40")); - data.withRoutes(l1, l2).withTransfer(STOP_C, TestTransfer.transfer(STOP_D, D1m)); + data.withRoutes(l1, l2).withTransfer(STOP_C, TestTransfers.transfer(STOP_D, D1m)); final RaptorPath path = pathBuilder .access(ACCESS_START, STOP_A, ACCESS_DURATION) @@ -412,7 +412,7 @@ void findTransferWithBoardingForbiddenAtSameStop() { TestRoute l2 = route(p2).withTimetable(schedule("10:20 10:30 10:40")); - data.withRoutes(l1, l2).withTransfer(STOP_C, TestTransfer.transfer(STOP_D, D1m)); + data.withRoutes(l1, l2).withTransfer(STOP_C, TestTransfers.transfer(STOP_D, D1m)); final RaptorPath path = pathBuilder .access(ACCESS_START, STOP_A, ACCESS_DURATION) @@ -444,7 +444,7 @@ void findTransferWithAlightingForbiddenAtDifferentStop() { TestRoute l1 = route(p1).withTimetable(schedule("10:00 10:10 10:20")); TestRoute l2 = route("L2", STOP_B, STOP_D, STOP_E).withTimetable(schedule("10:20 10:30 10:40")); - data.withRoutes(l1, l2).withTransfer(STOP_C, TestTransfer.transfer(STOP_D, D1m)); + data.withRoutes(l1, l2).withTransfer(STOP_C, TestTransfers.transfer(STOP_D, D1m)); var transitLegs = transitLegsTwoRoutes(STOP_A, STOP_B, STOP_E); @@ -468,7 +468,7 @@ void findTransferWithBoardingForbiddenAtDifferentStop() { TestRoute l2 = route(p2).withTimetable(schedule("10:20 10:30 10:40")); - data.withRoutes(l1, l2).withTransfer(STOP_C, TestTransfer.transfer(STOP_D, D1m)); + data.withRoutes(l1, l2).withTransfer(STOP_C, TestTransfers.transfer(STOP_D, D1m)); var transitLegs = transitLegsTwoRoutes(STOP_A, STOP_B, STOP_E); @@ -564,8 +564,8 @@ void findDependedTransfersForThreeRoutes() { data .withRoutes(l1, l2, l3) - .withTransfer(STOP_C, TestTransfer.transfer(STOP_D, D30s)) - .withTransfer(STOP_D, TestTransfer.transfer(STOP_F, D20s)); + .withTransfer(STOP_C, TestTransfers.transfer(STOP_D, D30s)) + .withTransfer(STOP_D, TestTransfers.transfer(STOP_F, D20s)); // The only possible place to transfer between A and D is stop C (no extra transfers): var path = pathBuilder @@ -607,7 +607,7 @@ private void testThatThereIsNoTransferAtStopB(TransferConstraint transfer) { var l2 = route("L2", STOP_B, STOP_D, STOP_E, STOP_F) .withTimetable(schedule("10:20 10:30 10:40 10:50")); - data.withRoutes(l1, l2).withTransfer(STOP_C, TestTransfer.transfer(STOP_D, D1m)); + data.withRoutes(l1, l2).withTransfer(STOP_C, TestTransfers.transfer(STOP_D, D1m)); final RaptorPath path = pathBuilder .access(ACCESS_START, STOP_A, ACCESS_DURATION) From 63002f587181ab020446f02e7b4a3fa6263e1a0c Mon Sep 17 00:00:00 2001 From: Thomas Gran Date: Fri, 31 Jan 2025 11:08:44 +0100 Subject: [PATCH 11/69] refactor: Make sure walkSteps is an empty list not null in StreetLeg --- .../main/java/org/opentripplanner/model/plan/StreetLeg.java | 2 +- .../org/opentripplanner/model/plan/StreetLegBuilder.java | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/application/src/main/java/org/opentripplanner/model/plan/StreetLeg.java b/application/src/main/java/org/opentripplanner/model/plan/StreetLeg.java index 2e3e58a275c..ef16c3bd76d 100644 --- a/application/src/main/java/org/opentripplanner/model/plan/StreetLeg.java +++ b/application/src/main/java/org/opentripplanner/model/plan/StreetLeg.java @@ -47,7 +47,7 @@ public StreetLeg(StreetLegBuilder builder) { this.generalizedCost = builder.getGeneralizedCost(); this.elevationProfile = builder.getElevationProfile(); this.legGeometry = builder.getGeometry(); - this.walkSteps = builder.getWalkSteps(); + this.walkSteps = Objects.requireNonNull(builder.getWalkSteps()); this.streetNotes = Set.copyOf(builder.getStreetNotes()); this.walkingBike = builder.getWalkingBike(); this.rentedVehicle = builder.getRentedVehicle(); diff --git a/application/src/main/java/org/opentripplanner/model/plan/StreetLegBuilder.java b/application/src/main/java/org/opentripplanner/model/plan/StreetLegBuilder.java index 5762c0c0b7f..6b139735f0c 100644 --- a/application/src/main/java/org/opentripplanner/model/plan/StreetLegBuilder.java +++ b/application/src/main/java/org/opentripplanner/model/plan/StreetLegBuilder.java @@ -3,6 +3,7 @@ import java.time.ZonedDateTime; import java.util.HashSet; import java.util.List; +import java.util.Objects; import java.util.Set; import org.locationtech.jts.geom.LineString; import org.opentripplanner.street.model.note.StreetNote; @@ -19,7 +20,7 @@ public class StreetLegBuilder { private int generalizedCost; private LineString geometry; private ElevationProfile elevationProfile; - private List walkSteps; + private List walkSteps = List.of(); private Boolean walkingBike; private Boolean rentedVehicle; private String vehicleRentalNetwork; @@ -157,7 +158,7 @@ public StreetLegBuilder withElevationProfile(ElevationProfile elevationProfile) } public StreetLegBuilder withWalkSteps(List walkSteps) { - this.walkSteps = walkSteps; + this.walkSteps = Objects.requireNonNull(walkSteps); return this; } From d119f95c3f7fa6d6568af42649cb995059880827 Mon Sep 17 00:00:00 2001 From: Thomas Gran Date: Fri, 14 Feb 2025 19:09:19 +0100 Subject: [PATCH 12/69] refactor: improve method name in PathBuilderLeg --- .../org/opentripplanner/raptor/path/PathBuilderLeg.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/raptor/src/main/java/org/opentripplanner/raptor/path/PathBuilderLeg.java b/raptor/src/main/java/org/opentripplanner/raptor/path/PathBuilderLeg.java index eb80b36316b..dbc2e25a371 100644 --- a/raptor/src/main/java/org/opentripplanner/raptor/path/PathBuilderLeg.java +++ b/raptor/src/main/java/org/opentripplanner/raptor/path/PathBuilderLeg.java @@ -201,7 +201,7 @@ public void timeShiftThisAndNextLeg( } if (next != null) { if (next.isTransfer()) { - next.timeShiftTransferTime(slackProvider); + next.setTransferTimeBasedOnPreviousLeg(slackProvider); if (next.next().isEgress()) { next.timeShiftThisAndNextLeg(slackProvider, iterationDepartureTime); } @@ -527,13 +527,16 @@ private void timeShiftAccessTime(RaptorSlackProvider slackProvider, int iteratio } } - private void timeShiftTransferTime(RaptorSlackProvider slackProvider) { + private void setTransferTimeBasedOnPreviousLeg(RaptorSlackProvider slackProvider) { int newFromTime; if (prev.isTransit()) { newFromTime = prev.toTime() + slackProvider.alightSlack(prev.asTransitLeg().trip.pattern().slackIndex()); } else if (prev.isAccess()) { newFromTime = prev.toTime(); + // } else if (prev.isTransfer()) { + // via search and transfer connection + // newFromTime = prev.toTime + slackProvider.transferSlack(); } else { throw new IllegalStateException("Unexpected leg type before TransferLeg: " + this); } From a1aca7a090145e39aac8c9c3bacfd4eda94ff7a0 Mon Sep 17 00:00:00 2001 From: Thomas Gran Date: Fri, 31 Jan 2025 11:12:34 +0100 Subject: [PATCH 13/69] feature: Handle ViaCoordinateTransfer in ItineraryMapping --- .../mapping/RaptorPathToItineraryMapper.java | 83 +++++++++++++------ 1 file changed, 57 insertions(+), 26 deletions(-) diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/mapping/RaptorPathToItineraryMapper.java b/application/src/main/java/org/opentripplanner/routing/algorithm/mapping/RaptorPathToItineraryMapper.java index 5e2fd9ff994..75b9469514b 100644 --- a/application/src/main/java/org/opentripplanner/routing/algorithm/mapping/RaptorPathToItineraryMapper.java +++ b/application/src/main/java/org/opentripplanner/routing/algorithm/mapping/RaptorPathToItineraryMapper.java @@ -2,6 +2,7 @@ import static org.opentripplanner.raptor.api.model.RaptorCostConverter.toOtpDomainCost; +import java.time.Duration; import java.time.ZonedDateTime; import java.util.ArrayList; import java.util.List; @@ -37,6 +38,7 @@ import org.opentripplanner.routing.api.request.RouteRequest; import org.opentripplanner.routing.api.request.StreetMode; import org.opentripplanner.routing.graph.Graph; +import org.opentripplanner.routing.via.model.ViaCoordinateTransfer; import org.opentripplanner.street.model.edge.Edge; import org.opentripplanner.street.search.TraverseMode; import org.opentripplanner.street.search.request.StreetSearchRequest; @@ -46,6 +48,7 @@ import org.opentripplanner.transit.model.timetable.TripIdAndServiceDate; import org.opentripplanner.transit.model.timetable.TripOnServiceDate; import org.opentripplanner.transit.service.TransitService; +import org.opentripplanner.utils.collection.ListUtils; /** * This maps the paths found by the Raptor search algorithm to the itinerary structure currently @@ -315,11 +318,19 @@ private Leg createTransferLegAtSameStop(PathLeg previousLeg, PathLeg nextL private List mapTransferLeg(TransferPathLeg pathLeg, TraverseMode transferMode) { var transferFromStop = raptorTransitData.getStopByIndex(pathLeg.fromStop()); var transferToStop = raptorTransitData.getStopByIndex(pathLeg.toStop()); - Transfer transfer = ((DefaultRaptorTransfer) pathLeg.transfer()).transfer(); + + var raptorTransfer = pathLeg.transfer(); Place from = Place.forStop(transferFromStop); Place to = Place.forStop(transferToStop); - return mapNonTransitLeg(pathLeg, transfer, transferMode, from, to); + + if (raptorTransfer instanceof DefaultRaptorTransfer dftTx) { + return mapTransferLeg(pathLeg, dftTx.transfer(), transferMode, from, to); + } + if (raptorTransfer instanceof ViaCoordinateTransfer viaTx) { + return mapViaCoordinateTransferLeg(pathLeg, viaTx, transferMode, from, to); + } + throw new ClassCastException("Unknown transfer type: " + raptorTransfer.getClass()); } private Itinerary mapEgressLeg(EgressPathLeg egressPathLeg) { @@ -337,7 +348,7 @@ private Itinerary mapEgressLeg(EgressPathLeg egressPathLeg) { return subItinerary.withTimeShiftToStartAt(createZonedDateTime(egressPathLeg.fromTime())); } - private List mapNonTransitLeg( + private List mapTransferLeg( PathLeg pathLeg, Transfer transfer, TraverseMode transferMode, @@ -361,33 +372,53 @@ private List mapNonTransitLeg( .build() ); } else { - StateEditor se = new StateEditor(edges.get(0).getFromVertex(), transferStreetRequest); - se.setTimeSeconds(createZonedDateTime(pathLeg.fromTime()).toEpochSecond()); - - State s = se.makeState(); - ArrayList transferStates = new ArrayList<>(); - transferStates.add(s); - for (Edge e : edges) { - var states = e.traverse(s); - if (State.isEmpty(states)) { - s = null; - } else { - transferStates.add(states[0]); - s = states[0]; - } - } + return mapTransferLegWithEdges(pathLeg.fromTime(), edges); + } + } - State[] states = transferStates.toArray(new State[0]); - var graphPath = new GraphPath<>(states[states.length - 1]); + private List mapViaCoordinateTransferLeg( + PathLeg pathLeg, + ViaCoordinateTransfer transfer, + TraverseMode transferMode, + Place from, + Place to + ) { + var fromLegs = mapTransferLegWithEdges(pathLeg.fromTime(), transfer.fromEdges()); + var toLegs = mapTransferLegWithEdges(pathLeg.toTime(), transfer.toEdges()); - Itinerary subItinerary = graphPathToItineraryMapper.generateItinerary(graphPath); + if (fromLegs.isEmpty() || toLegs.isEmpty()) { + throw new IllegalStateException( + "There need to be at least one edges to get from a stop to the via coordinate and back" + ); + } + // We need to timeshift the toLegs + long toDuration = toLegs.stream().mapToLong(l -> l.getDuration().toSeconds()).sum(); - if (subItinerary.getLegs().isEmpty()) { - return List.of(); - } + toLegs = toLegs.stream().map(l -> l.withTimeShift(Duration.ofSeconds(-toDuration))).toList(); + + return ListUtils.combine(fromLegs, toLegs); + } - return subItinerary.getLegs(); + private List mapTransferLegWithEdges(int fromTime, List edges) { + StateEditor se = new StateEditor(edges.getFirst().getFromVertex(), transferStreetRequest); + se.setTimeSeconds(createZonedDateTime(fromTime).toEpochSecond()); + + State s = se.makeState(); + ArrayList transferStates = new ArrayList<>(); + transferStates.add(s); + for (Edge e : edges) { + var states = e.traverse(s); + if (State.isEmpty(states)) { + s = null; + } else { + transferStates.add(states[0]); + s = states[0]; + } } + State[] states = transferStates.toArray(State[]::new); + var graphPath = new GraphPath<>(states[states.length - 1]); + var subItinerary = graphPathToItineraryMapper.generateItinerary(graphPath); + return subItinerary.getLegs(); } private Itinerary mapDirectPath(RaptorPath path) { @@ -417,7 +448,7 @@ private ZonedDateTime createZonedDateTime(int timeInSeconds) { * walk or bicycle. Do NOT include it if it represents a stay-seated transfer. See more details in * https://github.com/opentripplanner/OpenTripPlanner/issues/5086. * TODO: the logic should be revisited when adding support for transfer between on-board flex - * access and transit. + * access and transit. */ private boolean includeTransferInItinerary(Leg transitLegBeforeTransfer) { return ( From e7bd110b7717338400131c3dd8cadbd61b0f1251 Mon Sep 17 00:00:00 2001 From: Thomas Gran Date: Mon, 17 Feb 2025 14:24:31 +0100 Subject: [PATCH 14/69] refactor: Rename Raptor module test for via stop search --- ...ViaSearchTest.java => J02_ViaStopSearchTest.java} | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) rename raptor/src/test/java/org/opentripplanner/raptor/moduletests/{J02_ViaSearchTest.java => J02_ViaStopSearchTest.java} (97%) diff --git a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/J02_ViaSearchTest.java b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/J02_ViaStopSearchTest.java similarity index 97% rename from raptor/src/test/java/org/opentripplanner/raptor/moduletests/J02_ViaSearchTest.java rename to raptor/src/test/java/org/opentripplanner/raptor/moduletests/J02_ViaStopSearchTest.java index fd872a3d138..853fb713f8e 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/J02_ViaSearchTest.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/J02_ViaStopSearchTest.java @@ -36,19 +36,19 @@ /** * FEATURE UNDER TEST * - * Raptor should be able to handle route request with one or more via locations. - * If a stop is specified as via location in the request, then all the results returned - * from raptor should include the stop. The stop should be a alight, board or intermediate + * Raptor should be able to handle route request with one or more via locations transfering at a + * given set of stops. If a stop is specified as via location in the request, then all the results + * returned from raptor should include the stop. The stop should be a alight, board or intermediate * stop of one of the trips in the path. * - * It should be possible to specify more than one connection. The result should include the - * via locations in the order as they were specified in the request. Only alternatives that pass + * It should be possible to specify more than one connection. The result should include the via + * locations in the order as they were specified in the request. Only alternatives that pass * through all via locations should be included in the result. * * To support stations and other collections of stops, Raptor should also support multiple via * connections in one via location. */ -class J02_ViaSearchTest { +class J02_ViaStopSearchTest { static final List VIA_LOCATION_STOP_B = List.of(viaLocation("B", STOP_B)); static final List VIA_LOCATION_STOP_C = List.of(viaLocation("C", STOP_C)); From cc8c0b8c3dfb4f6690da412198787008cd82f1fe Mon Sep 17 00:00:00 2001 From: Thomas Gran Date: Mon, 17 Feb 2025 17:18:07 +0100 Subject: [PATCH 15/69] refactor: Use lamda in array creating in LifeCycleEventPublisher --- .../lifecycle/LifeCycleEventPublisher.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/lifecycle/LifeCycleEventPublisher.java b/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/lifecycle/LifeCycleEventPublisher.java index 4275b107309..4c5c77a5288 100644 --- a/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/lifecycle/LifeCycleEventPublisher.java +++ b/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/lifecycle/LifeCycleEventPublisher.java @@ -19,18 +19,18 @@ public class LifeCycleEventPublisher { @SuppressWarnings("unchecked") public LifeCycleEventPublisher(LifeCycleSubscriptions subscriptions) { - this.onRouteSearchListeners = subscriptions.onRouteSearchListeners.toArray(new Consumer[0]); + this.onRouteSearchListeners = subscriptions.onRouteSearchListeners.toArray(Consumer[]::new); this.setupIterationListeners = - subscriptions.setupIterationListeners.toArray(new IntConsumer[0]); + subscriptions.setupIterationListeners.toArray(IntConsumer[]::new); this.prepareForNextRoundListeners = - subscriptions.prepareForNextRoundListeners.toArray(new IntConsumer[0]); + subscriptions.prepareForNextRoundListeners.toArray(IntConsumer[]::new); this.transitsForRoundCompleteListeners = - subscriptions.transitsForRoundCompleteListeners.toArray(new Runnable[0]); + subscriptions.transitsForRoundCompleteListeners.toArray(Runnable[]::new); this.transfersForRoundCompleteListeners = - subscriptions.transfersForRoundCompleteListeners.toArray(new Runnable[0]); - this.roundCompleteListeners = subscriptions.roundCompleteListeners.toArray(new Consumer[0]); + subscriptions.transfersForRoundCompleteListeners.toArray(Runnable[]::new); + this.roundCompleteListeners = subscriptions.roundCompleteListeners.toArray(Consumer[]::new); this.iterationCompleteListeners = - subscriptions.iterationCompleteListeners.toArray(new Runnable[0]); + subscriptions.iterationCompleteListeners.toArray(Runnable[]::new); subscriptions.close(); } From a3926f99038802f9f28663c892e9b20f32775da4 Mon Sep 17 00:00:00 2001 From: Thomas Gran Date: Mon, 17 Feb 2025 17:20:41 +0100 Subject: [PATCH 16/69] refactor: Use inheritance for via connections in Raptor --- .../api/request/RaptorViaConnection.java | 116 ++++++++++++++---- .../raptor/api/request/RaptorViaLocation.java | 14 +-- .../multicriteria/McStopArrivals.java | 8 +- 3 files changed, 101 insertions(+), 37 deletions(-) diff --git a/raptor/src/main/java/org/opentripplanner/raptor/api/request/RaptorViaConnection.java b/raptor/src/main/java/org/opentripplanner/raptor/api/request/RaptorViaConnection.java index 489426af5e1..fd3c040d5bf 100644 --- a/raptor/src/main/java/org/opentripplanner/raptor/api/request/RaptorViaConnection.java +++ b/raptor/src/main/java/org/opentripplanner/raptor/api/request/RaptorViaConnection.java @@ -38,43 +38,44 @@ * {@code durationInSeconds}. The calculation of {@code c1} should include the walk time, but not * the min-wait-time (assuming all connections have the same minimum wait time). */ -public final class RaptorViaConnection { +public abstract sealed class RaptorViaConnection { private final int fromStop; private final int durationInSeconds; - @Nullable - private final RaptorTransfer transfer; - - RaptorViaConnection(RaptorViaLocation parent, int fromStop, @Nullable RaptorTransfer transfer) { + private RaptorViaConnection(RaptorViaLocation parent, int fromStop, int durationInSeconds) { this.fromStop = fromStop; - this.transfer = transfer; - this.durationInSeconds = - parent.minimumWaitTime() + - (transfer == null ? RaptorConstants.ZERO : transfer.durationInSeconds()); + this.durationInSeconds = parent.minimumWaitTime() + durationInSeconds; + } + + public static RaptorViaConnection of( + RaptorViaLocation parent, + int fromStop, + RaptorTransfer transfer + ) { + return transfer == null + ? new RaptorViaStopConnection(parent, fromStop) + : new RaptorViaTransferConnection(parent, fromStop, transfer); } /** * Stop index where the connection starts. */ - public int fromStop() { + public final int fromStop() { return fromStop; } @Nullable - public RaptorTransfer transfer() { - return transfer; - } + public abstract RaptorTransfer transfer(); /** * Stop index where the connection ends. This can be the same as the {@code fromStop}. */ - public int toStop() { - return isSameStop() ? fromStop : transfer.stop(); - } + public abstract int toStop(); /** - * The time duration to walk or travel from the {@code fromStop} to the {@code toStop}. + * The time duration to walk or travel from the {@code fromStop} to the {@code toStop} + * including wait-time at via point. */ public int durationInSeconds() { return durationInSeconds; @@ -86,13 +87,9 @@ public int durationInSeconds() { * This method is called many times, so care needs to be taken that the value is stored, not * calculated for each invocation. */ - public int c1() { - return isSameStop() ? RaptorConstants.ZERO : transfer.c1(); - } + public abstract int c1(); - public boolean isSameStop() { - return transfer == null; - } + public abstract boolean isSameStop(); /** * This method is used to check that all connections are unique/provide an optimal path. @@ -115,12 +112,16 @@ public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; RaptorViaConnection that = (RaptorViaConnection) o; - return fromStop == that.fromStop && Objects.equals(transfer, that.transfer); + return ( + fromStop == that.fromStop && + durationInSeconds == that.durationInSeconds && + toStop() == that.toStop() + ); } @Override public int hashCode() { - return Objects.hash(fromStop, transfer); + return Objects.hash(fromStop, toStop(), durationInSeconds(), c1()); } @Override @@ -130,7 +131,7 @@ public String toString() { public String toString(RaptorStopNameResolver stopNameResolver) { var buf = new StringBuilder(stopNameResolver.apply(fromStop)); - if (transfer != null) { + if (transfer() != null) { buf.append("~").append(stopNameResolver.apply(toStop())); } int d = durationInSeconds(); @@ -139,4 +140,67 @@ public String toString(RaptorStopNameResolver stopNameResolver) { } return buf.toString(); } + + private static final class RaptorViaStopConnection extends RaptorViaConnection { + + RaptorViaStopConnection(RaptorViaLocation parent, int fromStop) { + super(parent, fromStop, 0); + } + + @Nullable + @Override + public RaptorTransfer transfer() { + return null; + } + + @Override + public int toStop() { + return fromStop(); + } + + @Override + public int c1() { + return RaptorConstants.ZERO; + } + + @Override + public boolean isSameStop() { + return true; + } + } + + private static final class RaptorViaTransferConnection extends RaptorViaConnection { + + private final RaptorTransfer transfer; + + public RaptorViaTransferConnection( + RaptorViaLocation parent, + int fromStop, + RaptorTransfer transfer + ) { + super(parent, fromStop, transfer.durationInSeconds()); + this.transfer = transfer; + } + + @Nullable + @Override + public RaptorTransfer transfer() { + return transfer; + } + + @Override + public int toStop() { + return transfer.stop(); + } + + @Override + public int c1() { + return transfer.c1(); + } + + @Override + public boolean isSameStop() { + return false; + } + } } diff --git a/raptor/src/main/java/org/opentripplanner/raptor/api/request/RaptorViaLocation.java b/raptor/src/main/java/org/opentripplanner/raptor/api/request/RaptorViaLocation.java index fbaae6dabdc..a11433ba70b 100644 --- a/raptor/src/main/java/org/opentripplanner/raptor/api/request/RaptorViaLocation.java +++ b/raptor/src/main/java/org/opentripplanner/raptor/api/request/RaptorViaLocation.java @@ -31,7 +31,7 @@ private RaptorViaLocation( String label, boolean allowPassThrough, Duration minimumWaitTime, - List connections + List connections ) { this.label = label; this.allowPassThrough = allowPassThrough; @@ -130,13 +130,13 @@ public String toString(RaptorStopNameResolver stopNameResolver) { return buf.append("}").toString(); } - private List validateConnections(List connections) { + private List validateConnections(List connections) { if (connections.isEmpty()) { throw new IllegalArgumentException("At least one connection is required."); } var list = connections .stream() - .map(it -> new RaptorViaConnection(this, it.fromStop, it.transfer)) + .map(it -> RaptorViaConnection.of(this, it.fromStop, it.transfer)) .toList(); // Compare all pairs to check for duplicates and non-optimal connections @@ -159,7 +159,7 @@ public static final class Builder { private final String label; private final boolean allowPassThrough; private final Duration minimumWaitTime; - private final List connections = new ArrayList<>(); + private final List connections = new ArrayList<>(); public Builder(String label, boolean allowPassThrough, Duration minimumWaitTime) { this.label = label; @@ -168,12 +168,12 @@ public Builder(String label, boolean allowPassThrough, Duration minimumWaitTime) } public Builder addViaStop(int stop) { - this.connections.add(new StopAndTransfer(stop, null)); + this.connections.add(new BuilderStopAndTransfer(stop, null)); return this; } public Builder addViaTransfer(int fromStop, RaptorTransfer transfer) { - this.connections.add(new StopAndTransfer(fromStop, transfer)); + this.connections.add(new BuilderStopAndTransfer(fromStop, transfer)); return this; } @@ -187,5 +187,5 @@ public RaptorViaLocation build() { * needed to create the bidirectional relationship between {@link RaptorViaLocation} and * {@link RaptorViaConnection}. */ - private record StopAndTransfer(int fromStop, @Nullable RaptorTransfer transfer) {} + private static record BuilderStopAndTransfer(int fromStop, @Nullable RaptorTransfer transfer) {} } diff --git a/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/multicriteria/McStopArrivals.java b/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/multicriteria/McStopArrivals.java index f56e35d2f82..1fde9f288a5 100644 --- a/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/multicriteria/McStopArrivals.java +++ b/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/multicriteria/McStopArrivals.java @@ -40,7 +40,7 @@ public final class McStopArrivals { * Set the time at a transit index if it is optimal. This sets both the best time and the * transfer time. * - * @param nextLeg When chaining two Raptor searches together, the next-leg is the next + * @param nextLegArrivals When chaining two Raptor searches together, the next-leg is the next * search we are copying state into. */ public McStopArrivals( @@ -48,13 +48,13 @@ public McStopArrivals( @Nullable EgressPaths egressPaths, ViaConnections viaConnections, DestinationArrivalPaths paths, - McStopArrivals nextLeg, + McStopArrivals nextLegArrivals, McStopArrivalFactory stopArrivalFactory, ArrivalParetoSetComparatorFactory> comparatorFactory, DebugHandlerFactory debugHandlerFactory ) { // Assert only-one-of next or egressPaths is set - if (nextLeg == null) { + if (nextLegArrivals == null) { Objects.requireNonNull(egressPaths); } else if (egressPaths != null) { throw new IllegalArgumentException( @@ -69,7 +69,7 @@ public McStopArrivals( this.debugHandlerFactory = debugHandlerFactory; this.debugStats = new DebugStopArrivalsStatistics(debugHandlerFactory.debugLogger()); - initViaConnections(viaConnections, stopArrivalFactory, nextLeg); + initViaConnections(viaConnections, stopArrivalFactory, nextLegArrivals); initEgressStopAndGlueItToDestinationArrivals(egressPaths, paths); } From 9c7a8f55e196ddb17c7d02a296405fa61fedf682 Mon Sep 17 00:00:00 2001 From: Thomas Gran Date: Wed, 19 Feb 2025 16:36:03 +0100 Subject: [PATCH 17/69] refactor: Make stopNameResolver in RaptorTestConstants static so it can be use everywhere --- .../raptor/_data/RaptorTestConstants.java | 2 +- .../raptor/_data/api/PathUtils.java | 6 ++---- .../_data/api/TestPathBuilderTestRaptor.java | 9 ++++++--- .../_data/stoparrival/BasicPathTestCase.java | 7 +++++-- .../raptor/_data/transit/TestTransitData.java | 2 +- .../raptor/api/path/PathTest.java | 7 +++++-- .../raptor/rangeraptor/path/PathMapperTest.java | 17 ++++++++++------- 7 files changed, 30 insertions(+), 20 deletions(-) diff --git a/raptor/src/test/java/org/opentripplanner/raptor/_data/RaptorTestConstants.java b/raptor/src/test/java/org/opentripplanner/raptor/_data/RaptorTestConstants.java index 0b5e47c977a..a0299ffb3df 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/_data/RaptorTestConstants.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/_data/RaptorTestConstants.java @@ -81,7 +81,7 @@ public interface RaptorTestConstants { int ONE_RIDE = 1; int TWO_RIDES = 2; - default String stopIndexToName(int index) { + static String stopIndexToName(int index) { return Character.toString('A' + index - 1); } } diff --git a/raptor/src/test/java/org/opentripplanner/raptor/_data/api/PathUtils.java b/raptor/src/test/java/org/opentripplanner/raptor/_data/api/PathUtils.java index 9da872adbae..f9ffca92066 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/_data/api/PathUtils.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/_data/api/PathUtils.java @@ -15,8 +15,6 @@ */ public class PathUtils { - private static final RaptorTestConstants TRANSLATOR = new RaptorTestConstants() {}; - /** Util class, private constructor */ private PathUtils() {} @@ -25,7 +23,7 @@ public static String pathsToString(RaptorResponse response) { } public static String pathsToString(Collection> paths) { - return pathsToString(paths, p -> p.toString(TRANSLATOR::stopIndexToName)); + return pathsToString(paths, p -> p.toString(RaptorTestConstants::stopIndexToName)); } public static String pathsToStringDetailed(RaptorResponse response) { @@ -33,7 +31,7 @@ public static String pathsToStringDetailed(RaptorResponse response) { } public static String pathsToStringDetailed(Collection> paths) { - return pathsToString(paths, p -> p.toStringDetailed(TRANSLATOR::stopIndexToName)); + return pathsToString(paths, p -> p.toStringDetailed(RaptorTestConstants::stopIndexToName)); } public static String join(String... paths) { diff --git a/raptor/src/test/java/org/opentripplanner/raptor/_data/api/TestPathBuilderTestRaptor.java b/raptor/src/test/java/org/opentripplanner/raptor/_data/api/TestPathBuilderTestRaptor.java index e5a48ecd289..551126952ca 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/_data/api/TestPathBuilderTestRaptor.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/_data/api/TestPathBuilderTestRaptor.java @@ -54,7 +54,7 @@ public void testSimplePathWithOneTransit() { "~ BUS L1 10:02 10:07 5m C₁438 ~ B 15s " + "~ Walk 2m 10:07:15 10:09:15 C₁210 " + "[10:00:15 10:09:15 9m Tₓ0 C₁768]", - path.toStringDetailed(this::stopIndexToName) + path.toStringDetailed(RaptorTestConstants::stopIndexToName) ); } @@ -84,10 +84,13 @@ public void testBasicPath() { ) .egress(BasicPathTestCase.EGRESS_DURATION); - assertEquals(BasicPathTestCase.BASIC_PATH_AS_STRING, path.toString(this::stopIndexToName)); + assertEquals( + BasicPathTestCase.BASIC_PATH_AS_STRING, + path.toString(RaptorTestConstants::stopIndexToName) + ); assertEquals( BasicPathTestCase.BASIC_PATH_AS_DETAILED_STRING, - path.toStringDetailed(this::stopIndexToName) + path.toStringDetailed(RaptorTestConstants::stopIndexToName) ); assertEquals(BasicPathTestCase.TOTAL_C1, path.c1()); assertTrue(path.isC2Set()); diff --git a/raptor/src/test/java/org/opentripplanner/raptor/_data/stoparrival/BasicPathTestCase.java b/raptor/src/test/java/org/opentripplanner/raptor/_data/stoparrival/BasicPathTestCase.java index 5163140e40f..b1e7c0f4ec6 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/_data/stoparrival/BasicPathTestCase.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/_data/stoparrival/BasicPathTestCase.java @@ -419,11 +419,14 @@ public void testSetup() { transitArrivalCost(L21_END + ALIGHT_SLACK, TRIP_3, STOP_D, L31_START, STOP_E, L31_END) ); - assertEquals(BASIC_PATH_AS_STRING, basicTripAsPath().toString(this::stopIndexToName)); + assertEquals( + BASIC_PATH_AS_STRING, + basicTripAsPath().toString(RaptorTestConstants::stopIndexToName) + ); assertEquals( BASIC_PATH_AS_DETAILED_STRING, - basicTripAsPath().toStringDetailed(this::stopIndexToName) + basicTripAsPath().toStringDetailed(RaptorTestConstants::stopIndexToName) ); } diff --git a/raptor/src/test/java/org/opentripplanner/raptor/_data/transit/TestTransitData.java b/raptor/src/test/java/org/opentripplanner/raptor/_data/transit/TestTransitData.java index edd87c16b48..ca06baee50e 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/_data/transit/TestTransitData.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/_data/transit/TestTransitData.java @@ -135,7 +135,7 @@ public RaptorConstrainedTransfer findConstrainedTransfer( @Override public RaptorStopNameResolver stopNameResolver() { // Index is translated: 1->'A', 2->'B', 3->'C' ... - return this::stopIndexToName; + return RaptorTestConstants::stopIndexToName; } @Override diff --git a/raptor/src/test/java/org/opentripplanner/raptor/api/path/PathTest.java b/raptor/src/test/java/org/opentripplanner/raptor/api/path/PathTest.java index e0819717e10..ec5951bce7d 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/api/path/PathTest.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/api/path/PathTest.java @@ -109,12 +109,15 @@ public void waitTime() { @Test public void testToString() { - assertEquals(BASIC_PATH_AS_STRING, subject.toString(this::stopIndexToName)); + assertEquals(BASIC_PATH_AS_STRING, subject.toString(RaptorTestConstants::stopIndexToName)); } @Test public void testToStringDetailed() { - assertEquals(BASIC_PATH_AS_DETAILED_STRING, subject.toStringDetailed(this::stopIndexToName)); + assertEquals( + BASIC_PATH_AS_DETAILED_STRING, + subject.toStringDetailed(RaptorTestConstants::stopIndexToName) + ); } @Test diff --git a/raptor/src/test/java/org/opentripplanner/raptor/rangeraptor/path/PathMapperTest.java b/raptor/src/test/java/org/opentripplanner/raptor/rangeraptor/path/PathMapperTest.java index 027d3d5852a..a083e132b6f 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/rangeraptor/path/PathMapperTest.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/rangeraptor/path/PathMapperTest.java @@ -43,7 +43,7 @@ public void mapToPathBasicForwardSearch() { var mapper = new ForwardPathMapper<>( SLACK_PROVIDER, C1_CALCULATOR, - this::stopIndexToName, + RaptorTestConstants::stopIndexToName, null, lifeCycle(), false @@ -63,7 +63,7 @@ public void mapToPathBasicReverseSearch() { var mapper = new ReversePathMapper<>( SLACK_PROVIDER, C1_CALCULATOR, - this::stopIndexToName, + RaptorTestConstants::stopIndexToName, null, lifeCycle(), false @@ -123,7 +123,10 @@ public void mapToPathForFlexCaseBWOpeningHoursReverseSearch() { /* private helper methods */ private void assertPath(RaptorPath path) { - assertEquals(BASIC_PATH_AS_DETAILED_STRING, path.toStringDetailed(this::stopIndexToName)); + assertEquals( + BASIC_PATH_AS_DETAILED_STRING, + path.toStringDetailed(RaptorTestConstants::stopIndexToName) + ); } private void runTestFlexForward( @@ -134,7 +137,7 @@ private void runTestFlexForward( var mapper = new ForwardPathMapper( FLEX_SLACK_PROVIDER, FLEX_COST_CALCULATOR, - this::stopIndexToName, + RaptorTestConstants::stopIndexToName, null, lifeCycle(), false @@ -142,7 +145,7 @@ private void runTestFlexForward( // When: RaptorPath path = mapper.mapToPath(destArrival); // Then: - assertEquals(expected, path.toStringDetailed(this::stopIndexToName)); + assertEquals(expected, path.toStringDetailed(RaptorTestConstants::stopIndexToName)); } private void runTestFlexReverse( @@ -153,7 +156,7 @@ private void runTestFlexReverse( var mapper = new ReversePathMapper( FLEX_SLACK_PROVIDER, FLEX_COST_CALCULATOR, - this::stopIndexToName, + RaptorTestConstants::stopIndexToName, null, lifeCycle(), false @@ -161,6 +164,6 @@ private void runTestFlexReverse( // When: RaptorPath path = mapper.mapToPath(destArrival); // Then: - assertEquals(expected, path.toStringDetailed(this::stopIndexToName)); + assertEquals(expected, path.toStringDetailed(RaptorTestConstants::stopIndexToName)); } } From a6b06abb01cf762da65ba0ad5bd0fb97b9420245 Mon Sep 17 00:00:00 2001 From: Thomas Gran Date: Wed, 19 Feb 2025 16:39:02 +0100 Subject: [PATCH 18/69] refactor: Remove unused code in RaptorTestConstants --- .../opentripplanner/raptorlegacy/_data/RaptorTestConstants.java | 1 + 1 file changed, 1 insertion(+) diff --git a/application/src/test/java/org/opentripplanner/raptorlegacy/_data/RaptorTestConstants.java b/application/src/test/java/org/opentripplanner/raptorlegacy/_data/RaptorTestConstants.java index 8a68fcbdcce..2b270c7fbbb 100644 --- a/application/src/test/java/org/opentripplanner/raptorlegacy/_data/RaptorTestConstants.java +++ b/application/src/test/java/org/opentripplanner/raptorlegacy/_data/RaptorTestConstants.java @@ -27,6 +27,7 @@ public interface RaptorTestConstants { int D3m = durationInSeconds("3m"); int D4m = durationInSeconds("4m"); int D5m = durationInSeconds("5m"); + int D10m = durationInSeconds("10m"); int D24h = durationInSeconds("24h"); /** From 436ecbde44f30c9b196ac63b4483aa2360d3994c Mon Sep 17 00:00:00 2001 From: Thomas Gran Date: Wed, 19 Feb 2025 17:07:43 +0100 Subject: [PATCH 19/69] refactor: Code cleanup RaptorViaLocation --- .../transit/mappers/RaptorRequestMapper.java | 4 +- .../mappers/RaptorRequestMapperTest.java | 6 +- .../api/request/RaptorViaConnection.java | 17 +- .../raptor/api/request/RaptorViaLocation.java | 108 ++++---- .../api/request/RaptorViaLocationTest.java | 213 +++++++++++++++ .../raptor/api/request/ViaLocationTest.java | 251 ------------------ 6 files changed, 290 insertions(+), 309 deletions(-) create mode 100644 raptor/src/test/java/org/opentripplanner/raptor/api/request/RaptorViaLocationTest.java delete mode 100644 raptor/src/test/java/org/opentripplanner/raptor/api/request/ViaLocationTest.java diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/RaptorRequestMapper.java b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/RaptorRequestMapper.java index 0b5b01cb64c..6d0fc9e2d7e 100644 --- a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/RaptorRequestMapper.java +++ b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/RaptorRequestMapper.java @@ -238,9 +238,9 @@ private List mapViaLocations() { private RaptorViaLocation mapViaLocation(ViaLocation input) { if (input.isPassThroughLocation()) { - var builder = RaptorViaLocation.allowPassThrough(input.label()); + var builder = RaptorViaLocation.passThrough(input.label()); for (int stopIndex : lookUpStopIndex.lookupStopLocationIndexes(input.stopLocationIds())) { - builder.addViaStop(stopIndex); + builder.addPassThroughStop(stopIndex); } return builder.build(); } diff --git a/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/RaptorRequestMapperTest.java b/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/RaptorRequestMapperTest.java index 1c70c1c27d6..b58b237a630 100644 --- a/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/RaptorRequestMapperTest.java +++ b/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/RaptorRequestMapperTest.java @@ -107,7 +107,7 @@ void testViaLocation() { assertTrue(result.searchParams().hasViaLocations()); assertEquals( - "[Via{label: Via A, minWaitTime: 13m, connections: [0 13m]}]", + "[Via{label: Via A, minWaitTime: 13m, connections: [(stop 0, 13m)]}]", result.searchParams().viaLocations().toString() ); } @@ -142,7 +142,7 @@ void testViaCoordinate() { assertFalse(result.searchParams().viaLocations().isEmpty()); assertEquals( - "[Via{label: Via coordinate, minWaitTime: 10m, connections: [47~123 10m10s]}]", + "[Via{label: Via coordinate, minWaitTime: 10m, connections: [(stop 47 ~ 123, 10m10s)]}]", result.searchParams().viaLocations().toString() ); } @@ -282,7 +282,7 @@ private static void assertFeatureSet( assertTrue(result.searchParams().hasViaLocations()); // One via location exist(no NPE), but it does not allow pass-through assertEquals( - "Via{label: Via A, connections: [0]}", + "Via{label: Via A, connections: [(stop 0)]}", result.searchParams().viaLocations().get(0).toString() ); } diff --git a/raptor/src/main/java/org/opentripplanner/raptor/api/request/RaptorViaConnection.java b/raptor/src/main/java/org/opentripplanner/raptor/api/request/RaptorViaConnection.java index fd3c040d5bf..e17cb51d2b9 100644 --- a/raptor/src/main/java/org/opentripplanner/raptor/api/request/RaptorViaConnection.java +++ b/raptor/src/main/java/org/opentripplanner/raptor/api/request/RaptorViaConnection.java @@ -91,6 +91,11 @@ public int durationInSeconds() { public abstract boolean isSameStop(); + /** Return true if the connection uses the street network to transfer from one stop to another. */ + public final boolean isTransfer() { + return !isSameStop(); + } + /** * This method is used to check that all connections are unique/provide an optimal path. * The method returns {@code true} if this instance is better or equals to the given other @@ -125,20 +130,20 @@ public int hashCode() { } @Override - public String toString() { + public final String toString() { return toString(Integer::toString); } - public String toString(RaptorStopNameResolver stopNameResolver) { - var buf = new StringBuilder(stopNameResolver.apply(fromStop)); + public final String toString(RaptorStopNameResolver stopNameResolver) { + var buf = new StringBuilder("(stop ").append(stopNameResolver.apply(fromStop)); if (transfer() != null) { - buf.append("~").append(stopNameResolver.apply(toStop())); + buf.append(" ~ ").append(stopNameResolver.apply(toStop())); } int d = durationInSeconds(); if (d > RaptorConstants.ZERO) { - buf.append(" ").append(DurationUtils.durationToStr(d)); + buf.append(", ").append(DurationUtils.durationToStr(d)); } - return buf.toString(); + return buf.append(')').toString(); } private static final class RaptorViaStopConnection extends RaptorViaConnection { diff --git a/raptor/src/main/java/org/opentripplanner/raptor/api/request/RaptorViaLocation.java b/raptor/src/main/java/org/opentripplanner/raptor/api/request/RaptorViaLocation.java index a11433ba70b..a761e0ffaa6 100644 --- a/raptor/src/main/java/org/opentripplanner/raptor/api/request/RaptorViaLocation.java +++ b/raptor/src/main/java/org/opentripplanner/raptor/api/request/RaptorViaLocation.java @@ -3,7 +3,6 @@ import java.time.Duration; import java.util.ArrayList; import java.util.List; -import java.util.Objects; import javax.annotation.Nullable; import org.opentripplanner.raptor.api.model.RaptorConstants; import org.opentripplanner.raptor.api.model.RaptorStopNameResolver; @@ -20,58 +19,55 @@ */ public final class RaptorViaLocation { - private static final int MAX_WAIT_TIME_LIMIT = (int) Duration.ofHours(24).toSeconds(); + private static final int MAX_WAIT_TIME = (int) Duration.ofHours(24).toSeconds(); + private static final int MIN_WAIT_TIME = (int) Duration.ZERO.toSeconds(); private final String label; - private final boolean allowPassThrough; + private final boolean passThroughAllowed; private final int minimumWaitTime; private final List connections; private RaptorViaLocation( String label, - boolean allowPassThrough, + boolean passThroughAllowed, Duration minimumWaitTime, List connections ) { this.label = label; - this.allowPassThrough = allowPassThrough; + this.passThroughAllowed = passThroughAllowed; this.minimumWaitTime = IntUtils.requireInRange( (int) minimumWaitTime.toSeconds(), - RaptorConstants.ZERO, - MAX_WAIT_TIME_LIMIT, + MIN_WAIT_TIME, + MAX_WAIT_TIME, "minimumWaitTime" ); this.connections = validateConnections(connections); - - if (allowPassThrough && this.minimumWaitTime > RaptorConstants.ZERO) { - throw new IllegalArgumentException("Pass-through and min-wait-time is not allowed."); - } } /** * Force the path through a set of stops, either on-board or as an alight or board stop. */ - public static Builder allowPassThrough(@Nullable String label) { - return new Builder(label, true, Duration.ZERO); + public static BuilderPassThrough passThrough(@Nullable String label) { + return new BuilderPassThrough(label); } /** * Force the path through one of the listed connections. To visit a stop, the path must board or * alight transit at the given stop, on-board visits do not count, see - * {@link #allowPassThrough(String)}. + * {@link #passThrough(String)}. */ - public static Builder via(@Nullable String label) { - return new Builder(label, false, Duration.ZERO); + public static BuilderViaMinTime via(@Nullable String label) { + return via(label, Duration.ZERO); } /** * Force the path through one of the listed connections, and wait the given minimum-wait-time * before continuing. To visit a stop, the path must board or alight transit at the given stop, - * on-board visits do not count, see {@link #allowPassThrough(String)}. + * on-board visits do not count, see {@link #passThrough(String)}. */ - public static Builder via(@Nullable String label, Duration minimumWaitTime) { - return new Builder(label, false, minimumWaitTime); + public static BuilderViaMinTime via(@Nullable String label, Duration minimumWaitTime) { + return new BuilderViaMinTime(label, minimumWaitTime); } @Nullable @@ -79,8 +75,8 @@ public String label() { return label; } - public boolean allowPassThrough() { - return allowPassThrough; + public boolean isPassThroughAllowed() { + return passThroughAllowed; } public int minimumWaitTime() { @@ -97,20 +93,12 @@ public String toString() { @Override public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - RaptorViaLocation that = (RaptorViaLocation) o; - return ( - allowPassThrough == that.allowPassThrough && - minimumWaitTime == that.minimumWaitTime && - Objects.equals(label, that.label) && - Objects.equals(connections, that.connections) - ); + throw new UnsupportedOperationException("No need to compare " + getClass()); } @Override public int hashCode() { - return Objects.hash(label, allowPassThrough, minimumWaitTime, connections); + throw new UnsupportedOperationException("No need for hashCode of " + getClass()); } public String toString(RaptorStopNameResolver stopNameResolver) { @@ -118,15 +106,16 @@ public String toString(RaptorStopNameResolver stopNameResolver) { if (label != null) { buf.append("label: ").append(label).append(", "); } - if (allowPassThrough) { + if (passThroughAllowed) { buf.append("allowPassThrough, "); } if (minimumWaitTime > RaptorConstants.ZERO) { buf.append("minWaitTime: ").append(DurationUtils.durationToStr(minimumWaitTime)).append(", "); } buf - .append("connections: ") - .append(connections.stream().map(it -> it.toString(stopNameResolver)).toList()); + .append("connections") + .append(connections.size() <= 10 ? ": " : "(10/" + connections.size() + "):") + .append(connections.stream().limit(10).map(it -> it.toString(stopNameResolver)).toList()); return buf.append("}").toString(); } @@ -154,31 +143,56 @@ private List validateConnections(List { - private final String label; - private final boolean allowPassThrough; - private final Duration minimumWaitTime; - private final List connections = new ArrayList<>(); + protected final String label; + protected final List connections = new ArrayList<>(); - public Builder(String label, boolean allowPassThrough, Duration minimumWaitTime) { + public AbstractBuilder(String label) { this.label = label; - this.allowPassThrough = allowPassThrough; + } + + public T addConnection(int stop, @Nullable RaptorTransfer transfer) { + this.connections.add(new BuilderStopAndTransfer(stop, transfer)); + return (T) this; + } + } + + public static final class BuilderViaMinTime extends AbstractBuilder { + + private final Duration minimumWaitTime; + + public BuilderViaMinTime(String label, Duration minimumWaitTime) { + super(label); this.minimumWaitTime = minimumWaitTime; } - public Builder addViaStop(int stop) { - this.connections.add(new BuilderStopAndTransfer(stop, null)); - return this; + public BuilderViaMinTime addViaStop(int stop) { + return addConnection(stop, null); + } + + public BuilderViaMinTime addViaTransfer(int fromStop, RaptorTransfer transfer) { + return addConnection(fromStop, transfer); } - public Builder addViaTransfer(int fromStop, RaptorTransfer transfer) { - this.connections.add(new BuilderStopAndTransfer(fromStop, transfer)); + public RaptorViaLocation build() { + return new RaptorViaLocation(label, false, minimumWaitTime, connections); + } + } + + public static final class BuilderPassThrough extends AbstractBuilder { + + public BuilderPassThrough(String label) { + super(label); + } + + public BuilderPassThrough addPassThroughStop(int stop) { + this.connections.add(new BuilderStopAndTransfer(stop, null)); return this; } public RaptorViaLocation build() { - return new RaptorViaLocation(label, allowPassThrough, minimumWaitTime, connections); + return new RaptorViaLocation(label, true, Duration.ZERO, connections); } } diff --git a/raptor/src/test/java/org/opentripplanner/raptor/api/request/RaptorViaLocationTest.java b/raptor/src/test/java/org/opentripplanner/raptor/api/request/RaptorViaLocationTest.java new file mode 100644 index 00000000000..2b5c43d2eb0 --- /dev/null +++ b/raptor/src/test/java/org/opentripplanner/raptor/api/request/RaptorViaLocationTest.java @@ -0,0 +1,213 @@ +package org.opentripplanner.raptor.api.request; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.time.Duration; +import java.util.List; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; +import org.opentripplanner.raptor._data.RaptorTestConstants; +import org.opentripplanner.raptor._data.transit.TestTransfer; +import org.opentripplanner.raptor.api.model.RaptorConstants; + +class RaptorViaLocationTest implements RaptorTestConstants { + + private static final Duration MINIMUM_WAIT_TIME = Duration.ofSeconds(23); + private static final String VIA_LABEL = "Via"; + private static final String PASS_THROUGH_LABEL = "PassThrough"; + private static final int TX_C1 = 3000; + private static final int TX_DURATION = D30s; + private static final TestTransfer TRANSFER = TestTransfer.transfer(STOP_C, TX_DURATION, TX_C1); + + private final RaptorViaLocation subject = RaptorViaLocation + .via(VIA_LABEL, MINIMUM_WAIT_TIME) + .addViaTransfer(STOP_B, TRANSFER) + .addViaStop(STOP_A) + .build(); + + private final RaptorViaLocation subjectPassThrough = RaptorViaLocation + .passThrough(PASS_THROUGH_LABEL) + .addPassThroughStop(STOP_D) + .build(); + + private final RaptorViaConnection transferConnection = subject + .connections() + .stream() + .filter(it -> it.isTransfer()) + .findFirst() + .orElseThrow(); + + private final RaptorViaConnection stopConnection = subject + .connections() + .stream() + .filter(it -> it.isSameStop()) + .findFirst() + .orElseThrow(); + + private final RaptorViaConnection passThroughStopConnection = subjectPassThrough + .connections() + .stream() + .findFirst() + .orElseThrow(); + + @Test + void passThrough() { + assertFalse(subject.isPassThroughAllowed()); + assertTrue(subjectPassThrough.isPassThroughAllowed()); + } + + @Test + void connections() { + var connections = subject.connections(); + assertTrue(connections.contains(transferConnection), connections.toString()); + assertTrue(connections.contains(stopConnection), connections.toString()); + } + + @Test + void testToString() { + assertEquals( + "Via{label: Via, minWaitTime: 23s, connections: [(stop 2 ~ 3, 53s), (stop 1, 23s)]}", + subject.toString() + ); + assertEquals( + "Via{label: PassThrough, allowPassThrough, connections: [(stop 4)]}", + subjectPassThrough.toString() + ); + + assertEquals( + "Via{label: Via, minWaitTime: 23s, connections: [(stop B ~ C, 53s), (stop A, 23s)]}", + subject.toString(RaptorTestConstants::stopIndexToName) + ); + } + + @Test + void minimumWaitTime() { + assertEquals(MINIMUM_WAIT_TIME.toSeconds(), subject.minimumWaitTime()); + assertEquals(Duration.ZERO.toSeconds(), subjectPassThrough.minimumWaitTime()); + } + + @Test + void label() { + assertEquals(VIA_LABEL, subject.label()); + assertEquals(PASS_THROUGH_LABEL, subjectPassThrough.label()); + } + + @Test + void fromStop() { + assertEquals(STOP_A, stopConnection.fromStop()); + assertEquals(STOP_B, transferConnection.fromStop()); + assertEquals(STOP_D, passThroughStopConnection.fromStop()); + } + + @Test + void transfer() { + assertNull(stopConnection.transfer()); + assertNull(passThroughStopConnection.transfer()); + assertEquals(TRANSFER, transferConnection.transfer()); + } + + @Test + void toStop() { + assertEquals(STOP_A, stopConnection.toStop()); + assertEquals(STOP_D, passThroughStopConnection.toStop()); + assertEquals(STOP_C, transferConnection.toStop()); + } + + @Test + void durationInSeconds() { + assertEquals(MINIMUM_WAIT_TIME.toSeconds(), stopConnection.durationInSeconds()); + assertEquals( + MINIMUM_WAIT_TIME.plusSeconds(TRANSFER.durationInSeconds()).toSeconds(), + transferConnection.durationInSeconds() + ); + } + + @Test + void c1() { + assertEquals(RaptorConstants.ZERO, stopConnection.c1()); + assertEquals(TX_C1, transferConnection.c1()); + } + + @Test + void isSameStop() { + assertTrue(stopConnection.isSameStop()); + assertFalse(transferConnection.isSameStop()); + } + + @Test + void isTransfer() { + assertFalse(stopConnection.isTransfer()); + assertTrue(transferConnection.isTransfer()); + } + + static List isBetterThanTestCases() { + // Subject is: STOP_A, STOP_B, MIN_DURATION, C1 + return List.of( + Arguments.of(STOP_A, STOP_B, TX_DURATION, TX_C1, true, "Same"), + Arguments.of(STOP_C, STOP_B, TX_DURATION, TX_C1, false, "toStop differ"), + Arguments.of(STOP_A, STOP_C, TX_DURATION, TX_C1, false, "fromStop differ"), + Arguments.of(STOP_A, STOP_B, TX_DURATION + 1, TX_C1, true, "Wait time is better"), + Arguments.of(STOP_A, STOP_B, TX_DURATION - 1, TX_C1, false, "Wait time is worse"), + Arguments.of(STOP_A, STOP_B, TX_DURATION, TX_C1 + 1, true, "C1 is better"), + Arguments.of(STOP_A, STOP_B, TX_DURATION, TX_C1 - 1, false, "C1 is worse") + ); + } + + @ParameterizedTest + @MethodSource("isBetterThanTestCases") + void isBetterThan( + int fromStop, + int toStop, + int minWaitTime, + int c1, + boolean expected, + String description + ) { + var subject = RaptorViaLocation + .via("Subject") + .addViaTransfer(STOP_A, new TestTransfer(STOP_B, TX_DURATION, TX_C1)) + .build() + .connections() + .getFirst(); + + var candidate = RaptorViaLocation + .via("Candidate") + .addViaTransfer(fromStop, new TestTransfer(toStop, minWaitTime, c1)) + .build() + .connections() + .getFirst(); + + assertEquals(subject.isBetterOrEqual(candidate), expected, description); + } + + @Test + void testEqualsAndHAshCode() { + var viaTxConnection = RaptorViaLocation + .via("SameAsVia", MINIMUM_WAIT_TIME) + .addViaTransfer(STOP_B, TRANSFER) + .build(); + var viaStopConnections = RaptorViaLocation + .via("SameAsVia", MINIMUM_WAIT_TIME) + .addViaStop(STOP_A) + .build(); + + var sameTransferConnection = viaTxConnection.connections().get(0); + var sameStopConnection = viaStopConnections.connections().get(0); + + // Equals + assertEquals(sameTransferConnection, transferConnection); + assertEquals(sameStopConnection, stopConnection); + assertNotEquals(sameStopConnection, transferConnection); + + // Hash code + assertEquals(sameTransferConnection.hashCode(), transferConnection.hashCode()); + assertEquals(sameStopConnection.hashCode(), stopConnection.hashCode()); + assertNotEquals(sameStopConnection.hashCode(), transferConnection.hashCode()); + } +} diff --git a/raptor/src/test/java/org/opentripplanner/raptor/api/request/ViaLocationTest.java b/raptor/src/test/java/org/opentripplanner/raptor/api/request/ViaLocationTest.java deleted file mode 100644 index 2aca0845ff8..00000000000 --- a/raptor/src/test/java/org/opentripplanner/raptor/api/request/ViaLocationTest.java +++ /dev/null @@ -1,251 +0,0 @@ -package org.opentripplanner.raptor.api.request; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertNotEquals; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.assertTrue; - -import java.time.Duration; -import java.util.List; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.MethodSource; -import org.opentripplanner.raptor._data.transit.TestTransfer; -import org.opentripplanner.raptor.api.model.RaptorConstants; -import org.opentripplanner.raptor.api.model.RaptorTransfer; - -class ViaLocationTest { - - private static final int STOP_A = 12; - private static final int STOP_B = 13; - private static final int STOP_C = 14; - private static final Duration WAIT_TIME = Duration.ofMinutes(3); - private static final int WAIT_TIME_SEC = (int) WAIT_TIME.toSeconds(); - private static final int C1 = 200; - private static final int TX_DURATION = 35; - private static final RaptorTransfer TX = new TestTransfer(STOP_B, TX_DURATION, C1); - - @Test - void passThroughStop() { - var subject = RaptorViaLocation.allowPassThrough("PassThrough A").addViaStop(STOP_C).build(); - - assertEquals("PassThrough A", subject.label()); - assertTrue(subject.allowPassThrough()); - assertEquals(RaptorConstants.ZERO, subject.minimumWaitTime()); - assertEquals( - "Via{label: PassThrough A, allowPassThrough, connections: [C]}", - subject.toString(ViaLocationTest::stopName) - ); - assertEquals( - "Via{label: PassThrough A, allowPassThrough, connections: [14]}", - subject.toString() - ); - - assertEquals(1, subject.connections().size()); - - var c = subject.connections().getFirst(); - assertEquals(STOP_C, c.fromStop()); - assertEquals(STOP_C, c.toStop()); - assertTrue(c.isSameStop()); - Assertions.assertEquals(RaptorConstants.ZERO, c.durationInSeconds()); - assertEquals(RaptorConstants.ZERO, c.c1()); - } - - @Test - void viaSingleStop() { - var subject = RaptorViaLocation.via("Tx A").addViaStop(STOP_B).build(); - - assertEquals("Tx A", subject.label()); - assertFalse(subject.allowPassThrough()); - assertEquals(RaptorConstants.ZERO, subject.minimumWaitTime()); - assertEquals("Via{label: Tx A, connections: [B]}", subject.toString(ViaLocationTest::stopName)); - assertEquals("Via{label: Tx A, connections: [13]}", subject.toString()); - assertEquals(1, subject.connections().size()); - - var connection = subject.connections().getFirst(); - assertEquals(STOP_B, connection.fromStop()); - assertEquals(STOP_B, connection.toStop()); - assertTrue(connection.isSameStop()); - Assertions.assertEquals(RaptorConstants.ZERO, connection.durationInSeconds()); - assertEquals(RaptorConstants.ZERO, connection.c1()); - } - - @Test - void testCombinationOfPassThroughAndTransfer() { - var subject = RaptorViaLocation - .allowPassThrough("PassThrough A") - .addViaStop(STOP_C) - .addViaTransfer(STOP_A, TX) - .build(); - - assertEquals("PassThrough A", subject.label()); - assertTrue(subject.allowPassThrough()); - assertEquals(RaptorConstants.ZERO, subject.minimumWaitTime()); - assertEquals( - "Via{label: PassThrough A, allowPassThrough, connections: [C, A~B 35s]}", - subject.toString(ViaLocationTest::stopName) - ); - assertEquals(2, subject.connections().size()); - - var c = subject.connections().getFirst(); - assertEquals(STOP_C, c.fromStop()); - assertEquals(STOP_C, c.toStop()); - assertTrue(c.isSameStop()); - Assertions.assertEquals(RaptorConstants.ZERO, c.durationInSeconds()); - assertEquals(RaptorConstants.ZERO, c.c1()); - - c = subject.connections().getLast(); - assertEquals(STOP_A, c.fromStop()); - assertEquals(STOP_B, c.toStop()); - assertFalse(c.isSameStop()); - Assertions.assertEquals(TX_DURATION, c.durationInSeconds()); - assertEquals(C1, c.c1()); - } - - @Test - void viaStopAorCWithWaitTime() { - var subject = RaptorViaLocation - .via("Plaza", WAIT_TIME) - .addViaStop(STOP_C) - .addViaTransfer(STOP_A, TX) - .build(); - - assertEquals("Plaza", subject.label()); - assertFalse(subject.allowPassThrough()); - assertEquals(WAIT_TIME_SEC, subject.minimumWaitTime()); - assertEquals( - "Via{label: Plaza, minWaitTime: 3m, connections: [C 3m, A~B 3m35s]}", - subject.toString(ViaLocationTest::stopName) - ); - assertEquals(2, subject.connections().size()); - - var connection = subject.connections().getFirst(); - assertEquals(STOP_C, connection.fromStop()); - assertEquals(STOP_C, connection.toStop()); - assertTrue(connection.isSameStop()); - Assertions.assertEquals(WAIT_TIME_SEC, connection.durationInSeconds()); - assertEquals(RaptorConstants.ZERO, connection.c1()); - - connection = subject.connections().getLast(); - assertEquals(STOP_A, connection.fromStop()); - assertEquals(STOP_B, connection.toStop()); - assertFalse(connection.isSameStop()); - Assertions.assertEquals(WAIT_TIME_SEC + TX.durationInSeconds(), connection.durationInSeconds()); - assertEquals(C1, connection.c1()); - } - - static List isBetterThanTestCases() { - // Subject is: STOP_A, STOP_B, MIN_DURATION, C1 - return List.of( - Arguments.of(STOP_A, STOP_B, TX_DURATION, C1, true, "Same"), - Arguments.of(STOP_C, STOP_B, TX_DURATION, C1, false, "toStop differ"), - Arguments.of(STOP_A, STOP_C, TX_DURATION, C1, false, "fromStop differ"), - Arguments.of(STOP_A, STOP_B, TX_DURATION + 1, C1, true, "Wait time is better"), - Arguments.of(STOP_A, STOP_B, TX_DURATION - 1, C1, false, "Wait time is worse"), - Arguments.of(STOP_A, STOP_B, TX_DURATION, C1 + 1, true, "C1 is better"), - Arguments.of(STOP_A, STOP_B, TX_DURATION, C1 - 1, false, "C1 is worse") - ); - } - - @ParameterizedTest - @MethodSource("isBetterThanTestCases") - void isBetterThan( - int fromStop, - int toStop, - int minWaitTime, - int c1, - boolean expected, - String description - ) { - var subject = RaptorViaLocation - .via("Subject") - .addViaTransfer(STOP_A, new TestTransfer(STOP_B, TX_DURATION, C1)) - .build() - .connections() - .getFirst(); - - var candidate = RaptorViaLocation - .via("Candidate") - .addViaTransfer(fromStop, new TestTransfer(toStop, minWaitTime, c1)) - .build() - .connections() - .getFirst(); - - assertEquals(subject.isBetterOrEqual(candidate), expected, description); - } - - @Test - void throwsExceptionIfConnectionsIsNotParetoOptimal() { - var e = assertThrows( - IllegalArgumentException.class, - () -> - RaptorViaLocation - .via("S") - .addViaTransfer(STOP_A, new TestTransfer(STOP_B, TX_DURATION, C1)) - .addViaTransfer(STOP_A, new TestTransfer(STOP_B, TX_DURATION, C1)) - .build() - ); - assertEquals( - "All connection need to be pareto-optimal: (12~13 35s) <-> (12~13 35s)", - e.getMessage() - ); - } - - @Test - void testEqualsAndHashCode() { - var subject = RaptorViaLocation.via(null).addViaTransfer(STOP_A, TX).build(); - var same = RaptorViaLocation.via(null).addViaTransfer(STOP_A, TX).build(); - // Slightly less wait-time and slightly larger cost(c1) - var other = RaptorViaLocation - .via(null, Duration.ofSeconds(1)) - .addViaTransfer(STOP_A, TX) - .build(); - - assertEquals(subject, same); - assertNotEquals(subject, other); - assertNotEquals(subject, "Does not match another type"); - - assertEquals(subject.hashCode(), same.hashCode()); - assertNotEquals(subject.hashCode(), other.hashCode()); - } - - @Test - void testToString() { - var subject = RaptorViaLocation.via("A|B").addViaStop(STOP_A).addViaStop(STOP_B).build(); - assertEquals("Via{label: A|B, connections: [12, 13]}", subject.toString()); - assertEquals( - "Via{label: A|B, connections: [A, B]}", - subject.toString(ViaLocationTest::stopName) - ); - - subject = RaptorViaLocation.via(null, WAIT_TIME).addViaStop(STOP_B).build(); - assertEquals("Via{minWaitTime: 3m, connections: [13 3m]}", subject.toString()); - assertEquals( - "Via{minWaitTime: 3m, connections: [B 3m]}", - subject.toString(ViaLocationTest::stopName) - ); - - subject = RaptorViaLocation.via(null).addViaTransfer(STOP_A, TX).build(); - assertEquals("Via{connections: [12~13 35s]}", subject.toString()); - assertEquals("Via{connections: [A~B 35s]}", subject.toString(ViaLocationTest::stopName)); - - subject = RaptorViaLocation.allowPassThrough(null).addViaStop(STOP_C).build(); - assertEquals("Via{allowPassThrough, connections: [14]}", subject.toString()); - assertEquals( - "Via{allowPassThrough, connections: [C]}", - subject.toString(ViaLocationTest::stopName) - ); - } - - private static String stopName(int i) { - return switch (i) { - case 12 -> "A"; - case 13 -> "B"; - case 14 -> "C"; - default -> throw new IllegalArgumentException("Unknown stop: " + i); - }; - } -} From af0a44f52e189e1c36852cc199649e5ae23fd487 Mon Sep 17 00:00:00 2001 From: Thomas Gran Date: Wed, 19 Feb 2025 21:47:01 +0100 Subject: [PATCH 20/69] refactor: Update package-info.md in o.o.raptor.moduletests --- .../org/opentripplanner/raptor/moduletests/package-info.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/package-info.md b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/package-info.md index b84e7a179ac..afab143a09f 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/package-info.md +++ b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/package-info.md @@ -21,6 +21,9 @@ group from simple to complex tests (`01` to `99`). - `G` - Access and egress with opening hours/time restrictions - `H` - Combining the above advanced features - `I` - Heuristic test +- `J` - Via seach +- `K` - Transit priority +- `L` - Time penalty From e8f7548fcb114e32ee2015c40923830e669bd731 Mon Sep 17 00:00:00 2001 From: Thomas Gran Date: Wed, 19 Feb 2025 21:48:48 +0100 Subject: [PATCH 21/69] feature: Add support for via using transfer in Raptor --- .../multicriteria/McStopArrivals.java | 38 +-- ...ViaConnectionStopArrivalEventListener.java | 70 +++++- .../configure/McRangeRaptorConfig.java | 22 +- .../raptor/_data/RaptorTestConstants.java | 5 + .../raptor/_data/transit/TestRoute.java | 49 ++++ .../moduletests/J02_ViaStopSearchTest.java | 13 +- .../J03_ViaTransferSearchTest.java | 234 ++++++++++++++++++ 7 files changed, 394 insertions(+), 37 deletions(-) create mode 100644 raptor/src/test/java/org/opentripplanner/raptor/moduletests/J03_ViaTransferSearchTest.java diff --git a/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/multicriteria/McStopArrivals.java b/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/multicriteria/McStopArrivals.java index 1fde9f288a5..4728f96e03b 100644 --- a/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/multicriteria/McStopArrivals.java +++ b/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/multicriteria/McStopArrivals.java @@ -4,6 +4,7 @@ import java.util.BitSet; import java.util.Collections; +import java.util.List; import java.util.Objects; import java.util.function.Function; import java.util.stream.Stream; @@ -12,10 +13,8 @@ import org.opentripplanner.raptor.rangeraptor.debug.DebugHandlerFactory; import org.opentripplanner.raptor.rangeraptor.multicriteria.arrivals.ArrivalParetoSetComparatorFactory; import org.opentripplanner.raptor.rangeraptor.multicriteria.arrivals.McStopArrival; -import org.opentripplanner.raptor.rangeraptor.multicriteria.arrivals.McStopArrivalFactory; import org.opentripplanner.raptor.rangeraptor.path.DestinationArrivalPaths; import org.opentripplanner.raptor.rangeraptor.transit.EgressPaths; -import org.opentripplanner.raptor.rangeraptor.transit.ViaConnections; import org.opentripplanner.raptor.spi.IntIterator; import org.opentripplanner.raptor.util.BitSetIterator; import org.opentripplanner.raptor.util.paretoset.ParetoComparator; @@ -46,15 +45,13 @@ public final class McStopArrivals { public McStopArrivals( int nStops, @Nullable EgressPaths egressPaths, - ViaConnections viaConnections, + List> viaConnectionListeners, DestinationArrivalPaths paths, - McStopArrivals nextLegArrivals, - McStopArrivalFactory stopArrivalFactory, ArrivalParetoSetComparatorFactory> comparatorFactory, DebugHandlerFactory debugHandlerFactory ) { // Assert only-one-of next or egressPaths is set - if (nextLegArrivals == null) { + if (viaConnectionListeners.isEmpty()) { Objects.requireNonNull(egressPaths); } else if (egressPaths != null) { throw new IllegalArgumentException( @@ -69,7 +66,7 @@ public McStopArrivals( this.debugHandlerFactory = debugHandlerFactory; this.debugStats = new DebugStopArrivalsStatistics(debugHandlerFactory.debugLogger()); - initViaConnections(viaConnections, stopArrivalFactory, nextLegArrivals); + initViaConnections(viaConnectionListeners); initEgressStopAndGlueItToDestinationArrivals(egressPaths, paths); } @@ -153,26 +150,17 @@ private StopArrivalParetoSet findOrCreateSet(final int stop) { } private void initViaConnections( - @Nullable ViaConnections viaConnections, - McStopArrivalFactory stopArrivalFactory, - McStopArrivals nextLeg + List> viaConnectionListeners ) { - if (viaConnections == null) { - return; + for (ViaConnectionStopArrivalEventListener it : viaConnectionListeners) { + int stop = it.fromStop(); + this.arrivals[stop] = + StopArrivalParetoSet + .of(comparator) + .withDebugListener(debugHandlerFactory.paretoSetStopArrivalListener(stop)) + .withNextLegListener(it) + .build(); } - viaConnections - .byFromStop() - .forEachEntry((stop, connections) -> { - this.arrivals[stop] = - StopArrivalParetoSet - .of(comparator) - .withDebugListener(debugHandlerFactory.paretoSetStopArrivalListener(stop)) - .withNextLegListener( - new ViaConnectionStopArrivalEventListener<>(stopArrivalFactory, connections, nextLeg) - ) - .build(); - return true; - }); } /** diff --git a/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/multicriteria/ViaConnectionStopArrivalEventListener.java b/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/multicriteria/ViaConnectionStopArrivalEventListener.java index 6b0128e12e2..0cd51dfe88f 100644 --- a/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/multicriteria/ViaConnectionStopArrivalEventListener.java +++ b/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/multicriteria/ViaConnectionStopArrivalEventListener.java @@ -1,34 +1,94 @@ package org.opentripplanner.raptor.rangeraptor.multicriteria; +import java.util.ArrayList; import java.util.List; +import java.util.function.Consumer; import javax.annotation.Nullable; import org.opentripplanner.raptor.api.model.RaptorTripSchedule; import org.opentripplanner.raptor.api.request.RaptorViaConnection; import org.opentripplanner.raptor.api.view.ArrivalView; import org.opentripplanner.raptor.rangeraptor.multicriteria.arrivals.McStopArrival; import org.opentripplanner.raptor.rangeraptor.multicriteria.arrivals.McStopArrivalFactory; +import org.opentripplanner.raptor.rangeraptor.transit.ViaConnections; import org.opentripplanner.raptor.util.paretoset.ParetoSetEventListener; /** * This class is used to listen for stop arrivals in one raptor state and then copy * over the arrival event to another state. This is used to chain the Raptor searches * together to force the paths through the given via connections. + *

+ * We need to delay updating the next arrival state if the via connection is a transfer. + * Raptor process arrivals in phases, if you arrive at a stop by transit, you may continue + * using a transfer or transit. The transit state is copied over from the first leg state + * without delay, while the transfer via-leg state must be cached and copied over in the + * "transfer phase" of the Raptor algorithm. The life-cycle service will notify this class + * at the right time to publish the transter-arrivals. */ -class ViaConnectionStopArrivalEventListener +public class ViaConnectionStopArrivalEventListener implements ParetoSetEventListener> { private final McStopArrivalFactory stopArrivalFactory; private final List connections; private final McStopArrivals next; + private final List> transfersCashe = new ArrayList<>(); + /** + * @param publishTransfersEventHandler A callback used to publish via-transfer-connections. This + * should be done in the same phase as all other transfers + * processed by the Raptor algorithm. + */ public ViaConnectionStopArrivalEventListener( McStopArrivalFactory stopArrivalFactory, List connections, - McStopArrivals next + McStopArrivals next, + Consumer publishTransfersEventHandler ) { this.stopArrivalFactory = stopArrivalFactory; this.connections = connections; this.next = next; + publishTransfersEventHandler.accept(this::publishTransfers); + } + + /** + * Factory method for creating a {@link org.opentripplanner.raptor.util.paretoset.ParetoSet} + * listener used to copy the state when arriving at a "via piont" into the next Raptor "leg". + */ + public static < + T extends RaptorTripSchedule + > List> createEventListners( + @Nullable ViaConnections viaConnections, + McStopArrivalFactory stopArrivalFactory, + McStopArrivals nextLegStopArrivals, + Consumer onTransitCompleate + ) { + if (viaConnections == null) { + return List.of(); + } + var list = new ArrayList>(); + viaConnections + .byFromStop() + .forEachEntry((stop, connections) -> + list.add( + new ViaConnectionStopArrivalEventListener<>( + stopArrivalFactory, + connections, + nextLegStopArrivals, + onTransitCompleate + ) + ) + ); + return list; + } + + private void publishTransfers() { + for (var arrival : transfersCashe) { + next.addStopArrival(arrival); + } + transfersCashe.clear(); + } + + int fromStop() { + return connections.getFirst().fromStop(); } @Override @@ -37,7 +97,11 @@ public void notifyElementAccepted(ArrivalView newElement) { var e = (McStopArrival) newElement; var n = createViaStopArrival(e, c); if (n != null) { - next.addStopArrival(n); + if (c.isTransfer()) { + transfersCashe.add(n); + } else { + next.addStopArrival(n); + } } } } diff --git a/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/multicriteria/configure/McRangeRaptorConfig.java b/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/multicriteria/configure/McRangeRaptorConfig.java index f30b391b929..f7d35b619a8 100644 --- a/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/multicriteria/configure/McRangeRaptorConfig.java +++ b/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/multicriteria/configure/McRangeRaptorConfig.java @@ -1,5 +1,6 @@ package org.opentripplanner.raptor.rangeraptor.multicriteria.configure; +import java.util.List; import java.util.Objects; import javax.annotation.Nullable; import org.opentripplanner.raptor.api.model.DominanceFunction; @@ -16,6 +17,7 @@ import org.opentripplanner.raptor.rangeraptor.multicriteria.McRangeRaptorWorkerState; import org.opentripplanner.raptor.rangeraptor.multicriteria.McStopArrivals; import org.opentripplanner.raptor.rangeraptor.multicriteria.MultiCriteriaRoutingStrategy; +import org.opentripplanner.raptor.rangeraptor.multicriteria.ViaConnectionStopArrivalEventListener; import org.opentripplanner.raptor.rangeraptor.multicriteria.arrivals.ArrivalParetoSetComparatorFactory; import org.opentripplanner.raptor.rangeraptor.multicriteria.arrivals.McStopArrival; import org.opentripplanner.raptor.rangeraptor.multicriteria.arrivals.McStopArrivalFactory; @@ -49,6 +51,7 @@ public class McRangeRaptorConfig { private Heuristics heuristics; private McStopArrivals arrivals; private McStopArrivals nextLegArrivals = null; + private McStopArrivalFactory stopArrivalFactory = null; public McRangeRaptorConfig( SearchContextViaLeg contextLeg, @@ -109,10 +112,8 @@ public McStopArrivals stopArrivals() { new McStopArrivals<>( context().nStops(), contextLeg.egressPaths(), - contextLeg.viaConnections(), + createViaConnectionListeners(), createDestinationArrivalPaths(), - nextLegArrivals, - createStopArrivalFactory(), createFactoryParetoComparator(), context().debugFactory() ); @@ -169,7 +170,11 @@ private McRangeRaptorWorkerState createState(Heuristics heuristics) { } private McStopArrivalFactory createStopArrivalFactory() { - return includeC2() ? new StopArrivalFactoryC2<>() : new StopArrivalFactoryC1<>(); + if (stopArrivalFactory == null) { + this.stopArrivalFactory = + includeC2() ? new StopArrivalFactoryC2<>() : new StopArrivalFactoryC1<>(); + } + return stopArrivalFactory; } private SearchContext context() { @@ -208,6 +213,15 @@ private ArrivalParetoSetComparatorFactory> createFactoryParetoC return ArrivalParetoSetComparatorFactory.factory(mcRequest().relaxC1(), dominanceFunctionC2()); } + private List> createViaConnectionListeners() { + return ViaConnectionStopArrivalEventListener.createEventListners( + contextLeg.viaConnections(), + createStopArrivalFactory(), + nextLegArrivals, + context().lifeCycle()::onTransfersForRoundComplete + ); + } + private MultiCriteriaRequest mcRequest() { return context().multiCriteria(); } diff --git a/raptor/src/test/java/org/opentripplanner/raptor/_data/RaptorTestConstants.java b/raptor/src/test/java/org/opentripplanner/raptor/_data/RaptorTestConstants.java index a0299ffb3df..1e076700dc8 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/_data/RaptorTestConstants.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/_data/RaptorTestConstants.java @@ -84,4 +84,9 @@ public interface RaptorTestConstants { static String stopIndexToName(int index) { return Character.toString('A' + index - 1); } + + static int stopNameToIndex(String name) { + char ch = name.startsWith("STOP_") ? name.charAt(5) : name.charAt(0); + return (int) (ch - 'A' + 1); + } } diff --git a/raptor/src/test/java/org/opentripplanner/raptor/_data/transit/TestRoute.java b/raptor/src/test/java/org/opentripplanner/raptor/_data/transit/TestRoute.java index 2cd87a065ea..6176a72fc37 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/_data/transit/TestRoute.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/_data/transit/TestRoute.java @@ -1,13 +1,16 @@ package org.opentripplanner.raptor._data.transit; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; import java.util.List; +import org.opentripplanner.raptor._data.RaptorTestConstants; import org.opentripplanner.raptor.api.model.SearchDirection; import org.opentripplanner.raptor.spi.RaptorConstrainedBoardingSearch; import org.opentripplanner.raptor.spi.RaptorRoute; import org.opentripplanner.raptor.spi.RaptorTimeTable; import org.opentripplanner.raptor.spi.RaptorTripScheduleSearch; +import org.opentripplanner.utils.lang.StringUtils; import org.opentripplanner.utils.tostring.ToStringBuilder; public class TestRoute implements RaptorRoute, RaptorTimeTable { @@ -33,6 +36,10 @@ public static TestRoute route(String name, int... stopIndexes) { return route(TestTripPattern.pattern(name, stopIndexes)); } + public static Builder route(String name) { + return new Builder(name); + } + /* RaptorRoute */ @Override @@ -87,6 +94,15 @@ public TestRoute withTimetable(TestTripSchedule.Builder... scheduleBuilders) { return this; } + public TestRoute withTimetable(String timetable) { + Arrays + .stream(timetable.split("\\n")) + .filter(StringUtils::hasValue) + .map(s -> TestTripSchedule.schedule(s).pattern(pattern).build()) + .forEach(schedules::add); + return this; + } + @Override public String toString() { return ToStringBuilder @@ -141,4 +157,37 @@ void addTransferConstraint( } } } + + public static final class Builder { + + private String name; + + public Builder(String name) { + this.name = name; + } + + /** + * Create a route with the given stop-pattern and schedule parsing the given {@code timetable}. + * The format of the timetable is: + *

+     *   A      B      C      F
+     * 10:00  10:20  10:25  10:45
+     * 11:00  11:20  11:25  11:45
+     * 12:00  12:20  12:25  12:45
+     * 
+ * This will create a timetable with for stops(A, B, C, & F) and 3 scheduled trips. The + * {@link RaptorTestConstants#stopNameToIndex(String)} is used to resolve the stop index + * for each of the named stops A, B, C & F. The first line must contain the stop names(A-Z), + * and the each extra line is the trips. Extra white-space and empty lines are ignored. + */ + public TestRoute timetable(String timetable) { + timetable = timetable.trim(); + int end = timetable.indexOf('\n'); + var stopIndexes = Arrays + .stream(timetable.substring(0, end).split("\\s+")) + .mapToInt(RaptorTestConstants::stopNameToIndex) + .toArray(); + return route(name, stopIndexes).withTimetable(timetable.substring(end + 1)); + } + } } diff --git a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/J02_ViaStopSearchTest.java b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/J02_ViaStopSearchTest.java index 853fb713f8e..2185213993b 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/J02_ViaStopSearchTest.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/J02_ViaStopSearchTest.java @@ -250,11 +250,14 @@ void multipleViaPoints() { // The second one includes the second via point. // Both arrive at the desired destination, so normally there should not be any transfers. data.withRoutes( - route("R2", STOP_A, STOP_B, STOP_C, STOP_D, STOP_E, STOP_F) - .withTimetable( - schedule("0:02 0:05 0:10 0:15 0:20 0:25"), - schedule("0:12 0:15 0:20 0:25 0:30 0:35"), - schedule("0:22 0:25 0:30 0:35 0:40 0:45") + route("R2") + .timetable( + """ + A B C D E F + 0:02 0:05 0:10 0:15 0:20 0:25 + 0:12 0:15 0:20 0:25 0:30 0:35 + 0:22 0:25 0:30 0:35 0:40 0:45 + """ ) ); diff --git a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/J03_ViaTransferSearchTest.java b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/J03_ViaTransferSearchTest.java new file mode 100644 index 00000000000..a0d69685d00 --- /dev/null +++ b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/J03_ViaTransferSearchTest.java @@ -0,0 +1,234 @@ +package org.opentripplanner.raptor.moduletests; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.opentripplanner.raptor._data.RaptorTestConstants.D1m; +import static org.opentripplanner.raptor._data.RaptorTestConstants.D20s; +import static org.opentripplanner.raptor._data.RaptorTestConstants.D30s; +import static org.opentripplanner.raptor._data.RaptorTestConstants.STOP_A; +import static org.opentripplanner.raptor._data.RaptorTestConstants.STOP_B; +import static org.opentripplanner.raptor._data.RaptorTestConstants.STOP_C; +import static org.opentripplanner.raptor._data.RaptorTestConstants.STOP_D; +import static org.opentripplanner.raptor._data.RaptorTestConstants.STOP_E; +import static org.opentripplanner.raptor._data.RaptorTestConstants.STOP_F; +import static org.opentripplanner.raptor._data.RaptorTestConstants.T00_00; +import static org.opentripplanner.raptor._data.RaptorTestConstants.T01_00; +import static org.opentripplanner.raptor._data.api.PathUtils.pathsToString; +import static org.opentripplanner.raptor._data.transit.TestAccessEgress.walk; +import static org.opentripplanner.raptor._data.transit.TestRoute.route; +import static org.opentripplanner.raptor._data.transit.TestTransfer.transfer; +import static org.opentripplanner.raptor.api.request.RaptorViaLocation.via; + +import java.time.Duration; +import java.util.List; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.opentripplanner.raptor.RaptorService; +import org.opentripplanner.raptor._data.transit.TestTransfer; +import org.opentripplanner.raptor._data.transit.TestTransitData; +import org.opentripplanner.raptor._data.transit.TestTripSchedule; +import org.opentripplanner.raptor.api.request.RaptorProfile; +import org.opentripplanner.raptor.api.request.RaptorRequestBuilder; +import org.opentripplanner.raptor.api.request.RaptorViaLocation; +import org.opentripplanner.raptor.configure.RaptorConfig; + +/** + * FEATURE UNDER TEST + * + * Raptor should be able to handle route request with one or more via locations using transfers + * . The via point is a coordinate/node in the street map, but Raptor only see this as a special + * kind of transfer. If a stop is specified as via location in the request, then all the results + * returned from raptor should include the stop. The stop should be a alight, board or intermediate + * stop of one of the trips in the path. + * + * It should be possible to specify more than one connection. The result should include the via + * locations in the order as they were specified in the request. Only alternatives that pass + * through all via locations should be included in the result. + * + * To support stations and other collections of stops, Raptor should also support multiple via + * connections in one via location. + */ +class J03_ViaTransferSearchTest { + + private final RaptorService raptorService = new RaptorService<>( + RaptorConfig.defaultConfigForTest() + ); + + private RaptorRequestBuilder prepareRequest() { + var builder = new RaptorRequestBuilder(); + + builder + .profile(RaptorProfile.MULTI_CRITERIA) + // TODO: 2023-07-24 Currently heuristics does not work with pass-through so we + // have to turn them off. Make sure to re-enable optimization later when it's fixed + .clearOptimizations(); + + builder + .searchParams() + .earliestDepartureTime(T00_00) + .latestArrivalTime(T01_00) + .searchWindow(Duration.ofMinutes(10)) + .timetable(true); + + return builder; + } + + @Test + @DisplayName( + "Basic via search with just one route. You should be forced to get off the " + + "first trip and wait for the next one at the specified via stop." + ) + void viaSearchAlightingAtViaStop() { + var data = new TestTransitData(); + + data.withRoutes( + route("R1") + .timetable( + """ + A B C D + 0:02 0:10 0:20 0:30 + 0:12 0:20 0:30 0:40 + """ + ) + ); + + var requestBuilder = prepareRequest(); + + requestBuilder + .searchParams() + .addAccessPaths(walk(STOP_A, D30s)) + .addViaLocation( + RaptorViaLocation + .via("B") + .addViaTransfer(STOP_B, TestTransfer.transfer(STOP_B, D1m)) + .build() + ) + .addEgressPaths(walk(STOP_D, D30s)); + + var result = raptorService.route(requestBuilder.build(), data); + + // Verify that we alight the first trip at stop C and board the second trip + assertEquals( + "Walk 30s ~ A ~ BUS R1 0:02 0:10 ~ B ~ Walk 1m ~ B ~ BUS R1 0:20 0:40 ~ D ~ Walk 30s [0:01:30 0:40:30 39m Tₓ1 C₁3_660]", + pathsToString(result) + ); + } + + @Test + @DisplayName( + "Basic via search with just two routes. You should be forced use the provided via transfer " + + "even when a better regular transfer exist and an eariler depature could be reached. " + ) + void viaSearchArrivingByTransferAtViaStop() { + var data = new TestTransitData(); + + data.withRoutes( + route("R1", STOP_A, STOP_B, STOP_D).withTimetable(""" + 0:02 0:10 0:12 + """), + route("R2", STOP_C, STOP_D, STOP_E) + .withTimetable(""" + 0:10 0:13 0:15 + 0:12 0:15 0:17 + """) + ); + + var requestBuilder = prepareRequest(); + + requestBuilder + .searchParams() + .addAccessPaths(walk(STOP_A, D30s)) + .addViaLocation(via("BxC").addViaTransfer(STOP_B, TestTransfer.transfer(STOP_C, D1m)).build()) + .addEgressPaths(walk(STOP_E, D30s)); + + var result = raptorService.route(requestBuilder.build(), data); + + // Verify that we alight the first trip at stop C and board the second trip + assertEquals( + "Walk 30s ~ A ~ BUS R1 0:02 0:10 ~ B ~ Walk 1m ~ C ~ BUS R2 0:12 0:17 ~ E ~ Walk 30s " + + "[0:01:30 0:17:30 16m Tₓ1 C₁2_280]", + pathsToString(result) + ); + } + + @Test + @DisplayName( + "Via search with via transfer should force the usage of a route at the destination " + + "avoiding using a via-transfer followed by a regular transfer." + ) + void viaTransferSearchNotFolloedByRegularTransfer() { + var data = new TestTransitData(); + + data + .withRoutes( + route("R1", STOP_A, STOP_B).withTimetable("0:02 0:10"), + route("R2", STOP_C, STOP_D).withTimetable("0:12 0:15"), + route("R2", STOP_E, STOP_F).withTimetable(""" + 0:15 0:17 + 0:17 0:15 + """) + ) + .withTransfer(STOP_C, transfer(STOP_E, D1m)) + .withTransfer(STOP_D, transfer(STOP_E, D1m)); + var requestBuilder = prepareRequest(); + + requestBuilder + .searchParams() + .addAccessPaths(walk(STOP_A, D30s)) + .addViaLocation(via("BxC").addViaTransfer(STOP_B, TestTransfer.transfer(STOP_C, D1m)).build()) + .addEgressPaths(walk(STOP_F, D30s)); + + var result = raptorService.route(requestBuilder.build(), data); + + // Verify that we alight the first trip at stop C and board the second trip + assertEquals( + "Walk 30s ~ A ~ " + + "BUS R1 0:02 0:10 ~ B ~ Walk 1m ~ C ~ " + + "BUS R2 0:12 0:15 ~ D ~ Walk 1m ~ E ~ " + + "BUS R2 0:17 0:15 ~ F ~ Walk 30s " + + "[0:01:30 0:15:30 14m Tₓ2 C₁2_820]", + pathsToString(result) + ); + } + + @Test + @DisplayName("Test minimum wait time") + void testMinWaitTime() { + var data = new TestTransitData(); + data.withRoutes( + route("R1", STOP_A, STOP_B).withTimetable("0:02:00 0:04:00"), + route("R2") + .timetable( + """ + B C + 0:05:44 0:10 + 0:05:45 0:11 + 0:05:46 0:12 + """ + ) + ); + + var requestBuilder = prepareRequest(); + var minWaitTime = Duration.ofSeconds(25); + + requestBuilder + .searchParams() + .addAccessPaths(walk(STOP_A, D30s)) + .addViaLocations( + List.of( + RaptorViaLocation + .via("B", minWaitTime) + .addViaTransfer(STOP_B, transfer(STOP_B, D20s)) + .build() + ) + ) + .addEgressPaths(walk(STOP_C, D30s)); + + // We expect to bard the second trip at 0:05:45, since the minWaitTime is 45s and the + // transfer slack is 60s. + assertEquals( + "Walk 30s ~ A ~ BUS R1 0:02 0:04 ~ B ~ Walk 20s ~ B ~ BUS R2 0:05:45 0:11 ~ C ~ Walk 30s " + + "[0:01:30 0:11:30 10m Tₓ1 C₁1_880]", + pathsToString(raptorService.route(requestBuilder.build(), data)) + ); + } +} From a1ee277509bd690136172ffd3971121093a84a1b Mon Sep 17 00:00:00 2001 From: Thomas Gran Date: Thu, 20 Feb 2025 12:58:50 +0100 Subject: [PATCH 22/69] refactor: Cleanup RaptorViaLocation --- .../mappers/RaptorRequestMapperTest.java | 6 ++-- .../raptor/api/request/RaptorViaLocation.java | 31 +++++++++---------- .../api/request/RaptorViaLocationTest.java | 10 +++--- 3 files changed, 22 insertions(+), 25 deletions(-) diff --git a/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/RaptorRequestMapperTest.java b/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/RaptorRequestMapperTest.java index b58b237a630..1f6957893d4 100644 --- a/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/RaptorRequestMapperTest.java +++ b/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/RaptorRequestMapperTest.java @@ -107,7 +107,7 @@ void testViaLocation() { assertTrue(result.searchParams().hasViaLocations()); assertEquals( - "[Via{label: Via A, minWaitTime: 13m, connections: [(stop 0, 13m)]}]", + "[RaptorViaLocation{via Via A wait 13m : [(stop 0, 13m)]}]", result.searchParams().viaLocations().toString() ); } @@ -142,7 +142,7 @@ void testViaCoordinate() { assertFalse(result.searchParams().viaLocations().isEmpty()); assertEquals( - "[Via{label: Via coordinate, minWaitTime: 10m, connections: [(stop 47 ~ 123, 10m10s)]}]", + "[RaptorViaLocation{via Via coordinate wait 10m : [(stop 47 ~ 123, 10m10s)]}]", result.searchParams().viaLocations().toString() ); } @@ -282,7 +282,7 @@ private static void assertFeatureSet( assertTrue(result.searchParams().hasViaLocations()); // One via location exist(no NPE), but it does not allow pass-through assertEquals( - "Via{label: Via A, connections: [(stop 0)]}", + "RaptorViaLocation{via Via A : [(stop 0)]}", result.searchParams().viaLocations().get(0).toString() ); } diff --git a/raptor/src/main/java/org/opentripplanner/raptor/api/request/RaptorViaLocation.java b/raptor/src/main/java/org/opentripplanner/raptor/api/request/RaptorViaLocation.java index a761e0ffaa6..36ab03f39a6 100644 --- a/raptor/src/main/java/org/opentripplanner/raptor/api/request/RaptorViaLocation.java +++ b/raptor/src/main/java/org/opentripplanner/raptor/api/request/RaptorViaLocation.java @@ -23,18 +23,18 @@ public final class RaptorViaLocation { private static final int MIN_WAIT_TIME = (int) Duration.ZERO.toSeconds(); private final String label; - private final boolean passThroughAllowed; + private final boolean passThroughSearch; private final int minimumWaitTime; private final List connections; private RaptorViaLocation( String label, - boolean passThroughAllowed, + boolean passThroughSearch, Duration minimumWaitTime, List connections ) { this.label = label; - this.passThroughAllowed = passThroughAllowed; + this.passThroughSearch = passThroughSearch; this.minimumWaitTime = IntUtils.requireInRange( (int) minimumWaitTime.toSeconds(), @@ -75,8 +75,8 @@ public String label() { return label; } - public boolean isPassThroughAllowed() { - return passThroughAllowed; + public boolean isPassThroughSearch() { + return passThroughSearch; } public int minimumWaitTime() { @@ -87,10 +87,6 @@ public List connections() { return connections; } - public String toString() { - return toString(Integer::toString); - } - @Override public boolean equals(Object o) { throw new UnsupportedOperationException("No need to compare " + getClass()); @@ -101,20 +97,21 @@ public int hashCode() { throw new UnsupportedOperationException("No need for hashCode of " + getClass()); } + public String toString() { + return toString(Integer::toString); + } + public String toString(RaptorStopNameResolver stopNameResolver) { - var buf = new StringBuilder("Via{"); + var buf = new StringBuilder(getClass().getSimpleName()).append('{'); + buf.append(isPassThroughSearch() ? "pass-through " : "via "); if (label != null) { - buf.append("label: ").append(label).append(", "); - } - if (passThroughAllowed) { - buf.append("allowPassThrough, "); + buf.append(label).append(" "); } if (minimumWaitTime > RaptorConstants.ZERO) { - buf.append("minWaitTime: ").append(DurationUtils.durationToStr(minimumWaitTime)).append(", "); + buf.append("wait ").append(DurationUtils.durationToStr(minimumWaitTime)).append(" "); } buf - .append("connections") - .append(connections.size() <= 10 ? ": " : "(10/" + connections.size() + "):") + .append(connections.size() <= 10 ? ": " : "(10/" + connections.size() + "): ") .append(connections.stream().limit(10).map(it -> it.toString(stopNameResolver)).toList()); return buf.append("}").toString(); } diff --git a/raptor/src/test/java/org/opentripplanner/raptor/api/request/RaptorViaLocationTest.java b/raptor/src/test/java/org/opentripplanner/raptor/api/request/RaptorViaLocationTest.java index 2b5c43d2eb0..0c6a86d3add 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/api/request/RaptorViaLocationTest.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/api/request/RaptorViaLocationTest.java @@ -58,8 +58,8 @@ class RaptorViaLocationTest implements RaptorTestConstants { @Test void passThrough() { - assertFalse(subject.isPassThroughAllowed()); - assertTrue(subjectPassThrough.isPassThroughAllowed()); + assertFalse(subject.isPassThroughSearch()); + assertTrue(subjectPassThrough.isPassThroughSearch()); } @Test @@ -72,16 +72,16 @@ void connections() { @Test void testToString() { assertEquals( - "Via{label: Via, minWaitTime: 23s, connections: [(stop 2 ~ 3, 53s), (stop 1, 23s)]}", + "RaptorViaLocation{via Via wait 23s : [(stop 2 ~ 3, 53s), (stop 1, 23s)]}", subject.toString() ); assertEquals( - "Via{label: PassThrough, allowPassThrough, connections: [(stop 4)]}", + "RaptorViaLocation{pass-through PassThrough : [(stop 4)]}", subjectPassThrough.toString() ); assertEquals( - "Via{label: Via, minWaitTime: 23s, connections: [(stop B ~ C, 53s), (stop A, 23s)]}", + "RaptorViaLocation{via Via wait 23s : [(stop B ~ C, 53s), (stop A, 23s)]}", subject.toString(RaptorTestConstants::stopIndexToName) ); } From 801bd1e99016a034afd62e067a61508d85c897ac Mon Sep 17 00:00:00 2001 From: Thomas Gran Date: Thu, 20 Feb 2025 12:44:20 +0100 Subject: [PATCH 23/69] feature: Use the new viaLocation request parameters for pass-through The old multi-criteria pass-through parameters does not work any more. --- .../api/request/MultiCriteriaRequest.java | 30 ++----- .../raptor/api/request/RaptorViaLocation.java | 18 ++++ .../raptor/api/request/SearchParams.java | 18 ++++ .../raptor/configure/RaptorConfig.java | 7 +- .../context/SearchContextBuilder.java | 17 ++-- .../configure/McRangeRaptorConfig.java | 24 ++++-- .../BitSetPassThroughPointsService.java | 10 +-- .../api/request/MultiCriteriaRequestTest.java | 41 +--------- .../api/request/RaptorViaLocationTest.java | 21 +++++ .../raptor/api/request/SearchParamsTest.java | 82 +++++++++++++++++-- .../moduletests/J01_PassThroughTest.java | 82 +++++++++---------- .../BitSetPassThroughPointsServiceTest.java | 7 +- 12 files changed, 219 insertions(+), 138 deletions(-) diff --git a/raptor/src/main/java/org/opentripplanner/raptor/api/request/MultiCriteriaRequest.java b/raptor/src/main/java/org/opentripplanner/raptor/api/request/MultiCriteriaRequest.java index 7f0da11b558..af623f64d6f 100644 --- a/raptor/src/main/java/org/opentripplanner/raptor/api/request/MultiCriteriaRequest.java +++ b/raptor/src/main/java/org/opentripplanner/raptor/api/request/MultiCriteriaRequest.java @@ -20,22 +20,18 @@ public class MultiCriteriaRequest { @Nullable private final RaptorTransitGroupPriorityCalculator transitPriorityCalculator; - private final List passThroughPoints; - @Nullable private final Double relaxCostAtDestination; private MultiCriteriaRequest() { this.relaxC1 = RelaxFunction.NORMAL; this.transitPriorityCalculator = null; - this.passThroughPoints = List.of(); this.relaxCostAtDestination = null; } public MultiCriteriaRequest(Builder builder) { this.relaxC1 = Objects.requireNonNull(builder.relaxC1()); this.transitPriorityCalculator = builder.transitPriorityCalculator(); - this.passThroughPoints = builder.passThroughPoints(); this.relaxCostAtDestination = builder.relaxCostAtDestination(); } @@ -68,11 +64,11 @@ public Optional transitPriorityCalculator( } public boolean hasPassThroughPoints() { - return !passThroughPoints.isEmpty(); + throw new UnsupportedOperationException(); } public List passThroughPoints() { - return passThroughPoints; + throw new UnsupportedOperationException(); } /** @@ -106,19 +102,13 @@ public boolean equals(Object o) { return ( Objects.equals(relaxC1, that.relaxC1) && Objects.equals(transitPriorityCalculator, that.transitPriorityCalculator) && - Objects.equals(passThroughPoints, that.passThroughPoints) && Objects.equals(relaxCostAtDestination, that.relaxCostAtDestination) ); } @Override public int hashCode() { - return Objects.hash( - relaxC1, - transitPriorityCalculator, - passThroughPoints, - relaxCostAtDestination - ); + return Objects.hash(relaxC1, transitPriorityCalculator, relaxCostAtDestination); } @Override @@ -127,27 +117,20 @@ public String toString() { .of(MultiCriteriaRequest.class) .addObj("relaxC1", relaxC1, RelaxFunction.NORMAL) .addObj("transitPriorityCalculator", transitPriorityCalculator) - .addObj("passThroughPoints", passThroughPoints) .addNum("relaxCostAtDestination", relaxCostAtDestination) .toString(); } - public boolean includeC2() { - return hasPassThroughPoints() || transitPriorityCalculator != null; - } - public static class Builder { private final MultiCriteriaRequest original; private RelaxFunction relaxC1; private RaptorTransitGroupPriorityCalculator transitPriorityCalculator; - private List passThroughPoints; private Double relaxCostAtDestination; public Builder(MultiCriteriaRequest original) { this.original = original; this.relaxC1 = original.relaxC1; - this.passThroughPoints = original.passThroughPoints; this.transitPriorityCalculator = original.transitPriorityCalculator; this.relaxCostAtDestination = original.relaxCostAtDestination; } @@ -173,14 +156,12 @@ public Builder withTransitPriorityCalculator(RaptorTransitGroupPriorityCalcul } public List passThroughPoints() { - return passThroughPoints; + throw new UnsupportedOperationException(); } @Nullable public Builder withPassThroughPoints(List points) { - // Prevent setting this to an empty list - here we use null to represent NOT_SET - passThroughPoints = (points == null || points.isEmpty()) ? List.of() : points; - return this; + throw new UnsupportedOperationException(); } @Nullable @@ -206,7 +187,6 @@ public String toString() { .of(MultiCriteriaRequest.Builder.class) .addObj("relaxC1", relaxC1) .addObj("transitPriorityCalculator", transitPriorityCalculator) - .addObj("passThroughPoints", passThroughPoints) .addNum("relaxCostAtDestination", relaxCostAtDestination) .toString(); } diff --git a/raptor/src/main/java/org/opentripplanner/raptor/api/request/RaptorViaLocation.java b/raptor/src/main/java/org/opentripplanner/raptor/api/request/RaptorViaLocation.java index 36ab03f39a6..5343b34e977 100644 --- a/raptor/src/main/java/org/opentripplanner/raptor/api/request/RaptorViaLocation.java +++ b/raptor/src/main/java/org/opentripplanner/raptor/api/request/RaptorViaLocation.java @@ -2,7 +2,9 @@ import java.time.Duration; import java.util.ArrayList; +import java.util.BitSet; import java.util.List; +import java.util.stream.IntStream; import javax.annotation.Nullable; import org.opentripplanner.raptor.api.model.RaptorConstants; import org.opentripplanner.raptor.api.model.RaptorStopNameResolver; @@ -87,6 +89,17 @@ public List connections() { return connections; } + /** + * This is a convenient accessor method used inside Raptor. It converts the list stops to a + * bit-set. Add other access methods if needed. + */ + public BitSet asBitSet() { + return connections + .stream() + .mapToInt(RaptorViaConnection::fromStop) + .collect(BitSet::new, BitSet::set, BitSet::or); + } + @Override public boolean equals(Object o) { throw new UnsupportedOperationException("No need to compare " + getClass()); @@ -188,6 +201,11 @@ public BuilderPassThrough addPassThroughStop(int stop) { return this; } + public BuilderPassThrough addPassThroughStops(int... stops) { + IntStream.of(stops).forEach(this::addPassThroughStop); + return this; + } + public RaptorViaLocation build() { return new RaptorViaLocation(label, true, Duration.ZERO, connections); } diff --git a/raptor/src/main/java/org/opentripplanner/raptor/api/request/SearchParams.java b/raptor/src/main/java/org/opentripplanner/raptor/api/request/SearchParams.java index d43d0f11ab6..b4ab5cf6261 100644 --- a/raptor/src/main/java/org/opentripplanner/raptor/api/request/SearchParams.java +++ b/raptor/src/main/java/org/opentripplanner/raptor/api/request/SearchParams.java @@ -280,6 +280,20 @@ public String toString() { .toString(); } + public boolean isVisitViaSearch() { + return ( + !viaLocations.isEmpty() && + viaLocations.stream().noneMatch(RaptorViaLocation::isPassThroughSearch) + ); + } + + public boolean isPassThroughSearch() { + return ( + !viaLocations.isEmpty() && + viaLocations.stream().allMatch(RaptorViaLocation::isPassThroughSearch) + ); + } + static SearchParams defaults() { return new SearchParams(); } @@ -305,5 +319,9 @@ void verify() { viaLocations.size() <= MAX_VIA_POINTS, "The 'viaLocations' exceeds the maximum number of via-locations (" + MAX_VIA_POINTS + ")." ); + assertProperty( + viaLocations.isEmpty() || isVisitViaSearch() || isPassThroughSearch(), + "Combining pass-through and regular via-vist it is not allowed: " + viaLocations + "." + ); } } diff --git a/raptor/src/main/java/org/opentripplanner/raptor/configure/RaptorConfig.java b/raptor/src/main/java/org/opentripplanner/raptor/configure/RaptorConfig.java index 66d72900889..282e1b43015 100644 --- a/raptor/src/main/java/org/opentripplanner/raptor/configure/RaptorConfig.java +++ b/raptor/src/main/java/org/opentripplanner/raptor/configure/RaptorConfig.java @@ -104,7 +104,7 @@ private RaptorRouter createRangeRaptorWithMcWorker( RangeRaptorWorker worker = null; McStopArrivals nextStopArrivals = null; - if (request.searchParams().hasViaLocations()) { + if (request.searchParams().isVisitViaSearch()) { for (SearchContextViaLeg cxLeg : context.legs().reversed()) { var c = new McRangeRaptorConfig<>(cxLeg, passThroughPointsService) .connectWithNextLegArrivals(nextStopArrivals); @@ -163,7 +163,10 @@ public RaptorSearchWindowCalculator searchWindowCalculator() { /* private factory methods */ private static PassThroughPointsService createPassThroughPointsService(RaptorRequest request) { - return McRangeRaptorConfig.passThroughPointsService(request.multiCriteria()); + return McRangeRaptorConfig.createPassThroughPointsService( + request.searchParams().isPassThroughSearch(), + request.searchParams().viaLocations() + ); } private RangeRaptorWorker createWorker( diff --git a/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/context/SearchContextBuilder.java b/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/context/SearchContextBuilder.java index e0a6725c5c0..025886f9815 100644 --- a/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/context/SearchContextBuilder.java +++ b/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/context/SearchContextBuilder.java @@ -34,21 +34,13 @@ public SearchContextBuilder( } public SearchContext build() { - return createContext(accessPaths(), viaConnections(), egressPaths()); - } - - private SearchContext createContext( - AccessPaths accessPaths, - List viaConnections, - EgressPaths egressPaths - ) { return new SearchContext<>( request, tuningParameters, transit, - accessPaths, - viaConnections, - egressPaths, + accessPaths(), + viaConnections(), + egressPaths(), acceptC2AtDestination ); } @@ -62,7 +54,8 @@ private AccessPaths accessPaths() { } private List viaConnections() { - return request.searchParams().hasViaLocations() + // TODO VIA - This need to be changed if we allow mixing visit-via an pass-thorugh + return request.searchParams().isVisitViaSearch() ? request .searchParams() .viaLocations() diff --git a/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/multicriteria/configure/McRangeRaptorConfig.java b/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/multicriteria/configure/McRangeRaptorConfig.java index f7d35b619a8..b74a49ce430 100644 --- a/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/multicriteria/configure/McRangeRaptorConfig.java +++ b/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/multicriteria/configure/McRangeRaptorConfig.java @@ -7,6 +7,7 @@ import org.opentripplanner.raptor.api.model.RaptorTripSchedule; import org.opentripplanner.raptor.api.request.MultiCriteriaRequest; import org.opentripplanner.raptor.api.request.RaptorTransitGroupPriorityCalculator; +import org.opentripplanner.raptor.api.request.RaptorViaLocation; import org.opentripplanner.raptor.rangeraptor.context.SearchContext; import org.opentripplanner.raptor.rangeraptor.context.SearchContextViaLeg; import org.opentripplanner.raptor.rangeraptor.internalapi.Heuristics; @@ -63,14 +64,18 @@ public McRangeRaptorConfig( } /** - * The PassThroughPointsService is injected into the transit-calculator, so it needs to be - * created before the context(which create the calculator).So, to be able to do this, this - * factory is static, and the service is passed back in when this config is instantiated. + * Static factory method to allow the {@link org.opentripplanner.raptor.configure.RaptorConfig} + * inject PassThroughPointsService. + * TODO VIA - This method is not needed when pass-through is poted to use the chanied-worker + * strategy, and not c2. */ - public static PassThroughPointsService passThroughPointsService( - MultiCriteriaRequest multiCriteriaRequest + public static PassThroughPointsService createPassThroughPointsService( + boolean enableMcPassThrought, + List viaLocations ) { - return BitSetPassThroughPointsService.of(multiCriteriaRequest.passThroughPoints()); + return enableMcPassThrought + ? BitSetPassThroughPointsService.of(viaLocations) + : BitSetPassThroughPointsService.NOOP; } /** @@ -231,7 +236,10 @@ private MultiCriteriaRequest mcRequest() { * transit-group-priority features uses the c2 value. */ private boolean includeC2() { - return mcRequest().includeC2(); + return ( + context().searchParams().isPassThroughSearch() || + mcRequest().transitPriorityCalculator().isPresent() + ); } private PatternRideFactory> createPatternRideC2Factory() { @@ -260,7 +268,7 @@ private RaptorTransitGroupPriorityCalculator getTransitGroupPriorityCalculator() } private boolean isPassThrough() { - return mcRequest().hasPassThroughPoints(); + return context().searchParams().isPassThroughSearch(); } private boolean isTransitPriority() { diff --git a/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/multicriteria/passthrough/BitSetPassThroughPointsService.java b/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/multicriteria/passthrough/BitSetPassThroughPointsService.java index 8780980f790..92c6ea65e97 100644 --- a/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/multicriteria/passthrough/BitSetPassThroughPointsService.java +++ b/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/multicriteria/passthrough/BitSetPassThroughPointsService.java @@ -9,7 +9,7 @@ import java.util.function.IntPredicate; import org.opentripplanner.raptor.api.model.DominanceFunction; import org.opentripplanner.raptor.api.model.RaptorConstants; -import org.opentripplanner.raptor.api.request.PassThroughPoint; +import org.opentripplanner.raptor.api.request.RaptorViaLocation; import org.opentripplanner.raptor.rangeraptor.internalapi.PassThroughPointsService; /** @@ -31,12 +31,12 @@ private BitSetPassThroughPointsService(final List passThroughPoints) { this.expectedC2ValueAtDestination = passThroughPoints.size(); } - public static PassThroughPointsService of(List points) { - return points == null || points.isEmpty() + public static PassThroughPointsService of(List locations) { + return locations == null || locations.isEmpty() ? NOOP - : points + : locations .stream() - .map(PassThroughPoint::asBitSet) + .map(RaptorViaLocation::asBitSet) .collect(collectingAndThen(toList(), BitSetPassThroughPointsService::new)); } diff --git a/raptor/src/test/java/org/opentripplanner/raptor/api/request/MultiCriteriaRequestTest.java b/raptor/src/test/java/org/opentripplanner/raptor/api/request/MultiCriteriaRequestTest.java index 8468af54401..396f7567f08 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/api/request/MultiCriteriaRequestTest.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/api/request/MultiCriteriaRequestTest.java @@ -1,12 +1,9 @@ package org.opentripplanner.raptor.api.request; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertSame; -import static org.junit.jupiter.api.Assertions.assertTrue; -import java.util.List; import org.junit.jupiter.api.Test; import org.opentripplanner.raptor.api.model.GeneralizedCostRelaxFunction; import org.opentripplanner.raptor.api.model.RaptorTripSchedule; @@ -16,14 +13,9 @@ class MultiCriteriaRequestTest { private static final RelaxFunction RELAX_C1 = GeneralizedCostRelaxFunction.of(2.0, 600); - private static final List PASS_THROUGH_POINTS = List.of( - new PassThroughPoint(null, 7, 13) - ); - private final MultiCriteriaRequest subject = MultiCriteriaRequest .of() .withRelaxC1(RELAX_C1) - .withPassThroughPoints(PASS_THROUGH_POINTS) .build(); @Test @@ -35,10 +27,10 @@ void copyOf() { subject, subject .copyOf() - .withPassThroughPoints(null) + .withRelaxC1(RelaxFunction.NORMAL) .build() .copyOf() - .withPassThroughPoints(PASS_THROUGH_POINTS) + .withRelaxC1(RELAX_C1) .build() ); // Change another filed - build - make a new copy and set same value => should be equal @@ -59,46 +51,21 @@ void relaxC1() { assertEquals(RELAX_C1, subject.relaxC1()); } - @Test - void passThroughPoints() { - assertEquals(PASS_THROUGH_POINTS, subject.passThroughPoints()); - } - @Test void testEqualsAndHashCode() { - var eq = MultiCriteriaRequest - .of() - .withRelaxC1(RELAX_C1) - .withPassThroughPoints(PASS_THROUGH_POINTS) - .build(); + var eq = MultiCriteriaRequest.of().withRelaxC1(RELAX_C1).build(); var noRelaxC1 = subject.copyOf().withRelaxC1(RelaxFunction.NORMAL).build(); - var noPassThroughPoint = subject.copyOf().withPassThroughPoints(null).build(); assertEquals(subject, subject); assertEquals(subject, eq); assertNotEquals(subject, noRelaxC1); - assertNotEquals(subject, noPassThroughPoint); assertEquals(subject.hashCode(), eq.hashCode()); assertNotEquals(subject.hashCode(), noRelaxC1.hashCode()); - assertNotEquals(subject.hashCode(), noPassThroughPoint.hashCode()); } @Test void testToString() { - assertEquals( - "MultiCriteriaRequest{relaxC1: f(x) = 2.00 * x + 6.0, passThroughPoints: [(stops: 7, 13)]}", - subject.toString() - ); - } - - @Test - void includeC2() { - assertTrue(subject.includeC2()); - assertFalse(MultiCriteriaRequest.of().build().includeC2()); - assertTrue( - MultiCriteriaRequest.of().withPassThroughPoints(PASS_THROUGH_POINTS).build().includeC2() - ); - assertFalse(MultiCriteriaRequest.of().withRelaxC1(RELAX_C1).build().includeC2()); + assertEquals("MultiCriteriaRequest{relaxC1: f(x) = 2.00 * x + 6.0}", subject.toString()); } } diff --git a/raptor/src/test/java/org/opentripplanner/raptor/api/request/RaptorViaLocationTest.java b/raptor/src/test/java/org/opentripplanner/raptor/api/request/RaptorViaLocationTest.java index 0c6a86d3add..4e7daea2430 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/api/request/RaptorViaLocationTest.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/api/request/RaptorViaLocationTest.java @@ -186,6 +186,27 @@ void isBetterThan( assertEquals(subject.isBetterOrEqual(candidate), expected, description); } + @Test + void asBitSet() { + var subject = RaptorViaLocation + .passThrough(VIA_LABEL) + .addPassThroughStop(2) + .addPassThroughStop(7) + .addPassThroughStop(13) + .build(); + + var bitSet = subject.asBitSet(); + + // Sample some all set values as well as some not set values + assertFalse(bitSet.get(0)); + assertTrue(bitSet.get(2)); + assertFalse(bitSet.get(3)); + assertFalse(bitSet.get(6)); + assertTrue(bitSet.get(7)); + assertTrue(bitSet.get(13)); + assertFalse(bitSet.get(15000000)); + } + @Test void testEqualsAndHAshCode() { var viaTxConnection = RaptorViaLocation diff --git a/raptor/src/test/java/org/opentripplanner/raptor/api/request/SearchParamsTest.java b/raptor/src/test/java/org/opentripplanner/raptor/api/request/SearchParamsTest.java index 0a27c5a1575..da69623a32d 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/api/request/SearchParamsTest.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/api/request/SearchParamsTest.java @@ -1,15 +1,21 @@ package org.opentripplanner.raptor.api.request; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; +import java.util.Collection; +import java.util.List; import org.junit.jupiter.api.Test; +import org.opentripplanner.raptor._data.RaptorTestConstants; import org.opentripplanner.raptor._data.transit.TestAccessEgress; import org.opentripplanner.raptor._data.transit.TestTripSchedule; class SearchParamsTest { @Test - public void earliestDepartureTimeOrLatestArrivalTimeIsRequired() { + void earliestDepartureTimeOrLatestArrivalTimeIsRequired() { var p = new RaptorRequestBuilder().searchParams(); p.addAccessPaths(TestAccessEgress.walk(1, 30)); p.addEgressPaths(TestAccessEgress.walk(2, 20)); @@ -18,7 +24,7 @@ public void earliestDepartureTimeOrLatestArrivalTimeIsRequired() { } @Test - public void accessPathIsRequired() { + void accessPathIsRequired() { var p = new RaptorRequestBuilder().searchParams(); p.earliestDepartureTime(200); p.latestArrivalTime(600); @@ -28,7 +34,7 @@ public void accessPathIsRequired() { } @Test - public void egressPathIsRequired() { + void egressPathIsRequired() { var p = new RaptorRequestBuilder().searchParams(); p.earliestDepartureTime(200); p.latestArrivalTime(600); @@ -38,7 +44,7 @@ public void egressPathIsRequired() { } @Test - public void latestArrivalTimeRequiredWhenDepartAsLateAsPossibleEnabled() { + void latestArrivalTimeRequiredWhenDepartAsLateAsPossibleEnabled() { var p = new RaptorRequestBuilder().searchParams(); p.earliestDepartureTime(200); p.addAccessPaths(TestAccessEgress.walk(1, 30)); @@ -53,7 +59,7 @@ public void latestArrivalTimeRequiredWhenDepartAsLateAsPossibleEnabled() { } @Test - public void departAsLateAsPossibleAndTimetableEnabled() { + void departAsLateAsPossibleAndTimetableEnabled() { var p = new RaptorRequestBuilder().searchParams(); p.latestArrivalTime(200); p.addAccessPaths(TestAccessEgress.walk(1, 30)); @@ -68,7 +74,71 @@ public void departAsLateAsPossibleAndTimetableEnabled() { ); } - public void assertParamNotValid(SearchParamsBuilder p, String msg) { + @Test + void viaAndPassThrough() { + var noVia = new RaptorRequestBuilder().searchParams().buildSearchParam(); + var via = new RaptorRequestBuilder() + .searchParams() + .addViaLocation(RaptorViaLocation.via("Via").addViaStop(5).build()) + .buildSearchParam(); + var passThrough = new RaptorRequestBuilder() + .searchParams() + .addViaLocation(RaptorViaLocation.passThrough("Via").addPassThroughStop(5).build()) + .buildSearchParam(); + + assertFalse(noVia.isVisitViaSearch()); + assertTrue(via.isVisitViaSearch()); + assertFalse(passThrough.isVisitViaSearch()); + + assertFalse(noVia.isPassThroughSearch()); + assertFalse(via.isPassThroughSearch()); + assertTrue(passThrough.isPassThroughSearch()); + + assertEquals("[]", toString(noVia.viaLocations())); + assertEquals("[RaptorViaLocation{via Via : [(stop E)]}]", toString(via.viaLocations())); + assertEquals( + "[RaptorViaLocation{pass-through Via : [(stop E)]}]", + toString(passThrough.viaLocations()) + ); + } + + @Test + void addBothViaAndPassThroughIsNotSupported() { + var ex = assertThrows( + IllegalArgumentException.class, + () -> + new RaptorRequestBuilder() + .searchParams() + .earliestDepartureTime(1) + .latestArrivalTime(1200) + .addAccessPaths(TestAccessEgress.walk(1, 30)) + .addEgressPaths(TestAccessEgress.walk(7, 30)) + .addViaLocations( + List.of( + RaptorViaLocation.via("Via").addViaStop(5).build(), + RaptorViaLocation.passThrough("PassThrough").addPassThroughStop(5).build() + ) + ) + .build() + ); + assertEquals( + "Combining pass-through and regular via-vist it is not allowed: [" + + "RaptorViaLocation{via Via : [(stop 5)]}, " + + "RaptorViaLocation{pass-through PassThrough : [(stop 5)]}" + + "].", + ex.getMessage() + ); + } + + void assertParamNotValid(SearchParamsBuilder p, String msg) { assertThrows(IllegalArgumentException.class, p::build, msg); } + + private static String toString(Collection viaLocations) { + return viaLocations + .stream() + .map(it -> it.toString(RaptorTestConstants::stopIndexToName)) + .toList() + .toString(); + } } diff --git a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/J01_PassThroughTest.java b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/J01_PassThroughTest.java index 6047280488a..ddfd42ff9eb 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/J01_PassThroughTest.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/J01_PassThroughTest.java @@ -12,20 +12,21 @@ import static org.opentripplanner.raptor._data.RaptorTestConstants.T00_00; import static org.opentripplanner.raptor._data.RaptorTestConstants.T01_00; import static org.opentripplanner.raptor._data.api.PathUtils.pathsToString; +import static org.opentripplanner.raptor._data.transit.TestAccessEgress.walk; import static org.opentripplanner.raptor._data.transit.TestRoute.route; import static org.opentripplanner.raptor._data.transit.TestTripSchedule.schedule; +import static org.opentripplanner.raptor.api.request.RaptorViaLocation.passThrough; import java.time.Duration; import java.util.List; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.opentripplanner.raptor.RaptorService; -import org.opentripplanner.raptor._data.transit.TestAccessEgress; import org.opentripplanner.raptor._data.transit.TestTransitData; import org.opentripplanner.raptor._data.transit.TestTripSchedule; -import org.opentripplanner.raptor.api.request.PassThroughPoint; import org.opentripplanner.raptor.api.request.RaptorProfile; import org.opentripplanner.raptor.api.request.RaptorRequestBuilder; +import org.opentripplanner.raptor.api.request.RaptorViaLocation; import org.opentripplanner.raptor.configure.RaptorConfig; /** @@ -46,19 +47,25 @@ */ class J01_PassThroughTest { - static final List PASS_THROUGH_STOP_A = List.of(point("A", STOP_A)); - static final List PASS_THROUGH_STOP_C = List.of(point("C", STOP_C)); - static final List PASS_THROUGH_STOP_D = List.of(point("D", STOP_D)); - static final List PASS_THROUGH_STOP_B_OR_C = List.of( - point("B&C", STOP_B, STOP_C) + static final RaptorViaLocation PASS_THROUGH_STOP_A = passThrough("A") + .addPassThroughStop(STOP_A) + .build(); + static final RaptorViaLocation PASS_THROUGH_STOP_C = passThrough("C") + .addPassThroughStop(STOP_C) + .build(); + static final RaptorViaLocation PASS_THROUGH_STOP_D = passThrough("D") + .addPassThroughStop(STOP_D) + .build(); + static final List PASS_THROUGH_STOP_B_OR_C = List.of( + passThrough("B&C").addPassThroughStop(STOP_B).addPassThroughStop(STOP_C).build() ); - static final List PASS_THROUGH_STOP_B_THEN_C = List.of( - point("B", STOP_B), - point("C", STOP_C) + static final List PASS_THROUGH_STOP_B_THEN_C = List.of( + passThrough("B").addPassThroughStop(STOP_B).build(), + passThrough("C").addPassThroughStop(STOP_C).build() ); - static final List PASS_THROUGH_STOP_B_THEN_D = List.of( - point("B", STOP_B), - point("D", STOP_D) + static final List PASS_THROUGH_STOP_B_THEN_D = List.of( + passThrough("B").addPassThroughStop(STOP_B).build(), + passThrough("D").addPassThroughStop(STOP_D).build() ); private final RaptorService raptorService = new RaptorService<>( @@ -102,11 +109,11 @@ void passThroughPointOnEgress() { var requestBuilder = prepareRequest(); requestBuilder - .withMultiCriteria(mc -> mc.withPassThroughPoints(PASS_THROUGH_STOP_D)) .searchParams() - .addAccessPaths(TestAccessEgress.walk(STOP_A, D30s)) - .addEgressPaths(TestAccessEgress.walk(STOP_D, D30s)) - .addEgressPaths(TestAccessEgress.walk(STOP_C, D30s)); + .addAccessPaths(walk(STOP_A, D30s)) + .addViaLocation(PASS_THROUGH_STOP_D) + .addEgressPaths(walk(STOP_D, D30s)) + .addEgressPaths(walk(STOP_C, D30s)); // Verify that only the journey with pass-through stop point is included in response assertEquals( @@ -133,14 +140,11 @@ void passThroughPointOnAccess() { var requestBuilder = prepareRequest(); requestBuilder - .withMultiCriteria(mc -> - // Include desired pass-through point in the request - mc.withPassThroughPoints(PASS_THROUGH_STOP_A) - ) .searchParams() - .addAccessPaths(TestAccessEgress.walk(STOP_A, D30s)) - .addAccessPaths(TestAccessEgress.walk(STOP_B, D30s)) - .addEgressPaths(TestAccessEgress.walk(STOP_D, D30s)); + .addAccessPaths(walk(STOP_A, D30s)) + .addAccessPaths(walk(STOP_B, D30s)) + .addViaLocation(PASS_THROUGH_STOP_A) + .addEgressPaths(walk(STOP_D, D30s)); // Verify that only the journey with pass-through stop point is included in response assertEquals( @@ -168,10 +172,10 @@ void passThroughPointInTheMiddle() { var requestBuilder = prepareRequest(); requestBuilder - .withMultiCriteria(mc -> mc.withPassThroughPoints(PASS_THROUGH_STOP_C)) .searchParams() - .addAccessPaths(TestAccessEgress.walk(STOP_A, D30s)) - .addEgressPaths(TestAccessEgress.walk(STOP_D, D30s)); + .addAccessPaths(walk(STOP_A, D30s)) + .addViaLocation(PASS_THROUGH_STOP_C) + .addEgressPaths(walk(STOP_D, D30s)); // Verify that only the journey with pass-through stop point is included in response assertEquals( @@ -200,10 +204,10 @@ void multiplePassThroughPoints() { var requestBuilder = prepareRequest(); requestBuilder - .withMultiCriteria(mc -> mc.withPassThroughPoints(PASS_THROUGH_STOP_B_THEN_D)) .searchParams() - .addAccessPaths(TestAccessEgress.walk(STOP_A, D30s)) - .addEgressPaths(TestAccessEgress.walk(STOP_F, D30s)); + .addAccessPaths(walk(STOP_A, D30s)) + .addViaLocations(PASS_THROUGH_STOP_B_THEN_D) + .addEgressPaths(walk(STOP_F, D30s)); // Verify that Raptor generated journey with a transfer to r2 so that both pass-through points // are included @@ -230,10 +234,10 @@ void passThroughOrder() { var requestBuilder = prepareRequest(); requestBuilder - .withMultiCriteria(mc -> mc.withPassThroughPoints(PASS_THROUGH_STOP_B_THEN_C)) .searchParams() - .addAccessPaths(TestAccessEgress.walk(STOP_A, D30s)) - .addEgressPaths(TestAccessEgress.walk(STOP_D, D30s)); + .addAccessPaths(walk(STOP_A, D30s)) + .addViaLocations(PASS_THROUGH_STOP_B_THEN_C) + .addEgressPaths(walk(STOP_D, D30s)); // Verify that only route with correct pass-through order is returned assertEquals( @@ -259,13 +263,13 @@ void passThroughGroup() { var requestBuilder = prepareRequest(); requestBuilder - .withMultiCriteria(mc -> mc.withPassThroughPoints(PASS_THROUGH_STOP_B_OR_C)) .searchParams() // Both routes are pareto optimal. // Route 2 is faster but it contains more walk - .addAccessPaths(TestAccessEgress.walk(STOP_A, D30s)) - .addAccessPaths(TestAccessEgress.walk(STOP_B, D2m)) - .addEgressPaths(TestAccessEgress.walk(STOP_E, D30s)); + .addAccessPaths(walk(STOP_A, D30s)) + .addAccessPaths(walk(STOP_B, D2m)) + .addViaLocations(PASS_THROUGH_STOP_B_OR_C) + .addEgressPaths(walk(STOP_E, D30s)); // Verify that both routes are included as a valid result assertEquals( @@ -276,8 +280,4 @@ void passThroughGroup() { pathsToString(raptorService.route(requestBuilder.build(), data)) ); } - - private static PassThroughPoint point(String name, int... stops) { - return new PassThroughPoint(name, stops); - } } diff --git a/raptor/src/test/java/org/opentripplanner/raptor/rangeraptor/multicriteria/passthrough/BitSetPassThroughPointsServiceTest.java b/raptor/src/test/java/org/opentripplanner/raptor/rangeraptor/multicriteria/passthrough/BitSetPassThroughPointsServiceTest.java index 1d443cd2f9b..53e76668037 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/rangeraptor/multicriteria/passthrough/BitSetPassThroughPointsServiceTest.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/rangeraptor/multicriteria/passthrough/BitSetPassThroughPointsServiceTest.java @@ -12,7 +12,7 @@ import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; -import org.opentripplanner.raptor.api.request.PassThroughPoint; +import org.opentripplanner.raptor.api.request.RaptorViaLocation; import org.opentripplanner.raptor.rangeraptor.internalapi.PassThroughPointsService; class BitSetPassThroughPointsServiceTest { @@ -31,7 +31,10 @@ class BitSetPassThroughPointsServiceTest { private static final int STOP_31 = 6; private static final PassThroughPointsService SUBJECT = BitSetPassThroughPointsService.of( - List.of(new PassThroughPoint("PT1", STOPS_1), new PassThroughPoint("PT2", STOPS_2)) + List.of( + RaptorViaLocation.passThrough("PT1").addPassThroughStops(STOPS_1).build(), + RaptorViaLocation.passThrough("PT2").addPassThroughStops(STOPS_2).build() + ) ); /** * We expect the c2 value at the destination to be the same as the number of pass-through From 9b978b324e01ac8f2fa43674a806c04f072163bf Mon Sep 17 00:00:00 2001 From: Thomas Gran Date: Thu, 20 Feb 2025 13:07:16 +0100 Subject: [PATCH 24/69] feature: Use the new Raptor API for pass-through in application module --- .../raptoradapter/router/TransitRouter.java | 10 ++- .../transit/mappers/RaptorRequestMapper.java | 27 ++---- ...ansferOptimizationServiceConfigurator.java | 17 ++-- .../PassThroughPathTailFilter.java | 6 +- .../PassThroughPointsIterator.java | 18 ++-- .../passthrough/PathTailC2Calculator.java | 12 +-- .../routing/api/request/RouteRequest.java | 9 ++ .../mappers/RaptorRequestMapperTest.java | 24 +++--- .../model/passthrough/TestCase.java | 6 +- .../model/passthrough/TestCaseBuilder.java | 6 +- .../model/passthrough/TestUtils.java | 6 +- .../WalkDurationForStopCombinations.java | 6 +- .../routing/core/RouteRequestTest.java | 14 +++ .../api/request/MultiCriteriaRequest.java | 18 ---- .../raptor/api/request/PassThroughPoint.java | 85 ------------------- .../raptor/api/request/SearchParams.java | 4 - .../api/request/PassThroughPointTest.java | 49 ----------- 17 files changed, 85 insertions(+), 232 deletions(-) delete mode 100644 raptor/src/main/java/org/opentripplanner/raptor/api/request/PassThroughPoint.java delete mode 100644 raptor/src/test/java/org/opentripplanner/raptor/api/request/PassThroughPointTest.java diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/router/TransitRouter.java b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/router/TransitRouter.java index d71402129a2..b37c0639d8e 100644 --- a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/router/TransitRouter.java +++ b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/router/TransitRouter.java @@ -161,12 +161,14 @@ private TransitRouterResult route() { Collection> paths = transitResponse.paths(); - // TODO VIA Temporarily turn OptimizeTransfers OFF for VIA search until the service support via - // Remove '&& !request.isViaSearch()' + // TODO VIA - Temporarily turn OptimizeTransfers OFF for VIA search until the service support via + // Remove '&& !request.isViaSearch()' if ( OTPFeature.OptimizeTransfers.isOn() && !transitResponse.containsUnknownPaths() && - !request.isViaSearch() + // TODO VIA - This is temporary, we want pass via info in paths so transfer optimizer can + // skip legs containing via points. + request.allowTransferOptimization() ) { var service = TransferOptimizationServiceConfigurator.createOptimizeTransferService( raptorTransitData::getStopByIndex, @@ -175,7 +177,7 @@ private TransitRouterResult route() { requestTransitDataProvider, raptorTransitData.getStopBoardAlightTransferCosts(), request.preferences().transfer().optimization(), - raptorRequest.multiCriteria() + raptorRequest.searchParams().viaLocations() ); paths = service.optimize(transitResponse.paths()); } diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/RaptorRequestMapper.java b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/RaptorRequestMapper.java index 6d0fc9e2d7e..524ece2d7b3 100644 --- a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/RaptorRequestMapper.java +++ b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/RaptorRequestMapper.java @@ -20,7 +20,6 @@ import org.opentripplanner.raptor.api.request.DebugRequestBuilder; import org.opentripplanner.raptor.api.request.MultiCriteriaRequest; import org.opentripplanner.raptor.api.request.Optimization; -import org.opentripplanner.raptor.api.request.PassThroughPoint; import org.opentripplanner.raptor.api.request.RaptorRequest; import org.opentripplanner.raptor.api.request.RaptorRequestBuilder; import org.opentripplanner.raptor.api.request.RaptorViaLocation; @@ -138,17 +137,12 @@ private RaptorRequest doMap() { var pt = preferences.transit(); var r = pt.raptor(); - if (hasPassThroughOnly()) { - mcBuilder.withPassThroughPoints(mapPassThroughPoints()); - } else if (hasViaLocationsOnly()) { - builder.searchParams().addViaLocations(mapViaLocations()); - // relax transit group priority can be used with via-visit-stop, but not with pass-through - if (pt.isRelaxTransitGroupPrioritySet()) { - mapRelaxTransitGroupPriority(mcBuilder, pt); - } - } else if (pt.isRelaxTransitGroupPrioritySet()) { + builder.searchParams().addViaLocations(mapViaLocations()); + + // relax transit group priority can be used with via-visit-stop, but not with pass-through + if (pt.isRelaxTransitGroupPrioritySet() && !hasPassThroughOnly()) { mapRelaxTransitGroupPriority(mcBuilder, pt); - } else { + } else if (!request.isViaSearch()) { // The deprecated relaxGeneralizedCostAtDestination is only enabled, if there is no // via location and the relaxTransitGroupPriority is not used (Normal). r.relaxGeneralizedCostAtDestination().ifPresent(mcBuilder::withRelaxCostAtDestination); @@ -260,17 +254,6 @@ private RaptorViaLocation mapViaLocation(ViaLocation input) { } } - private List mapPassThroughPoints() { - return request.getViaLocations().stream().map(this::mapPassThroughPoints).toList(); - } - - private PassThroughPoint mapPassThroughPoints(ViaLocation location) { - return new PassThroughPoint( - location.label(), - lookUpStopIndex.lookupStopLocationIndexes(location.stopLocationIds()) - ); - } - static RelaxFunction mapRelaxCost(CostLinearFunction relax) { if (relax == null) { return null; diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/transferoptimization/configure/TransferOptimizationServiceConfigurator.java b/application/src/main/java/org/opentripplanner/routing/algorithm/transferoptimization/configure/TransferOptimizationServiceConfigurator.java index 214e79216e5..2945fc1b1df 100644 --- a/application/src/main/java/org/opentripplanner/routing/algorithm/transferoptimization/configure/TransferOptimizationServiceConfigurator.java +++ b/application/src/main/java/org/opentripplanner/routing/algorithm/transferoptimization/configure/TransferOptimizationServiceConfigurator.java @@ -1,11 +1,12 @@ package org.opentripplanner.routing.algorithm.transferoptimization.configure; +import java.util.List; import java.util.function.IntFunction; import javax.annotation.Nullable; import org.opentripplanner.model.transfer.TransferService; import org.opentripplanner.raptor.api.model.RaptorStopNameResolver; import org.opentripplanner.raptor.api.model.RaptorTripSchedule; -import org.opentripplanner.raptor.api.request.MultiCriteriaRequest; +import org.opentripplanner.raptor.api.request.RaptorViaLocation; import org.opentripplanner.raptor.spi.RaptorCostCalculator; import org.opentripplanner.raptor.spi.RaptorTransitDataProvider; import org.opentripplanner.routing.algorithm.transferoptimization.OptimizeTransferService; @@ -34,7 +35,7 @@ public class TransferOptimizationServiceConfigurator multiCriteriaRequest; + private final List viaLocations; private TransferOptimizationServiceConfigurator( IntFunction stopLookup, @@ -43,7 +44,7 @@ private TransferOptimizationServiceConfigurator( RaptorTransitDataProvider transitDataProvider, int[] stopBoardAlightTransferCosts, TransferOptimizationParameters config, - MultiCriteriaRequest multiCriteriaRequest + List viaLocations ) { this.stopLookup = stopLookup; this.stopNameResolver = stopNameResolver; @@ -51,7 +52,7 @@ private TransferOptimizationServiceConfigurator( this.transitDataProvider = transitDataProvider; this.stopBoardAlightTransferCosts = stopBoardAlightTransferCosts; this.config = config; - this.multiCriteriaRequest = multiCriteriaRequest; + this.viaLocations = viaLocations; } /** @@ -66,7 +67,7 @@ > OptimizeTransferService createOptimizeTransferService( RaptorTransitDataProvider transitDataProvider, @Nullable int[] stopBoardAlightTransferCosts, TransferOptimizationParameters config, - MultiCriteriaRequest multiCriteriaRequest + List viaLocations ) { return new TransferOptimizationServiceConfigurator( stopLookup, @@ -75,7 +76,7 @@ > OptimizeTransferService createOptimizeTransferService( transitDataProvider, stopBoardAlightTransferCosts, config, - multiCriteriaRequest + viaLocations ) .createOptimizeTransferService(); } @@ -150,8 +151,8 @@ private PathTailFilter createFilter() { ) .createFilter(); - if (multiCriteriaRequest.hasPassThroughPoints()) { - filter = new PassThroughPathTailFilter<>(filter, multiCriteriaRequest.passThroughPoints()); + if (!viaLocations.isEmpty()) { + filter = new PassThroughPathTailFilter<>(filter, viaLocations); } return filter; } diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/transferoptimization/model/passthrough/PassThroughPathTailFilter.java b/application/src/main/java/org/opentripplanner/routing/algorithm/transferoptimization/model/passthrough/PassThroughPathTailFilter.java index bff656bb940..a56c369ffed 100644 --- a/application/src/main/java/org/opentripplanner/routing/algorithm/transferoptimization/model/passthrough/PassThroughPathTailFilter.java +++ b/application/src/main/java/org/opentripplanner/routing/algorithm/transferoptimization/model/passthrough/PassThroughPathTailFilter.java @@ -8,7 +8,7 @@ import java.util.Set; import java.util.stream.Collectors; import org.opentripplanner.raptor.api.model.RaptorTripSchedule; -import org.opentripplanner.raptor.api.request.PassThroughPoint; +import org.opentripplanner.raptor.api.request.RaptorViaLocation; import org.opentripplanner.routing.algorithm.transferoptimization.model.OptimizedPathTail; import org.opentripplanner.routing.algorithm.transferoptimization.model.PathTailFilter; import org.opentripplanner.utils.tostring.ToStringBuilder; @@ -55,10 +55,10 @@ public class PassThroughPathTailFilter implements public PassThroughPathTailFilter( PathTailFilter filterChain, - List passThroughPoints + List viaLocations ) { this.filterChain = filterChain; - this.c2Calculator = new PathTailC2Calculator(passThroughPoints); + this.c2Calculator = new PathTailC2Calculator(viaLocations); } @Override diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/transferoptimization/model/passthrough/PassThroughPointsIterator.java b/application/src/main/java/org/opentripplanner/routing/algorithm/transferoptimization/model/passthrough/PassThroughPointsIterator.java index 01ea482d450..6dd3fb78cff 100644 --- a/application/src/main/java/org/opentripplanner/routing/algorithm/transferoptimization/model/passthrough/PassThroughPointsIterator.java +++ b/application/src/main/java/org/opentripplanner/routing/algorithm/transferoptimization/model/passthrough/PassThroughPointsIterator.java @@ -2,7 +2,7 @@ import java.util.BitSet; import java.util.List; -import org.opentripplanner.raptor.api.request.PassThroughPoint; +import org.opentripplanner.raptor.api.request.RaptorViaLocation; /** * Iterate over the pass-through points. Note! This implementation iterates backwards starting at the last @@ -10,12 +10,12 @@ */ class PassThroughPointsIterator { - private final List passThroughPoints; + private final List viaLocations; private int index; private BitSet current; - private PassThroughPointsIterator(List passThroughPoints, int c2) { - this.passThroughPoints = passThroughPoints; + private PassThroughPointsIterator(List viaLocations, int c2) { + this.viaLocations = viaLocations; this.index = c2; next(); } @@ -24,16 +24,16 @@ private PassThroughPointsIterator(List passThroughPoints, int * Iterate from the given {@code c2} value (pass-through-point number minus one) towards the * beginning. */ - static PassThroughPointsIterator tailIterator(List passThroughPoints, int c2) { - return new PassThroughPointsIterator(passThroughPoints, c2); + static PassThroughPointsIterator tailIterator(List viaLocations, int c2) { + return new PassThroughPointsIterator(viaLocations, c2); } /** * Iterate over the pass-though-points starting at the end/destination and towards the beginning * of the points, until the origin is reached. */ - static PassThroughPointsIterator tailIterator(List passThroughPoints) { - return new PassThroughPointsIterator(passThroughPoints, passThroughPoints.size()); + static PassThroughPointsIterator tailIterator(List viaLocations) { + return new PassThroughPointsIterator(viaLocations, viaLocations.size()); } /** @@ -48,7 +48,7 @@ int currC2() { */ void next() { --index; - this.current = index < 0 ? null : passThroughPoints.get(index).asBitSet(); + this.current = index < 0 ? null : viaLocations.get(index).asBitSet(); } boolean isPassThroughPoint(int stopIndex) { diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/transferoptimization/model/passthrough/PathTailC2Calculator.java b/application/src/main/java/org/opentripplanner/routing/algorithm/transferoptimization/model/passthrough/PathTailC2Calculator.java index 45605d45062..c72fd98e94a 100644 --- a/application/src/main/java/org/opentripplanner/routing/algorithm/transferoptimization/model/passthrough/PathTailC2Calculator.java +++ b/application/src/main/java/org/opentripplanner/routing/algorithm/transferoptimization/model/passthrough/PathTailC2Calculator.java @@ -1,16 +1,16 @@ package org.opentripplanner.routing.algorithm.transferoptimization.model.passthrough; import java.util.List; -import org.opentripplanner.raptor.api.request.PassThroughPoint; +import org.opentripplanner.raptor.api.request.RaptorViaLocation; import org.opentripplanner.raptor.path.PathBuilderLeg; import org.opentripplanner.routing.algorithm.transferoptimization.model.OptimizedPathTail; class PathTailC2Calculator { - private final List passThroughPoints; + private final List viaLocations; - PathTailC2Calculator(List passThroughPoints) { - this.passThroughPoints = passThroughPoints; + PathTailC2Calculator(List viaLocations) { + this.viaLocations = viaLocations; } int calculateC2(OptimizedPathTail tail) { @@ -33,10 +33,10 @@ private PassThroughPointsIterator calculateAndSetC2ForLeg(PathBuilderLeg tail var curr = findFirstLegWithC2Set(tail); if (curr.isEgress()) { - ptpIter = PassThroughPointsIterator.tailIterator(passThroughPoints); + ptpIter = PassThroughPointsIterator.tailIterator(viaLocations); curr.c2(ptpIter.currC2()); } else { - ptpIter = PassThroughPointsIterator.tailIterator(passThroughPoints, curr.c2()); + ptpIter = PassThroughPointsIterator.tailIterator(viaLocations, curr.c2()); } while (curr != tail) { diff --git a/application/src/main/java/org/opentripplanner/routing/api/request/RouteRequest.java b/application/src/main/java/org/opentripplanner/routing/api/request/RouteRequest.java index daafe70f9e7..528b5d16cab 100644 --- a/application/src/main/java/org/opentripplanner/routing/api/request/RouteRequest.java +++ b/application/src/main/java/org/opentripplanner/routing/api/request/RouteRequest.java @@ -281,6 +281,15 @@ public void setTo(GenericLocation to) { this.to = to; } + + /** + * TransferOptimization is appled to all results exept via-visit requests. + * TODO VIA - When the Optimized transfer support this, then this method should be removed. + */ + public boolean allowTransferOptimization() { + return !isViaSearch() || via.stream().allMatch(ViaLocation::isPassThroughLocation); + } + /** * Return {@code true} if at least one via location is set! */ diff --git a/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/RaptorRequestMapperTest.java b/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/RaptorRequestMapperTest.java index 1f6957893d4..d68265e1ba1 100644 --- a/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/RaptorRequestMapperTest.java +++ b/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/RaptorRequestMapperTest.java @@ -105,7 +105,7 @@ void testViaLocation() { var result = map(req); - assertTrue(result.searchParams().hasViaLocations()); + assertTrue(result.searchParams().isVisitViaSearch()); assertEquals( "[RaptorViaLocation{via Via A wait 13m : [(stop 0, 13m)]}]", result.searchParams().viaLocations().toString() @@ -120,10 +120,10 @@ void testPassThroughPoints() { var result = map(req); - assertTrue(result.multiCriteria().hasPassThroughPoints()); + assertTrue(result.searchParams().isPassThroughSearch()); assertEquals( - "[(Via A, stops: " + STOP_A.getIndex() + ")]", - result.multiCriteria().passThroughPoints().toString() + "[RaptorViaLocation{pass-through Via A : [(stop " + STOP_A.getIndex() + ")]}]", + result.searchParams().viaLocations().toString() ); } @@ -234,7 +234,7 @@ VIA_PASS_THROUGH and VIA_VISIT override VIA_VISIT (see above) @ParameterizedTest(name = "{0}. {1} => {2}") @MethodSource("testViaAndTransitGroupPriorityCombinationsTestCases") void testViaAndTransitGroupPriorityCombinations( - String testDescription, + String ignore, List requestedFeatures, List expectedFeatures, @Nullable String errorMessage @@ -279,7 +279,7 @@ private static void assertFeatureSet( switch (feature) { case VIA_VISIT: if (expected) { - assertTrue(result.searchParams().hasViaLocations()); + assertTrue(result.searchParams().isVisitViaSearch()); // One via location exist(no NPE), but it does not allow pass-through assertEquals( "RaptorViaLocation{via Via A : [(stop 0)]}", @@ -289,24 +289,24 @@ private static void assertFeatureSet( break; case VIA_PASS_THROUGH: if (expected) { - assertTrue(result.multiCriteria().hasPassThroughPoints()); + assertTrue(result.searchParams().isPassThroughSearch()); assertEquals( - "(Via A, stops: 0)", - result.multiCriteria().passThroughPoints().get(0).toString() + "RaptorViaLocation{pass-through Via A : [(stop 0)]}", + result.searchParams().viaLocations().get(0).toString() ); } break; case TRANSIT_GROUP_PRIORITY: assertEquals(expected, result.multiCriteria().transitPriorityCalculator().isPresent()); if (expected) { - assertFalse(result.multiCriteria().hasPassThroughPoints()); + assertFalse(result.searchParams().isPassThroughSearch()); } break; case RELAX_COST_DEST: assertEquals(expected, result.multiCriteria().relaxCostAtDestination() != null); if (expected) { - assertFalse(result.multiCriteria().hasPassThroughPoints()); - assertFalse(result.searchParams().hasViaLocations()); + assertFalse(result.searchParams().isPassThroughSearch()); + assertFalse(result.searchParams().isVisitViaSearch()); } break; } diff --git a/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/model/passthrough/TestCase.java b/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/model/passthrough/TestCase.java index 8ca961dcab0..ffbbec223f4 100644 --- a/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/model/passthrough/TestCase.java +++ b/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/model/passthrough/TestCase.java @@ -1,7 +1,7 @@ package org.opentripplanner.routing.algorithm.transferoptimization.model.passthrough; import java.util.List; -import org.opentripplanner.raptor.api.request.PassThroughPoint; +import org.opentripplanner.raptor.api.request.RaptorViaLocation; import org.opentripplanner.raptorlegacy._data.RaptorTestConstants; record TestCase( @@ -9,7 +9,7 @@ record TestCase( int stopIndexA, int stopIndexB, boolean fromAToB, - List points + List points ) implements RaptorTestConstants { static TestCaseBuilder testCase(String description) { @@ -61,7 +61,7 @@ public String toString() { } private void appendPoint(StringBuilder buf, int passThroughPointIndex) { - points.get(passThroughPointIndex).appendStops(buf, " or ", this::stopIndexToName); + buf.append(points.get(passThroughPointIndex).toString(this::stopIndexToName)); } boolean contains(int stopIndex) { diff --git a/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/model/passthrough/TestCaseBuilder.java b/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/model/passthrough/TestCaseBuilder.java index aed3170df3f..a723accb07b 100644 --- a/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/model/passthrough/TestCaseBuilder.java +++ b/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/model/passthrough/TestCaseBuilder.java @@ -3,7 +3,7 @@ import java.util.ArrayList; import java.util.List; import org.opentripplanner.raptor.api.model.RaptorConstants; -import org.opentripplanner.raptor.api.request.PassThroughPoint; +import org.opentripplanner.raptor.api.request.RaptorViaLocation; class TestCaseBuilder { @@ -11,14 +11,14 @@ class TestCaseBuilder { int stopIndexA = RaptorConstants.NOT_SET; int stopIndexB = RaptorConstants.NOT_SET; boolean txFromAToB = false; - final List points = new ArrayList<>(); + final List points = new ArrayList<>(); TestCaseBuilder(String description) { this.description = description; } TestCaseBuilder points(int... stops) { - points.add(new PassThroughPoint("PT" + (points.size() + 1), stops)); + points.add(RaptorViaLocation.passThrough("PT").addPassThroughStops(stops).build()); return this; } diff --git a/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/model/passthrough/TestUtils.java b/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/model/passthrough/TestUtils.java index 103e2c88f3f..fb819c4371e 100644 --- a/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/model/passthrough/TestUtils.java +++ b/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/model/passthrough/TestUtils.java @@ -4,7 +4,7 @@ import java.util.Collection; import java.util.List; -import org.opentripplanner.raptor.api.request.PassThroughPoint; +import org.opentripplanner.raptor.api.request.RaptorViaLocation; import org.opentripplanner.raptor.spi.RaptorCostCalculator; import org.opentripplanner.raptorlegacy._data.RaptorTestConstants; import org.opentripplanner.raptorlegacy._data.api.TestPathBuilder; @@ -55,11 +55,11 @@ static TripToTripTransfer tx( } static OptimizePathDomainService domainService( - List passThroughPoints, + List viaLocations, final List>... transfers ) { var filter = new MinCostPathTailFilterFactory(false, false).createFilter(); - filter = new PassThroughPathTailFilter<>(filter, passThroughPoints); + filter = new PassThroughPathTailFilter<>(filter, viaLocations); var generator = dummyTransferGenerator(transfers); return new OptimizePathDomainService<>( diff --git a/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/model/passthrough/WalkDurationForStopCombinations.java b/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/model/passthrough/WalkDurationForStopCombinations.java index 66bb1e02c17..8414e44cccd 100644 --- a/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/model/passthrough/WalkDurationForStopCombinations.java +++ b/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/model/passthrough/WalkDurationForStopCombinations.java @@ -4,7 +4,7 @@ import java.util.Collection; import java.util.HashMap; import java.util.Map; -import org.opentripplanner.raptor.api.request.PassThroughPoint; +import org.opentripplanner.raptor.api.request.RaptorViaLocation; import org.opentripplanner.utils.lang.IntUtils; /** @@ -24,11 +24,11 @@ public WalkDurationForStopCombinations(int nStops) { } WalkDurationForStopCombinations withPassThroughPoints( - Collection points, + Collection viaLocations, int passThroughPointExtraCost ) { var passThroughStops = new BitSet(); - points.stream().map(PassThroughPoint::asBitSet).forEach(passThroughStops::or); + viaLocations.stream().map(RaptorViaLocation::asBitSet).forEach(passThroughStops::or); for (int i = 0; i < stopCost.length; i++) { if (passThroughStops.get(i)) { diff --git a/application/src/test/java/org/opentripplanner/routing/core/RouteRequestTest.java b/application/src/test/java/org/opentripplanner/routing/core/RouteRequestTest.java index 15960c44122..01498453425 100644 --- a/application/src/test/java/org/opentripplanner/routing/core/RouteRequestTest.java +++ b/application/src/test/java/org/opentripplanner/routing/core/RouteRequestTest.java @@ -1,6 +1,7 @@ package org.opentripplanner.routing.core; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotSame; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -11,10 +12,12 @@ import org.junit.jupiter.api.Test; import org.opentripplanner.model.GenericLocation; import org.opentripplanner.routing.api.request.RouteRequest; +import org.opentripplanner.routing.api.request.via.VisitViaLocation; import org.opentripplanner.routing.api.response.InputField; import org.opentripplanner.routing.api.response.RoutingError; import org.opentripplanner.routing.api.response.RoutingErrorCode; import org.opentripplanner.routing.error.RoutingValidationException; +import org.opentripplanner.transit.model.framework.FeedScopedId; class RouteRequestTest { @@ -149,6 +152,17 @@ void testNegativeSearchWindow() { ); } + @Test + void allowTransferOptimization() { + RouteRequest request = new RouteRequest(); + assertTrue(request.allowTransferOptimization()); + + request.setViaLocations( + List.of(new VisitViaLocation("VIA", null, List.of(new FeedScopedId("F", "1")), List.of())) + ); + assertFalse(request.allowTransferOptimization()); + } + private GenericLocation randomLocation() { return new GenericLocation(Math.random(), Math.random()); } diff --git a/raptor/src/main/java/org/opentripplanner/raptor/api/request/MultiCriteriaRequest.java b/raptor/src/main/java/org/opentripplanner/raptor/api/request/MultiCriteriaRequest.java index af623f64d6f..d0776cd1b00 100644 --- a/raptor/src/main/java/org/opentripplanner/raptor/api/request/MultiCriteriaRequest.java +++ b/raptor/src/main/java/org/opentripplanner/raptor/api/request/MultiCriteriaRequest.java @@ -1,6 +1,5 @@ package org.opentripplanner.raptor.api.request; -import java.util.List; import java.util.Objects; import java.util.Optional; import javax.annotation.Nullable; @@ -63,14 +62,6 @@ public Optional transitPriorityCalculator( return Optional.ofNullable(transitPriorityCalculator); } - public boolean hasPassThroughPoints() { - throw new UnsupportedOperationException(); - } - - public List passThroughPoints() { - throw new UnsupportedOperationException(); - } - /** * Whether to accept non-optimal trips if they are close enough - if and only if they represent * an optimal path for their given iteration. In other words this slack only relaxes the pareto @@ -155,15 +146,6 @@ public Builder withTransitPriorityCalculator(RaptorTransitGroupPriorityCalcul return this; } - public List passThroughPoints() { - throw new UnsupportedOperationException(); - } - - @Nullable - public Builder withPassThroughPoints(List points) { - throw new UnsupportedOperationException(); - } - @Nullable @Deprecated public Double relaxCostAtDestination() { diff --git a/raptor/src/main/java/org/opentripplanner/raptor/api/request/PassThroughPoint.java b/raptor/src/main/java/org/opentripplanner/raptor/api/request/PassThroughPoint.java deleted file mode 100644 index 7c529343b32..00000000000 --- a/raptor/src/main/java/org/opentripplanner/raptor/api/request/PassThroughPoint.java +++ /dev/null @@ -1,85 +0,0 @@ -package org.opentripplanner.raptor.api.request; - -import java.util.Arrays; -import java.util.BitSet; -import java.util.Objects; -import java.util.function.IntFunction; -import java.util.stream.IntStream; -import javax.annotation.Nullable; -import org.opentripplanner.utils.lang.StringUtils; - -/** - * A collection of stop indexes used to define a pass through-point. - * - * @deprecated This will be replaced by ViaLocation - */ -@Deprecated -public class PassThroughPoint { - - private final String name; - private final int[] stops; - - public PassThroughPoint(@Nullable String name, int... stops) { - Objects.requireNonNull(stops); - if (stops.length == 0) { - throw new IllegalArgumentException("At least one stop is required"); - } - this.name = StringUtils.hasNoValue(name) ? null : name; - this.stops = Arrays.copyOf(stops, stops.length); - } - - /** - * This is a convenient accessor method used inside Raptor. It converts the list stops to a - * bit-set. Add other access methods if needed. - */ - public BitSet asBitSet() { - return IntStream.of(stops).collect(BitSet::new, BitSet::set, BitSet::or); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - PassThroughPoint that = (PassThroughPoint) o; - return Arrays.equals(stops, that.stops); - } - - @Override - public int hashCode() { - return Arrays.hashCode(stops); - } - - /** - * We want the {@code toString()} to be as easy to read as possible for value objects, so the - * format for this class is: - *

- * {@code "(, )"}, for example: - * {@code "(PT-Name, 1, 12, 123)"} or without the name {@code "(1, 12, 123)"} - */ - @Override - public String toString() { - return toString(Integer::toString); - } - - public String toString(IntFunction nameResolver) { - StringBuilder buf = new StringBuilder("("); - if (name != null) { - buf.append(name).append(", "); - } - buf.append("stops: "); - appendStops(buf, ", ", nameResolver); - return buf.append(")").toString(); - } - - public void appendStops(StringBuilder buf, String sep, IntFunction nameResolver) { - boolean skipFirst = true; - for (int stop : stops) { - if (skipFirst) { - skipFirst = false; - } else { - buf.append(sep); - } - buf.append(nameResolver.apply(stop)); - } - } -} diff --git a/raptor/src/main/java/org/opentripplanner/raptor/api/request/SearchParams.java b/raptor/src/main/java/org/opentripplanner/raptor/api/request/SearchParams.java index b4ab5cf6261..9a2dd6104fe 100644 --- a/raptor/src/main/java/org/opentripplanner/raptor/api/request/SearchParams.java +++ b/raptor/src/main/java/org/opentripplanner/raptor/api/request/SearchParams.java @@ -211,10 +211,6 @@ public List viaLocations() { return viaLocations; } - public boolean hasViaLocations() { - return !viaLocations.isEmpty(); - } - /** * Get the maximum duration of any access or egress path in seconds. */ diff --git a/raptor/src/test/java/org/opentripplanner/raptor/api/request/PassThroughPointTest.java b/raptor/src/test/java/org/opentripplanner/raptor/api/request/PassThroughPointTest.java deleted file mode 100644 index 155e122a7b6..00000000000 --- a/raptor/src/test/java/org/opentripplanner/raptor/api/request/PassThroughPointTest.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.opentripplanner.raptor.api.request; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertNotEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; - -import org.junit.jupiter.api.Test; - -class PassThroughPointTest { - - private static final int[] STOPS = { 2, 7, 13 }; - - private final PassThroughPoint subject = new PassThroughPoint("PT1", STOPS); - - @Test - void asBitSet() { - var bitSet = subject.asBitSet(); - - // Sample some all set values as well as some not set values - assertFalse(bitSet.get(0)); - assertTrue(bitSet.get(2)); - assertFalse(bitSet.get(3)); - assertFalse(bitSet.get(6)); - assertTrue(bitSet.get(7)); - assertTrue(bitSet.get(13)); - assertFalse(bitSet.get(15000000)); - } - - @Test - void testEqualsAndHashCode() { - var same = new PassThroughPoint("PT1", STOPS); - var other = new PassThroughPoint("PT2", 2, 7); - - assertEquals(subject, subject); - assertEquals(same, subject); - assertNotEquals(other, subject); - - assertEquals(same.hashCode(), subject.hashCode()); - assertNotEquals(other.hashCode(), subject.hashCode()); - } - - @Test - void testToString() { - assertEquals("(PT1, stops: 2, 7, 13)", subject.toString()); - assertEquals("(stops: 2, 7, 13)", new PassThroughPoint(" ", STOPS).toString()); - assertEquals("(stops: 2, 7, 13)", new PassThroughPoint(null, STOPS).toString()); - } -} From 78a4ad5882e33340a0fa2e7e216877f18b06eb10 Mon Sep 17 00:00:00 2001 From: Thomas Gran Date: Thu, 20 Feb 2025 18:26:04 +0100 Subject: [PATCH 25/69] feature: Use the via label+coordinate to name vertex in graph - this is also returned in the response. --- .../raptoradapter/transit/mappers/RaptorRequestMapper.java | 6 +++++- .../opentripplanner/routing/api/request/RouteRequest.java | 1 - .../routing/via/ViaCoordinateTransferFactory.java | 6 +++++- .../via/service/DefaultViaCoordinateTransferFactory.java | 7 ++++++- .../transit/mappers/RaptorRequestMapperTest.java | 1 + 5 files changed, 17 insertions(+), 4 deletions(-) diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/RaptorRequestMapper.java b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/RaptorRequestMapper.java index 524ece2d7b3..3c37f7ef0d2 100644 --- a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/RaptorRequestMapper.java +++ b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/RaptorRequestMapper.java @@ -245,7 +245,11 @@ private RaptorViaLocation mapViaLocation(ViaLocation input) { builder.addViaStop(stopIndex); } for (var coordinate : input.coordinates()) { - var viaTransfers = viaTransferResolver.createViaTransfers(request, coordinate); + var viaTransfers = viaTransferResolver.createViaTransfers( + request, + input.label(), + coordinate + ); for (var it : viaTransfers) { builder.addViaTransfer(it.fromStopIndex(), it); } diff --git a/application/src/main/java/org/opentripplanner/routing/api/request/RouteRequest.java b/application/src/main/java/org/opentripplanner/routing/api/request/RouteRequest.java index 528b5d16cab..8ac0ce7fca4 100644 --- a/application/src/main/java/org/opentripplanner/routing/api/request/RouteRequest.java +++ b/application/src/main/java/org/opentripplanner/routing/api/request/RouteRequest.java @@ -281,7 +281,6 @@ public void setTo(GenericLocation to) { this.to = to; } - /** * TransferOptimization is appled to all results exept via-visit requests. * TODO VIA - When the Optimized transfer support this, then this method should be removed. diff --git a/application/src/main/java/org/opentripplanner/routing/via/ViaCoordinateTransferFactory.java b/application/src/main/java/org/opentripplanner/routing/via/ViaCoordinateTransferFactory.java index 86cebca8408..747c782a662 100644 --- a/application/src/main/java/org/opentripplanner/routing/via/ViaCoordinateTransferFactory.java +++ b/application/src/main/java/org/opentripplanner/routing/via/ViaCoordinateTransferFactory.java @@ -6,5 +6,9 @@ import org.opentripplanner.routing.via.model.ViaCoordinateTransfer; public interface ViaCoordinateTransferFactory { - List createViaTransfers(RouteRequest request, WgsCoordinate coordinate); + List createViaTransfers( + RouteRequest request, + String label, + WgsCoordinate coordinate + ); } diff --git a/application/src/main/java/org/opentripplanner/routing/via/service/DefaultViaCoordinateTransferFactory.java b/application/src/main/java/org/opentripplanner/routing/via/service/DefaultViaCoordinateTransferFactory.java index 6b7722f8d04..1bf23440e58 100644 --- a/application/src/main/java/org/opentripplanner/routing/via/service/DefaultViaCoordinateTransferFactory.java +++ b/application/src/main/java/org/opentripplanner/routing/via/service/DefaultViaCoordinateTransferFactory.java @@ -23,6 +23,7 @@ import org.opentripplanner.street.search.TraverseMode; import org.opentripplanner.street.search.TraverseModeSet; import org.opentripplanner.transit.service.TransitService; +import org.opentripplanner.utils.lang.StringUtils; public class DefaultViaCoordinateTransferFactory implements ViaCoordinateTransferFactory { @@ -48,16 +49,20 @@ public DefaultViaCoordinateTransferFactory( @Override public List createViaTransfers( RouteRequest request, + String viaLabel, WgsCoordinate coordinate ) { DisposableEdgeCollection tempEdges = null; try { var nearbyStopFinder = createNearbyStopFinder(radiusByDuration); + var name = I18NString.of( + (StringUtils.hasValue(viaLabel) ? viaLabel : "Via") + " " + coordinate + ); var viaVertex = TemporaryStreetLocation.via( UUID.randomUUID().toString(), coordinate.asJtsCoordinate(), - I18NString.of("Via " + coordinate) + name ); var m = mapTransferMode(request.journey().modes().transferMode); diff --git a/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/RaptorRequestMapperTest.java b/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/RaptorRequestMapperTest.java index d68265e1ba1..aecb3d50fef 100644 --- a/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/RaptorRequestMapperTest.java +++ b/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/RaptorRequestMapperTest.java @@ -345,6 +345,7 @@ private static class DummyViaCoordinateTransferFactory implements ViaCoordinateT @Override public List createViaTransfers( RouteRequest request, + String ignore, WgsCoordinate coordinate ) { // Make sure the input is the expected via-coordinate From 2ae244d70b87516c519afb17df2479c3f0711262 Mon Sep 17 00:00:00 2001 From: Teemu Kalvas Date: Mon, 24 Feb 2025 15:20:20 +0200 Subject: [PATCH 26/69] fix inaccuracy in state reversal which generates rounding errors in creating the reversed path for arriveBy queries --- .../routing/impl/GraphPathFinder.java | 10 +++---- .../street/search/state/State.java | 4 +-- .../street/integration/WalkRoutingTest.java | 26 ++++++++++++++++--- 3 files changed, 30 insertions(+), 10 deletions(-) diff --git a/application/src/main/java/org/opentripplanner/routing/impl/GraphPathFinder.java b/application/src/main/java/org/opentripplanner/routing/impl/GraphPathFinder.java index d8de0332238..0fe5d4ed95e 100644 --- a/application/src/main/java/org/opentripplanner/routing/impl/GraphPathFinder.java +++ b/application/src/main/java/org/opentripplanner/routing/impl/GraphPathFinder.java @@ -139,7 +139,7 @@ public List> graphPathFinderEntryPoint( Set to ) { OTPRequestTimeoutException.checkForTimeout(); - Instant reqTime = request.dateTime().truncatedTo(ChronoUnit.SECONDS); + Instant reqTime = request.dateTime(); List> paths = getPaths(request, from, to); @@ -151,13 +151,13 @@ public List> graphPathFinderEntryPoint( GraphPath graphPath = gpi.next(); // TODO check, is it possible that arriveBy and time are modifed in-place by the search? if (request.arriveBy()) { - if (graphPath.states.getLast().getTime().isAfter(reqTime)) { - LOG.error("A graph path arrives after the requested time. This implies a bug."); + if (graphPath.states.getLast().getTimeAccurate().isAfter(reqTime)) { + LOG.error("A graph path arrives {} after the requested time {}. This implies a bug.", graphPath.states.getLast().getTimeAccurate(), reqTime); gpi.remove(); } } else { - if (graphPath.states.getFirst().getTime().isBefore(reqTime)) { - LOG.error("A graph path leaves before the requested time. This implies a bug."); + if (graphPath.states.getFirst().getTimeAccurate().isBefore(reqTime)) { + LOG.error("A graph path leaves {} before the requested time {}. This implies a bug.", graphPath.states.getFirst().getTimeAccurate(), reqTime); gpi.remove(); } } diff --git a/application/src/main/java/org/opentripplanner/street/search/state/State.java b/application/src/main/java/org/opentripplanner/street/search/state/State.java index 90336cdaa2a..9b4c50580cf 100644 --- a/application/src/main/java/org/opentripplanner/street/search/state/State.java +++ b/application/src/main/java/org/opentripplanner/street/search/state/State.java @@ -527,7 +527,7 @@ private double getWalkDistanceDelta() { private State reversedClone() { StreetSearchRequest reversedRequest = request - .copyOfReversed(getTime()) + .copyOfReversed(getTimeAccurate()) .withPreferences(p -> { p.withCar(c -> c.withRental(r -> r.withUseAvailabilityInformation(false))); p.withBike(b -> b.withRental(r -> r.withUseAvailabilityInformation(false))); @@ -535,7 +535,7 @@ private State reversedClone() { .build(); StateData newStateData = stateData.clone(); newStateData.backMode = null; - return new State(this.vertex, getTime(), newStateData, reversedRequest); + return new State(this.vertex, getTimeAccurate(), newStateData, reversedRequest); } /** diff --git a/application/src/test/java/org/opentripplanner/street/integration/WalkRoutingTest.java b/application/src/test/java/org/opentripplanner/street/integration/WalkRoutingTest.java index 6f3f47ba6e6..b4f81410cfd 100644 --- a/application/src/test/java/org/opentripplanner/street/integration/WalkRoutingTest.java +++ b/application/src/test/java/org/opentripplanner/street/integration/WalkRoutingTest.java @@ -1,9 +1,12 @@ package org.opentripplanner.street.integration; import java.time.Instant; +import java.time.temporal.ChronoUnit; import java.util.List; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; import org.opentripplanner.ConstantsForTests; import org.opentripplanner.TestOtpModel; import org.opentripplanner.astar.model.GraphPath; @@ -45,18 +48,35 @@ class WalkRoutingTest { void shouldRouteAroundRoundabout() { var start = new GenericLocation(59.94646, 10.77511); var end = new GenericLocation(59.94641, 10.77522); - Assertions.assertDoesNotThrow(() -> route(roundabout, start, end)); + Assertions.assertDoesNotThrow(() -> route(roundabout, start, end, dateTime, false)); + } + + @ParameterizedTest + @ValueSource(ints = {0, 200, 400, 499, 500, 501, 600, 700, 800, 900, 999}) + void pathReversalWorks(int offset) { + var start = new GenericLocation(59.94646, 10.77511); + var end = new GenericLocation(59.94641, 10.77522); + var base = dateTime.truncatedTo(ChronoUnit.SECONDS); + var time = base.plusMillis(offset); + var results = route(roundabout, start, end, time, true); + Assertions.assertEquals(1, results.size()); + var states = results.get(0).states; + var diff = ChronoUnit.MILLIS.between(states.getFirst().getTimeAccurate(), states.getLast().getTimeAccurate()); + Assertions.assertEquals(13926, diff); // should be same for every parametrized offset, otherwise irrelevant } private static List> route( Graph graph, GenericLocation from, - GenericLocation to + GenericLocation to, + Instant instant, + boolean arriveBy ) { RouteRequest request = new RouteRequest(); - request.setDateTime(dateTime); + request.setDateTime(instant); request.setFrom(from); request.setTo(to); + request.setArriveBy(arriveBy); request.journey().direct().setMode(StreetMode.WALK); try ( From 048f39b9f657dc68774f5aa3920ef7b1e661074a Mon Sep 17 00:00:00 2001 From: Thomas Gran Date: Mon, 24 Feb 2025 13:38:27 +0100 Subject: [PATCH 27/69] review: Remove `LinkingDirection` from TemporaryStreetLocation. --- .../routing/graph/index/StreetIndex.java | 15 +--- .../DefaultViaCoordinateTransferFactory.java | 2 +- .../model/vertex/TemporaryStreetLocation.java | 76 ++++--------------- .../org/opentripplanner/astar/AStarTest.java | 8 +- .../routing/algorithm/GraphRoutingTest.java | 8 +- 5 files changed, 23 insertions(+), 86 deletions(-) diff --git a/application/src/main/java/org/opentripplanner/routing/graph/index/StreetIndex.java b/application/src/main/java/org/opentripplanner/routing/graph/index/StreetIndex.java index 8e070b9ccc8..7c3cb1224a9 100644 --- a/application/src/main/java/org/opentripplanner/routing/graph/index/StreetIndex.java +++ b/application/src/main/java/org/opentripplanner/routing/graph/index/StreetIndex.java @@ -102,12 +102,7 @@ public static TemporaryStreetLocation createTemporaryStreetLocationForTest( ) { boolean wheelchairAccessible = false; - TemporaryStreetLocation location = TemporaryStreetLocation.originOrDestination( - label, - nearestPoint, - name, - endVertex - ); + var location = new TemporaryStreetLocation(label, nearestPoint, name); for (StreetEdge street : edges) { Vertex fromv = street.getFromVertex(); @@ -377,12 +372,8 @@ private Vertex createVertexFromCoordinate( name = new NonLocalizedString(label); } - TemporaryStreetLocation temporaryStreetLocation = TemporaryStreetLocation.originOrDestination( - UUID.randomUUID().toString(), - coordinate, - name, - endVertex - ); + String id = UUID.randomUUID().toString(); + var temporaryStreetLocation = new TemporaryStreetLocation(id, coordinate, name); TraverseMode nonTransitMode = getTraverseModeForLinker(streetMode, endVertex); diff --git a/application/src/main/java/org/opentripplanner/routing/via/service/DefaultViaCoordinateTransferFactory.java b/application/src/main/java/org/opentripplanner/routing/via/service/DefaultViaCoordinateTransferFactory.java index 1bf23440e58..b46e49621f9 100644 --- a/application/src/main/java/org/opentripplanner/routing/via/service/DefaultViaCoordinateTransferFactory.java +++ b/application/src/main/java/org/opentripplanner/routing/via/service/DefaultViaCoordinateTransferFactory.java @@ -59,7 +59,7 @@ public List createViaTransfers( (StringUtils.hasValue(viaLabel) ? viaLabel : "Via") + " " + coordinate ); - var viaVertex = TemporaryStreetLocation.via( + var viaVertex = new TemporaryStreetLocation( UUID.randomUUID().toString(), coordinate.asJtsCoordinate(), name diff --git a/application/src/main/java/org/opentripplanner/street/model/vertex/TemporaryStreetLocation.java b/application/src/main/java/org/opentripplanner/street/model/vertex/TemporaryStreetLocation.java index 7d2bdf52d11..438734a21fd 100644 --- a/application/src/main/java/org/opentripplanner/street/model/vertex/TemporaryStreetLocation.java +++ b/application/src/main/java/org/opentripplanner/street/model/vertex/TemporaryStreetLocation.java @@ -2,85 +2,35 @@ import org.locationtech.jts.geom.Coordinate; import org.opentripplanner.framework.i18n.I18NString; -import org.opentripplanner.routing.linking.LinkingDirection; import org.opentripplanner.street.model.edge.Edge; import org.opentripplanner.street.model.edge.TemporaryEdge; +/** + * A temporary vertex witch can be used as the origin(outgoing edges), destination(incomming + * edges) or via point(in-/out-going edges). There is no constraint on adding incomming/outgoing + * edges. For a temporary request scoped vertex with both incomming and outcomming edges, there + * need to be a something that exclude it from other parallell searches. One way to do this is to + * add a small cost to the temporary edges so the alternative permanent edges have a small + * advatage. + */ public final class TemporaryStreetLocation extends StreetLocation implements TemporaryVertex { - private final LinkingDirection linkingDirection; - - private TemporaryStreetLocation( - String id, - Coordinate nearestPoint, - I18NString name, - LinkingDirection linkingDirection - ) { + public TemporaryStreetLocation(String id, Coordinate nearestPoint, I18NString name) { super(id, nearestPoint, name); - this.linkingDirection = linkingDirection; - } - - public static TemporaryStreetLocation originOrDestination( - String id, - Coordinate nearestPoint, - I18NString name, - boolean destination - ) { - return destination ? destination(id, nearestPoint, name) : origin(id, nearestPoint, name); - } - - /** - * Create a temporary vertex witch can be used as the starting point - the origin of a search. - * The origin only has outgoing edges, an attempt to add incoming edges will fail. - */ - public static TemporaryStreetLocation origin( - String id, - Coordinate nearestPoint, - I18NString name - ) { - return new TemporaryStreetLocation(id, nearestPoint, name, LinkingDirection.OUTGOING); - } - - /** - * Create a temporary vertex witch can be used as the end point - the destination of a search. - * The destination only has incoming edges, an attempt to add outgoing edges will fail. - */ - public static TemporaryStreetLocation destination( - String id, - Coordinate nearestPoint, - I18NString name - ) { - return new TemporaryStreetLocation(id, nearestPoint, name, LinkingDirection.INCOMING); - } - - /** - * Create a temporary vertex witch can be used as either the origin or the destination - * in a nearby-search. This is used to route via a coordinate. - */ - public static TemporaryStreetLocation via(String id, Coordinate nearestPoint, I18NString name) { - return new TemporaryStreetLocation(id, nearestPoint, name, LinkingDirection.BOTH_WAYS); } @Override public void addOutgoing(Edge edge) { assertConnectToTemporaryEdge(edge); - if (linkingDirection.allowOutgoing()) { - addRentalRestriction(edge.getToVertex().rentalRestrictions()); - super.addOutgoing(edge); - } else { - throw new UnsupportedOperationException("Can't add outgoing edge to end vertex"); - } + addRentalRestriction(edge.getToVertex().rentalRestrictions()); + super.addOutgoing(edge); } @Override public void addIncoming(Edge edge) { assertConnectToTemporaryEdge(edge); - if (linkingDirection.allowIncoming()) { - super.addIncoming(edge); - addRentalRestriction(edge.getFromVertex().rentalRestrictions()); - } else { - throw new UnsupportedOperationException("Can't add incoming edge to start vertex"); - } + super.addIncoming(edge); + addRentalRestriction(edge.getFromVertex().rentalRestrictions()); } private static void assertConnectToTemporaryEdge(Edge edge) { diff --git a/application/src/test/java/org/opentripplanner/astar/AStarTest.java b/application/src/test/java/org/opentripplanner/astar/AStarTest.java index f2075f815da..027db82cce8 100644 --- a/application/src/test/java/org/opentripplanner/astar/AStarTest.java +++ b/application/src/test/java/org/opentripplanner/astar/AStarTest.java @@ -163,14 +163,14 @@ public void testForwardExtraEdges() { request.withPreferences(pref -> pref.withWalk(w -> w.withSpeed(1.0))); - TemporaryStreetLocation from = TemporaryStreetLocation.origin( + TemporaryStreetLocation from = new TemporaryStreetLocation( "near_shilshole_22nd", new Coordinate(-122.385050, 47.666620), new NonLocalizedString("near_shilshole_22nd") ); TemporaryConcreteEdge.createTemporaryConcreteEdge(from, graph.getVertex("shilshole_22nd")); - TemporaryStreetLocation to = TemporaryStreetLocation.destination( + TemporaryStreetLocation to = new TemporaryStreetLocation( "near_56th_20th", new Coordinate(-122.382347, 47.669518), new NonLocalizedString("near_56th_20th") @@ -209,14 +209,14 @@ public void testBackExtraEdges() { request.withPreferences(pref -> pref.withWalk(w -> w.withSpeed(1.0))); request.setArriveBy(true); - TemporaryStreetLocation from = TemporaryStreetLocation.origin( + TemporaryStreetLocation from = new TemporaryStreetLocation( "near_shilshole_22nd", new Coordinate(-122.385050, 47.666620), new NonLocalizedString("near_shilshole_22nd") ); TemporaryConcreteEdge.createTemporaryConcreteEdge(from, graph.getVertex("shilshole_22nd")); - TemporaryStreetLocation to = TemporaryStreetLocation.destination( + TemporaryStreetLocation to = new TemporaryStreetLocation( "near_56th_20th", new Coordinate(-122.382347, 47.669518), new NonLocalizedString("near_56th_20th") diff --git a/application/src/test/java/org/opentripplanner/routing/algorithm/GraphRoutingTest.java b/application/src/test/java/org/opentripplanner/routing/algorithm/GraphRoutingTest.java index 3fffc597c76..d00fdc1ba17 100644 --- a/application/src/test/java/org/opentripplanner/routing/algorithm/GraphRoutingTest.java +++ b/application/src/test/java/org/opentripplanner/routing/algorithm/GraphRoutingTest.java @@ -359,12 +359,8 @@ public TemporaryStreetLocation streetLocation( double longitude, boolean endVertex ) { - return TemporaryStreetLocation.originOrDestination( - name, - new Coordinate(longitude, latitude), - new NonLocalizedString(name), - endVertex - ); + var nearestPoint = new Coordinate(longitude, latitude); + return new TemporaryStreetLocation(name, nearestPoint, new NonLocalizedString(name)); } public TemporaryFreeEdge link(TemporaryVertex from, StreetVertex to) { From 589ee59f884c12f0b1eb02d77f4beb41cc625079 Mon Sep 17 00:00:00 2001 From: Thomas Gran Date: Tue, 25 Feb 2025 08:34:41 +0100 Subject: [PATCH 28/69] refactor: Rename BOTH_WAYS to BIDIRECTIONAL --- .../module/OsmBoardingLocationsModule.java | 4 ++-- .../graph_builder/module/StreetLinkerModule.java | 12 ++++++------ .../mapping/RaptorPathToItineraryMapper.java | 2 +- .../routing/linking/LinkingDirection.java | 6 +++--- .../service/DefaultViaCoordinateTransferFactory.java | 2 +- .../street/model/edge/StreetEdge.java | 4 ++-- .../vehicle_parking/VehicleParkingUpdater.java | 4 ++-- .../updater/vehicle_rental/VehicleRentalUpdater.java | 2 +- .../java/org/opentripplanner/ConstantsForTests.java | 2 +- .../graph_builder/module/linking/TestGraph.java | 2 +- .../routing/linking/LinkStopToPlatformTest.java | 3 +-- .../routing/linking/LinkingDirectionTest.java | 4 ++-- .../street/model/edge/StreetEdgeSplittingTest.java | 4 ++-- 13 files changed, 25 insertions(+), 26 deletions(-) diff --git a/application/src/main/java/org/opentripplanner/graph_builder/module/OsmBoardingLocationsModule.java b/application/src/main/java/org/opentripplanner/graph_builder/module/OsmBoardingLocationsModule.java index 61668ab6299..16f88e85208 100644 --- a/application/src/main/java/org/opentripplanner/graph_builder/module/OsmBoardingLocationsModule.java +++ b/application/src/main/java/org/opentripplanner/graph_builder/module/OsmBoardingLocationsModule.java @@ -212,7 +212,7 @@ private boolean connectVertexToWay(TransitStopVertex ts, StreetIndex index) { for (var vertex : linker.linkToSpecificStreetEdgesPermanently( boardingLocation, new TraverseModeSet(TraverseMode.WALK), - LinkingDirection.BOTH_WAYS, + LinkingDirection.BIDIRECTIONAL, platformEdgeList.getValue().stream().map(StreetEdge.class::cast).collect(Collectors.toSet()) )) { linkBoardingLocationToStop(ts, stop.getCode(), vertex); @@ -243,7 +243,7 @@ private boolean connectVertexToNode(TransitStopVertex ts, StreetIndex index) { linker.linkVertexPermanently( boardingLocation, new TraverseModeSet(TraverseMode.WALK), - LinkingDirection.BOTH_WAYS, + LinkingDirection.BIDIRECTIONAL, (osmBoardingLocationVertex, splitVertex) -> getConnectingEdges(boardingLocation, osmBoardingLocationVertex, splitVertex) ); diff --git a/application/src/main/java/org/opentripplanner/graph_builder/module/StreetLinkerModule.java b/application/src/main/java/org/opentripplanner/graph_builder/module/StreetLinkerModule.java index d50659f275c..6127bfb5f69 100644 --- a/application/src/main/java/org/opentripplanner/graph_builder/module/StreetLinkerModule.java +++ b/application/src/main/java/org/opentripplanner/graph_builder/module/StreetLinkerModule.java @@ -160,7 +160,7 @@ private void linkStopToStreetNetwork(TransitStopVertex tStop, StopLinkType linkT .linkVertexPermanently( tStop, WALK_ONLY, - LinkingDirection.BOTH_WAYS, + LinkingDirection.BIDIRECTIONAL, (transitVertex, streetVertex) -> { var linkEdges = createStopLinkEdges((TransitStopVertex) transitVertex, streetVertex); @@ -187,7 +187,7 @@ private void linkToDriveableEdge(TransitStopVertex tStop) { .linkVertexPermanently( tStop, CAR_ONLY, - LinkingDirection.BOTH_WAYS, + LinkingDirection.BIDIRECTIONAL, (transitVertex, streetVertex) -> createStopLinkEdges((TransitStopVertex) transitVertex, streetVertex) ); @@ -213,7 +213,7 @@ private static void linkVehicleParkingWithLinker( .linkVertexPermanently( vehicleParkingVertex, new TraverseModeSet(TraverseMode.WALK), - LinkingDirection.BOTH_WAYS, + LinkingDirection.BIDIRECTIONAL, (vertex, streetVertex) -> List.of( StreetVehicleParkingLink.createStreetVehicleParkingLink( @@ -234,7 +234,7 @@ private static void linkVehicleParkingWithLinker( .linkVertexPermanently( vehicleParkingVertex, new TraverseModeSet(TraverseMode.CAR), - LinkingDirection.BOTH_WAYS, + LinkingDirection.BIDIRECTIONAL, (vertex, streetVertex) -> List.of( StreetVehicleParkingLink.createStreetVehicleParkingLink( @@ -258,7 +258,7 @@ private void linkTransitEntrances(Graph graph) { .linkVertexPermanently( tEntrance, new TraverseModeSet(TraverseMode.WALK), - LinkingDirection.BOTH_WAYS, + LinkingDirection.BIDIRECTIONAL, (vertex, streetVertex) -> List.of( StreetTransitEntranceLink.createStreetTransitEntranceLink( @@ -296,7 +296,7 @@ private void linkStationCentroids(Graph graph) { .linkVertexPermanently( station, new TraverseModeSet(TraverseMode.WALK), - LinkingDirection.BOTH_WAYS, + LinkingDirection.BIDIRECTIONAL, stationAndStreetVertexLinker ); } diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/mapping/RaptorPathToItineraryMapper.java b/application/src/main/java/org/opentripplanner/routing/algorithm/mapping/RaptorPathToItineraryMapper.java index 75b9469514b..6da21931211 100644 --- a/application/src/main/java/org/opentripplanner/routing/algorithm/mapping/RaptorPathToItineraryMapper.java +++ b/application/src/main/java/org/opentripplanner/routing/algorithm/mapping/RaptorPathToItineraryMapper.java @@ -388,7 +388,7 @@ private List mapViaCoordinateTransferLeg( if (fromLegs.isEmpty() || toLegs.isEmpty()) { throw new IllegalStateException( - "There need to be at least one edges to get from a stop to the via coordinate and back" + "There need to be at least one edge to get from a stop to the via coordinate and back" ); } // We need to timeshift the toLegs diff --git a/application/src/main/java/org/opentripplanner/routing/linking/LinkingDirection.java b/application/src/main/java/org/opentripplanner/routing/linking/LinkingDirection.java index 67df67648c1..b93f9b1ca15 100644 --- a/application/src/main/java/org/opentripplanner/routing/linking/LinkingDirection.java +++ b/application/src/main/java/org/opentripplanner/routing/linking/LinkingDirection.java @@ -16,19 +16,19 @@ public enum LinkingDirection { /** * Link both ways */ - BOTH_WAYS; + BIDIRECTIONAL; /** * Return {@code true} if either outgoing or both-ways. */ public boolean allowOutgoing() { - return this == OUTGOING || this == BOTH_WAYS; + return this == OUTGOING || this == BIDIRECTIONAL; } /** * Return {@code true} if either incoming or both-ways. */ public boolean allowIncoming() { - return this == INCOMING || this == BOTH_WAYS; + return this == INCOMING || this == BIDIRECTIONAL; } } diff --git a/application/src/main/java/org/opentripplanner/routing/via/service/DefaultViaCoordinateTransferFactory.java b/application/src/main/java/org/opentripplanner/routing/via/service/DefaultViaCoordinateTransferFactory.java index b46e49621f9..0e11f1ea4be 100644 --- a/application/src/main/java/org/opentripplanner/routing/via/service/DefaultViaCoordinateTransferFactory.java +++ b/application/src/main/java/org/opentripplanner/routing/via/service/DefaultViaCoordinateTransferFactory.java @@ -73,7 +73,7 @@ public List createViaTransfers( .linkVertexForRequest( viaVertex, new TraverseModeSet(m), - LinkingDirection.BOTH_WAYS, + LinkingDirection.BIDIRECTIONAL, (via, street) -> { var v = (TemporaryStreetLocation) via; return List.of( diff --git a/application/src/main/java/org/opentripplanner/street/model/edge/StreetEdge.java b/application/src/main/java/org/opentripplanner/street/model/edge/StreetEdge.java index 58da81f9161..ddfdc795616 100644 --- a/application/src/main/java/org/opentripplanner/street/model/edge/StreetEdge.java +++ b/application/src/main/java/org/opentripplanner/street/model/edge/StreetEdge.java @@ -721,7 +721,7 @@ public SplitStreetEdge splitNonDestructively( StreetEdge e1 = null; StreetEdge e2 = null; - if (direction == LinkingDirection.OUTGOING || direction == LinkingDirection.BOTH_WAYS) { + if (direction == LinkingDirection.OUTGOING || direction == LinkingDirection.BIDIRECTIONAL) { var seb1 = new TemporaryPartialStreetEdgeBuilder() .withParentEdge(this) .withFromVertex((StreetVertex) fromv) @@ -734,7 +734,7 @@ public SplitStreetEdge splitNonDestructively( copyRentalRestrictionsToSplitEdge(e1); tempEdges.addEdge(e1); } - if (direction == LinkingDirection.INCOMING || direction == LinkingDirection.BOTH_WAYS) { + if (direction == LinkingDirection.INCOMING || direction == LinkingDirection.BIDIRECTIONAL) { var seb2 = new TemporaryPartialStreetEdgeBuilder() .withParentEdge(this) .withFromVertex(v) diff --git a/application/src/main/java/org/opentripplanner/updater/vehicle_parking/VehicleParkingUpdater.java b/application/src/main/java/org/opentripplanner/updater/vehicle_parking/VehicleParkingUpdater.java index 5513e224f57..326cf28fb16 100644 --- a/application/src/main/java/org/opentripplanner/updater/vehicle_parking/VehicleParkingUpdater.java +++ b/application/src/main/java/org/opentripplanner/updater/vehicle_parking/VehicleParkingUpdater.java @@ -178,7 +178,7 @@ private List linkVehicleParkingForRealtime( var disposableWalkEdges = linker.linkVertexForRealTime( vehicleParkingEntranceVertex, new TraverseModeSet(TraverseMode.WALK), - LinkingDirection.BOTH_WAYS, + LinkingDirection.BIDIRECTIONAL, (vertex, streetVertex) -> List.of( StreetVehicleParkingLink.createStreetVehicleParkingLink( @@ -198,7 +198,7 @@ private List linkVehicleParkingForRealtime( var disposableCarEdges = linker.linkVertexForRealTime( vehicleParkingEntranceVertex, new TraverseModeSet(TraverseMode.CAR), - LinkingDirection.BOTH_WAYS, + LinkingDirection.BIDIRECTIONAL, (vertex, streetVertex) -> List.of( StreetVehicleParkingLink.createStreetVehicleParkingLink( diff --git a/application/src/main/java/org/opentripplanner/updater/vehicle_rental/VehicleRentalUpdater.java b/application/src/main/java/org/opentripplanner/updater/vehicle_rental/VehicleRentalUpdater.java index 8419d004138..cfa096cdf0e 100644 --- a/application/src/main/java/org/opentripplanner/updater/vehicle_rental/VehicleRentalUpdater.java +++ b/application/src/main/java/org/opentripplanner/updater/vehicle_rental/VehicleRentalUpdater.java @@ -164,7 +164,7 @@ public void run(RealTimeUpdateContext context) { DisposableEdgeCollection tempEdges = linker.linkVertexForRealTime( vehicleRentalVertex, new TraverseModeSet(TraverseMode.WALK), - LinkingDirection.BOTH_WAYS, + LinkingDirection.BIDIRECTIONAL, (vertex, streetVertex) -> List.of( StreetVehicleRentalLink.createStreetVehicleRentalLink( diff --git a/application/src/test/java/org/opentripplanner/ConstantsForTests.java b/application/src/test/java/org/opentripplanner/ConstantsForTests.java index 97a73196733..4797de1a41a 100644 --- a/application/src/test/java/org/opentripplanner/ConstantsForTests.java +++ b/application/src/test/java/org/opentripplanner/ConstantsForTests.java @@ -353,7 +353,7 @@ private static void addPortlandVehicleRentals(Graph graph) { linker.linkVertexPermanently( stationVertex, new TraverseModeSet(TraverseMode.WALK), - LinkingDirection.BOTH_WAYS, + LinkingDirection.BIDIRECTIONAL, (vertex, streetVertex) -> List.of( StreetVehicleRentalLink.createStreetVehicleRentalLink( diff --git a/application/src/test/java/org/opentripplanner/graph_builder/module/linking/TestGraph.java b/application/src/test/java/org/opentripplanner/graph_builder/module/linking/TestGraph.java index a21b7aff55a..4bc9ca4a39b 100644 --- a/application/src/test/java/org/opentripplanner/graph_builder/module/linking/TestGraph.java +++ b/application/src/test/java/org/opentripplanner/graph_builder/module/linking/TestGraph.java @@ -70,7 +70,7 @@ public static void link(Graph graph, TimetableRepository timetableRepository) { linker.linkVertexPermanently( tStop, new TraverseModeSet(TraverseMode.WALK), - LinkingDirection.BOTH_WAYS, + LinkingDirection.BIDIRECTIONAL, (vertex, streetVertex) -> List.of( StreetTransitStopLink.createStreetTransitStopLink( diff --git a/application/src/test/java/org/opentripplanner/routing/linking/LinkStopToPlatformTest.java b/application/src/test/java/org/opentripplanner/routing/linking/LinkStopToPlatformTest.java index b99215b057b..971b08a8b22 100644 --- a/application/src/test/java/org/opentripplanner/routing/linking/LinkStopToPlatformTest.java +++ b/application/src/test/java/org/opentripplanner/routing/linking/LinkStopToPlatformTest.java @@ -6,7 +6,6 @@ import java.util.ArrayList; import java.util.List; -import java.util.Set; import org.junit.jupiter.api.Test; import org.locationtech.jts.geom.Coordinate; import org.locationtech.jts.geom.GeometryFactory; @@ -253,7 +252,7 @@ private void linkStops(Graph graph) { linker.linkVertexPermanently( tStop, new TraverseModeSet(TraverseMode.WALK), - LinkingDirection.BOTH_WAYS, + LinkingDirection.BIDIRECTIONAL, (vertex, streetVertex) -> List.of( StreetTransitStopLink.createStreetTransitStopLink( diff --git a/application/src/test/java/org/opentripplanner/routing/linking/LinkingDirectionTest.java b/application/src/test/java/org/opentripplanner/routing/linking/LinkingDirectionTest.java index 7ed19855960..10a0d31f911 100644 --- a/application/src/test/java/org/opentripplanner/routing/linking/LinkingDirectionTest.java +++ b/application/src/test/java/org/opentripplanner/routing/linking/LinkingDirectionTest.java @@ -11,13 +11,13 @@ class LinkingDirectionTest { void allowOutgoing() { assertFalse(LinkingDirection.INCOMING.allowOutgoing()); assertTrue(LinkingDirection.OUTGOING.allowOutgoing()); - assertTrue(LinkingDirection.BOTH_WAYS.allowOutgoing()); + assertTrue(LinkingDirection.BIDIRECTIONAL.allowOutgoing()); } @Test void allowIncoming() { assertTrue(LinkingDirection.INCOMING.allowIncoming()); assertFalse(LinkingDirection.OUTGOING.allowIncoming()); - assertTrue(LinkingDirection.BOTH_WAYS.allowIncoming()); + assertTrue(LinkingDirection.BIDIRECTIONAL.allowIncoming()); } } diff --git a/application/src/test/java/org/opentripplanner/street/model/edge/StreetEdgeSplittingTest.java b/application/src/test/java/org/opentripplanner/street/model/edge/StreetEdgeSplittingTest.java index 0507d3d812b..1f01bf6c138 100644 --- a/application/src/test/java/org/opentripplanner/street/model/edge/StreetEdgeSplittingTest.java +++ b/application/src/test/java/org/opentripplanner/street/model/edge/StreetEdgeSplittingTest.java @@ -76,7 +76,7 @@ public void turnRestrictionFromEdgeSplitWithTemporary() { var splitResult = streetEdge1.splitNonDestructively( splitVtx, disposableEdgeCollection, - LinkingDirection.BOTH_WAYS + LinkingDirection.BIDIRECTIONAL ); assertTrue(splitResult.head().getTurnRestrictions().isEmpty()); assertFalse(splitResult.tail().getTurnRestrictions().isEmpty()); @@ -97,7 +97,7 @@ public void turnRestrictionToEdgeSplitTemporary() { var splitResult = streetEdge2.splitNonDestructively( splitVtx, disposableEdgeCollection, - LinkingDirection.BOTH_WAYS + LinkingDirection.BIDIRECTIONAL ); assertEquals(splitResult.head(), addedRestriction(streetEdge1).to); assertOriginalRestrictionExists(); From 13e12457ba12333f1a22e64e8d1bb38805c17ad4 Mon Sep 17 00:00:00 2001 From: Thomas Gran Date: Tue, 25 Feb 2025 15:02:21 +0100 Subject: [PATCH 29/69] refactor: Move LinkingDirection to o.o.street.model.edge The enum is used in StreetEdge, so it need to be in the model to avoid circular dependencies --- .../graph_builder/module/OsmBoardingLocationsModule.java | 2 +- .../graph_builder/module/StreetLinkerModule.java | 2 +- .../org/opentripplanner/routing/graph/index/StreetIndex.java | 2 +- .../java/org/opentripplanner/routing/linking/VertexLinker.java | 1 + .../via/service/DefaultViaCoordinateTransferFactory.java | 2 +- .../linking => street/model/edge}/LinkingDirection.java | 2 +- .../java/org/opentripplanner/street/model/edge/StreetEdge.java | 1 - .../updater/vehicle_parking/VehicleParkingUpdater.java | 2 +- .../updater/vehicle_rental/VehicleRentalUpdater.java | 2 +- .../src/test/java/org/opentripplanner/ConstantsForTests.java | 2 +- .../opentripplanner/graph_builder/module/linking/TestGraph.java | 2 +- .../opentripplanner/routing/linking/LinkStopToPlatformTest.java | 1 + .../opentripplanner/routing/linking/LinkingDirectionTest.java | 1 + .../street/model/edge/StreetEdgeSplittingTest.java | 1 - 14 files changed, 12 insertions(+), 11 deletions(-) rename application/src/main/java/org/opentripplanner/{routing/linking => street/model/edge}/LinkingDirection.java (93%) diff --git a/application/src/main/java/org/opentripplanner/graph_builder/module/OsmBoardingLocationsModule.java b/application/src/main/java/org/opentripplanner/graph_builder/module/OsmBoardingLocationsModule.java index 16f88e85208..d014736bb5a 100644 --- a/application/src/main/java/org/opentripplanner/graph_builder/module/OsmBoardingLocationsModule.java +++ b/application/src/main/java/org/opentripplanner/graph_builder/module/OsmBoardingLocationsModule.java @@ -18,7 +18,6 @@ import org.opentripplanner.graph_builder.model.GraphBuilderModule; import org.opentripplanner.routing.graph.Graph; import org.opentripplanner.routing.graph.index.StreetIndex; -import org.opentripplanner.routing.linking.LinkingDirection; import org.opentripplanner.routing.linking.VertexLinker; import org.opentripplanner.service.osminfo.OsmInfoGraphBuildService; import org.opentripplanner.service.osminfo.model.Platform; @@ -27,6 +26,7 @@ import org.opentripplanner.street.model.edge.AreaEdge; import org.opentripplanner.street.model.edge.BoardingLocationToStopLink; import org.opentripplanner.street.model.edge.Edge; +import org.opentripplanner.street.model.edge.LinkingDirection; import org.opentripplanner.street.model.edge.StreetEdge; import org.opentripplanner.street.model.edge.StreetEdgeBuilder; import org.opentripplanner.street.model.edge.StreetTransitStopLink; diff --git a/application/src/main/java/org/opentripplanner/graph_builder/module/StreetLinkerModule.java b/application/src/main/java/org/opentripplanner/graph_builder/module/StreetLinkerModule.java index 6127bfb5f69..824bf74284f 100644 --- a/application/src/main/java/org/opentripplanner/graph_builder/module/StreetLinkerModule.java +++ b/application/src/main/java/org/opentripplanner/graph_builder/module/StreetLinkerModule.java @@ -10,11 +10,11 @@ import org.opentripplanner.graph_builder.issues.ParkAndRideEntranceRemoved; import org.opentripplanner.graph_builder.model.GraphBuilderModule; import org.opentripplanner.routing.graph.Graph; -import org.opentripplanner.routing.linking.LinkingDirection; import org.opentripplanner.service.vehicleparking.VehicleParkingRepository; import org.opentripplanner.service.vehicleparking.model.VehicleParking; import org.opentripplanner.service.vehicleparking.model.VehicleParkingHelper; import org.opentripplanner.street.model.edge.Edge; +import org.opentripplanner.street.model.edge.LinkingDirection; import org.opentripplanner.street.model.edge.StreetStationCentroidLink; import org.opentripplanner.street.model.edge.StreetTransitEntranceLink; import org.opentripplanner.street.model.edge.StreetTransitStopLink; diff --git a/application/src/main/java/org/opentripplanner/routing/graph/index/StreetIndex.java b/application/src/main/java/org/opentripplanner/routing/graph/index/StreetIndex.java index 7c3cb1224a9..20dee986289 100644 --- a/application/src/main/java/org/opentripplanner/routing/graph/index/StreetIndex.java +++ b/application/src/main/java/org/opentripplanner/routing/graph/index/StreetIndex.java @@ -23,10 +23,10 @@ import org.opentripplanner.routing.api.request.StreetMode; import org.opentripplanner.routing.graph.Graph; import org.opentripplanner.routing.linking.DisposableEdgeCollection; -import org.opentripplanner.routing.linking.LinkingDirection; import org.opentripplanner.routing.linking.Scope; import org.opentripplanner.routing.linking.VertexLinker; import org.opentripplanner.street.model.edge.Edge; +import org.opentripplanner.street.model.edge.LinkingDirection; import org.opentripplanner.street.model.edge.StreetEdge; import org.opentripplanner.street.model.edge.TemporaryFreeEdge; import org.opentripplanner.street.model.edge.TemporaryPartialStreetEdge; diff --git a/application/src/main/java/org/opentripplanner/routing/linking/VertexLinker.java b/application/src/main/java/org/opentripplanner/routing/linking/VertexLinker.java index ba92e4636c9..d8db9cfce80 100644 --- a/application/src/main/java/org/opentripplanner/routing/linking/VertexLinker.java +++ b/application/src/main/java/org/opentripplanner/routing/linking/VertexLinker.java @@ -26,6 +26,7 @@ import org.opentripplanner.street.model.edge.AreaEdgeBuilder; import org.opentripplanner.street.model.edge.AreaGroup; import org.opentripplanner.street.model.edge.Edge; +import org.opentripplanner.street.model.edge.LinkingDirection; import org.opentripplanner.street.model.edge.StreetEdge; import org.opentripplanner.street.model.vertex.IntersectionVertex; import org.opentripplanner.street.model.vertex.SplitterVertex; diff --git a/application/src/main/java/org/opentripplanner/routing/via/service/DefaultViaCoordinateTransferFactory.java b/application/src/main/java/org/opentripplanner/routing/via/service/DefaultViaCoordinateTransferFactory.java index 0e11f1ea4be..080d52062aa 100644 --- a/application/src/main/java/org/opentripplanner/routing/via/service/DefaultViaCoordinateTransferFactory.java +++ b/application/src/main/java/org/opentripplanner/routing/via/service/DefaultViaCoordinateTransferFactory.java @@ -15,9 +15,9 @@ import org.opentripplanner.routing.graph.Graph; import org.opentripplanner.routing.graphfinder.NearbyStop; import org.opentripplanner.routing.linking.DisposableEdgeCollection; -import org.opentripplanner.routing.linking.LinkingDirection; import org.opentripplanner.routing.via.ViaCoordinateTransferFactory; import org.opentripplanner.routing.via.model.ViaCoordinateTransfer; +import org.opentripplanner.street.model.edge.LinkingDirection; import org.opentripplanner.street.model.edge.TemporaryFreeEdge; import org.opentripplanner.street.model.vertex.TemporaryStreetLocation; import org.opentripplanner.street.search.TraverseMode; diff --git a/application/src/main/java/org/opentripplanner/routing/linking/LinkingDirection.java b/application/src/main/java/org/opentripplanner/street/model/edge/LinkingDirection.java similarity index 93% rename from application/src/main/java/org/opentripplanner/routing/linking/LinkingDirection.java rename to application/src/main/java/org/opentripplanner/street/model/edge/LinkingDirection.java index b93f9b1ca15..7eacc27e329 100644 --- a/application/src/main/java/org/opentripplanner/routing/linking/LinkingDirection.java +++ b/application/src/main/java/org/opentripplanner/street/model/edge/LinkingDirection.java @@ -1,4 +1,4 @@ -package org.opentripplanner.routing.linking; +package org.opentripplanner.street.model.edge; /** * Represents the direction of travel of the edges created when linking a vertex into the street diff --git a/application/src/main/java/org/opentripplanner/street/model/edge/StreetEdge.java b/application/src/main/java/org/opentripplanner/street/model/edge/StreetEdge.java index ddfdc795616..4f64bcb87aa 100644 --- a/application/src/main/java/org/opentripplanner/street/model/edge/StreetEdge.java +++ b/application/src/main/java/org/opentripplanner/street/model/edge/StreetEdge.java @@ -19,7 +19,6 @@ import org.opentripplanner.framework.i18n.I18NString; import org.opentripplanner.routing.api.request.preference.RoutingPreferences; import org.opentripplanner.routing.linking.DisposableEdgeCollection; -import org.opentripplanner.routing.linking.LinkingDirection; import org.opentripplanner.routing.util.ElevationUtils; import org.opentripplanner.street.model.RentalRestrictionExtension; import org.opentripplanner.street.model.StreetTraversalPermission; diff --git a/application/src/main/java/org/opentripplanner/updater/vehicle_parking/VehicleParkingUpdater.java b/application/src/main/java/org/opentripplanner/updater/vehicle_parking/VehicleParkingUpdater.java index 326cf28fb16..639ce664b33 100644 --- a/application/src/main/java/org/opentripplanner/updater/vehicle_parking/VehicleParkingUpdater.java +++ b/application/src/main/java/org/opentripplanner/updater/vehicle_parking/VehicleParkingUpdater.java @@ -11,12 +11,12 @@ import java.util.stream.Collectors; import org.opentripplanner.routing.graph.Graph; import org.opentripplanner.routing.linking.DisposableEdgeCollection; -import org.opentripplanner.routing.linking.LinkingDirection; import org.opentripplanner.routing.linking.VertexLinker; import org.opentripplanner.service.vehicleparking.VehicleParkingRepository; import org.opentripplanner.service.vehicleparking.model.VehicleParking; import org.opentripplanner.service.vehicleparking.model.VehicleParkingHelper; import org.opentripplanner.service.vehicleparking.model.VehicleParkingState; +import org.opentripplanner.street.model.edge.LinkingDirection; import org.opentripplanner.street.model.edge.StreetVehicleParkingLink; import org.opentripplanner.street.model.edge.VehicleParkingEdge; import org.opentripplanner.street.model.vertex.VehicleParkingEntranceVertex; diff --git a/application/src/main/java/org/opentripplanner/updater/vehicle_rental/VehicleRentalUpdater.java b/application/src/main/java/org/opentripplanner/updater/vehicle_rental/VehicleRentalUpdater.java index cfa096cdf0e..f1cb602060b 100644 --- a/application/src/main/java/org/opentripplanner/updater/vehicle_rental/VehicleRentalUpdater.java +++ b/application/src/main/java/org/opentripplanner/updater/vehicle_rental/VehicleRentalUpdater.java @@ -12,7 +12,6 @@ import java.util.stream.Collectors; import java.util.stream.Stream; import org.opentripplanner.routing.linking.DisposableEdgeCollection; -import org.opentripplanner.routing.linking.LinkingDirection; import org.opentripplanner.routing.linking.VertexLinker; import org.opentripplanner.service.vehiclerental.VehicleRentalRepository; import org.opentripplanner.service.vehiclerental.model.GeofencingZone; @@ -22,6 +21,7 @@ import org.opentripplanner.service.vehiclerental.street.VehicleRentalPlaceVertex; import org.opentripplanner.street.model.RentalFormFactor; import org.opentripplanner.street.model.RentalRestrictionExtension; +import org.opentripplanner.street.model.edge.LinkingDirection; import org.opentripplanner.street.model.edge.StreetEdge; import org.opentripplanner.street.model.vertex.VertexFactory; import org.opentripplanner.street.search.TraverseMode; diff --git a/application/src/test/java/org/opentripplanner/ConstantsForTests.java b/application/src/test/java/org/opentripplanner/ConstantsForTests.java index 4797de1a41a..2944eb5a290 100644 --- a/application/src/test/java/org/opentripplanner/ConstantsForTests.java +++ b/application/src/test/java/org/opentripplanner/ConstantsForTests.java @@ -32,7 +32,6 @@ import org.opentripplanner.routing.api.request.RouteRequest; import org.opentripplanner.routing.fares.FareServiceFactory; import org.opentripplanner.routing.graph.Graph; -import org.opentripplanner.routing.linking.LinkingDirection; import org.opentripplanner.routing.linking.VertexLinker; import org.opentripplanner.service.osminfo.internal.DefaultOsmInfoGraphBuildRepository; import org.opentripplanner.service.vehicleparking.internal.DefaultVehicleParkingRepository; @@ -43,6 +42,7 @@ import org.opentripplanner.service.vehiclerental.street.VehicleRentalPlaceVertex; import org.opentripplanner.standalone.config.BuildConfig; import org.opentripplanner.standalone.config.OtpConfigLoader; +import org.opentripplanner.street.model.edge.LinkingDirection; import org.opentripplanner.street.search.TraverseMode; import org.opentripplanner.street.search.TraverseModeSet; import org.opentripplanner.test.support.ResourceLoader; diff --git a/application/src/test/java/org/opentripplanner/graph_builder/module/linking/TestGraph.java b/application/src/test/java/org/opentripplanner/graph_builder/module/linking/TestGraph.java index 4bc9ca4a39b..1070751f3a3 100644 --- a/application/src/test/java/org/opentripplanner/graph_builder/module/linking/TestGraph.java +++ b/application/src/test/java/org/opentripplanner/graph_builder/module/linking/TestGraph.java @@ -2,8 +2,8 @@ import java.util.List; import org.opentripplanner.routing.graph.Graph; -import org.opentripplanner.routing.linking.LinkingDirection; import org.opentripplanner.routing.linking.VertexLinker; +import org.opentripplanner.street.model.edge.LinkingDirection; import org.opentripplanner.street.model.edge.StreetTransitStopLink; import org.opentripplanner.street.model.vertex.TransitStopVertex; import org.opentripplanner.street.search.TraverseMode; diff --git a/application/src/test/java/org/opentripplanner/routing/linking/LinkStopToPlatformTest.java b/application/src/test/java/org/opentripplanner/routing/linking/LinkStopToPlatformTest.java index 971b08a8b22..15b5ced245f 100644 --- a/application/src/test/java/org/opentripplanner/routing/linking/LinkStopToPlatformTest.java +++ b/application/src/test/java/org/opentripplanner/routing/linking/LinkStopToPlatformTest.java @@ -21,6 +21,7 @@ import org.opentripplanner.street.model.edge.AreaEdgeBuilder; import org.opentripplanner.street.model.edge.AreaGroup; import org.opentripplanner.street.model.edge.Edge; +import org.opentripplanner.street.model.edge.LinkingDirection; import org.opentripplanner.street.model.edge.StreetTransitStopLink; import org.opentripplanner.street.model.vertex.IntersectionVertex; import org.opentripplanner.street.model.vertex.LabelledIntersectionVertex; diff --git a/application/src/test/java/org/opentripplanner/routing/linking/LinkingDirectionTest.java b/application/src/test/java/org/opentripplanner/routing/linking/LinkingDirectionTest.java index 10a0d31f911..752d754db82 100644 --- a/application/src/test/java/org/opentripplanner/routing/linking/LinkingDirectionTest.java +++ b/application/src/test/java/org/opentripplanner/routing/linking/LinkingDirectionTest.java @@ -4,6 +4,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import org.junit.jupiter.api.Test; +import org.opentripplanner.street.model.edge.LinkingDirection; class LinkingDirectionTest { diff --git a/application/src/test/java/org/opentripplanner/street/model/edge/StreetEdgeSplittingTest.java b/application/src/test/java/org/opentripplanner/street/model/edge/StreetEdgeSplittingTest.java index 1f01bf6c138..4a4ed498300 100644 --- a/application/src/test/java/org/opentripplanner/street/model/edge/StreetEdgeSplittingTest.java +++ b/application/src/test/java/org/opentripplanner/street/model/edge/StreetEdgeSplittingTest.java @@ -11,7 +11,6 @@ import org.opentripplanner.routing.algorithm.GraphRoutingTest; import org.opentripplanner.routing.graph.Graph; import org.opentripplanner.routing.linking.DisposableEdgeCollection; -import org.opentripplanner.routing.linking.LinkingDirection; import org.opentripplanner.street.model.StreetTraversalPermission; import org.opentripplanner.street.model.TurnRestriction; import org.opentripplanner.street.model.TurnRestrictionType; From f365779496672489831153498d74541d50d0564c Mon Sep 17 00:00:00 2001 From: Thomas Gran Date: Tue, 25 Feb 2025 15:06:59 +0100 Subject: [PATCH 30/69] doc: Remove old warning about coordinates not supported --- .../apis/transmodel/model/plan/ViaLocationInputType.java | 2 -- .../routing/api/request/via/VisitViaLocation.java | 2 -- 2 files changed, 4 deletions(-) diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/ViaLocationInputType.java b/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/ViaLocationInputType.java index 33e0fe0d24e..f7313a2bbf2 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/ViaLocationInputType.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/ViaLocationInputType.java @@ -26,8 +26,6 @@ public class ViaLocationInputType { on-board visit does not count, the traveler must alight or board at the given stop for it to to be accepted. To visit a coordinate, the traveler must walk(bike or drive) to the closest point in the street network from a stop and back to another stop to join the transit network. - - NOTE! Coordinates are NOT supported yet. """; private static final String DOC_PASS_THROUGH_VIA_LOCATION = """ diff --git a/application/src/main/java/org/opentripplanner/routing/api/request/via/VisitViaLocation.java b/application/src/main/java/org/opentripplanner/routing/api/request/via/VisitViaLocation.java index 550b1646aeb..c8dd853d8e5 100644 --- a/application/src/main/java/org/opentripplanner/routing/api/request/via/VisitViaLocation.java +++ b/application/src/main/java/org/opentripplanner/routing/api/request/via/VisitViaLocation.java @@ -14,8 +14,6 @@ * visit does not count. The traveler must alight or board at the given stop for it to to be * accepted. To visit a coordinate, the traveler must walk(bike or drive) to the closest point in * the street network from a stop and back to another stop to join the transit network. - *

- * TODO: NOTE! Coordinates are NOT supported yet. */ public class VisitViaLocation extends AbstractViaLocation { From e5177b817b7b47fdc55d23e9714cf41fa540c178 Mon Sep 17 00:00:00 2001 From: Thomas Gran Date: Tue, 25 Feb 2025 15:24:08 +0100 Subject: [PATCH 31/69] doc: Add JavaDoc to ViaCoordinateTransferFactory --- .../routing/via/ViaCoordinateTransferFactory.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/application/src/main/java/org/opentripplanner/routing/via/ViaCoordinateTransferFactory.java b/application/src/main/java/org/opentripplanner/routing/via/ViaCoordinateTransferFactory.java index 747c782a662..363ce1bd6b9 100644 --- a/application/src/main/java/org/opentripplanner/routing/via/ViaCoordinateTransferFactory.java +++ b/application/src/main/java/org/opentripplanner/routing/via/ViaCoordinateTransferFactory.java @@ -5,6 +5,10 @@ import org.opentripplanner.routing.api.request.RouteRequest; import org.opentripplanner.routing.via.model.ViaCoordinateTransfer; +/** + * This class is a factory for creating {@link ViaCoordinateTransfer}s. It is injected into + * the transit router using dependency injection. + */ public interface ViaCoordinateTransferFactory { List createViaTransfers( RouteRequest request, From 5dcc881447eefe748649c34fd75d53aa143e82e1 Mon Sep 17 00:00:00 2001 From: Thomas Gran Date: Tue, 25 Feb 2025 15:28:21 +0100 Subject: [PATCH 32/69] doc: Fix spelling --- .../opentripplanner/routing/api/request/RouteRequest.java | 2 +- .../org/opentripplanner/apis/transmodel/schema.graphql | 2 -- .../multicriteria/configure/McRangeRaptorConfig.java | 6 +++--- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/application/src/main/java/org/opentripplanner/routing/api/request/RouteRequest.java b/application/src/main/java/org/opentripplanner/routing/api/request/RouteRequest.java index 8ac0ce7fca4..c362e43194e 100644 --- a/application/src/main/java/org/opentripplanner/routing/api/request/RouteRequest.java +++ b/application/src/main/java/org/opentripplanner/routing/api/request/RouteRequest.java @@ -282,7 +282,7 @@ public void setTo(GenericLocation to) { } /** - * TransferOptimization is appled to all results exept via-visit requests. + * TransferOptimization is applied to all results except via-visit requests. * TODO VIA - When the Optimized transfer support this, then this method should be removed. */ public boolean allowTransferOptimization() { diff --git a/application/src/main/resources/org/opentripplanner/apis/transmodel/schema.graphql b/application/src/main/resources/org/opentripplanner/apis/transmodel/schema.graphql index dd0c8535351..a7ec89c9ed6 100644 --- a/application/src/main/resources/org/opentripplanner/apis/transmodel/schema.graphql +++ b/application/src/main/resources/org/opentripplanner/apis/transmodel/schema.graphql @@ -2258,8 +2258,6 @@ A visit-via-location is a physical visit to one of the stop locations or coordin on-board visit does not count, the traveler must alight or board at the given stop for it to to be accepted. To visit a coordinate, the traveler must walk(bike or drive) to the closest point in the street network from a stop and back to another stop to join the transit network. - -NOTE! Coordinates are NOT supported yet. """ input TripVisitViaLocationInput { "A coordinate to route through." diff --git a/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/multicriteria/configure/McRangeRaptorConfig.java b/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/multicriteria/configure/McRangeRaptorConfig.java index b74a49ce430..b0162acc698 100644 --- a/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/multicriteria/configure/McRangeRaptorConfig.java +++ b/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/multicriteria/configure/McRangeRaptorConfig.java @@ -66,14 +66,14 @@ public McRangeRaptorConfig( /** * Static factory method to allow the {@link org.opentripplanner.raptor.configure.RaptorConfig} * inject PassThroughPointsService. - * TODO VIA - This method is not needed when pass-through is poted to use the chanied-worker + * TODO VIA - This method is not needed when pass-through is ported to use the chained-worker * strategy, and not c2. */ public static PassThroughPointsService createPassThroughPointsService( - boolean enableMcPassThrought, + boolean enableMcPassThrough, List viaLocations ) { - return enableMcPassThrought + return enableMcPassThrough ? BitSetPassThroughPointsService.of(viaLocations) : BitSetPassThroughPointsService.NOOP; } From 55f88051517cf40592342ac1c0718da8361853b6 Mon Sep 17 00:00:00 2001 From: Teemu Kalvas Date: Wed, 26 Feb 2025 12:24:24 +0200 Subject: [PATCH 33/69] change State.reversedClone time handling back, reversed times must change to work with changed arriveBy time rounding logic --- .../router/street/DirectStreetRouter.java | 1 + .../routing/impl/GraphPathFinder.java | 14 +++++++++++--- .../opentripplanner/street/search/state/State.java | 7 +++++-- .../street/integration/WalkRoutingTest.java | 7 +++++-- 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/router/street/DirectStreetRouter.java b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/router/street/DirectStreetRouter.java index 7d73d705dfe..757dd02bbd8 100644 --- a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/router/street/DirectStreetRouter.java +++ b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/router/street/DirectStreetRouter.java @@ -57,6 +57,7 @@ public static List route(OtpServerRequestContext serverContext, Route directRequest, temporaryVertices ); + var path = paths.getFirst(); // Convert the internal GraphPaths to itineraries final GraphPathToItineraryMapper graphPathToItineraryMapper = new GraphPathToItineraryMapper( diff --git a/application/src/main/java/org/opentripplanner/routing/impl/GraphPathFinder.java b/application/src/main/java/org/opentripplanner/routing/impl/GraphPathFinder.java index 0fe5d4ed95e..27c597de204 100644 --- a/application/src/main/java/org/opentripplanner/routing/impl/GraphPathFinder.java +++ b/application/src/main/java/org/opentripplanner/routing/impl/GraphPathFinder.java @@ -139,7 +139,7 @@ public List> graphPathFinderEntryPoint( Set to ) { OTPRequestTimeoutException.checkForTimeout(); - Instant reqTime = request.dateTime(); + Instant reqTime = request.dateTime().truncatedTo(ChronoUnit.MILLIS); List> paths = getPaths(request, from, to); @@ -152,12 +152,20 @@ public List> graphPathFinderEntryPoint( // TODO check, is it possible that arriveBy and time are modifed in-place by the search? if (request.arriveBy()) { if (graphPath.states.getLast().getTimeAccurate().isAfter(reqTime)) { - LOG.error("A graph path arrives {} after the requested time {}. This implies a bug.", graphPath.states.getLast().getTimeAccurate(), reqTime); + LOG.error( + "A graph path arrives {} after the requested time {}. This implies a bug.", + graphPath.states.getLast().getTimeAccurate(), + reqTime + ); gpi.remove(); } } else { if (graphPath.states.getFirst().getTimeAccurate().isBefore(reqTime)) { - LOG.error("A graph path leaves {} before the requested time {}. This implies a bug.", graphPath.states.getFirst().getTimeAccurate(), reqTime); + LOG.error( + "A graph path leaves {} before the requested time {}. This implies a bug.", + graphPath.states.getFirst().getTimeAccurate(), + reqTime + ); gpi.remove(); } } diff --git a/application/src/main/java/org/opentripplanner/street/search/state/State.java b/application/src/main/java/org/opentripplanner/street/search/state/State.java index 9b4c50580cf..19ef2ba1f9b 100644 --- a/application/src/main/java/org/opentripplanner/street/search/state/State.java +++ b/application/src/main/java/org/opentripplanner/street/search/state/State.java @@ -526,8 +526,11 @@ private double getWalkDistanceDelta() { } private State reversedClone() { + // these must be getTime(), not getTimeAccurate(), so that the reversed path (which does not + // have arriveBy true anymore) has times which round correctly, as the rounding rules + // depend on arriveBy StreetSearchRequest reversedRequest = request - .copyOfReversed(getTimeAccurate()) + .copyOfReversed(getTime()) .withPreferences(p -> { p.withCar(c -> c.withRental(r -> r.withUseAvailabilityInformation(false))); p.withBike(b -> b.withRental(r -> r.withUseAvailabilityInformation(false))); @@ -535,7 +538,7 @@ private State reversedClone() { .build(); StateData newStateData = stateData.clone(); newStateData.backMode = null; - return new State(this.vertex, getTimeAccurate(), newStateData, reversedRequest); + return new State(this.vertex, getTime(), newStateData, reversedRequest); } /** diff --git a/application/src/test/java/org/opentripplanner/street/integration/WalkRoutingTest.java b/application/src/test/java/org/opentripplanner/street/integration/WalkRoutingTest.java index b4f81410cfd..950ba427525 100644 --- a/application/src/test/java/org/opentripplanner/street/integration/WalkRoutingTest.java +++ b/application/src/test/java/org/opentripplanner/street/integration/WalkRoutingTest.java @@ -52,7 +52,7 @@ void shouldRouteAroundRoundabout() { } @ParameterizedTest - @ValueSource(ints = {0, 200, 400, 499, 500, 501, 600, 700, 800, 900, 999}) + @ValueSource(ints = { 0, 200, 400, 499, 500, 501, 600, 700, 800, 900, 999 }) void pathReversalWorks(int offset) { var start = new GenericLocation(59.94646, 10.77511); var end = new GenericLocation(59.94641, 10.77522); @@ -61,7 +61,10 @@ void pathReversalWorks(int offset) { var results = route(roundabout, start, end, time, true); Assertions.assertEquals(1, results.size()); var states = results.get(0).states; - var diff = ChronoUnit.MILLIS.between(states.getFirst().getTimeAccurate(), states.getLast().getTimeAccurate()); + var diff = ChronoUnit.MILLIS.between( + states.getFirst().getTimeAccurate(), + states.getLast().getTimeAccurate() + ); Assertions.assertEquals(13926, diff); // should be same for every parametrized offset, otherwise irrelevant } From e5d070c64270551fc0ea8be5050e3ea3d7f1a0e8 Mon Sep 17 00:00:00 2001 From: Teemu Kalvas Date: Wed, 26 Feb 2025 12:35:18 +0200 Subject: [PATCH 34/69] remove left-behind debug code --- .../raptoradapter/router/street/DirectStreetRouter.java | 1 - 1 file changed, 1 deletion(-) diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/router/street/DirectStreetRouter.java b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/router/street/DirectStreetRouter.java index 757dd02bbd8..7d73d705dfe 100644 --- a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/router/street/DirectStreetRouter.java +++ b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/router/street/DirectStreetRouter.java @@ -57,7 +57,6 @@ public static List route(OtpServerRequestContext serverContext, Route directRequest, temporaryVertices ); - var path = paths.getFirst(); // Convert the internal GraphPaths to itineraries final GraphPathToItineraryMapper graphPathToItineraryMapper = new GraphPathToItineraryMapper( From 2eda8220f3c27d47d8f92bdc858ff359bcce6ab4 Mon Sep 17 00:00:00 2001 From: Thomas Gran Date: Wed, 26 Feb 2025 13:45:03 +0100 Subject: [PATCH 35/69] refactor: Remove check enforced by the Transmodel Schema validation --- .../model/framework/CoordinateInputType.java | 22 +++++---------- .../framework/CoordinateInputTypeTest.java | 27 +++---------------- 2 files changed, 9 insertions(+), 40 deletions(-) diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/model/framework/CoordinateInputType.java b/application/src/main/java/org/opentripplanner/apis/transmodel/model/framework/CoordinateInputType.java index 268f4b62318..d940bf01b11 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/model/framework/CoordinateInputType.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/model/framework/CoordinateInputType.java @@ -43,15 +43,13 @@ public static Optional mapToWsgCoordinate( ) { Map coordinate = (Map) input.get(fieldName); - if (coordinate != null) { - return Optional.of( - new WgsCoordinate( - readCoordinateValue(LATITUDE, coordinate), - readCoordinateValue(LONGITUDE, coordinate) - ) - ); + if (coordinate == null) { + return Optional.empty(); } - return Optional.empty(); + + return Optional.of( + new WgsCoordinate((Double) coordinate.get(LATITUDE), (Double) coordinate.get(LONGITUDE)) + ); } public static Map mapForTest(WgsCoordinate coordinate) { @@ -60,12 +58,4 @@ public static Map mapForTest(WgsCoordinate coordinate) { Map.entry(LONGITUDE, coordinate.longitude()) ); } - - private static Double readCoordinateValue(String fieldName, Map coordinate) { - var value = (Double) coordinate.get(fieldName); - if (value == null) { - throw new IllegalArgumentException("The '%s' parameter is required.".formatted(fieldName)); - } - return value; - } } diff --git a/application/src/test/java/org/opentripplanner/apis/transmodel/model/framework/CoordinateInputTypeTest.java b/application/src/test/java/org/opentripplanner/apis/transmodel/model/framework/CoordinateInputTypeTest.java index 81d181194b8..11d613d235f 100644 --- a/application/src/test/java/org/opentripplanner/apis/transmodel/model/framework/CoordinateInputTypeTest.java +++ b/application/src/test/java/org/opentripplanner/apis/transmodel/model/framework/CoordinateInputTypeTest.java @@ -1,7 +1,7 @@ package org.opentripplanner.apis.transmodel.model.framework; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.Map; import org.junit.jupiter.api.Test; @@ -27,28 +27,7 @@ void mapToWsgCoordinate() { } @Test - void mapToWsgCoordinateWithMissingLongitude() { - var ex = assertThrows( - IllegalArgumentException.class, - () -> - CoordinateInputType.mapToWsgCoordinate( - "c", - Map.of("c", Map.ofEntries(Map.entry(CoordinateInputType.LONGITUDE, LONGITUDE_VALUE))) - ) - ); - assertEquals("The 'latitude' parameter is required.", ex.getMessage()); - } - - @Test - void mapToWsgCoordinateWithMissingLatitude() { - var ex = assertThrows( - IllegalArgumentException.class, - () -> - CoordinateInputType.mapToWsgCoordinate( - "c", - Map.of("c", Map.ofEntries(Map.entry(CoordinateInputType.LATITUDE, LATITUDE_VALUE))) - ) - ); - assertEquals("The 'longitude' parameter is required.", ex.getMessage()); + void mapEmptyCoordinateToNull() { + assertTrue(CoordinateInputType.mapToWsgCoordinate("c", Map.of()).isEmpty()); } } From 7a97e8f7f3f702a94b5f411b58c1dd2255e34672 Mon Sep 17 00:00:00 2001 From: Thomas Gran Date: Wed, 26 Feb 2025 13:49:27 +0100 Subject: [PATCH 36/69] doc: Fix spelling in SearchContextBuilder --- .../raptor/rangeraptor/context/SearchContextBuilder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/context/SearchContextBuilder.java b/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/context/SearchContextBuilder.java index 025886f9815..f13856e702b 100644 --- a/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/context/SearchContextBuilder.java +++ b/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/context/SearchContextBuilder.java @@ -54,7 +54,7 @@ private AccessPaths accessPaths() { } private List viaConnections() { - // TODO VIA - This need to be changed if we allow mixing visit-via an pass-thorugh + // TODO VIA - This need to be changed if we allow mixing visit-via and pass-through return request.searchParams().isVisitViaSearch() ? request .searchParams() From a4fe72e0a63e97f67c50416d8bca8ec69107f9dc Mon Sep 17 00:00:00 2001 From: Joel Lappalainen Date: Wed, 26 Feb 2025 16:40:58 +0200 Subject: [PATCH 37/69] Refactor max stop count limit This also fixes and issue with default values being overridden --- .../raptoradapter/router/TransitRouter.java | 4 +- .../preference/AccessEgressPreferences.java | 43 ++--- .../request/preference/MaxStopCountLimit.java | 161 ++++++++++++++++++ .../routerequest/RouteRequestConfig.java | 3 +- 4 files changed, 182 insertions(+), 29 deletions(-) create mode 100644 application/src/main/java/org/opentripplanner/routing/api/request/preference/MaxStopCountLimit.java diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/router/TransitRouter.java b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/router/TransitRouter.java index e287da7110c..8c23fdfdea9 100644 --- a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/router/TransitRouter.java +++ b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/router/TransitRouter.java @@ -266,9 +266,7 @@ private Collection fetchAccessEgresses(AccessEgre .accessEgress(); Duration durationLimit = accessEgressPreferences.maxDuration().valueOf(mode); - int stopCountLimit = accessEgressPreferences - .maxStopCountForMode() - .getOrDefault(mode, accessEgressPreferences.defaultMaxStopCount()); + int stopCountLimit = accessEgressPreferences.maxStopCountLimit().limitForMode(mode); var nearbyStops = AccessEgressRouter.findAccessEgresses( accessRequest, diff --git a/application/src/main/java/org/opentripplanner/routing/api/request/preference/AccessEgressPreferences.java b/application/src/main/java/org/opentripplanner/routing/api/request/preference/AccessEgressPreferences.java index 46419924fa8..6aec68f9ac5 100644 --- a/application/src/main/java/org/opentripplanner/routing/api/request/preference/AccessEgressPreferences.java +++ b/application/src/main/java/org/opentripplanner/routing/api/request/preference/AccessEgressPreferences.java @@ -4,7 +4,6 @@ import java.io.Serializable; import java.time.Duration; -import java.util.Collections; import java.util.Map; import java.util.Objects; import java.util.function.Consumer; @@ -28,21 +27,18 @@ public final class AccessEgressPreferences implements Serializable { private final TimeAndCostPenaltyForEnum penalty; private final DurationForEnum maxDuration; - private final int defaultMaxStopCount; - private final Map maxStopCountForMode; + private final MaxStopCountLimit maxStopCountLimit; private AccessEgressPreferences() { this.maxDuration = durationForStreetModeOf(ofMinutes(45)); this.penalty = DEFAULT_TIME_AND_COST; - this.defaultMaxStopCount = 500; - this.maxStopCountForMode = Map.of(); + this.maxStopCountLimit = new MaxStopCountLimit(); } private AccessEgressPreferences(Builder builder) { this.maxDuration = builder.maxDuration; this.penalty = builder.penalty; - this.defaultMaxStopCount = builder.defaultMaxStopCount; - this.maxStopCountForMode = Collections.unmodifiableMap(builder.maxStopCountForMode); + this.maxStopCountLimit = builder.maxStopCountLimit; } public static Builder of() { @@ -61,12 +57,8 @@ public DurationForEnum maxDuration() { return maxDuration; } - public int defaultMaxStopCount() { - return defaultMaxStopCount; - } - - public Map maxStopCountForMode() { - return maxStopCountForMode; + public MaxStopCountLimit maxStopCountLimit() { + return maxStopCountLimit; } @Override @@ -77,14 +69,13 @@ public boolean equals(Object o) { return ( penalty.equals(that.penalty) && maxDuration.equals(that.maxDuration) && - defaultMaxStopCount == that.defaultMaxStopCount && - maxStopCountForMode.equals(that.maxStopCountForMode) + maxStopCountLimit.equals(that.maxStopCountLimit) ); } @Override public int hashCode() { - return Objects.hash(penalty, maxDuration, defaultMaxStopCount, maxStopCountForMode); + return Objects.hash(penalty, maxDuration, maxStopCountLimit); } @Override @@ -93,8 +84,7 @@ public String toString() { .of(AccessEgressPreferences.class) .addObj("penalty", penalty, DEFAULT.penalty) .addObj("maxDuration", maxDuration, DEFAULT.maxDuration) - .addObj("defaultMaxStopCount", defaultMaxStopCount, DEFAULT.defaultMaxStopCount) - .addObj("maxStopCountForMode", maxStopCountForMode, DEFAULT.maxStopCountForMode) + .addObj("maxStopCount", maxStopCountLimit, DEFAULT.maxStopCountLimit) .toString(); } @@ -103,15 +93,13 @@ public static class Builder { private final AccessEgressPreferences original; private TimeAndCostPenaltyForEnum penalty; private DurationForEnum maxDuration; - private Map maxStopCountForMode; - private int defaultMaxStopCount; + private MaxStopCountLimit maxStopCountLimit; public Builder(AccessEgressPreferences original) { this.original = original; this.maxDuration = original.maxDuration; this.penalty = original.penalty; - this.defaultMaxStopCount = original.defaultMaxStopCount; - this.maxStopCountForMode = original.maxStopCountForMode; + this.maxStopCountLimit = original.maxStopCountLimit; } public Builder withMaxDuration(Consumer> body) { @@ -124,13 +112,18 @@ public Builder withMaxDuration(Duration defaultValue, Map return withMaxDuration(b -> b.withDefault(defaultValue).withValues(values)); } + public Builder withMaxStopCount(Consumer body) { + this.maxStopCountLimit = this.maxStopCountLimit.copyOf().apply(body).build(); + return this; + } + public Builder withMaxStopCount( int defaultMaxStopCount, Map maxStopCountForMode ) { - this.defaultMaxStopCount = defaultMaxStopCount; - this.maxStopCountForMode = maxStopCountForMode; - return this; + return withMaxStopCount(b -> + b.withDefaultLimit(defaultMaxStopCount).withValues(maxStopCountForMode) + ); } public Builder withPenalty(Consumer> body) { diff --git a/application/src/main/java/org/opentripplanner/routing/api/request/preference/MaxStopCountLimit.java b/application/src/main/java/org/opentripplanner/routing/api/request/preference/MaxStopCountLimit.java new file mode 100644 index 00000000000..4c6739d6039 --- /dev/null +++ b/application/src/main/java/org/opentripplanner/routing/api/request/preference/MaxStopCountLimit.java @@ -0,0 +1,161 @@ +package org.opentripplanner.routing.api.request.preference; + +import java.util.EnumMap; +import java.util.Map; +import java.util.Objects; +import java.util.function.Consumer; +import org.opentripplanner.routing.api.request.StreetMode; +import org.opentripplanner.utils.lang.IntUtils; +import org.opentripplanner.utils.tostring.ToStringBuilder; + +/** + * This class is used for storing default and mode specific stop count limits for access and egress + * routing. + */ +public class MaxStopCountLimit { + + public static final int DEFAULT_LIMIT = 500; + private static final Map DEFAULT_FOR_MODE = Map.of(); + + private final int defaultLimit; + private final Map limitForMode; + + public MaxStopCountLimit() { + this.defaultLimit = DEFAULT_LIMIT; + this.limitForMode = DEFAULT_FOR_MODE; + } + + MaxStopCountLimit(Builder builder) { + this.defaultLimit = IntUtils.requireNotNegative(builder.defaultLimit()); + this.limitForMode = builder.copyValueForEnum(); + } + + public Builder copyOf() { + return new Builder(this); + } + + /** + * Get the max stop count limit for mode. If no custom value is defined, default is used. + */ + public int limitForMode(StreetMode mode) { + return limitForMode.getOrDefault(mode, defaultLimit); + } + + @Override + public String toString() { + return ToStringBuilder + .of(MaxStopCountLimit.class) + .addNum("defaultLimit", defaultLimit, DEFAULT_LIMIT) + .addObj("limitForMode", limitForMode, DEFAULT_FOR_MODE) + .toString(); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + var that = (MaxStopCountLimit) o; + + return (defaultLimit == that.defaultLimit && limitForMode.equals(that.limitForMode)); + } + + @Override + public int hashCode() { + return Objects.hash(defaultLimit, limitForMode); + } + + private int defaultLimit() { + return defaultLimit; + } + + private Map limitForMode() { + return limitForMode; + } + + private boolean hasCustomLimit(StreetMode mode) { + return limitForMode.containsKey(mode); + } + + public static class Builder { + + private final MaxStopCountLimit original; + private int defaultLimit; + private Map limitForMode = null; + + Builder(MaxStopCountLimit original) { + this.original = original; + this.defaultLimit = original.defaultLimit(); + } + + int defaultLimit() { + return defaultLimit; + } + + Map limitForMode() { + return limitForMode; + } + + public Builder withDefaultLimit(int defaultLimit) { + this.defaultLimit = defaultLimit; + return this; + } + + public Builder with(StreetMode mode, Integer limit) { + // Lazy initialize the valueForEnum map + if (limitForMode == null) { + limitForMode = new EnumMap<>(StreetMode.class); + for (StreetMode it : StreetMode.values()) { + if (original.hasCustomLimit(it)) { + limitForMode.put(it, original.limitForMode(it)); + } + } + } + limitForMode.put(mode, limit); + return this; + } + + public Builder withValues(Map values) { + for (Map.Entry e : values.entrySet()) { + with(e.getKey(), e.getValue()); + } + return this; + } + + /** + * Build a copy of the current values, excluding the defaultLimit from the map. This + * ensures equality and make a defencive copy of the builder values. Hence, the builder + * can be used to generate new values if desired. + * */ + Map copyValueForEnum() { + if (limitForMode == null) { + // The limitForMode is protected and should never be mutated, so we can reuse it + return original.limitForMode(); + } + + var copy = new EnumMap(StreetMode.class); + for (Map.Entry it : limitForMode.entrySet()) { + if (defaultLimit != it.getValue()) { + copy.put(it.getKey(), it.getValue()); + } + } + return copy; + } + + public Builder apply(Consumer body) { + body.accept(this); + return this; + } + + public MaxStopCountLimit build() { + var it = new MaxStopCountLimit(this); + + // Return original if not change, subscriber is not notified + if (original != null && original.equals(it)) { + return original; + } + + return it; + } + } +} diff --git a/application/src/main/java/org/opentripplanner/standalone/config/routerequest/RouteRequestConfig.java b/application/src/main/java/org/opentripplanner/standalone/config/routerequest/RouteRequestConfig.java index 5d49f53a12b..e1e3911e02c 100644 --- a/application/src/main/java/org/opentripplanner/standalone/config/routerequest/RouteRequestConfig.java +++ b/application/src/main/java/org/opentripplanner/standalone/config/routerequest/RouteRequestConfig.java @@ -27,6 +27,7 @@ import org.opentripplanner.routing.api.request.preference.BikePreferences; import org.opentripplanner.routing.api.request.preference.CarPreferences; import org.opentripplanner.routing.api.request.preference.EscalatorPreferences; +import org.opentripplanner.routing.api.request.preference.MaxStopCountLimit; import org.opentripplanner.routing.api.request.preference.RoutingPreferences; import org.opentripplanner.routing.api.request.preference.ScooterPreferences; import org.opentripplanner.routing.api.request.preference.StreetPreferences; @@ -544,7 +545,7 @@ duration can be set per mode(`maxDurationForMode`), because some street modes se Safety limit to prevent access to and egress from too many stops. """ ) - .asInt(dftAccessEgress.defaultMaxStopCount()), + .asInt(MaxStopCountLimit.DEFAULT_LIMIT), cae .of("maxStopCountForMode") .since(V2_7) From 6aa80e32c05b9fe43cf9de02d524c6471f8679d5 Mon Sep 17 00:00:00 2001 From: Thomas Gran Date: Wed, 26 Feb 2025 16:01:13 +0100 Subject: [PATCH 38/69] refactor: Move via request mapping out one level The via mapping was done in the mc-criteria mapping block, but the via is part of the search-criteria --- .../raptoradapter/transit/mappers/RaptorRequestMapper.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/RaptorRequestMapper.java b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/RaptorRequestMapper.java index 3c37f7ef0d2..dba6de60593 100644 --- a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/RaptorRequestMapper.java +++ b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/RaptorRequestMapper.java @@ -90,7 +90,6 @@ public static RaptorRequest mapRequest( private RaptorRequest doMap() { var builder = new RaptorRequestBuilder(); var searchParams = builder.searchParams(); - var preferences = request.preferences(); // TODO Fix the Raptor search so pass-through and via search can be used together. @@ -125,6 +124,8 @@ private RaptorRequest doMap() { searchParams.searchWindow(c.searchWindow()); } + builder.searchParams().addViaLocations(mapViaLocations()); + if (preferences.transfer().maxTransfers() != null) { searchParams.maxNumberOfTransfers(preferences.transfer().maxTransfers()); } @@ -137,8 +138,6 @@ private RaptorRequest doMap() { var pt = preferences.transit(); var r = pt.raptor(); - builder.searchParams().addViaLocations(mapViaLocations()); - // relax transit group priority can be used with via-visit-stop, but not with pass-through if (pt.isRelaxTransitGroupPrioritySet() && !hasPassThroughOnly()) { mapRelaxTransitGroupPriority(mcBuilder, pt); From 43e6882370d38399fbab0a9b04b28bbcd7136e50 Mon Sep 17 00:00:00 2001 From: Thomas Gran Date: Wed, 26 Feb 2025 16:01:30 +0100 Subject: [PATCH 39/69] refactor: Add toString to AllowAllTransitFilter --- .../api/request/request/filter/AllowAllTransitFilter.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/application/src/main/java/org/opentripplanner/routing/api/request/request/filter/AllowAllTransitFilter.java b/application/src/main/java/org/opentripplanner/routing/api/request/request/filter/AllowAllTransitFilter.java index d362db5d345..b22a1540ea1 100644 --- a/application/src/main/java/org/opentripplanner/routing/api/request/request/filter/AllowAllTransitFilter.java +++ b/application/src/main/java/org/opentripplanner/routing/api/request/request/filter/AllowAllTransitFilter.java @@ -26,4 +26,9 @@ public boolean matchTripPattern(TripPattern tripPattern) { public boolean matchTripTimes(TripTimes trip) { return true; } + + @Override + public String toString() { + return "ALLOW_ALL"; + } } From 5889c9073127d1497f225aab30f58abccec8df65 Mon Sep 17 00:00:00 2001 From: Joel Lappalainen Date: Wed, 26 Feb 2025 17:08:34 +0200 Subject: [PATCH 40/69] Fix defaultLimit --- .../api/request/preference/MaxStopCountLimit.java | 14 +++++--------- .../config/routerequest/RouteRequestConfig.java | 2 +- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/application/src/main/java/org/opentripplanner/routing/api/request/preference/MaxStopCountLimit.java b/application/src/main/java/org/opentripplanner/routing/api/request/preference/MaxStopCountLimit.java index 4c6739d6039..16bd24b670a 100644 --- a/application/src/main/java/org/opentripplanner/routing/api/request/preference/MaxStopCountLimit.java +++ b/application/src/main/java/org/opentripplanner/routing/api/request/preference/MaxStopCountLimit.java @@ -14,7 +14,7 @@ */ public class MaxStopCountLimit { - public static final int DEFAULT_LIMIT = 500; + private static final int DEFAULT_LIMIT = 500; private static final Map DEFAULT_FOR_MODE = Map.of(); private final int defaultLimit; @@ -41,6 +41,10 @@ public int limitForMode(StreetMode mode) { return limitForMode.getOrDefault(mode, defaultLimit); } + public int defaultLimit() { + return defaultLimit; + } + @Override public String toString() { return ToStringBuilder @@ -65,10 +69,6 @@ public int hashCode() { return Objects.hash(defaultLimit, limitForMode); } - private int defaultLimit() { - return defaultLimit; - } - private Map limitForMode() { return limitForMode; } @@ -92,10 +92,6 @@ int defaultLimit() { return defaultLimit; } - Map limitForMode() { - return limitForMode; - } - public Builder withDefaultLimit(int defaultLimit) { this.defaultLimit = defaultLimit; return this; diff --git a/application/src/main/java/org/opentripplanner/standalone/config/routerequest/RouteRequestConfig.java b/application/src/main/java/org/opentripplanner/standalone/config/routerequest/RouteRequestConfig.java index e1e3911e02c..edea5c6b408 100644 --- a/application/src/main/java/org/opentripplanner/standalone/config/routerequest/RouteRequestConfig.java +++ b/application/src/main/java/org/opentripplanner/standalone/config/routerequest/RouteRequestConfig.java @@ -545,7 +545,7 @@ duration can be set per mode(`maxDurationForMode`), because some street modes se Safety limit to prevent access to and egress from too many stops. """ ) - .asInt(MaxStopCountLimit.DEFAULT_LIMIT), + .asInt(dftAccessEgress.maxStopCountLimit().defaultLimit()), cae .of("maxStopCountForMode") .since(V2_7) From edd0f1f4803987778230f278f2881830fd100589 Mon Sep 17 00:00:00 2001 From: Joel Lappalainen Date: Wed, 26 Feb 2025 17:25:19 +0200 Subject: [PATCH 41/69] Add tests --- .../preference/StreetPreferencesTest.java | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/application/src/test/java/org/opentripplanner/routing/api/request/preference/StreetPreferencesTest.java b/application/src/test/java/org/opentripplanner/routing/api/request/preference/StreetPreferencesTest.java index faf7fec9a3e..af569155d7b 100644 --- a/application/src/test/java/org/opentripplanner/routing/api/request/preference/StreetPreferencesTest.java +++ b/application/src/test/java/org/opentripplanner/routing/api/request/preference/StreetPreferencesTest.java @@ -18,6 +18,8 @@ class StreetPreferencesTest { private static final double TURN_RELUCTANCE = 2.0; private static final Duration MAX_ACCESS_EGRESS = Duration.ofMinutes(5); private static final Duration MAX_DIRECT = Duration.ofMinutes(10); + private static final int MAX_DEFAULT_STOP_COUNT = 245; + private static final int MAX_CAR_STOP_COUNT = 0; private static final Duration ROUTING_TIMEOUT = Duration.ofSeconds(3); private static final DrivingDirection DRIVING_DIRECTION = DrivingDirection.LEFT; private static final int ELEVATOR_BOARD_TIME = (int) Duration.ofMinutes(2).toSeconds(); @@ -36,6 +38,9 @@ class StreetPreferencesTest { .withIntersectionTraversalModel(INTERSECTION_TRAVERSAL_MODEL) .withAccessEgress(it -> it.withPenalty(Map.of(StreetMode.CAR_TO_PARK, CAR_TO_PARK_PENALTY))) .withAccessEgress(it -> it.withMaxDuration(MAX_ACCESS_EGRESS, Map.of())) + .withAccessEgress(it -> + it.withMaxStopCount(MAX_DEFAULT_STOP_COUNT, Map.of(StreetMode.CAR, MAX_CAR_STOP_COUNT)) + ) .withMaxDirectDuration(MAX_DIRECT, Map.of()) .withRoutingTimeout(ROUTING_TIMEOUT) .build(); @@ -67,6 +72,19 @@ void maxAccessEgressDuration() { assertEquals(MAX_ACCESS_EGRESS, subject.accessEgress().maxDuration().defaultValue()); } + @Test + void maxAccessEgressStopCountLimit() { + assertEquals(MAX_DEFAULT_STOP_COUNT, subject.accessEgress().maxStopCountLimit().defaultLimit()); + assertEquals( + MAX_DEFAULT_STOP_COUNT, + subject.accessEgress().maxStopCountLimit().limitForMode(StreetMode.BIKE) + ); + assertEquals( + MAX_CAR_STOP_COUNT, + subject.accessEgress().maxStopCountLimit().limitForMode(StreetMode.CAR) + ); + } + @Test void maxDirectDuration() { assertEquals(MAX_DIRECT, subject.maxDirectDuration().defaultValue()); @@ -120,8 +138,8 @@ void testToString() { "CAR_RENTAL: (timePenalty: 20m + 2.0 t, costFactor: 1.50), " + "CAR_HAILING: (timePenalty: 20m + 2.0 t, costFactor: 1.50), " + "FLEXIBLE: (timePenalty: 10m + 1.30 t, costFactor: 1.30)}, " + - "maxDuration: DurationForStreetMode{default:5m}" + - "}, " + + "maxDuration: DurationForStreetMode{default:5m}, " + + "maxStopCount: MaxStopCountLimit{defaultLimit: 245, limitForMode: {CAR=0}}}, " + "maxDirectDuration: DurationForStreetMode{default:10m}" + "}", subject.toString() From 50a01ce2ec7e7b2c5c22803759d0bf6ab96dc8c9 Mon Sep 17 00:00:00 2001 From: Joel Lappalainen Date: Wed, 26 Feb 2025 18:32:45 +0200 Subject: [PATCH 42/69] Move some tests and minor refactoring --- .../request/preference/MaxStopCountLimit.java | 6 ++ .../AccessEgressPreferencesTest.java | 79 +++++++++++++++++++ .../preference/MaxStopCountLimitTest.java | 52 ++++++++++++ .../preference/StreetPreferencesTest.java | 56 +------------ 4 files changed, 140 insertions(+), 53 deletions(-) create mode 100644 application/src/test/java/org/opentripplanner/routing/api/request/preference/AccessEgressPreferencesTest.java create mode 100644 application/src/test/java/org/opentripplanner/routing/api/request/preference/MaxStopCountLimitTest.java diff --git a/application/src/main/java/org/opentripplanner/routing/api/request/preference/MaxStopCountLimit.java b/application/src/main/java/org/opentripplanner/routing/api/request/preference/MaxStopCountLimit.java index 16bd24b670a..4bd4857cb38 100644 --- a/application/src/main/java/org/opentripplanner/routing/api/request/preference/MaxStopCountLimit.java +++ b/application/src/main/java/org/opentripplanner/routing/api/request/preference/MaxStopCountLimit.java @@ -17,6 +17,8 @@ public class MaxStopCountLimit { private static final int DEFAULT_LIMIT = 500; private static final Map DEFAULT_FOR_MODE = Map.of(); + public static final MaxStopCountLimit DEFAULT = new MaxStopCountLimit(); + private final int defaultLimit; private final Map limitForMode; @@ -30,6 +32,10 @@ public MaxStopCountLimit() { this.limitForMode = builder.copyValueForEnum(); } + public static Builder of() { + return DEFAULT.copyOf(); + } + public Builder copyOf() { return new Builder(this); } diff --git a/application/src/test/java/org/opentripplanner/routing/api/request/preference/AccessEgressPreferencesTest.java b/application/src/test/java/org/opentripplanner/routing/api/request/preference/AccessEgressPreferencesTest.java new file mode 100644 index 00000000000..1373f12af77 --- /dev/null +++ b/application/src/test/java/org/opentripplanner/routing/api/request/preference/AccessEgressPreferencesTest.java @@ -0,0 +1,79 @@ +package org.opentripplanner.routing.api.request.preference; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.opentripplanner.routing.api.request.preference.ImmutablePreferencesAsserts.assertEqualsAndHashCode; + +import java.time.Duration; +import java.util.Map; +import org.junit.jupiter.api.Test; +import org.opentripplanner.routing.api.request.StreetMode; +import org.opentripplanner.routing.api.request.framework.TimeAndCostPenalty; +import org.opentripplanner.routing.api.request.framework.TimePenalty; + +public class AccessEgressPreferencesTest { + + private static final Duration MAX_ACCESS_EGRESS = Duration.ofMinutes(5); + private static final int MAX_DEFAULT_STOP_COUNT = 245; + private static final int MAX_CAR_STOP_COUNT = 0; + private static final TimeAndCostPenalty CAR_TO_PARK_PENALTY = TimeAndCostPenalty.of( + TimePenalty.of("2m + 1.5t"), + 3.5 + ); + + private final AccessEgressPreferences subject = AccessEgressPreferences + .of() + .withPenalty(Map.of(StreetMode.CAR_TO_PARK, CAR_TO_PARK_PENALTY)) + .withMaxDuration(MAX_ACCESS_EGRESS, Map.of()) + .withMaxStopCount(MAX_DEFAULT_STOP_COUNT, Map.of(StreetMode.CAR, MAX_CAR_STOP_COUNT)) + .build(); + + @Test + void accessEgressPenalty() { + assertEquals(TimeAndCostPenalty.ZERO, subject.penalty().valueOf(StreetMode.WALK)); + assertEquals(CAR_TO_PARK_PENALTY, subject.penalty().valueOf(StreetMode.CAR_TO_PARK)); + } + + @Test + void maxAccessEgressDuration() { + assertEquals(MAX_ACCESS_EGRESS, subject.maxDuration().defaultValue()); + } + + @Test + void testOfAndCopyOf() { + // Return same object if no value is set + assertSame(AccessEgressPreferences.DEFAULT, AccessEgressPreferences.of().build()); + assertSame(subject, subject.copyOf().build()); + } + + @Test + void testEqualsAndHashCode() { + // Create a copy, make a change and set it back again to force creating a new object + var other = subject.copyOf().withMaxStopCount(20, Map.of()).build(); + var copy = other + .copyOf() + .withMaxStopCount(MAX_DEFAULT_STOP_COUNT, Map.of(StreetMode.CAR, MAX_CAR_STOP_COUNT)) + .build(); + assertEqualsAndHashCode(subject, other, copy); + } + + @Test + void testToString() { + assertEquals("StreetPreferences{}", StreetPreferences.DEFAULT.toString()); + assertEquals( + "AccessEgressPreferences{" + + "penalty: TimeAndCostPenaltyForEnum{" + + "CAR_TO_PARK: " + + CAR_TO_PARK_PENALTY + + ", " + + "CAR_PICKUP: (timePenalty: 20m + 2.0 t, costFactor: 1.50), " + + "CAR_RENTAL: (timePenalty: 20m + 2.0 t, costFactor: 1.50), " + + "CAR_HAILING: (timePenalty: 20m + 2.0 t, costFactor: 1.50), " + + "FLEXIBLE: (timePenalty: 10m + 1.30 t, costFactor: 1.30)}, " + + "maxDuration: DurationForStreetMode{default:5m}, " + + "maxStopCount: MaxStopCountLimit{defaultLimit: 245, limitForMode: {CAR=0}}" + + "}", + subject.toString() + ); + } +} diff --git a/application/src/test/java/org/opentripplanner/routing/api/request/preference/MaxStopCountLimitTest.java b/application/src/test/java/org/opentripplanner/routing/api/request/preference/MaxStopCountLimitTest.java new file mode 100644 index 00000000000..6519eb13cdb --- /dev/null +++ b/application/src/test/java/org/opentripplanner/routing/api/request/preference/MaxStopCountLimitTest.java @@ -0,0 +1,52 @@ +package org.opentripplanner.routing.api.request.preference; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.opentripplanner.routing.api.request.preference.ImmutablePreferencesAsserts.assertEqualsAndHashCode; + +import java.util.Map; +import org.junit.jupiter.api.Test; +import org.opentripplanner.routing.api.request.StreetMode; + +public class MaxStopCountLimitTest { + + private static final int MAX_DEFAULT_STOP_COUNT = 245; + private static final int MAX_CAR_STOP_COUNT = 0; + + private final MaxStopCountLimit subject = MaxStopCountLimit + .of() + .withDefaultLimit(MAX_DEFAULT_STOP_COUNT) + .withValues(Map.of(StreetMode.CAR, MAX_CAR_STOP_COUNT)) + .build(); + + @Test + void maxAccessEgressStopCountLimit() { + assertEquals(MAX_DEFAULT_STOP_COUNT, subject.defaultLimit()); + assertEquals(MAX_DEFAULT_STOP_COUNT, subject.limitForMode(StreetMode.BIKE)); + assertEquals(MAX_CAR_STOP_COUNT, subject.limitForMode(StreetMode.CAR)); + } + + @Test + void testOfAndCopyOf() { + // Return same object if no value is set + assertSame(MaxStopCountLimit.DEFAULT, MaxStopCountLimit.of().build()); + assertSame(subject, subject.copyOf().build()); + } + + @Test + void testEqualsAndHashCode() { + // Create a copy, make a change and set it back again to force creating a new object + var other = subject.copyOf().withDefaultLimit(20).build(); + var copy = other.copyOf().withDefaultLimit(MAX_DEFAULT_STOP_COUNT).build(); + assertEqualsAndHashCode(subject, other, copy); + } + + @Test + void testToString() { + assertEquals("StreetPreferences{}", StreetPreferences.DEFAULT.toString()); + assertEquals( + "MaxStopCountLimit{" + "defaultLimit: 245, " + "limitForMode: {CAR=0}" + "}", + subject.toString() + ); + } +} diff --git a/application/src/test/java/org/opentripplanner/routing/api/request/preference/StreetPreferencesTest.java b/application/src/test/java/org/opentripplanner/routing/api/request/preference/StreetPreferencesTest.java index af569155d7b..52b95532a66 100644 --- a/application/src/test/java/org/opentripplanner/routing/api/request/preference/StreetPreferencesTest.java +++ b/application/src/test/java/org/opentripplanner/routing/api/request/preference/StreetPreferencesTest.java @@ -7,9 +7,6 @@ import java.time.Duration; import java.util.Map; import org.junit.jupiter.api.Test; -import org.opentripplanner.routing.api.request.StreetMode; -import org.opentripplanner.routing.api.request.framework.TimeAndCostPenalty; -import org.opentripplanner.routing.api.request.framework.TimePenalty; import org.opentripplanner.street.search.intersection_model.DrivingDirection; import org.opentripplanner.street.search.intersection_model.IntersectionTraversalModel; @@ -18,17 +15,11 @@ class StreetPreferencesTest { private static final double TURN_RELUCTANCE = 2.0; private static final Duration MAX_ACCESS_EGRESS = Duration.ofMinutes(5); private static final Duration MAX_DIRECT = Duration.ofMinutes(10); - private static final int MAX_DEFAULT_STOP_COUNT = 245; - private static final int MAX_CAR_STOP_COUNT = 0; private static final Duration ROUTING_TIMEOUT = Duration.ofSeconds(3); private static final DrivingDirection DRIVING_DIRECTION = DrivingDirection.LEFT; private static final int ELEVATOR_BOARD_TIME = (int) Duration.ofMinutes(2).toSeconds(); private static final IntersectionTraversalModel INTERSECTION_TRAVERSAL_MODEL = IntersectionTraversalModel.CONSTANT; - private static final TimeAndCostPenalty CAR_TO_PARK_PENALTY = TimeAndCostPenalty.of( - TimePenalty.of("2m + 1.5t"), - 3.5 - ); private final StreetPreferences subject = StreetPreferences .of() @@ -36,11 +27,7 @@ class StreetPreferencesTest { .withTurnReluctance(TURN_RELUCTANCE) .withElevator(it -> it.withBoardTime(ELEVATOR_BOARD_TIME)) .withIntersectionTraversalModel(INTERSECTION_TRAVERSAL_MODEL) - .withAccessEgress(it -> it.withPenalty(Map.of(StreetMode.CAR_TO_PARK, CAR_TO_PARK_PENALTY))) .withAccessEgress(it -> it.withMaxDuration(MAX_ACCESS_EGRESS, Map.of())) - .withAccessEgress(it -> - it.withMaxStopCount(MAX_DEFAULT_STOP_COUNT, Map.of(StreetMode.CAR, MAX_CAR_STOP_COUNT)) - ) .withMaxDirectDuration(MAX_DIRECT, Map.of()) .withRoutingTimeout(ROUTING_TIMEOUT) .build(); @@ -55,36 +42,6 @@ void intersectionTraversalModel() { assertEquals(INTERSECTION_TRAVERSAL_MODEL, subject.intersectionTraversalModel()); } - @Test - void accessEgressPenalty() { - assertEquals( - TimeAndCostPenalty.ZERO, - subject.accessEgress().penalty().valueOf(StreetMode.WALK) - ); - assertEquals( - CAR_TO_PARK_PENALTY, - subject.accessEgress().penalty().valueOf(StreetMode.CAR_TO_PARK) - ); - } - - @Test - void maxAccessEgressDuration() { - assertEquals(MAX_ACCESS_EGRESS, subject.accessEgress().maxDuration().defaultValue()); - } - - @Test - void maxAccessEgressStopCountLimit() { - assertEquals(MAX_DEFAULT_STOP_COUNT, subject.accessEgress().maxStopCountLimit().defaultLimit()); - assertEquals( - MAX_DEFAULT_STOP_COUNT, - subject.accessEgress().maxStopCountLimit().limitForMode(StreetMode.BIKE) - ); - assertEquals( - MAX_CAR_STOP_COUNT, - subject.accessEgress().maxStopCountLimit().limitForMode(StreetMode.CAR) - ); - } - @Test void maxDirectDuration() { assertEquals(MAX_DIRECT, subject.maxDirectDuration().defaultValue()); @@ -130,16 +87,9 @@ void testToString() { "routingTimeout: 3s, " + "elevator: ElevatorPreferences{boardTime: 2m}, " + "intersectionTraversalModel: CONSTANT, " + - "accessEgress: AccessEgressPreferences{penalty: TimeAndCostPenaltyForEnum{" + - "CAR_TO_PARK: " + - CAR_TO_PARK_PENALTY + - ", " + - "CAR_PICKUP: (timePenalty: 20m + 2.0 t, costFactor: 1.50), " + - "CAR_RENTAL: (timePenalty: 20m + 2.0 t, costFactor: 1.50), " + - "CAR_HAILING: (timePenalty: 20m + 2.0 t, costFactor: 1.50), " + - "FLEXIBLE: (timePenalty: 10m + 1.30 t, costFactor: 1.30)}, " + - "maxDuration: DurationForStreetMode{default:5m}, " + - "maxStopCount: MaxStopCountLimit{defaultLimit: 245, limitForMode: {CAR=0}}}, " + + "accessEgress: AccessEgressPreferences{" + + "maxDuration: DurationForStreetMode{default:5m}" + + "}, " + "maxDirectDuration: DurationForStreetMode{default:10m}" + "}", subject.toString() From 5be0edf54a0c55f0a63800f6481e5cca7dd78955 Mon Sep 17 00:00:00 2001 From: Thomas Gran Date: Wed, 26 Feb 2025 18:04:19 +0100 Subject: [PATCH 43/69] feature: Remove none pareto optimal via options --- .../transit/mappers/RaptorRequestMapper.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/RaptorRequestMapper.java b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/RaptorRequestMapper.java index dba6de60593..6abba8de6fb 100644 --- a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/RaptorRequestMapper.java +++ b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/RaptorRequestMapper.java @@ -6,6 +6,7 @@ import java.time.Instant; import java.time.ZonedDateTime; import java.util.Collection; +import java.util.HashSet; import java.util.List; import java.util.Objects; import java.util.function.Predicate; @@ -239,9 +240,11 @@ private RaptorViaLocation mapViaLocation(ViaLocation input) { } // Visit Via location else { + var viaStops = new HashSet(); var builder = RaptorViaLocation.via(input.label(), input.minimumWaitTime()); for (int stopIndex : lookUpStopIndex.lookupStopLocationIndexes(input.stopLocationIds())) { builder.addViaStop(stopIndex); + viaStops.add(stopIndex); } for (var coordinate : input.coordinates()) { var viaTransfers = viaTransferResolver.createViaTransfers( @@ -250,6 +253,12 @@ private RaptorViaLocation mapViaLocation(ViaLocation input) { coordinate ); for (var it : viaTransfers) { + // If via-stop and via-transfers are used together then walking from a stop + // to the coordinate andd back is not pareto optimal, using just the stop + // is the optimal option. + if(it.stop() == it.fromStopIndex() && viaStops.contains(it.stop())) { + continue; + } builder.addViaTransfer(it.fromStopIndex(), it); } } From 6ff83ef4e0730c4053b4b4302e19da800c26a40e Mon Sep 17 00:00:00 2001 From: Teemu Kalvas Date: Thu, 27 Feb 2025 14:06:02 +0200 Subject: [PATCH 44/69] force initial state time to be an exact number of seconds. Force RouteRequest datetime to be an exact number of seconds. Backward and forward searches will now not match unless the request datetime is an exact number of seconds. --- .../opentripplanner/routing/api/request/RouteRequest.java | 3 ++- .../org/opentripplanner/street/search/state/State.java | 8 +++++++- .../street/integration/BarrierRoutingTest.java | 3 ++- .../street/integration/BicycleRoutingTest.java | 3 ++- .../street/integration/CarRoutingTest.java | 3 ++- .../street/integration/WalkRoutingTest.java | 2 +- 6 files changed, 16 insertions(+), 6 deletions(-) diff --git a/application/src/main/java/org/opentripplanner/routing/api/request/RouteRequest.java b/application/src/main/java/org/opentripplanner/routing/api/request/RouteRequest.java index daafe70f9e7..d32b126c311 100644 --- a/application/src/main/java/org/opentripplanner/routing/api/request/RouteRequest.java +++ b/application/src/main/java/org/opentripplanner/routing/api/request/RouteRequest.java @@ -7,6 +7,7 @@ import java.time.Instant; import java.time.ZoneId; import java.time.ZonedDateTime; +import java.time.temporal.ChronoUnit; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -54,7 +55,7 @@ public class RouteRequest implements Cloneable, Serializable { private List via = Collections.emptyList(); - private Instant dateTime = Instant.now(); + private Instant dateTime = Instant.now().truncatedTo(ChronoUnit.SECONDS); @Nullable private Duration maxSearchWindow; diff --git a/application/src/main/java/org/opentripplanner/street/search/state/State.java b/application/src/main/java/org/opentripplanner/street/search/state/State.java index 19ef2ba1f9b..bce2f2c55e5 100644 --- a/application/src/main/java/org/opentripplanner/street/search/state/State.java +++ b/application/src/main/java/org/opentripplanner/street/search/state/State.java @@ -3,6 +3,7 @@ import static org.opentripplanner.utils.lang.ObjectUtils.requireNotInitialized; import java.time.Instant; +import java.time.temporal.ChronoUnit; import java.util.ArrayList; import java.util.Collection; import java.util.Objects; @@ -92,7 +93,12 @@ public static Collection getInitialStates( for (Vertex vertex : vertices) { for (StateData stateData : StateData.getInitialStateDatas(streetSearchRequest)) { states.add( - new State(vertex, streetSearchRequest.startTime(), stateData, streetSearchRequest) + new State( + vertex, + streetSearchRequest.startTime().truncatedTo(ChronoUnit.SECONDS), + stateData, + streetSearchRequest + ) ); } } diff --git a/application/src/test/java/org/opentripplanner/street/integration/BarrierRoutingTest.java b/application/src/test/java/org/opentripplanner/street/integration/BarrierRoutingTest.java index 8092ab62bc3..52dcc771c5d 100644 --- a/application/src/test/java/org/opentripplanner/street/integration/BarrierRoutingTest.java +++ b/application/src/test/java/org/opentripplanner/street/integration/BarrierRoutingTest.java @@ -7,6 +7,7 @@ import static org.opentripplanner.test.support.PolylineAssert.assertThatPolylinesAreEqual; import java.time.Instant; +import java.time.temporal.ChronoUnit; import java.util.List; import java.util.function.Consumer; import java.util.function.Function; @@ -35,7 +36,7 @@ public class BarrierRoutingTest { - private static final Instant dateTime = Instant.now(); + private static final Instant dateTime = Instant.now().truncatedTo(ChronoUnit.SECONDS); private static Graph graph; diff --git a/application/src/test/java/org/opentripplanner/street/integration/BicycleRoutingTest.java b/application/src/test/java/org/opentripplanner/street/integration/BicycleRoutingTest.java index 60dc43aa3f9..301caeda8b2 100644 --- a/application/src/test/java/org/opentripplanner/street/integration/BicycleRoutingTest.java +++ b/application/src/test/java/org/opentripplanner/street/integration/BicycleRoutingTest.java @@ -5,6 +5,7 @@ import static org.opentripplanner.test.support.PolylineAssert.assertThatPolylinesAreEqual; import java.time.Instant; +import java.time.temporal.ChronoUnit; import org.junit.jupiter.api.Test; import org.locationtech.jts.geom.Geometry; import org.opentripplanner.ConstantsForTests; @@ -25,7 +26,7 @@ public class BicycleRoutingTest { - static final Instant dateTime = Instant.now(); + static final Instant dateTime = Instant.now().truncatedTo(ChronoUnit.SECONDS); private final Graph herrenbergGraph; { diff --git a/application/src/test/java/org/opentripplanner/street/integration/CarRoutingTest.java b/application/src/test/java/org/opentripplanner/street/integration/CarRoutingTest.java index caddf972e86..34beead9aed 100644 --- a/application/src/test/java/org/opentripplanner/street/integration/CarRoutingTest.java +++ b/application/src/test/java/org/opentripplanner/street/integration/CarRoutingTest.java @@ -5,6 +5,7 @@ import static org.opentripplanner.test.support.PolylineAssert.assertThatPolylinesAreEqual; import java.time.Instant; +import java.time.temporal.ChronoUnit; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -26,7 +27,7 @@ public class CarRoutingTest { - static final Instant dateTime = Instant.now(); + static final Instant dateTime = Instant.now().truncatedTo(ChronoUnit.SECONDS); private static final ResourceLoader RESOURCE_LOADER = ResourceLoader.of(CarRoutingTest.class); private static Graph herrenbergGraph; diff --git a/application/src/test/java/org/opentripplanner/street/integration/WalkRoutingTest.java b/application/src/test/java/org/opentripplanner/street/integration/WalkRoutingTest.java index 950ba427525..dcbd69e7778 100644 --- a/application/src/test/java/org/opentripplanner/street/integration/WalkRoutingTest.java +++ b/application/src/test/java/org/opentripplanner/street/integration/WalkRoutingTest.java @@ -23,7 +23,7 @@ class WalkRoutingTest { - static final Instant dateTime = Instant.now(); + static final Instant dateTime = Instant.now().truncatedTo(ChronoUnit.SECONDS); private final Graph roundabout; { From a455fcdcb728bb4b1beb023c5769af0c496e6af0 Mon Sep 17 00:00:00 2001 From: Joel Lappalainen Date: Thu, 27 Feb 2025 14:55:47 +0200 Subject: [PATCH 45/69] Apply suggestions from code review Co-authored-by: Ville Pihlava --- .../routing/api/request/preference/MaxStopCountLimit.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/application/src/main/java/org/opentripplanner/routing/api/request/preference/MaxStopCountLimit.java b/application/src/main/java/org/opentripplanner/routing/api/request/preference/MaxStopCountLimit.java index 4bd4857cb38..6781866c523 100644 --- a/application/src/main/java/org/opentripplanner/routing/api/request/preference/MaxStopCountLimit.java +++ b/application/src/main/java/org/opentripplanner/routing/api/request/preference/MaxStopCountLimit.java @@ -126,7 +126,7 @@ public Builder withValues(Map values) { /** * Build a copy of the current values, excluding the defaultLimit from the map. This - * ensures equality and make a defencive copy of the builder values. Hence, the builder + * ensures equality and makes a defensive copy of the builder values. Hence, the builder * can be used to generate new values if desired. * */ Map copyValueForEnum() { @@ -152,7 +152,7 @@ public Builder apply(Consumer body) { public MaxStopCountLimit build() { var it = new MaxStopCountLimit(this); - // Return original if not change, subscriber is not notified + // Return the original if there are no changes, the subscriber is not notified. if (original != null && original.equals(it)) { return original; } From 452900d5518ee845ba0865836db2c5ce751e3acb Mon Sep 17 00:00:00 2001 From: Joel Lappalainen Date: Thu, 27 Feb 2025 14:58:44 +0200 Subject: [PATCH 46/69] Fix spelling --- .../ext/dataoverlay/api/DataOverlayParameters.java | 2 +- .../routing/api/request/framework/DurationForEnum.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/application/src/ext/java/org/opentripplanner/ext/dataoverlay/api/DataOverlayParameters.java b/application/src/ext/java/org/opentripplanner/ext/dataoverlay/api/DataOverlayParameters.java index 42a0209ba94..febe4ddae2e 100644 --- a/application/src/ext/java/org/opentripplanner/ext/dataoverlay/api/DataOverlayParameters.java +++ b/application/src/ext/java/org/opentripplanner/ext/dataoverlay/api/DataOverlayParameters.java @@ -35,7 +35,7 @@ public class DataOverlayParameters implements Serializable { private final Map values; public DataOverlayParameters(Map values) { - // Make a defencive copy to protect the map entries, this make this class immutable + // Make a defensive copy to protect the map entries, this makes the class immutable // and thread safe this.values = Map.copyOf(values); } diff --git a/application/src/main/java/org/opentripplanner/routing/api/request/framework/DurationForEnum.java b/application/src/main/java/org/opentripplanner/routing/api/request/framework/DurationForEnum.java index c6586aa8b0f..1a3de4f4175 100644 --- a/application/src/main/java/org/opentripplanner/routing/api/request/framework/DurationForEnum.java +++ b/application/src/main/java/org/opentripplanner/routing/api/request/framework/DurationForEnum.java @@ -152,7 +152,7 @@ public Builder with(E key, Duration value) { /** * Build a copy of the current values, excluding the defaultValue from the map. This - * ensures equality and make a defencive copy of the builder values. Hence, the builder + * ensures equality and makes a defensive copy of the builder values. Hence, the builder * can be used to generate new values if desired. * */ Map copyValueForEnum() { @@ -185,7 +185,7 @@ public Builder apply(Consumer> body) { public DurationForEnum build() { var it = new DurationForEnum<>(this); - // Return original if not change, subscriber is not notified + // Return the original if there are no changes, the subscriber is not notified. if (original != null && original.equals(it)) { return original; } From 3b625ef412c93d87a3f5fc54c590b60e030024da Mon Sep 17 00:00:00 2001 From: Joel Lappalainen Date: Thu, 27 Feb 2025 15:03:40 +0200 Subject: [PATCH 47/69] Use less generic naming --- .../api/request/preference/AccessEgressPreferences.java | 2 +- .../routing/api/request/preference/MaxStopCountLimit.java | 8 ++++---- .../api/request/preference/MaxStopCountLimitTest.java | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/application/src/main/java/org/opentripplanner/routing/api/request/preference/AccessEgressPreferences.java b/application/src/main/java/org/opentripplanner/routing/api/request/preference/AccessEgressPreferences.java index 6aec68f9ac5..9a9bb7bdc3a 100644 --- a/application/src/main/java/org/opentripplanner/routing/api/request/preference/AccessEgressPreferences.java +++ b/application/src/main/java/org/opentripplanner/routing/api/request/preference/AccessEgressPreferences.java @@ -122,7 +122,7 @@ public Builder withMaxStopCount( Map maxStopCountForMode ) { return withMaxStopCount(b -> - b.withDefaultLimit(defaultMaxStopCount).withValues(maxStopCountForMode) + b.withDefaultLimit(defaultMaxStopCount).withLimitsForModes(maxStopCountForMode) ); } diff --git a/application/src/main/java/org/opentripplanner/routing/api/request/preference/MaxStopCountLimit.java b/application/src/main/java/org/opentripplanner/routing/api/request/preference/MaxStopCountLimit.java index 6781866c523..770e8977f42 100644 --- a/application/src/main/java/org/opentripplanner/routing/api/request/preference/MaxStopCountLimit.java +++ b/application/src/main/java/org/opentripplanner/routing/api/request/preference/MaxStopCountLimit.java @@ -29,7 +29,7 @@ public MaxStopCountLimit() { MaxStopCountLimit(Builder builder) { this.defaultLimit = IntUtils.requireNotNegative(builder.defaultLimit()); - this.limitForMode = builder.copyValueForEnum(); + this.limitForMode = builder.copyCustomLimits(); } public static Builder of() { @@ -117,8 +117,8 @@ public Builder with(StreetMode mode, Integer limit) { return this; } - public Builder withValues(Map values) { - for (Map.Entry e : values.entrySet()) { + public Builder withLimitsForModes(Map limitsForModes) { + for (Map.Entry e : limitsForModes.entrySet()) { with(e.getKey(), e.getValue()); } return this; @@ -129,7 +129,7 @@ public Builder withValues(Map values) { * ensures equality and makes a defensive copy of the builder values. Hence, the builder * can be used to generate new values if desired. * */ - Map copyValueForEnum() { + Map copyCustomLimits() { if (limitForMode == null) { // The limitForMode is protected and should never be mutated, so we can reuse it return original.limitForMode(); diff --git a/application/src/test/java/org/opentripplanner/routing/api/request/preference/MaxStopCountLimitTest.java b/application/src/test/java/org/opentripplanner/routing/api/request/preference/MaxStopCountLimitTest.java index 6519eb13cdb..d0e8db8a7d0 100644 --- a/application/src/test/java/org/opentripplanner/routing/api/request/preference/MaxStopCountLimitTest.java +++ b/application/src/test/java/org/opentripplanner/routing/api/request/preference/MaxStopCountLimitTest.java @@ -16,7 +16,7 @@ public class MaxStopCountLimitTest { private final MaxStopCountLimit subject = MaxStopCountLimit .of() .withDefaultLimit(MAX_DEFAULT_STOP_COUNT) - .withValues(Map.of(StreetMode.CAR, MAX_CAR_STOP_COUNT)) + .withLimitsForModes(Map.of(StreetMode.CAR, MAX_CAR_STOP_COUNT)) .build(); @Test From 9eaca9519c4c5eec83edd074c8fa20f1281791e8 Mon Sep 17 00:00:00 2001 From: Joel Lappalainen Date: Thu, 27 Feb 2025 15:14:56 +0200 Subject: [PATCH 48/69] More renaming --- .../request/preference/MaxStopCountLimit.java | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/application/src/main/java/org/opentripplanner/routing/api/request/preference/MaxStopCountLimit.java b/application/src/main/java/org/opentripplanner/routing/api/request/preference/MaxStopCountLimit.java index 770e8977f42..1bf6545855f 100644 --- a/application/src/main/java/org/opentripplanner/routing/api/request/preference/MaxStopCountLimit.java +++ b/application/src/main/java/org/opentripplanner/routing/api/request/preference/MaxStopCountLimit.java @@ -15,21 +15,21 @@ public class MaxStopCountLimit { private static final int DEFAULT_LIMIT = 500; - private static final Map DEFAULT_FOR_MODE = Map.of(); + private static final Map DEFAULT_FOR_MODES = Map.of(); public static final MaxStopCountLimit DEFAULT = new MaxStopCountLimit(); private final int defaultLimit; - private final Map limitForMode; + private final Map limitsForModes; public MaxStopCountLimit() { this.defaultLimit = DEFAULT_LIMIT; - this.limitForMode = DEFAULT_FOR_MODE; + this.limitsForModes = DEFAULT_FOR_MODES; } MaxStopCountLimit(Builder builder) { this.defaultLimit = IntUtils.requireNotNegative(builder.defaultLimit()); - this.limitForMode = builder.copyCustomLimits(); + this.limitsForModes = builder.copyCustomLimits(); } public static Builder of() { @@ -44,7 +44,7 @@ public Builder copyOf() { * Get the max stop count limit for mode. If no custom value is defined, default is used. */ public int limitForMode(StreetMode mode) { - return limitForMode.getOrDefault(mode, defaultLimit); + return limitsForModes.getOrDefault(mode, defaultLimit); } public int defaultLimit() { @@ -56,7 +56,7 @@ public String toString() { return ToStringBuilder .of(MaxStopCountLimit.class) .addNum("defaultLimit", defaultLimit, DEFAULT_LIMIT) - .addObj("limitForMode", limitForMode, DEFAULT_FOR_MODE) + .addObj("limitsForModes", limitsForModes, DEFAULT_FOR_MODES) .toString(); } @@ -67,27 +67,27 @@ public boolean equals(Object o) { var that = (MaxStopCountLimit) o; - return (defaultLimit == that.defaultLimit && limitForMode.equals(that.limitForMode)); + return (defaultLimit == that.defaultLimit && limitsForModes.equals(that.limitsForModes)); } @Override public int hashCode() { - return Objects.hash(defaultLimit, limitForMode); + return Objects.hash(defaultLimit, limitsForModes); } - private Map limitForMode() { - return limitForMode; + private Map limitsForModes() { + return limitsForModes; } private boolean hasCustomLimit(StreetMode mode) { - return limitForMode.containsKey(mode); + return limitsForModes.containsKey(mode); } public static class Builder { private final MaxStopCountLimit original; private int defaultLimit; - private Map limitForMode = null; + private Map limitsForModes = null; Builder(MaxStopCountLimit original) { this.original = original; @@ -105,15 +105,15 @@ public Builder withDefaultLimit(int defaultLimit) { public Builder with(StreetMode mode, Integer limit) { // Lazy initialize the valueForEnum map - if (limitForMode == null) { - limitForMode = new EnumMap<>(StreetMode.class); + if (limitsForModes == null) { + limitsForModes = new EnumMap<>(StreetMode.class); for (StreetMode it : StreetMode.values()) { if (original.hasCustomLimit(it)) { - limitForMode.put(it, original.limitForMode(it)); + limitsForModes.put(it, original.limitForMode(it)); } } } - limitForMode.put(mode, limit); + limitsForModes.put(mode, limit); return this; } @@ -130,13 +130,13 @@ public Builder withLimitsForModes(Map limitsForModes) { * can be used to generate new values if desired. * */ Map copyCustomLimits() { - if (limitForMode == null) { + if (limitsForModes == null) { // The limitForMode is protected and should never be mutated, so we can reuse it - return original.limitForMode(); + return original.limitsForModes(); } var copy = new EnumMap(StreetMode.class); - for (Map.Entry it : limitForMode.entrySet()) { + for (Map.Entry it : limitsForModes.entrySet()) { if (defaultLimit != it.getValue()) { copy.put(it.getKey(), it.getValue()); } From 9ed972883f1a1f4da7af1099225c3e4e9deb73d0 Mon Sep 17 00:00:00 2001 From: Joel Lappalainen Date: Thu, 27 Feb 2025 15:30:05 +0200 Subject: [PATCH 49/69] Update tests --- .../api/request/preference/AccessEgressPreferencesTest.java | 2 +- .../routing/api/request/preference/MaxStopCountLimitTest.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/application/src/test/java/org/opentripplanner/routing/api/request/preference/AccessEgressPreferencesTest.java b/application/src/test/java/org/opentripplanner/routing/api/request/preference/AccessEgressPreferencesTest.java index 1373f12af77..13fc9a60da9 100644 --- a/application/src/test/java/org/opentripplanner/routing/api/request/preference/AccessEgressPreferencesTest.java +++ b/application/src/test/java/org/opentripplanner/routing/api/request/preference/AccessEgressPreferencesTest.java @@ -71,7 +71,7 @@ void testToString() { "CAR_HAILING: (timePenalty: 20m + 2.0 t, costFactor: 1.50), " + "FLEXIBLE: (timePenalty: 10m + 1.30 t, costFactor: 1.30)}, " + "maxDuration: DurationForStreetMode{default:5m}, " + - "maxStopCount: MaxStopCountLimit{defaultLimit: 245, limitForMode: {CAR=0}}" + + "maxStopCount: MaxStopCountLimit{defaultLimit: 245, limitsForModes: {CAR=0}}" + "}", subject.toString() ); diff --git a/application/src/test/java/org/opentripplanner/routing/api/request/preference/MaxStopCountLimitTest.java b/application/src/test/java/org/opentripplanner/routing/api/request/preference/MaxStopCountLimitTest.java index d0e8db8a7d0..0291b5f39dd 100644 --- a/application/src/test/java/org/opentripplanner/routing/api/request/preference/MaxStopCountLimitTest.java +++ b/application/src/test/java/org/opentripplanner/routing/api/request/preference/MaxStopCountLimitTest.java @@ -45,7 +45,7 @@ void testEqualsAndHashCode() { void testToString() { assertEquals("StreetPreferences{}", StreetPreferences.DEFAULT.toString()); assertEquals( - "MaxStopCountLimit{" + "defaultLimit: 245, " + "limitForMode: {CAR=0}" + "}", + "MaxStopCountLimit{" + "defaultLimit: 245, " + "limitsForModes: {CAR=0}" + "}", subject.toString() ); } From 3e5333c563793e0f1bf33d932c3026dd1a6081e0 Mon Sep 17 00:00:00 2001 From: Teemu Kalvas Date: Thu, 27 Feb 2025 15:42:43 +0200 Subject: [PATCH 50/69] style fixes from review --- .../street/integration/WalkRoutingTest.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/application/src/test/java/org/opentripplanner/street/integration/WalkRoutingTest.java b/application/src/test/java/org/opentripplanner/street/integration/WalkRoutingTest.java index dcbd69e7778..7d9a2277129 100644 --- a/application/src/test/java/org/opentripplanner/street/integration/WalkRoutingTest.java +++ b/application/src/test/java/org/opentripplanner/street/integration/WalkRoutingTest.java @@ -1,9 +1,11 @@ package org.opentripplanner.street.integration; +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import static org.junit.jupiter.api.Assertions.assertEquals; + import java.time.Instant; import java.time.temporal.ChronoUnit; import java.util.List; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; @@ -48,7 +50,7 @@ class WalkRoutingTest { void shouldRouteAroundRoundabout() { var start = new GenericLocation(59.94646, 10.77511); var end = new GenericLocation(59.94641, 10.77522); - Assertions.assertDoesNotThrow(() -> route(roundabout, start, end, dateTime, false)); + assertDoesNotThrow(() -> route(roundabout, start, end, dateTime, false)); } @ParameterizedTest @@ -59,13 +61,14 @@ void pathReversalWorks(int offset) { var base = dateTime.truncatedTo(ChronoUnit.SECONDS); var time = base.plusMillis(offset); var results = route(roundabout, start, end, time, true); - Assertions.assertEquals(1, results.size()); + assertEquals(1, results.size()); var states = results.get(0).states; var diff = ChronoUnit.MILLIS.between( states.getFirst().getTimeAccurate(), states.getLast().getTimeAccurate() ); - Assertions.assertEquals(13926, diff); // should be same for every parametrized offset, otherwise irrelevant + // should be same for every parametrized offset, otherwise irrelevant + assertEquals(13926, diff); } private static List> route( From 5fb2e6b376346e20cecb681e81cd3f9dfc9170e0 Mon Sep 17 00:00:00 2001 From: Teemu Kalvas Date: Thu, 27 Feb 2025 15:54:30 +0200 Subject: [PATCH 51/69] force routerequest datetime to be accurate to one second, no more --- .../opentripplanner/routing/api/request/RouteRequest.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/application/src/main/java/org/opentripplanner/routing/api/request/RouteRequest.java b/application/src/main/java/org/opentripplanner/routing/api/request/RouteRequest.java index d32b126c311..ebf751bc50d 100644 --- a/application/src/main/java/org/opentripplanner/routing/api/request/RouteRequest.java +++ b/application/src/main/java/org/opentripplanner/routing/api/request/RouteRequest.java @@ -153,8 +153,14 @@ public Instant dateTime() { return dateTime; } + /** + * The dateTime will be set to a whole number of seconds. We don't do sub-second accuracy, + * and if we set the millisecond part to a non-zero value, rounding will not be guaranteed + * to be the same for departAt and arriveBy queries. + * @param dateTime Either a departAt time or an arriveBy time, one second's accuracy + */ public void setDateTime(Instant dateTime) { - this.dateTime = dateTime; + this.dateTime = dateTime.truncatedTo(ChronoUnit.SECONDS); } public void setDateTime(String date, String time, ZoneId tz) { From 955867f8ec8e9a758a97c068f2c266bfb9655891 Mon Sep 17 00:00:00 2001 From: Teemu Kalvas Date: Thu, 27 Feb 2025 17:36:32 +0200 Subject: [PATCH 52/69] cleanup based on review --- .../street/search/request/StreetSearchRequest.java | 5 +++-- .../org/opentripplanner/street/search/state/State.java | 7 +------ .../street/integration/BarrierRoutingTest.java | 2 +- .../street/integration/BicycleRoutingTest.java | 2 +- .../opentripplanner/street/integration/CarRoutingTest.java | 2 +- .../street/integration/WalkRoutingTest.java | 2 +- 6 files changed, 8 insertions(+), 12 deletions(-) diff --git a/application/src/main/java/org/opentripplanner/street/search/request/StreetSearchRequest.java b/application/src/main/java/org/opentripplanner/street/search/request/StreetSearchRequest.java index c93ea598256..7aa8b74352c 100644 --- a/application/src/main/java/org/opentripplanner/street/search/request/StreetSearchRequest.java +++ b/application/src/main/java/org/opentripplanner/street/search/request/StreetSearchRequest.java @@ -1,6 +1,7 @@ package org.opentripplanner.street.search.request; import java.time.Instant; +import java.time.temporal.ChronoUnit; import javax.annotation.Nullable; import org.locationtech.jts.geom.Coordinate; import org.locationtech.jts.geom.Envelope; @@ -52,7 +53,7 @@ public class StreetSearchRequest implements AStarRequest { * Constructor only used for creating a default instance. */ private StreetSearchRequest() { - this.startTime = Instant.now(); + this.startTime = Instant.now().truncatedTo(ChronoUnit.SECONDS); this.preferences = new RoutingPreferences(); this.mode = StreetMode.WALK; this.arriveBy = false; @@ -64,7 +65,7 @@ private StreetSearchRequest() { } StreetSearchRequest(StreetSearchRequestBuilder builder) { - this.startTime = builder.startTime; + this.startTime = builder.startTime.truncatedTo(ChronoUnit.SECONDS); this.preferences = builder.preferences; this.mode = builder.mode; this.arriveBy = builder.arriveBy; diff --git a/application/src/main/java/org/opentripplanner/street/search/state/State.java b/application/src/main/java/org/opentripplanner/street/search/state/State.java index bce2f2c55e5..96960f5c5f5 100644 --- a/application/src/main/java/org/opentripplanner/street/search/state/State.java +++ b/application/src/main/java/org/opentripplanner/street/search/state/State.java @@ -93,12 +93,7 @@ public static Collection getInitialStates( for (Vertex vertex : vertices) { for (StateData stateData : StateData.getInitialStateDatas(streetSearchRequest)) { states.add( - new State( - vertex, - streetSearchRequest.startTime().truncatedTo(ChronoUnit.SECONDS), - stateData, - streetSearchRequest - ) + new State(vertex, streetSearchRequest.startTime(), stateData, streetSearchRequest) ); } } diff --git a/application/src/test/java/org/opentripplanner/street/integration/BarrierRoutingTest.java b/application/src/test/java/org/opentripplanner/street/integration/BarrierRoutingTest.java index 52dcc771c5d..944903188f0 100644 --- a/application/src/test/java/org/opentripplanner/street/integration/BarrierRoutingTest.java +++ b/application/src/test/java/org/opentripplanner/street/integration/BarrierRoutingTest.java @@ -36,7 +36,7 @@ public class BarrierRoutingTest { - private static final Instant dateTime = Instant.now().truncatedTo(ChronoUnit.SECONDS); + private static final Instant dateTime = Instant.now(); private static Graph graph; diff --git a/application/src/test/java/org/opentripplanner/street/integration/BicycleRoutingTest.java b/application/src/test/java/org/opentripplanner/street/integration/BicycleRoutingTest.java index 301caeda8b2..73b0cbf3fdd 100644 --- a/application/src/test/java/org/opentripplanner/street/integration/BicycleRoutingTest.java +++ b/application/src/test/java/org/opentripplanner/street/integration/BicycleRoutingTest.java @@ -26,7 +26,7 @@ public class BicycleRoutingTest { - static final Instant dateTime = Instant.now().truncatedTo(ChronoUnit.SECONDS); + static final Instant dateTime = Instant.now(); private final Graph herrenbergGraph; { diff --git a/application/src/test/java/org/opentripplanner/street/integration/CarRoutingTest.java b/application/src/test/java/org/opentripplanner/street/integration/CarRoutingTest.java index 34beead9aed..76e42b50c0e 100644 --- a/application/src/test/java/org/opentripplanner/street/integration/CarRoutingTest.java +++ b/application/src/test/java/org/opentripplanner/street/integration/CarRoutingTest.java @@ -27,7 +27,7 @@ public class CarRoutingTest { - static final Instant dateTime = Instant.now().truncatedTo(ChronoUnit.SECONDS); + static final Instant dateTime = Instant.now(); private static final ResourceLoader RESOURCE_LOADER = ResourceLoader.of(CarRoutingTest.class); private static Graph herrenbergGraph; diff --git a/application/src/test/java/org/opentripplanner/street/integration/WalkRoutingTest.java b/application/src/test/java/org/opentripplanner/street/integration/WalkRoutingTest.java index 7d9a2277129..550985152fe 100644 --- a/application/src/test/java/org/opentripplanner/street/integration/WalkRoutingTest.java +++ b/application/src/test/java/org/opentripplanner/street/integration/WalkRoutingTest.java @@ -25,7 +25,7 @@ class WalkRoutingTest { - static final Instant dateTime = Instant.now().truncatedTo(ChronoUnit.SECONDS); + static final Instant dateTime = Instant.now(); private final Graph roundabout; { From 37ad6e77d8b6d2ca49ff42e66dbcc6a24059e93c Mon Sep 17 00:00:00 2001 From: Thomas Gran Date: Thu, 27 Feb 2025 17:20:20 +0100 Subject: [PATCH 53/69] refactor: Apply review comments --- .../mapping/TripViaLocationMapper.java | 2 +- .../model/framework/CoordinateInputType.java | 2 +- .../mapping/RaptorPathToItineraryMapper.java | 2 +- .../transit/mappers/RaptorRequestMapper.java | 4 +- .../routing/graphfinder/NearbyStop.java | 1 + .../via/model/ViaCoordinateTransfer.java | 12 ++-- .../DefaultViaCoordinateTransferFactory.java | 59 +++++++++++-------- .../updater/siri/SiriTripPatternCache.java | 2 +- .../framework/CoordinateInputTypeTest.java | 6 +- .../api/request/RaptorViaConnection.java | 1 - .../raptor/api/request/RaptorViaLocation.java | 44 +++++++------- .../context/SearchContextViaLeg.java | 8 ++- ...ViaConnectionStopArrivalEventListener.java | 25 ++++---- .../configure/McRangeRaptorConfig.java | 2 +- .../raptor/_data/RaptorTestConstants.java | 5 -- .../raptor/moduletests/package-info.md | 2 +- .../utils/collection/ListUtils.java | 12 ++++ .../utils/collection/ListUtilsTest.java | 14 +++++ 18 files changed, 119 insertions(+), 84 deletions(-) diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/mapping/TripViaLocationMapper.java b/application/src/main/java/org/opentripplanner/apis/transmodel/mapping/TripViaLocationMapper.java index 3e3e79a8c7a..50766866e19 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/mapping/TripViaLocationMapper.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/mapping/TripViaLocationMapper.java @@ -77,7 +77,7 @@ private static List mapStopLocationIds(Map map) { private static List mapCoordinate(Map map) { return CoordinateInputType - .mapToWsgCoordinate(ViaLocationInputType.FIELD_COORDINATE, map) + .mapToWgsCoordinate(ViaLocationInputType.FIELD_COORDINATE, map) .map(List::of) .orElseGet(List::of); } diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/model/framework/CoordinateInputType.java b/application/src/main/java/org/opentripplanner/apis/transmodel/model/framework/CoordinateInputType.java index d940bf01b11..2b95e850032 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/model/framework/CoordinateInputType.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/model/framework/CoordinateInputType.java @@ -37,7 +37,7 @@ public class CoordinateInputType { ) .build(); - public static Optional mapToWsgCoordinate( + public static Optional mapToWgsCoordinate( String fieldName, Map input ) { diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/mapping/RaptorPathToItineraryMapper.java b/application/src/main/java/org/opentripplanner/routing/algorithm/mapping/RaptorPathToItineraryMapper.java index 6da21931211..86b4eefb2d9 100644 --- a/application/src/main/java/org/opentripplanner/routing/algorithm/mapping/RaptorPathToItineraryMapper.java +++ b/application/src/main/java/org/opentripplanner/routing/algorithm/mapping/RaptorPathToItineraryMapper.java @@ -330,7 +330,7 @@ private List mapTransferLeg(TransferPathLeg pathLeg, TraverseMode transf if (raptorTransfer instanceof ViaCoordinateTransfer viaTx) { return mapViaCoordinateTransferLeg(pathLeg, viaTx, transferMode, from, to); } - throw new ClassCastException("Unknown transfer type: " + raptorTransfer.getClass()); + throw new IllegalArgumentException("Unknown transfer type: " + raptorTransfer.getClass()); } private Itinerary mapEgressLeg(EgressPathLeg egressPathLeg) { diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/RaptorRequestMapper.java b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/RaptorRequestMapper.java index 6abba8de6fb..43956616915 100644 --- a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/RaptorRequestMapper.java +++ b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/RaptorRequestMapper.java @@ -254,9 +254,9 @@ private RaptorViaLocation mapViaLocation(ViaLocation input) { ); for (var it : viaTransfers) { // If via-stop and via-transfers are used together then walking from a stop - // to the coordinate andd back is not pareto optimal, using just the stop + // to the coordinate and back is not pareto optimal, using just the stop // is the optimal option. - if(it.stop() == it.fromStopIndex() && viaStops.contains(it.stop())) { + if (it.stop() == it.fromStopIndex() && viaStops.contains(it.stop())) { continue; } builder.addViaTransfer(it.fromStopIndex(), it); diff --git a/application/src/main/java/org/opentripplanner/routing/graphfinder/NearbyStop.java b/application/src/main/java/org/opentripplanner/routing/graphfinder/NearbyStop.java index a6581812ee4..e0782ffd122 100644 --- a/application/src/main/java/org/opentripplanner/routing/graphfinder/NearbyStop.java +++ b/application/src/main/java/org/opentripplanner/routing/graphfinder/NearbyStop.java @@ -10,6 +10,7 @@ import java.util.stream.Collectors; import org.opentripplanner.astar.model.GraphPath; import org.opentripplanner.routing.api.request.RouteRequest; +import org.opentripplanner.routing.api.request.StreetMode; import org.opentripplanner.routing.api.request.request.StreetRequest; import org.opentripplanner.street.model.edge.Edge; import org.opentripplanner.street.model.vertex.TransitStopVertex; diff --git a/application/src/main/java/org/opentripplanner/routing/via/model/ViaCoordinateTransfer.java b/application/src/main/java/org/opentripplanner/routing/via/model/ViaCoordinateTransfer.java index 6b5a4debec3..09b6444a308 100644 --- a/application/src/main/java/org/opentripplanner/routing/via/model/ViaCoordinateTransfer.java +++ b/application/src/main/java/org/opentripplanner/routing/via/model/ViaCoordinateTransfer.java @@ -11,11 +11,11 @@ /** * This class will act as a {@link RaptorTransfer} during the Raptor routing and carry enough * information to create an itinerary after the routing is done. - *

- * When routing via a coordinate, we need to generate transfers Raptor can use for all permutations - * of near-by-stops. This class is one such instance. We do NOT stitch the two sets of edges - * together because this will use unnecessary resource before we know if an instance is used - * in a Raptor Path. So this is left to the itinerary mapping. + + * When routing through a coordinate, we need to generate transfers for each pair of stops + * connected to it. In this class we keep a reference to the incoming and outgoing paths, instead + * of connecting the two paths together into one. This approach reduces memory usage during + * routing. Connecting paths is left to the itinerary mapping. */ public class ViaCoordinateTransfer implements RaptorTransfer { @@ -37,7 +37,7 @@ public class ViaCoordinateTransfer implements RaptorTransfer { * via `minimum-wait-time`. * @param generalizedCostInSeconds The total cost traversing the from and to edges in the OTP * domain generalized-cost. The unit is equivalent to seconds. - * The cost will be converted to Raptor units and cashed for + * The cost will be converted to Raptor units and cached for * optimal performance. */ public ViaCoordinateTransfer( diff --git a/application/src/main/java/org/opentripplanner/routing/via/service/DefaultViaCoordinateTransferFactory.java b/application/src/main/java/org/opentripplanner/routing/via/service/DefaultViaCoordinateTransferFactory.java index 080d52062aa..7e22d35cea7 100644 --- a/application/src/main/java/org/opentripplanner/routing/via/service/DefaultViaCoordinateTransferFactory.java +++ b/application/src/main/java/org/opentripplanner/routing/via/service/DefaultViaCoordinateTransferFactory.java @@ -3,6 +3,7 @@ import jakarta.inject.Inject; import java.time.Duration; import java.util.ArrayList; +import java.util.Collection; import java.util.List; import java.util.UUID; import org.opentripplanner.framework.geometry.WgsCoordinate; @@ -12,6 +13,7 @@ import org.opentripplanner.graph_builder.module.nearbystops.StreetNearbyStopFinder; import org.opentripplanner.routing.api.request.RouteRequest; import org.opentripplanner.routing.api.request.StreetMode; +import org.opentripplanner.routing.api.request.request.StreetRequest; import org.opentripplanner.routing.graph.Graph; import org.opentripplanner.routing.graphfinder.NearbyStop; import org.opentripplanner.routing.linking.DisposableEdgeCollection; @@ -39,8 +41,9 @@ public DefaultViaCoordinateTransferFactory( ) { this.graph = graph; this.transitService = transitService; + // We divide the regular transfer radius by two, since we have two "transfers" after each - // other here. This reduces the number of possible transfers 4 times. The radius should + // other here. This reduces the number of possible transfers to one fourth. The radius should // probably have its own configuration setting. There are no algorithmic reasons for using // the transfer radius here, any value can be used. this.radiusByDuration = radiusByDuration.dividedBy(2); @@ -83,25 +86,12 @@ public List createViaTransfers( } ); - var toStops = nearbyStopFinder.findNearbyStops( - viaVertex, - request, - request.journey().transfer(), - false - ); - var fromStops = nearbyStopFinder.findNearbyStops( - viaVertex, - request, - request.journey().transfer(), - true - ); + var toStops = findNearbyStops(nearbyStopFinder, viaVertex, request, false); + var fromStops = findNearbyStops(nearbyStopFinder, viaVertex, request, true); var transfers = new ArrayList(); for (NearbyStop from : fromStops) { - if (from.stop.transfersNotAllowed()) { - continue; - } for (NearbyStop to : toStops) { transfers.add( new ViaCoordinateTransfer( @@ -118,6 +108,7 @@ public List createViaTransfers( } return transfers; } catch (RuntimeException ex) { + // This make sure we dispose the edges in case something goes wrong. if (tempEdges != null) { tempEdges.disposeEdges(); } @@ -125,17 +116,19 @@ public List createViaTransfers( } } - private static TraverseMode mapTransferMode(StreetMode txM) { - if (txM.includesBiking()) { - return TraverseMode.BICYCLE; - } - if (txM.includesScooter()) { - return TraverseMode.SCOOTER; - } - if (txM.includesWalking()) { - return TraverseMode.WALK; + private static TraverseMode mapTransferMode(StreetMode streetMode) { + if (streetMode.transferAllowed()) { + if (streetMode.includesBiking()) { + return TraverseMode.BICYCLE; + } + if (streetMode.includesDriving()) { + return TraverseMode.CAR; + } + if (streetMode.includesWalking()) { + return TraverseMode.WALK; + } } - throw new IllegalStateException("Mode not allowed for transfer: " + txM); + throw new IllegalStateException("Mode not allowed for transfer: " + streetMode); } /** @@ -149,4 +142,18 @@ private NearbyStopFinder createNearbyStopFinder(Duration radiusByDuration) { return new StreetNearbyStopFinder(radiusByDuration, 0, null); } } + + /** + * Find the nearest stops allowed for transfers. + */ + private List findNearbyStops( + NearbyStopFinder finder, + TemporaryStreetLocation viaVertex, + RouteRequest request, + boolean reverseDirection + ) { + var transferRequest = request.journey().transfer(); + var r = finder.findNearbyStops(viaVertex, request, transferRequest, reverseDirection); + return r.stream().filter(it -> !it.stop.transfersNotAllowed()).toList(); + } } diff --git a/application/src/main/java/org/opentripplanner/updater/siri/SiriTripPatternCache.java b/application/src/main/java/org/opentripplanner/updater/siri/SiriTripPatternCache.java index 19816bd085f..2f26f4125a0 100644 --- a/application/src/main/java/org/opentripplanner/updater/siri/SiriTripPatternCache.java +++ b/application/src/main/java/org/opentripplanner/updater/siri/SiriTripPatternCache.java @@ -23,7 +23,7 @@ * TODO RT_TG: There is no clear strategy for what should be in the cache and the transit model and the flow * between them. The NeTEx and a GTFS version of this should be merged. Having NeTex and GTFS * specific indexes inside is ok. With the increased usage of DatedServiceJourneys, this should probably - * be part of the main model - not a separate cashe. It is possible that this class works when it comes to + * be part of the main model - not a separate cache. It is possible that this class works when it comes to * the thread-safety, but just by looking at a few lines of code I see problems - a strategy needs to be * analysed, designed and documented. */ diff --git a/application/src/test/java/org/opentripplanner/apis/transmodel/model/framework/CoordinateInputTypeTest.java b/application/src/test/java/org/opentripplanner/apis/transmodel/model/framework/CoordinateInputTypeTest.java index 11d613d235f..6defbed804f 100644 --- a/application/src/test/java/org/opentripplanner/apis/transmodel/model/framework/CoordinateInputTypeTest.java +++ b/application/src/test/java/org/opentripplanner/apis/transmodel/model/framework/CoordinateInputTypeTest.java @@ -17,17 +17,17 @@ class CoordinateInputTypeTest { ); @Test - void mapToWsgCoordinate() { + void mapToWgsCoordinate() { assertEquals( new WgsCoordinate(LATITUDE_VALUE, LONGITUDE_VALUE), CoordinateInputType - .mapToWsgCoordinate("c", Map.of("c", CoordinateInputType.mapForTest(COORDINATE))) + .mapToWgsCoordinate("c", Map.of("c", CoordinateInputType.mapForTest(COORDINATE))) .get() ); } @Test void mapEmptyCoordinateToNull() { - assertTrue(CoordinateInputType.mapToWsgCoordinate("c", Map.of()).isEmpty()); + assertTrue(CoordinateInputType.mapToWgsCoordinate("c", Map.of()).isEmpty()); } } diff --git a/raptor/src/main/java/org/opentripplanner/raptor/api/request/RaptorViaConnection.java b/raptor/src/main/java/org/opentripplanner/raptor/api/request/RaptorViaConnection.java index e17cb51d2b9..6ab8a3a9f32 100644 --- a/raptor/src/main/java/org/opentripplanner/raptor/api/request/RaptorViaConnection.java +++ b/raptor/src/main/java/org/opentripplanner/raptor/api/request/RaptorViaConnection.java @@ -187,7 +187,6 @@ public RaptorViaTransferConnection( this.transfer = transfer; } - @Nullable @Override public RaptorTransfer transfer() { return transfer; diff --git a/raptor/src/main/java/org/opentripplanner/raptor/api/request/RaptorViaLocation.java b/raptor/src/main/java/org/opentripplanner/raptor/api/request/RaptorViaLocation.java index 5343b34e977..9338d7ee2ae 100644 --- a/raptor/src/main/java/org/opentripplanner/raptor/api/request/RaptorViaLocation.java +++ b/raptor/src/main/java/org/opentripplanner/raptor/api/request/RaptorViaLocation.java @@ -6,7 +6,6 @@ import java.util.List; import java.util.stream.IntStream; import javax.annotation.Nullable; -import org.opentripplanner.raptor.api.model.RaptorConstants; import org.opentripplanner.raptor.api.model.RaptorStopNameResolver; import org.opentripplanner.raptor.api.model.RaptorTransfer; import org.opentripplanner.utils.lang.IntUtils; @@ -21,8 +20,8 @@ */ public final class RaptorViaLocation { - private static final int MAX_WAIT_TIME = (int) Duration.ofHours(24).toSeconds(); - private static final int MIN_WAIT_TIME = (int) Duration.ZERO.toSeconds(); + private static final Duration MAX_WAIT_TIME = Duration.ofHours(24); + private static final Duration MIN_WAIT_TIME = Duration.ZERO; private final String label; private final boolean passThroughSearch; @@ -40,8 +39,8 @@ private RaptorViaLocation( this.minimumWaitTime = IntUtils.requireInRange( (int) minimumWaitTime.toSeconds(), - MIN_WAIT_TIME, - MAX_WAIT_TIME, + (int) MIN_WAIT_TIME.toSeconds(), + (int) MAX_WAIT_TIME.toSeconds(), "minimumWaitTime" ); this.connections = validateConnections(connections); @@ -50,8 +49,8 @@ private RaptorViaLocation( /** * Force the path through a set of stops, either on-board or as an alight or board stop. */ - public static BuilderPassThrough passThrough(@Nullable String label) { - return new BuilderPassThrough(label); + public static PassThroughBuilder passThrough(@Nullable String label) { + return new PassThroughBuilder(label); } /** @@ -59,8 +58,8 @@ public static BuilderPassThrough passThrough(@Nullable String label) { * alight transit at the given stop, on-board visits do not count, see * {@link #passThrough(String)}. */ - public static BuilderViaMinTime via(@Nullable String label) { - return via(label, Duration.ZERO); + public static ViaVisitBuilder via(@Nullable String label) { + return via(label, MIN_WAIT_TIME); } /** @@ -68,8 +67,8 @@ public static BuilderViaMinTime via(@Nullable String label) { * before continuing. To visit a stop, the path must board or alight transit at the given stop, * on-board visits do not count, see {@link #passThrough(String)}. */ - public static BuilderViaMinTime via(@Nullable String label, Duration minimumWaitTime) { - return new BuilderViaMinTime(label, minimumWaitTime); + public static ViaVisitBuilder via(@Nullable String label, Duration minimumWaitTime) { + return new ViaVisitBuilder(label, minimumWaitTime); } @Nullable @@ -110,6 +109,7 @@ public int hashCode() { throw new UnsupportedOperationException("No need for hashCode of " + getClass()); } + @Override public String toString() { return toString(Integer::toString); } @@ -120,7 +120,7 @@ public String toString(RaptorStopNameResolver stopNameResolver) { if (label != null) { buf.append(label).append(" "); } - if (minimumWaitTime > RaptorConstants.ZERO) { + if (minimumWaitTime > MIN_WAIT_TIME.toSeconds()) { buf.append("wait ").append(DurationUtils.durationToStr(minimumWaitTime)).append(" "); } buf @@ -153,7 +153,7 @@ private List validateConnections(List { + public abstract static sealed class AbstractBuilder { protected final String label; protected final List connections = new ArrayList<>(); @@ -162,26 +162,26 @@ public AbstractBuilder(String label) { this.label = label; } - public T addConnection(int stop, @Nullable RaptorTransfer transfer) { + T addConnection(int stop, @Nullable RaptorTransfer transfer) { this.connections.add(new BuilderStopAndTransfer(stop, transfer)); return (T) this; } } - public static final class BuilderViaMinTime extends AbstractBuilder { + public static final class ViaVisitBuilder extends AbstractBuilder { private final Duration minimumWaitTime; - public BuilderViaMinTime(String label, Duration minimumWaitTime) { + public ViaVisitBuilder(String label, Duration minimumWaitTime) { super(label); this.minimumWaitTime = minimumWaitTime; } - public BuilderViaMinTime addViaStop(int stop) { + public ViaVisitBuilder addViaStop(int stop) { return addConnection(stop, null); } - public BuilderViaMinTime addViaTransfer(int fromStop, RaptorTransfer transfer) { + public ViaVisitBuilder addViaTransfer(int fromStop, RaptorTransfer transfer) { return addConnection(fromStop, transfer); } @@ -190,18 +190,18 @@ public RaptorViaLocation build() { } } - public static final class BuilderPassThrough extends AbstractBuilder { + public static final class PassThroughBuilder extends AbstractBuilder { - public BuilderPassThrough(String label) { + public PassThroughBuilder(String label) { super(label); } - public BuilderPassThrough addPassThroughStop(int stop) { + public PassThroughBuilder addPassThroughStop(int stop) { this.connections.add(new BuilderStopAndTransfer(stop, null)); return this; } - public BuilderPassThrough addPassThroughStops(int... stops) { + public PassThroughBuilder addPassThroughStops(int... stops) { IntStream.of(stops).forEach(this::addPassThroughStop); return this; } diff --git a/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/context/SearchContextViaLeg.java b/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/context/SearchContextViaLeg.java index 9472d3b1464..ee22aab9f01 100644 --- a/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/context/SearchContextViaLeg.java +++ b/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/context/SearchContextViaLeg.java @@ -15,14 +15,18 @@ public class SearchContextViaLeg { private final SearchContext parent; private final AccessPaths accessPaths; + + @Nullable private final ViaConnections viaConnections; + + @Nullable private final EgressPaths egressPaths; public SearchContextViaLeg( SearchContext parent, AccessPaths accessPaths, - ViaConnections viaConnections, - EgressPaths egressPaths + @Nullable ViaConnections viaConnections, + @Nullable EgressPaths egressPaths ) { this.parent = parent; this.accessPaths = accessPaths; diff --git a/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/multicriteria/ViaConnectionStopArrivalEventListener.java b/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/multicriteria/ViaConnectionStopArrivalEventListener.java index 0cd51dfe88f..f0b7e708923 100644 --- a/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/multicriteria/ViaConnectionStopArrivalEventListener.java +++ b/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/multicriteria/ViaConnectionStopArrivalEventListener.java @@ -1,5 +1,7 @@ package org.opentripplanner.raptor.rangeraptor.multicriteria; +import static org.opentripplanner.utils.collection.ListUtils.requireAtLeastNElements; + import java.util.ArrayList; import java.util.List; import java.util.function.Consumer; @@ -11,6 +13,7 @@ import org.opentripplanner.raptor.rangeraptor.multicriteria.arrivals.McStopArrivalFactory; import org.opentripplanner.raptor.rangeraptor.transit.ViaConnections; import org.opentripplanner.raptor.util.paretoset.ParetoSetEventListener; +import org.opentripplanner.utils.collection.ListUtils; /** * This class is used to listen for stop arrivals in one raptor state and then copy @@ -24,42 +27,42 @@ * "transfer phase" of the Raptor algorithm. The life-cycle service will notify this class * at the right time to publish the transter-arrivals. */ -public class ViaConnectionStopArrivalEventListener +public final class ViaConnectionStopArrivalEventListener implements ParetoSetEventListener> { private final McStopArrivalFactory stopArrivalFactory; private final List connections; private final McStopArrivals next; - private final List> transfersCashe = new ArrayList<>(); + private final List> transfersCache = new ArrayList<>(); /** * @param publishTransfersEventHandler A callback used to publish via-transfer-connections. This * should be done in the same phase as all other transfers * processed by the Raptor algorithm. */ - public ViaConnectionStopArrivalEventListener( + private ViaConnectionStopArrivalEventListener( McStopArrivalFactory stopArrivalFactory, List connections, McStopArrivals next, Consumer publishTransfersEventHandler ) { this.stopArrivalFactory = stopArrivalFactory; - this.connections = connections; + this.connections = requireAtLeastNElements(connections, 1); this.next = next; publishTransfersEventHandler.accept(this::publishTransfers); } /** * Factory method for creating a {@link org.opentripplanner.raptor.util.paretoset.ParetoSet} - * listener used to copy the state when arriving at a "via piont" into the next Raptor "leg". + * listener used to copy the state when arriving at a "via point" into the next Raptor "leg". */ public static < T extends RaptorTripSchedule - > List> createEventListners( + > List> createEventListeners( @Nullable ViaConnections viaConnections, McStopArrivalFactory stopArrivalFactory, McStopArrivals nextLegStopArrivals, - Consumer onTransitCompleate + Consumer onTransitComplete ) { if (viaConnections == null) { return List.of(); @@ -73,7 +76,7 @@ > List> createEventListners( stopArrivalFactory, connections, nextLegStopArrivals, - onTransitCompleate + onTransitComplete ) ) ); @@ -81,10 +84,10 @@ > List> createEventListners( } private void publishTransfers() { - for (var arrival : transfersCashe) { + for (var arrival : transfersCache) { next.addStopArrival(arrival); } - transfersCashe.clear(); + transfersCache.clear(); } int fromStop() { @@ -98,7 +101,7 @@ public void notifyElementAccepted(ArrivalView newElement) { var n = createViaStopArrival(e, c); if (n != null) { if (c.isTransfer()) { - transfersCashe.add(n); + transfersCache.add(n); } else { next.addStopArrival(n); } diff --git a/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/multicriteria/configure/McRangeRaptorConfig.java b/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/multicriteria/configure/McRangeRaptorConfig.java index b0162acc698..522fc56a632 100644 --- a/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/multicriteria/configure/McRangeRaptorConfig.java +++ b/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/multicriteria/configure/McRangeRaptorConfig.java @@ -219,7 +219,7 @@ private ArrivalParetoSetComparatorFactory> createFactoryParetoC } private List> createViaConnectionListeners() { - return ViaConnectionStopArrivalEventListener.createEventListners( + return ViaConnectionStopArrivalEventListener.createEventListeners( contextLeg.viaConnections(), createStopArrivalFactory(), nextLegArrivals, diff --git a/raptor/src/test/java/org/opentripplanner/raptor/_data/RaptorTestConstants.java b/raptor/src/test/java/org/opentripplanner/raptor/_data/RaptorTestConstants.java index 1e076700dc8..06a0b62ef41 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/_data/RaptorTestConstants.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/_data/RaptorTestConstants.java @@ -54,11 +54,6 @@ public interface RaptorTestConstants { int STOP_F = 6; int STOP_G = 7; int STOP_H = 8; - int STOP_I = 9; - int STOP_J = 10; - int STOP_K = 11; - int STOP_L = 12; - int STOP_M = 13; int NUM_STOPS = 14; diff --git a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/package-info.md b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/package-info.md index afab143a09f..2fe372591a1 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/package-info.md +++ b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/package-info.md @@ -21,7 +21,7 @@ group from simple to complex tests (`01` to `99`). - `G` - Access and egress with opening hours/time restrictions - `H` - Combining the above advanced features - `I` - Heuristic test -- `J` - Via seach +- `J` - Via search - `K` - Transit priority - `L` - Time penalty diff --git a/utils/src/main/java/org/opentripplanner/utils/collection/ListUtils.java b/utils/src/main/java/org/opentripplanner/utils/collection/ListUtils.java index 658bf768179..de0fa74f145 100644 --- a/utils/src/main/java/org/opentripplanner/utils/collection/ListUtils.java +++ b/utils/src/main/java/org/opentripplanner/utils/collection/ListUtils.java @@ -79,4 +79,16 @@ public static List ofNullable(T input) { public static List nullSafeImmutableList(@Nullable Collection c) { return (c == null) ? List.of() : List.copyOf(c); } + + /** + * Check if a list has at least the given {@code minLimit} number of elements(inclusive). + * @throws IllegalStateException if the list has fewer lements. + * @throws NumberFormatException if the list is {@code null} + */ + public static List requireAtLeastNElements(List list, int minLimit) { + if (list.size() < minLimit) { + throw new IllegalArgumentException("The list must have at least " + minLimit + " elements."); + } + return list; + } } diff --git a/utils/src/test/java/org/opentripplanner/utils/collection/ListUtilsTest.java b/utils/src/test/java/org/opentripplanner/utils/collection/ListUtilsTest.java index 602182a64b4..7cbb61c5755 100644 --- a/utils/src/test/java/org/opentripplanner/utils/collection/ListUtilsTest.java +++ b/utils/src/test/java/org/opentripplanner/utils/collection/ListUtilsTest.java @@ -2,8 +2,10 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertThrows; import static org.opentripplanner.utils.collection.ListUtils.first; import static org.opentripplanner.utils.collection.ListUtils.last; +import static org.opentripplanner.utils.collection.ListUtils.requireAtLeastNElements; import java.util.List; import org.junit.jupiter.api.Test; @@ -62,5 +64,17 @@ void ofNullable() { assertEquals(List.of("A"), ListUtils.ofNullable("A")); } + @Test + void testRequireAtLeastNElements() { + var zeroElements = List.of(); + var oneElement = List.of("w"); + requireAtLeastNElements(zeroElements, 0); + requireAtLeastNElements(oneElement, 1); + + assertThrows(NullPointerException.class, () -> requireAtLeastNElements(null, 0)); + assertThrows(IllegalArgumentException.class, () -> requireAtLeastNElements(zeroElements, 1)); + assertThrows(IllegalArgumentException.class, () -> requireAtLeastNElements(oneElement, 2)); + } + private record Wrapper(int i, String string) {} } From dd10d3ca6d2f57d7ed4021f6885057693e228132 Mon Sep 17 00:00:00 2001 From: Thomas Gran Date: Thu, 27 Feb 2025 17:29:39 +0100 Subject: [PATCH 54/69] refactor: Rename `radiusByDuration` -> `radiusAsDuration` --- .../module/DirectTransferGenerator.java | 6 +++--- .../DefaultViaCoordinateTransferFactory.java | 16 +++++++--------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/application/src/main/java/org/opentripplanner/graph_builder/module/DirectTransferGenerator.java b/application/src/main/java/org/opentripplanner/graph_builder/module/DirectTransferGenerator.java index f6e6ce1b238..e8074651c1e 100644 --- a/application/src/main/java/org/opentripplanner/graph_builder/module/DirectTransferGenerator.java +++ b/application/src/main/java/org/opentripplanner/graph_builder/module/DirectTransferGenerator.java @@ -197,17 +197,17 @@ public void buildGraph() { * whether the graph has a street network and if ConsiderPatternsForDirectTransfers feature is * enabled. */ - private NearbyStopFinder createNearbyStopFinder(Duration radiusByDuration) { + private NearbyStopFinder createNearbyStopFinder(Duration radiusAsDuration) { var transitService = new DefaultTransitService(timetableRepository); NearbyStopFinder finder; if (!graph.hasStreets) { LOG.info( "Creating direct transfer edges between stops using straight line distance (not streets)..." ); - finder = new StraightLineNearbyStopFinder(transitService, radiusByDuration); + finder = new StraightLineNearbyStopFinder(transitService, radiusAsDuration); } else { LOG.info("Creating direct transfer edges between stops using the street network from OSM..."); - finder = new StreetNearbyStopFinder(radiusByDuration, 0, null); + finder = new StreetNearbyStopFinder(radiusAsDuration, 0, null); } if (OTPFeature.ConsiderPatternsForDirectTransfers.isOn()) { diff --git a/application/src/main/java/org/opentripplanner/routing/via/service/DefaultViaCoordinateTransferFactory.java b/application/src/main/java/org/opentripplanner/routing/via/service/DefaultViaCoordinateTransferFactory.java index 7e22d35cea7..e3efd69755d 100644 --- a/application/src/main/java/org/opentripplanner/routing/via/service/DefaultViaCoordinateTransferFactory.java +++ b/application/src/main/java/org/opentripplanner/routing/via/service/DefaultViaCoordinateTransferFactory.java @@ -3,7 +3,6 @@ import jakarta.inject.Inject; import java.time.Duration; import java.util.ArrayList; -import java.util.Collection; import java.util.List; import java.util.UUID; import org.opentripplanner.framework.geometry.WgsCoordinate; @@ -13,7 +12,6 @@ import org.opentripplanner.graph_builder.module.nearbystops.StreetNearbyStopFinder; import org.opentripplanner.routing.api.request.RouteRequest; import org.opentripplanner.routing.api.request.StreetMode; -import org.opentripplanner.routing.api.request.request.StreetRequest; import org.opentripplanner.routing.graph.Graph; import org.opentripplanner.routing.graphfinder.NearbyStop; import org.opentripplanner.routing.linking.DisposableEdgeCollection; @@ -31,13 +29,13 @@ public class DefaultViaCoordinateTransferFactory implements ViaCoordinateTransfe private final Graph graph; private final TransitService transitService; - private final Duration radiusByDuration; + private final Duration radiusAsDuration; @Inject public DefaultViaCoordinateTransferFactory( Graph graph, TransitService transitService, - Duration radiusByDuration + Duration radiusAsDuration ) { this.graph = graph; this.transitService = transitService; @@ -46,7 +44,7 @@ public DefaultViaCoordinateTransferFactory( // other here. This reduces the number of possible transfers to one fourth. The radius should // probably have its own configuration setting. There are no algorithmic reasons for using // the transfer radius here, any value can be used. - this.radiusByDuration = radiusByDuration.dividedBy(2); + this.radiusAsDuration = radiusAsDuration.dividedBy(2); } @Override @@ -57,7 +55,7 @@ public List createViaTransfers( ) { DisposableEdgeCollection tempEdges = null; try { - var nearbyStopFinder = createNearbyStopFinder(radiusByDuration); + var nearbyStopFinder = createNearbyStopFinder(radiusAsDuration); var name = I18NString.of( (StringUtils.hasValue(viaLabel) ? viaLabel : "Via") + " " + coordinate ); @@ -135,11 +133,11 @@ private static TraverseMode mapTransferMode(StreetMode streetMode) { * Factory method for creating a NearbyStopFinder. The linker will use streets if they are * available, or straight-line distance otherwise. */ - private NearbyStopFinder createNearbyStopFinder(Duration radiusByDuration) { + private NearbyStopFinder createNearbyStopFinder(Duration radiusAsDuration) { if (!graph.hasStreets) { - return new StraightLineNearbyStopFinder(transitService, radiusByDuration); + return new StraightLineNearbyStopFinder(transitService, radiusAsDuration); } else { - return new StreetNearbyStopFinder(radiusByDuration, 0, null); + return new StreetNearbyStopFinder(radiusAsDuration, 0, null); } } From 94d89ade908666e8863a1a254c5572886d17b9a2 Mon Sep 17 00:00:00 2001 From: Thomas Gran Date: Thu, 27 Feb 2025 18:34:19 +0100 Subject: [PATCH 55/69] Apply suggestions from code review Co-authored-by: Joel Lappalainen --- .../street/model/vertex/TemporaryStreetLocation.java | 12 ++++++------ .../moduletests/J03_ViaTransferSearchTest.java | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/application/src/main/java/org/opentripplanner/street/model/vertex/TemporaryStreetLocation.java b/application/src/main/java/org/opentripplanner/street/model/vertex/TemporaryStreetLocation.java index 438734a21fd..a5804e358ea 100644 --- a/application/src/main/java/org/opentripplanner/street/model/vertex/TemporaryStreetLocation.java +++ b/application/src/main/java/org/opentripplanner/street/model/vertex/TemporaryStreetLocation.java @@ -6,12 +6,12 @@ import org.opentripplanner.street.model.edge.TemporaryEdge; /** - * A temporary vertex witch can be used as the origin(outgoing edges), destination(incomming - * edges) or via point(in-/out-going edges). There is no constraint on adding incomming/outgoing - * edges. For a temporary request scoped vertex with both incomming and outcomming edges, there - * need to be a something that exclude it from other parallell searches. One way to do this is to - * add a small cost to the temporary edges so the alternative permanent edges have a small - * advatage. + * A temporary vertex which can be used as the origin(outgoing edges), destination(incoming + * edges) or via point(in-/out-going edges). There is no constraint on adding incoming/outgoing + * edges. For a temporary request scoped vertex with both incoming and outgoing edges, there + * needs to be something that excludes it from other parallel searches. One way to do this is to + * add a small cost to the temporary edges so that the alternative permanent edges have a small + * advantage. */ public final class TemporaryStreetLocation extends StreetLocation implements TemporaryVertex { diff --git a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/J03_ViaTransferSearchTest.java b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/J03_ViaTransferSearchTest.java index a0d69685d00..7c7b4ed80e8 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/J03_ViaTransferSearchTest.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/J03_ViaTransferSearchTest.java @@ -115,8 +115,8 @@ void viaSearchAlightingAtViaStop() { @Test @DisplayName( - "Basic via search with just two routes. You should be forced use the provided via transfer " + - "even when a better regular transfer exist and an eariler depature could be reached. " + "Basic via search with just two routes. You should be forced to use the provided via transfer " + + "even when a better regular transfer exists and an earlier departure could be reached. " ) void viaSearchArrivingByTransferAtViaStop() { var data = new TestTransitData(); @@ -155,7 +155,7 @@ void viaSearchArrivingByTransferAtViaStop() { "Via search with via transfer should force the usage of a route at the destination " + "avoiding using a via-transfer followed by a regular transfer." ) - void viaTransferSearchNotFolloedByRegularTransfer() { + void viaTransferSearchNotFollowedByRegularTransfer() { var data = new TestTransitData(); data From 51624cffd594ac25a71026d6afc25eaa57b3b776 Mon Sep 17 00:00:00 2001 From: Thomas Gran Date: Thu, 27 Feb 2025 18:37:30 +0100 Subject: [PATCH 56/69] refactor: Rename `byFromStop` -> `groupByFromStop` --- .../raptor/rangeraptor/transit/ViaConnections.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/transit/ViaConnections.java b/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/transit/ViaConnections.java index 053c1da4354..0448b01e5c6 100644 --- a/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/transit/ViaConnections.java +++ b/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/transit/ViaConnections.java @@ -10,17 +10,17 @@ public class ViaConnections { - private final TIntObjectMap> byFromStop; + private final TIntObjectMap> groupByFromStop; public ViaConnections(Collection viaConnections) { - this.byFromStop = new TIntObjectHashMap<>(); + this.groupByFromStop = new TIntObjectHashMap<>(); viaConnections .stream() .collect(groupingBy(RaptorViaConnection::fromStop)) - .forEach(byFromStop::put); + .forEach(groupByFromStop::put); } public TIntObjectMap> byFromStop() { - return byFromStop; + return groupByFromStop; } } From d99e081a301b2f644fd09a6c671ae84d8b19a16e Mon Sep 17 00:00:00 2001 From: Thomas Gran Date: Thu, 27 Feb 2025 18:47:24 +0100 Subject: [PATCH 57/69] refactor: Remove commented-out code The feature this code adressed is solved elsewhere. --- .../java/org/opentripplanner/raptor/path/PathBuilderLeg.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/raptor/src/main/java/org/opentripplanner/raptor/path/PathBuilderLeg.java b/raptor/src/main/java/org/opentripplanner/raptor/path/PathBuilderLeg.java index dbc2e25a371..eaaf5524705 100644 --- a/raptor/src/main/java/org/opentripplanner/raptor/path/PathBuilderLeg.java +++ b/raptor/src/main/java/org/opentripplanner/raptor/path/PathBuilderLeg.java @@ -534,9 +534,6 @@ private void setTransferTimeBasedOnPreviousLeg(RaptorSlackProvider slackProvider prev.toTime() + slackProvider.alightSlack(prev.asTransitLeg().trip.pattern().slackIndex()); } else if (prev.isAccess()) { newFromTime = prev.toTime(); - // } else if (prev.isTransfer()) { - // via search and transfer connection - // newFromTime = prev.toTime + slackProvider.transferSlack(); } else { throw new IllegalStateException("Unexpected leg type before TransferLeg: " + this); } From 5306f687f9e4662efe2db37d8836a7a7a89e04da Mon Sep 17 00:00:00 2001 From: Brickblock1 <100433052+Brickblock1@users.noreply.github.com> Date: Sat, 1 Mar 2025 01:39:03 +0100 Subject: [PATCH 58/69] Add highway=platform to IsBoardingLocation() --- .../src/main/java/org/opentripplanner/osm/model/OsmEntity.java | 1 + doc/user/BoardingLocations.md | 2 ++ 2 files changed, 3 insertions(+) diff --git a/application/src/main/java/org/opentripplanner/osm/model/OsmEntity.java b/application/src/main/java/org/opentripplanner/osm/model/OsmEntity.java index 3f6b798d200..f9b30a1b211 100644 --- a/application/src/main/java/org/opentripplanner/osm/model/OsmEntity.java +++ b/application/src/main/java/org/opentripplanner/osm/model/OsmEntity.java @@ -579,6 +579,7 @@ public boolean isBoardingLocation() { isTag("railway", "halt") || isTag("amenity", "bus_station") || isTag("amenity", "ferry_terminal") || + isTag("highway", "platform") || isPlatform() ); } diff --git a/doc/user/BoardingLocations.md b/doc/user/BoardingLocations.md index bf92033624b..b5b75a02f7c 100644 --- a/doc/user/BoardingLocations.md +++ b/doc/user/BoardingLocations.md @@ -20,6 +20,8 @@ You can add cross-references to a stop's id or code on all OSM entities (nodes, have one of the following tag combinations: - `public_transport=platform` +- `railway=platform` +- `highway=platform` - `highway=bus_stop` - `railway=tram_stop` - `railway=station` From 485c4e57450e97460b44fa1412ecd2882c164f74 Mon Sep 17 00:00:00 2001 From: Brickblock1 <100433052+Brickblock1@users.noreply.github.com> Date: Sun, 2 Mar 2025 13:34:02 +0100 Subject: [PATCH 59/69] Add unit test --- .../osm/moduletests/BoardingLocationTest.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/application/src/test/java/org/opentripplanner/graph_builder/module/osm/moduletests/BoardingLocationTest.java b/application/src/test/java/org/opentripplanner/graph_builder/module/osm/moduletests/BoardingLocationTest.java index e2a697d6ccd..734e86d1cf8 100644 --- a/application/src/test/java/org/opentripplanner/graph_builder/module/osm/moduletests/BoardingLocationTest.java +++ b/application/src/test/java/org/opentripplanner/graph_builder/module/osm/moduletests/BoardingLocationTest.java @@ -66,4 +66,28 @@ void skipPlatformsWithoutReferences() { var platform = osmInfoRepository.findPlatform(edges.getFirst()); assertTrue(platform.isEmpty()); } + + @Test + void testHighwayPlatform() { + var way = new OsmWay(); + way.addTag("highway", "platform"); + way.addTag("ref", "1"); + var provider = TestOsmProvider.of().addWay(way).build(); + + var graph = new Graph(new Deduplicator()); + var osmInfoRepository = new DefaultOsmInfoGraphBuildRepository(); + var osmModule = OsmModule + .of(provider, graph, osmInfoRepository, new DefaultVehicleParkingRepository()) + .withBoardingAreaRefTags(Set.of("ref")) + .build(); + + osmModule.buildGraph(); + var edges = List.copyOf(graph.getEdges()); + assertThat(edges).hasSize(2); + + var platform = osmInfoRepository.findPlatform(edges.getFirst()); + + assertTrue(platform.isPresent()); + assertEquals(Set.of("1"), platform.get().references()); + } } From efaa55ff37e2a88b6c2e44276ac20b1da98c9c8a Mon Sep 17 00:00:00 2001 From: Teemu Kalvas Date: Mon, 3 Mar 2025 10:33:42 +0200 Subject: [PATCH 60/69] this date truncate is no longer necessary --- .../java/org/opentripplanner/routing/impl/GraphPathFinder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/src/main/java/org/opentripplanner/routing/impl/GraphPathFinder.java b/application/src/main/java/org/opentripplanner/routing/impl/GraphPathFinder.java index 27c597de204..c481c52efa9 100644 --- a/application/src/main/java/org/opentripplanner/routing/impl/GraphPathFinder.java +++ b/application/src/main/java/org/opentripplanner/routing/impl/GraphPathFinder.java @@ -139,7 +139,7 @@ public List> graphPathFinderEntryPoint( Set to ) { OTPRequestTimeoutException.checkForTimeout(); - Instant reqTime = request.dateTime().truncatedTo(ChronoUnit.MILLIS); + Instant reqTime = request.dateTime(); List> paths = getPaths(request, from, to); From 0240eda7a2af99f073b984bb6901bc1ec63f1916 Mon Sep 17 00:00:00 2001 From: Teemu Kalvas Date: Mon, 3 Mar 2025 10:40:06 +0200 Subject: [PATCH 61/69] removed unnecessary imports --- .../java/org/opentripplanner/routing/impl/GraphPathFinder.java | 1 - .../main/java/org/opentripplanner/street/search/state/State.java | 1 - .../opentripplanner/street/integration/BarrierRoutingTest.java | 1 - .../opentripplanner/street/integration/BicycleRoutingTest.java | 1 - .../org/opentripplanner/street/integration/CarRoutingTest.java | 1 - 5 files changed, 5 deletions(-) diff --git a/application/src/main/java/org/opentripplanner/routing/impl/GraphPathFinder.java b/application/src/main/java/org/opentripplanner/routing/impl/GraphPathFinder.java index c481c52efa9..77264af9212 100644 --- a/application/src/main/java/org/opentripplanner/routing/impl/GraphPathFinder.java +++ b/application/src/main/java/org/opentripplanner/routing/impl/GraphPathFinder.java @@ -1,7 +1,6 @@ package org.opentripplanner.routing.impl; import java.time.Instant; -import java.time.temporal.ChronoUnit; import java.util.Iterator; import java.util.List; import java.util.Set; diff --git a/application/src/main/java/org/opentripplanner/street/search/state/State.java b/application/src/main/java/org/opentripplanner/street/search/state/State.java index 96960f5c5f5..19ef2ba1f9b 100644 --- a/application/src/main/java/org/opentripplanner/street/search/state/State.java +++ b/application/src/main/java/org/opentripplanner/street/search/state/State.java @@ -3,7 +3,6 @@ import static org.opentripplanner.utils.lang.ObjectUtils.requireNotInitialized; import java.time.Instant; -import java.time.temporal.ChronoUnit; import java.util.ArrayList; import java.util.Collection; import java.util.Objects; diff --git a/application/src/test/java/org/opentripplanner/street/integration/BarrierRoutingTest.java b/application/src/test/java/org/opentripplanner/street/integration/BarrierRoutingTest.java index 944903188f0..8092ab62bc3 100644 --- a/application/src/test/java/org/opentripplanner/street/integration/BarrierRoutingTest.java +++ b/application/src/test/java/org/opentripplanner/street/integration/BarrierRoutingTest.java @@ -7,7 +7,6 @@ import static org.opentripplanner.test.support.PolylineAssert.assertThatPolylinesAreEqual; import java.time.Instant; -import java.time.temporal.ChronoUnit; import java.util.List; import java.util.function.Consumer; import java.util.function.Function; diff --git a/application/src/test/java/org/opentripplanner/street/integration/BicycleRoutingTest.java b/application/src/test/java/org/opentripplanner/street/integration/BicycleRoutingTest.java index 73b0cbf3fdd..60dc43aa3f9 100644 --- a/application/src/test/java/org/opentripplanner/street/integration/BicycleRoutingTest.java +++ b/application/src/test/java/org/opentripplanner/street/integration/BicycleRoutingTest.java @@ -5,7 +5,6 @@ import static org.opentripplanner.test.support.PolylineAssert.assertThatPolylinesAreEqual; import java.time.Instant; -import java.time.temporal.ChronoUnit; import org.junit.jupiter.api.Test; import org.locationtech.jts.geom.Geometry; import org.opentripplanner.ConstantsForTests; diff --git a/application/src/test/java/org/opentripplanner/street/integration/CarRoutingTest.java b/application/src/test/java/org/opentripplanner/street/integration/CarRoutingTest.java index 76e42b50c0e..caddf972e86 100644 --- a/application/src/test/java/org/opentripplanner/street/integration/CarRoutingTest.java +++ b/application/src/test/java/org/opentripplanner/street/integration/CarRoutingTest.java @@ -5,7 +5,6 @@ import static org.opentripplanner.test.support.PolylineAssert.assertThatPolylinesAreEqual; import java.time.Instant; -import java.time.temporal.ChronoUnit; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; From c8cb62769e7871eae27d848bef1ea5a1340ce1ff Mon Sep 17 00:00:00 2001 From: OTP Changelog Bot Date: Mon, 3 Mar 2025 14:47:44 +0000 Subject: [PATCH 62/69] Add changelog entry for #6484 [ci skip] --- doc/user/Changelog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/user/Changelog.md b/doc/user/Changelog.md index 353da6a32c3..3aaacadb730 100644 --- a/doc/user/Changelog.md +++ b/doc/user/Changelog.md @@ -105,6 +105,7 @@ based on merged pull requests. Search GitHub issues and pull requests for smalle - Fix ClassCastException in Itinerary mapper [#6455](https://github.com/opentripplanner/OpenTripPlanner/pull/6455) - Create TripOnServiceDate for added GTFS trips [#6459](https://github.com/opentripplanner/OpenTripPlanner/pull/6459) - Improve street routing within concave parts of area holes [#6486](https://github.com/opentripplanner/OpenTripPlanner/pull/6486) +- Fix rounding error in street routing [#6484](https://github.com/opentripplanner/OpenTripPlanner/pull/6484) [](AUTOMATIC_CHANGELOG_PLACEHOLDER_DO_NOT_REMOVE) ## 2.6.0 (2024-09-18) From 3cbb3fb552915389b7bcacca079764ab59a15f59 Mon Sep 17 00:00:00 2001 From: OTP Changelog Bot Date: Mon, 3 Mar 2025 16:51:07 +0000 Subject: [PATCH 63/69] Add changelog entry for #6477 [ci skip] --- doc/user/Changelog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/user/Changelog.md b/doc/user/Changelog.md index 3aaacadb730..1c32c9b0255 100644 --- a/doc/user/Changelog.md +++ b/doc/user/Changelog.md @@ -106,6 +106,7 @@ based on merged pull requests. Search GitHub issues and pull requests for smalle - Create TripOnServiceDate for added GTFS trips [#6459](https://github.com/opentripplanner/OpenTripPlanner/pull/6459) - Improve street routing within concave parts of area holes [#6486](https://github.com/opentripplanner/OpenTripPlanner/pull/6486) - Fix rounding error in street routing [#6484](https://github.com/opentripplanner/OpenTripPlanner/pull/6484) +- Support for coordinates in via search [#6477](https://github.com/opentripplanner/OpenTripPlanner/pull/6477) [](AUTOMATIC_CHANGELOG_PLACEHOLDER_DO_NOT_REMOVE) ## 2.6.0 (2024-09-18) From d4bdcc574137d8dfffbce567bf964a621b06e63b Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 4 Mar 2025 05:33:09 +0000 Subject: [PATCH 64/69] fix(deps): update logging dependencies (#6509) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 6250f144cf4..f27c1e067a3 100644 --- a/pom.xml +++ b/pom.xml @@ -69,14 +69,14 @@ 5.11.4 1.14.1 5.6.0 - 1.5.12 + 1.5.17 10.1.0 1.14.4 2.0.15 5.6.0 4.29.3 2.0.0 - 2.0.16 + 2.0.17 UTF-8 opentripplanner/OpenTripPlanner From df96d003c5be774f51c1017ad028284befe50101 Mon Sep 17 00:00:00 2001 From: OTP Changelog Bot Date: Tue, 4 Mar 2025 12:53:14 +0000 Subject: [PATCH 65/69] Add changelog entry for #6494 [ci skip] --- doc/user/Changelog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/user/Changelog.md b/doc/user/Changelog.md index 1c32c9b0255..19c884a5317 100644 --- a/doc/user/Changelog.md +++ b/doc/user/Changelog.md @@ -107,6 +107,7 @@ based on merged pull requests. Search GitHub issues and pull requests for smalle - Improve street routing within concave parts of area holes [#6486](https://github.com/opentripplanner/OpenTripPlanner/pull/6486) - Fix rounding error in street routing [#6484](https://github.com/opentripplanner/OpenTripPlanner/pull/6484) - Support for coordinates in via search [#6477](https://github.com/opentripplanner/OpenTripPlanner/pull/6477) +- Use default max stop count for mode from routing defaults in transfer requests [#6494](https://github.com/opentripplanner/OpenTripPlanner/pull/6494) [](AUTOMATIC_CHANGELOG_PLACEHOLDER_DO_NOT_REMOVE) ## 2.6.0 (2024-09-18) From 060d77985ba9904f3cb064c0a36a99c1432d7d94 Mon Sep 17 00:00:00 2001 From: Joel Lappalainen Date: Fri, 28 Feb 2025 12:33:40 +0200 Subject: [PATCH 66/69] Update prettier java version --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f27c1e067a3..0641394eaf3 100644 --- a/pom.xml +++ b/pom.xml @@ -294,7 +294,7 @@ prettier-maven-plugin ${plugin.prettier.skip} - 2.0.0 + 2.6.7 src/main/java/**/*.java src/test/java/**/*.java From cfb31f03255c4dd29f26770f8fb010edb233117d Mon Sep 17 00:00:00 2001 From: OTP Serialization Version Bot Date: Tue, 4 Mar 2025 12:54:33 +0000 Subject: [PATCH 67/69] Bump serialization version id for #6494 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f27c1e067a3..a13ae66fdb6 100644 --- a/pom.xml +++ b/pom.xml @@ -58,7 +58,7 @@ - 184 + 185 32.2 From e8e9a7716955b68b5b37997a0267148f1dcbcf9e Mon Sep 17 00:00:00 2001 From: Joel Lappalainen Date: Tue, 4 Mar 2025 15:02:10 +0200 Subject: [PATCH 68/69] Run formatting with newer prettier java version --- .../DecorateWithAccessibilityScoreTest.java | 5 +- .../ext/emissions/EmissionsModuleTest.java | 3 +- .../ext/emissions/EmissionsTest.java | 33 +- .../ext/fares/FareRuleSetTest.java | 6 +- .../fares/impl/AtlantaFareServiceTest.java | 105 ++- .../fares/impl/DefaultFareServiceTest.java | 28 +- .../ext/fares/impl/FareModelForTest.java | 46 +- .../ext/fares/impl/FaresIntegrationTest.java | 11 +- .../fares/impl/GtfsFaresV2ServiceTest.java | 186 +++-- .../ext/fares/impl/HSLFareServiceTest.java | 48 +- ...reInFreeTransferWindowFareServiceTest.java | 27 +- .../ext/fares/impl/OrcaFareServiceTest.java | 33 +- .../flex/AreaStopsToVerticesMapperTest.java | 6 +- .../ext/flex/FlexIntegrationTest.java | 9 +- .../ext/flex/FlexPathDurationsTest.java | 15 +- .../ext/flex/FlexStopTimesForTest.java | 3 +- .../flex/FlexibleTransitLegBuilderTest.java | 11 +- .../flex/flexpathcalculator/FlexPathTest.java | 6 +- .../ScheduledFlexPathCalculatorTest.java | 3 +- .../trip/UnscheduledDrivingDurationTest.java | 14 +- .../ext/flex/trip/UnscheduledTripTest.java | 35 +- .../ext/geocoder/LuceneIndexTest.java | 71 +- .../ext/geocoder/StopClusterMapperTest.java | 6 +- .../mapping/TransmodelMappingUtilTest.java | 3 +- .../RealtimeResolverTest.java | 16 +- .../model/ApiTravelOptionsMakerTest.java | 48 +- .../parameter/QualifiedModeSetTest.java | 20 +- .../restapi/parameter/QualifiedModeTest.java | 3 +- .../DecorateWithRideHailingTest.java | 3 +- .../RideHailingAccessShifterTest.java | 3 +- .../updater/azure/SiriAzureUpdaterTest.java | 45 +- .../DecorateConsolidatedStopNamesTest.java | 9 +- .../TestStopConsolidationModel.java | 11 +- .../model/ConsolidatedStopLegBuilderTest.java | 23 +- .../areastops/AreaStopPropertyMapperTest.java | 3 +- .../areastops/AreaStopsLayerBuilderTest.java | 38 +- .../DigitransitStationPropertyMapperTest.java | 3 +- .../layers/stops/RealtimeStopsLayerTest.java | 35 +- .../layers/stops/StopsLayerTest.java | 6 +- .../VehicleParkingGroupsLayerTest.java | 98 ++- .../VehicleParkingsLayerTest.java | 48 +- .../mapper/VehicleRentalLayerTest.java | 21 +- .../ext/actuator/ActuatorAPI.java | 42 +- .../MicrometerGraphQLInstrumentation.java | 6 +- .../DataOverlayStreetEdgeCostExtension.java | 2 +- .../ext/dataoverlay/GenericDataFile.java | 6 +- .../ext/dataoverlay/GenericEdgeUpdater.java | 7 +- .../configuration/DataOverlayConfig.java | 3 +- .../DataOverlayParameterBindings.java | 3 +- .../configuration/IndexVariable.java | 3 +- .../configuration/ParameterBinding.java | 3 +- .../ext/dataoverlay/routing/Parameter.java | 3 +- .../datastore/gs/GsDataSourceRepository.java | 8 +- .../EdgeVertexTileRenderer.java | 12 +- .../ElevationEdgeRenderer.java | 46 +- .../debugrastertiles/TileRendererManager.java | 7 +- .../api/resource/DebugRasterTileResource.java | 11 +- .../ext/emissions/DecorateWithEmission.java | 5 +- .../ext/emissions/EmissionsConfig.java | 24 +- .../ext/fares/impl/DefaultFareService.java | 26 +- .../ext/fares/impl/GtfsFaresV2Service.java | 17 +- .../ext/fares/impl/HSLFareService.java | 12 +- ...stFareInFreeTransferWindowFareService.java | 6 +- ...nFreeTransferWindowFareServiceFactory.java | 18 +- .../ext/fares/impl/OrcaFareService.java | 8 +- .../ext/fares/model/FareRule.java | 3 +- .../ext/flex/FlexAccessEgress.java | 9 +- .../opentripplanner/ext/flex/FlexRouter.java | 52 +- .../ext/flex/FlexTripsMapper.java | 6 +- .../ext/flex/FlexibleTransitLeg.java | 3 +- .../DirectFlexPathCalculator.java | 9 +- .../StreetFlexPathCalculator.java | 9 +- .../flex/template/AbstractFlexTemplate.java | 9 +- .../ext/flex/template/ClosestTrip.java | 7 +- .../flex/template/FlexDirectPathFactory.java | 19 +- .../flex/template/FlexTemplateFactory.java | 7 +- .../ext/flex/trip/ScheduledDeviatedTrip.java | 3 +- .../ext/geocoder/GeocoderResource.java | 3 +- .../ext/geocoder/LuceneIndex.java | 62 +- .../ext/geocoder/StopClusterMapper.java | 20 +- .../parkAndRideApi/ParkAndRideResource.java | 8 +- .../reportapi/model/GraphReportBuilder.java | 27 +- .../ext/reportapi/model/TransfersReport.java | 7 +- .../reportapi/resource/ReportResource.java | 3 +- .../ext/restapi/mapping/FareMapper.java | 9 +- .../ext/restapi/mapping/LegMapper.java | 49 +- .../ext/restapi/mapping/PlaceMapper.java | 18 +- .../ext/restapi/mapping/RouteMapper.java | 7 +- .../ext/restapi/mapping/StopMapper.java | 5 +- .../ext/restapi/mapping/WalkStepMapper.java | 6 +- .../ext/restapi/model/ApiBookingInfo.java | 3 +- .../ext/restapi/model/ApiContactInfo.java | 3 +- .../ext/restapi/model/ApiRouterInfo.java | 13 +- .../restapi/resources/PlannerResource.java | 4 +- .../resources/RequestToPreferencesMapper.java | 25 +- .../restapi/resources/RoutingResource.java | 20 +- .../JSONObjectMapperProvider.java | 9 +- .../CachingRideHailingService.java | 14 +- .../ridehailing/RideHailingAccessShifter.java | 2 - .../service/oauth/CachedOAuthToken.java | 4 +- .../service/oauth/CachingOAuthService.java | 3 +- .../service/oauth/UrlEncodedOAuthService.java | 3 +- .../ridehailing/service/uber/UberService.java | 24 +- .../updater/azure/SiriAzureSXUpdater.java | 7 +- .../siri/updater/azure/SiriAzureUpdater.java | 80 +- .../SmooveBikeRentalDataSource.java | 35 +- .../SorlandsbanenNorwayService.java | 6 +- .../StopConsolidationParser.java | 9 +- .../areastops/AreaStopsLayerBuilder.java | 6 +- .../layers/stations/StationsLayerBuilder.java | 6 +- .../layers/stops/StopsLayerBuilder.java | 14 +- .../VehicleParkingGroupsLayerBuilder.java | 5 +- .../VehicleParkingsLayerBuilder.java | 5 +- .../vehicleparking/bikeep/BikeepUpdater.java | 15 +- .../vehicleparking/bikely/BikelyUpdater.java | 49 +- .../liipi/LiipiFacilitiesDownloader.java | 32 +- .../LiipiHubToVehicleParkingGroupMapper.java | 3 +- .../liipi/LiipiHubsDownloader.java | 26 +- .../LiipiParkToVehicleParkingMapper.java | 6 +- .../liipi/LiipiParkUpdater.java | 52 +- .../parkapi/ParkAPIUpdater.java | 25 +- .../sirifm/SiriFmDatasource.java | 27 +- ...ntalServiceDirectoryFetcherParameters.java | 5 +- .../main/java/com/jhlabs/awt/TextStroke.java | 9 +- .../api/common/OTPExceptionMapper.java | 15 +- .../api/parameter/QualifiedModeSet.java | 11 +- .../api/resource/UpdaterStatusResource.java | 3 +- .../api/resource/WebMercatorTile.java | 2 +- .../apis/gtfs/DefaultValueInjector.java | 69 +- .../apis/gtfs/GraphQLScalars.java | 103 +-- .../apis/gtfs/GtfsGraphQLAPI.java | 6 +- .../apis/gtfs/GtfsGraphQLIndex.java | 18 +- .../apis/gtfs/IntrospectionTypeWiring.java | 77 +- .../apis/gtfs/SchemaFactory.java | 6 +- .../apis/gtfs/datafetchers/AgencyImpl.java | 5 +- .../gtfs/datafetchers/DepartureRowImpl.java | 20 +- .../apis/gtfs/datafetchers/LegImpl.java | 33 +- .../apis/gtfs/datafetchers/PatternImpl.java | 25 +- .../apis/gtfs/datafetchers/QueryTypeImpl.java | 310 ++++--- .../apis/gtfs/datafetchers/RouteImpl.java | 26 +- .../apis/gtfs/datafetchers/RouteTypeImpl.java | 9 +- .../apis/gtfs/datafetchers/StopImpl.java | 139 ++-- .../apis/gtfs/datafetchers/TripImpl.java | 30 +- .../datafetchers/TripOnServiceDateImpl.java | 7 +- .../gtfs/generated/GraphQLDataFetchers.java | 32 +- .../apis/gtfs/generated/GraphQLTypes.java | 568 ++++++------- .../mapping/routerequest/ArgumentUtils.java | 11 +- .../LegacyRouteRequestMapper.java | 118 ++- .../routerequest/ViaLocationMapper.java | 3 +- .../apis/support/TileJson.java | 13 +- .../injectdoc/ApiDocumentationProfile.java | 2 +- .../injectdoc/CustomDocumentation.java | 5 +- .../apis/transmodel/TransmodelAPI.java | 21 +- .../apis/transmodel/TransmodelGraph.java | 20 +- .../transmodel/TransmodelGraphQLPlanner.java | 6 +- .../transmodel/TransmodelGraphQLSchema.java | 515 +++++------- .../apis/transmodel/mapping/FilterMapper.java | 27 +- .../transmodel/mapping/SeverityMapper.java | 7 +- .../transmodel/mapping/TripRequestMapper.java | 74 +- .../mapping/TripViaLocationMapper.java | 3 +- .../transmodel/mapping/ViaRequestMapper.java | 12 +- .../preferences/BikePreferencesMapper.java | 11 +- .../ItineraryFilterPreferencesMapper.java | 5 +- .../preferences/RentalPreferencesMapper.java | 10 +- .../preferences/ScooterPreferencesMapper.java | 9 +- .../preferences/TransitPreferencesMapper.java | 24 +- .../model/DefaultRouteRequestType.java | 147 ++-- .../apis/transmodel/model/EnumTypes.java | 81 +- .../model/TransmodelTransportSubmode.java | 3 +- .../transmodel/model/TransportModeSlack.java | 60 +- .../model/TripTimeOnDateHelper.java | 6 +- .../model/framework/AuthorityType.java | 21 +- .../model/framework/BrandingType.java | 21 +- .../model/framework/CoordinateInputType.java | 9 +- .../model/framework/InfoLinkType.java | 9 +- .../model/framework/LocationInputType.java | 12 +- .../framework/MultilingualStringType.java | 9 +- .../model/framework/NoticeType.java | 9 +- .../model/framework/OperatorType.java | 21 +- .../framework/PassThroughPointInputType.java | 9 +- .../framework/PenaltyForStreetModeType.java | 36 +- .../model/framework/PointsOnLinkType.java | 9 +- .../framework/RentalVehicleTypeType.java | 18 +- .../model/framework/ServerInfoType.java | 35 +- .../StreetModeDurationInputType.java | 21 +- .../model/framework/SystemNoticeType.java | 11 +- .../model/framework/TransmodelDirectives.java | 3 +- .../model/framework/ValidityPeriodType.java | 9 +- .../model/network/DestinationDisplayType.java | 9 +- .../model/network/GroupOfLinesType.java | 21 +- .../model/network/JourneyPatternType.java | 48 +- .../transmodel/model/network/LineType.java | 69 +- .../model/network/PresentationType.java | 9 +- .../model/network/StopToStopGeometryType.java | 12 +- .../model/plan/BannedInputType.java | 3 +- .../model/plan/ElevationProfileStepType.java | 26 +- .../model/plan/FilterInputType.java | 9 +- .../model/plan/ItineraryFiltersInputType.java | 48 +- .../model/plan/JourneyWhiteListed.java | 8 +- .../apis/transmodel/model/plan/LegType.java | 129 +-- .../model/plan/ModeAndSubModeInputType.java | 9 +- .../transmodel/model/plan/ModeInputType.java | 15 +- .../model/plan/PathGuidanceType.java | 36 +- .../transmodel/model/plan/PlanPlaceType.java | 27 +- .../transmodel/model/plan/RelaxCostType.java | 15 +- .../model/plan/RoutingErrorType.java | 12 +- .../model/plan/SelectInputType.java | 18 +- .../model/plan/TriangleFactorsInputType.java | 12 +- .../plan/TripPatternTimePenaltyType.java | 14 +- .../model/plan/TripPatternType.java | 75 +- .../model/plan/TripPlanTimePenaltyDto.java | 6 +- .../apis/transmodel/model/plan/TripQuery.java | 171 ++-- .../apis/transmodel/model/plan/TripType.java | 42 +- .../model/plan/ViaLocationInputType.java | 96 +-- .../plan/legacyvia/ViaLocationInputType.java | 18 +- .../plan/legacyvia/ViaSegmentInputType.java | 21 +- .../model/plan/legacyvia/ViaTripQuery.java | 33 +- .../model/plan/legacyvia/ViaTripType.java | 27 +- .../model/scalars/DateTimeScalarFactory.java | 9 +- .../model/scalars/DoubleFunctionFactory.java | 5 +- .../scalars/GeoJSONCoordinatesScalar.java | 21 +- .../model/scalars/LocalTimeScalarFactory.java | 3 +- .../model/scalars/TimeScalarFactory.java | 15 +- .../model/siri/et/EstimatedCallType.java | 128 ++- .../transmodel/model/siri/sx/AffectsType.java | 91 +-- .../model/siri/sx/PtSituationElementType.java | 89 +- .../transmodel/model/stop/BikeParkType.java | 21 +- .../model/stop/BikeRentalStationType.java | 30 +- .../model/stop/PlaceAtDistanceType.java | 21 +- .../model/stop/PlaceInterfaceType.java | 12 +- .../model/stop/QuayAtDistanceType.java | 12 +- .../apis/transmodel/model/stop/QuayType.java | 117 +-- .../model/stop/RentalVehicleType.java | 21 +- .../transmodel/model/stop/StopPlaceType.java | 126 ++- .../transmodel/model/stop/TariffZoneType.java | 6 +- .../timetable/BookingArrangementType.java | 42 +- .../timetable/DatedServiceJourneyQuery.java | 50 +- .../timetable/DatedServiceJourneyType.java | 36 +- .../model/timetable/InterchangeType.java | 33 +- .../model/timetable/ServiceJourneyType.java | 87 +- .../timetable/TimetabledPassingTimeType.java | 68 +- .../model/timetable/TripMetadataType.java | 12 +- .../support/ExecutionResultMapper.java | 23 +- .../apis/transmodel/support/GqlUtil.java | 6 +- .../support/OneOfInputValidator.java | 3 +- .../apis/vectortiles/DebugStyleSpec.java | 78 +- .../GraphInspectorVectorTileResource.java | 12 +- .../apis/vectortiles/model/StyleBuilder.java | 5 +- .../opentripplanner/astar/model/BinHeap.java | 8 +- .../astar/model/ShortestPathTree.java | 2 +- .../datastore/OtpDataStore.java | 7 +- .../file/ZipStreamDataSourceDecorator.java | 3 +- .../https/HttpsDataSourceMetadata.java | 3 +- .../framework/application/OTPFeature.java | 23 +- .../geometry/CompactElevationProfile.java | 9 +- .../geometry/CompactLineStringUtils.java | 11 +- .../framework/geometry/DirectionUtils.java | 4 +- .../framework/geometry/GeometryUtils.java | 3 +- .../geometry/HashGridSpatialIndex.java | 74 +- .../geometry/SphericalDistanceLibrary.java | 6 +- .../graphql/scalar/CostScalarFactory.java | 3 +- .../graphql/scalar/DateScalarFactory.java | 3 +- .../graphql/scalar/DurationScalarFactory.java | 3 +- .../framework/io/FileUtils.java | 8 +- .../framework/io/JsonDataListDownloader.java | 26 +- .../framework/io/OtpHttpClient.java | 59 +- .../framework/io/OtpHttpClientFactory.java | 37 +- .../framework/token/Deserializer.java | 5 +- .../framework/token/Serializer.java | 3 +- .../framework/token/TokenDefinition.java | 3 +- .../framework/token/TokenSchema.java | 3 +- .../GraphBuilderDataSources.java | 6 +- .../graph_builder/issue/api/Issue.java | 3 +- .../issues/ParkAndRideEntranceRemoved.java | 3 +- .../module/AddTransitEntitiesToGraph.java | 11 +- .../module/DirectTransferGenerator.java | 6 +- .../module/OsmBoardingLocationsModule.java | 2 +- .../module/StreetLinkerModule.java | 14 +- .../module/TransferParameters.java | 3 +- .../module/TripPatternNamer.java | 5 +- .../module/configure/GraphBuilderModules.java | 26 +- .../module/geometry/GeometryProcessor.java | 29 +- .../module/geometry/IndexedLineSegment.java | 13 +- .../module/islandpruning/PruneIslands.java | 3 +- .../module/islandpruning/Subgraph.java | 2 +- .../nearbystops/StreetNearbyStopFinder.java | 6 +- .../module/ned/ElevationModule.java | 21 +- .../module/ned/MissingElevationHandler.java | 9 +- .../module/ned/VerticalDatum.java | 16 +- .../module/osm/ElevatorProcessor.java | 28 +- .../module/osm/EscalatorProcessor.java | 7 +- .../graph_builder/module/osm/OsmArea.java | 5 +- .../graph_builder/module/osm/OsmDatabase.java | 134 ++-- .../graph_builder/module/osm/OsmModule.java | 63 +- .../module/osm/ParkingProcessor.java | 58 +- .../graph_builder/module/osm/Ring.java | 8 +- .../module/osm/SafetyValueNormalizer.java | 5 +- .../module/osm/VertexGenerator.java | 26 +- .../module/osm/WalkableAreaBuilder.java | 28 +- .../module/osm/naming/SidewalkNamer.java | 5 +- .../gtfs/GenerateTripPatternsOperation.java | 9 +- .../gtfs/graphbuilder/GtfsBundle.java | 29 +- .../gtfs/graphbuilder/GtfsModule.java | 6 +- .../gtfs/interlining/InterlineProcessor.java | 14 +- .../gtfs/mapping/AgencyMapper.java | 3 +- .../gtfs/mapping/BoardingAreaMapper.java | 6 +- .../gtfs/mapping/BookingRuleMapper.java | 30 +- .../gtfs/mapping/EntranceMapper.java | 20 +- .../gtfs/mapping/FareAttributeMapper.java | 6 +- .../gtfs/mapping/FareLegRuleMapper.java | 31 +- .../gtfs/mapping/FrequencyMapper.java | 3 +- .../GTFSToOtpTransitServiceMapper.java | 35 +- .../gtfs/mapping/PathwayMapper.java | 3 +- .../gtfs/mapping/PathwayNodeMapper.java | 20 +- .../gtfs/mapping/RouteMapper.java | 19 +- .../mapping/ServiceCalendarDateMapper.java | 5 +- .../gtfs/mapping/ServiceCalendarMapper.java | 3 +- .../gtfs/mapping/ShapePointMapper.java | 3 +- .../gtfs/mapping/StationMapper.java | 3 +- .../gtfs/mapping/StopTimeMapper.java | 15 +- .../gtfs/mapping/TranslationHelper.java | 3 +- .../gtfs/mapping/TripMapper.java | 13 +- .../vector/VectorTileResponseFactory.java | 6 +- .../vector/stop/GroupStopLayerBuilder.java | 19 +- .../vector/vertex/VertexPropertyMapper.java | 35 +- .../org/opentripplanner/model/Frequency.java | 3 +- .../opentripplanner/model/PathTransfer.java | 3 +- .../opentripplanner/model/SystemNotice.java | 3 +- .../org/opentripplanner/model/Timetable.java | 3 +- .../model/TimetableSnapshot.java | 13 +- .../model/calendar/CalendarServiceData.java | 5 +- .../model/calendar/ServiceCalendarDate.java | 3 +- .../impl/CalendarServiceDataFactoryImpl.java | 10 +- .../calendar/openinghours/OHCalendar.java | 3 +- .../model/fare/FareProduct.java | 3 +- .../model/fare/ItineraryFares.java | 3 +- .../model/impl/OtpTransitServiceBuilder.java | 6 +- .../model/impl/OtpTransitServiceImpl.java | 5 +- .../modes/AllowMainAndSubModeFilter.java | 3 +- .../modes/AllowMainAndSubModesFilter.java | 6 +- .../model/modes/FilterFactory.java | 5 +- .../opentripplanner/model/plan/Itinerary.java | 24 +- .../model/plan/ItinerarySortKey.java | 3 +- .../org/opentripplanner/model/plan/Place.java | 6 +- .../model/plan/ScheduledTransitLeg.java | 17 +- .../model/plan/StopArrival.java | 3 +- .../opentripplanner/model/plan/StreetLeg.java | 6 +- .../opentripplanner/model/plan/TripPlan.java | 3 +- .../model/plan/UnknownTransitPathLeg.java | 3 +- .../opentripplanner/model/plan/WalkStep.java | 3 +- .../model/plan/WalkStepBuilder.java | 2 +- .../legreference/LegReferenceSerializer.java | 6 +- .../plan/legreference/LegReferenceType.java | 3 +- .../ScheduledTransitLegReference.java | 3 +- .../paging/PagingSearchWindowAdjuster.java | 9 +- .../model/plan/paging/cursor/PageCursor.java | 3 +- .../plan/paging/cursor/PageCursorFactory.java | 35 +- .../paging/cursor/PageCursorSerializer.java | 21 +- .../model/projectinfo/VersionControlInfo.java | 3 +- .../model/transfer/ConstrainedTransfer.java | 9 +- .../transfer/RouteStopTransferPoint.java | 3 +- .../model/transfer/StationTransferPoint.java | 3 +- .../model/transfer/TransferConstraint.java | 3 +- .../model/transfer/TransferPointMap.java | 25 +- .../model/transfer/TripTransferPoint.java | 3 +- .../opentripplanner/netex/NetexBundle.java | 21 +- .../netex/config/NetexFeedParameters.java | 3 +- .../netex/configure/NetexConfigure.java | 13 +- .../netex/index/NetexEntityIndex.java | 28 +- .../loader/NetexDataSourceHierarchy.java | 3 +- .../parser/ServiceCalendarFrameParser.java | 3 +- .../netex/loader/parser/SiteFrameParser.java | 7 +- .../mapping/AuthorityToAgencyMapper.java | 17 +- .../netex/mapping/BookingInfoMapper.java | 9 +- .../netex/mapping/GroupOfRoutesMapper.java | 3 +- .../netex/mapping/GroupOfStationsMapper.java | 6 +- .../mapping/MultiModalStationMapper.java | 5 +- .../netex/mapping/NetexMapper.java | 3 +- .../netex/mapping/NoticeAssignmentMapper.java | 3 +- .../netex/mapping/NoticeMapper.java | 10 +- .../netex/mapping/QuayMapper.java | 5 +- .../netex/mapping/ServiceLinkMapper.java | 3 +- .../netex/mapping/StationMapper.java | 17 +- .../netex/mapping/StopAndStationMapper.java | 26 +- .../netex/mapping/StopTimesMapper.java | 36 +- .../netex/mapping/TripMapper.java | 14 +- .../netex/mapping/TripPatternMapper.java | 75 +- .../netex/mapping/VehicleParkingMapper.java | 3 +- .../netex/mapping/WheelChairMapper.java | 3 +- .../mapping/support/NetexMapperIndexes.java | 7 +- .../support/ServiceAlterationFilter.java | 6 +- .../netex/support/ServiceJourneyHelper.java | 3 +- .../netex/support/ServiceJourneyInfo.java | 5 +- ...erviceJourneyNonIncreasingPassingTime.java | 3 +- .../osm/DefaultOsmProvider.java | 3 +- .../osm/OsmOpeningHoursParser.java | 15 +- .../opentripplanner/osm/model/OsmEntity.java | 12 +- .../org/opentripplanner/osm/model/OsmWay.java | 6 +- .../osm/tagmapping/FinlandMapper.java | 11 +- .../osm/tagmapping/NorwayMapper.java | 3 +- .../osm/wayproperty/WayPropertySet.java | 34 +- .../wayproperty/specifier/OsmSpecifier.java | 3 +- .../routing/algorithm/RoutingWorker.java | 39 +- .../filterchain/api/GroupBySimilarity.java | 3 +- .../filters/system/NumItinerariesFilter.java | 5 +- .../system/NumItinerariesFilterResults.java | 3 +- .../system/SingleCriteriaComparator.java | 6 +- .../RemoveIfFirstOrLastTripIsTheSame.java | 2 +- .../framework/filter/RemoveFilter.java | 9 +- .../groupids/GroupByAllSameStations.java | 21 +- .../framework/groupids/GroupByDistance.java | 12 +- .../groupids/GroupBySameRoutesAndStops.java | 23 +- .../framework/sort/SortOrderComparator.java | 3 +- .../algorithm/mapping/AlertToLegMapper.java | 15 +- .../mapping/GraphPathToItineraryMapper.java | 15 +- .../mapping/RaptorPathToItineraryMapper.java | 17 +- .../RouteRequestToFilterChainMapper.java | 6 +- .../mapping/StatesToWalkStepsMapper.java | 21 +- .../algorithm/mapping/TripPlanMapper.java | 18 +- .../raptoradapter/path/PathDiff.java | 14 +- .../raptoradapter/router/TransitRouter.java | 10 +- .../PerformanceTimersForRaptor.java | 10 +- .../router/street/AccessEgressRouter.java | 3 +- .../raptoradapter/transit/Transfer.java | 3 +- .../transit/TripPatternForDate.java | 50 +- .../ConstrainedBoardingSearch.java | 24 +- .../ConstrainedTransfersForPatterns.java | 3 +- .../TransferPointForPatternFactory.java | 7 +- .../transit/cost/CostCalculatorFactory.java | 20 +- .../transit/cost/DefaultCostCalculator.java | 19 +- .../cost/GeneralizedCostParameters.java | 3 +- .../cost/WheelchairCostCalculator.java | 11 +- .../GeneralizedCostParametersMapper.java | 6 +- .../transit/mappers/RaptorRequestMapper.java | 3 +- .../mappers/RaptorTransitDataMapper.java | 6 +- .../RealTimeRaptorTransitDataUpdater.java | 24 +- .../transit/mappers/TransfersMapper.java | 18 +- .../request/RaptorRequestTransferCache.java | 8 +- .../RaptorRoutingRequestTransitData.java | 42 +- ...aptorRoutingRequestTransitDataCreator.java | 10 +- .../transit/request/TripPatternForDates.java | 3 +- .../request/TripScheduleAlightSearch.java | 3 +- .../request/TripScheduleBoardSearch.java | 3 +- .../request/TripScheduleWithOffset.java | 3 +- .../api/OptimizedPath.java | 5 +- ...ansferOptimizationServiceConfigurator.java | 12 +- .../model/BasicStopTime.java | 3 +- .../model/MinSafeTransferTimeCalculator.java | 2 +- .../model/OptimizedPathTail.java | 25 +- .../model/TransferWaitTimeCostCalculator.java | 2 +- .../model/TripStopTime.java | 3 +- .../model/TripToTripTransfer.java | 3 +- .../costfilter/MinCostPathTailFilter.java | 3 +- .../PassThroughPathTailFilter.java | 3 +- .../services/OptimizePathDomainService.java | 9 +- .../services/TransitPathLegSelector.java | 3 +- .../algorithm/via/ViaRoutingWorker.java | 6 +- .../alternativelegs/AlternativeLegs.java | 13 +- .../AlternativeLegsFilter.java | 19 +- .../routing/api/request/DebugRaptor.java | 3 +- .../routing/api/request/RequestModes.java | 8 +- .../routing/api/request/RouteRequest.java | 19 +- .../routing/api/request/StreetMode.java | 60 +- .../request/framework/CostLinearFunction.java | 6 +- .../request/framework/DurationForEnum.java | 3 +- .../preference/AccessEgressPreferences.java | 6 +- .../preference/AccessibilityPreferences.java | 10 +- .../request/preference/BikePreferences.java | 3 +- .../request/preference/CarPreferences.java | 3 +- .../preference/ElevatorPreferences.java | 3 +- .../preference/EscalatorPreferences.java | 3 +- .../ItineraryFilterPreferences.java | 33 +- .../request/preference/MaxStopCountLimit.java | 3 +- .../request/preference/RaptorPreferences.java | 21 +- .../preference/RoutingPreferences.java | 12 +- .../preference/ScooterPreferences.java | 3 +- .../request/preference/StreetPreferences.java | 3 +- .../request/preference/SystemPreferences.java | 3 +- .../TransferOptimizationPreferences.java | 11 +- .../preference/TransferPreferences.java | 9 +- .../preference/TransitPreferences.java | 3 +- .../preference/VehicleParkingPreferences.java | 41 +- .../preference/VehicleRentalPreferences.java | 8 +- .../preference/VehicleWalkingPreferences.java | 3 +- .../request/preference/WalkPreferences.java | 3 +- .../preference/WheelchairPreferences.java | 8 +- .../filter/VehicleParkingFilter.java | 3 +- .../api/request/request/JourneyRequest.java | 3 +- .../request/request/filter/SelectRequest.java | 3 +- .../request/filter/TransitFilterRequest.java | 3 +- .../request/filter/TransitGroupSelect.java | 10 +- .../request/via/PassThroughViaLocation.java | 3 +- .../api/request/via/VisitViaLocation.java | 14 +- .../routing/api/response/RoutingError.java | 3 +- .../routing/api/response/RoutingResponse.java | 3 +- .../api/response/TripSearchMetadata.java | 3 +- .../core/VehicleRoutingOptimizeType.java | 5 +- .../error/RoutingValidationException.java | 7 +- .../framework/DebugTimingAggregator.java | 20 +- .../routing/graph/index/StreetIndex.java | 20 +- .../routing/graphfinder/NearbyStop.java | 3 +- .../routing/graphfinder/PatternAtStop.java | 3 +- .../PlaceFinderTraverseVisitor.java | 4 +- .../graphfinder/StreetGraphFinder.java | 3 +- .../routing/impl/GraphPathFinder.java | 3 +- .../routing/linking/SameEdgeAdjuster.java | 3 +- .../routing/linking/VertexLinker.java | 19 +- .../service/DefaultRoutingService.java | 9 +- .../services/notes/StreetNoteModel.java | 8 +- .../routing/stoptimes/StopTimesHelper.java | 16 +- .../routing/util/ElevationUtils.java | 9 +- .../DefaultViaCoordinateTransferFactory.java | 29 +- .../DefaultOsmInfoGraphBuildRepository.java | 3 +- .../service/paging/PagingService.java | 32 +- .../model/RealtimeVehicle.java | 3 +- .../DefaultVehicleParkingRepository.java | 8 +- .../vehicleparking/model/VehicleParking.java | 9 +- .../model/VehicleParkingEntrance.java | 3 +- .../model/VehicleParkingGroup.java | 3 +- .../model/VehicleParkingHelper.java | 6 +- .../model/VehicleParkingSpaces.java | 3 +- .../model/RentalVehicleType.java | 6 +- .../model/VehicleRentalStation.java | 7 +- .../CompositeRentalRestrictionExtension.java | 6 +- .../street/GeofencingZoneExtension.java | 6 +- .../worldenvelope/model/WorldEnvelope.java | 3 +- .../opentripplanner/standalone/OTPMain.java | 22 +- .../standalone/OtpStartupInfo.java | 5 +- .../standalone/config/BuildConfig.java | 759 +++++++++--------- .../standalone/config/ConfigModel.java | 6 +- .../standalone/config/DebugUiConfig.java | 69 +- .../standalone/config/OtpConfig.java | 24 +- .../standalone/config/OtpConfigLoader.java | 3 +- .../standalone/config/RouterConfig.java | 13 +- .../buildconfig/IslandPruningConfig.java | 68 +- .../config/buildconfig/NetexConfig.java | 32 +- .../config/buildconfig/OsmConfig.java | 4 +- .../config/buildconfig/S3BucketConfig.java | 67 +- .../config/buildconfig/TransferConfig.java | 38 +- .../buildconfig/TransferParametersMapper.java | 44 +- .../buildconfig/TransferRequestConfig.java | 32 +- .../config/buildconfig/TransitFeedConfig.java | 2 +- .../config/framework/json/ConfigType.java | 65 +- .../config/framework/json/EnumMapper.java | 3 +- .../config/framework/json/NodeInfo.java | 3 +- .../framework/json/ParameterBuilder.java | 33 +- .../project/EnvironmentVariableReplacer.java | 6 +- .../config/routerconfig/ServerConfig.java | 151 ++-- .../routerconfig/TransitRoutingConfig.java | 489 ++++++----- .../config/routerconfig/UpdatersConfig.java | 15 +- .../config/routerconfig/VectorTileConfig.java | 22 +- .../MqttGtfsRealtimeUpdaterConfig.java | 26 +- .../updaters/PollingTripUpdaterConfig.java | 26 +- .../SiriETGooglePubsubUpdaterConfig.java | 16 +- .../updaters/SiriSXUpdaterConfig.java | 4 +- .../updaters/VehicleParkingUpdaterConfig.java | 12 +- .../sources/VehicleRentalSourceFactory.java | 20 +- .../routerequest/ItineraryFiltersConfig.java | 144 ++-- .../routerequest/RouteRequestConfig.java | 228 +++--- .../config/routerequest/TransferConfig.java | 61 +- .../TransitGroupPriorityConfig.java | 5 +- .../config/routerequest/WheelchairConfig.java | 21 +- .../standalone/config/sandbox/FlexConfig.java | 100 ++- .../config/sandbox/TransmodelAPIConfig.java | 45 +- ...leRentalServiceDirectoryFetcherConfig.java | 2 +- .../configure/ConstructApplication.java | 28 +- .../standalone/server/AlertMetrics.java | 17 +- .../standalone/server/EtagRequestFilter.java | 3 +- .../standalone/server/GrizzlyServer.java | 3 +- .../standalone/server/MetricsLogging.java | 18 +- .../model/StreetTraversalPermission.java | 4 +- .../street/model/edge/CarPickupableEdge.java | 6 +- .../street/model/edge/ElevatorBoardEdge.java | 7 +- .../street/model/edge/PathwayEdge.java | 30 +- .../street/model/edge/StreetEdge.java | 107 ++- .../model/edge/StreetElevationExtension.java | 3 +- .../edge/StreetElevationExtensionBuilder.java | 5 +- .../model/edge/StreetTransitEntityLink.java | 6 +- .../edge/TemporaryPartialStreetEdge.java | 6 +- .../model/elevation/ElevationUtils.java | 9 +- .../model/note/StreetNoteAndMatcher.java | 3 +- .../model/vertex/StationEntranceVertex.java | 3 +- .../street/model/vertex/StreetVertex.java | 18 +- .../model/vertex/TransitStopVertex.java | 15 +- .../street/model/vertex/Vertex.java | 5 +- .../street/search/StreetSearchBuilder.java | 12 +- .../request/StreetSearchRequestMapper.java | 6 +- .../street/search/state/State.java | 20 +- .../street/search/state/StateData.java | 36 +- .../street/search/state/StateEditor.java | 5 +- .../transit/model/basic/Distance.java | 16 +- .../transit/model/basic/MainAndSubMode.java | 3 +- .../transit/model/basic/Ratio.java | 10 +- .../transit/model/basic/TransitMode.java | 8 +- .../filter/transit/RouteMatcherFactory.java | 5 +- .../TripOnServiceDateMatcherFactory.java | 6 +- .../transit/model/framework/Deduplicator.java | 10 +- .../transit/model/framework/FeedScopedId.java | 3 +- .../transit/model/network/StopPattern.java | 6 +- .../transit/model/network/TripPattern.java | 9 +- .../model/network/TripPatternBuilder.java | 15 +- .../TransitGroupPriorityService.java | 5 +- .../transit/model/organization/Agency.java | 24 +- .../model/organization/ContactInfo.java | 3 +- .../transit/model/organization/Operator.java | 7 +- .../transit/model/site/GroupStopBuilder.java | 15 +- .../transit/model/site/Station.java | 6 +- .../transit/model/site/StationElement.java | 6 +- .../model/timetable/OccupancyStatus.java | 54 +- .../model/timetable/RealTimeTripTimes.java | 6 +- .../timetable/ScheduledTripTimesBuilder.java | 12 +- .../transit/model/timetable/Trip.java | 13 +- .../model/timetable/booking/BookingInfo.java | 3 +- .../timetable/booking/RoutingBookingInfo.java | 13 +- .../service/DefaultTransitService.java | 25 +- .../transit/service/SiteRepository.java | 12 +- .../transit/service/StopModelIndex.java | 11 +- .../transit/service/TimetableRepository.java | 9 +- .../service/TimetableRepositoryIndex.java | 3 +- .../updater/GraphUpdaterManager.java | 53 +- .../updater/TimetableSnapshotParameters.java | 6 +- .../alert/gtfs/AlertsUpdateHandler.java | 3 +- .../gtfs/mapping/GtfsRealtimeCauseMapper.java | 7 +- .../mapping/GtfsRealtimeEffectMapper.java | 7 +- .../mapping/GtfsRealtimeSeverityMapper.java | 7 +- .../alert/siri/SiriAlertsUpdateHandler.java | 16 +- .../updater/alert/siri/SiriSXUpdater.java | 27 +- .../alert/siri/lite/SiriLiteHttpLoader.java | 7 +- .../alert/siri/mapping/AffectsMapper.java | 6 +- .../configure/UpdaterConfigurator.java | 12 +- .../updater/spi/GenericJsonDataSource.java | 15 +- .../updater/spi/ResultLogger.java | 2 +- .../gtfs/GtfsRealTimeTripUpdateAdapter.java | 115 +-- .../updater/trip/gtfs/TripPatternCache.java | 18 +- .../updater/trip/gtfs/TripTimesUpdater.java | 38 +- .../updater/http/HttpTripUpdateSource.java | 12 +- .../gtfs/updater/http/PollingTripUpdater.java | 3 +- .../updater/mqtt/MqttGtfsRealtimeUpdater.java | 3 +- .../trip/metrics/BatchTripUpdateMetrics.java | 46 +- .../metrics/StreamingTripUpdateMetrics.java | 9 +- .../trip/metrics/TripUpdateMetrics.java | 11 +- .../updater/trip/siri/AddedTripBuilder.java | 12 +- .../updater/trip/siri/DebugString.java | 17 +- .../updater/trip/siri/EntityResolver.java | 6 +- .../trip/siri/ModifiedTripBuilder.java | 12 +- .../trip/siri/SiriFuzzyTripMatcher.java | 6 +- .../siri/SiriRealTimeTripUpdateAdapter.java | 39 +- .../trip/siri/SiriTripPatternCache.java | 18 +- .../updater/SiriETHttpTripUpdateSource.java | 7 +- .../trip/siri/updater/SiriETUpdater.java | 13 +- .../GooglePubsubEstimatedTimetableSource.java | 68 +- .../google/SiriETGooglePubsubUpdater.java | 35 +- .../SiriETGooglePubsubUpdaterParameters.java | 3 +- .../lite/SiriETLiteHttpTripUpdateSource.java | 3 +- .../VehicleParkingAvailabilityUpdater.java | 9 +- .../VehicleParkingUpdater.java | 13 +- ...GtfsRealtimeHttpVehiclePositionSource.java | 3 +- .../PollingVehiclePositionUpdater.java | 6 +- .../RealtimeVehiclePatternMatcher.java | 19 +- .../GeofencingVertexUpdater.java | 3 +- .../vehicle_rental/VehicleRentalUpdater.java | 19 +- .../GbfsFreeVehicleStatusMapper.java | 51 +- .../datasources/GbfsGeofencingZoneMapper.java | 3 +- .../GbfsStationInformationMapper.java | 55 +- .../datasources/GbfsStationStatusMapper.java | 77 +- .../GbfsSystemInformationMapper.java | 18 +- .../GbfsVehicleRentalDataSource.java | 11 +- .../opentripplanner/visualizer/ShowGraph.java | 29 +- .../opentripplanner/ConstantsForTests.java | 20 +- .../java/org/opentripplanner/GtfsTest.java | 18 +- .../OtpArchitectureModules.java | 3 +- .../opentripplanner/TestServerContext.java | 10 +- .../_support/geometry/Polygons.java | 3 +- .../_support/text/TextAssertionsTest.java | 29 +- .../apis/gtfs/CoordinateValueScalarTest.java | 73 +- .../apis/gtfs/CostScalarTest.java | 46 +- .../apis/gtfs/DurationScalarTest.java | 5 +- .../apis/gtfs/GeoJsonScalarTest.java | 3 +- .../apis/gtfs/GraphQLIntegrationTest.java | 132 ++- .../apis/gtfs/OffsetDateTimeScalarTest.java | 3 +- .../apis/gtfs/RatioScalarTest.java | 49 +- .../apis/gtfs/ReluctanceScalarTest.java | 53 +- .../apis/gtfs/SchemaFactoryTest.java | 3 +- .../apis/gtfs/TestRoutingService.java | 17 +- .../datafetchers/BookingInfoImplTest.java | 6 +- .../gtfs/datafetchers/QueryTypeImplTest.java | 6 +- .../gtfs/mapping/DirectionMapperTest.java | 13 +- .../LegacyRouteRequestMapperTest.java | 32 +- .../RouteRequestMapperBicycleTest.java | 5 +- .../RouteRequestMapperCarTest.java | 5 +- .../RouteRequestMapperModesTest.java | 45 +- .../RouteRequestMapperScooterTest.java | 5 +- .../routerequest/RouteRequestMapperTest.java | 35 +- .../apis/support/TileJsonTest.java | 3 +- .../InjectCustomDocumentationTest.java | 56 +- .../mapping/BookingInfoMapperTest.java | 9 +- .../mapping/RequestModesMapperTest.java | 12 +- .../mapping/TripRequestMapperTest.java | 49 +- .../mapping/TripViaLocationMapperTest.java | 28 +- .../apis/transmodel/model/EnumTypesTest.java | 25 +- .../model/TransportModeSlackTest.java | 3 +- .../framework/CoordinateInputTypeTest.java | 7 +- .../model/plan/RelaxCostTypeTest.java | 6 +- .../support/ExecutionResultMapperTest.java | 10 +- .../apis/transmodel/support/GqlUtilTest.java | 42 +- .../support/OneOfInputValidatorTest.java | 16 +- .../org/opentripplanner/astar/AStarTest.java | 15 +- .../datastore/OtpDataStoreTest.java | 3 +- .../base/ByteArrayDataSourceTest.java | 20 +- .../resources/PlannerResourceTest.java | 3 +- .../framework/FrameworkArchitectureTest.java | 12 +- .../framework/application/OTPFeatureTest.java | 12 +- .../framework/geometry/GeometryUtilsTest.java | 23 +- .../geometry/PolylineEncoderTest.java | 3 +- .../SphericalDistanceLibraryTest.java | 3 +- .../framework/graphql/GraphQLUtilsTest.java | 32 +- .../graphql/scalar/DateScalarFactoryTest.java | 6 +- .../framework/i18n/LocalizedStringTest.java | 16 +- .../framework/json/JsonUtilsTest.java | 8 +- .../framework/model/UnitsTest.java | 5 +- .../framework/retry/OtpRetryTest.java | 49 +- .../token/AdvancedTokenSchemaTest.java | 73 +- .../framework/token/TokenSchemaTest.java | 43 +- .../doc/BuildConfigurationDocTest.java | 3 +- .../generate/doc/OsmMapperDocTest.java | 3 +- .../generate/doc/RideHailingDocTest.java | 3 +- .../generate/doc/RouteRequestDocTest.java | 6 +- .../doc/RouterConfigurationDocTest.java | 3 +- .../generate/doc/RoutingModeDocTest.java | 6 +- .../doc/StopConsolidationDocTest.java | 10 +- .../doc/framework/DocBuilderTest.java | 8 +- .../doc/framework/DocsTestConstants.java | 4 +- .../generate/doc/framework/TemplateUtil.java | 23 +- .../doc/framework/TemplateUtilTest.java | 19 +- .../generate/doc/support/ConfigTypeTable.java | 3 +- .../generate/doc/support/OTPFeatureTable.java | 3 +- .../module/DirectTransferGeneratorTest.java | 86 +- .../OsmBoardingLocationsModuleTest.java | 60 +- .../module/StreetLinkerModuleTest.java | 36 +- .../module/TestStreetLinkerModule.java | 3 +- .../module/VehicleParkingLinkingTest.java | 15 +- .../islandpruning/AdaptivePruningTest.java | 15 +- .../islandpruning/IslandPruningUtils.java | 3 +- .../islandpruning/PruneNoThruIslandsTest.java | 19 +- .../islandpruning/SubgraphOnlyFerryTest.java | 27 +- .../module/linking/LinkingTest.java | 9 +- .../ned/MissingElevationHandlerTest.java | 3 +- .../module/osm/OsmModuleTest.java | 39 +- .../module/osm/ParkingProcessorTest.java | 6 +- .../module/osm/PlatformLinkerTest.java | 13 +- .../module/osm/TriangleInequalityTest.java | 24 +- .../module/osm/UnconnectedAreasTest.java | 13 +- .../module/osm/UnroutableTest.java | 16 +- .../osm/moduletests/BoardingLocationTest.java | 24 +- .../walkablearea/ConcaveHoleTest.java | 19 +- .../walkablearea/SimpleAreaTest.java | 16 +- .../GenerateTripPatternsOperationTest.java | 91 +-- .../gtfs/GtfsContextBuilder.java | 11 +- .../interlining/InterlineProcessorTest.java | 6 +- .../gtfs/mapping/EntranceMapperTest.java | 5 +- .../gtfs/mapping/FareAttributeMapperTest.java | 3 +- .../gtfs/mapping/FareLegRuleMapperTest.java | 33 +- .../gtfs/mapping/FareRuleMapperTest.java | 3 +- .../gtfs/mapping/FeedInfoMapperTest.java | 3 +- .../gtfs/mapping/FeedScopedIdMapperTest.java | 5 +- .../gtfs/mapping/LocationMapperTest.java | 12 +- .../gtfs/mapping/StopTimeMapperTest.java | 5 +- .../gtfs/mapping/TransferMapperTest.java | 35 +- .../vector/VectorTileResponseFactoryTest.java | 6 +- .../model/TimetableSnapshotTest.java | 15 +- .../model/TripPatternTest.java | 6 +- .../calendar/ServiceDateIntervalTest.java | 6 +- ...pTransitServiceBuilderLimitPeriodTest.java | 6 +- .../impl/OtpTransitServiceBuilderTest.java | 6 +- .../model/impl/OtpTransitServiceImplTest.java | 14 +- .../model/plan/ElevationProfileTest.java | 6 +- .../model/plan/ItineraryTest.java | 3 +- .../opentripplanner/model/plan/PlaceTest.java | 6 +- .../plan/ScheduledTransitLegBuilderTest.java | 6 +- .../model/plan/ScheduledTransitLegTest.java | 15 +- .../model/plan/TestItineraryBuilder.java | 71 +- .../model/plan/WalkStepTest.java | 2 +- .../ScheduledTransitLegReferenceTest.java | 34 +- .../cursor/DeduplicationPageCutTest.java | 3 +- .../paging/cursor/PageCursorFactoryTest.java | 32 +- .../plan/paging/cursor/PageCursorTest.java | 23 +- .../projectinfo/MavenProjectVersionTest.java | 36 +- .../model/routing/TripSearchMetadataTest.java | 44 +- .../transfer/TransferConstraintTest.java | 9 +- .../model/transfer/TransferPointTest.java | 8 +- .../model/transfer/TransferTestData.java | 6 +- .../netex/NetexTestDataSupport.java | 17 +- .../netex/config/NetexFeedParametersTest.java | 3 +- .../ServiceCalendarFrameParserTest.java | 11 +- .../netex/mapping/FlexStopsMapperTest.java | 13 +- .../netex/mapping/NetexTestDataSample.java | 34 +- .../mapping/NoticeAssignmentMapperTest.java | 14 +- .../netex/mapping/NoticeMapperTest.java | 13 +- .../mapping/OperatorToAgencyMapperTest.java | 14 +- .../netex/mapping/RouteMapperTest.java | 3 +- .../netex/mapping/ServiceLinkMapperTest.java | 25 +- .../netex/mapping/StationMapperTest.java | 17 +- .../mapping/StopAndStationMapperTest.java | 17 +- .../mapping/TransportModeMapperTest.java | 21 +- .../mapping/TripCalendarBuilderTest.java | 6 +- .../netex/mapping/TripMapperTest.java | 3 +- .../mapping/WgsCoordinateMapperTest.java | 10 +- .../DatedServiceJourneyMapperTest.java | 10 +- .../calendar/DayTypeAssignmentMapperTest.java | 6 +- .../JourneyPatternSJMismatchTest.java | 3 +- ...ceJourneyNonIncreasingPassingTimeTest.java | 39 +- .../osm/wayproperty/MapperTest.java | 8 +- .../wayproperty/specifier/ConditionTest.java | 4 +- .../_data/api/TestPathBuilder.java | 20 +- .../TestConstrainedBoardingSearch.java | 6 +- .../transit/TestConstrainedTransfer.java | 3 +- .../raptorlegacy/_data/transit/TestRoute.java | 13 +- .../_data/transit/TestTransferPoint.java | 3 +- .../_data/transit/TestTransitData.java | 9 +- .../_data/transit/TestTripPattern.java | 3 +- .../_data/transit/TestTripSchedule.java | 6 +- .../routing/TestHalfEdges.java | 298 ++++--- .../routing/algorithm/FilterTest.java | 298 +++---- .../routing/algorithm/GraphRoutingTest.java | 6 +- .../algorithm/StreetModeLinkingTest.java | 6 +- .../routing/algorithm/TestBanning.java | 21 +- .../routing/algorithm/TurnCostTest.java | 3 +- .../ItineraryListFilterChainTest.java | 14 +- ...emoveParkAndRideWithMostlyWalkingTest.java | 5 +- .../system/FlexSearchWindowFilterTest.java | 6 +- .../system/OutsideSearchWindowFilterTest.java | 19 +- .../system/SingleCriteriaComparatorTest.java | 3 +- .../system/mcmax/McMaxLimitFilterTest.java | 3 +- ...moveItinerariesWithShortStreetLegTest.java | 6 +- ...RemoveTransitIfStreetOnlyIsBetterTest.java | 5 +- .../filterchain/DeleteResultHandlerTest.java | 10 +- .../groupids/GroupByDistanceTest.java | 10 +- .../sort/SortOnGeneralizedCostTest.java | 10 +- .../sort/SortOnNumberOfTransfersTest.java | 8 +- .../sort/SortOrderComparatorTest.java | 41 +- .../mapping/BikeRentalSnapshotTest.java | 6 +- .../GraphPathToItineraryMapperTest.java | 24 +- .../RaptorPathToItineraryMapperTest.java | 34 +- .../algorithm/mapping/SnapshotTestBase.java | 78 +- .../mapping/StatesToWalkStepsMapperTest.java | 6 +- ...ilterTransitWhenDirectModeIsEmptyTest.java | 6 +- .../router/street/AccessEgressRouterTest.java | 29 +- .../router/street/AccessEgressesTest.java | 6 +- .../transit/RaptorTransitDataTest.java | 23 +- .../transit/TripPatternForDateTest.java | 9 +- .../ConstrainedBoardingSearchTest.java | 67 +- .../cost/DefaultCostCalculatorTest.java | 6 +- .../cost/PatternCostCalculatorTest.java | 32 +- .../cost/RaptorCostLinearFunctionTest.java | 16 +- .../cost/WheelchairCostCalculatorTest.java | 24 +- .../GeneralizedCostParametersMapperTest.java | 13 +- .../mappers/LookupStopIndexCallbackTest.java | 10 +- .../mappers/RaptorRequestMapperTest.java | 12 +- ...rRoutingRequestTransitDataCreatorTest.java | 6 +- ...eRequestTransitDataProviderFilterTest.java | 45 +- .../transit/request/TestRouteData.java | 27 +- .../transit/request/TestTransitCaseData.java | 12 +- .../request/TripPatternForDatesTest.java | 3 +- .../request/TripScheduleAlightSearchTest.java | 14 +- .../request/TripScheduleBoardSearchTest.java | 12 +- .../BasicPathTestCase.java | 30 +- .../MinSafeTransferTimeCalculatorTest.java | 11 +- .../model/OptimizedPathTailTest.java | 16 +- .../TransferWaitTimeCostCalculatorTest.java | 11 +- .../model/TripStopTimeTest.java | 5 +- .../costfilter/MinCostPathTailFilterTest.java | 11 +- .../PassThroughNoTransfersTest.java | 3 +- .../PassThroughOneTransferTest.java | 6 +- .../PassThroughTwoTransfersTest.java | 9 +- .../model/passthrough/TestUtils.java | 9 +- ...imizePathDomainServiceConstrainedTest.java | 9 +- .../OptimizePathDomainServiceTest.java | 48 +- .../services/TestTransferBuilder.java | 6 +- .../services/TransferGeneratorTest.java | 64 +- .../services/TransitPathLegSelectorTest.java | 17 +- .../algorithm/via/ViaRoutingWorkerTest.java | 28 +- .../request/WheelchairPreferencesTest.java | 6 +- .../framework/CostLinearFunctionTest.java | 10 +- .../framework/DurationForEnumTest.java | 20 +- .../LinearFunctionSerializationTest.java | 40 +- .../TimeAndCostPenaltyForEnumTest.java | 15 +- .../request/framework/TimePenaltyTest.java | 9 +- .../AccessEgressPreferencesTest.java | 3 +- .../AccessibilityPreferencesTest.java | 3 +- .../preference/BikePreferencesTest.java | 15 +- .../preference/CarPreferencesTest.java | 3 +- .../preference/ElevatorPreferencesTest.java | 3 +- .../ItineraryFilterPreferencesTest.java | 15 +- .../preference/MaxStopCountLimitTest.java | 3 +- .../preference/RaptorPreferencesTest.java | 24 +- .../preference/ScooterPreferencesTest.java | 15 +- .../preference/StreetPreferencesTest.java | 3 +- .../preference/SystemPreferencesTest.java | 3 +- .../TimeSlopeSafetyTriangleTest.java | 6 +- .../TransferOptimizationPreferencesTest.java | 3 +- .../preference/TransferPreferencesTest.java | 9 +- .../preference/TransitPreferencesTest.java | 3 +- .../VehicleParkingPreferencesTest.java | 3 +- .../VehicleRentalPreferencesTest.java | 3 +- .../VehicleWalkingPreferencesTest.java | 3 +- .../preference/WalkPreferencesTest.java | 27 +- .../request/filter/SelectRequestTest.java | 3 +- .../via/PassThroughViaLocationTest.java | 3 +- .../api/request/via/VisitViaLocationTest.java | 3 +- .../routing/core/DistanceTest.java | 42 +- .../routing/core/RouteRequestTest.java | 10 +- .../routing/graph/GraphSerializationTest.java | 33 +- .../routing/graph/SimpleConcreteEdge.java | 2 +- .../routing/graph/TemporaryConcreteEdge.java | 2 +- .../PlaceFinderTraverseVisitorTest.java | 31 +- .../graphfinder/StreetGraphFinderTest.java | 75 +- .../stoptimes/AlternativeLegsTest.java | 12 +- .../stoptimes/StopTimesHelperTest.java | 9 +- .../routing/util/TestElevationUtils.java | 14 +- .../elevation/ToblersHikingFunctionTest.java | 2 +- ...FewItinerariesOnSearchWindowLimitTest.java | 8 +- .../service/paging/TestPagingModel.java | 6 +- .../VehicleParkingHelperTest.java | 44 +- .../VehicleParkingTestUtil.java | 3 +- .../DefaultVehicleRentalServiceTest.java | 8 +- .../TestFreeFloatingRentalVehicleBuilder.java | 59 +- .../TestVehicleRentalStationBuilder.java | 35 +- .../internal/WorldEnvelopeRepositoryTest.java | 3 +- .../internal/WorldEnvelopeServiceTest.java | 3 +- .../model/WorldEnvelopeTest.java | 9 +- .../standalone/config/ExampleConfigTest.java | 10 +- .../config/OtpConfigLoaderTest.java | 3 +- .../config/buildconfig/DemConfigTest.java | 12 +- .../config/buildconfig/GtfsConfigTest.java | 12 +- .../config/buildconfig/OsmConfigTest.java | 12 +- .../framework/file/ConfigFileLoaderTest.java | 9 +- .../config/framework/json/EnumMapperTest.java | 14 +- .../framework/json/NodeAdapterTest.java | 33 +- .../config/framework/json/NodeInfoTest.java | 6 +- .../EnvironmentVariableReplacerTest.java | 15 +- .../config/routerconfig/ServerConfigTest.java | 5 +- .../routerequest/RouteRequestConfigTest.java | 16 +- .../TimeAndCostPenaltyMapperTest.java | 6 +- .../routerequest/WheelchairConfigTest.java | 11 +- .../server/RequestTraceFilterTest.java | 3 +- .../integration/BarrierRoutingTest.java | 15 +- .../street/integration/BikeRentalTest.java | 30 +- .../street/integration/BikeWalkingTest.java | 3 +- .../street/integration/CarPickupTest.java | 3 +- .../street/integration/ParkAndRideTest.java | 3 +- .../SplitEdgeTurnRestrictionsTest.java | 3 +- .../street/model/TurnRestrictionTest.java | 9 +- .../model/_data/StreetModelForTest.java | 6 +- .../model/edge/AreaEdgeBuilderTest.java | 3 +- .../model/edge/ElevatorHopEdgeTest.java | 3 +- .../street/model/edge/EscalatorEdgeTest.java | 3 +- .../street/model/edge/PathwayEdgeTest.java | 3 +- .../model/edge/StreetEdgeBuilderTest.java | 3 +- .../model/edge/StreetEdgeGeofencingTest.java | 24 +- .../edge/StreetEdgeRentalTraversalTest.java | 18 +- .../edge/StreetEdgeScooterTraversalTest.java | 23 +- .../street/model/edge/StreetEdgeTest.java | 35 +- .../edge/StreetEdgeWheelchairCostTest.java | 12 +- .../StreetElevationExtensionBuilderTest.java | 48 +- .../edge/StreetTransitEntityLinkTest.java | 40 +- .../edge/StreetVehicleParkingLinkTest.java | 6 +- ...TemporaryPartialStreetEdgeBuilderTest.java | 3 +- .../edge/TemporaryPartialStreetEdgeTest.java | 3 +- .../model/edge/VehicleParkingEdgeTest.java | 3 +- .../edge/VehicleParkingPreferredTagsTest.java | 6 +- .../model/edge/VehicleRentalEdgeTest.java | 73 +- .../street/search/state/StateDataTest.java | 6 +- .../street/search/state/TestStateBuilder.java | 38 +- .../test/support/JsonAssertions.java | 13 +- .../test/support/TestTableParser.java | 20 +- .../api/model/RequiredFilterValuesTest.java | 18 +- .../TimetableRepositoryArchitectureTest.java | 66 +- .../transit/model/_data/PatternTestModel.java | 9 +- .../_data/TimetableRepositoryForTest.java | 34 +- .../transit/model/basic/NoticeTest.java | 3 +- .../expr/NullSafeWrapperMatcherTest.java | 6 +- .../RegularStopMatcherFactoryTest.java | 18 +- .../transit/RouteMatcherFactoryTest.java | 40 +- .../StopLocationMatcherFactoryTest.java | 24 +- .../transit/TripMatcherFactoryTest.java | 111 ++- .../TripOnServiceDateMatcherFactoryTest.java | 149 ++-- .../model/framework/FeedScopedIdTest.java | 9 +- .../model/network/GroupOfRoutesTest.java | 3 +- .../transit/model/network/RouteTest.java | 9 +- .../model/network/TripPatternTest.java | 9 +- ...ultTransitGroupPriorityCalculatorTest.java | 3 +- .../network/grouppriority/MatchersTest.java | 12 +- .../TransitGroupPriorityServiceTest.java | 3 +- .../model/organization/AgencyTest.java | 3 +- .../model/organization/BrandingTest.java | 3 +- .../model/organization/ContactInfoTest.java | 3 +- .../model/organization/OperatorTest.java | 3 +- .../transit/model/site/AreaStopTest.java | 3 +- .../transit/model/site/BoardingAreaTest.java | 6 +- .../transit/model/site/EntranceTest.java | 3 +- .../transit/model/site/FareZoneTest.java | 3 +- .../model/site/GroupOfStationsTest.java | 8 +- .../transit/model/site/GroupStopTest.java | 43 +- .../model/site/MultiModalStationTest.java | 5 +- .../transit/model/site/PathwayNodeTest.java | 3 +- .../transit/model/site/PathwayTest.java | 6 +- .../transit/model/site/RegularStopTest.java | 3 +- .../transit/model/site/StationTest.java | 3 +- .../timetable/RealTimeTripTimesTest.java | 6 +- .../timetable/ScheduledTripTimesTest.java | 18 +- .../model/timetable/StopTimeKeyTest.java | 7 +- .../timetable/TripOnServiceDateTest.java | 5 +- .../transit/model/timetable/TripTest.java | 12 +- .../timetable/booking/BookingInfoTest.java | 9 +- .../booking/RoutingBookingInfoTest.java | 15 +- .../service/DefaultTransitServiceTest.java | 63 +- .../PatternByServiceDatesFilterTest.java | 14 +- .../transit/service/SiteRepositoryTest.java | 12 +- .../service/TimetableRepositoryTest.java | 12 +- .../transit/speed_test/ResultPrinter.java | 3 +- .../transit/speed_test/SpeedTest.java | 65 +- .../transit/speed_test/SpeedTestRequest.java | 3 +- .../transit/speed_test/TransferCacheTest.java | 17 +- .../speed_test/model/SpeedTestProfile.java | 6 +- .../model/testcase/CsvFileSupport.java | 11 +- .../model/testcase/TableTestReport.java | 3 +- .../model/timer/SpeedTestTimer.java | 3 +- .../support/AssertSpeedTestSetup.java | 2 +- .../GtfsRealtimeFuzzyTripMatcherTest.java | 24 +- .../alert/gtfs/AlertsUpdateHandlerTest.java | 114 +-- .../siri/SiriAlertsUpdateHandlerTest.java | 46 +- .../updater/trip/RealtimeTestConstants.java | 3 +- .../updater/trip/RealtimeTestEnvironment.java | 35 +- .../trip/RealtimeTestEnvironmentBuilder.java | 15 +- .../trip/TimetableSnapshotManagerTest.java | 9 +- .../updater/trip/TripUpdateBuilder.java | 9 +- .../GtfsRealTimeTripUpdateAdapterTest.java | 42 +- ...egacyTimetableSnapshotIntegrationTest.java | 120 ++- .../trip/gtfs/TripTimesUpdaterTest.java | 63 +- .../cancellation/CanceledTripTest.java | 6 +- .../CancellationDeletionTest.java | 6 +- .../gtfs/moduletests/delay/DelayedTest.java | 6 +- .../gtfs/moduletests/delay/SkippedTest.java | 3 +- .../rejection/InvalidInputTest.java | 3 +- .../trip/siri/AddedTripBuilderTest.java | 81 +- .../updater/trip/siri/EntityResolverTest.java | 3 +- .../trip/siri/ModifiedTripBuilderTest.java | 114 +-- .../updater/trip/siri/SiriEtBuilder.java | 3 +- .../trip/siri/SiriFuzzyTripMatcherTest.java | 3 +- .../trip/siri/TimetableHelperTest.java | 24 +- .../siri/moduletests/InterpolationTest.java | 3 +- .../cancellation/CancellationTest.java | 3 +- .../cancellation/CancelledStopTest.java | 3 +- .../extrajourney/ExtraJourneyTest.java | 3 +- .../fuzzymatching/FuzzyTripMatchingTest.java | 18 +- .../rejection/InvalidStopPointRefTest.java | 6 +- .../rejection/NegativeTimesTest.java | 6 +- .../rejection/NotMonitoredTest.java | 3 +- .../unsupported/UnsupportedTest.java | 3 +- .../moduletests/update/QuayChangeTest.java | 3 +- .../moduletests/update/UpdatedTimesTest.java | 18 +- ...VehicleParkingAvailabilityUpdaterTest.java | 38 +- .../VehicleParkingUpdaterTest.java | 39 +- .../RealtimeVehicleMatcherTest.java | 15 +- .../datasources/GbfsFeedLoaderTest.java | 17 +- .../opentripplanner/raptor/RaptorService.java | 8 +- .../raptor/api/debug/DebugEvent.java | 3 +- .../raptor/api/request/DebugRequest.java | 3 +- .../api/request/MultiCriteriaRequest.java | 6 +- .../raptor/api/request/RaptorRequest.java | 3 +- .../raptor/api/request/RaptorViaLocation.java | 13 +- .../raptor/api/request/SearchParams.java | 3 +- .../api/request/SearchParamsBuilder.java | 3 +- .../raptor/api/response/RaptorResponse.java | 3 +- .../raptor/configure/RaptorConfig.java | 6 +- .../org/opentripplanner/raptor/path/Path.java | 15 +- .../raptor/rangeraptor/CompositeResult.java | 6 +- .../ConcurrentCompositeRaptorRouter.java | 12 +- .../rangeraptor/SystemErrDebugLogger.java | 6 +- .../rangeraptor/context/SearchContext.java | 11 +- .../debug/DebugHandlerFactory.java | 25 +- .../internalapi/HeuristicAtStop.java | 6 +- .../lifecycle/LifeCycleEventPublisher.java | 15 +- .../multicriteria/McStopArrivals.java | 28 +- .../MultiCriteriaRoutingStrategy.java | 5 +- ...ViaConnectionStopArrivalEventListener.java | 6 +- .../ArrivalParetoSetComparatorFactory.java | 35 +- .../configure/McRangeRaptorConfig.java | 41 +- .../multicriteria/ride/c1/PatternRideC1.java | 9 +- .../multicriteria/ride/c2/PatternRideC2.java | 11 +- .../path/DestinationArrivalPaths.java | 6 +- .../path/PathParetoSetComparators.java | 90 +-- .../standard/besttimes/BestTimes.java | 3 +- .../configure/StdRangeRaptorConfig.java | 34 +- .../debug/DebugStopArrivalsState.java | 12 +- .../heuristics/HeuristicsAdapter.java | 26 +- .../stoparrivals/EgressStopArrivalState.java | 3 +- .../stoparrivals/StdStopArrivals.java | 21 +- .../path/EgressArrivalToPathAdapter.java | 3 +- .../transit/AccessEgressFunctions.java | 6 +- .../ForwardRaptorTransitCalculator.java | 7 +- .../transit/RaptorSearchWindowCalculator.java | 6 +- .../ReverseRaptorTransitCalculator.java | 8 +- .../transit/TripScheduleExactMatchSearch.java | 3 +- .../service/RangeRaptorDynamicSearch.java | 18 +- .../raptor/spi/ExtraMcRouterSearch.java | 6 +- .../raptor/util/CompareIntArrays.java | 30 +- .../raptor/util/composite/CompositeUtil.java | 3 +- .../raptor/RaptorArchitectureTest.java | 133 ++- .../raptor/_data/api/TestPathBuilder.java | 20 +- .../ride/TestPatterRideBuilder.java | 9 +- ...AndEgressWithOpeningHoursPathTestCase.java | 10 +- .../_data/stoparrival/BasicPathTestCase.java | 15 +- .../TestConstrainedBoardingSearch.java | 6 +- .../transit/TestConstrainedTransfer.java | 3 +- .../raptor/_data/transit/TestRoute.java | 19 +- .../raptor/_data/transit/TestTripPattern.java | 3 +- .../_data/transit/TestTripSchedule.java | 9 +- .../_data/transit/TestTripScheduleSearch.java | 3 +- .../AbstractAccessEgressDecoratorTest.java | 12 +- .../GeneralizedCostRelaxFunctionTest.java | 20 +- .../raptor/api/path/PathTest.java | 12 +- .../api/request/MultiCriteriaRequestTest.java | 3 +- .../raptor/api/request/RaptorRequestTest.java | 3 +- .../api/request/RaptorViaLocationTest.java | 23 +- .../raptor/api/request/SearchParamsTest.java | 28 +- .../api/view/BoardAndAlightTimeTest.java | 3 +- .../moduletests/A01_SingleRouteTest.java | 6 +- .../raptor/moduletests/A04_BoardingTest.java | 11 +- .../raptor/moduletests/B01_AccessTest.java | 11 +- .../raptor/moduletests/B02_EgressTest.java | 11 +- .../moduletests/B03_AccessEgressTest.java | 11 +- .../B04_AccessEgressBoardingTest.java | 11 +- ...EgressStopBoardAlightTransferCostTest.java | 6 +- .../C01_TransferBoardAndAlightSlackTest.java | 20 +- .../C02_OnStreetTransfersTest.java | 20 +- ...3_OnBoardArrivalDominateTransfersTest.java | 6 +- ...SingeRouteBoardAlightRestrictionsTest.java | 9 +- .../E01_StaySeatedTransferTest.java | 6 +- .../E02_GuaranteedWalkTransferTest.java | 6 +- ...E03_NotAllowedConstrainedTransferTest.java | 21 +- .../moduletests/F01_AccessWithRidesTest.java | 11 +- .../moduletests/F02_EgressWithRidesTest.java | 11 +- ...gressWithRidesBoardAndAlightSlackTest.java | 29 +- ...04_AccessEgressWithRidesNoTransitTest.java | 18 +- ...5_OnBoardAccessEgressAndTransfersTest.java | 6 +- ...cessWithRidesMultipleOptimalPathsTest.java | 9 +- ...ressWithRidesMultipleOptimalPathsTest.java | 9 +- .../G01_AccessWithOpeningHoursTest.java | 30 +- .../G02_EgressWithOpeningHoursTest.java | 37 +- ...ssWithOpeningHoursMultipleOptionsTest.java | 6 +- ...ssWithOpeningHoursMultipleOptionsTest.java | 6 +- .../G05_ClosedAccessOpeningHoursTest.java | 6 +- .../G06_ClosedEgressOpeningHoursTest.java | 6 +- ..._GuaranteedTransferWithFlexAccessTest.java | 6 +- .../raptor/moduletests/I01_HeuristicTest.java | 3 +- .../moduletests/J01_PassThroughTest.java | 20 +- .../moduletests/J02_ViaStopSearchTest.java | 58 +- .../J03_ViaTransferSearchTest.java | 51 +- .../moduletests/K01_TransitPriorityTest.java | 23 +- .../K02_TransitPriorityDestinationTest.java | 23 +- .../L01_TimePenaltyAccessTest.java | 12 +- .../L01_TimePenaltyEgressTest.java | 12 +- .../support/RaptorModuleTestCaseFactory.java | 6 +- .../support/TestGroupPriorityCalculator.java | 3 +- .../context/SearchContextTest.java | 3 +- .../NoopPassThroughPointsServiceTest.java | 5 +- .../StopArrivalStateParetoSetTest.java | 27 +- ...ArrivalParetoSetComparatorFactoryTest.java | 12 +- .../arrivals/c1/AccessStopArrivalTest.java | 7 +- .../arrivals/c1/StopArrivalFactoryC1Test.java | 3 +- .../arrivals/c1/TransferStopArrivalTest.java | 23 +- .../arrivals/c1/TransitStopArrivalTest.java | 9 +- .../arrivals/c2/AccessStopArrivalC2Test.java | 7 +- .../arrivals/c2/StopArrivalFactoryC2Test.java | 3 +- .../c2/TransferStopArrivalC2Test.java | 25 +- .../arrivals/c2/TransitStopArrivalC2Test.java | 9 +- .../BitSetPassThroughPointsServiceTest.java | 28 +- .../path/DestinationArrivalTest.java | 24 +- .../transit/AccessEgressFunctionsTest.java | 16 +- .../rangeraptor/transit/AccessPathsTest.java | 13 +- .../RaptorSearchWindowCalculatorTest.java | 4 +- .../TripScheduleExactMatchSearchTest.java | 9 +- .../transit/TripTimesSearchTest.java | 22 +- .../raptor/spi/RaptorTripScheduleTest.java | 5 +- .../paretoset/ParetoSetEventListenerTest.java | 4 +- .../raptor/util/paretoset/ParetoSetTest.java | 20 +- .../paretoset/ParetoSetWithMarkerTest.java | 7 +- .../utils/lang/StringUtils.java | 3 +- .../utils/logging/ProgressTracker.java | 2 +- .../utils/time/DurationUtils.java | 3 +- .../utils/time/RelativeTime.java | 3 +- .../utils/tostring/ToStringBuilder.java | 12 +- .../utils/lang/IntUtilsTest.java | 22 +- .../lang/MemEfficientArrayBuilderTest.java | 3 +- .../utils/lang/ObjectUtilsTest.java | 13 +- .../utils/lang/StringUtilsTest.java | 5 +- .../opentripplanner/utils/text/TableTest.java | 41 +- .../text/TextVariablesSubstitutionTest.java | 5 +- .../utils/time/DurationUtilsTest.java | 43 +- .../utils/time/OffsetDateTimeParserTest.java | 9 +- .../MultiLineToStringBuilderTest.java | 22 +- .../utils/tostring/ToStringBuilderTest.java | 16 +- 1203 files changed, 10888 insertions(+), 13426 deletions(-) diff --git a/application/src/ext-test/java/org/opentripplanner/ext/accessibilityscore/DecorateWithAccessibilityScoreTest.java b/application/src/ext-test/java/org/opentripplanner/ext/accessibilityscore/DecorateWithAccessibilityScoreTest.java index 27c10c08129..01237ddda87 100644 --- a/application/src/ext-test/java/org/opentripplanner/ext/accessibilityscore/DecorateWithAccessibilityScoreTest.java +++ b/application/src/ext-test/java/org/opentripplanner/ext/accessibilityscore/DecorateWithAccessibilityScoreTest.java @@ -19,9 +19,8 @@ class DecorateWithAccessibilityScoreTest implements PlanTestConstants { private static final int ID = 1; - private static final DecorateWithAccessibilityScore DECORATOR = new DecorateWithAccessibilityScore( - WheelchairPreferences.DEFAULT.maxSlope() - ); + private static final DecorateWithAccessibilityScore DECORATOR = + new DecorateWithAccessibilityScore(WheelchairPreferences.DEFAULT.maxSlope()); static List accessibilityScoreTestCase() { return List.of( diff --git a/application/src/ext-test/java/org/opentripplanner/ext/emissions/EmissionsModuleTest.java b/application/src/ext-test/java/org/opentripplanner/ext/emissions/EmissionsModuleTest.java index e45e83a020d..6e36193e12b 100644 --- a/application/src/ext-test/java/org/opentripplanner/ext/emissions/EmissionsModuleTest.java +++ b/application/src/ext-test/java/org/opentripplanner/ext/emissions/EmissionsModuleTest.java @@ -37,7 +37,8 @@ public class EmissionsModuleTest { void testMultipleGtfsDataReading() { inputData.put(GTFS, new FileDataSource(CO2_GTFS_ZIP, GTFS)); inputData.put(GTFS, new FileDataSource(CO2_GTFS, GTFS)); - Iterable> configuredDataSource = getGtfsConfiguredDatasource(); + Iterable> configuredDataSource = + getGtfsConfiguredDatasource(); EmissionsDataModel emissionsDataModel = new EmissionsDataModel(); EmissionsModule emissionsModule = new EmissionsModule( configuredDataSource, diff --git a/application/src/ext-test/java/org/opentripplanner/ext/emissions/EmissionsTest.java b/application/src/ext-test/java/org/opentripplanner/ext/emissions/EmissionsTest.java index aa5bb4f8c2c..c56d1c5a3e5 100644 --- a/application/src/ext-test/java/org/opentripplanner/ext/emissions/EmissionsTest.java +++ b/application/src/ext-test/java/org/opentripplanner/ext/emissions/EmissionsTest.java @@ -35,27 +35,26 @@ class EmissionsTest { private static DefaultEmissionsService eService; private static DecorateWithEmission decorateWithEmission; - static final ZonedDateTime TIME = OffsetDateTime - .parse("2023-07-20T17:49:06+03:00") - .toZonedDateTime(); + static final ZonedDateTime TIME = OffsetDateTime.parse( + "2023-07-20T17:49:06+03:00" + ).toZonedDateTime(); - private static final StreetLeg STREET_LEG = StreetLeg - .create() + private static final StreetLeg STREET_LEG = StreetLeg.create() .withMode(TraverseMode.CAR) .withDistanceMeters(214.4) .withStartTime(TIME) .withEndTime(TIME.plusHours(1)) .build(); - private static final Route ROUTE_WITH_EMISSIONS = TimetableRepositoryForTest - .route(id("1")) - .build(); - private static final Route ROUTE_WITH_ZERO_EMISSIONS = TimetableRepositoryForTest - .route(id("2")) - .build(); - private static final Route ROUTE_WITHOUT_EMISSIONS_CONFIGURED = TimetableRepositoryForTest - .route(id("3")) - .build(); + private static final Route ROUTE_WITH_EMISSIONS = TimetableRepositoryForTest.route( + id("1") + ).build(); + private static final Route ROUTE_WITH_ZERO_EMISSIONS = TimetableRepositoryForTest.route( + id("2") + ).build(); + private static final Route ROUTE_WITHOUT_EMISSIONS_CONFIGURED = TimetableRepositoryForTest.route( + id("3") + ).build(); @BeforeAll static void SetUp() { @@ -129,12 +128,10 @@ private ScheduledTransitLeg createTransitLeg(Route route) { var stopTwo = testModel.stop("1:stop1", 61, 25).build(); var stopThree = testModel.stop("1:stop1", 62, 25).build(); var stopPattern = TimetableRepositoryForTest.stopPattern(stopOne, stopTwo, stopThree); - var pattern = TimetableRepositoryForTest - .tripPattern("1", route) + var pattern = TimetableRepositoryForTest.tripPattern("1", route) .withStopPattern(stopPattern) .build(); - var trip = Trip - .of(FeedScopedId.parse("FOO:BAR")) + var trip = Trip.of(FeedScopedId.parse("FOO:BAR")) .withMode(TransitMode.BUS) .withRoute(route) .build(); diff --git a/application/src/ext-test/java/org/opentripplanner/ext/fares/FareRuleSetTest.java b/application/src/ext-test/java/org/opentripplanner/ext/fares/FareRuleSetTest.java index 13d4f713634..4e6b2dde3e5 100644 --- a/application/src/ext-test/java/org/opentripplanner/ext/fares/FareRuleSetTest.java +++ b/application/src/ext-test/java/org/opentripplanner/ext/fares/FareRuleSetTest.java @@ -20,8 +20,7 @@ class FareRuleSetTest { @BeforeEach void setUp() { FeedScopedId id = new FeedScopedId("feed", "fare1"); - FareAttribute fareAttribute = FareAttribute - .of(id) + FareAttribute fareAttribute = FareAttribute.of(id) .setPrice(TWO_FIFTY) .setPaymentMethod(1) .setTransfers(1) @@ -175,8 +174,7 @@ void testMatchesWithTransferDuration() { @Test void testMatchesWithJourneyDuration() { - FareAttribute journeyFare = FareAttribute - .of(new FeedScopedId("feed", "journey")) + FareAttribute journeyFare = FareAttribute.of(new FeedScopedId("feed", "journey")) .setPrice(Money.usDollars(3.00f)) .setPaymentMethod(1) .setJourneyDuration(7200) diff --git a/application/src/ext-test/java/org/opentripplanner/ext/fares/impl/AtlantaFareServiceTest.java b/application/src/ext-test/java/org/opentripplanner/ext/fares/impl/AtlantaFareServiceTest.java index 177a74a58db..3707b6cafdd 100644 --- a/application/src/ext-test/java/org/opentripplanner/ext/fares/impl/AtlantaFareServiceTest.java +++ b/application/src/ext-test/java/org/opentripplanner/ext/fares/impl/AtlantaFareServiceTest.java @@ -95,12 +95,11 @@ void fromCobbTransfers() { calculateFare(rides, DEFAULT_TEST_RIDE_PRICE.plus(DEFAULT_TEST_RIDE_PRICE).plus(usDollars(3))); // Local to circulator to express - rides = - List.of( - getLeg(COBB_AGENCY_ID, 0), - getLeg(COBB_AGENCY_ID, "BLUE", 1), - getLeg(COBB_AGENCY_ID, "101", 1) - ); + rides = List.of( + getLeg(COBB_AGENCY_ID, 0), + getLeg(COBB_AGENCY_ID, "BLUE", 1), + getLeg(COBB_AGENCY_ID, "101", 1) + ); calculateFare(rides, DEFAULT_TEST_RIDE_PRICE.plus(usDollars(1))); } @@ -122,45 +121,41 @@ void tooManyLegs() { ); calculateFare(rides, DEFAULT_TEST_RIDE_PRICE.plus(DEFAULT_TEST_RIDE_PRICE)); - rides = - List.of( - getLeg(MARTA_AGENCY_ID, 0), - getLeg(MARTA_AGENCY_ID, 1), - getLeg(GCT_AGENCY_ID, 2), - getLeg(GCT_AGENCY_ID, 3), - getLeg(MARTA_AGENCY_ID, 4), - getLeg(COBB_AGENCY_ID, 5) - ); + rides = List.of( + getLeg(MARTA_AGENCY_ID, 0), + getLeg(MARTA_AGENCY_ID, 1), + getLeg(GCT_AGENCY_ID, 2), + getLeg(GCT_AGENCY_ID, 3), + getLeg(MARTA_AGENCY_ID, 4), + getLeg(COBB_AGENCY_ID, 5) + ); calculateFare(rides, DEFAULT_TEST_RIDE_PRICE.plus(DEFAULT_TEST_RIDE_PRICE)); - rides = - List.of( - getLeg(GCT_AGENCY_ID, 0), - getLeg(MARTA_AGENCY_ID, 1), - getLeg(MARTA_AGENCY_ID, 2), - getLeg(MARTA_AGENCY_ID, 3) - ); + rides = List.of( + getLeg(GCT_AGENCY_ID, 0), + getLeg(MARTA_AGENCY_ID, 1), + getLeg(MARTA_AGENCY_ID, 2), + getLeg(MARTA_AGENCY_ID, 3) + ); calculateFare(rides, DEFAULT_TEST_RIDE_PRICE); - rides = - List.of( - getLeg(GCT_AGENCY_ID, 0), - getLeg(MARTA_AGENCY_ID, 1), - getLeg(MARTA_AGENCY_ID, 2), - getLeg(MARTA_AGENCY_ID, 3), - // new transfer - only got 3 from GCT - getLeg(MARTA_AGENCY_ID, 4) - ); + rides = List.of( + getLeg(GCT_AGENCY_ID, 0), + getLeg(MARTA_AGENCY_ID, 1), + getLeg(MARTA_AGENCY_ID, 2), + getLeg(MARTA_AGENCY_ID, 3), + // new transfer - only got 3 from GCT + getLeg(MARTA_AGENCY_ID, 4) + ); calculateFare(rides, DEFAULT_TEST_RIDE_PRICE.plus(DEFAULT_TEST_RIDE_PRICE)); - rides = - List.of( - getLeg(MARTA_AGENCY_ID, 0), - getLeg(MARTA_AGENCY_ID, 1), - getLeg(MARTA_AGENCY_ID, 2), - getLeg(GCT_AGENCY_ID, 3), - getLeg(GCT_AGENCY_ID, 4) - ); + rides = List.of( + getLeg(MARTA_AGENCY_ID, 0), + getLeg(MARTA_AGENCY_ID, 1), + getLeg(MARTA_AGENCY_ID, 2), + getLeg(GCT_AGENCY_ID, 3), + getLeg(GCT_AGENCY_ID, 4) + ); calculateFare(rides, DEFAULT_TEST_RIDE_PRICE); } @@ -174,14 +169,13 @@ void expiredTransfer() { ); calculateFare(rides, DEFAULT_TEST_RIDE_PRICE.plus(DEFAULT_TEST_RIDE_PRICE)); - rides = - List.of( - getLeg(MARTA_AGENCY_ID, 0), - getLeg(GCT_AGENCY_ID, 1), - getLeg(GCT_AGENCY_ID, 181), - getLeg(MARTA_AGENCY_ID, 181 + 178), - getLeg(MARTA_AGENCY_ID, 181 + 179) - ); + rides = List.of( + getLeg(MARTA_AGENCY_ID, 0), + getLeg(GCT_AGENCY_ID, 1), + getLeg(GCT_AGENCY_ID, 181), + getLeg(MARTA_AGENCY_ID, 181 + 178), + getLeg(MARTA_AGENCY_ID, 181 + 179) + ); calculateFare(rides, DEFAULT_TEST_RIDE_PRICE.plus(DEFAULT_TEST_RIDE_PRICE)); } @@ -197,12 +191,11 @@ void useStreetcar() { ); calculateFare(rides, DEFAULT_TEST_RIDE_PRICE.plus(STREETCAR_PRICE)); - rides = - List.of( - getLeg(COBB_AGENCY_ID, 0), - getLeg(MARTA_AGENCY_ID, "atlsc", 1), - getLeg(COBB_AGENCY_ID, "101", 2) - ); + rides = List.of( + getLeg(COBB_AGENCY_ID, 0), + getLeg(MARTA_AGENCY_ID, "atlsc", 1), + getLeg(COBB_AGENCY_ID, "101", 2) + ); calculateFare(rides, DEFAULT_TEST_RIDE_PRICE.plus(usDollars(1)).plus(STREETCAR_PRICE)); } @@ -263,8 +256,7 @@ private static Leg createLeg(String agencyId, String shortName, long startTimeMi private static Itinerary createItinerary(String agencyId, String shortName, long startTimeMins) { var siteRepositoryBuilder = SiteRepository.of(); - Agency agency = Agency - .of(new FeedScopedId(FEED_ID, agencyId)) + Agency agency = Agency.of(new FeedScopedId(FEED_ID, agencyId)) .withName(agencyId) .withTimezone(ZoneIds.NEW_YORK.getId()) .build(); @@ -282,8 +274,7 @@ private static Itinerary createItinerary(String agencyId, String shortName, long .build(); FeedScopedId routeFeedScopeId = new FeedScopedId(FEED_ID, "123"); - Route route = Route - .of(routeFeedScopeId) + Route route = Route.of(routeFeedScopeId) .withAgency(agency) .withShortName(shortName) .withLongName(new NonLocalizedString("123")) diff --git a/application/src/ext-test/java/org/opentripplanner/ext/fares/impl/DefaultFareServiceTest.java b/application/src/ext-test/java/org/opentripplanner/ext/fares/impl/DefaultFareServiceTest.java index 788c1c9b6d6..ce03fd0c302 100644 --- a/application/src/ext-test/java/org/opentripplanner/ext/fares/impl/DefaultFareServiceTest.java +++ b/application/src/ext-test/java/org/opentripplanner/ext/fares/impl/DefaultFareServiceTest.java @@ -30,12 +30,16 @@ class DefaultFareServiceTest implements PlanTestConstants { private static final Money TEN_DOLLARS = Money.usDollars(10); - private static final FareProduct OTHER_FEED_PRODUCT = FareProduct - .of(OTHER_FEED_ATTRIBUTE.getId(), "regular", TEN_DOLLARS) - .build(); - private static final FareProduct AIRPORT_TO_CITY_CENTER_PRODUCT = FareProduct - .of(AIRPORT_TO_CITY_CENTER_SET.getFareAttribute().getId(), "regular", TEN_DOLLARS) - .build(); + private static final FareProduct OTHER_FEED_PRODUCT = FareProduct.of( + OTHER_FEED_ATTRIBUTE.getId(), + "regular", + TEN_DOLLARS + ).build(); + private static final FareProduct AIRPORT_TO_CITY_CENTER_PRODUCT = FareProduct.of( + AIRPORT_TO_CITY_CENTER_SET.getFareAttribute().getId(), + "regular", + TEN_DOLLARS + ).build(); @Test void noRules() { @@ -92,13 +96,11 @@ void applyToSeveralLegs() { List.of( new FareProductUse( "ddbf1572-18bc-3724-8b64-e1c7d5c8b6c6", - FareProduct - .of( - FREE_TRANSFERS_IN_CITY_SET.getFareAttribute().getId(), - "regular", - TEN_DOLLARS.plus(TEN_DOLLARS) - ) - .build() + FareProduct.of( + FREE_TRANSFERS_IN_CITY_SET.getFareAttribute().getId(), + "regular", + TEN_DOLLARS.plus(TEN_DOLLARS) + ).build() ) ), firstProducts diff --git a/application/src/ext-test/java/org/opentripplanner/ext/fares/impl/FareModelForTest.java b/application/src/ext-test/java/org/opentripplanner/ext/fares/impl/FareModelForTest.java index 9f4265c5443..03917f20369 100644 --- a/application/src/ext-test/java/org/opentripplanner/ext/fares/impl/FareModelForTest.java +++ b/application/src/ext-test/java/org/opentripplanner/ext/fares/impl/FareModelForTest.java @@ -24,63 +24,64 @@ public class FareModelForTest { public static final FareZone AIRPORT_ZONE = FareZone.of(id("airport-zone")).build(); public static final FareZone CITY_CENTER_ZONE = FareZone.of(id("city-center")).build(); - public static final FareZone OTHER_FEED_ZONE = FareZone - .of(FeedScopedId.ofNullable("F2", "other-feed-zone")) - .build(); + public static final FareZone OTHER_FEED_ZONE = FareZone.of( + FeedScopedId.ofNullable("F2", "other-feed-zone") + ).build(); private static final SiteRepositoryBuilder SITE_REPOSITORY_BUILDER = SiteRepository.of(); - static final RegularStop AIRPORT_STOP = SITE_REPOSITORY_BUILDER - .regularStop(id("airport")) + static final RegularStop AIRPORT_STOP = SITE_REPOSITORY_BUILDER.regularStop(id("airport")) .withCoordinate(new WgsCoordinate(1, 1)) .addFareZones(AIRPORT_ZONE) .withName(I18NString.of("Airport")) .build(); - static final RegularStop CITY_CENTER_A_STOP = SITE_REPOSITORY_BUILDER - .regularStop(id("city-center-a")) + static final RegularStop CITY_CENTER_A_STOP = SITE_REPOSITORY_BUILDER.regularStop( + id("city-center-a") + ) .withCoordinate(new WgsCoordinate(1, 2)) .addFareZones(CITY_CENTER_ZONE) .withName(I18NString.of("City center: stop A")) .build(); - static final RegularStop CITY_CENTER_B_STOP = SITE_REPOSITORY_BUILDER - .regularStop(id("city-center-b")) + static final RegularStop CITY_CENTER_B_STOP = SITE_REPOSITORY_BUILDER.regularStop( + id("city-center-b") + ) .withCoordinate(new WgsCoordinate(1, 3)) .addFareZones(CITY_CENTER_ZONE) .withName(I18NString.of("City center: stop B")) .build(); - static final RegularStop CITY_CENTER_C_STOP = SITE_REPOSITORY_BUILDER - .regularStop(id("city-center-c")) + static final RegularStop CITY_CENTER_C_STOP = SITE_REPOSITORY_BUILDER.regularStop( + id("city-center-c") + ) .withCoordinate(new WgsCoordinate(1, 4)) .addFareZones(CITY_CENTER_ZONE) .withName(I18NString.of("City center: stop C")) .build(); - static final RegularStop SUBURB_STOP = SITE_REPOSITORY_BUILDER - .regularStop(id("suburb")) + static final RegularStop SUBURB_STOP = SITE_REPOSITORY_BUILDER.regularStop(id("suburb")) .withCoordinate(new WgsCoordinate(1, 4)) .withName(I18NString.of("Suburb")) .build(); - static final RegularStop OTHER_FEED_STOP = SITE_REPOSITORY_BUILDER - .regularStop(FeedScopedId.ofNullable("F2", "other-feed-stop")) + static final RegularStop OTHER_FEED_STOP = SITE_REPOSITORY_BUILDER.regularStop( + FeedScopedId.ofNullable("F2", "other-feed-stop") + ) .withCoordinate(new WgsCoordinate(1, 5)) .withName(I18NString.of("Other feed stop")) .addFareZones(OTHER_FEED_ZONE) .build(); - static final FareAttribute TEN_DOLLARS = FareAttribute - .of(id("airport-to-city-center")) + static final FareAttribute TEN_DOLLARS = FareAttribute.of(id("airport-to-city-center")) .setPrice(Money.usDollars(10)) .setTransfers(0) .build(); - static final FareAttribute FREE_TRANSFERS = FareAttribute - .of(id("free-transfers")) + static final FareAttribute FREE_TRANSFERS = FareAttribute.of(id("free-transfers")) .setPrice(Money.usDollars(20)) .setTransfers(10) .build(); - static final FareAttribute OTHER_FEED_ATTRIBUTE = FareAttribute - .of(FeedScopedId.ofNullable("F2", "other-feed-attribute")) + static final FareAttribute OTHER_FEED_ATTRIBUTE = FareAttribute.of( + FeedScopedId.ofNullable("F2", "other-feed-attribute") + ) .setPrice(Money.usDollars(10)) .setTransfers(1) .setAgency(OTHER_FEED_AGENCY.getId()) @@ -124,8 +125,7 @@ public class FareModelForTest { ); } - static Route OTHER_FEED_ROUTE = Route - .of(new FeedScopedId("F2", "other-feed-route")) + static Route OTHER_FEED_ROUTE = Route.of(new FeedScopedId("F2", "other-feed-route")) .withAgency(OTHER_FEED_AGENCY) .withLongName(I18NString.of("other-feed-route")) .withMode(TransitMode.BUS) diff --git a/application/src/ext-test/java/org/opentripplanner/ext/fares/impl/FaresIntegrationTest.java b/application/src/ext-test/java/org/opentripplanner/ext/fares/impl/FaresIntegrationTest.java index f5ad2b471ab..2b006fcabb5 100644 --- a/application/src/ext-test/java/org/opentripplanner/ext/fares/impl/FaresIntegrationTest.java +++ b/application/src/ext-test/java/org/opentripplanner/ext/fares/impl/FaresIntegrationTest.java @@ -36,8 +36,7 @@ public void testBasic() { var serverContext = TestServerContext.createServerContext(graph, timetableRepository); - var start = LocalDateTime - .of(2009, Month.AUGUST, 7, 12, 0, 0) + var start = LocalDateTime.of(2009, Month.AUGUST, 7, 12, 0, 0) .atZone(ZoneIds.LOS_ANGELES) .toInstant(); var from = GenericLocation.fromStopId("Origin", feedId, "Millbrae Caltrain"); @@ -70,8 +69,7 @@ public void testPortland() { "8371" ); - Instant startTime = LocalDateTime - .of(2009, 11, 1, 12, 0, 0) + Instant startTime = LocalDateTime.of(2009, 11, 1, 12, 0, 0) .atZone(ZoneId.of("America/Los_Angeles")) .toInstant(); @@ -85,8 +83,9 @@ public void testPortland() { // long trip - startTime = - LocalDateTime.of(2009, 11, 2, 14, 0, 0).atZone(ZoneId.of("America/Los_Angeles")).toInstant(); + startTime = LocalDateTime.of(2009, 11, 2, 14, 0, 0) + .atZone(ZoneId.of("America/Los_Angeles")) + .toInstant(); from = GenericLocation.fromStopId("Origin", portlandId, "8389"); to = GenericLocation.fromStopId("Destination", portlandId, "1252"); diff --git a/application/src/ext-test/java/org/opentripplanner/ext/fares/impl/GtfsFaresV2ServiceTest.java b/application/src/ext-test/java/org/opentripplanner/ext/fares/impl/GtfsFaresV2ServiceTest.java index 47875c65801..110b0e92ba4 100644 --- a/application/src/ext-test/java/org/opentripplanner/ext/fares/impl/GtfsFaresV2ServiceTest.java +++ b/application/src/ext-test/java/org/opentripplanner/ext/fares/impl/GtfsFaresV2ServiceTest.java @@ -39,45 +39,59 @@ class GtfsFaresV2ServiceTest implements PlanTestConstants { String expressNetwork = "express"; String localNetwork = "local"; - FareProduct single = FareProduct - .of(new FeedScopedId(FEED_ID, "single"), "Single one-way ticket", Money.euros(1)) - .build(); - FareProduct singleToOuter = FareProduct - .of( - new FeedScopedId(FEED_ID, "single_to_outer"), - "Single one-way ticket to outer zone", - Money.euros(1) - ) - .build(); - FareProduct singleFromOuter = FareProduct - .of( - new FeedScopedId(FEED_ID, "single_from_outer"), - "Single one-way ticket from outer zone to anywhere", - Money.euros(1) - ) - .build(); - FareProduct dayPass = FareProduct - .of(new FeedScopedId(FEED_ID, "day_pass"), "Day Pass", Money.euros(5)) + FareProduct single = FareProduct.of( + new FeedScopedId(FEED_ID, "single"), + "Single one-way ticket", + Money.euros(1) + ).build(); + FareProduct singleToOuter = FareProduct.of( + new FeedScopedId(FEED_ID, "single_to_outer"), + "Single one-way ticket to outer zone", + Money.euros(1) + ).build(); + FareProduct singleFromOuter = FareProduct.of( + new FeedScopedId(FEED_ID, "single_from_outer"), + "Single one-way ticket from outer zone to anywhere", + Money.euros(1) + ).build(); + FareProduct dayPass = FareProduct.of( + new FeedScopedId(FEED_ID, "day_pass"), + "Day Pass", + Money.euros(5) + ) .withValidity(Duration.ofDays(1)) .build(); - FareProduct innerToOuterZoneSingle = FareProduct - .of(new FeedScopedId(FEED_ID, "zone_ab_single"), "Day Pass", Money.euros(5)) - .build(); - FareProduct monthlyPass = FareProduct - .of(new FeedScopedId("another", "monthly_pass"), "Monthly Pass", Money.euros(30)) + FareProduct innerToOuterZoneSingle = FareProduct.of( + new FeedScopedId(FEED_ID, "zone_ab_single"), + "Day Pass", + Money.euros(5) + ).build(); + FareProduct monthlyPass = FareProduct.of( + new FeedScopedId("another", "monthly_pass"), + "Monthly Pass", + Money.euros(30) + ) .withValidity(Duration.ofDays(30)) .build(); - FareProduct expressPass = FareProduct - .of(new FeedScopedId(FEED_ID, "express_pass"), "Express Pass", Money.euros(50)) + FareProduct expressPass = FareProduct.of( + new FeedScopedId(FEED_ID, "express_pass"), + "Express Pass", + Money.euros(50) + ) .withValidity(Duration.ofDays(1)) .build(); - FareProduct localPass = FareProduct - .of(new FeedScopedId(FEED_ID, "local_pass"), "Local Pass", Money.euros(20)) + FareProduct localPass = FareProduct.of( + new FeedScopedId(FEED_ID, "local_pass"), + "Local Pass", + Money.euros(20) + ) .withValidity(Duration.ofDays(1)) .build(); - FareProduct freeTransfer = FareProduct - .of(new FeedScopedId(FEED_ID, "free_transfer"), "Free transfer", Money.euros(0)) - .build(); + FareProduct freeTransfer = FareProduct.of( + new FeedScopedId(FEED_ID, "free_transfer"), + "Free transfer", + Money.euros(0) + ).build(); Place INNER_ZONE_STOP = Place.forStop( testModel.stop("inner city stop").withCoordinate(1, 1).build() @@ -91,29 +105,24 @@ class GtfsFaresV2ServiceTest implements PlanTestConstants { GtfsFaresV2Service service = new GtfsFaresV2Service( List.of( FareLegRule.of(id("1"), single).withLegGroupId(LEG_GROUP1).build(), - FareLegRule - .of(id("2"), singleToOuter) + FareLegRule.of(id("2"), singleToOuter) .withLegGroupId(LEG_GROUP1) .withToAreaId(OUTER_ZONE) .build(), - FareLegRule - .of(id("3"), singleFromOuter) + FareLegRule.of(id("3"), singleFromOuter) .withLegGroupId(LEG_GROUP1) .withFromAreaId(OUTER_ZONE) .build(), FareLegRule.of(id("4"), dayPass).withLegGroupId(LEG_GROUP1).build(), - FareLegRule - .of(id("5"), expressPass) + FareLegRule.of(id("5"), expressPass) .withLegGroupId(LEG_GROUP1) .withNetworkId(expressNetwork) .build(), - FareLegRule - .of(id("5"), localPass) + FareLegRule.of(id("5"), localPass) .withLegGroupId(LEG_GROUP1) .withNetworkId(localNetwork) .build(), - FareLegRule - .of(id("6"), innerToOuterZoneSingle) + FareLegRule.of(id("6"), innerToOuterZoneSingle) .withLegGroupId(LEG_GROUP1) .withFromAreaId(INNER_ZONE) .withToAreaId(OUTER_ZONE) @@ -214,39 +223,32 @@ void onlyFromAreaId() { class Transfers { FeedScopedId TRANSFER_ID = id("transfer"); - FareProduct freeTransferFromInnerToOuter = FareProduct - .of( - new FeedScopedId(FEED_ID, "free-transfer-from-inner-to-outer"), - "Single ticket with free transfer from the inner to the outer zone", - Money.euros(50) - ) - .build(); - - FareProduct freeTransferSingle = FareProduct - .of( - new FeedScopedId(FEED_ID, "free-transfer-from-anywhere-to-outer"), - "Single ticket with free transfer any zone", - Money.euros(10) - ) - .build(); + FareProduct freeTransferFromInnerToOuter = FareProduct.of( + new FeedScopedId(FEED_ID, "free-transfer-from-inner-to-outer"), + "Single ticket with free transfer from the inner to the outer zone", + Money.euros(50) + ).build(); + + FareProduct freeTransferSingle = FareProduct.of( + new FeedScopedId(FEED_ID, "free-transfer-from-anywhere-to-outer"), + "Single ticket with free transfer any zone", + Money.euros(10) + ).build(); GtfsFaresV2Service service = new GtfsFaresV2Service( List.of( - FareLegRule - .of(id("6"), freeTransferFromInnerToOuter) + FareLegRule.of(id("6"), freeTransferFromInnerToOuter) .withLegGroupId(LEG_GROUP2) .withFromAreaId(INNER_ZONE) .withToAreaId(INNER_ZONE) .build(), - FareLegRule - .of(id("7"), single) + FareLegRule.of(id("7"), single) .withLegGroupId(LEG_GROUP3) .withFromAreaId(OUTER_ZONE) .withToAreaId(OUTER_ZONE) .build(), FareLegRule.of(id("8"), freeTransferSingle).withLegGroupId(LEG_GROUP4).build(), - FareLegRule - .of(id("9"), singleToOuter) + FareLegRule.of(id("9"), singleToOuter) .withLegGroupId(LEG_GROUP5) .withFromAreaId(INNER_ZONE) .withToAreaId(OUTER_ZONE) @@ -287,50 +289,64 @@ void freeTransferIntoAnotherGroup() { class DistanceFares { FeedScopedId DISTANCE_ID = id("distance"); - FareProduct threeStopProduct = FareProduct - .of(new FeedScopedId(FEED_ID, "three-stop-product"), "three-stop-product", Money.euros(1)) + FareProduct threeStopProduct = FareProduct.of( + new FeedScopedId(FEED_ID, "three-stop-product"), + "three-stop-product", + Money.euros(1) + ) .withValidity(Duration.ofHours(1)) .build(); - FareProduct fiveStopProduct = FareProduct - .of(new FeedScopedId(FEED_ID, "five-stop-product"), "five-stop-product", Money.euros(1)) + FareProduct fiveStopProduct = FareProduct.of( + new FeedScopedId(FEED_ID, "five-stop-product"), + "five-stop-product", + Money.euros(1) + ) .withValidity(Duration.ofHours(1)) .build(); - FareProduct twelveStopProduct = FareProduct - .of(new FeedScopedId(FEED_ID, "twelve-stop-product"), "twelve-stop-product", Money.euros(1)) + FareProduct twelveStopProduct = FareProduct.of( + new FeedScopedId(FEED_ID, "twelve-stop-product"), + "twelve-stop-product", + Money.euros(1) + ) .withValidity(Duration.ofHours(1)) .build(); - FareProduct tenKmProduct = FareProduct - .of(new FeedScopedId(FEED_ID, "ten-km-product"), "ten-km-product", Money.euros(1)) + FareProduct tenKmProduct = FareProduct.of( + new FeedScopedId(FEED_ID, "ten-km-product"), + "ten-km-product", + Money.euros(1) + ) .withValidity(Duration.ofHours(1)) .build(); - FareProduct threeKmProduct = FareProduct - .of(new FeedScopedId(FEED_ID, "three-km-product"), "three-km-product", Money.euros(1)) + FareProduct threeKmProduct = FareProduct.of( + new FeedScopedId(FEED_ID, "three-km-product"), + "three-km-product", + Money.euros(1) + ) .withValidity(Duration.ofHours(1)) .build(); - FareProduct twoKmProduct = FareProduct - .of(new FeedScopedId(FEED_ID, "two-km-product"), "two-km-product", Money.euros(1)) + FareProduct twoKmProduct = FareProduct.of( + new FeedScopedId(FEED_ID, "two-km-product"), + "two-km-product", + Money.euros(1) + ) .withValidity(Duration.ofHours(1)) .build(); List stopRules = List.of( - FareLegRule - .of(DISTANCE_ID, threeStopProduct) + FareLegRule.of(DISTANCE_ID, threeStopProduct) .withFareDistance(new FareDistance.Stops(0, 3)) .build(), - FareLegRule - .of(DISTANCE_ID, fiveStopProduct) + FareLegRule.of(DISTANCE_ID, fiveStopProduct) .withFareDistance(new FareDistance.Stops(5, 10)) .build(), - FareLegRule - .of(DISTANCE_ID, twelveStopProduct) + FareLegRule.of(DISTANCE_ID, twelveStopProduct) .withFareDistance(new FareDistance.Stops(12, 20)) .build() ); List distanceRules = List.of( - FareLegRule - .of(DISTANCE_ID, tenKmProduct) + FareLegRule.of(DISTANCE_ID, tenKmProduct) .withFareDistance( new LinearDistance( Distance.ofKilometersBoxed(7d, ignore -> {}).orElse(null), @@ -338,8 +354,7 @@ class DistanceFares { ) ) .build(), - FareLegRule - .of(DISTANCE_ID, threeKmProduct) + FareLegRule.of(DISTANCE_ID, threeKmProduct) .withFareDistance( new LinearDistance( Distance.ofKilometersBoxed(3d, ignore -> {}).orElse(null), @@ -347,8 +362,7 @@ class DistanceFares { ) ) .build(), - FareLegRule - .of(DISTANCE_ID, twoKmProduct) + FareLegRule.of(DISTANCE_ID, twoKmProduct) .withFareDistance( new LinearDistance( Distance.ofMetersBoxed(0d, ignore -> {}).orElse(null), diff --git a/application/src/ext-test/java/org/opentripplanner/ext/fares/impl/HSLFareServiceTest.java b/application/src/ext-test/java/org/opentripplanner/ext/fares/impl/HSLFareServiceTest.java index d3e31a1383b..3cfc3a7f0cc 100644 --- a/application/src/ext-test/java/org/opentripplanner/ext/fares/impl/HSLFareServiceTest.java +++ b/application/src/ext-test/java/org/opentripplanner/ext/fares/impl/HSLFareServiceTest.java @@ -53,19 +53,16 @@ public void canCalculateHSLFares( private static List createTestCases() { List args = new LinkedList<>(); - Agency agency1 = Agency - .of(new FeedScopedId(FEED_ID, "AG1")) + Agency agency1 = Agency.of(new FeedScopedId(FEED_ID, "AG1")) .withName("Agency 1") .withTimezone("Europe/Helsinki") .build(); - Agency agency2 = Agency - .of(new FeedScopedId(FEED_ID, "AG2")) + Agency agency2 = Agency.of(new FeedScopedId(FEED_ID, "AG2")) .withName("Agency 2") .withTimezone("Europe/Helsinki") .build(); - Agency agency3 = Agency - .of(new FeedScopedId("FEED2", "AG3")) + Agency agency3 = Agency.of(new FeedScopedId("FEED2", "AG3")) .withName("Agency 3") .withTimezone("Europe/Helsinki") .build(); @@ -101,57 +98,48 @@ private static List createTestCases() { // Fare attributes - FareAttribute fareAttributeAB = FareAttribute - .of(new FeedScopedId(FEED_ID, "AB")) + FareAttribute fareAttributeAB = FareAttribute.of(new FeedScopedId(FEED_ID, "AB")) .setPrice(AB_PRICE) .setTransferDuration(fiveMinutes) .build(); - FareAttribute fareAttributeBC = FareAttribute - .of(new FeedScopedId(FEED_ID, "BC")) + FareAttribute fareAttributeBC = FareAttribute.of(new FeedScopedId(FEED_ID, "BC")) .setPrice(BC_PRICE) .setTransferDuration(fiveMinutes) .build(); - FareAttribute fareAttributeCD = FareAttribute - .of(new FeedScopedId(FEED_ID, "CD")) + FareAttribute fareAttributeCD = FareAttribute.of(new FeedScopedId(FEED_ID, "CD")) .setPrice(CD_PRICE) .setTransferDuration(fiveMinutes) .build(); - FareAttribute fareAttributeD = FareAttribute - .of(new FeedScopedId(FEED_ID, "D")) + FareAttribute fareAttributeD = FareAttribute.of(new FeedScopedId(FEED_ID, "D")) .setPrice(D_PRICE) .setTransferDuration(fiveMinutes) //.setAgency(agency1.getId().getId()) .build(); - FareAttribute fareAttributeABC = FareAttribute - .of(new FeedScopedId(FEED_ID, "ABC")) + FareAttribute fareAttributeABC = FareAttribute.of(new FeedScopedId(FEED_ID, "ABC")) .setPrice(ABC_PRICE) .setTransferDuration(fiveMinutes) .build(); - FareAttribute fareAttributeBCD = FareAttribute - .of(new FeedScopedId(FEED_ID, "BCD")) + FareAttribute fareAttributeBCD = FareAttribute.of(new FeedScopedId(FEED_ID, "BCD")) .setPrice(BCD_PRICE) .setTransferDuration(fiveMinutes) .build(); - FareAttribute fareAttributeABCD = FareAttribute - .of(new FeedScopedId(FEED_ID, "ABCD")) + FareAttribute fareAttributeABCD = FareAttribute.of(new FeedScopedId(FEED_ID, "ABCD")) .setPrice(ABCD_PRICE) .setTransferDuration(fiveMinutes) .build(); - FareAttribute fareAttributeD2 = FareAttribute - .of(new FeedScopedId(FEED_ID, "D2")) + FareAttribute fareAttributeD2 = FareAttribute.of(new FeedScopedId(FEED_ID, "D2")) .setPrice(Money.euros(0)) .setAgency(agency2.getId()) .build(); - FareAttribute fareAttributeAgency3 = FareAttribute - .of(new FeedScopedId("FEED2", "attribute")) + FareAttribute fareAttributeAgency3 = FareAttribute.of(new FeedScopedId("FEED2", "attribute")) .setPrice(Money.euros(0)) .setAgency(agency3.getId()) .build(); @@ -210,22 +198,19 @@ private static List createTestCases() { ) ); - Route routeAgency1 = Route - .of(new FeedScopedId(FEED_ID, "R1")) + Route routeAgency1 = Route.of(new FeedScopedId(FEED_ID, "R1")) .withAgency(agency1) .withLongName(new NonLocalizedString("Route agency 1")) .withMode(TransitMode.BUS) .build(); - Route routeAgency2 = Route - .of(new FeedScopedId(FEED_ID, "R2")) + Route routeAgency2 = Route.of(new FeedScopedId(FEED_ID, "R2")) .withAgency(agency2) .withLongName(new NonLocalizedString("Route agency 2")) .withMode(TransitMode.BUS) .build(); - Route routeAgency3 = Route - .of(new FeedScopedId("FEED2", "R3")) + Route routeAgency3 = Route.of(new FeedScopedId("FEED2", "R3")) .withAgency(agency3) .withLongName(new NonLocalizedString("Route agency 3")) .withMode(TransitMode.BUS) @@ -434,8 +419,7 @@ private static List createTestCases() { @Test void unknownFare() { - FareAttribute fareAttributeAB = FareAttribute - .of(new FeedScopedId(FEED_ID, "AB")) + FareAttribute fareAttributeAB = FareAttribute.of(new FeedScopedId(FEED_ID, "AB")) .setPrice(euros(2.80f)) .setTransferDuration(60 * 5) .build(); diff --git a/application/src/ext-test/java/org/opentripplanner/ext/fares/impl/HighestFareInFreeTransferWindowFareServiceTest.java b/application/src/ext-test/java/org/opentripplanner/ext/fares/impl/HighestFareInFreeTransferWindowFareServiceTest.java index c65db6c3a9f..a82eab479f4 100644 --- a/application/src/ext-test/java/org/opentripplanner/ext/fares/impl/HighestFareInFreeTransferWindowFareServiceTest.java +++ b/application/src/ext-test/java/org/opentripplanner/ext/fares/impl/HighestFareInFreeTransferWindowFareServiceTest.java @@ -27,8 +27,7 @@ class HighestFareInFreeTransferWindowFareServiceTest implements PlanTestConstants { - static Agency agency = Agency - .of(id("agency")) + static Agency agency = Agency.of(id("agency")) .withName("Houston") .withTimezone("America/Chicago") .build(); @@ -61,8 +60,9 @@ private static List createTestCases() { // $1 fares var oneDollar = Money.usDollars(1.0f); - FareAttribute oneDollarFareAttribute = FareAttribute - .of(new FeedScopedId(FEED_ID, "oneDollarAttribute")) + FareAttribute oneDollarFareAttribute = FareAttribute.of( + new FeedScopedId(FEED_ID, "oneDollarAttribute") + ) .setPrice(oneDollar) .build(); FareRuleSet oneDollarRouteBasedFares = new FareRuleSet(oneDollarFareAttribute); @@ -72,8 +72,9 @@ private static List createTestCases() { // $2 fares var twoDollars = Money.usDollars(2.0f); - FareAttribute twoDollarFareAttribute = FareAttribute - .of(new FeedScopedId(FEED_ID, "twoDollarAttribute")) + FareAttribute twoDollarFareAttribute = FareAttribute.of( + new FeedScopedId(FEED_ID, "twoDollarAttribute") + ) .setPrice(twoDollars) .build(); @@ -207,11 +208,12 @@ private static List createTestCases() { // a two transit leg itinerary with an interlined transfer where the second route costs more than the first // route, but both are within the free transfer window and the fare service is configured with the // analyzeInterlinedTransfers set to true should calculate the second route cost - FareService fareServiceWithAnalyzedInterlinedTransfersConfig = new HighestFareInFreeTransferWindowFareService( - defaultFareRules, - Duration.ofMinutes(150), - true - ); + FareService fareServiceWithAnalyzedInterlinedTransfersConfig = + new HighestFareInFreeTransferWindowFareService( + defaultFareRules, + Duration.ofMinutes(150), + true + ); args.add( Arguments.of( @@ -227,8 +229,7 @@ private static List createTestCases() { private static Route route(String id, String name) { NonLocalizedString lName = new NonLocalizedString(name); - return Route - .of(id(id)) + return Route.of(id(id)) .withLongName(lName) .withAgency(agency) .withMode(TransitMode.BUS) diff --git a/application/src/ext-test/java/org/opentripplanner/ext/fares/impl/OrcaFareServiceTest.java b/application/src/ext-test/java/org/opentripplanner/ext/fares/impl/OrcaFareServiceTest.java index ed408008ca7..a6e0d496f76 100644 --- a/application/src/ext-test/java/org/opentripplanner/ext/fares/impl/OrcaFareServiceTest.java +++ b/application/src/ext-test/java/org/opentripplanner/ext/fares/impl/OrcaFareServiceTest.java @@ -104,10 +104,11 @@ private static void assertLegFareEquals( var rideCost = legFareProducts .stream() .map(FareProductUse::product) - .filter(fp -> - fp.medium().name().equals("electronic") && - fp.category().name().equals("regular") && - fp.name().equals("rideCost") + .filter( + fp -> + fp.medium().name().equals("electronic") && + fp.category().name().equals("regular") && + fp.name().equals("rideCost") ) .findFirst(); if (rideCost.isEmpty()) { @@ -118,10 +119,11 @@ private static void assertLegFareEquals( var transfer = legFareProducts .stream() .map(FareProductUse::product) - .filter(fp -> - fp.medium().name().equals("electronic") && - fp.category().name().equals("regular") && - fp.name().equals("transfer") + .filter( + fp -> + fp.medium().name().equals("electronic") && + fp.category().name().equals("regular") && + fp.name().equals("transfer") ) .findFirst(); Assertions.assertEquals(hasXfer, transfer.isPresent(), "Incorrect transfer leg fare product."); @@ -404,11 +406,10 @@ void calculateSoundTransitBusFares() { calculateFare(rides, FareType.electronicYouth, Money.ZERO_USD); // Also make sure that PT's 500 and 501 get regular Pierce fare and not ST's fare - rides = - List.of( - getLeg(PIERCE_COUNTY_TRANSIT_AGENCY_ID, "500", 0), - getLeg(PIERCE_COUNTY_TRANSIT_AGENCY_ID, "501", 60) - ); + rides = List.of( + getLeg(PIERCE_COUNTY_TRANSIT_AGENCY_ID, "500", 0), + getLeg(PIERCE_COUNTY_TRANSIT_AGENCY_ID, "501", 60) + ); calculateFare(rides, regular, DEFAULT_TEST_RIDE_PRICE.times(2)); calculateFare(rides, FareType.senior, TWO_DOLLARS); calculateFare(rides, FareType.youth, Money.ZERO_USD); @@ -661,8 +662,7 @@ private static Itinerary createItinerary( ) { // Use the agency ID as feed ID to make sure that we have a new feed ID for each different agency // This tests to make sure we are calculating transfers across feeds correctly. - Agency agency = Agency - .of(new FeedScopedId(agencyId, agencyId)) + Agency agency = Agency.of(new FeedScopedId(agencyId, agencyId)) .withName(agencyId) .withTimezone(ZoneIds.NEW_YORK.getId()) .build(); @@ -686,8 +686,7 @@ private static Itinerary createItinerary( if (routeLongName != null) { longName = new NonLocalizedString(routeLongName); } - Route route = Route - .of(routeFeedScopeId) + Route route = Route.of(routeFeedScopeId) .withAgency(agency) .withShortName(shortName) .withLongName(longName) diff --git a/application/src/ext-test/java/org/opentripplanner/ext/flex/AreaStopsToVerticesMapperTest.java b/application/src/ext-test/java/org/opentripplanner/ext/flex/AreaStopsToVerticesMapperTest.java index 979db157268..1628ccd735b 100644 --- a/application/src/ext-test/java/org/opentripplanner/ext/flex/AreaStopsToVerticesMapperTest.java +++ b/application/src/ext-test/java/org/opentripplanner/ext/flex/AreaStopsToVerticesMapperTest.java @@ -29,12 +29,10 @@ class AreaStopsToVerticesMapperTest { private static final TimetableRepositoryForTest TEST_MODEL = TimetableRepositoryForTest.of(); - private static final AreaStop BERLIN_AREA_STOP = TEST_MODEL - .areaStop("berlin") + private static final AreaStop BERLIN_AREA_STOP = TEST_MODEL.areaStop("berlin") .withGeometry(Polygons.BERLIN) .build(); - public static final SiteRepository SITE_REPOSITORY = TEST_MODEL - .siteRepositoryBuilder() + public static final SiteRepository SITE_REPOSITORY = TEST_MODEL.siteRepositoryBuilder() .withAreaStop(AreaStopsToVerticesMapperTest.BERLIN_AREA_STOP) .build(); diff --git a/application/src/ext-test/java/org/opentripplanner/ext/flex/FlexIntegrationTest.java b/application/src/ext-test/java/org/opentripplanner/ext/flex/FlexIntegrationTest.java index 46ee09af07b..e359a5a8659 100644 --- a/application/src/ext-test/java/org/opentripplanner/ext/flex/FlexIntegrationTest.java +++ b/application/src/ext-test/java/org/opentripplanner/ext/flex/FlexIntegrationTest.java @@ -42,9 +42,9 @@ public class FlexIntegrationTest { public static final GenericLocation OUTSIDE_FLEX_ZONE = new GenericLocation(33.7552, -84.4631); public static final GenericLocation INSIDE_FLEX_ZONE = new GenericLocation(33.8694, -84.6233); - static Instant dateTime = ZonedDateTime - .parse("2021-12-02T12:00:00-05:00[America/New_York]") - .toInstant(); + static Instant dateTime = ZonedDateTime.parse( + "2021-12-02T12:00:00-05:00[America/New_York]" + ).toInstant(); static Graph graph; @@ -207,8 +207,7 @@ private static void addGtfsToGraph( DataImportIssueStore.NOOP, Duration.ofMinutes(10), List.of(req) - ) - .buildGraph(); + ).buildGraph(); timetableRepository.index(); graph.index(timetableRepository.getSiteRepository()); diff --git a/application/src/ext-test/java/org/opentripplanner/ext/flex/FlexPathDurationsTest.java b/application/src/ext-test/java/org/opentripplanner/ext/flex/FlexPathDurationsTest.java index e4cd85822f9..110afb92204 100644 --- a/application/src/ext-test/java/org/opentripplanner/ext/flex/FlexPathDurationsTest.java +++ b/application/src/ext-test/java/org/opentripplanner/ext/flex/FlexPathDurationsTest.java @@ -23,17 +23,14 @@ class FlexPathDurationsTest { @Test void constructor() { - assertThrows( - IllegalArgumentException.class, - () -> new FlexPathDurations(-1, TRIP_DURATION_SEC, EGRESS_DURATION_SEC, OFFSET) + assertThrows(IllegalArgumentException.class, () -> + new FlexPathDurations(-1, TRIP_DURATION_SEC, EGRESS_DURATION_SEC, OFFSET) ); - assertThrows( - IllegalArgumentException.class, - () -> new FlexPathDurations(ACCESS_DURATION_SEC, -1, EGRESS_DURATION_SEC, OFFSET) + assertThrows(IllegalArgumentException.class, () -> + new FlexPathDurations(ACCESS_DURATION_SEC, -1, EGRESS_DURATION_SEC, OFFSET) ); - assertThrows( - IllegalArgumentException.class, - () -> new FlexPathDurations(ACCESS_DURATION_SEC, TRIP_DURATION_SEC, -1, OFFSET) + assertThrows(IllegalArgumentException.class, () -> + new FlexPathDurations(ACCESS_DURATION_SEC, TRIP_DURATION_SEC, -1, OFFSET) ); } diff --git a/application/src/ext-test/java/org/opentripplanner/ext/flex/FlexStopTimesForTest.java b/application/src/ext-test/java/org/opentripplanner/ext/flex/FlexStopTimesForTest.java index 9cff9177e2e..89e38edda54 100644 --- a/application/src/ext-test/java/org/opentripplanner/ext/flex/FlexStopTimesForTest.java +++ b/application/src/ext-test/java/org/opentripplanner/ext/flex/FlexStopTimesForTest.java @@ -12,8 +12,7 @@ public class FlexStopTimesForTest { private static final TimetableRepositoryForTest TEST_MODEL = TimetableRepositoryForTest.of(); - private static final StopLocation AREA_STOP = TEST_MODEL - .areaStop("area") + private static final StopLocation AREA_STOP = TEST_MODEL.areaStop("area") .withGeometry(Polygons.BERLIN) .build(); private static final RegularStop REGULAR_STOP = TEST_MODEL.stop("stop").build(); diff --git a/application/src/ext-test/java/org/opentripplanner/ext/flex/FlexibleTransitLegBuilderTest.java b/application/src/ext-test/java/org/opentripplanner/ext/flex/FlexibleTransitLegBuilderTest.java index e19083b0a40..7e2977c9b28 100644 --- a/application/src/ext-test/java/org/opentripplanner/ext/flex/FlexibleTransitLegBuilderTest.java +++ b/application/src/ext-test/java/org/opentripplanner/ext/flex/FlexibleTransitLegBuilderTest.java @@ -33,8 +33,7 @@ class FlexibleTransitLegBuilderTest implements PlanTestConstants { LocalDate.of(2025, 1, 15), new FlexPath(1000, 600, () -> GeometryUtils.makeLineString(1, 1, 2, 2)) ); - private static final TransitAlert ALERT = TransitAlert - .of(id("alert")) + private static final TransitAlert ALERT = TransitAlert.of(id("alert")) .withHeaderText(I18NString.of("alert 1")) .build(); private static final Duration TIME_SHIFT = Duration.ofHours(5); @@ -57,14 +56,10 @@ void everythingIsNonNull() { var expectedType = RuntimeException.class; assertThrows(expectedType, () -> new FlexibleTransitLegBuilder().withStartTime(null).build()); assertThrows(expectedType, () -> new FlexibleTransitLegBuilder().withEndTime(null).build()); - assertThrows( - expectedType, - () -> new FlexibleTransitLegBuilder().withFlexTripEdge(null).build() + assertThrows(expectedType, () -> new FlexibleTransitLegBuilder().withFlexTripEdge(null).build() ); assertThrows(expectedType, () -> new FlexibleTransitLegBuilder().withAlerts(null).build()); - assertThrows( - expectedType, - () -> new FlexibleTransitLegBuilder().withFareProducts(null).build() + assertThrows(expectedType, () -> new FlexibleTransitLegBuilder().withFareProducts(null).build() ); } diff --git a/application/src/ext-test/java/org/opentripplanner/ext/flex/flexpathcalculator/FlexPathTest.java b/application/src/ext-test/java/org/opentripplanner/ext/flex/flexpathcalculator/FlexPathTest.java index 3d37de02af4..46ab8d0c327 100644 --- a/application/src/ext-test/java/org/opentripplanner/ext/flex/flexpathcalculator/FlexPathTest.java +++ b/application/src/ext-test/java/org/opentripplanner/ext/flex/flexpathcalculator/FlexPathTest.java @@ -13,10 +13,8 @@ class FlexPathTest { private static final int THIRTY_MINS_IN_SECONDS = (int) Duration.ofMinutes(30).toSeconds(); - private static final FlexPath PATH = new FlexPath( - 10_000, - THIRTY_MINS_IN_SECONDS, - () -> LineStrings.SIMPLE + private static final FlexPath PATH = new FlexPath(10_000, THIRTY_MINS_IN_SECONDS, () -> + LineStrings.SIMPLE ); static List cases() { diff --git a/application/src/ext-test/java/org/opentripplanner/ext/flex/flexpathcalculator/ScheduledFlexPathCalculatorTest.java b/application/src/ext-test/java/org/opentripplanner/ext/flex/flexpathcalculator/ScheduledFlexPathCalculatorTest.java index 23827b9503b..b6ddfe7b2cc 100644 --- a/application/src/ext-test/java/org/opentripplanner/ext/flex/flexpathcalculator/ScheduledFlexPathCalculatorTest.java +++ b/application/src/ext-test/java/org/opentripplanner/ext/flex/flexpathcalculator/ScheduledFlexPathCalculatorTest.java @@ -15,8 +15,7 @@ class ScheduledFlexPathCalculatorTest { - private static final ScheduledDeviatedTrip TRIP = ScheduledDeviatedTrip - .of(id("123")) + private static final ScheduledDeviatedTrip TRIP = ScheduledDeviatedTrip.of(id("123")) .withStopTimes( List.of( regularStop("10:00", "10:01"), diff --git a/application/src/ext-test/java/org/opentripplanner/ext/flex/trip/UnscheduledDrivingDurationTest.java b/application/src/ext-test/java/org/opentripplanner/ext/flex/trip/UnscheduledDrivingDurationTest.java index f6fd43595a9..2fc69ca0a4a 100644 --- a/application/src/ext-test/java/org/opentripplanner/ext/flex/trip/UnscheduledDrivingDurationTest.java +++ b/application/src/ext-test/java/org/opentripplanner/ext/flex/trip/UnscheduledDrivingDurationTest.java @@ -18,12 +18,11 @@ class UnscheduledDrivingDurationTest { static final FlexPathCalculator STATIC_CALCULATOR = ( - fromv, - tov, - boardStopPosition, - alightStopPosition - ) -> - new FlexPath(10_000, (int) Duration.ofMinutes(10).toSeconds(), () -> LineStrings.SIMPLE); + fromv, + tov, + boardStopPosition, + alightStopPosition + ) -> new FlexPath(10_000, (int) Duration.ofMinutes(10).toSeconds(), () -> LineStrings.SIMPLE); private static final StopTime STOP_TIME = FlexStopTimesForTest.area("10:00", "18:00"); @Test @@ -37,8 +36,7 @@ void noPenalty() { @Test void withPenalty() { - var trip = UnscheduledTrip - .of(id("1")) + var trip = UnscheduledTrip.of(id("1")) .withStopTimes(List.of(STOP_TIME)) .withTimePenalty(TimePenalty.of(Duration.ofMinutes(2), 1.5f)) .build(); diff --git a/application/src/ext-test/java/org/opentripplanner/ext/flex/trip/UnscheduledTripTest.java b/application/src/ext-test/java/org/opentripplanner/ext/flex/trip/UnscheduledTripTest.java index 6ce964045ab..635cd4e9e44 100644 --- a/application/src/ext-test/java/org/opentripplanner/ext/flex/trip/UnscheduledTripTest.java +++ b/application/src/ext-test/java/org/opentripplanner/ext/flex/trip/UnscheduledTripTest.java @@ -48,20 +48,16 @@ class IsUnscheduledTrip { private static final StopTime SCHEDULED_STOP = FlexStopTimesForTest.regularStop("10:00"); private static final StopTime UNSCHEDULED_STOP = FlexStopTimesForTest.area("10:10", "10:20"); - private static final StopTime CONTINUOUS_PICKUP_STOP = FlexStopTimesForTest.regularStopWithContinuousPickup( - "10:30" - ); - private static final StopTime CONTINUOUS_DROP_OFF_STOP = FlexStopTimesForTest.regularStopWithContinuousDropOff( - "10:40" - ); + private static final StopTime CONTINUOUS_PICKUP_STOP = + FlexStopTimesForTest.regularStopWithContinuousPickup("10:30"); + private static final StopTime CONTINUOUS_DROP_OFF_STOP = + FlexStopTimesForTest.regularStopWithContinuousDropOff("10:40"); // disallowed by the GTFS spec - private static final StopTime FLEX_AND_CONTINUOUS_PICKUP_STOP = FlexStopTimesForTest.areaWithContinuousPickup( - "10:50" - ); - private static final StopTime FLEX_AND_CONTINUOUS_DROP_OFF_STOP = FlexStopTimesForTest.areaWithContinuousDropOff( - "11:00" - ); + private static final StopTime FLEX_AND_CONTINUOUS_PICKUP_STOP = + FlexStopTimesForTest.areaWithContinuousPickup("10:50"); + private static final StopTime FLEX_AND_CONTINUOUS_DROP_OFF_STOP = + FlexStopTimesForTest.areaWithContinuousDropOff("11:00"); static List> notUnscheduled() { return List.of( @@ -116,8 +112,7 @@ void testUnscheduledTrip() { toStopTime.setFlexWindowStart(T11_00); toStopTime.setFlexWindowEnd(T15_00); - var trip = UnscheduledTrip - .of(id("UNSCHEDULED")) + var trip = UnscheduledTrip.of(id("UNSCHEDULED")) .withStopTimes(List.of(fromStopTime, toStopTime)) .build(); @@ -141,8 +136,7 @@ void testUnscheduledFeederTripFromScheduledStop() { toStopTime.setFlexWindowStart(T10_00); toStopTime.setFlexWindowEnd(T14_00); - var trip = UnscheduledTrip - .of(id("UNSCHEDULED")) + var trip = UnscheduledTrip.of(id("UNSCHEDULED")) .withStopTimes(List.of(fromStopTime, toStopTime)) .build(); @@ -166,8 +160,7 @@ void testUnscheduledFeederTripToScheduledStop() { toStopTime.setStop(REGULAR_STOP); toStopTime.setArrivalTime(T14_00); - var trip = UnscheduledTrip - .of(id("UNSCHEDULED")) + var trip = UnscheduledTrip.of(id("UNSCHEDULED")) .withStopTimes(List.of(fromStopTime, toStopTime)) .build(); @@ -537,8 +530,7 @@ void boardingAlighting() { second.setPickupType(NONE); var third = area(AREA_STOP3, "10:20", "10:25"); - var trip = TestCase - .tc(first, third) + var trip = TestCase.tc(first, third) .withStopTimes(List.of(first, second, third)) .build() .trip(); @@ -601,8 +593,7 @@ UnscheduledTrip trip() { @Override public String toString() { - return ToStringBuilder - .of(TestCase.class) + return ToStringBuilder.of(TestCase.class) .addObj( "expected", expectedDescription + diff --git a/application/src/ext-test/java/org/opentripplanner/ext/geocoder/LuceneIndexTest.java b/application/src/ext-test/java/org/opentripplanner/ext/geocoder/LuceneIndexTest.java index b1468444076..1bd2408d71f 100644 --- a/application/src/ext-test/java/org/opentripplanner/ext/geocoder/LuceneIndexTest.java +++ b/application/src/ext-test/java/org/opentripplanner/ext/geocoder/LuceneIndexTest.java @@ -37,64 +37,53 @@ class LuceneIndexTest { private static final TimetableRepositoryForTest TEST_MODEL = TimetableRepositoryForTest.of(); - static final Agency BVG = Agency - .of(id("bvg")) + static final Agency BVG = Agency.of(id("bvg")) .withName("BVG") .withTimezone("Europe/Berlin") .build(); // Berlin - static final Station BERLIN_HAUPTBAHNHOF_STATION = TEST_MODEL - .station("Hauptbahnhof") + static final Station BERLIN_HAUPTBAHNHOF_STATION = TEST_MODEL.station("Hauptbahnhof") .withCoordinate(52.52495, 13.36952) .build(); - static final Station ALEXANDERPLATZ_STATION = TEST_MODEL - .station("Alexanderplatz") + static final Station ALEXANDERPLATZ_STATION = TEST_MODEL.station("Alexanderplatz") .withCoordinate(52.52277, 13.41046) .build(); - static final RegularStop ALEXANDERPLATZ_BUS = TEST_MODEL - .stop("Alexanderplatz Bus") + static final RegularStop ALEXANDERPLATZ_BUS = TEST_MODEL.stop("Alexanderplatz Bus") .withCoordinate(52.52277, 13.41046) .withVehicleType(BUS) .withParentStation(ALEXANDERPLATZ_STATION) .build(); - static final RegularStop ALEXANDERPLATZ_RAIL = TEST_MODEL - .stop("Alexanderplatz S-Bahn") + static final RegularStop ALEXANDERPLATZ_RAIL = TEST_MODEL.stop("Alexanderplatz S-Bahn") .withCoordinate(52.52157, 13.41123) .withVehicleType(TransitMode.RAIL) .withParentStation(ALEXANDERPLATZ_STATION) .build(); - static final RegularStop LICHTERFELDE_OST_1 = TEST_MODEL - .stop("Lichterfelde Ost") + static final RegularStop LICHTERFELDE_OST_1 = TEST_MODEL.stop("Lichterfelde Ost") .withId(id("lichterfelde-gleis-1")) .withCoordinate(52.42986, 13.32808) .build(); - static final RegularStop LICHTERFELDE_OST_2 = TEST_MODEL - .stop("Lichterfelde Ost") + static final RegularStop LICHTERFELDE_OST_2 = TEST_MODEL.stop("Lichterfelde Ost") .withId(id("lichterfelde-gleis-2")) .withCoordinate(52.42985, 13.32807) .build(); - static final RegularStop WESTHAFEN = TEST_MODEL - .stop("Westhafen") + static final RegularStop WESTHAFEN = TEST_MODEL.stop("Westhafen") .withVehicleType(null) .withCoordinate(52.42985, 13.32807) .build(); // Atlanta - static final Station FIVE_POINTS_STATION = TEST_MODEL - .station("Five Points") + static final Station FIVE_POINTS_STATION = TEST_MODEL.station("Five Points") .withCoordinate(33.753899, -84.39156) .build(); - static final RegularStop ARTS_CENTER = TEST_MODEL - .stop("Arts Center") + static final RegularStop ARTS_CENTER = TEST_MODEL.stop("Arts Center") .withCode("4456") .withCoordinate(52.52277, 13.41046) .build(); - static final RegularStop ARTHUR = TEST_MODEL - .stop("Arthur Langford Jr Pl SW at 220") + static final RegularStop ARTHUR = TEST_MODEL.stop("Arthur Langford Jr Pl SW at 220") .withCoordinate(52.52277, 13.41046) .build(); @@ -109,28 +98,28 @@ class LuceneIndexTest { @BeforeAll static void setup() { var siteRepository = TEST_MODEL.siteRepositoryBuilder(); - List - .of( - ALEXANDERPLATZ_BUS, - ALEXANDERPLATZ_RAIL, - LICHTERFELDE_OST_1, - LICHTERFELDE_OST_2, - WESTHAFEN, - ARTS_CENTER, - ARTHUR, - MERIDIAN_N1, - MERIDIAN_N2, - MERIDIAN_AVE - ) - .forEach(siteRepository::withRegularStop); - List - .of(ALEXANDERPLATZ_STATION, BERLIN_HAUPTBAHNHOF_STATION, FIVE_POINTS_STATION) - .forEach(siteRepository::withStation); + List.of( + ALEXANDERPLATZ_BUS, + ALEXANDERPLATZ_RAIL, + LICHTERFELDE_OST_1, + LICHTERFELDE_OST_2, + WESTHAFEN, + ARTS_CENTER, + ARTHUR, + MERIDIAN_N1, + MERIDIAN_N2, + MERIDIAN_AVE + ).forEach(siteRepository::withRegularStop); + List.of(ALEXANDERPLATZ_STATION, BERLIN_HAUPTBAHNHOF_STATION, FIVE_POINTS_STATION).forEach( + siteRepository::withStation + ); var timetableRepository = new TimetableRepository(siteRepository.build(), new Deduplicator()); timetableRepository.index(); var transitService = new DefaultTransitService(timetableRepository) { - private final Multimap modes = ImmutableMultimap - .builder() + private final Multimap modes = ImmutableMultimap.< + StopLocation, + TransitMode + >builder() .putAll(WESTHAFEN, FERRY, BUS) .build(); diff --git a/application/src/ext-test/java/org/opentripplanner/ext/geocoder/StopClusterMapperTest.java b/application/src/ext-test/java/org/opentripplanner/ext/geocoder/StopClusterMapperTest.java index 6af0eab2e18..47bee9940b7 100644 --- a/application/src/ext-test/java/org/opentripplanner/ext/geocoder/StopClusterMapperTest.java +++ b/application/src/ext-test/java/org/opentripplanner/ext/geocoder/StopClusterMapperTest.java @@ -22,16 +22,14 @@ class StopClusterMapperTest { private static final RegularStop STOP_B = TEST_MODEL.stop("B").build(); private static final RegularStop STOP_C = TEST_MODEL.stop("C").build(); private static final List STOPS = List.of(STOP_A, STOP_B, STOP_C); - private static final SiteRepository SITE_REPOSITORY = TEST_MODEL - .siteRepositoryBuilder() + private static final SiteRepository SITE_REPOSITORY = TEST_MODEL.siteRepositoryBuilder() .withRegularStops(STOPS) .build(); private static final TimetableRepository TIMETABLE_REPOSITORY = new TimetableRepository( SITE_REPOSITORY, new Deduplicator() ); - private static final List LOCATIONS = STOPS - .stream() + private static final List LOCATIONS = STOPS.stream() .map(StopLocation.class::cast) .toList(); diff --git a/application/src/ext-test/java/org/opentripplanner/ext/mapping/TransmodelMappingUtilTest.java b/application/src/ext-test/java/org/opentripplanner/ext/mapping/TransmodelMappingUtilTest.java index 82023904f0f..8aedefccd7c 100644 --- a/application/src/ext-test/java/org/opentripplanner/ext/mapping/TransmodelMappingUtilTest.java +++ b/application/src/ext-test/java/org/opentripplanner/ext/mapping/TransmodelMappingUtilTest.java @@ -33,8 +33,7 @@ public void resolveFixedFeedIdTest() { Agency agency(String feedScope, int id) { // We use the test builder to make sure we get back an agency with all required fields - return TimetableRepositoryForTest - .agency("Agency " + id) + return TimetableRepositoryForTest.agency("Agency " + id) .copy() .withId(new FeedScopedId(feedScope, Integer.toString(id))) .build(); diff --git a/application/src/ext-test/java/org/opentripplanner/ext/realtimeresolver/RealtimeResolverTest.java b/application/src/ext-test/java/org/opentripplanner/ext/realtimeresolver/RealtimeResolverTest.java index 80e5d1b153b..94492d349a3 100644 --- a/application/src/ext-test/java/org/opentripplanner/ext/realtimeresolver/RealtimeResolverTest.java +++ b/application/src/ext-test/java/org/opentripplanner/ext/realtimeresolver/RealtimeResolverTest.java @@ -57,8 +57,7 @@ void testPopulateLegsWithRealtime() { var transitService = makeTransitService(List.of(delayedPattern, patterns.get(1)), serviceDate); // Put an alert on stop3 - var alert = TransitAlert - .of(stop3.getId()) + var alert = TransitAlert.of(stop3.getId()) .addEntity(new EntitySelector.StopAndRoute(stop3.getId(), route2.getId())) .addTimePeriod(new TimePeriod(0, 0)) .build(); @@ -130,8 +129,7 @@ private static TripPattern delay(TripPattern pattern1, int seconds) { var originalTimeTable = pattern1.getScheduledTimetable(); var delayedTripTimes = delay(originalTimeTable.getTripTimes(0), seconds); - var delayedTimetable = Timetable - .of() + var delayedTimetable = Timetable.of() .withTripPattern(pattern1) .addTripTimes(delayedTripTimes) .build(); @@ -141,12 +139,10 @@ private static TripPattern delay(TripPattern pattern1, int seconds) { private static TripTimes delay(TripTimes tt, int seconds) { var delayed = tt.copyScheduledTimes(); - IntStream - .range(0, delayed.getNumStops()) - .forEach(i -> { - delayed.updateArrivalDelay(i, seconds); - delayed.updateDepartureDelay(i, seconds); - }); + IntStream.range(0, delayed.getNumStops()).forEach(i -> { + delayed.updateArrivalDelay(i, seconds); + delayed.updateDepartureDelay(i, seconds); + }); return delayed; } diff --git a/application/src/ext-test/java/org/opentripplanner/ext/restapi/model/ApiTravelOptionsMakerTest.java b/application/src/ext-test/java/org/opentripplanner/ext/restapi/model/ApiTravelOptionsMakerTest.java index fdcd0a7fe20..cf1acc021fb 100644 --- a/application/src/ext-test/java/org/opentripplanner/ext/restapi/model/ApiTravelOptionsMakerTest.java +++ b/application/src/ext-test/java/org/opentripplanner/ext/restapi/model/ApiTravelOptionsMakerTest.java @@ -43,8 +43,12 @@ public void testMakeOptions() throws Exception { hasBikeRide = true; - options = - ApiTravelOptionsMaker.makeOptions(transitModes, hasBikeShare, hasBikeRide, hasParkRide); + options = ApiTravelOptionsMaker.makeOptions( + transitModes, + hasBikeShare, + hasBikeRide, + hasParkRide + ); expected = new HashSet<>(); expected.add(new ApiTravelOption("TRANSIT,WALK", "TRANSIT")); expected.add(new ApiTravelOption("BUS,WALK", "BUS")); @@ -62,8 +66,12 @@ public void testMakeOptions() throws Exception { hasBikeShare = true; - options = - ApiTravelOptionsMaker.makeOptions(transitModes, hasBikeShare, hasBikeRide, hasParkRide); + options = ApiTravelOptionsMaker.makeOptions( + transitModes, + hasBikeShare, + hasBikeRide, + hasParkRide + ); expected = new HashSet<>(); expected.add(new ApiTravelOption("TRANSIT,WALK", "TRANSIT")); expected.add(new ApiTravelOption("BUS,WALK", "BUS")); @@ -81,8 +89,12 @@ public void testMakeOptions() throws Exception { hasBikeShare = false; hasParkRide = true; - options = - ApiTravelOptionsMaker.makeOptions(transitModes, hasBikeShare, hasBikeRide, hasParkRide); + options = ApiTravelOptionsMaker.makeOptions( + transitModes, + hasBikeShare, + hasBikeRide, + hasParkRide + ); expected = new HashSet<>(); expected.add(new ApiTravelOption("TRANSIT,WALK", "TRANSIT")); expected.add(new ApiTravelOption("BUS,WALK", "BUS")); @@ -100,8 +112,12 @@ public void testMakeOptions() throws Exception { hasParkRide = true; hasBikeRide = true; - options = - ApiTravelOptionsMaker.makeOptions(transitModes, hasBikeShare, hasBikeRide, hasParkRide); + options = ApiTravelOptionsMaker.makeOptions( + transitModes, + hasBikeShare, + hasBikeRide, + hasParkRide + ); expected = new HashSet<>(); expected.add(new ApiTravelOption("TRANSIT,WALK", "TRANSIT")); expected.add(new ApiTravelOption("BUS,WALK", "BUS")); @@ -120,8 +136,12 @@ public void testMakeOptions() throws Exception { transitModes = new HashSet<>(); - options = - ApiTravelOptionsMaker.makeOptions(transitModes, hasBikeShare, hasBikeRide, hasParkRide); + options = ApiTravelOptionsMaker.makeOptions( + transitModes, + hasBikeShare, + hasBikeRide, + hasParkRide + ); expected = new HashSet<>(); expected.add(new ApiTravelOption("WALK", "WALK")); expected.add(new ApiTravelOption("BICYCLE", "BICYCLE")); @@ -134,8 +154,12 @@ public void testMakeOptions() throws Exception { hasParkRide = false; hasBikeShare = false; - options = - ApiTravelOptionsMaker.makeOptions(transitModes, hasBikeShare, hasBikeRide, hasParkRide); + options = ApiTravelOptionsMaker.makeOptions( + transitModes, + hasBikeShare, + hasBikeRide, + hasParkRide + ); expected = new HashSet<>(); expected.add(new ApiTravelOption("WALK", "WALK")); expected.add(new ApiTravelOption("BICYCLE", "BICYCLE")); diff --git a/application/src/ext-test/java/org/opentripplanner/ext/restapi/parameter/QualifiedModeSetTest.java b/application/src/ext-test/java/org/opentripplanner/ext/restapi/parameter/QualifiedModeSetTest.java index 7c3bf410192..92adf1f823b 100644 --- a/application/src/ext-test/java/org/opentripplanner/ext/restapi/parameter/QualifiedModeSetTest.java +++ b/application/src/ext-test/java/org/opentripplanner/ext/restapi/parameter/QualifiedModeSetTest.java @@ -43,8 +43,7 @@ public void singleWalk() { QualifiedModeSet modeSet = new QualifiedModeSet("WALK"); assertEquals(Set.of(new QualifiedMode("WALK")), modeSet.qModes); assertEquals( - RequestModes - .of() + RequestModes.of() .withAccessMode(WALK) .withEgressMode(WALK) .withDirectMode(WALK) @@ -89,8 +88,7 @@ public void singleWalkAndBicycleToPark() { modeSet.qModes ); assertEquals( - RequestModes - .of() + RequestModes.of() .withAccessMode(BIKE_TO_PARK) .withEgressMode(WALK) .withDirectMode(BIKE_TO_PARK) @@ -105,8 +103,7 @@ public void multipleWalksAndBicycle() { QualifiedModeSet modeSet = new QualifiedModeSet("WALK,BICYCLE,WALK"); assertEquals(Set.of(new QualifiedMode("WALK"), new QualifiedMode("BICYCLE")), modeSet.qModes); assertEquals( - RequestModes - .of() + RequestModes.of() .withAccessMode(BIKE) .withEgressMode(BIKE) .withDirectMode(BIKE) @@ -118,9 +115,8 @@ public void multipleWalksAndBicycle() { @Test public void multipleNonWalkModes() { - assertThrows( - IllegalStateException.class, - () -> new QualifiedModeSet("WALK,BICYCLE,CAR").getRequestModes() + assertThrows(IllegalStateException.class, () -> + new QualifiedModeSet("WALK,BICYCLE,CAR").getRequestModes() ); } @@ -136,8 +132,7 @@ public void allFlexible() { modeSet.qModes ); assertEquals( - RequestModes - .of() + RequestModes.of() .withAccessMode(FLEXIBLE) .withEgressMode(FLEXIBLE) .withDirectMode(FLEXIBLE) @@ -155,8 +150,7 @@ public void bicycleToParkWithFlexibleEgress() { modeSet.qModes ); assertEquals( - RequestModes - .of() + RequestModes.of() .withAccessMode(BIKE_TO_PARK) .withEgressMode(FLEXIBLE) .withDirectMode(BIKE_TO_PARK) diff --git a/application/src/ext-test/java/org/opentripplanner/ext/restapi/parameter/QualifiedModeTest.java b/application/src/ext-test/java/org/opentripplanner/ext/restapi/parameter/QualifiedModeTest.java index 3a682ba40c9..a89c2da8247 100644 --- a/application/src/ext-test/java/org/opentripplanner/ext/restapi/parameter/QualifiedModeTest.java +++ b/application/src/ext-test/java/org/opentripplanner/ext/restapi/parameter/QualifiedModeTest.java @@ -15,8 +15,7 @@ public class QualifiedModeTest { @Test public void test() { Set ALL_QUALIFIERS = Arrays.stream(Qualifier.values()).collect(Collectors.toSet()); - String ALL_QUALIFIERS_STR = ALL_QUALIFIERS - .stream() + String ALL_QUALIFIERS_STR = ALL_QUALIFIERS.stream() .map(Enum::name) .reduce((i, j) -> i + "_" + j) .orElse("X"); diff --git a/application/src/ext-test/java/org/opentripplanner/ext/ridehailing/DecorateWithRideHailingTest.java b/application/src/ext-test/java/org/opentripplanner/ext/ridehailing/DecorateWithRideHailingTest.java index 58eb6315dd9..2a56dd3d43d 100644 --- a/application/src/ext-test/java/org/opentripplanner/ext/ridehailing/DecorateWithRideHailingTest.java +++ b/application/src/ext-test/java/org/opentripplanner/ext/ridehailing/DecorateWithRideHailingTest.java @@ -32,8 +32,7 @@ class DecorateWithRideHailingTest implements PlanTestConstants { ); RideHailingService failingService = new FailingRideHailingService(); - Itinerary i = TestItineraryBuilder - .newItinerary(A) + Itinerary i = TestItineraryBuilder.newItinerary(A) .drive(T11_30, PlanTestConstants.T11_50, B) .build(); diff --git a/application/src/ext-test/java/org/opentripplanner/ext/ridehailing/RideHailingAccessShifterTest.java b/application/src/ext-test/java/org/opentripplanner/ext/ridehailing/RideHailingAccessShifterTest.java index 3e6df7135e5..aa5e4f0bb6a 100644 --- a/application/src/ext-test/java/org/opentripplanner/ext/ridehailing/RideHailingAccessShifterTest.java +++ b/application/src/ext-test/java/org/opentripplanner/ext/ridehailing/RideHailingAccessShifterTest.java @@ -31,8 +31,7 @@ class RideHailingAccessShifterTest { private static final Instant TIME = OffsetDateTime.parse("2023-03-23T17:00:00+01:00").toInstant(); private static final GenericLocation FROM = new GenericLocation(0d, 0d); private static final GenericLocation TO = new GenericLocation(1d, 1d); - private static final State DRIVING_STATE = TestStateBuilder - .ofDriving() + private static final State DRIVING_STATE = TestStateBuilder.ofDriving() .streetEdge() .streetEdge() .build(); diff --git a/application/src/ext-test/java/org/opentripplanner/ext/siri/updater/azure/SiriAzureUpdaterTest.java b/application/src/ext-test/java/org/opentripplanner/ext/siri/updater/azure/SiriAzureUpdaterTest.java index 92b85856dfd..d64c21d23f5 100644 --- a/application/src/ext-test/java/org/opentripplanner/ext/siri/updater/azure/SiriAzureUpdaterTest.java +++ b/application/src/ext-test/java/org/opentripplanner/ext/siri/updater/azure/SiriAzureUpdaterTest.java @@ -58,22 +58,21 @@ public void setUp() throws Exception { when(mockConfig.isFuzzyTripMatching()).thenReturn(true); // Create a spy on AbstractAzureSiriUpdater with the mock configuration - updater = - spy( - new SiriAzureUpdater( - mockConfig, - new SiriAzureMessageHandler() { - @Override - public void setup(WriteToGraphCallback writeToGraphCallback) {} - - @Override - @Nullable - public Future handleMessage(ServiceDelivery serviceDelivery, String messageId) { - return null; - } + updater = spy( + new SiriAzureUpdater( + mockConfig, + new SiriAzureMessageHandler() { + @Override + public void setup(WriteToGraphCallback writeToGraphCallback) {} + + @Override + @Nullable + public Future handleMessage(ServiceDelivery serviceDelivery, String messageId) { + return null; } - ) - ); + } + ) + ); task = mock(SiriAzureUpdater.CheckedRunnable.class); } @@ -167,9 +166,9 @@ public void testExecuteWithRetry_MultipleRetriesThenSuccess() throws Throwable { .run(); doAnswer(invocation -> { - latch.countDown(); - return null; - }) + latch.countDown(); + return null; + }) .when(updater) .sleep(anyInt()); @@ -225,11 +224,11 @@ public void testExecuteWithRetry_OneRetryThenSuccess() throws Throwable { .run(); doAnswer(invocation -> { - if (invocation.getArgument(0).equals(1000)) { - latch.countDown(); - } - return null; - }) + if (invocation.getArgument(0).equals(1000)) { + latch.countDown(); + } + return null; + }) .when(updater) .sleep(anyInt()); diff --git a/application/src/ext-test/java/org/opentripplanner/ext/stopconsolidation/DecorateConsolidatedStopNamesTest.java b/application/src/ext-test/java/org/opentripplanner/ext/stopconsolidation/DecorateConsolidatedStopNamesTest.java index 8d0f9175f95..6164cc31af7 100644 --- a/application/src/ext-test/java/org/opentripplanner/ext/stopconsolidation/DecorateConsolidatedStopNamesTest.java +++ b/application/src/ext-test/java/org/opentripplanner/ext/stopconsolidation/DecorateConsolidatedStopNamesTest.java @@ -33,8 +33,7 @@ class DecorateConsolidatedStopNamesTest { void changeNames() { var filter = defaultFilter(); - var itinerary = TestItineraryBuilder - .newItinerary(PLACE_C) + var itinerary = TestItineraryBuilder.newItinerary(PLACE_C) .bus(TestStopConsolidationModel.ROUTE, 1, T11_05, T11_12, PLACE_C) .bus(1, T11_05, T11_12, PlanTestConstants.E) .bus(1, T11_05, T11_12, PlanTestConstants.F) @@ -61,8 +60,7 @@ void changeNames() { void removeTransferAtConsolidatedStop() { final var filter = defaultFilter(); - var itinerary = TestItineraryBuilder - .newItinerary(PLACE_C) + var itinerary = TestItineraryBuilder.newItinerary(PLACE_C) .bus(TestStopConsolidationModel.ROUTE, 1, T11_05, T11_12, PLACE_C) .walk(1, PLACE_C) .bus(1, T11_05, T11_12, PlanTestConstants.F) @@ -78,8 +76,7 @@ void removeTransferAtConsolidatedStop() { void keepRegularTransfer() { final var filter = defaultFilter(); - var itinerary = TestItineraryBuilder - .newItinerary(PLACE_C) + var itinerary = TestItineraryBuilder.newItinerary(PLACE_C) .bus(TestStopConsolidationModel.ROUTE, 1, T11_05, T11_12, PLACE_C) .walk(1, PlanTestConstants.E) .bus(1, T11_05, T11_12, PlanTestConstants.F) diff --git a/application/src/ext-test/java/org/opentripplanner/ext/stopconsolidation/TestStopConsolidationModel.java b/application/src/ext-test/java/org/opentripplanner/ext/stopconsolidation/TestStopConsolidationModel.java index f763b520f5b..5be3218e588 100644 --- a/application/src/ext-test/java/org/opentripplanner/ext/stopconsolidation/TestStopConsolidationModel.java +++ b/application/src/ext-test/java/org/opentripplanner/ext/stopconsolidation/TestStopConsolidationModel.java @@ -25,13 +25,13 @@ class TestStopConsolidationModel { STOP_C ); static final String SECONDARY_FEED_ID = "secondary"; - static final Agency AGENCY = TimetableRepositoryForTest - .agency("agency") + static final Agency AGENCY = TimetableRepositoryForTest.agency("agency") .copy() .withId(new FeedScopedId(SECONDARY_FEED_ID, "agency")) .build(); - static final Route ROUTE = TimetableRepositoryForTest - .route(new FeedScopedId(SECONDARY_FEED_ID, "route-33")) + static final Route ROUTE = TimetableRepositoryForTest.route( + new FeedScopedId(SECONDARY_FEED_ID, "route-33") + ) .withAgency(AGENCY) .build(); static final RegularStop STOP_D = testModel @@ -39,8 +39,7 @@ class TestStopConsolidationModel { .withId(new FeedScopedId(SECONDARY_FEED_ID, "secondary-stop-D")) .build(); - static final TripPattern PATTERN = TripPattern - .of(id("123")) + static final TripPattern PATTERN = TripPattern.of(id("123")) .withRoute(ROUTE) .withStopPattern(STOP_PATTERN) .build(); diff --git a/application/src/ext-test/java/org/opentripplanner/ext/stopconsolidation/model/ConsolidatedStopLegBuilderTest.java b/application/src/ext-test/java/org/opentripplanner/ext/stopconsolidation/model/ConsolidatedStopLegBuilderTest.java index aa70b2dd998..34f665dff3f 100644 --- a/application/src/ext-test/java/org/opentripplanner/ext/stopconsolidation/model/ConsolidatedStopLegBuilderTest.java +++ b/application/src/ext-test/java/org/opentripplanner/ext/stopconsolidation/model/ConsolidatedStopLegBuilderTest.java @@ -24,18 +24,18 @@ class ConsolidatedStopLegBuilderTest implements PlanTestConstants { private static final Set ALERTS = Set.of( TransitAlert.of(id("alert")).withDescriptionText(I18NString.of("alert")).build() ); - private static final TripPattern PATTERN = TimetableRepositoryForTest - .of() + private static final TripPattern PATTERN = TimetableRepositoryForTest.of() .pattern(TransitMode.BUS) .build(); - private static final ScheduledTransitLeg SCHEDULED_TRANSIT_LEG = new ScheduledTransitLegBuilder<>() - .withZoneId(ZoneIds.BERLIN) - .withServiceDate(LocalDate.of(2025, 1, 15)) - .withTripPattern(PATTERN) - .withBoardStopIndexInPattern(0) - .withDistanceMeters(1000) - .withAlightStopIndexInPattern(1) - .build(); + private static final ScheduledTransitLeg SCHEDULED_TRANSIT_LEG = + new ScheduledTransitLegBuilder<>() + .withZoneId(ZoneIds.BERLIN) + .withServiceDate(LocalDate.of(2025, 1, 15)) + .withTripPattern(PATTERN) + .withBoardStopIndexInPattern(0) + .withDistanceMeters(1000) + .withAlightStopIndexInPattern(1) + .build(); private static final List FARES = List.of(FARE_PRODUCT_USE); @Test @@ -86,8 +86,7 @@ void copyConsolidatedLeg() { @Test void copyAttributesFromScheduledLeg() { - var leg = SCHEDULED_TRANSIT_LEG - .copy() + var leg = SCHEDULED_TRANSIT_LEG.copy() .withFareProducts(FARES) .withAlerts(Set.of(ALERTS)) .build(); diff --git a/application/src/ext-test/java/org/opentripplanner/ext/vectortiles/layers/areastops/AreaStopPropertyMapperTest.java b/application/src/ext-test/java/org/opentripplanner/ext/vectortiles/layers/areastops/AreaStopPropertyMapperTest.java index a33a8b55286..be27be45edd 100644 --- a/application/src/ext-test/java/org/opentripplanner/ext/vectortiles/layers/areastops/AreaStopPropertyMapperTest.java +++ b/application/src/ext-test/java/org/opentripplanner/ext/vectortiles/layers/areastops/AreaStopPropertyMapperTest.java @@ -17,8 +17,7 @@ class AreaStopPropertyMapperTest { SiteRepository.of() ); private static final AreaStop STOP = MODEL.areaStop("123").build(); - private static final Route ROUTE_WITH_COLOR = TimetableRepositoryForTest - .route("123") + private static final Route ROUTE_WITH_COLOR = TimetableRepositoryForTest.route("123") .withColor("ffffff") .build(); private static final Route ROUTE_WITHOUT_COLOR = TimetableRepositoryForTest.route("456").build(); diff --git a/application/src/ext-test/java/org/opentripplanner/ext/vectortiles/layers/areastops/AreaStopsLayerBuilderTest.java b/application/src/ext-test/java/org/opentripplanner/ext/vectortiles/layers/areastops/AreaStopsLayerBuilderTest.java index cf5683b49b5..083b01071c2 100644 --- a/application/src/ext-test/java/org/opentripplanner/ext/vectortiles/layers/areastops/AreaStopsLayerBuilderTest.java +++ b/application/src/ext-test/java/org/opentripplanner/ext/vectortiles/layers/areastops/AreaStopsLayerBuilderTest.java @@ -25,26 +25,26 @@ class AreaStopsLayerBuilderTest { private static final I18NString NAME = I18NString.of("Test stop"); private static final String CONFIG = """ - { - "vectorTiles": { - "layers" : [ - { - "name": "areaStops", - "type": "AreaStop", - "mapper": "OTPRR", - "maxZoom": 20, - "minZoom": 14, - "cacheMaxSeconds": 60, - "expansionFactor": 0 - } - ] + { + "vectorTiles": { + "layers" : [ + { + "name": "areaStops", + "type": "AreaStop", + "mapper": "OTPRR", + "maxZoom": 20, + "minZoom": 14, + "cacheMaxSeconds": 60, + "expansionFactor": 0 + } + ] + } } - } - """; - private static final LayerParameters LAYER_CONFIG = VectorTileConfig - .mapVectorTilesParameters(newNodeAdapterForTest(CONFIG), "vectorTiles") - .layers() - .getFirst(); + """; + private static final LayerParameters LAYER_CONFIG = + VectorTileConfig.mapVectorTilesParameters(newNodeAdapterForTest(CONFIG), "vectorTiles") + .layers() + .getFirst(); private final SiteRepositoryBuilder siteRepositoryBuilder = SiteRepository.of(); diff --git a/application/src/ext-test/java/org/opentripplanner/ext/vectortiles/layers/stations/DigitransitStationPropertyMapperTest.java b/application/src/ext-test/java/org/opentripplanner/ext/vectortiles/layers/stations/DigitransitStationPropertyMapperTest.java index f3b1c9e2126..fe1d9d58260 100644 --- a/application/src/ext-test/java/org/opentripplanner/ext/vectortiles/layers/stations/DigitransitStationPropertyMapperTest.java +++ b/application/src/ext-test/java/org/opentripplanner/ext/vectortiles/layers/stations/DigitransitStationPropertyMapperTest.java @@ -26,8 +26,7 @@ void map() { var mapper = DigitransitStationPropertyMapper.create(transitService, Locale.US); - var station = Station - .of(id("a-station")) + var station = Station.of(id("a-station")) .withCoordinate(1, 1) .withName(I18NString.of("A station")) .build(); diff --git a/application/src/ext-test/java/org/opentripplanner/ext/vectortiles/layers/stops/RealtimeStopsLayerTest.java b/application/src/ext-test/java/org/opentripplanner/ext/vectortiles/layers/stops/RealtimeStopsLayerTest.java index 0db19baf6e5..485dfb9a976 100644 --- a/application/src/ext-test/java/org/opentripplanner/ext/vectortiles/layers/stops/RealtimeStopsLayerTest.java +++ b/application/src/ext-test/java/org/opentripplanner/ext/vectortiles/layers/stops/RealtimeStopsLayerTest.java @@ -39,24 +39,20 @@ public class RealtimeStopsLayerTest { public void setUp() { var name = I18NString.of("name"); var desc = I18NString.of("desc"); - stop = - SiteRepository - .of() - .regularStop(new FeedScopedId("F", "name")) - .withName(name) - .withDescription(desc) - .withCoordinate(50, 10) - .withTimeZone(ZoneIds.HELSINKI) - .build(); - stop2 = - SiteRepository - .of() - .regularStop(new FeedScopedId("F", "name")) - .withName(name) - .withDescription(desc) - .withCoordinate(51, 10) - .withTimeZone(ZoneIds.HELSINKI) - .build(); + stop = SiteRepository.of() + .regularStop(new FeedScopedId("F", "name")) + .withName(name) + .withDescription(desc) + .withCoordinate(50, 10) + .withTimeZone(ZoneIds.HELSINKI) + .build(); + stop2 = SiteRepository.of() + .regularStop(new FeedScopedId("F", "name")) + .withName(name) + .withDescription(desc) + .withCoordinate(51, 10) + .withTimeZone(ZoneIds.HELSINKI) + .build(); } @Test @@ -80,8 +76,7 @@ public TransitAlertService getTransitAlertService() { .build(); var startDate = ZonedDateTime.now(ZoneIds.HELSINKI).minusDays(1).toEpochSecond(); var endDate = ZonedDateTime.now(ZoneIds.HELSINKI).plusDays(1).toEpochSecond(); - var alert = TransitAlert - .of(stop.getId()) + var alert = TransitAlert.of(stop.getId()) .addEntity(new EntitySelector.Stop(stop.getId())) .addTimePeriod(new TimePeriod(startDate, endDate)) .withEffect(AlertEffect.NO_SERVICE) diff --git a/application/src/ext-test/java/org/opentripplanner/ext/vectortiles/layers/stops/StopsLayerTest.java b/application/src/ext-test/java/org/opentripplanner/ext/vectortiles/layers/stops/StopsLayerTest.java index d5d12576a1a..4a945f4f404 100644 --- a/application/src/ext-test/java/org/opentripplanner/ext/vectortiles/layers/stops/StopsLayerTest.java +++ b/application/src/ext-test/java/org/opentripplanner/ext/vectortiles/layers/stops/StopsLayerTest.java @@ -42,13 +42,11 @@ public class StopsLayerTest { false ); - private static final Station STATION = Station - .of(id("station1")) + private static final Station STATION = Station.of(id("station1")) .withCoordinate(WgsCoordinate.GREENWICH) .withName(I18NString.of("A Station")) .build(); - private static final RegularStop STOP = SiteRepository - .of() + private static final RegularStop STOP = SiteRepository.of() .regularStop(new FeedScopedId("F", "name")) .withName(NAME_TRANSLATIONS) .withDescription(DESC_TRANSLATIONS) diff --git a/application/src/ext-test/java/org/opentripplanner/ext/vectortiles/layers/vehicleparkings/VehicleParkingGroupsLayerTest.java b/application/src/ext-test/java/org/opentripplanner/ext/vectortiles/layers/vehicleparkings/VehicleParkingGroupsLayerTest.java index b8a88c11703..29cd52340ea 100644 --- a/application/src/ext-test/java/org/opentripplanner/ext/vectortiles/layers/vehicleparkings/VehicleParkingGroupsLayerTest.java +++ b/application/src/ext-test/java/org/opentripplanner/ext/vectortiles/layers/vehicleparkings/VehicleParkingGroupsLayerTest.java @@ -39,54 +39,50 @@ public class VehicleParkingGroupsLayerTest { @BeforeEach public void setUp() { - vehicleParkingGroup = - VehicleParkingGroup - .of(ID) - .withName( - TranslatedString.getI18NString( - new HashMap<>() { - { - put(null, "groupName"); - put("de", "groupDE"); - } - }, - false, - false - ) - ) - .withCoordinate(new WgsCoordinate(1.9, 1.1)) - .build(); - vehicleParking = - VehicleParking - .builder() - .id(ID) - .name( - TranslatedString.getI18NString( - new HashMap<>() { - { - put(null, "name"); - put("de", "DE"); - } - }, - false, - false - ) + vehicleParkingGroup = VehicleParkingGroup.of(ID) + .withName( + TranslatedString.getI18NString( + new HashMap<>() { + { + put(null, "groupName"); + put("de", "groupDE"); + } + }, + false, + false ) - .coordinate(new WgsCoordinate(2, 1)) - .bicyclePlaces(false) - .carPlaces(true) - .wheelchairAccessibleCarPlaces(false) - .imageUrl("image") - .detailsUrl("details") - .note(new NonLocalizedString("note")) - .tags(List.of("tag1", "tag2")) - .state(VehicleParkingState.OPERATIONAL) - .capacity(VehicleParkingSpaces.builder().bicycleSpaces(5).carSpaces(6).build()) - .availability( - VehicleParkingSpaces.builder().wheelchairAccessibleCarSpaces(1).bicycleSpaces(1).build() + ) + .withCoordinate(new WgsCoordinate(1.9, 1.1)) + .build(); + vehicleParking = VehicleParking.builder() + .id(ID) + .name( + TranslatedString.getI18NString( + new HashMap<>() { + { + put(null, "name"); + put("de", "DE"); + } + }, + false, + false ) - .vehicleParkingGroup(vehicleParkingGroup) - .build(); + ) + .coordinate(new WgsCoordinate(2, 1)) + .bicyclePlaces(false) + .carPlaces(true) + .wheelchairAccessibleCarPlaces(false) + .imageUrl("image") + .detailsUrl("details") + .note(new NonLocalizedString("note")) + .tags(List.of("tag1", "tag2")) + .state(VehicleParkingState.OPERATIONAL) + .capacity(VehicleParkingSpaces.builder().bicycleSpaces(5).carSpaces(6).build()) + .availability( + VehicleParkingSpaces.builder().wheelchairAccessibleCarSpaces(1).bicycleSpaces(1).build() + ) + .vehicleParkingGroup(vehicleParkingGroup) + .build(); } @Test @@ -132,9 +128,8 @@ public void vehicleParkingGroupGeometryTest() { @Test public void digitransitVehicleParkingGroupPropertyMapperTest() { - VehicleParkingGroupPropertyMapperWithPublicMap mapper = new VehicleParkingGroupPropertyMapperWithPublicMap( - Locale.US - ); + VehicleParkingGroupPropertyMapperWithPublicMap mapper = + new VehicleParkingGroupPropertyMapperWithPublicMap(Locale.US); Map map = new HashMap<>(); mapper .map(new VehicleParkingAndGroup(vehicleParkingGroup, Set.of(vehicleParking))) @@ -151,9 +146,8 @@ public void digitransitVehicleParkingGroupPropertyMapperTest() { @Test public void digitransitVehicleParkingGroupPropertyMapperTranslationTest() { - VehicleParkingGroupPropertyMapperWithPublicMap mapper = new VehicleParkingGroupPropertyMapperWithPublicMap( - new Locale("de") - ); + VehicleParkingGroupPropertyMapperWithPublicMap mapper = + new VehicleParkingGroupPropertyMapperWithPublicMap(new Locale("de")); Map map = new HashMap<>(); mapper .map(new VehicleParkingAndGroup(vehicleParkingGroup, Set.of(vehicleParking))) diff --git a/application/src/ext-test/java/org/opentripplanner/ext/vectortiles/layers/vehicleparkings/VehicleParkingsLayerTest.java b/application/src/ext-test/java/org/opentripplanner/ext/vectortiles/layers/vehicleparkings/VehicleParkingsLayerTest.java index cad94672576..19cd7d262d1 100644 --- a/application/src/ext-test/java/org/opentripplanner/ext/vectortiles/layers/vehicleparkings/VehicleParkingsLayerTest.java +++ b/application/src/ext-test/java/org/opentripplanner/ext/vectortiles/layers/vehicleparkings/VehicleParkingsLayerTest.java @@ -56,32 +56,30 @@ public void setUp() { .on(LocalDate.of(2022, Month.APRIL, 1)) .add(); - vehicleParking = - VehicleParking - .builder() - .id(ID) - .name( - TranslatedString.getI18NString( - Map.of("", "default name", "de", "deutscher Name"), - false, - false - ) + vehicleParking = VehicleParking.builder() + .id(ID) + .name( + TranslatedString.getI18NString( + Map.of("", "default name", "de", "deutscher Name"), + false, + false ) - .coordinate(new WgsCoordinate(2, 1)) - .bicyclePlaces(true) - .carPlaces(true) - .wheelchairAccessibleCarPlaces(false) - .imageUrl("image") - .detailsUrl("details") - .note(TranslatedString.getI18NString("default note", "DE", "deutsche Notiz")) - .tags(List.of("tag1", "tag2")) - .openingHoursCalendar(calBuilder.build()) - .state(VehicleParkingState.OPERATIONAL) - .capacity(VehicleParkingSpaces.builder().bicycleSpaces(5).carSpaces(6).build()) - .availability( - VehicleParkingSpaces.builder().wheelchairAccessibleCarSpaces(1).bicycleSpaces(1).build() - ) - .build(); + ) + .coordinate(new WgsCoordinate(2, 1)) + .bicyclePlaces(true) + .carPlaces(true) + .wheelchairAccessibleCarPlaces(false) + .imageUrl("image") + .detailsUrl("details") + .note(TranslatedString.getI18NString("default note", "DE", "deutsche Notiz")) + .tags(List.of("tag1", "tag2")) + .openingHoursCalendar(calBuilder.build()) + .state(VehicleParkingState.OPERATIONAL) + .capacity(VehicleParkingSpaces.builder().bicycleSpaces(5).carSpaces(6).build()) + .availability( + VehicleParkingSpaces.builder().wheelchairAccessibleCarSpaces(1).bicycleSpaces(1).build() + ) + .build(); } @Test diff --git a/application/src/ext-test/java/org/opentripplanner/ext/vectortiles/layers/vehiclerental/mapper/VehicleRentalLayerTest.java b/application/src/ext-test/java/org/opentripplanner/ext/vectortiles/layers/vehiclerental/mapper/VehicleRentalLayerTest.java index 45a4ab30744..c42256f8691 100644 --- a/application/src/ext-test/java/org/opentripplanner/ext/vectortiles/layers/vehiclerental/mapper/VehicleRentalLayerTest.java +++ b/application/src/ext-test/java/org/opentripplanner/ext/vectortiles/layers/vehiclerental/mapper/VehicleRentalLayerTest.java @@ -68,17 +68,16 @@ public void stationWithTranslations() { station.latitude = 1; station.longitude = 2; var germanName = "nameDE"; - station.name = - TranslatedString.getI18NString( - new HashMap<>() { - { - put(null, NAME); - put("de", germanName); - } - }, - false, - false - ); + station.name = TranslatedString.getI18NString( + new HashMap<>() { + { + put(null, NAME); + put("de", germanName); + } + }, + false, + false + ); station.vehicleTypesAvailable = Map.of(vehicleType(BICYCLE), 5, vehicleType(SCOOTER), 10); Map map = new HashMap<>(); diff --git a/application/src/ext/java/org/opentripplanner/ext/actuator/ActuatorAPI.java b/application/src/ext/java/org/opentripplanner/ext/actuator/ActuatorAPI.java index f8b61a56ecc..f779acca4d0 100644 --- a/application/src/ext/java/org/opentripplanner/ext/actuator/ActuatorAPI.java +++ b/application/src/ext/java/org/opentripplanner/ext/actuator/ActuatorAPI.java @@ -32,27 +32,26 @@ public class ActuatorAPI { @GET @Produces(MediaType.APPLICATION_JSON) public Response actuator(@Context UriInfo uriInfo) { - return Response - .status(Response.Status.OK) + return Response.status(Response.Status.OK) .entity( String.format( """ - { - "_links" : { - "self" : { - "href" : "%1$s", - "templated" : false - }, - "health" : { - "href" : "%1$s/health", - "templated" : false - }, - "prometheus" : { - "href" : "%1$s/prometheus", - "templated" : false - } + { + "_links" : { + "self" : { + "href" : "%1$s", + "templated" : false + }, + "health" : { + "href" : "%1$s/health", + "templated" : false + }, + "prometheus" : { + "href" : "%1$s/prometheus", + "templated" : false } - }""", + } + }""", uriInfo.getRequestUri().toString().replace("$/", "") ) ) @@ -74,8 +73,7 @@ public Response health(@Context OtpServerRequestContext serverContext) { if (!listUnprimedUpdaters.isEmpty()) { LOG.info("Graph ready, waiting for updaters: {}", listUnprimedUpdaters); throw new WebApplicationException( - Response - .status(Response.Status.NOT_FOUND) + Response.status(Response.Status.NOT_FOUND) .entity("Graph ready, waiting for updaters: " + listUnprimedUpdaters + "\n") .type("text/plain") .build() @@ -83,8 +81,7 @@ public Response health(@Context OtpServerRequestContext serverContext) { } } - return Response - .status(Response.Status.OK) + return Response.status(Response.Status.OK) .entity("{\n" + " \"status\" : \"UP\"" + "\n}") .type("application/json") .build(); @@ -104,8 +101,7 @@ public Response prometheus( ? CONTENT_TYPE_OPENMETRICS_100 : CONTENT_TYPE_004; - return Response - .status(Response.Status.OK) + return Response.status(Response.Status.OK) .entity(prometheusRegistry.scrape(contentType)) .type(contentType) .build(); diff --git a/application/src/ext/java/org/opentripplanner/ext/actuator/MicrometerGraphQLInstrumentation.java b/application/src/ext/java/org/opentripplanner/ext/actuator/MicrometerGraphQLInstrumentation.java index ab76adcc444..ecbc6d4adc0 100644 --- a/application/src/ext/java/org/opentripplanner/ext/actuator/MicrometerGraphQLInstrumentation.java +++ b/application/src/ext/java/org/opentripplanner/ext/actuator/MicrometerGraphQLInstrumentation.java @@ -131,8 +131,7 @@ public InstrumentationContext beginFieldFetch( } private Timer buildQueryTimer(String operationName, String operation) { - return Timer - .builder(QUERY_TIME_METRIC_NAME) + return Timer.builder(QUERY_TIME_METRIC_NAME) .description(TIMER_DESCRIPTION) .tag(OPERATION_NAME_TAG, operationName) .tag(OPERATION, operation) @@ -141,8 +140,7 @@ private Timer buildQueryTimer(String operationName, String operation) { } private Timer buildFieldTimer(String operationName, String parent, String field) { - return Timer - .builder(RESOLVER_TIME_METRIC_NAME) + return Timer.builder(RESOLVER_TIME_METRIC_NAME) .description(TIMER_DESCRIPTION) .tag(OPERATION_NAME_TAG, operationName) .tag(PARENT, parent) diff --git a/application/src/ext/java/org/opentripplanner/ext/dataoverlay/DataOverlayStreetEdgeCostExtension.java b/application/src/ext/java/org/opentripplanner/ext/dataoverlay/DataOverlayStreetEdgeCostExtension.java index 9a5e34ff3cc..19f7e0fb29d 100644 --- a/application/src/ext/java/org/opentripplanner/ext/dataoverlay/DataOverlayStreetEdgeCostExtension.java +++ b/application/src/ext/java/org/opentripplanner/ext/dataoverlay/DataOverlayStreetEdgeCostExtension.java @@ -51,7 +51,7 @@ class DataOverlayStreetEdgeCostExtension implements StreetEdgeCostExtension, Ser @Override public double calculateExtraCost(State state, int edgeLength, TraverseMode traverseMode) { if (traverseMode.isWalking() || traverseMode.isCyclingIsh()) { - return calculateDataOverlayPenalties(state) * edgeLength / 1000; + return (calculateDataOverlayPenalties(state) * edgeLength) / 1000; } return 0d; } diff --git a/application/src/ext/java/org/opentripplanner/ext/dataoverlay/GenericDataFile.java b/application/src/ext/java/org/opentripplanner/ext/dataoverlay/GenericDataFile.java index dbf3d5ee6b3..235e0ea5b12 100644 --- a/application/src/ext/java/org/opentripplanner/ext/dataoverlay/GenericDataFile.java +++ b/application/src/ext/java/org/opentripplanner/ext/dataoverlay/GenericDataFile.java @@ -67,9 +67,9 @@ public GenericDataFile(File file, DataOverlayConfig dataOverlayConfig) { } DateUnit dateUnit = new DateUnit(time.getUnitsString()); - Optional dateOrigin = Optional - .ofNullable(dateUnit.getDateOrigin()) - .map(Date::toInstant); + Optional dateOrigin = Optional.ofNullable(dateUnit.getDateOrigin()).map( + Date::toInstant + ); if (dateOrigin.isEmpty()) { error = String.format("Missing origin date from %s file", file.getAbsolutePath()); diff --git a/application/src/ext/java/org/opentripplanner/ext/dataoverlay/GenericEdgeUpdater.java b/application/src/ext/java/org/opentripplanner/ext/dataoverlay/GenericEdgeUpdater.java index f4188481fcf..650fe8a70b8 100644 --- a/application/src/ext/java/org/opentripplanner/ext/dataoverlay/GenericEdgeUpdater.java +++ b/application/src/ext/java/org/opentripplanner/ext/dataoverlay/GenericEdgeUpdater.java @@ -159,12 +159,13 @@ private float[] getAverageValue( ) { EdgeGenQuality edgeGenQuality = new EdgeGenQuality<>(); - getClosestSamples(fromLongitude, fromLatitude, toLongitude, toLatitude, propertyName) - .forEach(sample -> { + getClosestSamples(fromLongitude, fromLatitude, toLongitude, toLatitude, propertyName).forEach( + sample -> { for (int time = 0; time < sample.size(); time++) { edgeGenQuality.addPropertyValueSample(time, (Number) sample.get(time)); } - }); + } + ); return edgeGenQuality.getPropertyValueAverage((int) dataFile.getTimeArray().getSize()); } diff --git a/application/src/ext/java/org/opentripplanner/ext/dataoverlay/configuration/DataOverlayConfig.java b/application/src/ext/java/org/opentripplanner/ext/dataoverlay/configuration/DataOverlayConfig.java index 858ac97d8ce..cade9a99fb0 100644 --- a/application/src/ext/java/org/opentripplanner/ext/dataoverlay/configuration/DataOverlayConfig.java +++ b/application/src/ext/java/org/opentripplanner/ext/dataoverlay/configuration/DataOverlayConfig.java @@ -102,8 +102,7 @@ public DataOverlayParameterBindings getParameterBindings() { @Override public String toString() { - return ToStringBuilder - .of(DataOverlayConfig.class) + return ToStringBuilder.of(DataOverlayConfig.class) .addStr("fileName", fileName) .addStr("latitudeVariable", latitudeVariable) .addStr("longitudeVariable", longitudeVariable) diff --git a/application/src/ext/java/org/opentripplanner/ext/dataoverlay/configuration/DataOverlayParameterBindings.java b/application/src/ext/java/org/opentripplanner/ext/dataoverlay/configuration/DataOverlayParameterBindings.java index 7b3d1f19bac..fe20085942f 100644 --- a/application/src/ext/java/org/opentripplanner/ext/dataoverlay/configuration/DataOverlayParameterBindings.java +++ b/application/src/ext/java/org/opentripplanner/ext/dataoverlay/configuration/DataOverlayParameterBindings.java @@ -20,8 +20,7 @@ public Optional getParameterBinding(ParameterName name) { @Override public String toString() { - return ToStringBuilder - .of(DataOverlayParameterBindings.class) + return ToStringBuilder.of(DataOverlayParameterBindings.class) .addCol("parameters", parameters) .toString(); } diff --git a/application/src/ext/java/org/opentripplanner/ext/dataoverlay/configuration/IndexVariable.java b/application/src/ext/java/org/opentripplanner/ext/dataoverlay/configuration/IndexVariable.java index 720ded65f89..9acd9ef39f4 100644 --- a/application/src/ext/java/org/opentripplanner/ext/dataoverlay/configuration/IndexVariable.java +++ b/application/src/ext/java/org/opentripplanner/ext/dataoverlay/configuration/IndexVariable.java @@ -32,8 +32,7 @@ public String getVariable() { @Override public String toString() { - return ToStringBuilder - .of(IndexVariable.class) + return ToStringBuilder.of(IndexVariable.class) .addStr("name", name) .addStr("displayName", displayName) .addStr("variable", variable) diff --git a/application/src/ext/java/org/opentripplanner/ext/dataoverlay/configuration/ParameterBinding.java b/application/src/ext/java/org/opentripplanner/ext/dataoverlay/configuration/ParameterBinding.java index 07a29d4c4c1..4dfb64ef7c6 100644 --- a/application/src/ext/java/org/opentripplanner/ext/dataoverlay/configuration/ParameterBinding.java +++ b/application/src/ext/java/org/opentripplanner/ext/dataoverlay/configuration/ParameterBinding.java @@ -43,8 +43,7 @@ public String getFormula() { @Override public String toString() { - return ToStringBuilder - .of(Parameter.class) + return ToStringBuilder.of(Parameter.class) .addEnum("name", name) .addStr("variable", variable) .addStr("formula", formula) diff --git a/application/src/ext/java/org/opentripplanner/ext/dataoverlay/routing/Parameter.java b/application/src/ext/java/org/opentripplanner/ext/dataoverlay/routing/Parameter.java index 542f7ee26dc..cec4b6694e0 100644 --- a/application/src/ext/java/org/opentripplanner/ext/dataoverlay/routing/Parameter.java +++ b/application/src/ext/java/org/opentripplanner/ext/dataoverlay/routing/Parameter.java @@ -38,8 +38,7 @@ public String getFormula() { @Override public String toString() { - return ToStringBuilder - .of(Parameter.class) + return ToStringBuilder.of(Parameter.class) .addObj("binding", binding) .addNum("threshold", threshold) .addNum("penalty", penalty) diff --git a/application/src/ext/java/org/opentripplanner/ext/datastore/gs/GsDataSourceRepository.java b/application/src/ext/java/org/opentripplanner/ext/datastore/gs/GsDataSourceRepository.java index f049beef0b8..14020894ec4 100644 --- a/application/src/ext/java/org/opentripplanner/ext/datastore/gs/GsDataSourceRepository.java +++ b/application/src/ext/java/org/opentripplanner/ext/datastore/gs/GsDataSourceRepository.java @@ -94,11 +94,9 @@ private Storage connectToStorage() { StorageOptions.Builder builder = StorageOptions.getDefaultInstance().toBuilder(); if (credentialsFilename != null) { - GoogleCredentials credentials = GoogleCredentials - .fromStream(new FileInputStream(credentialsFilename)) - .createScoped( - Collections.singletonList("https://www.googleapis.com/auth/cloud-platform") - ); + GoogleCredentials credentials = GoogleCredentials.fromStream( + new FileInputStream(credentialsFilename) + ).createScoped(Collections.singletonList("https://www.googleapis.com/auth/cloud-platform")); builder.setCredentials(credentials); } return builder.build().getService(); diff --git a/application/src/ext/java/org/opentripplanner/ext/debugrastertiles/EdgeVertexTileRenderer.java b/application/src/ext/java/org/opentripplanner/ext/debugrastertiles/EdgeVertexTileRenderer.java index 91d8015cb0b..0d8b7d87c90 100644 --- a/application/src/ext/java/org/opentripplanner/ext/debugrastertiles/EdgeVertexTileRenderer.java +++ b/application/src/ext/java/org/opentripplanner/ext/debugrastertiles/EdgeVertexTileRenderer.java @@ -234,12 +234,12 @@ public void renderTile(TileRenderContext context) { } public interface EdgeVertexRenderer { - Comparator defaultVertexComparator = Comparator - .comparing((Vertex v) -> v instanceof StreetVertex) - .reversed(); - Comparator defaultEdgeComparator = Comparator - .comparing((Edge e) -> e.getGeometry() != null) - .thenComparing(e -> e instanceof StreetEdge); + Comparator defaultVertexComparator = Comparator.comparing((Vertex v) -> + v instanceof StreetVertex + ).reversed(); + Comparator defaultEdgeComparator = Comparator.comparing( + (Edge e) -> e.getGeometry() != null + ).thenComparing(e -> e instanceof StreetEdge); /** * @param e The edge being rendered. diff --git a/application/src/ext/java/org/opentripplanner/ext/debugrastertiles/ElevationEdgeRenderer.java b/application/src/ext/java/org/opentripplanner/ext/debugrastertiles/ElevationEdgeRenderer.java index e32bcf9d196..d90b85a5b38 100644 --- a/application/src/ext/java/org/opentripplanner/ext/debugrastertiles/ElevationEdgeRenderer.java +++ b/application/src/ext/java/org/opentripplanner/ext/debugrastertiles/ElevationEdgeRenderer.java @@ -20,12 +20,11 @@ class ElevationEdgeRenderer implements EdgeVertexRenderer { ElevationEdgeRenderer(Graph graph) { if (graph.hasElevation) { - colorPalette = - new DefaultScalarColorPalette( - graph.minElevation, - (graph.minElevation + graph.maxElevation) / 2, - graph.maxElevation - ); + colorPalette = new DefaultScalarColorPalette( + graph.minElevation, + (graph.minElevation + graph.maxElevation) / 2, + graph.maxElevation + ); } else { colorPalette = new DefaultScalarColorPalette(0, 0, 0); } @@ -79,24 +78,23 @@ public Iterable edgeSegments(Edge edge) { } private Double findElevationForVertex(Vertex v) { - return Stream - .concat( - v - .getIncomingStreetEdges() - .stream() - .filter(StreetEdge::hasElevationExtension) - .map(streetEdge -> - streetEdge - .getElevationProfile() - .getCoordinate(streetEdge.getElevationProfile().size() - 1) - .y - ), - v - .getOutgoingStreetEdges() - .stream() - .filter(StreetEdge::hasElevationExtension) - .map(streetEdge -> streetEdge.getElevationProfile().getCoordinate(0).y) - ) + return Stream.concat( + v + .getIncomingStreetEdges() + .stream() + .filter(StreetEdge::hasElevationExtension) + .map(streetEdge -> + streetEdge + .getElevationProfile() + .getCoordinate(streetEdge.getElevationProfile().size() - 1) + .y + ), + v + .getOutgoingStreetEdges() + .stream() + .filter(StreetEdge::hasElevationExtension) + .map(streetEdge -> streetEdge.getElevationProfile().getCoordinate(0).y) + ) .findAny() .orElse(null); } diff --git a/application/src/ext/java/org/opentripplanner/ext/debugrastertiles/TileRendererManager.java b/application/src/ext/java/org/opentripplanner/ext/debugrastertiles/TileRendererManager.java index 7629573906d..86ba655f7e9 100644 --- a/application/src/ext/java/org/opentripplanner/ext/debugrastertiles/TileRendererManager.java +++ b/application/src/ext/java/org/opentripplanner/ext/debugrastertiles/TileRendererManager.java @@ -50,8 +50,8 @@ public BufferedImage renderTile(final MapTile mapTile, String layer) { public Envelope expandPixels(double marginXPixels, double marginYPixels) { Envelope retval = new Envelope(bbox); retval.expandBy( - marginXPixels / mapTile.width() * (bbox.getMaxX() - bbox.getMinX()), - marginYPixels / mapTile.height() * (bbox.getMaxY() - bbox.getMinY()) + (marginXPixels / mapTile.width()) * (bbox.getMaxX() - bbox.getMinX()), + (marginYPixels / mapTile.height()) * (bbox.getMaxY() - bbox.getMinY()) ); return retval; } @@ -79,7 +79,8 @@ public Envelope expandPixels(double marginXPixels, double marginYPixels) { -context.bbox.getMinY() - context.bbox.getHeight() ); context.transform.scale(xScale, -yScale); - context.metersPerPixel = Math.toRadians(context.bbox.getHeight()) * 6371000 / mapTile.height(); + context.metersPerPixel = + (Math.toRadians(context.bbox.getHeight()) * 6371000) / mapTile.height(); context.tileWidth = mapTile.width(); context.tileHeight = mapTile.height(); diff --git a/application/src/ext/java/org/opentripplanner/ext/debugrastertiles/api/resource/DebugRasterTileResource.java b/application/src/ext/java/org/opentripplanner/ext/debugrastertiles/api/resource/DebugRasterTileResource.java index da0d3217a03..d0b1f1d9111 100644 --- a/application/src/ext/java/org/opentripplanner/ext/debugrastertiles/api/resource/DebugRasterTileResource.java +++ b/application/src/ext/java/org/opentripplanner/ext/debugrastertiles/api/resource/DebugRasterTileResource.java @@ -36,11 +36,10 @@ public class DebugRasterTileResource { private final TileRendererManager tileRendererManager; public DebugRasterTileResource(@Context OtpServerRequestContext serverContext) { - this.tileRendererManager = - new TileRendererManager( - serverContext.graph(), - serverContext.defaultRouteRequest().preferences().wheelchair() - ); + this.tileRendererManager = new TileRendererManager( + serverContext.graph(), + serverContext.defaultRouteRequest().preferences().wheelchair() + ); } @GET @@ -61,7 +60,7 @@ public Response tileGet( MIMEImageFormat format = new MIMEImageFormat("image/" + ext); ByteArrayOutputStream baos = new ByteArrayOutputStream( - image.getWidth() * image.getHeight() / 4 + (image.getWidth() * image.getHeight()) / 4 ); ImageIO.write(image, format.type, baos); CacheControl cc = new CacheControl(); diff --git a/application/src/ext/java/org/opentripplanner/ext/emissions/DecorateWithEmission.java b/application/src/ext/java/org/opentripplanner/ext/emissions/DecorateWithEmission.java index 9657e053cb9..603cd2e427b 100644 --- a/application/src/ext/java/org/opentripplanner/ext/emissions/DecorateWithEmission.java +++ b/application/src/ext/java/org/opentripplanner/ext/emissions/DecorateWithEmission.java @@ -69,8 +69,9 @@ private Optional calculateCo2EmissionsForTransit(List transit feedScopedRouteId ); if (co2EmissionsForRoute.isPresent()) { - co2Emissions = - co2Emissions.plus(co2EmissionsForRoute.get().getCo2().multiply(leg.getDistanceMeters())); + co2Emissions = co2Emissions.plus( + co2EmissionsForRoute.get().getCo2().multiply(leg.getDistanceMeters()) + ); } else { // Partial results would not give an accurate representation of the emissions. return Optional.empty(); diff --git a/application/src/ext/java/org/opentripplanner/ext/emissions/EmissionsConfig.java b/application/src/ext/java/org/opentripplanner/ext/emissions/EmissionsConfig.java index 65f02e20e52..6ec143a2db7 100644 --- a/application/src/ext/java/org/opentripplanner/ext/emissions/EmissionsConfig.java +++ b/application/src/ext/java/org/opentripplanner/ext/emissions/EmissionsConfig.java @@ -26,19 +26,17 @@ public EmissionsConfig(String parameterName, NodeAdapter root) { ) .asObject(); - this.carAvgCo2PerKm = - c - .of("carAvgCo2PerKm") - .since(V2_5) - .summary("The average CO₂ emissions of a car in grams per kilometer.") - .asInt(170); - - this.carAvgOccupancy = - c - .of("carAvgOccupancy") - .since(V2_5) - .summary("The average number of passengers in a car.") - .asDouble(1.3); + this.carAvgCo2PerKm = c + .of("carAvgCo2PerKm") + .since(V2_5) + .summary("The average CO₂ emissions of a car in grams per kilometer.") + .asInt(170); + + this.carAvgOccupancy = c + .of("carAvgOccupancy") + .since(V2_5) + .summary("The average number of passengers in a car.") + .asDouble(1.3); } public int getCarAvgCo2PerKm() { diff --git a/application/src/ext/java/org/opentripplanner/ext/fares/impl/DefaultFareService.java b/application/src/ext/java/org/opentripplanner/ext/fares/impl/DefaultFareService.java index 03e6eeff9fd..b94d82a117c 100644 --- a/application/src/ext/java/org/opentripplanner/ext/fares/impl/DefaultFareService.java +++ b/application/src/ext/java/org/opentripplanner/ext/fares/impl/DefaultFareService.java @@ -147,13 +147,11 @@ protected Collection fareRulesForFeed(FareType fareType, String fee .entrySet() .stream() .collect( - Collectors.toMap( - Map.Entry::getKey, - rules -> - rules - .getValue() - .stream() - .collect(Collectors.groupingBy(rule -> rule.getFareAttribute().getId().getFeedId())) + Collectors.toMap(Map.Entry::getKey, rules -> + rules + .getValue() + .stream() + .collect(Collectors.groupingBy(rule -> rule.getFareAttribute().getId().getFeedId())) ) ); return fareRulesByTypeAndFeed.get(fareType).get(feedId); @@ -199,9 +197,11 @@ protected ItineraryFares calculateFaresForType( int via = r.next[start][r.endOfComponent[start]]; float cost = r.resultTable[start][via]; FeedScopedId fareId = r.fareIds[start][via]; - var product = FareProduct - .of(fareId, fareType.name(), Money.ofFractionalAmount(currency, cost)) - .build(); + var product = FareProduct.of( + fareId, + fareType.name(), + Money.ofFractionalAmount(currency, cost) + ).build(); List applicableLegs = new ArrayList<>(); for (int i = start; i <= via; ++i) { @@ -313,9 +313,9 @@ protected Optional getBestFareAndId( } LOG.debug("{} best for {}", bestAttribute, legs); Money finalBestFare = bestFare; - return Optional - .ofNullable(bestAttribute) - .map(attribute -> new FareAndId(finalBestFare, attribute.getId())); + return Optional.ofNullable(bestAttribute).map(attribute -> + new FareAndId(finalBestFare, attribute.getId()) + ); } /** diff --git a/application/src/ext/java/org/opentripplanner/ext/fares/impl/GtfsFaresV2Service.java b/application/src/ext/java/org/opentripplanner/ext/fares/impl/GtfsFaresV2Service.java index 5bff64f05e0..e036183d8cf 100644 --- a/application/src/ext/java/org/opentripplanner/ext/fares/impl/GtfsFaresV2Service.java +++ b/application/src/ext/java/org/opentripplanner/ext/fares/impl/GtfsFaresV2Service.java @@ -111,14 +111,10 @@ private boolean coversItinerary(Itinerary i, LegProducts.ProductWithTransfer pwt return ( allLegsInProductFeed && - ( - transitLegs.size() == 1 || - ( - pwt.products().stream().anyMatch(p -> p.coversDuration(i.getTransitDuration())) && - appliesToAllLegs(pwt.legRule(), transitLegs) - ) || - coversItineraryWithFreeTransfers(i, pwt) - ) + (transitLegs.size() == 1 || + (pwt.products().stream().anyMatch(p -> p.coversDuration(i.getTransitDuration())) && + appliesToAllLegs(pwt.legRule(), transitLegs)) || + coversItineraryWithFreeTransfers(i, pwt)) ); } @@ -235,9 +231,8 @@ private boolean matchesNetworkId(ScheduledTransitLeg leg, FareLegRule rule) { .toList(); return ( - ( - isNull(rule.networkId()) && networksWithRules.stream().noneMatch(routesNetworkIds::contains) - ) || + (isNull(rule.networkId()) && + networksWithRules.stream().noneMatch(routesNetworkIds::contains)) || routesNetworkIds.contains(rule.networkId()) ); } diff --git a/application/src/ext/java/org/opentripplanner/ext/fares/impl/HSLFareService.java b/application/src/ext/java/org/opentripplanner/ext/fares/impl/HSLFareService.java index 6d61e415566..4de8993f3a5 100644 --- a/application/src/ext/java/org/opentripplanner/ext/fares/impl/HSLFareService.java +++ b/application/src/ext/java/org/opentripplanner/ext/fares/impl/HSLFareService.java @@ -105,11 +105,9 @@ but visit temporarily (maybe 1 stop only) an 'external' zone */ } if ( isSpecialRoute || - ( - ruleSet.getRoutes().contains(leg.getRoute().getId()) && + (ruleSet.getRoutes().contains(leg.getRoute().getId()) && ruleSet.getContains().contains(leg.getFrom().stop.getFirstZoneAsString()) && - ruleSet.getContains().contains(leg.getTo().stop.getFirstZoneAsString()) - ) + ruleSet.getContains().contains(leg.getTo().stop.getFirstZoneAsString())) ) { // check validity of this special rule and that it is the cheapest applicable one FareAttribute attribute = ruleSet.getFareAttribute(); @@ -197,8 +195,8 @@ but visit temporarily (maybe 1 stop only) an 'external' zone */ } LOG.debug("HSL {} best for {}", bestAttribute, legs); final Money finalBestFare = bestFare; - return Optional - .ofNullable(bestAttribute) - .map(attribute -> new FareAndId(finalBestFare, attribute.getId())); + return Optional.ofNullable(bestAttribute).map(attribute -> + new FareAndId(finalBestFare, attribute.getId()) + ); } } diff --git a/application/src/ext/java/org/opentripplanner/ext/fares/impl/HighestFareInFreeTransferWindowFareService.java b/application/src/ext/java/org/opentripplanner/ext/fares/impl/HighestFareInFreeTransferWindowFareService.java index 3cc9398f7c7..5e0085b66da 100644 --- a/application/src/ext/java/org/opentripplanner/ext/fares/impl/HighestFareInFreeTransferWindowFareService.java +++ b/application/src/ext/java/org/opentripplanner/ext/fares/impl/HighestFareInFreeTransferWindowFareService.java @@ -77,8 +77,10 @@ protected ItineraryFares calculateFaresForType( if (freeTransferWindowEndTimeEpochSeconds == -1) { // the new transfer window end time should be calculated by adding the ride's start time (which is in // seconds past the epoch) and the number of equivalent seconds in the free transfer window minutes. - freeTransferWindowEndTimeEpochSeconds = - leg.getStartTime().plus(freeTransferWindow).toEpochSecond(); + freeTransferWindowEndTimeEpochSeconds = leg + .getStartTime() + .plus(freeTransferWindow) + .toEpochSecond(); } currentTransferWindowCost = Money.max(currentTransferWindowCost, rideCost.orElse(zero)); diff --git a/application/src/ext/java/org/opentripplanner/ext/fares/impl/HighestFareInFreeTransferWindowFareServiceFactory.java b/application/src/ext/java/org/opentripplanner/ext/fares/impl/HighestFareInFreeTransferWindowFareServiceFactory.java index bb27e2952b7..bf916398670 100644 --- a/application/src/ext/java/org/opentripplanner/ext/fares/impl/HighestFareInFreeTransferWindowFareServiceFactory.java +++ b/application/src/ext/java/org/opentripplanner/ext/fares/impl/HighestFareInFreeTransferWindowFareServiceFactory.java @@ -54,14 +54,16 @@ public void processGtfs(FareRulesData fareRulesData, OtpTransitService transitSe @Override public void configure(JsonNode config) { var adapter = new NodeAdapter(config, null); - freeTransferWindow = - adapter.of("freeTransferWindow").since(NA).summary("TODO").asDuration(freeTransferWindow); + freeTransferWindow = adapter + .of("freeTransferWindow") + .since(NA) + .summary("TODO") + .asDuration(freeTransferWindow); - analyzeInterlinedTransfers = - adapter - .of("analyzeInterlinedTransfers") - .since(NA) - .summary("TODO") - .asBoolean(analyzeInterlinedTransfers); + analyzeInterlinedTransfers = adapter + .of("analyzeInterlinedTransfers") + .since(NA) + .summary("TODO") + .asBoolean(analyzeInterlinedTransfers); } } diff --git a/application/src/ext/java/org/opentripplanner/ext/fares/impl/OrcaFareService.java b/application/src/ext/java/org/opentripplanner/ext/fares/impl/OrcaFareService.java index f2b06309ddd..3d52842a37a 100644 --- a/application/src/ext/java/org/opentripplanner/ext/fares/impl/OrcaFareService.java +++ b/application/src/ext/java/org/opentripplanner/ext/fares/impl/OrcaFareService.java @@ -499,9 +499,11 @@ public ItineraryFares calculateFaresForType( } } if (cost.fractionalAmount().floatValue() < Float.MAX_VALUE) { - var fp = FareProduct - .of(new FeedScopedId(FEED_ID, fareType.name()), fareType.name(), cost) - .build(); + var fp = FareProduct.of( + new FeedScopedId(FEED_ID, fareType.name()), + fareType.name(), + cost + ).build(); fare.addItineraryProducts(List.of(fp)); } return fare; diff --git a/application/src/ext/java/org/opentripplanner/ext/fares/model/FareRule.java b/application/src/ext/java/org/opentripplanner/ext/fares/model/FareRule.java index 3b416ec2a6d..c77b2e25d85 100644 --- a/application/src/ext/java/org/opentripplanner/ext/fares/model/FareRule.java +++ b/application/src/ext/java/org/opentripplanner/ext/fares/model/FareRule.java @@ -59,8 +59,7 @@ public void setContainsId(String containsId) { } public String toString() { - return ToStringBuilder - .of(FareRule.class) + return ToStringBuilder.of(FareRule.class) .addObjOp("route", route, AbstractTransitEntity::getId) .addObj("originId", originId) .addObj("containsId", containsId) diff --git a/application/src/ext/java/org/opentripplanner/ext/flex/FlexAccessEgress.java b/application/src/ext/java/org/opentripplanner/ext/flex/FlexAccessEgress.java index 9ff2b3f67be..d42d9ff5214 100644 --- a/application/src/ext/java/org/opentripplanner/ext/flex/FlexAccessEgress.java +++ b/application/src/ext/java/org/opentripplanner/ext/flex/FlexAccessEgress.java @@ -37,8 +37,10 @@ public FlexAccessEgress( this.trip = Objects.requireNonNull(trip); this.lastState = lastState; this.stopReachedOnBoard = stopReachedOnBoard; - this.routingBookingInfo = - RoutingBookingInfo.of(requestedBookingTime, trip.getPickupBookingInfo(boardStopPosition)); + this.routingBookingInfo = RoutingBookingInfo.of( + requestedBookingTime, + trip.getPickupBookingInfo(boardStopPosition) + ); } public RegularStop stop() { @@ -90,8 +92,7 @@ public int latestArrivalTime(int arrivalTime) { @Override public String toString() { - return ToStringBuilder - .of(FlexAccessEgress.class) + return ToStringBuilder.of(FlexAccessEgress.class) .addNum("boardStopPosition", boardStopPosition) .addNum("alightStopPosition", alightStopPosition) .addObj("durations", pathDurations) diff --git a/application/src/ext/java/org/opentripplanner/ext/flex/FlexRouter.java b/application/src/ext/java/org/opentripplanner/ext/flex/FlexRouter.java index e7f3d3544ab..82bcee4f1e7 100644 --- a/application/src/ext/java/org/opentripplanner/ext/flex/FlexRouter.java +++ b/application/src/ext/java/org/opentripplanner/ext/flex/FlexRouter.java @@ -71,18 +71,21 @@ public FlexRouter( this.streetEgresses = egressTransfers; this.flexIndex = transitService.getFlexIndex(); this.callbackService = new CallbackAdapter(); - this.graphPathToItineraryMapper = - new GraphPathToItineraryMapper( - transitService.getTimeZone(), - graph.streetNotesService, - graph.ellipsoidToGeoidDifference - ); + this.graphPathToItineraryMapper = new GraphPathToItineraryMapper( + transitService.getTimeZone(), + graph.streetNotesService, + graph.ellipsoidToGeoidDifference + ); if (graph.hasStreets) { - this.accessFlexPathCalculator = - new StreetFlexPathCalculator(false, flexParameters.maxFlexTripDuration()); - this.egressFlexPathCalculator = - new StreetFlexPathCalculator(true, flexParameters.maxFlexTripDuration()); + this.accessFlexPathCalculator = new StreetFlexPathCalculator( + false, + flexParameters.maxFlexTripDuration() + ); + this.egressFlexPathCalculator = new StreetFlexPathCalculator( + true, + flexParameters.maxFlexTripDuration() + ); } else { // this is only really useful in tests. in real world scenarios you're unlikely to get useful // results if you don't have streets @@ -94,17 +97,15 @@ public FlexRouter( LocalDate searchDate = LocalDate.ofInstant(requestedTime, tz); this.startOfTime = ServiceDateUtils.asStartOfService(searchDate, tz); this.requestedTime = ServiceDateUtils.secondsSinceStartOfTime(startOfTime, requestedTime); - this.requestedBookingTime = - requestedBookingTime == null - ? RoutingBookingInfo.NOT_SET - : ServiceDateUtils.secondsSinceStartOfTime(startOfTime, requestedBookingTime); - this.dates = - createFlexServiceDates( - transitService, - additionalPastSearchDays, - additionalFutureSearchDays, - searchDate - ); + this.requestedBookingTime = requestedBookingTime == null + ? RoutingBookingInfo.NOT_SET + : ServiceDateUtils.secondsSinceStartOfTime(startOfTime, requestedBookingTime); + this.dates = createFlexServiceDates( + transitService, + additionalPastSearchDays, + additionalFutureSearchDays, + searchDate + ); } public List createFlexOnlyItineraries(boolean arriveBy) { @@ -115,8 +116,7 @@ public List createFlexOnlyItineraries(boolean arriveBy) { accessFlexPathCalculator, egressFlexPathCalculator, flexParameters.maxTransferDuration() - ) - .calculateDirectFlexPaths(streetAccesses, streetEgresses, dates, requestedTime, arriveBy); + ).calculateDirectFlexPaths(streetAccesses, streetEgresses, dates, requestedTime, arriveBy); var itineraries = new ArrayList(); @@ -140,8 +140,7 @@ public Collection createFlexAccesses() { callbackService, accessFlexPathCalculator, flexParameters.maxTransferDuration() - ) - .createFlexAccesses(streetAccesses, dates); + ).createFlexAccesses(streetAccesses, dates); } public Collection createFlexEgresses() { @@ -150,8 +149,7 @@ public Collection createFlexEgresses() { callbackService, egressFlexPathCalculator, flexParameters.maxTransferDuration() - ) - .createFlexEgresses(streetEgresses, dates); + ).createFlexEgresses(streetEgresses, dates); } private List createFlexServiceDates( diff --git a/application/src/ext/java/org/opentripplanner/ext/flex/FlexTripsMapper.java b/application/src/ext/java/org/opentripplanner/ext/flex/FlexTripsMapper.java index 17ce735a447..02aa7618261 100644 --- a/application/src/ext/java/org/opentripplanner/ext/flex/FlexTripsMapper.java +++ b/application/src/ext/java/org/opentripplanner/ext/flex/FlexTripsMapper.java @@ -37,8 +37,7 @@ public class FlexTripsMapper { if (UnscheduledTrip.isUnscheduledTrip(stopTimes)) { var timePenalty = builder.getFlexTimePenalty().getOrDefault(trip, TimePenalty.NONE); result.add( - UnscheduledTrip - .of(trip.getId()) + UnscheduledTrip.of(trip.getId()) .withTrip(trip) .withStopTimes(stopTimes) .withTimePenalty(timePenalty) @@ -69,7 +68,8 @@ public class FlexTripsMapper { private static boolean hasContinuousStops(List stopTimes) { return stopTimes .stream() - .anyMatch(st -> st.getFlexContinuousPickup() != NONE || st.getFlexContinuousDropOff() != NONE + .anyMatch( + st -> st.getFlexContinuousPickup() != NONE || st.getFlexContinuousDropOff() != NONE ); } } diff --git a/application/src/ext/java/org/opentripplanner/ext/flex/FlexibleTransitLeg.java b/application/src/ext/java/org/opentripplanner/ext/flex/FlexibleTransitLeg.java index daf04d51e26..95961d5572e 100644 --- a/application/src/ext/java/org/opentripplanner/ext/flex/FlexibleTransitLeg.java +++ b/application/src/ext/java/org/opentripplanner/ext/flex/FlexibleTransitLeg.java @@ -230,8 +230,7 @@ public FlexibleTransitLegBuilder copy() { */ @Override public String toString() { - return ToStringBuilder - .of(FlexibleTransitLeg.class) + return ToStringBuilder.of(FlexibleTransitLeg.class) .addObj("from", getFrom()) .addObj("to", getTo()) .addTime("startTime", startTime) diff --git a/application/src/ext/java/org/opentripplanner/ext/flex/flexpathcalculator/DirectFlexPathCalculator.java b/application/src/ext/java/org/opentripplanner/ext/flex/flexpathcalculator/DirectFlexPathCalculator.java index 793cd112444..b86531ad098 100644 --- a/application/src/ext/java/org/opentripplanner/ext/flex/flexpathcalculator/DirectFlexPathCalculator.java +++ b/application/src/ext/java/org/opentripplanner/ext/flex/flexpathcalculator/DirectFlexPathCalculator.java @@ -29,14 +29,11 @@ public FlexPath calculateFlexPath( int alightStopPosition ) { double distance = SphericalDistanceLibrary.distance(fromv.getCoordinate(), tov.getCoordinate()); - LineString geometry = GeometryUtils - .getGeometryFactory() + LineString geometry = GeometryUtils.getGeometryFactory() .createLineString(new Coordinate[] { fromv.getCoordinate(), tov.getCoordinate() }); - return new FlexPath( - (int) distance, - (int) (distance / flexSpeed) + DIRECT_EXTRA_TIME, - () -> geometry + return new FlexPath((int) distance, (int) (distance / flexSpeed) + DIRECT_EXTRA_TIME, () -> + geometry ); } } diff --git a/application/src/ext/java/org/opentripplanner/ext/flex/flexpathcalculator/StreetFlexPathCalculator.java b/application/src/ext/java/org/opentripplanner/ext/flex/flexpathcalculator/StreetFlexPathCalculator.java index 597afd9b17a..78913097f11 100644 --- a/application/src/ext/java/org/opentripplanner/ext/flex/flexpathcalculator/StreetFlexPathCalculator.java +++ b/application/src/ext/java/org/opentripplanner/ext/flex/flexpathcalculator/StreetFlexPathCalculator.java @@ -72,10 +72,8 @@ public FlexPath calculateFlexPath( // computing the linestring from the graph path is a surprisingly expensive operation // so we delay it until it's actually needed. since most flex paths are never shown to the user // this improves performance quite a bit. - return new FlexPath( - distance, - duration, - () -> GeometryUtils.concatenateLineStrings(path.edges, Edge::getGeometry) + return new FlexPath(distance, duration, () -> + GeometryUtils.concatenateLineStrings(path.edges, Edge::getGeometry) ); } @@ -83,8 +81,7 @@ private ShortestPathTree routeToMany(Vertex vertex) { RouteRequest routingRequest = new RouteRequest(); routingRequest.setArriveBy(reverseDirection); - return StreetSearchBuilder - .of() + return StreetSearchBuilder.of() .setSkipEdgeStrategy(new DurationSkipEdgeStrategy<>(maxFlexTripDuration)) .setDominanceFunction(new DominanceFunctions.EarliestArrival()) .setRequest(routingRequest) diff --git a/application/src/ext/java/org/opentripplanner/ext/flex/template/AbstractFlexTemplate.java b/application/src/ext/java/org/opentripplanner/ext/flex/template/AbstractFlexTemplate.java index 8dbcf4d785e..b2455fba6c8 100644 --- a/application/src/ext/java/org/opentripplanner/ext/flex/template/AbstractFlexTemplate.java +++ b/application/src/ext/java/org/opentripplanner/ext/flex/template/AbstractFlexTemplate.java @@ -100,9 +100,9 @@ StopLocation getAccessEgressStop() { Stream createFlexAccessEgressStream(FlexAccessEgressCallbackAdapter callback) { if (transferStop instanceof RegularStop stop) { var flexVertex = callback.getStopVertexForStopId(stop.getId()); - return Stream - .of(createFlexAccessEgress(new ArrayList<>(), flexVertex, stop)) - .filter(Objects::nonNull); + return Stream.of(createFlexAccessEgress(new ArrayList<>(), flexVertex, stop)).filter( + Objects::nonNull + ); } // transferStop is Location Area/Line else { @@ -126,8 +126,7 @@ Stream createFlexAccessEgressStream(FlexAccessEgressCallbackAd @Override public String toString() { - return ToStringBuilder - .of(AbstractFlexTemplate.class) + return ToStringBuilder.of(AbstractFlexTemplate.class) .addObj("accessEgress", accessEgress) .addObj("trip", trip) .addNum("boardStopPosition", boardStopPosition) diff --git a/application/src/ext/java/org/opentripplanner/ext/flex/template/ClosestTrip.java b/application/src/ext/java/org/opentripplanner/ext/flex/template/ClosestTrip.java index 553c8aee6c0..c65c62da467 100644 --- a/application/src/ext/java/org/opentripplanner/ext/flex/template/ClosestTrip.java +++ b/application/src/ext/java/org/opentripplanner/ext/flex/template/ClosestTrip.java @@ -127,8 +127,9 @@ private static boolean exceedsLatestBookingTime( FlexServiceDate date, int stopPos ) { - return RoutingBookingInfo - .of(date.requestedBookingTime(), trip.getPickupBookingInfo(stopPos)) - .exceedsLatestBookingTime(); + return RoutingBookingInfo.of( + date.requestedBookingTime(), + trip.getPickupBookingInfo(stopPos) + ).exceedsLatestBookingTime(); } } diff --git a/application/src/ext/java/org/opentripplanner/ext/flex/template/FlexDirectPathFactory.java b/application/src/ext/java/org/opentripplanner/ext/flex/template/FlexDirectPathFactory.java index f27a502911f..ec3f1a95aee 100644 --- a/application/src/ext/java/org/opentripplanner/ext/flex/template/FlexDirectPathFactory.java +++ b/application/src/ext/java/org/opentripplanner/ext/flex/template/FlexDirectPathFactory.java @@ -49,15 +49,13 @@ public Collection calculateDirectFlexPaths( callbackService, accessPathCalculator, maxTransferDuration - ) - .calculateFlexAccessTemplates(streetAccesses, dates); + ).calculateFlexAccessTemplates(streetAccesses, dates); var flexEgressTemplates = new FlexEgressFactory( callbackService, egressPathCalculator, maxTransferDuration - ) - .calculateFlexEgressTemplates(streetEgresses, dates); + ).calculateFlexEgressTemplates(streetEgresses, dates); Multimap streetEgressByStop = HashMultimap.create(); streetEgresses.forEach(it -> streetEgressByStop.put(it.stop, it)); @@ -78,8 +76,9 @@ public Collection calculateDirectFlexPaths( flexEgressTemplates.stream().anyMatch(t -> t.getAccessEgressStop().equals(transferStop)) ) { for (NearbyStop egress : streetEgressByStop.get(transferStop)) { - createDirectGraphPath(template, egress, arriveBy, requestTime) - .ifPresent(directFlexPaths::add); + createDirectGraphPath(template, egress, arriveBy, requestTime).ifPresent( + directFlexPaths::add + ); } } } @@ -154,10 +153,10 @@ private Optional createDirectGraphPath( // Time-shift departure so the minimum-booking-notice restriction is honored. var bookingInfo = trip.getPickupBookingInfo(accessBoardStopPosition); - firstStopDepartureTime = - RoutingBookingInfo - .of(requestedBookingTime, bookingInfo) - .earliestDepartureTime(firstStopDepartureTime); + firstStopDepartureTime = RoutingBookingInfo.of( + requestedBookingTime, + bookingInfo + ).earliestDepartureTime(firstStopDepartureTime); int earliestDepartureTime = trip.earliestDepartureTime( firstStopDepartureTime, diff --git a/application/src/ext/java/org/opentripplanner/ext/flex/template/FlexTemplateFactory.java b/application/src/ext/java/org/opentripplanner/ext/flex/template/FlexTemplateFactory.java index b7a9408af4a..799dd28d92a 100644 --- a/application/src/ext/java/org/opentripplanner/ext/flex/template/FlexTemplateFactory.java +++ b/application/src/ext/java/org/opentripplanner/ext/flex/template/FlexTemplateFactory.java @@ -91,9 +91,10 @@ private List createEgressTemplates() { private boolean isAllowedToBoardAt(int boardStopPosition) { return ( trip.getBoardRule(boardStopPosition).isRoutable() && - !RoutingBookingInfo - .of(date.requestedBookingTime(), trip.getPickupBookingInfo(boardStopPosition)) - .exceedsLatestBookingTime() + !RoutingBookingInfo.of( + date.requestedBookingTime(), + trip.getPickupBookingInfo(boardStopPosition) + ).exceedsLatestBookingTime() ); } diff --git a/application/src/ext/java/org/opentripplanner/ext/flex/trip/ScheduledDeviatedTrip.java b/application/src/ext/java/org/opentripplanner/ext/flex/trip/ScheduledDeviatedTrip.java index ce6404a975b..a0bb5712d40 100644 --- a/application/src/ext/java/org/opentripplanner/ext/flex/trip/ScheduledDeviatedTrip.java +++ b/application/src/ext/java/org/opentripplanner/ext/flex/trip/ScheduledDeviatedTrip.java @@ -107,8 +107,7 @@ public int numberOfStops() { @Override public Set getStops() { - return Arrays - .stream(stopTimes) + return Arrays.stream(stopTimes) .map(scheduledDeviatedStopTime -> scheduledDeviatedStopTime.stop) .collect(Collectors.toSet()); } diff --git a/application/src/ext/java/org/opentripplanner/ext/geocoder/GeocoderResource.java b/application/src/ext/java/org/opentripplanner/ext/geocoder/GeocoderResource.java index 304829843ae..1d781f440a5 100644 --- a/application/src/ext/java/org/opentripplanner/ext/geocoder/GeocoderResource.java +++ b/application/src/ext/java/org/opentripplanner/ext/geocoder/GeocoderResource.java @@ -62,8 +62,7 @@ public Response textSearch( @QueryParam("stops") @DefaultValue("true") boolean stops, @QueryParam("clusters") @DefaultValue("false") boolean clusters ) { - return Response - .status(Response.Status.OK) + return Response.status(Response.Status.OK) .entity(query(query, autocomplete, stops, clusters)) .build(); } diff --git a/application/src/ext/java/org/opentripplanner/ext/geocoder/LuceneIndex.java b/application/src/ext/java/org/opentripplanner/ext/geocoder/LuceneIndex.java index 50452899deb..5ef1bcc3fa5 100644 --- a/application/src/ext/java/org/opentripplanner/ext/geocoder/LuceneIndex.java +++ b/application/src/ext/java/org/opentripplanner/ext/geocoder/LuceneIndex.java @@ -90,15 +90,14 @@ public LuceneIndex( this.transitService = transitService; this.stopClusterMapper = new StopClusterMapper(transitService, stopConsolidationService); - this.analyzer = - new PerFieldAnalyzerWrapper( - new StandardAnalyzer(), - Map.ofEntries( - entry(NAME, new EnglishAnalyzer()), - entry(NAME_NGRAM, new EnglishNGramAnalyzer()), - entry(SUGGEST, new CompletionAnalyzer(new StandardAnalyzer())) - ) - ); + this.analyzer = new PerFieldAnalyzerWrapper( + new StandardAnalyzer(), + Map.ofEntries( + entry(NAME, new EnglishAnalyzer()), + entry(NAME_NGRAM, new EnglishNGramAnalyzer()), + entry(SUGGEST, new CompletionAnalyzer(new StandardAnalyzer())) + ) + ); var directory = new ByteBuffersDirectory(); @@ -166,13 +165,15 @@ public LuceneIndex( } public Stream queryStopLocations(String query, boolean autocomplete) { - return matchingDocuments(StopLocation.class, query, autocomplete) - .map(document -> transitService.getStopLocation(FeedScopedId.parse(document.get(ID)))); + return matchingDocuments(StopLocation.class, query, autocomplete).map(document -> + transitService.getStopLocation(FeedScopedId.parse(document.get(ID))) + ); } public Stream queryStopLocationGroups(String query, boolean autocomplete) { - return matchingDocuments(StopLocationsGroup.class, query, autocomplete) - .map(document -> transitService.getStopLocationsGroup(FeedScopedId.parse(document.get(ID)))); + return matchingDocuments(StopLocationsGroup.class, query, autocomplete).map(document -> + transitService.getStopLocationsGroup(FeedScopedId.parse(document.get(ID))) + ); } /** @@ -192,8 +193,7 @@ private StopCluster toStopCluster(Document document) { var primaryId = FeedScopedId.parse(document.get(ID)); var primary = stopClusterMapper.toLocation(primaryId); - var secondaryIds = Arrays - .stream(document.getValues(SECONDARY_IDS)) + var secondaryIds = Arrays.stream(document.getValues(SECONDARY_IDS)) .map(FeedScopedId::parse) .map(stopClusterMapper::toLocation) .toList(); @@ -281,15 +281,13 @@ private Stream matchingDocuments( var topDocs = searcher.suggest(query, 25, true); - return Arrays - .stream(topDocs.scoreDocs) - .map(scoreDoc -> { - try { - return searcher.storedFields().document(scoreDoc.doc); - } catch (IOException e) { - throw new RuntimeException(e); - } - }); + return Arrays.stream(topDocs.scoreDocs).map(scoreDoc -> { + try { + return searcher.storedFields().document(scoreDoc.doc); + } catch (IOException e) { + throw new RuntimeException(e); + } + }); } else { var nameParser = new QueryParser(NAME_NGRAM, analyzer); var nameQuery = nameParser.parse(searchTerms); @@ -326,15 +324,13 @@ private Stream matchingDocuments( var topDocs = searcher.search(query, 25); - return Arrays - .stream(topDocs.scoreDocs) - .map(scoreDoc -> { - try { - return searcher.storedFields().document(scoreDoc.doc); - } catch (IOException e) { - throw new RuntimeException(e); - } - }); + return Arrays.stream(topDocs.scoreDocs).map(scoreDoc -> { + try { + return searcher.storedFields().document(scoreDoc.doc); + } catch (IOException e) { + throw new RuntimeException(e); + } + }); } } catch (IOException | ParseException ex) { throw new RuntimeException(ex); diff --git a/application/src/ext/java/org/opentripplanner/ext/geocoder/StopClusterMapper.java b/application/src/ext/java/org/opentripplanner/ext/geocoder/StopClusterMapper.java index df9531d4b8b..5d82940148e 100644 --- a/application/src/ext/java/org/opentripplanner/ext/geocoder/StopClusterMapper.java +++ b/application/src/ext/java/org/opentripplanner/ext/geocoder/StopClusterMapper.java @@ -160,17 +160,15 @@ private static Optional map(List stopLocations) var names = getNames(stopLocations); var codes = getCodes(stopLocations); - return Optional - .ofNullable(primary.getName()) - .map(name -> - new LuceneStopCluster( - primary.getId().toString(), - secondaryIds, - names, - codes, - toCoordinate(primary.getCoordinate()) - ) - ); + return Optional.ofNullable(primary.getName()).map(name -> + new LuceneStopCluster( + primary.getId().toString(), + secondaryIds, + names, + codes, + toCoordinate(primary.getCoordinate()) + ) + ); } private List agenciesForStopLocation(StopLocation stop) { diff --git a/application/src/ext/java/org/opentripplanner/ext/parkAndRideApi/ParkAndRideResource.java b/application/src/ext/java/org/opentripplanner/ext/parkAndRideApi/ParkAndRideResource.java index 5fbae4b75d6..7578e26e8f7 100644 --- a/application/src/ext/java/org/opentripplanner/ext/parkAndRideApi/ParkAndRideResource.java +++ b/application/src/ext/java/org/opentripplanner/ext/parkAndRideApi/ParkAndRideResource.java @@ -42,8 +42,9 @@ public ParkAndRideResource( // - serverContext.graphFinder(). This needs at least a comment! // - This can be replaced with a search done with the SiteRepository // - if we have a radius search there. - this.graphFinder = - new DirectGraphFinder(serverContext.transitService()::findRegularStopsByBoundingBox); + this.graphFinder = new DirectGraphFinder( + serverContext.transitService()::findRegularStopsByBoundingBox + ); } /** Envelopes are in latitude, longitude format */ @@ -98,8 +99,7 @@ private boolean hasTransitStopsNearby(Double maxTransitDistance, VehicleParking public record ParkAndRideInfo(String name, double x, double y) { public static ParkAndRideInfo ofVehicleParking(VehicleParking parking) { - var name = Optional - .ofNullable(parking.getName()) + var name = Optional.ofNullable(parking.getName()) .map(I18NString::toString) .orElse(parking.getId().getId()); diff --git a/application/src/ext/java/org/opentripplanner/ext/reportapi/model/GraphReportBuilder.java b/application/src/ext/java/org/opentripplanner/ext/reportapi/model/GraphReportBuilder.java index 338d425db9a..735097814fc 100644 --- a/application/src/ext/java/org/opentripplanner/ext/reportapi/model/GraphReportBuilder.java +++ b/application/src/ext/java/org/opentripplanner/ext/reportapi/model/GraphReportBuilder.java @@ -13,21 +13,18 @@ public static GraphStats build(OtpServerRequestContext context) { var graph = context.graph(); var constrainedTransfers = transitService.getTransferService().listAll(); - var constrainedTransferCounts = countValues( - constrainedTransfers, - transfer -> { - var transferConstraint = transfer.getTransferConstraint(); - if (transferConstraint.isMinTransferTimeSet()) { - return "minTransferTime"; - } else if (transferConstraint.isStaySeated()) { - return "staySeated"; - } else if (transferConstraint.isGuaranteed()) { - return "guaranteed"; - } else if (transferConstraint.isNotAllowed()) { - return "notAllowed"; - } else return "unknown"; - } - ); + var constrainedTransferCounts = countValues(constrainedTransfers, transfer -> { + var transferConstraint = transfer.getTransferConstraint(); + if (transferConstraint.isMinTransferTimeSet()) { + return "minTransferTime"; + } else if (transferConstraint.isStaySeated()) { + return "staySeated"; + } else if (transferConstraint.isGuaranteed()) { + return "guaranteed"; + } else if (transferConstraint.isNotAllowed()) { + return "notAllowed"; + } else return "unknown"; + }); var stopCounts = countValues( transitService.listStopLocations(), diff --git a/application/src/ext/java/org/opentripplanner/ext/reportapi/model/TransfersReport.java b/application/src/ext/java/org/opentripplanner/ext/reportapi/model/TransfersReport.java index e9b5ac8a236..9eadbe862a9 100644 --- a/application/src/ext/java/org/opentripplanner/ext/reportapi/model/TransfersReport.java +++ b/application/src/ext/java/org/opentripplanner/ext/reportapi/model/TransfersReport.java @@ -139,10 +139,9 @@ private static void addLocation( if (trip != null) { var tt = pattern.getScheduledTimetable().getTripTimes(trip); - r.time = - boarding - ? tt.getScheduledDepartureTime(stopPosition) - : tt.getScheduledArrivalTime(stopPosition); + r.time = boarding + ? tt.getScheduledDepartureTime(stopPosition) + : tt.getScheduledArrivalTime(stopPosition); } } diff --git a/application/src/ext/java/org/opentripplanner/ext/reportapi/resource/ReportResource.java b/application/src/ext/java/org/opentripplanner/ext/reportapi/resource/ReportResource.java index 56a224d3d68..ea1fb6e8526 100644 --- a/application/src/ext/java/org/opentripplanner/ext/reportapi/resource/ReportResource.java +++ b/application/src/ext/java/org/opentripplanner/ext/reportapi/resource/ReportResource.java @@ -57,8 +57,7 @@ public String getTransitGroupPriorities() { @GET @Path("/graph.json") public Response stats(@Context OtpServerRequestContext serverRequestContext) { - return Response - .status(Response.Status.OK) + return Response.status(Response.Status.OK) .entity(cachedStats.get(() -> GraphReportBuilder.build(serverRequestContext))) .type("application/json") .build(); diff --git a/application/src/ext/java/org/opentripplanner/ext/restapi/mapping/FareMapper.java b/application/src/ext/java/org/opentripplanner/ext/restapi/mapping/FareMapper.java index 0e9f452b5c1..2ba4d1e4b6d 100644 --- a/application/src/ext/java/org/opentripplanner/ext/restapi/mapping/FareMapper.java +++ b/application/src/ext/java/org/opentripplanner/ext/restapi/mapping/FareMapper.java @@ -63,15 +63,13 @@ private List toApiLegProducts( } private static ApiFareQualifier toApiFareQualifier(@Nullable FareMedium nullable) { - return Optional - .ofNullable(nullable) + return Optional.ofNullable(nullable) .map(c -> new ApiFareQualifier(c.id().getId(), c.name())) .orElse(null); } private static ApiFareQualifier toApiFareQualifier(@Nullable RiderCategory nullable) { - return Optional - .ofNullable(nullable) + return Optional.ofNullable(nullable) .map(c -> new ApiFareQualifier(c.id().getId(), c.name())) .orElse(null); } @@ -81,7 +79,8 @@ private List instancesToApiFareProducts(Collection toApiFareProducts(Collection product) { - if (product.isEmpty()) return null; else { + if (product.isEmpty()) return null; + else { return product .stream() .map(p -> diff --git a/application/src/ext/java/org/opentripplanner/ext/restapi/mapping/LegMapper.java b/application/src/ext/java/org/opentripplanner/ext/restapi/mapping/LegMapper.java index 18d2eebadd1..f97bcef1955 100644 --- a/application/src/ext/java/org/opentripplanner/ext/restapi/mapping/LegMapper.java +++ b/application/src/ext/java/org/opentripplanner/ext/restapi/mapping/LegMapper.java @@ -68,22 +68,20 @@ public ApiLeg mapLeg( api.endTime = GregorianCalendar.from(domain.getEndTime()); // Set the arrival and departure times, even if this is redundant information - api.from = - placeMapper.mapPlace( - domain.getFrom(), - arrivalTimeFromPlace, - domain.getStartTime(), - domain.getBoardStopPosInPattern(), - domain.getBoardingGtfsStopSequence() - ); - api.to = - placeMapper.mapPlace( - domain.getTo(), - domain.getEndTime(), - departureTimeToPlace, - domain.getAlightStopPosInPattern(), - domain.getAlightGtfsStopSequence() - ); + api.from = placeMapper.mapPlace( + domain.getFrom(), + arrivalTimeFromPlace, + domain.getStartTime(), + domain.getBoardStopPosInPattern(), + domain.getBoardingGtfsStopSequence() + ); + api.to = placeMapper.mapPlace( + domain.getTo(), + domain.getEndTime(), + departureTimeToPlace, + domain.getAlightStopPosInPattern(), + domain.getAlightGtfsStopSequence() + ); api.departureDelay = domain.getDepartureDelay(); api.arrivalDelay = domain.getArrivalDelay(); @@ -133,18 +131,19 @@ public ApiLeg mapLeg( api.legGeometry = EncodedPolyline.encode(domain.getLegGeometry()); api.legElevation = mapElevation(domain.getElevationProfile()); api.steps = walkStepMapper.mapWalkSteps(domain.getWalkSteps()); - api.alerts = - concatenateAlerts( - streetNoteMaperMapper.mapToApi(domain.getStreetNotes()), - alertMapper.mapToApi(domain.getTransitAlerts()) - ); + api.alerts = concatenateAlerts( + streetNoteMaperMapper.mapToApi(domain.getStreetNotes()), + alertMapper.mapToApi(domain.getTransitAlerts()) + ); api.boardRule = getBoardAlightMessage(domain.getBoardRule()); api.alightRule = getBoardAlightMessage(domain.getAlightRule()); - api.pickupBookingInfo = - BookingInfoMapper.mapBookingInfoForPickup(domain.getPickupBookingInfo()); - api.dropOffBookingInfo = - BookingInfoMapper.mapBookingInfoForDropOff(domain.getDropOffBookingInfo()); + api.pickupBookingInfo = BookingInfoMapper.mapBookingInfoForPickup( + domain.getPickupBookingInfo() + ); + api.dropOffBookingInfo = BookingInfoMapper.mapBookingInfoForDropOff( + domain.getDropOffBookingInfo() + ); api.rentedBike = domain.getRentedVehicle(); api.walkingBike = domain.getWalkingBike(); diff --git a/application/src/ext/java/org/opentripplanner/ext/restapi/mapping/PlaceMapper.java b/application/src/ext/java/org/opentripplanner/ext/restapi/mapping/PlaceMapper.java index 059b0f93812..768cd396eb9 100644 --- a/application/src/ext/java/org/opentripplanner/ext/restapi/mapping/PlaceMapper.java +++ b/application/src/ext/java/org/opentripplanner/ext/restapi/mapping/PlaceMapper.java @@ -64,12 +64,12 @@ public ApiPlace mapPlace( if (domain.stop != null) { api.stopId = FeedScopedIdMapper.mapToApi(domain.stop.getId()); api.stopCode = domain.stop.getCode(); - api.platformCode = - domain.stop instanceof RegularStop ? ((RegularStop) domain.stop).getPlatformCode() : null; - api.zoneId = - domain.stop instanceof RegularStop - ? ((RegularStop) domain.stop).getFirstZoneAsString() - : null; + api.platformCode = domain.stop instanceof RegularStop + ? ((RegularStop) domain.stop).getPlatformCode() + : null; + api.zoneId = domain.stop instanceof RegularStop + ? ((RegularStop) domain.stop).getFirstZoneAsString() + : null; } if (domain.coordinate != null) { @@ -101,8 +101,7 @@ private static ApiVehicleParkingSpaces mapVehicleParkingSpaces( return null; } - return ApiVehicleParkingSpaces - .builder() + return ApiVehicleParkingSpaces.builder() .bicycleSpaces(parkingSpaces.getBicycleSpaces()) .carSpaces(parkingSpaces.getCarSpaces()) .wheelchairAccessibleCarSpaces(parkingSpaces.getWheelchairAccessibleCarSpaces()) @@ -115,8 +114,7 @@ private ApiVehicleParkingWithEntrance mapVehicleParking( var vp = vehicleParkingWithEntrance.getVehicleParking(); var e = vehicleParkingWithEntrance.getEntrance(); - return ApiVehicleParkingWithEntrance - .builder() + return ApiVehicleParkingWithEntrance.builder() .id(FeedScopedIdMapper.mapToApi(vp.getId())) .name(i18NStringMapper.mapToApi(vp.getName())) .entranceId(FeedScopedIdMapper.mapToApi(e.getEntranceId())) diff --git a/application/src/ext/java/org/opentripplanner/ext/restapi/mapping/RouteMapper.java b/application/src/ext/java/org/opentripplanner/ext/restapi/mapping/RouteMapper.java index decee369a17..f6a32532238 100644 --- a/application/src/ext/java/org/opentripplanner/ext/restapi/mapping/RouteMapper.java +++ b/application/src/ext/java/org/opentripplanner/ext/restapi/mapping/RouteMapper.java @@ -29,10 +29,9 @@ public static ApiRoute mapToApi(Route domain) { api.shortName = domain.getShortName(); api.longName = stringMapper.mapToApi(domain.getLongName()); api.mode = ModeMapper.mapToApi(domain.getMode()); - api.type = - domain.getGtfsType() != null - ? domain.getGtfsType() - : RouteTypeMapper.mapToApi(domain.getMode()); + api.type = domain.getGtfsType() != null + ? domain.getGtfsType() + : RouteTypeMapper.mapToApi(domain.getMode()); api.desc = domain.getDescription(); api.url = domain.getUrl(); api.color = domain.getColor(); diff --git a/application/src/ext/java/org/opentripplanner/ext/restapi/mapping/StopMapper.java b/application/src/ext/java/org/opentripplanner/ext/restapi/mapping/StopMapper.java index 9e3c8b04262..e183fdc44f6 100644 --- a/application/src/ext/java/org/opentripplanner/ext/restapi/mapping/StopMapper.java +++ b/application/src/ext/java/org/opentripplanner/ext/restapi/mapping/StopMapper.java @@ -41,8 +41,9 @@ public static ApiStop mapToApi(StopLocation domain, boolean extended) { api.stationId = FeedScopedIdMapper.mapIdToApi(domain.getParentStation()); api.parentStation = mapToParentStationOldId(domain); //api.stopTimezone = stop.getTimezone(); - api.wheelchairBoarding = - WheelchairAccessibilityMapper.mapToApi(domain.getWheelchairAccessibility()); + api.wheelchairBoarding = WheelchairAccessibilityMapper.mapToApi( + domain.getWheelchairAccessibility() + ); //api.direction = stop.getDirection(); } return api; diff --git a/application/src/ext/java/org/opentripplanner/ext/restapi/mapping/WalkStepMapper.java b/application/src/ext/java/org/opentripplanner/ext/restapi/mapping/WalkStepMapper.java index c4aa11904cc..1c1aa48f589 100644 --- a/application/src/ext/java/org/opentripplanner/ext/restapi/mapping/WalkStepMapper.java +++ b/application/src/ext/java/org/opentripplanner/ext/restapi/mapping/WalkStepMapper.java @@ -37,8 +37,10 @@ public ApiWalkStep mapWalkStep(WalkStep domain) { api.distance = domain.getDistance(); api.relativeDirection = mapRelativeDirection(domain.getRelativeDirection()); api.streetName = domain.getDirectionText().toString(locale); - api.absoluteDirection = - domain.getAbsoluteDirection().map(AbsoluteDirectionMapper::mapAbsoluteDirection).orElse(null); + api.absoluteDirection = domain + .getAbsoluteDirection() + .map(AbsoluteDirectionMapper::mapAbsoluteDirection) + .orElse(null); api.exit = domain.highwayExit().orElse(null); api.stayOn = domain.isStayOn(); api.area = domain.getArea(); diff --git a/application/src/ext/java/org/opentripplanner/ext/restapi/model/ApiBookingInfo.java b/application/src/ext/java/org/opentripplanner/ext/restapi/model/ApiBookingInfo.java index 1fd4566a9b8..830321a3737 100644 --- a/application/src/ext/java/org/opentripplanner/ext/restapi/model/ApiBookingInfo.java +++ b/application/src/ext/java/org/opentripplanner/ext/restapi/model/ApiBookingInfo.java @@ -92,8 +92,7 @@ public ApiBookingInfo( @Override public String toString() { - return ToStringBuilder - .of(getClass()) + return ToStringBuilder.of(getClass()) .addObj("contactInfo", contactInfo) .addCol("bookingMethods", bookingMethods) .addObj("earliestBookingTime", earliestBookingTime) diff --git a/application/src/ext/java/org/opentripplanner/ext/restapi/model/ApiContactInfo.java b/application/src/ext/java/org/opentripplanner/ext/restapi/model/ApiContactInfo.java index cc7e6d069f1..ef57bb0f7e5 100644 --- a/application/src/ext/java/org/opentripplanner/ext/restapi/model/ApiContactInfo.java +++ b/application/src/ext/java/org/opentripplanner/ext/restapi/model/ApiContactInfo.java @@ -63,8 +63,7 @@ public ApiContactInfo( @Override public String toString() { - return ToStringBuilder - .of(getClass()) + return ToStringBuilder.of(getClass()) .addStr("contactPerson", contactPerson) .addStr("phoneNumber", phoneNumber) .addStr("eMail", eMail) diff --git a/application/src/ext/java/org/opentripplanner/ext/restapi/model/ApiRouterInfo.java b/application/src/ext/java/org/opentripplanner/ext/restapi/model/ApiRouterInfo.java index 87ac08a7d8b..e552900cd25 100644 --- a/application/src/ext/java/org/opentripplanner/ext/restapi/model/ApiRouterInfo.java +++ b/application/src/ext/java/org/opentripplanner/ext/restapi/model/ApiRouterInfo.java @@ -49,13 +49,12 @@ public ApiRouterInfo( this.hasCarPark = mapHasCarPark(vehicleParkingService); this.hasParkRide = this.hasCarPark; this.hasVehicleParking = mapHasVehicleParking(vehicleParkingService); - this.travelOptions = - ApiTravelOptionsMaker.makeOptions( - graph, - vehicleRentalService, - vehicleParkingService, - transitService - ); + this.travelOptions = ApiTravelOptionsMaker.makeOptions( + graph, + vehicleRentalService, + vehicleParkingService, + transitService + ); } public boolean mapHasBikeSharing(VehicleRentalService service) { diff --git a/application/src/ext/java/org/opentripplanner/ext/restapi/resources/PlannerResource.java b/application/src/ext/java/org/opentripplanner/ext/restapi/resources/PlannerResource.java index f160f0427b9..1d5b97087b5 100644 --- a/application/src/ext/java/org/opentripplanner/ext/restapi/resources/PlannerResource.java +++ b/application/src/ext/java/org/opentripplanner/ext/restapi/resources/PlannerResource.java @@ -85,8 +85,8 @@ public Response plan(@Context UriInfo uriInfo, @Context Request grizzlyRequest) /* Populate up the elevation metadata */ response.elevationMetadata = new ElevationMetadata(); - response.elevationMetadata.ellipsoidToGeoidDifference = - serverContext.graph().ellipsoidToGeoidDifference; + response.elevationMetadata.ellipsoidToGeoidDifference = serverContext.graph() + .ellipsoidToGeoidDifference; response.elevationMetadata.geoidElevation = request.preferences().system().geoidElevation(); response.debugOutput = res.getDebugTimingAggregator().finishedRendering(); diff --git a/application/src/ext/java/org/opentripplanner/ext/restapi/resources/RequestToPreferencesMapper.java b/application/src/ext/java/org/opentripplanner/ext/restapi/resources/RequestToPreferencesMapper.java index 22aa194d4bb..9c37c0bdade 100644 --- a/application/src/ext/java/org/opentripplanner/ext/restapi/resources/RequestToPreferencesMapper.java +++ b/application/src/ext/java/org/opentripplanner/ext/restapi/resources/RequestToPreferencesMapper.java @@ -68,9 +68,8 @@ private void mapBike() { setIfNotNull(req.bikeSpeed, bike::withSpeed); setIfNotNull(req.bikeReluctance, bike::withReluctance); setIfNotNull(req.bikeBoardCost, bike::withBoardCost); - setIfNotNull( - req.bikeOptimizeType, - optimizeType -> bike.withOptimizeType(LegacyVehicleRoutingOptimizeType.map(optimizeType)) + setIfNotNull(req.bikeOptimizeType, optimizeType -> + bike.withOptimizeType(LegacyVehicleRoutingOptimizeType.map(optimizeType)) ); if (req.bikeOptimizeType == LegacyVehicleRoutingOptimizeType.TRIANGLE) { @@ -100,9 +99,8 @@ private void mapScooter() { preferences.withScooter(scooter -> { setIfNotNull(req.bikeSpeed, scooter::withSpeed); setIfNotNull(req.bikeReluctance, scooter::withReluctance); - setIfNotNull( - req.bikeOptimizeType, - optimizeType -> scooter.withOptimizeType(LegacyVehicleRoutingOptimizeType.map(optimizeType)) + setIfNotNull(req.bikeOptimizeType, optimizeType -> + scooter.withOptimizeType(LegacyVehicleRoutingOptimizeType.map(optimizeType)) ); if (req.bikeOptimizeType == LegacyVehicleRoutingOptimizeType.TRIANGLE) { @@ -127,9 +125,8 @@ private BoardAndAlightSlack mapTransit() { if (req.relaxTransitGroupPriority != null) { tr.withRelaxTransitGroupPriority(CostLinearFunction.of(req.relaxTransitGroupPriority)); } else { - setIfNotNull( - req.relaxTransitSearchGeneralizedCostAtDestination, - v -> tr.withRaptor(r -> r.withRelaxGeneralizedCostAtDestination(v)) + setIfNotNull(req.relaxTransitSearchGeneralizedCostAtDestination, v -> + tr.withRaptor(r -> r.withRelaxGeneralizedCostAtDestination(v)) ); } }); @@ -168,9 +165,8 @@ private void mapRental(VehicleRentalPreferences.Builder rental) { setIfNotNull(req.allowedVehicleRentalNetworks, rental::withAllowedNetworks); setIfNotNull(req.bannedVehicleRentalNetworks, rental::withBannedNetworks); - setIfNotNull( - req.keepingRentedBicycleAtDestinationCost, - cost -> rental.withArrivingInRentalVehicleAtDestinationCost((int) Math.round(cost)) + setIfNotNull(req.keepingRentedBicycleAtDestinationCost, cost -> + rental.withArrivingInRentalVehicleAtDestinationCost((int) Math.round(cost)) ); rental.withUseAvailabilityInformation(isPlannedForNow); } @@ -185,9 +181,8 @@ private void mapItineraryFilter() { filter::withGroupedOtherThanSameLegsMaxCostMultiplier ); filter.withTransitGeneralizedCostLimit(mapTransitGeneralizedCostFilterParams(filter)); - setIfNotNull( - req.nonTransitGeneralizedCostLimitFunction, - it -> filter.withNonTransitGeneralizedCostLimit(CostLinearFunction.of(it)) + setIfNotNull(req.nonTransitGeneralizedCostLimitFunction, it -> + filter.withNonTransitGeneralizedCostLimit(CostLinearFunction.of(it)) ); }); } diff --git a/application/src/ext/java/org/opentripplanner/ext/restapi/resources/RoutingResource.java b/application/src/ext/java/org/opentripplanner/ext/restapi/resources/RoutingResource.java index 9a0f030a807..36d3f9e2bdd 100644 --- a/application/src/ext/java/org/opentripplanner/ext/restapi/resources/RoutingResource.java +++ b/application/src/ext/java/org/opentripplanner/ext/restapi/resources/RoutingResource.java @@ -769,27 +769,23 @@ protected RouteRequest buildRequest(MultivaluedMap queryParamete setIfNotNull(bannedTrips, journey.transit()::setBannedTripsFromString); // Excluded entities - setIfNotNull( - bannedAgencies, - s -> filterBuilder.addNot(SelectRequest.of().withAgenciesFromString(s).build()) + setIfNotNull(bannedAgencies, s -> + filterBuilder.addNot(SelectRequest.of().withAgenciesFromString(s).build()) ); - setIfNotNull( - bannedRoutes, - s -> filterBuilder.addNot(SelectRequest.of().withRoutesFromString(s).build()) + setIfNotNull(bannedRoutes, s -> + filterBuilder.addNot(SelectRequest.of().withRoutesFromString(s).build()) ); // Included entities var selectors = new ArrayList(); - setIfNotNull( - whiteListedAgencies, - s -> selectors.add(SelectRequest.of().withAgenciesFromString(s)) + setIfNotNull(whiteListedAgencies, s -> + selectors.add(SelectRequest.of().withAgenciesFromString(s)) ); - setIfNotNull( - whiteListedRoutes, - s -> selectors.add(SelectRequest.of().withRoutesFromString(s)) + setIfNotNull(whiteListedRoutes, s -> + selectors.add(SelectRequest.of().withRoutesFromString(s)) ); List tModes; diff --git a/application/src/ext/java/org/opentripplanner/ext/restapi/serialization/JSONObjectMapperProvider.java b/application/src/ext/java/org/opentripplanner/ext/restapi/serialization/JSONObjectMapperProvider.java index e271e945ca1..8c6adfb44f2 100644 --- a/application/src/ext/java/org/opentripplanner/ext/restapi/serialization/JSONObjectMapperProvider.java +++ b/application/src/ext/java/org/opentripplanner/ext/restapi/serialization/JSONObjectMapperProvider.java @@ -54,11 +54,10 @@ public JSONObjectMapperProvider() { // Our module includes a single class-serializer relationship. // Constructors are available for both unnamed, unversioned throwaway modules // and named, versioned reusable modules. - mapper = - new ObjectMapper() - .registerModule(FeedScopedIdSerializer.makeModule()) - .registerModule(new JtsModule()) - .setSerializationInclusion(Include.NON_NULL); // skip null fields + mapper = new ObjectMapper() + .registerModule(FeedScopedIdSerializer.makeModule()) + .registerModule(new JtsModule()) + .setSerializationInclusion(Include.NON_NULL); // skip null fields } /** diff --git a/application/src/ext/java/org/opentripplanner/ext/ridehailing/CachingRideHailingService.java b/application/src/ext/java/org/opentripplanner/ext/ridehailing/CachingRideHailingService.java index 553d9135796..410b51210b6 100644 --- a/application/src/ext/java/org/opentripplanner/ext/ridehailing/CachingRideHailingService.java +++ b/application/src/ext/java/org/opentripplanner/ext/ridehailing/CachingRideHailingService.java @@ -19,14 +19,11 @@ public abstract class CachingRideHailingService implements RideHailingService { // This value should be no longer than 30 minutes (according to Uber API docs) TODO check Lyft time limit private static final Duration CACHE_DURATION = Duration.ofMinutes(2); - private final Cache> arrivalTimeCache = CacheBuilder - .newBuilder() - .expireAfterWrite(CACHE_DURATION) - .build(); - private final Cache> rideEstimateCache = CacheBuilder - .newBuilder() + private final Cache> arrivalTimeCache = CacheBuilder.newBuilder() .expireAfterWrite(CACHE_DURATION) .build(); + private final Cache> rideEstimateCache = + CacheBuilder.newBuilder().expireAfterWrite(CACHE_DURATION).build(); /** * Get the next arrivals for a specific location. @@ -34,9 +31,8 @@ public abstract class CachingRideHailingService implements RideHailingService { @Override public List arrivalTimes(WgsCoordinate coordinate, boolean wheelchairAccessible) throws ExecutionException { - return arrivalTimeCache.get( - coordinate.roundToApproximate10m(), - () -> queryArrivalTimes(coordinate, wheelchairAccessible) + return arrivalTimeCache.get(coordinate.roundToApproximate10m(), () -> + queryArrivalTimes(coordinate, wheelchairAccessible) ); } diff --git a/application/src/ext/java/org/opentripplanner/ext/ridehailing/RideHailingAccessShifter.java b/application/src/ext/java/org/opentripplanner/ext/ridehailing/RideHailingAccessShifter.java index 5e4eee09920..bf7c54a6f38 100644 --- a/application/src/ext/java/org/opentripplanner/ext/ridehailing/RideHailingAccessShifter.java +++ b/application/src/ext/java/org/opentripplanner/ext/ridehailing/RideHailingAccessShifter.java @@ -52,8 +52,6 @@ public static List shiftAccesses( } else { return null; } - // if it is an egress leg, we pretend that it arrives on time, - // and we don't need to time-shift } else { return ae; } diff --git a/application/src/ext/java/org/opentripplanner/ext/ridehailing/service/oauth/CachedOAuthToken.java b/application/src/ext/java/org/opentripplanner/ext/ridehailing/service/oauth/CachedOAuthToken.java index 56487a9bd6e..a96e858cca5 100644 --- a/application/src/ext/java/org/opentripplanner/ext/ridehailing/service/oauth/CachedOAuthToken.java +++ b/application/src/ext/java/org/opentripplanner/ext/ridehailing/service/oauth/CachedOAuthToken.java @@ -24,8 +24,8 @@ public CachedOAuthToken(SerializedOAuthToken token) { value = token.access_token(); // Expire the token one minute before the actual expiry, e.g. to cover // long API calls or calls over slow networks near the expiration time. - tokenExpirationTime = - Instant.now().plus(Duration.ofSeconds(token.expires_in()).minusMinutes(1)); + tokenExpirationTime = Instant.now() + .plus(Duration.ofSeconds(token.expires_in()).minusMinutes(1)); } /** diff --git a/application/src/ext/java/org/opentripplanner/ext/ridehailing/service/oauth/CachingOAuthService.java b/application/src/ext/java/org/opentripplanner/ext/ridehailing/service/oauth/CachingOAuthService.java index c477e637e97..73c8fee418f 100644 --- a/application/src/ext/java/org/opentripplanner/ext/ridehailing/service/oauth/CachingOAuthService.java +++ b/application/src/ext/java/org/opentripplanner/ext/ridehailing/service/oauth/CachingOAuthService.java @@ -30,8 +30,7 @@ public String getToken() throws IOException { try { var request = oauthTokenRequest(); LOG.info("Requesting new {} access token", request.uri()); - var response = HttpClient - .newHttpClient() + var response = HttpClient.newHttpClient() .send(request, HttpResponse.BodyHandlers.ofString()); if (response.statusCode() != 200) { diff --git a/application/src/ext/java/org/opentripplanner/ext/ridehailing/service/oauth/UrlEncodedOAuthService.java b/application/src/ext/java/org/opentripplanner/ext/ridehailing/service/oauth/UrlEncodedOAuthService.java index 52e2451c7e8..f40042822aa 100644 --- a/application/src/ext/java/org/opentripplanner/ext/ridehailing/service/oauth/UrlEncodedOAuthService.java +++ b/application/src/ext/java/org/opentripplanner/ext/ridehailing/service/oauth/UrlEncodedOAuthService.java @@ -21,8 +21,7 @@ public UrlEncodedOAuthService(String clientSecret, String clientId, String scope @Override protected HttpRequest oauthTokenRequest() { - return HttpRequest - .newBuilder(uri) + return HttpRequest.newBuilder(uri) .POST(HttpRequest.BodyPublishers.ofString(authRequest.toRequestParamString())) .header(CONTENT_TYPE, "application/x-www-form-urlencoded") .build(); diff --git a/application/src/ext/java/org/opentripplanner/ext/ridehailing/service/uber/UberService.java b/application/src/ext/java/org/opentripplanner/ext/ridehailing/service/uber/UberService.java index d5ab1e8c5fa..9f846a444d4 100644 --- a/application/src/ext/java/org/opentripplanner/ext/ridehailing/service/uber/UberService.java +++ b/application/src/ext/java/org/opentripplanner/ext/ridehailing/service/uber/UberService.java @@ -94,12 +94,10 @@ public List queryArrivalTimes(WgsCoordinate coord, boolean wheelcha var finalUri = uri; if (uri.getScheme().equalsIgnoreCase("https")) { - finalUri = - UriBuilder - .fromUri(uri) - .queryParam("start_latitude", coord.latitude()) - .queryParam("start_longitude", coord.longitude()) - .build(); + finalUri = UriBuilder.fromUri(uri) + .queryParam("start_latitude", coord.latitude()) + .queryParam("start_longitude", coord.longitude()) + .build(); } LOG.info("Made arrival time request to Uber API at following URL: {}", uri); @@ -137,14 +135,12 @@ public List queryRideEstimates(RideEstimateRequest request) throws var finalUri = uri; if (uri.getScheme().equalsIgnoreCase("https")) { - finalUri = - UriBuilder - .fromUri(uri) - .queryParam("start_latitude", request.startPosition().latitude()) - .queryParam("start_longitude", request.startPosition().longitude()) - .queryParam("end_latitude", request.endPosition().latitude()) - .queryParam("end_longitude", request.endPosition().longitude()) - .build(); + finalUri = UriBuilder.fromUri(uri) + .queryParam("start_latitude", request.startPosition().latitude()) + .queryParam("start_longitude", request.startPosition().longitude()) + .queryParam("end_latitude", request.endPosition().latitude()) + .queryParam("end_longitude", request.endPosition().longitude()) + .build(); } LOG.info("Made price estimate request to Uber API at following URL: {}", uri); diff --git a/application/src/ext/java/org/opentripplanner/ext/siri/updater/azure/SiriAzureSXUpdater.java b/application/src/ext/java/org/opentripplanner/ext/siri/updater/azure/SiriAzureSXUpdater.java index 6cec89ab346..a1fb95e2003 100644 --- a/application/src/ext/java/org/opentripplanner/ext/siri/updater/azure/SiriAzureSXUpdater.java +++ b/application/src/ext/java/org/opentripplanner/ext/siri/updater/azure/SiriAzureSXUpdater.java @@ -26,8 +26,11 @@ public SiriAzureSXUpdater( TimetableRepository timetableRepository ) { this.transitAlertService = new TransitAlertServiceImpl(timetableRepository); - this.updateHandler = - new SiriAlertsUpdateHandler(config.feedId(), transitAlertService, Duration.ZERO); + this.updateHandler = new SiriAlertsUpdateHandler( + config.feedId(), + transitAlertService, + Duration.ZERO + ); } @Override diff --git a/application/src/ext/java/org/opentripplanner/ext/siri/updater/azure/SiriAzureUpdater.java b/application/src/ext/java/org/opentripplanner/ext/siri/updater/azure/SiriAzureUpdater.java index 9e5ff9a8499..884efec7ee5 100644 --- a/application/src/ext/java/org/opentripplanner/ext/siri/updater/azure/SiriAzureUpdater.java +++ b/application/src/ext/java/org/opentripplanner/ext/siri/updater/azure/SiriAzureUpdater.java @@ -118,8 +118,10 @@ interface CheckedRunnable { } this.configRef = Objects.requireNonNull(config.configRef(), "configRef must not be null"); - this.authenticationType = - Objects.requireNonNull(config.getAuthenticationType(), "authenticationType must not be null"); + this.authenticationType = Objects.requireNonNull( + config.getAuthenticationType(), + "authenticationType must not be null" + ); this.topicName = Objects.requireNonNull(config.getTopicName(), "topicName must not be null"); this.updaterType = Objects.requireNonNull(config.getType(), "type must not be null"); this.timeout = config.getTimeout(); @@ -127,18 +129,16 @@ interface CheckedRunnable { this.prefetchCount = config.getPrefetchCount(); if (authenticationType == AuthenticationType.FederatedIdentity) { - this.fullyQualifiedNamespace = - Objects.requireNonNull( - config.getFullyQualifiedNamespace(), - "fullyQualifiedNamespace must not be null when using FederatedIdentity authentication" - ); + this.fullyQualifiedNamespace = Objects.requireNonNull( + config.getFullyQualifiedNamespace(), + "fullyQualifiedNamespace must not be null when using FederatedIdentity authentication" + ); this.serviceBusUrl = null; } else if (authenticationType == AuthenticationType.SharedAccessKey) { - this.serviceBusUrl = - Objects.requireNonNull( - config.getServiceBusUrl(), - "serviceBusUrl must not be null when using SharedAccessKey authentication" - ); + this.serviceBusUrl = Objects.requireNonNull( + config.getServiceBusUrl(), + "serviceBusUrl must not be null when using SharedAccessKey authentication" + ); this.fullyQualifiedNamespace = null; } else { throw new IllegalArgumentException("Unsupported authentication type: " + authenticationType); @@ -193,19 +193,16 @@ public void run() { setPrimed(); - ApplicationShutdownSupport.addShutdownHook( - "azure-siri-updater-shutdown", - () -> { - LOG.info("Calling shutdownHook on AbstractAzureSiriUpdater"); - if (eventProcessor != null) { - eventProcessor.close(); - } - if (serviceBusAdmin != null) { - serviceBusAdmin.deleteSubscription(topicName, subscriptionName).block(); - LOG.info("Subscription '{}' deleted on topic '{}'.", subscriptionName, topicName); - } + ApplicationShutdownSupport.addShutdownHook("azure-siri-updater-shutdown", () -> { + LOG.info("Calling shutdownHook on AbstractAzureSiriUpdater"); + if (eventProcessor != null) { + eventProcessor.close(); } - ); + if (serviceBusAdmin != null) { + serviceBusAdmin.deleteSubscription(topicName, subscriptionName).block(); + LOG.info("Subscription '{}' deleted on topic '{}'.", subscriptionName, topicName); + } + }); } catch (ServiceBusException e) { LOG.error("Service Bus encountered an error during setup: {}", e.getMessage(), e); } catch (URISyntaxException e) { @@ -299,15 +296,13 @@ boolean shouldRetry(Exception e) { private void setupSubscription() throws ServiceBusException, URISyntaxException { // Client with permissions to create subscription if (authenticationType == AuthenticationType.FederatedIdentity) { - serviceBusAdmin = - new ServiceBusAdministrationClientBuilder() - .credential(fullyQualifiedNamespace, new DefaultAzureCredentialBuilder().build()) - .buildAsyncClient(); + serviceBusAdmin = new ServiceBusAdministrationClientBuilder() + .credential(fullyQualifiedNamespace, new DefaultAzureCredentialBuilder().build()) + .buildAsyncClient(); } else if (authenticationType == AuthenticationType.SharedAccessKey) { - serviceBusAdmin = - new ServiceBusAdministrationClientBuilder() - .connectionString(serviceBusUrl) - .buildAsyncClient(); + serviceBusAdmin = new ServiceBusAdministrationClientBuilder() + .connectionString(serviceBusUrl) + .buildAsyncClient(); } // Set options @@ -357,17 +352,16 @@ private void startEventProcessor() throws ServiceBusException { throw new IllegalArgumentException("Unsupported authentication type: " + authenticationType); } - eventProcessor = - clientBuilder - .processor() - .topicName(topicName) - .subscriptionName(subscriptionName) - .receiveMode(ServiceBusReceiveMode.RECEIVE_AND_DELETE) - .disableAutoComplete() // Receive and delete does not need autocomplete - .prefetchCount(prefetchCount) - .processError(this::errorConsumer) - .processMessage(this::handleMessage) - .buildProcessorClient(); + eventProcessor = clientBuilder + .processor() + .topicName(topicName) + .subscriptionName(subscriptionName) + .receiveMode(ServiceBusReceiveMode.RECEIVE_AND_DELETE) + .disableAutoComplete() // Receive and delete does not need autocomplete + .prefetchCount(prefetchCount) + .processError(this::errorConsumer) + .processMessage(this::handleMessage) + .buildProcessorClient(); eventProcessor.start(); LOG.info( diff --git a/application/src/ext/java/org/opentripplanner/ext/smoovebikerental/SmooveBikeRentalDataSource.java b/application/src/ext/java/org/opentripplanner/ext/smoovebikerental/SmooveBikeRentalDataSource.java index b65c22b4727..5657a50204c 100644 --- a/application/src/ext/java/org/opentripplanner/ext/smoovebikerental/SmooveBikeRentalDataSource.java +++ b/application/src/ext/java/org/opentripplanner/ext/smoovebikerental/SmooveBikeRentalDataSource.java @@ -47,24 +47,23 @@ public SmooveBikeRentalDataSource( networkName = config.getNetwork(DEFAULT_NETWORK_NAME); vehicleType = RentalVehicleType.getDefaultType(networkName); overloadingAllowed = config.overloadingAllowed(); - system = - new VehicleRentalSystem( - networkName, - "fi", - "Helsinki/Espoo", - null, - null, - null, - null, - null, - null, - null, - null, - "Europe/Helsinki", - null, - null, - null - ); + system = new VehicleRentalSystem( + networkName, + "fi", + "Helsinki/Espoo", + null, + null, + null, + null, + null, + null, + null, + null, + "Europe/Helsinki", + null, + null, + null + ); } /** diff --git a/application/src/ext/java/org/opentripplanner/ext/sorlandsbanen/SorlandsbanenNorwayService.java b/application/src/ext/java/org/opentripplanner/ext/sorlandsbanen/SorlandsbanenNorwayService.java index 1bb4ca49261..90abefdd12f 100644 --- a/application/src/ext/java/org/opentripplanner/ext/sorlandsbanen/SorlandsbanenNorwayService.java +++ b/application/src/ext/java/org/opentripplanner/ext/sorlandsbanen/SorlandsbanenNorwayService.java @@ -70,7 +70,11 @@ public RaptorTransitDataProvider createTransitDataAlternativeSearc } @Override - public BiFunction>, Collection>, Collection>> merger() { + public BiFunction< + Collection>, + Collection>, + Collection> + > merger() { return new MergePaths<>(); } }; diff --git a/application/src/ext/java/org/opentripplanner/ext/stopconsolidation/StopConsolidationParser.java b/application/src/ext/java/org/opentripplanner/ext/stopconsolidation/StopConsolidationParser.java index 0c01a280968..d19a041d435 100644 --- a/application/src/ext/java/org/opentripplanner/ext/stopconsolidation/StopConsolidationParser.java +++ b/application/src/ext/java/org/opentripplanner/ext/stopconsolidation/StopConsolidationParser.java @@ -37,10 +37,11 @@ public static List parseGroups(InputStream is) { var groups = entries .stream() .collect( - ImmutableListMultimap.flatteningToImmutableListMultimap( - x -> x.groupId, - Stream::of - ) + ImmutableListMultimap.< + StopGroupEntry, + String, + StopGroupEntry + >flatteningToImmutableListMultimap(x -> x.groupId, Stream::of) ); return groups diff --git a/application/src/ext/java/org/opentripplanner/ext/vectortiles/layers/areastops/AreaStopsLayerBuilder.java b/application/src/ext/java/org/opentripplanner/ext/vectortiles/layers/areastops/AreaStopsLayerBuilder.java index 31952752dbc..5be004bc211 100644 --- a/application/src/ext/java/org/opentripplanner/ext/vectortiles/layers/areastops/AreaStopsLayerBuilder.java +++ b/application/src/ext/java/org/opentripplanner/ext/vectortiles/layers/areastops/AreaStopsLayerBuilder.java @@ -15,10 +15,8 @@ public class AreaStopsLayerBuilder extends LayerBuilder { - static Map>> mappers = Map.of( - MapperType.OTPRR, - AreaStopPropertyMapper::create - ); + static Map>> mappers = + Map.of(MapperType.OTPRR, AreaStopPropertyMapper::create); private final TransitService transitService; public AreaStopsLayerBuilder( diff --git a/application/src/ext/java/org/opentripplanner/ext/vectortiles/layers/stations/StationsLayerBuilder.java b/application/src/ext/java/org/opentripplanner/ext/vectortiles/layers/stations/StationsLayerBuilder.java index c157621a740..6e794e22aa4 100644 --- a/application/src/ext/java/org/opentripplanner/ext/vectortiles/layers/stations/StationsLayerBuilder.java +++ b/application/src/ext/java/org/opentripplanner/ext/vectortiles/layers/stations/StationsLayerBuilder.java @@ -19,10 +19,8 @@ public class StationsLayerBuilder extends LayerBuilder { - static Map>> mappers = Map.of( - MapperType.Digitransit, - DigitransitStationPropertyMapper::create - ); + static Map>> mappers = + Map.of(MapperType.Digitransit, DigitransitStationPropertyMapper::create); private final TransitService transitService; public StationsLayerBuilder( diff --git a/application/src/ext/java/org/opentripplanner/ext/vectortiles/layers/stops/StopsLayerBuilder.java b/application/src/ext/java/org/opentripplanner/ext/vectortiles/layers/stops/StopsLayerBuilder.java index c1e03cdefca..60a31d2886d 100644 --- a/application/src/ext/java/org/opentripplanner/ext/vectortiles/layers/stops/StopsLayerBuilder.java +++ b/application/src/ext/java/org/opentripplanner/ext/vectortiles/layers/stops/StopsLayerBuilder.java @@ -26,15 +26,13 @@ public StopsLayerBuilder( Locale locale ) { super( - Map - .ofEntries( - entry(MapperType.Digitransit, new DigitransitStopPropertyMapper(transitService, locale)), - entry( - MapperType.DigitransitRealtime, - new DigitransitRealtimeStopPropertyMapper(transitService, locale) - ) + Map.ofEntries( + entry(MapperType.Digitransit, new DigitransitStopPropertyMapper(transitService, locale)), + entry( + MapperType.DigitransitRealtime, + new DigitransitRealtimeStopPropertyMapper(transitService, locale) ) - .get(MapperType.valueOf(layerParameters.mapper())), + ).get(MapperType.valueOf(layerParameters.mapper())), layerParameters.name(), layerParameters.expansionFactor() ); diff --git a/application/src/ext/java/org/opentripplanner/ext/vectortiles/layers/vehicleparkings/VehicleParkingGroupsLayerBuilder.java b/application/src/ext/java/org/opentripplanner/ext/vectortiles/layers/vehicleparkings/VehicleParkingGroupsLayerBuilder.java index 36217e05972..8be04678cd2 100644 --- a/application/src/ext/java/org/opentripplanner/ext/vectortiles/layers/vehicleparkings/VehicleParkingGroupsLayerBuilder.java +++ b/application/src/ext/java/org/opentripplanner/ext/vectortiles/layers/vehicleparkings/VehicleParkingGroupsLayerBuilder.java @@ -17,7 +17,10 @@ public class VehicleParkingGroupsLayerBuilder extends LayerBuilder { - static Map>> mappers = Map.of( + static Map< + VehicleParkingGroupsLayerBuilder.MapperType, + Function> + > mappers = Map.of( VehicleParkingGroupsLayerBuilder.MapperType.Digitransit, DigitransitVehicleParkingGroupPropertyMapper::create ); diff --git a/application/src/ext/java/org/opentripplanner/ext/vectortiles/layers/vehicleparkings/VehicleParkingsLayerBuilder.java b/application/src/ext/java/org/opentripplanner/ext/vectortiles/layers/vehicleparkings/VehicleParkingsLayerBuilder.java index ea569c7a295..ae89e7a2ae1 100644 --- a/application/src/ext/java/org/opentripplanner/ext/vectortiles/layers/vehicleparkings/VehicleParkingsLayerBuilder.java +++ b/application/src/ext/java/org/opentripplanner/ext/vectortiles/layers/vehicleparkings/VehicleParkingsLayerBuilder.java @@ -21,7 +21,10 @@ public class VehicleParkingsLayerBuilder extends LayerBuilder { - static Map>> mappers = Map.ofEntries( + static Map< + VehicleParkingsLayerBuilder.MapperType, + Function> + > mappers = Map.ofEntries( entry( VehicleParkingsLayerBuilder.MapperType.Stadtnavi, StadtnaviVehicleParkingPropertyMapper::create diff --git a/application/src/ext/java/org/opentripplanner/ext/vehicleparking/bikeep/BikeepUpdater.java b/application/src/ext/java/org/opentripplanner/ext/vehicleparking/bikeep/BikeepUpdater.java index decbda7abf6..e8a3cecbfc5 100644 --- a/application/src/ext/java/org/opentripplanner/ext/vehicleparking/bikeep/BikeepUpdater.java +++ b/application/src/ext/java/org/opentripplanner/ext/vehicleparking/bikeep/BikeepUpdater.java @@ -20,8 +20,7 @@ public class BikeepUpdater extends GenericJsonDataSource { private static final String JSON_PARSE_PATH = "features"; - private static final ObjectReader STRING_LIST_READER = ObjectMappers - .ignoringExtraFields() + private static final ObjectReader STRING_LIST_READER = ObjectMappers.ignoringExtraFields() .readerForListOf(String.class); private final BikeepUpdaterParameters params; @@ -43,12 +42,10 @@ protected VehicleParking parseElement(JsonNode jsonNode) { List tags = STRING_LIST_READER.readValue(props.path("tags")); - var availability = VehicleParkingSpaces - .builder() + var availability = VehicleParkingSpaces.builder() .bicycleSpaces(parking.get("available").asInt()) .build(); - var capacity = VehicleParkingSpaces - .builder() + var capacity = VehicleParkingSpaces.builder() .bicycleSpaces(parking.get("total").asInt()) .build(); @@ -59,8 +56,7 @@ protected VehicleParking parseElement(JsonNode jsonNode) { .walkAccessible(true) .carAccessible(true); - return VehicleParking - .builder() + return VehicleParking.builder() .id(vehicleParkId) .name(name) .state(VehicleParkingState.OPERATIONAL) @@ -78,8 +74,7 @@ protected VehicleParking parseElement(JsonNode jsonNode) { @Override public String toString() { - return ToStringBuilder - .of(this.getClass()) + return ToStringBuilder.of(this.getClass()) .addStr("feedId", this.params.feedId()) .addStr("url", this.params.url().toString()) .toString(); diff --git a/application/src/ext/java/org/opentripplanner/ext/vehicleparking/bikely/BikelyUpdater.java b/application/src/ext/java/org/opentripplanner/ext/vehicleparking/bikely/BikelyUpdater.java index eba0547dbf5..3fcb9cb7b88 100644 --- a/application/src/ext/java/org/opentripplanner/ext/vehicleparking/bikely/BikelyUpdater.java +++ b/application/src/ext/java/org/opentripplanner/ext/vehicleparking/bikely/BikelyUpdater.java @@ -38,8 +38,7 @@ public class BikelyUpdater implements DataSource { private static final String JSON_PARSE_PATH = "result"; private static final Currency NOK = Currency.getInstance("NOK"); private static final ObjectMapper OBJECT_MAPPER = ObjectMappers.ignoringExtraFields(); - private static final ObjectNode POST_PARAMS = OBJECT_MAPPER - .createObjectNode() + private static final ObjectNode POST_PARAMS = OBJECT_MAPPER.createObjectNode() .put("groupPins", true) .put("lonMin", 0) .put("lonMax", 0) @@ -55,28 +54,26 @@ public BikelyUpdater(BikelyUpdaterParameters parameters) { @Override public boolean update() { - this.lots = - httpClient.postJsonAndMap( - parameters.url(), - POST_PARAMS, - Duration.ofSeconds(30), - parameters.httpHeaders().asMap(), - is -> { - try { - var lots = new ArrayList(); - OBJECT_MAPPER - .readTree(is) - .path(JSON_PARSE_PATH) - .forEach(node -> lots.add(parseElement(node))); - - return lots.stream().filter(Objects::nonNull).toList(); - } catch (Exception e) { - LOG.error("Could not get Bikely updates", e); - } - - return List.of(); + this.lots = httpClient.postJsonAndMap( + parameters.url(), + POST_PARAMS, + Duration.ofSeconds(30), + parameters.httpHeaders().asMap(), + is -> { + try { + var lots = new ArrayList(); + OBJECT_MAPPER.readTree(is) + .path(JSON_PARSE_PATH) + .forEach(node -> lots.add(parseElement(node))); + + return lots.stream().filter(Objects::nonNull).toList(); + } catch (Exception e) { + LOG.error("Could not get Bikely updates", e); } - ); + + return List.of(); + } + ); return true; } @@ -111,8 +108,7 @@ private VehicleParking parseElement(JsonNode jsonNode) { .walkAccessible(true) .carAccessible(false); - return VehicleParking - .builder() + return VehicleParking.builder() .id(vehicleParkId) .name(name) .bicyclePlaces(true) @@ -149,6 +145,7 @@ private static LocalizedString toNote(JsonNode price) { } private static VehicleParkingState toState(boolean isUnderMaintenance) { - if (isUnderMaintenance) return VehicleParkingState.TEMPORARILY_CLOSED; else return OPERATIONAL; + if (isUnderMaintenance) return VehicleParkingState.TEMPORARILY_CLOSED; + else return OPERATIONAL; } } diff --git a/application/src/ext/java/org/opentripplanner/ext/vehicleparking/liipi/LiipiFacilitiesDownloader.java b/application/src/ext/java/org/opentripplanner/ext/vehicleparking/liipi/LiipiFacilitiesDownloader.java index 202d7dcf23c..880379a50e6 100644 --- a/application/src/ext/java/org/opentripplanner/ext/vehicleparking/liipi/LiipiFacilitiesDownloader.java +++ b/application/src/ext/java/org/opentripplanner/ext/vehicleparking/liipi/LiipiFacilitiesDownloader.java @@ -25,7 +25,11 @@ public class LiipiFacilitiesDownloader { private static final ObjectMapper mapper = new ObjectMapper(); private final String jsonParsePath; - private final BiFunction, VehicleParking> facilitiesParser; + private final BiFunction< + JsonNode, + Map, + VehicleParking + > facilitiesParser; private final String url; private final OtpHttpClient otpHttpClient; @@ -50,22 +54,18 @@ public List downloadFacilities( } try { - return otpHttpClient.getAndMap( - URI.create(url), - Map.of(), - is -> { - try { - return parseJSON(is, hubForPark); - } catch (IllegalArgumentException e) { - LOG.warn("Error parsing facilities from {}", url, e); - } catch (JsonProcessingException e) { - LOG.warn("Error parsing facilities from {} (bad JSON of some sort)", url, e); - } catch (IOException e) { - LOG.warn("Error reading facilities from {}", url, e); - } - return null; + return otpHttpClient.getAndMap(URI.create(url), Map.of(), is -> { + try { + return parseJSON(is, hubForPark); + } catch (IllegalArgumentException e) { + LOG.warn("Error parsing facilities from {}", url, e); + } catch (JsonProcessingException e) { + LOG.warn("Error parsing facilities from {} (bad JSON of some sort)", url, e); + } catch (IOException e) { + LOG.warn("Error reading facilities from {}", url, e); } - ); + return null; + }); } catch (OtpHttpClientException e) { LOG.warn("Failed to get data from url {}", url); return null; diff --git a/application/src/ext/java/org/opentripplanner/ext/vehicleparking/liipi/LiipiHubToVehicleParkingGroupMapper.java b/application/src/ext/java/org/opentripplanner/ext/vehicleparking/liipi/LiipiHubToVehicleParkingGroupMapper.java index 3d7600dff54..c6ae5afa0f8 100644 --- a/application/src/ext/java/org/opentripplanner/ext/vehicleparking/liipi/LiipiHubToVehicleParkingGroupMapper.java +++ b/application/src/ext/java/org/opentripplanner/ext/vehicleparking/liipi/LiipiHubToVehicleParkingGroupMapper.java @@ -54,8 +54,7 @@ public Map parseHub(JsonNode jsonNode) { ? new NonLocalizedString(hubId.getId()) : TranslatedString.getI18NString(translations, true, false); Geometry geometry = GEOMETRY_PARSER.geometryFromJson(jsonNode.path("location")); - var vehicleParkingGroup = VehicleParkingGroup - .of(hubId) + var vehicleParkingGroup = VehicleParkingGroup.of(hubId) .withName(name) .withCoordinate(new WgsCoordinate(geometry.getCentroid())) .build(); diff --git a/application/src/ext/java/org/opentripplanner/ext/vehicleparking/liipi/LiipiHubsDownloader.java b/application/src/ext/java/org/opentripplanner/ext/vehicleparking/liipi/LiipiHubsDownloader.java index f7dcebe6485..0f4e32ea460 100644 --- a/application/src/ext/java/org/opentripplanner/ext/vehicleparking/liipi/LiipiHubsDownloader.java +++ b/application/src/ext/java/org/opentripplanner/ext/vehicleparking/liipi/LiipiHubsDownloader.java @@ -45,22 +45,18 @@ public Map downloadHubs() { return null; } try { - return otpHttpClient.getAndMap( - URI.create(url), - Map.of(), - is -> { - try { - return parseJSON(is); - } catch (IllegalArgumentException e) { - LOG.warn("Error parsing hubs from {}", url, e); - } catch (JsonProcessingException e) { - LOG.warn("Error parsing hubs from {} (bad JSON of some sort)", url, e); - } catch (IOException e) { - LOG.warn("Error reading hubs from {}", url, e); - } - return null; + return otpHttpClient.getAndMap(URI.create(url), Map.of(), is -> { + try { + return parseJSON(is); + } catch (IllegalArgumentException e) { + LOG.warn("Error parsing hubs from {}", url, e); + } catch (JsonProcessingException e) { + LOG.warn("Error parsing hubs from {} (bad JSON of some sort)", url, e); + } catch (IOException e) { + LOG.warn("Error reading hubs from {}", url, e); } - ); + return null; + }); } catch (OtpHttpClientException e) { LOG.warn("Failed to get data from url {}", url); return null; diff --git a/application/src/ext/java/org/opentripplanner/ext/vehicleparking/liipi/LiipiParkToVehicleParkingMapper.java b/application/src/ext/java/org/opentripplanner/ext/vehicleparking/liipi/LiipiParkToVehicleParkingMapper.java index 28a8da41f40..21776bd318b 100644 --- a/application/src/ext/java/org/opentripplanner/ext/vehicleparking/liipi/LiipiParkToVehicleParkingMapper.java +++ b/application/src/ext/java/org/opentripplanner/ext/vehicleparking/liipi/LiipiParkToVehicleParkingMapper.java @@ -109,8 +109,7 @@ public VehicleParking parsePark( var openingHoursCalendar = parseOpeningHours(openingHoursByDayType); VehicleParkingGroup vehicleParkingGroup = hubForPark.get(vehicleParkId); - return VehicleParking - .builder() + return VehicleParking.builder() .id(vehicleParkId) .name(name) .state(state) @@ -159,8 +158,7 @@ private VehicleParkingSpaces createVehiclePlaces( Integer wheelchairAccessibleCarSpaces, Integer bicycleSpaces ) { - return VehicleParkingSpaces - .builder() + return VehicleParkingSpaces.builder() .bicycleSpaces(bicycleSpaces) .carSpaces(carSpaces) .wheelchairAccessibleCarSpaces(wheelchairAccessibleCarSpaces) diff --git a/application/src/ext/java/org/opentripplanner/ext/vehicleparking/liipi/LiipiParkUpdater.java b/application/src/ext/java/org/opentripplanner/ext/vehicleparking/liipi/LiipiParkUpdater.java index 04ea86cf3fb..73cc73aea0c 100644 --- a/application/src/ext/java/org/opentripplanner/ext/vehicleparking/liipi/LiipiParkUpdater.java +++ b/application/src/ext/java/org/opentripplanner/ext/vehicleparking/liipi/LiipiParkUpdater.java @@ -43,37 +43,33 @@ public LiipiParkUpdater( OpeningHoursCalendarService openingHoursCalendarService ) { String feedId = parameters.feedId(); - vehicleParkingMapper = - new LiipiParkToVehicleParkingMapper( - feedId, - openingHoursCalendarService, - parameters.timeZone() - ); + vehicleParkingMapper = new LiipiParkToVehicleParkingMapper( + feedId, + openingHoursCalendarService, + parameters.timeZone() + ); vehicleParkingGroupMapper = new LiipiHubToVehicleParkingGroupMapper(feedId); parkPatchMapper = new LiipiParkUtilizationToPatchMapper(feedId); var otpHttpClientFactory = new OtpHttpClientFactory(); - facilitiesDownloader = - new LiipiFacilitiesDownloader( - parameters.facilitiesUrl(), - JSON_PARSE_PATH, - vehicleParkingMapper::parsePark, - otpHttpClientFactory - ); - hubsDownloader = - new LiipiHubsDownloader( - parameters.hubsUrl(), - JSON_PARSE_PATH, - vehicleParkingGroupMapper::parseHub, - otpHttpClientFactory - ); - utilizationsDownloader = - new JsonDataListDownloader<>( - parameters.utilizationsUrl(), - "", - parkPatchMapper::parseUtilization, - Map.of(), - otpHttpClientFactory.create(LOG) - ); + facilitiesDownloader = new LiipiFacilitiesDownloader( + parameters.facilitiesUrl(), + JSON_PARSE_PATH, + vehicleParkingMapper::parsePark, + otpHttpClientFactory + ); + hubsDownloader = new LiipiHubsDownloader( + parameters.hubsUrl(), + JSON_PARSE_PATH, + vehicleParkingGroupMapper::parseHub, + otpHttpClientFactory + ); + utilizationsDownloader = new JsonDataListDownloader<>( + parameters.utilizationsUrl(), + "", + parkPatchMapper::parseUtilization, + Map.of(), + otpHttpClientFactory.create(LOG) + ); this.facilitiesFrequencySec = parameters.facilitiesFrequencySec(); } diff --git a/application/src/ext/java/org/opentripplanner/ext/vehicleparking/parkapi/ParkAPIUpdater.java b/application/src/ext/java/org/opentripplanner/ext/vehicleparking/parkapi/ParkAPIUpdater.java index 3e206fc660d..38b11d3730b 100644 --- a/application/src/ext/java/org/opentripplanner/ext/vehicleparking/parkapi/ParkAPIUpdater.java +++ b/application/src/ext/java/org/opentripplanner/ext/vehicleparking/parkapi/ParkAPIUpdater.java @@ -46,8 +46,10 @@ public ParkAPIUpdater( super(parameters.url(), JSON_PARSE_PATH, parameters.httpHeaders()); this.feedId = parameters.feedId(); this.staticTags = parameters.tags(); - this.osmOpeningHoursParser = - new OsmOpeningHoursParser(openingHoursCalendarService, parameters.timeZone()); + this.osmOpeningHoursParser = new OsmOpeningHoursParser( + openingHoursCalendarService, + parameters.timeZone() + ); this.url = parameters.url(); } @@ -96,8 +98,7 @@ protected VehicleParking parseElement(JsonNode jsonNode) { .map(c -> hasPlaces(capacity.getWheelchairAccessibleCarSpaces())) .orElse(false); - return VehicleParking - .builder() + return VehicleParking.builder() .id(vehicleParkId) .name(new NonLocalizedString(jsonNode.path("name").asText())) .state(state) @@ -142,8 +143,7 @@ private VehicleParkingSpaces createVehiclePlaces( Integer wheelchairAccessibleCarSpaces, Integer bicycleSpaces ) { - return VehicleParkingSpaces - .builder() + return VehicleParkingSpaces.builder() .bicycleSpaces(bicycleSpaces) .carSpaces(carSpaces) .wheelchairAccessibleCarSpaces(wheelchairAccessibleCarSpaces) @@ -179,13 +179,12 @@ private FeedScopedId createIdForNode(JsonNode jsonNode) { if (jsonNode.has("id")) { id = jsonNode.path("id").asText(); } else { - id = - String.format( - "%s/%f/%f", - jsonNode.get("name"), - jsonNode.path("coords").path("lng").asDouble(), - jsonNode.path("coords").path("lat").asDouble() - ); + id = String.format( + "%s/%f/%f", + jsonNode.get("name"), + jsonNode.path("coords").path("lng").asDouble(), + jsonNode.path("coords").path("lat").asDouble() + ); } return new FeedScopedId(feedId, id); } diff --git a/application/src/ext/java/org/opentripplanner/ext/vehicleparking/sirifm/SiriFmDatasource.java b/application/src/ext/java/org/opentripplanner/ext/vehicleparking/sirifm/SiriFmDatasource.java index e05cfdb42ad..ffc9531b300 100644 --- a/application/src/ext/java/org/opentripplanner/ext/vehicleparking/sirifm/SiriFmDatasource.java +++ b/application/src/ext/java/org/opentripplanner/ext/vehicleparking/sirifm/SiriFmDatasource.java @@ -37,30 +37,23 @@ public SiriFmDatasource(SiriFmUpdaterParameters parameters) { @Override public String toString() { - return ToStringBuilder - .of(this.getClass()) + return ToStringBuilder.of(this.getClass()) .addStr("url", this.params.url().toString()) .toString(); } @Override public boolean update() { - updates = - httpClient.getAndMap( - params.url(), - headers, - resp -> { - var siri = SiriXml.parseXml(resp); + updates = httpClient.getAndMap(params.url(), headers, resp -> { + var siri = SiriXml.parseXml(resp); - return Stream - .ofNullable(siri.getServiceDelivery()) - .flatMap(sd -> sd.getFacilityMonitoringDeliveries().stream()) - .flatMap(d -> d.getFacilityConditions().stream()) - .filter(this::conformsToItalianProfile) - .map(this::mapToUpdate) - .toList(); - } - ); + return Stream.ofNullable(siri.getServiceDelivery()) + .flatMap(sd -> sd.getFacilityMonitoringDeliveries().stream()) + .flatMap(d -> d.getFacilityConditions().stream()) + .filter(this::conformsToItalianProfile) + .map(this::mapToUpdate) + .toList(); + }); return true; } diff --git a/application/src/ext/java/org/opentripplanner/ext/vehiclerentalservicedirectory/api/VehicleRentalServiceDirectoryFetcherParameters.java b/application/src/ext/java/org/opentripplanner/ext/vehiclerentalservicedirectory/api/VehicleRentalServiceDirectoryFetcherParameters.java index 9b67114b499..eec06aab2fc 100644 --- a/application/src/ext/java/org/opentripplanner/ext/vehiclerentalservicedirectory/api/VehicleRentalServiceDirectoryFetcherParameters.java +++ b/application/src/ext/java/org/opentripplanner/ext/vehiclerentalservicedirectory/api/VehicleRentalServiceDirectoryFetcherParameters.java @@ -43,8 +43,9 @@ public VehicleRentalServiceDirectoryFetcherParameters( this.sourceNetworkName = networkName; this.language = language; this.headers = headers; - this.parametersForNetwork = - networkParameters.stream().collect(Collectors.toMap(NetworkParameters::network, it -> it)); + this.parametersForNetwork = networkParameters + .stream() + .collect(Collectors.toMap(NetworkParameters::network, it -> it)); this.defaultNetwork = parametersForNetwork.get(DEFAULT_NETWORK_NAME); } diff --git a/application/src/main/java/com/jhlabs/awt/TextStroke.java b/application/src/main/java/com/jhlabs/awt/TextStroke.java index c5f15dbfe86..2d69802f28d 100644 --- a/application/src/main/java/com/jhlabs/awt/TextStroke.java +++ b/application/src/main/java/com/jhlabs/awt/TextStroke.java @@ -97,13 +97,12 @@ public Shape createStrokedShape(Shape shape) { float x = lastX + next * dx * r; float y = lastY + next * dy * r; float advance = nextAdvance; - nextAdvance = - currentChar < length - 1 - ? glyphVector.getGlyphMetrics(currentChar + 1).getAdvance() * 0.5f - : 0; + nextAdvance = currentChar < length - 1 + ? glyphVector.getGlyphMetrics(currentChar + 1).getAdvance() * 0.5f + : 0; t.setToTranslation(x, y); t.rotate(angle); - t.translate(-px - advance, -py + height * factor / 2.0f); + t.translate(-px - advance, -py + (height * factor) / 2.0f); result.append(t.createTransformedShape(glyph), false); next += (advance + nextAdvance) * factor; currentChar++; diff --git a/application/src/main/java/org/opentripplanner/api/common/OTPExceptionMapper.java b/application/src/main/java/org/opentripplanner/api/common/OTPExceptionMapper.java index b7399fe46da..a34e7460084 100644 --- a/application/src/main/java/org/opentripplanner/api/common/OTPExceptionMapper.java +++ b/application/src/main/java/org/opentripplanner/api/common/OTPExceptionMapper.java @@ -27,28 +27,24 @@ public Response toResponse(Exception ex) { } else if (ex instanceof NotFoundException) { header = "FOUR ZERO FOUR\n\n"; } - return Response - .fromResponse(((WebApplicationException) ex).getResponse()) + return Response.fromResponse(((WebApplicationException) ex).getResponse()) .entity(header + ex.getMessage()) .build(); } if (ex instanceof OtpAppException) { - return Response - .status(Response.Status.INTERNAL_SERVER_ERROR) + return Response.status(Response.Status.INTERNAL_SERVER_ERROR) .entity("OTP Application error: " + ex.getMessage()) .type("text/plain") .build(); } if (ex instanceof OTPRequestTimeoutException) { - return Response - .status(OtpHttpStatus.STATUS_UNPROCESSABLE_ENTITY) + return Response.status(OtpHttpStatus.STATUS_UNPROCESSABLE_ENTITY) .entity("OTP API Processing Timeout") .type("text/plain") .build(); } if (ex instanceof JsonParseException || ex instanceof MismatchedInputException) { - return Response - .status(Response.Status.BAD_REQUEST) + return Response.status(Response.Status.BAD_REQUEST) .entity(ex.getMessage()) .type("text/plain") .build(); @@ -57,8 +53,7 @@ public Response toResponse(Exception ex) { // Show the exception in the server log LOG.error("Unhandled exception", ex); // Return the short form message to the client - return Response - .serverError() + return Response.serverError() .entity(ex.toString() + " " + ex.getMessage()) .type("text/plain") .build(); diff --git a/application/src/main/java/org/opentripplanner/api/parameter/QualifiedModeSet.java b/application/src/main/java/org/opentripplanner/api/parameter/QualifiedModeSet.java index 98ce58c6d21..6a4dc756640 100644 --- a/application/src/main/java/org/opentripplanner/api/parameter/QualifiedModeSet.java +++ b/application/src/main/java/org/opentripplanner/api/parameter/QualifiedModeSet.java @@ -52,11 +52,12 @@ public RequestModes getRequestModes() { List filteredModes = qModes .stream() - .filter(m -> - m.mode == ApiRequestMode.WALK || - m.mode == ApiRequestMode.BICYCLE || - m.mode == ApiRequestMode.SCOOTER || - m.mode == ApiRequestMode.CAR + .filter( + m -> + m.mode == ApiRequestMode.WALK || + m.mode == ApiRequestMode.BICYCLE || + m.mode == ApiRequestMode.SCOOTER || + m.mode == ApiRequestMode.CAR ) .toList(); diff --git a/application/src/main/java/org/opentripplanner/api/resource/UpdaterStatusResource.java b/application/src/main/java/org/opentripplanner/api/resource/UpdaterStatusResource.java index d90b7c6a32a..193e689c0ed 100644 --- a/application/src/main/java/org/opentripplanner/api/resource/UpdaterStatusResource.java +++ b/application/src/main/java/org/opentripplanner/api/resource/UpdaterStatusResource.java @@ -38,8 +38,7 @@ public Response getUpdaters() { if (updaterStatus == null) { return Response.status(Response.Status.NOT_FOUND).entity("No updaters running.").build(); } - return Response - .status(Response.Status.OK) + return Response.status(Response.Status.OK) .entity(updaterStatus.getUpdaterDescriptions()) .build(); } diff --git a/application/src/main/java/org/opentripplanner/api/resource/WebMercatorTile.java b/application/src/main/java/org/opentripplanner/api/resource/WebMercatorTile.java index 081d5f56839..f871155b07d 100644 --- a/application/src/main/java/org/opentripplanner/api/resource/WebMercatorTile.java +++ b/application/src/main/java/org/opentripplanner/api/resource/WebMercatorTile.java @@ -20,7 +20,7 @@ public static Envelope tile2Envelope(int x, int y, int zoom) { } private static double tile2lon(int x, int z) { - return x / Math.pow(2.0, z) * 360.0 - 180; + return (x / Math.pow(2.0, z)) * 360.0 - 180; } private static double tile2lat(int y, int z) { diff --git a/application/src/main/java/org/opentripplanner/apis/gtfs/DefaultValueInjector.java b/application/src/main/java/org/opentripplanner/apis/gtfs/DefaultValueInjector.java index 172ad530a60..a0478af0367 100644 --- a/application/src/main/java/org/opentripplanner/apis/gtfs/DefaultValueInjector.java +++ b/application/src/main/java/org/opentripplanner/apis/gtfs/DefaultValueInjector.java @@ -233,32 +233,28 @@ private static void setModeDefaults( builder .enumListReq( "PlanModesInput.direct", - StreetModeMapper - .getStreetModesForApi(journey.direct().mode()) + StreetModeMapper.getStreetModesForApi(journey.direct().mode()) .stream() .map(mode -> (Enum) DirectModeMapper.map(mode)) .toList() ) .enumListReq( "PlanTransitModesInput.access", - StreetModeMapper - .getStreetModesForApi(journey.access().mode()) + StreetModeMapper.getStreetModesForApi(journey.access().mode()) .stream() .map(mode -> (Enum) AccessModeMapper.map(mode)) .toList() ) .enumListReq( "PlanTransitModesInput.egress", - StreetModeMapper - .getStreetModesForApi(journey.egress().mode()) + StreetModeMapper.getStreetModesForApi(journey.egress().mode()) .stream() .map(mode -> (Enum) EgressModeMapper.map(mode)) .toList() ) .enumListReq( "PlanTransitModesInput.transfer", - StreetModeMapper - .getStreetModesForApi(journey.transfer().mode()) + StreetModeMapper.getStreetModesForApi(journey.transfer().mode()) .stream() .map(mode -> (Enum) TransferModeMapper.map(mode)) .toList() @@ -354,8 +350,7 @@ private static void setWheelchairDefaults( } private static ArrayValue mapTransitModes(Map reluctanceForMode) { - var modesWithReluctance = Arrays - .stream(GraphQLTypes.GraphQLTransitMode.values()) + var modesWithReluctance = Arrays.stream(GraphQLTypes.GraphQLTransitMode.values()) .map(mode -> mapTransitMode(mode, reluctanceForMode.get(TransitModeMapper.map(mode)))) .toList(); return ArrayValue.newArrayValue().values(modesWithReluctance).build(); @@ -365,22 +360,18 @@ private static Value mapTransitMode( GraphQLTypes.GraphQLTransitMode mode, @Nullable Double reluctance ) { - var objectBuilder = ObjectValue - .newObjectValue() + var objectBuilder = ObjectValue.newObjectValue() .objectField( ObjectField.newObjectField().name("mode").value(EnumValue.of(mode.name())).build() ); if (reluctance != null) { objectBuilder.objectField( - ObjectField - .newObjectField() + ObjectField.newObjectField() .name("cost") .value( - ObjectValue - .newObjectValue() + ObjectValue.newObjectValue() .objectField( - ObjectField - .newObjectField() + ObjectField.newObjectField() .name("reluctance") .value(FloatValue.of(reluctance)) .build() @@ -399,29 +390,24 @@ private static ObjectValue mapVehicleOptimize( Function typeMapper ) { var optimizationField = type == VehicleRoutingOptimizeType.TRIANGLE - ? ObjectField - .newObjectField() + ? ObjectField.newObjectField() .name("triangle") .value( - ObjectValue - .newObjectValue() + ObjectValue.newObjectValue() .objectField( - ObjectField - .newObjectField() + ObjectField.newObjectField() .name("flatness") .value(FloatValue.of(triangle.slope())) .build() ) .objectField( - ObjectField - .newObjectField() + ObjectField.newObjectField() .name("safety") .value(FloatValue.of(triangle.safety())) .build() ) .objectField( - ObjectField - .newObjectField() + ObjectField.newObjectField() .name("time") .value(FloatValue.of(triangle.time())) .build() @@ -429,8 +415,7 @@ private static ObjectValue mapVehicleOptimize( .build() ) .build() - : ObjectField - .newObjectField() + : ObjectField.newObjectField() .name("type") .value(EnumValue.of(typeMapper.apply(type).name())) .build(); @@ -441,8 +426,7 @@ private static ArrayValue mapVehicleParkingFilter(VehicleParkingFilter filter) { var arrayBuilder = ArrayValue.newArrayValue(); if (!filter.not().isEmpty() || !filter.select().isEmpty()) { arrayBuilder.value( - ObjectValue - .newObjectValue() + ObjectValue.newObjectValue() .objectField(mapVehicleParkingSelects("not", filter.not())) .objectField(mapVehicleParkingSelects("select", filter.select())) .build() @@ -458,15 +442,12 @@ private static ObjectField mapVehicleParkingSelects( var selects = selectList .stream() .map(select -> - (Value) ObjectValue - .newObjectValue() + (Value) ObjectValue.newObjectValue() .objectField( - ObjectField - .newObjectField() + ObjectField.newObjectField() .name("tags") .value( - ArrayValue - .newArrayValue() + ArrayValue.newArrayValue() .values(select.tags().stream().map(tag -> (Value) StringValue.of(tag)).toList()) .build() ) @@ -475,8 +456,7 @@ private static ObjectField mapVehicleParkingSelects( .build() ) .toList(); - return ObjectField - .newObjectField() + return ObjectField.newObjectField() .name(fieldName) .value(ArrayValue.newArrayValue().values(selects).build()) .build(); @@ -516,8 +496,7 @@ public DefaultMappingBuilder boolReq(String key, boolean value) { public DefaultMappingBuilder enumListReq(String key, List valueList) { defaultValueForKey.put( key, - ArrayValue - .newArrayValue() + ArrayValue.newArrayValue() .values((valueList.stream().map(value -> (Value) new EnumValue(value.name())).toList())) .build() ); @@ -537,8 +516,7 @@ public DefaultMappingBuilder arrayReq(String key, ArrayValue value) { public DefaultMappingBuilder arrayStringsReq(String key, Collection values) { defaultValueForKey.put( key, - ArrayValue - .newArrayValue() + ArrayValue.newArrayValue() .values(values.stream().map(value -> (Value) StringValue.of(value)).toList()) .build() ); @@ -549,8 +527,7 @@ public DefaultMappingBuilder arrayStringsOpt(String key, @Nullable Collection (Value) StringValue.of(value)).toList()) .build() ); diff --git a/application/src/main/java/org/opentripplanner/apis/gtfs/GraphQLScalars.java b/application/src/main/java/org/opentripplanner/apis/gtfs/GraphQLScalars.java index 8427777bd38..5e7338c8c5d 100644 --- a/application/src/main/java/org/opentripplanner/apis/gtfs/GraphQLScalars.java +++ b/application/src/main/java/org/opentripplanner/apis/gtfs/GraphQLScalars.java @@ -27,10 +27,10 @@ public class GraphQLScalars { private static final ObjectMapper GEOJSON_MAPPER = ObjectMappers.geoJson(); - public static final GraphQLScalarType DURATION_SCALAR = DurationScalarFactory.createDurationScalar(); + public static final GraphQLScalarType DURATION_SCALAR = + DurationScalarFactory.createDurationScalar(); - public static final GraphQLScalarType POLYLINE_SCALAR = GraphQLScalarType - .newScalar() + public static final GraphQLScalarType POLYLINE_SCALAR = GraphQLScalarType.newScalar() .name("Polyline") .description( "List of coordinates in an encoded polyline format (see https://developers.google.com/maps/documentation/utilities/polylinealgorithm). The value appears in JSON as a string." @@ -58,8 +58,7 @@ public String parseLiteral(Object input) { ) .build(); - public static final GraphQLScalarType OFFSET_DATETIME_SCALAR = GraphQLScalarType - .newScalar() + public static final GraphQLScalarType OFFSET_DATETIME_SCALAR = GraphQLScalarType.newScalar() .name("OffsetDateTime") .coercing( new Coercing() { @@ -113,8 +112,7 @@ public OffsetDateTime parseLiteral(Object input) throws CoercingParseLiteralExce ) .build(); - public static final GraphQLScalarType COORDINATE_VALUE_SCALAR = GraphQLScalarType - .newScalar() + public static final GraphQLScalarType COORDINATE_VALUE_SCALAR = GraphQLScalarType.newScalar() .name("CoordinateValue") .coercing( new Coercing() { @@ -138,12 +136,14 @@ public Double serialize(Object dataFetcherResult) throws CoercingSerializeExcept @Override public Double parseValue(Object input) throws CoercingParseValueException { if (input instanceof Double doubleValue) { - return validateCoordinate(doubleValue) - .orElseThrow(() -> new CoercingParseValueException(VALIDATION_ERROR_MESSAGE)); + return validateCoordinate(doubleValue).orElseThrow(() -> + new CoercingParseValueException(VALIDATION_ERROR_MESSAGE) + ); } if (input instanceof Integer intValue) { - return validateCoordinate(intValue) - .orElseThrow(() -> new CoercingParseValueException(VALIDATION_ERROR_MESSAGE)); + return validateCoordinate(intValue).orElseThrow(() -> + new CoercingParseValueException(VALIDATION_ERROR_MESSAGE) + ); } throw new CoercingParseValueException( "Expected a number, got %s %s".formatted(input.getClass().getSimpleName(), input) @@ -153,12 +153,14 @@ public Double parseValue(Object input) throws CoercingParseValueException { @Override public Double parseLiteral(Object input) throws CoercingParseLiteralException { if (input instanceof FloatValue coordinate) { - return validateCoordinate(coordinate.getValue().doubleValue()) - .orElseThrow(() -> new CoercingParseLiteralException(VALIDATION_ERROR_MESSAGE)); + return validateCoordinate(coordinate.getValue().doubleValue()).orElseThrow(() -> + new CoercingParseLiteralException(VALIDATION_ERROR_MESSAGE) + ); } if (input instanceof IntValue coordinate) { - return validateCoordinate(coordinate.getValue().doubleValue()) - .orElseThrow(() -> new CoercingParseLiteralException(VALIDATION_ERROR_MESSAGE)); + return validateCoordinate(coordinate.getValue().doubleValue()).orElseThrow(() -> + new CoercingParseLiteralException(VALIDATION_ERROR_MESSAGE) + ); } throw new CoercingParseLiteralException( "Expected a number, got: " + input.getClass().getSimpleName() @@ -175,8 +177,7 @@ private static Optional validateCoordinate(double coordinate) { ) .build(); - public static final GraphQLScalarType COST_SCALAR = GraphQLScalarType - .newScalar() + public static final GraphQLScalarType COST_SCALAR = GraphQLScalarType.newScalar() .name("Cost") .coercing( new Coercing() { @@ -202,8 +203,9 @@ public Integer serialize(Object dataFetcherResult) throws CoercingSerializeExcep @Override public Cost parseValue(Object input) throws CoercingParseValueException { if (input instanceof Integer intValue) { - return validateCost(intValue) - .orElseThrow(() -> new CoercingParseValueException(VALIDATION_ERROR_MESSAGE)); + return validateCost(intValue).orElseThrow(() -> + new CoercingParseValueException(VALIDATION_ERROR_MESSAGE) + ); } throw new CoercingParseValueException( "Expected an integer, got %s %s".formatted(input.getClass().getSimpleName(), input) @@ -214,8 +216,9 @@ public Cost parseValue(Object input) throws CoercingParseValueException { public Cost parseLiteral(Object input) throws CoercingParseLiteralException { if (input instanceof IntValue intValue) { var value = intValue.getValue().intValue(); - return validateCost(value) - .orElseThrow(() -> new CoercingParseLiteralException(VALIDATION_ERROR_MESSAGE)); + return validateCost(value).orElseThrow(() -> + new CoercingParseLiteralException(VALIDATION_ERROR_MESSAGE) + ); } throw new CoercingParseLiteralException( "Expected an integer, got: " + input.getClass().getSimpleName() @@ -232,10 +235,10 @@ private static Optional validateCost(int cost) { ) .build(); - public static final GraphQLScalarType LOCAL_DATE_SCALAR = DateScalarFactory.createGtfsDateScalar(); + public static final GraphQLScalarType LOCAL_DATE_SCALAR = + DateScalarFactory.createGtfsDateScalar(); - public static final GraphQLScalarType GEOJSON_SCALAR = GraphQLScalarType - .newScalar() + public static final GraphQLScalarType GEOJSON_SCALAR = GraphQLScalarType.newScalar() .name("GeoJson") .description("Geographic data structures in JSON format. See: https://geojson.org/") .coercing( @@ -262,8 +265,7 @@ public Geometry parseLiteral(Object input) throws CoercingParseLiteralException ) .build(); - public static final GraphQLScalarType GRAPHQL_ID_SCALAR = GraphQLScalarType - .newScalar() + public static final GraphQLScalarType GRAPHQL_ID_SCALAR = GraphQLScalarType.newScalar() .name("ID") .coercing( new Coercing() { @@ -302,8 +304,7 @@ public Relay.ResolvedGlobalId parseLiteral(Object input) ) .build(); - public static final GraphQLScalarType GRAMS_SCALAR = GraphQLScalarType - .newScalar() + public static final GraphQLScalarType GRAMS_SCALAR = GraphQLScalarType.newScalar() .name("Grams") .coercing( new Coercing() { @@ -345,8 +346,7 @@ public Grams parseLiteral(Object input) throws CoercingParseLiteralException { ) .build(); - public static final GraphQLScalarType RATIO_SCALAR = GraphQLScalarType - .newScalar() + public static final GraphQLScalarType RATIO_SCALAR = GraphQLScalarType.newScalar() .name("Ratio") .coercing( new Coercing() { @@ -372,12 +372,14 @@ public Double serialize(Object dataFetcherResult) throws CoercingSerializeExcept @Override public Double parseValue(Object input) throws CoercingParseValueException { if (input instanceof Double doubleValue) { - return validateRatio(doubleValue) - .orElseThrow(() -> new CoercingParseValueException(VALIDATION_ERROR_MESSAGE)); + return validateRatio(doubleValue).orElseThrow(() -> + new CoercingParseValueException(VALIDATION_ERROR_MESSAGE) + ); } if (input instanceof Integer intValue) { - return validateRatio(intValue) - .orElseThrow(() -> new CoercingParseValueException(VALIDATION_ERROR_MESSAGE)); + return validateRatio(intValue).orElseThrow(() -> + new CoercingParseValueException(VALIDATION_ERROR_MESSAGE) + ); } throw new CoercingParseValueException( "Expected a number, got %s %s".formatted(input.getClass().getSimpleName(), input) @@ -387,12 +389,14 @@ public Double parseValue(Object input) throws CoercingParseValueException { @Override public Double parseLiteral(Object input) throws CoercingParseLiteralException { if (input instanceof FloatValue ratio) { - return validateRatio(ratio.getValue().doubleValue()) - .orElseThrow(() -> new CoercingParseLiteralException(VALIDATION_ERROR_MESSAGE)); + return validateRatio(ratio.getValue().doubleValue()).orElseThrow(() -> + new CoercingParseLiteralException(VALIDATION_ERROR_MESSAGE) + ); } if (input instanceof IntValue ratio) { - return validateRatio(ratio.getValue().doubleValue()) - .orElseThrow(() -> new CoercingParseLiteralException(VALIDATION_ERROR_MESSAGE)); + return validateRatio(ratio.getValue().doubleValue()).orElseThrow(() -> + new CoercingParseLiteralException(VALIDATION_ERROR_MESSAGE) + ); } throw new CoercingParseLiteralException( "Expected a number, got: " + input.getClass().getSimpleName() @@ -409,8 +413,7 @@ private static Optional validateRatio(double ratio) { ) .build(); - public static final GraphQLScalarType RELUCTANCE_SCALAR = GraphQLScalarType - .newScalar() + public static final GraphQLScalarType RELUCTANCE_SCALAR = GraphQLScalarType.newScalar() .name("Reluctance") .coercing( new Coercing() { @@ -437,12 +440,14 @@ public Double serialize(Object dataFetcherResult) throws CoercingSerializeExcept @Override public Double parseValue(Object input) throws CoercingParseValueException { if (input instanceof Double doubleValue) { - return validateReluctance(doubleValue) - .orElseThrow(() -> new CoercingParseValueException(VALIDATION_ERROR_MESSAGE)); + return validateReluctance(doubleValue).orElseThrow(() -> + new CoercingParseValueException(VALIDATION_ERROR_MESSAGE) + ); } if (input instanceof Integer intValue) { - return validateReluctance(intValue) - .orElseThrow(() -> new CoercingParseValueException(VALIDATION_ERROR_MESSAGE)); + return validateReluctance(intValue).orElseThrow(() -> + new CoercingParseValueException(VALIDATION_ERROR_MESSAGE) + ); } throw new CoercingParseValueException( "Expected a number, got %s %s".formatted(input.getClass().getSimpleName(), input) @@ -452,12 +457,14 @@ public Double parseValue(Object input) throws CoercingParseValueException { @Override public Double parseLiteral(Object input) throws CoercingParseLiteralException { if (input instanceof FloatValue reluctance) { - return validateReluctance(reluctance.getValue().doubleValue()) - .orElseThrow(() -> new CoercingParseLiteralException(VALIDATION_ERROR_MESSAGE)); + return validateReluctance(reluctance.getValue().doubleValue()).orElseThrow(() -> + new CoercingParseLiteralException(VALIDATION_ERROR_MESSAGE) + ); } if (input instanceof IntValue reluctance) { - return validateReluctance(reluctance.getValue().doubleValue()) - .orElseThrow(() -> new CoercingParseLiteralException(VALIDATION_ERROR_MESSAGE)); + return validateReluctance(reluctance.getValue().doubleValue()).orElseThrow(() -> + new CoercingParseLiteralException(VALIDATION_ERROR_MESSAGE) + ); } throw new CoercingParseLiteralException( "Expected a number, got: " + input.getClass().getSimpleName() diff --git a/application/src/main/java/org/opentripplanner/apis/gtfs/GtfsGraphQLAPI.java b/application/src/main/java/org/opentripplanner/apis/gtfs/GtfsGraphQLAPI.java index fd135d05544..1bf92065219 100644 --- a/application/src/main/java/org/opentripplanner/apis/gtfs/GtfsGraphQLAPI.java +++ b/application/src/main/java/org/opentripplanner/apis/gtfs/GtfsGraphQLAPI.java @@ -57,8 +57,7 @@ public Response getGraphQL( ) { if (queryParameters == null || !queryParameters.containsKey("query")) { LOG.debug("No query found in body"); - return Response - .status(Response.Status.BAD_REQUEST) + return Response.status(Response.Status.BAD_REQUEST) .type(MediaType.TEXT_PLAIN_TYPE) .entity("No query found in body") .build(); @@ -79,8 +78,7 @@ public Response getGraphQL( try { variables = deserializer.readValue((String) queryVariables, Map.class); } catch (IOException e) { - return Response - .status(Response.Status.BAD_REQUEST) + return Response.status(Response.Status.BAD_REQUEST) .type(MediaType.TEXT_PLAIN_TYPE) .entity("Variables must be a valid json object") .build(); diff --git a/application/src/main/java/org/opentripplanner/apis/gtfs/GtfsGraphQLIndex.java b/application/src/main/java/org/opentripplanner/apis/gtfs/GtfsGraphQLIndex.java index afb6bfc8802..338c9f13b72 100644 --- a/application/src/main/java/org/opentripplanner/apis/gtfs/GtfsGraphQLIndex.java +++ b/application/src/main/java/org/opentripplanner/apis/gtfs/GtfsGraphQLIndex.java @@ -35,15 +35,13 @@ static ExecutionResult getGraphQLExecutionResult( Instrumentation instrumentation = new MaxQueryComplexityInstrumentation(maxResolves); if (OTPFeature.ActuatorAPI.isOn()) { - instrumentation = - new ChainedInstrumentation( - new MicrometerGraphQLInstrumentation(Metrics.globalRegistry, List.of()), - instrumentation - ); + instrumentation = new ChainedInstrumentation( + new MicrometerGraphQLInstrumentation(Metrics.globalRegistry, List.of()), + instrumentation + ); } - GraphQL graphQL = GraphQL - .newGraphQL(requestContext.schema()) + GraphQL graphQL = GraphQL.newGraphQL(requestContext.schema()) .instrumentation(instrumentation) .defaultDataFetcherExceptionHandler(new LoggingDataFetcherExceptionHandler()) .build(); @@ -52,8 +50,7 @@ static ExecutionResult getGraphQLExecutionResult( variables = new HashMap<>(); } - ExecutionInput executionInput = ExecutionInput - .newExecutionInput() + ExecutionInput executionInput = ExecutionInput.newExecutionInput() .query(query) .operationName(operationName) .context(requestContext) @@ -86,8 +83,7 @@ static Response getGraphQLResponse( requestContext ); - return Response - .status(Response.Status.OK) + return Response.status(Response.Status.OK) .entity(GraphQLResponseSerializer.serialize(executionResult)) .build(); } diff --git a/application/src/main/java/org/opentripplanner/apis/gtfs/IntrospectionTypeWiring.java b/application/src/main/java/org/opentripplanner/apis/gtfs/IntrospectionTypeWiring.java index 78a6619a6b9..cd489d8fcd7 100644 --- a/application/src/main/java/org/opentripplanner/apis/gtfs/IntrospectionTypeWiring.java +++ b/application/src/main/java/org/opentripplanner/apis/gtfs/IntrospectionTypeWiring.java @@ -44,58 +44,53 @@ TypeRuntimeWiring build(Class clazz) throws Exception { throw new IllegalArgumentException("Type %s is not object type".formatted(type.getName())); } - return TypeRuntimeWiring - .newTypeWiring(clazz.getSimpleName().replaceAll("Impl$", "")) + return TypeRuntimeWiring.newTypeWiring(clazz.getSimpleName().replaceAll("Impl$", "")) .dataFetchers( - Arrays - .stream(clazz.getDeclaredMethods()) + Arrays.stream(clazz.getDeclaredMethods()) .filter(isMethodPublic) .filter(isMethodReturnTypeDataFetcher) .collect( - Collectors.toMap( - Method::getName, - method -> { - String fieldName = method.getName(); - try { - DataFetcher dataFetcher = (DataFetcher) method.invoke(instance); - if (dataFetcher == null) { - throw new RuntimeException( - String.format( - "Data fetcher %s for type %s is null", - fieldName, - clazz.getSimpleName() - ) - ); - } - if ( - OTPFeature.AsyncGraphQLFetchers.isOn() && - objectType - .getFieldDefinitions() - .stream() - .filter(fieldDefinition -> fieldDefinition.getName().equals(fieldName)) - .anyMatch(fieldDefinition -> - fieldDefinition - .getDirectives() - .stream() - .anyMatch(directive -> directive.getName().equals("async")) - ) - ) { - return AsyncDataFetcher.async(dataFetcher); - } - - return dataFetcher; - } catch (IllegalAccessException | InvocationTargetException error) { + Collectors.toMap(Method::getName, method -> { + String fieldName = method.getName(); + try { + DataFetcher dataFetcher = (DataFetcher) method.invoke(instance); + if (dataFetcher == null) { throw new RuntimeException( String.format( - "Data fetcher %s for type %s threw error", + "Data fetcher %s for type %s is null", fieldName, clazz.getSimpleName() - ), - error + ) ); } + if ( + OTPFeature.AsyncGraphQLFetchers.isOn() && + objectType + .getFieldDefinitions() + .stream() + .filter(fieldDefinition -> fieldDefinition.getName().equals(fieldName)) + .anyMatch(fieldDefinition -> + fieldDefinition + .getDirectives() + .stream() + .anyMatch(directive -> directive.getName().equals("async")) + ) + ) { + return AsyncDataFetcher.async(dataFetcher); + } + + return dataFetcher; + } catch (IllegalAccessException | InvocationTargetException error) { + throw new RuntimeException( + String.format( + "Data fetcher %s for type %s threw error", + fieldName, + clazz.getSimpleName() + ), + error + ); } - ) + }) ) ) .build(); diff --git a/application/src/main/java/org/opentripplanner/apis/gtfs/SchemaFactory.java b/application/src/main/java/org/opentripplanner/apis/gtfs/SchemaFactory.java index 6909d1dd98d..86561416006 100644 --- a/application/src/main/java/org/opentripplanner/apis/gtfs/SchemaFactory.java +++ b/application/src/main/java/org/opentripplanner/apis/gtfs/SchemaFactory.java @@ -112,8 +112,7 @@ public static GraphQLSchema createSchema() { URL url = Objects.requireNonNull(SchemaFactory.class.getResource("schema.graphqls")); TypeDefinitionRegistry typeRegistry = new SchemaParser().parse(url.openStream()); IntrospectionTypeWiring typeWiring = new IntrospectionTypeWiring(typeRegistry); - RuntimeWiring runtimeWiring = RuntimeWiring - .newRuntimeWiring() + RuntimeWiring runtimeWiring = RuntimeWiring.newRuntimeWiring() .scalar(GraphQLScalars.DURATION_SCALAR) .scalar(GraphQLScalars.POLYLINE_SCALAR) .scalar(GraphQLScalars.GEOJSON_SCALAR) @@ -128,8 +127,7 @@ public static GraphQLSchema createSchema() { .scalar(ExtendedScalars.GraphQLLong) .scalar(ExtendedScalars.Locale) .scalar( - ExtendedScalars - .newAliasedScalar("Speed") + ExtendedScalars.newAliasedScalar("Speed") .aliasedScalar(ExtendedScalars.NonNegativeFloat) .build() ) diff --git a/application/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/AgencyImpl.java b/application/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/AgencyImpl.java index d8ed772c9e5..b6069edba94 100644 --- a/application/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/AgencyImpl.java +++ b/application/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/AgencyImpl.java @@ -47,8 +47,9 @@ public DataFetcher> alerts() { .forEach(alerts::add); break; case ROUTES: - getRoutes(environment) - .forEach(route -> alerts.addAll(alertService.getRouteAlerts(route.getId()))); + getRoutes(environment).forEach(route -> + alerts.addAll(alertService.getRouteAlerts(route.getId())) + ); break; } }); diff --git a/application/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/DepartureRowImpl.java b/application/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/DepartureRowImpl.java index 64b84c4c132..f6a242ca095 100644 --- a/application/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/DepartureRowImpl.java +++ b/application/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/DepartureRowImpl.java @@ -44,18 +44,16 @@ public DataFetcher stop() { @Override public DataFetcher> stoptimes() { return environment -> { - GraphQLTypes.GraphQLDepartureRowStoptimesArgs args = new GraphQLTypes.GraphQLDepartureRowStoptimesArgs( - environment.getArguments() - ); + GraphQLTypes.GraphQLDepartureRowStoptimesArgs args = + new GraphQLTypes.GraphQLDepartureRowStoptimesArgs(environment.getArguments()); - return getSource(environment) - .getStoptimes( - getTransitService(environment), - GraphQLUtils.getTimeOrNow(args.getGraphQLStartTime()), - Duration.ofSeconds(args.getGraphQLTimeRange()), - args.getGraphQLNumberOfDepartures(), - args.getGraphQLOmitNonPickups() ? ArrivalDeparture.DEPARTURES : ArrivalDeparture.BOTH - ); + return getSource(environment).getStoptimes( + getTransitService(environment), + GraphQLUtils.getTimeOrNow(args.getGraphQLStartTime()), + Duration.ofSeconds(args.getGraphQLTimeRange()), + args.getGraphQLNumberOfDepartures(), + args.getGraphQLOmitNonPickups() ? ArrivalDeparture.DEPARTURES : ArrivalDeparture.BOTH + ); }; } diff --git a/application/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/LegImpl.java b/application/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/LegImpl.java index 23dd1a437c4..c102cca9583 100644 --- a/application/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/LegImpl.java +++ b/application/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/LegImpl.java @@ -298,34 +298,29 @@ private DataFetcher> alternativeLegs(NavigationDirection direction boolean limitToExactOriginStop = originModesWithParentStation == null || - !( - originModesWithParentStation + !(originModesWithParentStation .stream() .map(GraphQLTypes.GraphQLTransitMode::toString) .toList() - .contains(originalLeg.getMode().name()) - ); + .contains(originalLeg.getMode().name())); boolean limitToExactDestinationStop = destinationModesWithParentStation == null || - !( - destinationModesWithParentStation + !(destinationModesWithParentStation .stream() .map(GraphQLTypes.GraphQLTransitMode::toString) .toList() - .contains(originalLeg.getMode().name()) - ); - - var res = AlternativeLegs - .getAlternativeLegs( - environment.getSource(), - numberOfLegs, - environment.getContext().transitService(), - direction, - AlternativeLegsFilter.NO_FILTER, - limitToExactOriginStop, - limitToExactDestinationStop - ) + .contains(originalLeg.getMode().name())); + + var res = AlternativeLegs.getAlternativeLegs( + environment.getSource(), + numberOfLegs, + environment.getContext().transitService(), + direction, + AlternativeLegsFilter.NO_FILTER, + limitToExactOriginStop, + limitToExactDestinationStop + ) .stream() .map(Leg.class::cast) .toList(); diff --git a/application/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/PatternImpl.java b/application/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/PatternImpl.java index fbab1e95400..db0dae0fb26 100644 --- a/application/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/PatternImpl.java +++ b/application/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/PatternImpl.java @@ -71,8 +71,9 @@ public DataFetcher> alerts() { ); break; case TRIPS: - getTrips(environment) - .forEach(trip -> alerts.addAll(alertService.getTripAlerts(trip.getId(), null))); + getTrips(environment).forEach(trip -> + alerts.addAll(alertService.getTripAlerts(trip.getId(), null)) + ); break; case STOPS_ON_PATTERN: alerts.addAll( @@ -84,10 +85,8 @@ public DataFetcher> alerts() { .entities() .stream() .anyMatch(entity -> - ( - entity instanceof EntitySelector.StopAndRoute stopAndRoute && - stopAndRoute.routeId().equals(getRoute(environment).getId()) - ) + (entity instanceof EntitySelector.StopAndRoute stopAndRoute && + stopAndRoute.routeId().equals(getRoute(environment).getId())) ) ) .toList() @@ -111,10 +110,8 @@ public DataFetcher> alerts() { .entities() .stream() .anyMatch(entity -> - ( - entity instanceof EntitySelector.StopAndTrip stopAndTrip && - stopAndTrip.tripId().equals(getSource(environment).getId()) - ) + (entity instanceof EntitySelector.StopAndTrip stopAndTrip && + stopAndTrip.tripId().equals(getSource(environment).getId())) ) ) .toList() @@ -207,12 +204,12 @@ public DataFetcher> tripsForDate() { return environment -> { String serviceDate = new GraphQLTypes.GraphQLPatternTripsForDateArgs( environment.getArguments() - ) - .getGraphQLServiceDate(); + ).getGraphQLServiceDate(); try { - TIntSet services = getTransitService(environment) - .getServiceCodesRunningForDate(ServiceDateUtils.parseString(serviceDate)); + TIntSet services = getTransitService(environment).getServiceCodesRunningForDate( + ServiceDateUtils.parseString(serviceDate) + ); return getSource(environment) .getScheduledTimetable() .getTripTimes() diff --git a/application/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/QueryTypeImpl.java b/application/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/QueryTypeImpl.java index 25f7ec4ddf2..ea677c1cb98 100644 --- a/application/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/QueryTypeImpl.java +++ b/application/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/QueryTypeImpl.java @@ -174,16 +174,17 @@ public DataFetcher> bikeRentalStations() { ); if (args.getGraphQLIds() != null) { - ArrayListMultimap vehicleRentalStations = vehicleRentalStationService - .getVehicleRentalPlaces() - .stream() - .collect( - Multimaps.toMultimap( - VehicleRentalPlace::getStationId, - station -> station, - ArrayListMultimap::create - ) - ); + ArrayListMultimap vehicleRentalStations = + vehicleRentalStationService + .getVehicleRentalPlaces() + .stream() + .collect( + Multimaps.toMultimap( + VehicleRentalPlace::getStationId, + station -> station, + ArrayListMultimap::create + ) + ); return args .getGraphQLIds() .stream() @@ -279,13 +280,12 @@ public DataFetcher fuzzyTrip() { TransitService transitService = getTransitService(environment); - return new GtfsRealtimeFuzzyTripMatcher(transitService) - .getTrip( - transitService.getRoute(FeedScopedId.parse(args.getGraphQLRoute())), - DIRECTION_MAPPER.map(args.getGraphQLDirection()), - args.getGraphQLTime(), - ServiceDateUtils.parseString(args.getGraphQLDate()) - ); + return new GtfsRealtimeFuzzyTripMatcher(transitService).getTrip( + transitService.getRoute(FeedScopedId.parse(args.getGraphQLRoute())), + DIRECTION_MAPPER.map(args.getGraphQLDirection()), + args.getGraphQLTime(), + ServiceDateUtils.parseString(args.getGraphQLDate()) + ); }; } @@ -307,18 +307,15 @@ public DataFetcher> nearest() { GraphQLTypes.GraphQLInputFiltersInput filterByIds = args.getGraphQLFilterByIds(); if (filterByIds != null) { - filterByStops = - filterByIds.getGraphQLStops() != null - ? filterByIds.getGraphQLStops().stream().map(FeedScopedId::parse).toList() - : null; - filterByStations = - filterByIds.getGraphQLStations() != null - ? filterByIds.getGraphQLStations().stream().map(FeedScopedId::parse).toList() - : null; - filterByRoutes = - filterByIds.getGraphQLRoutes() != null - ? filterByIds.getGraphQLRoutes().stream().map(FeedScopedId::parse).toList() - : null; + filterByStops = filterByIds.getGraphQLStops() != null + ? filterByIds.getGraphQLStops().stream().map(FeedScopedId::parse).toList() + : null; + filterByStations = filterByIds.getGraphQLStations() != null + ? filterByIds.getGraphQLStations().stream().map(FeedScopedId::parse).toList() + : null; + filterByRoutes = filterByIds.getGraphQLRoutes() != null + ? filterByIds.getGraphQLRoutes().stream().map(FeedScopedId::parse).toList() + : null; filterByBikeRentalStations = filterByIds.getGraphQLBikeRentalStations(); filterByBikeParks = filterByIds.getGraphQLBikeParks(); filterByCarParks = filterByIds.getGraphQLCarParks(); @@ -345,24 +342,22 @@ public DataFetcher> nearest() { List places; try { - places = - new ArrayList<>( - getGraphFinder(environment) - .findClosestPlaces( - args.getGraphQLLat(), - args.getGraphQLLon(), - args.getGraphQLMaxDistance(), - args.getGraphQLMaxResults(), - filterByModes, - filterByPlaceTypes, - filterByStops, - filterByStations, - filterByRoutes, - filterByBikeRentalStations, - filterByNetwork, - getTransitService(environment) - ) - ); + places = new ArrayList<>( + getGraphFinder(environment).findClosestPlaces( + args.getGraphQLLat(), + args.getGraphQLLon(), + args.getGraphQLMaxDistance(), + args.getGraphQLMaxResults(), + filterByModes, + filterByPlaceTypes, + filterByStops, + filterByStations, + filterByRoutes, + filterByBikeRentalStations, + filterByNetwork, + getTransitService(environment) + ) + ); } catch (RoutingValidationException e) { places = Collections.emptyList(); } @@ -439,37 +434,34 @@ public DataFetcher node() { return PatternAtStop.fromId(transitService, id); case "Pattern": return transitService.getTripPattern(FeedScopedId.parse(id)); - case "placeAtDistance": - { - String[] parts = id.split(";"); - - Relay.ResolvedGlobalId internalId = new Relay().fromGlobalId(parts[1]); - - Object place = node() - .get( - DataFetchingEnvironmentImpl - .newDataFetchingEnvironment(environment) - .source(new Object()) - .arguments(Map.of("id", internalId)) - .build() - ); - - return new PlaceAtDistance(place, Double.parseDouble(parts[0])); - } + case "placeAtDistance": { + String[] parts = id.split(";"); + + Relay.ResolvedGlobalId internalId = new Relay().fromGlobalId(parts[1]); + + Object place = node() + .get( + DataFetchingEnvironmentImpl.newDataFetchingEnvironment(environment) + .source(new Object()) + .arguments(Map.of("id", internalId)) + .build() + ); + + return new PlaceAtDistance(place, Double.parseDouble(parts[0])); + } case "Route": return transitService.getRoute(FeedScopedId.parse(id)); case "Stop": return transitService.getRegularStop(FeedScopedId.parse(id)); case "Stoptime": return null; //TODO - case "stopAtDistance": - { - String[] parts = id.split(";"); - var stop = transitService.getRegularStop(FeedScopedId.parse(parts[1])); - - // TODO: Add geometry - return new NearbyStop(stop, Integer.parseInt(parts[0]), null, null); - } + case "stopAtDistance": { + String[] parts = id.split(";"); + var stop = transitService.getRegularStop(FeedScopedId.parse(parts[1])); + + // TODO: Add geometry + return new NearbyStop(stop, Integer.parseInt(parts[0]), null, null); + } case "TicketType": return null; //TODO case "Trip": @@ -494,12 +486,11 @@ public DataFetcher node() { @Override public DataFetcher pattern() { return environment -> - getTransitService(environment) - .getTripPattern( - FeedScopedId.parse( - new GraphQLTypes.GraphQLQueryTypePatternArgs(environment.getArguments()).getGraphQLId() - ) - ); + getTransitService(environment).getTripPattern( + FeedScopedId.parse( + new GraphQLTypes.GraphQLQueryTypePatternArgs(environment.getArguments()).getGraphQLId() + ) + ); } @Override @@ -555,16 +546,17 @@ public DataFetcher> rentalVehicles() { var args = new GraphQLTypes.GraphQLQueryTypeRentalVehiclesArgs(environment.getArguments()); if (args.getGraphQLIds() != null) { - ArrayListMultimap vehicleRentalVehicles = vehicleRentalStationService - .getVehicleRentalVehicles() - .stream() - .collect( - Multimaps.toMultimap( - vehicle -> vehicle.getId().toString(), - vehicle -> vehicle, - ArrayListMultimap::create - ) - ); + ArrayListMultimap vehicleRentalVehicles = + vehicleRentalStationService + .getVehicleRentalVehicles() + .stream() + .collect( + Multimaps.toMultimap( + vehicle -> vehicle.getId().toString(), + vehicle -> vehicle, + ArrayListMultimap::create + ) + ); return args .getGraphQLIds() .stream() @@ -591,12 +583,11 @@ public DataFetcher> rentalVehicles() { @Override public DataFetcher route() { return environment -> - getTransitService(environment) - .getRoute( - FeedScopedId.parse( - new GraphQLTypes.GraphQLQueryTypeRouteArgs(environment.getArguments()).getGraphQLId() - ) - ); + getTransitService(environment).getRoute( + FeedScopedId.parse( + new GraphQLTypes.GraphQLQueryTypeRouteArgs(environment.getArguments()).getGraphQLId() + ) + ); } @Override @@ -633,11 +624,11 @@ public DataFetcher> routes() { if (args.getGraphQLName() != null) { String name = args.getGraphQLName().toLowerCase(environment.getLocale()); - routeStream = - routeStream.filter(route -> + routeStream = routeStream.filter( + route -> GraphQLUtils.startsWith(route.getShortName(), name, environment.getLocale()) || GraphQLUtils.startsWith(route.getLongName(), name, environment.getLocale()) - ); + ); } if (LocalDateRangeUtil.hasServiceDateFilter(args.getGraphQLServiceDates())) { @@ -659,12 +650,11 @@ public DataFetcher serviceTimeRange() { @Override public DataFetcher station() { return environment -> - getTransitService(environment) - .getStation( - FeedScopedId.parse( - new GraphQLTypes.GraphQLQueryTypeStationArgs(environment.getArguments()).getGraphQLId() - ) - ); + getTransitService(environment).getStation( + FeedScopedId.parse( + new GraphQLTypes.GraphQLQueryTypeStationArgs(environment.getArguments()).getGraphQLId() + ) + ); } @Override @@ -687,10 +677,9 @@ public DataFetcher> stations() { if (args.getGraphQLName() != null) { String name = args.getGraphQLName().toLowerCase(environment.getLocale()); - stationStream = - stationStream.filter(station -> - GraphQLUtils.startsWith(station.getName(), name, environment.getLocale()) - ); + stationStream = stationStream.filter(station -> + GraphQLUtils.startsWith(station.getName(), name, environment.getLocale()) + ); } return stationStream.collect(Collectors.toList()); @@ -700,12 +689,11 @@ public DataFetcher> stations() { @Override public DataFetcher stop() { return environment -> - getTransitService(environment) - .getRegularStop( - FeedScopedId.parse( - new GraphQLTypes.GraphQLQueryTypeStopArgs(environment.getArguments()).getGraphQLId() - ) - ); + getTransitService(environment).getRegularStop( + FeedScopedId.parse( + new GraphQLTypes.GraphQLQueryTypeStopArgs(environment.getArguments()).getGraphQLId() + ) + ); } @Override @@ -731,10 +719,9 @@ public DataFetcher> stops() { if (args.getGraphQLName() != null) { String name = args.getGraphQLName().toLowerCase(environment.getLocale()); - stopStream = - stopStream.filter(stop -> - GraphQLUtils.startsWith(stop.getName(), name, environment.getLocale()) - ); + stopStream = stopStream.filter(stop -> + GraphQLUtils.startsWith(stop.getName(), name, environment.getLocale()) + ); } return stopStream.collect(Collectors.toList()); @@ -774,12 +761,10 @@ public DataFetcher> stopsByRadius() { List stops; try { - stops = - getGraphFinder(environment) - .findClosestStops( - new Coordinate(args.getGraphQLLon(), args.getGraphQLLat()), - args.getGraphQLRadius() - ); + stops = getGraphFinder(environment).findClosestStops( + new Coordinate(args.getGraphQLLon(), args.getGraphQLLat()), + args.getGraphQLRadius() + ); } catch (RoutingValidationException e) { stops = Collections.emptyList(); } @@ -809,12 +794,11 @@ public DataFetcher> ticketTypes() { @Override public DataFetcher trip() { return environment -> - getTransitService(environment) - .getTrip( - FeedScopedId.parse( - new GraphQLTypes.GraphQLQueryTypeTripArgs(environment.getArguments()).getGraphQLId() - ) - ); + getTransitService(environment).getTrip( + FeedScopedId.parse( + new GraphQLTypes.GraphQLQueryTypeTripArgs(environment.getArguments()).getGraphQLId() + ) + ); } @Override @@ -921,16 +905,17 @@ public DataFetcher> vehicleRentalStations() { ); if (args.getGraphQLIds() != null) { - ArrayListMultimap vehicleRentalStations = vehicleRentalStationService - .getVehicleRentalStations() - .stream() - .collect( - Multimaps.toMultimap( - station -> station.getId().toString(), - station -> station, - ArrayListMultimap::create - ) - ); + ArrayListMultimap vehicleRentalStations = + vehicleRentalStationService + .getVehicleRentalStations() + .stream() + .collect( + Multimaps.toMultimap( + station -> station.getId().toString(), + station -> station, + ArrayListMultimap::create + ) + ); return args .getGraphQLIds() .stream() @@ -988,8 +973,7 @@ private GraphFinder getGraphFinder(DataFetchingEnvironment environment) { private DataFetcherResult getPlanResult(GraphQLRequestContext context, RouteRequest request) { RoutingResponse res = context.routingService().route(request); - return DataFetcherResult - .newResult() + return DataFetcherResult.newResult() .data(res) .localContext(Map.of("locale", request.locale())) .build(); @@ -1004,31 +988,35 @@ protected static List filterAlerts( var causes = args.getGraphQLCause(); return alerts .stream() - .filter(alert -> - args.getGraphQLFeeds() == null || args.getGraphQLFeeds().contains(alert.getId().getFeedId()) + .filter( + alert -> + args.getGraphQLFeeds() == null || + args.getGraphQLFeeds().contains(alert.getId().getFeedId()) ) - .filter(alert -> - severities == null || severities.contains(getGraphQLSeverity(alert.severity())) + .filter( + alert -> severities == null || severities.contains(getGraphQLSeverity(alert.severity())) ) .filter(alert -> effects == null || effects.contains(getGraphQLEffect(alert.effect()))) .filter(alert -> causes == null || causes.contains(getGraphQLCause(alert.cause()))) - .filter(alert -> - args.getGraphQLRoute() == null || - alert - .entities() - .stream() - .filter(entitySelector -> entitySelector instanceof EntitySelector.Route) - .map(EntitySelector.Route.class::cast) - .anyMatch(route -> args.getGraphQLRoute().contains(route.routeId().toString())) + .filter( + alert -> + args.getGraphQLRoute() == null || + alert + .entities() + .stream() + .filter(entitySelector -> entitySelector instanceof EntitySelector.Route) + .map(EntitySelector.Route.class::cast) + .anyMatch(route -> args.getGraphQLRoute().contains(route.routeId().toString())) ) - .filter(alert -> - args.getGraphQLStop() == null || - alert - .entities() - .stream() - .filter(entitySelector -> entitySelector instanceof EntitySelector.Stop) - .map(EntitySelector.Stop.class::cast) - .anyMatch(stop -> args.getGraphQLStop().contains(stop.stopId().toString())) + .filter( + alert -> + args.getGraphQLStop() == null || + alert + .entities() + .stream() + .filter(entitySelector -> entitySelector instanceof EntitySelector.Stop) + .map(EntitySelector.Stop.class::cast) + .anyMatch(stop -> args.getGraphQLStop().contains(stop.stopId().toString())) ) .toList(); } diff --git a/application/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/RouteImpl.java b/application/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/RouteImpl.java index 4fb3548eb63..eed2ad23ecd 100644 --- a/application/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/RouteImpl.java +++ b/application/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/RouteImpl.java @@ -67,8 +67,9 @@ public DataFetcher> alerts() { ); break; case TRIPS: - getTrips(environment) - .forEach(trip -> alerts.addAll(alertService.getTripAlerts(trip.getId(), null))); + getTrips(environment).forEach(trip -> + alerts.addAll(alertService.getTripAlerts(trip.getId(), null)) + ); break; case STOPS_ON_ROUTE: alerts.addAll( @@ -79,17 +80,17 @@ public DataFetcher> alerts() { alert .entities() .stream() - .anyMatch(entity -> - entity instanceof EntitySelector.StopAndRoute stopAndRoute && - stopAndRoute.routeId().equals(getSource(environment).getId()) + .anyMatch( + entity -> + entity instanceof EntitySelector.StopAndRoute stopAndRoute && + stopAndRoute.routeId().equals(getSource(environment).getId()) ) ) .toList() ); - getStops(environment) - .forEach(stop -> - alerts.addAll(alertService.getStopAlerts(((StopLocation) stop).getId())) - ); + getStops(environment).forEach(stop -> + alerts.addAll(alertService.getStopAlerts(((StopLocation) stop).getId())) + ); break; case STOPS_ON_TRIPS: Iterable trips = getTrips(environment); @@ -102,9 +103,10 @@ public DataFetcher> alerts() { alert .entities() .stream() - .anyMatch(entity -> - entity instanceof EntitySelector.StopAndTrip stopAndTrip && - stopAndTrip.tripId().equals(trip.getId()) + .anyMatch( + entity -> + entity instanceof EntitySelector.StopAndTrip stopAndTrip && + stopAndTrip.tripId().equals(trip.getId()) ) ) .toList() diff --git a/application/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/RouteTypeImpl.java b/application/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/RouteTypeImpl.java index 108b4bd2bc0..09cedc48f22 100644 --- a/application/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/RouteTypeImpl.java +++ b/application/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/RouteTypeImpl.java @@ -29,10 +29,11 @@ public DataFetcher> routes() { return getTransitService(environment) .listRoutes() .stream() - .filter(route -> - route.getId().getFeedId().equals(getSource(environment).getFeedId()) && - route.getGtfsType() == getSource(environment).getRouteType() && - (agency == null || route.getAgency().equals(agency)) + .filter( + route -> + route.getId().getFeedId().equals(getSource(environment).getFeedId()) && + route.getGtfsType() == getSource(environment).getRouteType() && + (agency == null || route.getAgency().equals(agency)) ) .collect(Collectors.toList()); }; diff --git a/application/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/StopImpl.java b/application/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/StopImpl.java index 5a2e6f29204..c86d554f8d9 100644 --- a/application/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/StopImpl.java +++ b/application/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/StopImpl.java @@ -64,17 +64,14 @@ public DataFetcher> alerts() { alert .entities() .stream() - .anyMatch(entity -> - ( - types.contains(GraphQLTypes.GraphQLStopAlertType.STOP_ON_ROUTES) && - entity instanceof StopAndRoute stopAndRoute && - stopAndRoute.stopId().equals(id) - ) || - ( - types.contains(GraphQLTypes.GraphQLStopAlertType.STOP_ON_TRIPS) && - entity instanceof EntitySelector.StopAndTrip stopAndTrip && - stopAndTrip.stopId().equals(id) - ) + .anyMatch( + entity -> + (types.contains(GraphQLTypes.GraphQLStopAlertType.STOP_ON_ROUTES) && + entity instanceof StopAndRoute stopAndRoute && + stopAndRoute.stopId().equals(id)) || + (types.contains(GraphQLTypes.GraphQLStopAlertType.STOP_ON_TRIPS) && + entity instanceof EntitySelector.StopAndTrip stopAndTrip && + stopAndTrip.stopId().equals(id)) ) ) .toList() @@ -84,36 +81,34 @@ public DataFetcher> alerts() { types.contains(GraphQLTypes.GraphQLStopAlertType.PATTERNS) || types.contains(GraphQLTypes.GraphQLStopAlertType.TRIPS) ) { - getPatterns(environment) - .forEach(pattern -> { - if (types.contains(GraphQLTypes.GraphQLStopAlertType.PATTERNS)) { - alerts.addAll( - alertService.getDirectionAndRouteAlerts( - pattern.getDirection(), - pattern.getRoute().getId() - ) - ); - } - if (types.contains(GraphQLTypes.GraphQLStopAlertType.TRIPS)) { - pattern - .scheduledTripsAsStream() - .forEach(trip -> alerts.addAll(alertService.getTripAlerts(trip.getId(), null))); - } - }); + getPatterns(environment).forEach(pattern -> { + if (types.contains(GraphQLTypes.GraphQLStopAlertType.PATTERNS)) { + alerts.addAll( + alertService.getDirectionAndRouteAlerts( + pattern.getDirection(), + pattern.getRoute().getId() + ) + ); + } + if (types.contains(GraphQLTypes.GraphQLStopAlertType.TRIPS)) { + pattern + .scheduledTripsAsStream() + .forEach(trip -> alerts.addAll(alertService.getTripAlerts(trip.getId(), null))); + } + }); } if ( types.contains(GraphQLTypes.GraphQLStopAlertType.ROUTES) || types.contains(GraphQLTypes.GraphQLStopAlertType.AGENCIES_OF_ROUTES) ) { - getRoutes(environment) - .forEach(route -> { - if (types.contains(GraphQLTypes.GraphQLStopAlertType.ROUTES)) { - alerts.addAll(alertService.getRouteAlerts(route.getId())); - } - if (types.contains(GraphQLTypes.GraphQLStopAlertType.AGENCIES_OF_ROUTES)) { - alerts.addAll(alertService.getAgencyAlerts(route.getAgency().getId())); - } - }); + getRoutes(environment).forEach(route -> { + if (types.contains(GraphQLTypes.GraphQLStopAlertType.ROUTES)) { + alerts.addAll(alertService.getRouteAlerts(route.getId())); + } + if (types.contains(GraphQLTypes.GraphQLStopAlertType.AGENCIES_OF_ROUTES)) { + alerts.addAll(alertService.getAgencyAlerts(route.getAgency().getId())); + } + }); } return alerts.stream().distinct().collect(Collectors.toList()); } else { @@ -267,9 +262,8 @@ public DataFetcher> stopTimesForPattern() { environment, stop -> { TransitService transitService = getTransitService(environment); - GraphQLTypes.GraphQLStopStopTimesForPatternArgs args = new GraphQLTypes.GraphQLStopStopTimesForPatternArgs( - environment.getArguments() - ); + GraphQLTypes.GraphQLStopStopTimesForPatternArgs args = + new GraphQLTypes.GraphQLStopStopTimesForPatternArgs(environment.getArguments()); TripPattern pattern = transitService.getTripPattern( FeedScopedId.parse(args.getGraphQLId()) ); @@ -327,16 +321,13 @@ public DataFetcher> stoptimesForPatterns() { !args.getGraphQLOmitCanceled() ); - return getValue( - environment, - stopTFunction, - station -> - station - .getChildStops() - .stream() - .map(stopTFunction) - .flatMap(Collection::stream) - .collect(Collectors.toList()) + return getValue(environment, stopTFunction, station -> + station + .getChildStops() + .stream() + .map(stopTFunction) + .flatMap(Collection::stream) + .collect(Collectors.toList()) ); }; } @@ -363,16 +354,13 @@ public DataFetcher> stoptimesForServiceDate() { !args.getGraphQLOmitCanceled() ); - return getValue( - environment, - stopTFunction, - station -> - station - .getChildStops() - .stream() - .map(stopTFunction) - .flatMap(Collection::stream) - .collect(Collectors.toList()) + return getValue(environment, stopTFunction, station -> + station + .getChildStops() + .stream() + .map(stopTFunction) + .flatMap(Collection::stream) + .collect(Collectors.toList()) ); }; } @@ -395,10 +383,8 @@ public DataFetcher> stoptimesWithoutPatterns() { ) .stream(); - Stream stream = getValue( - environment, - stopTFunction, - station -> station.getChildStops().stream().flatMap(stopTFunction) + Stream stream = getValue(environment, stopTFunction, station -> + station.getChildStops().stream().flatMap(stopTFunction) ); return stream @@ -427,8 +413,7 @@ public DataFetcher> transfers() { stop -> { Integer maxDistance = new GraphQLTypes.GraphQLStopTransfersArgs( environment.getArguments() - ) - .getGraphQLMaxDistance(); + ).getGraphQLMaxDistance(); return getTransitService(environment) .findPathTransfers(stop) @@ -477,10 +462,7 @@ public DataFetcher vehicleType() { @Override public DataFetcher wheelchairBoarding() { return environment -> { - var boarding = getValue( - environment, - StopLocation::getWheelchairAccessibility, - station -> null + var boarding = getValue(environment, StopLocation::getWheelchairAccessibility, station -> null ); return GraphQLUtils.toGraphQL(boarding); }; @@ -524,11 +506,10 @@ private List getTripTimeOnDatesForPatternAtStopIncludingTripsWit Instant startTime = GraphQLUtils.getTimeOrNow(args.getGraphQLStartTime()); LocalDate date = startTime.atZone(transitService.getTimeZone()).toLocalDate(); - return Stream - .concat( - getRealtimeAddedPatternsAsStream(originalPattern, transitService, date), - Stream.of(originalPattern) - ) + return Stream.concat( + getRealtimeAddedPatternsAsStream(originalPattern, transitService, date), + Stream.of(originalPattern) + ) .flatMap(tripPattern -> transitService .findTripTimeOnDate( @@ -543,8 +524,8 @@ private List getTripTimeOnDatesForPatternAtStopIncludingTripsWit .stream() ) .sorted( - Comparator.comparing((TripTimeOnDate tts) -> - tts.getServiceDayMidnight() + tts.getRealtimeDeparture() + Comparator.comparing( + (TripTimeOnDate tts) -> tts.getServiceDayMidnight() + tts.getRealtimeDeparture() ) ) .limit(args.getGraphQLNumberOfDepartures()) @@ -563,8 +544,10 @@ private Stream getRealtimeAddedPatternsAsStream( return originalPattern .scheduledTripsAsStream() .map(trip -> transitService.findNewTripPatternForModifiedTrip(trip.getId(), date)) - .filter(tripPattern -> - tripPattern != null && tripPattern.isModifiedFromTripPatternWithEqualStops(originalPattern) + .filter( + tripPattern -> + tripPattern != null && + tripPattern.isModifiedFromTripPatternWithEqualStops(originalPattern) ); } diff --git a/application/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/TripImpl.java b/application/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/TripImpl.java index 7e3385f028b..a56765abfcc 100644 --- a/application/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/TripImpl.java +++ b/application/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/TripImpl.java @@ -99,24 +99,20 @@ public DataFetcher> alerts() { alert .entities() .stream() - .anyMatch(entity -> - ( - entity instanceof EntitySelector.StopAndRoute stopAndRoute && - stopAndRoute.routeId().equals(getRoute(environment).getId()) - ) || - ( - entity instanceof EntitySelector.StopAndTrip stopAndTrip && - stopAndTrip.tripId().equals(getSource(environment).getId()) - ) + .anyMatch( + entity -> + (entity instanceof EntitySelector.StopAndRoute stopAndRoute && + stopAndRoute.routeId().equals(getRoute(environment).getId())) || + (entity instanceof EntitySelector.StopAndTrip stopAndTrip && + stopAndTrip.tripId().equals(getSource(environment).getId())) ) ) .toList() ); - getStops(environment) - .forEach(stop -> { - FeedScopedId stopId = ((StopLocation) stop).getId(); - alerts.addAll(alertService.getStopAlerts(stopId)); - }); + getStops(environment).forEach(stop -> { + FeedScopedId stopId = ((StopLocation) stop).getId(); + alerts.addAll(alertService.getStopAlerts(stopId)); + }); break; } }); @@ -186,8 +182,7 @@ public DataFetcher>> geometry() { if (geometry == null) { return null; } - return Arrays - .stream(geometry.getCoordinateSequence().toCoordinateArray()) + return Arrays.stream(geometry.getCoordinateSequence().toCoordinateArray()) .map(coordinate -> Arrays.asList(coordinate.x, coordinate.y)) .collect(Collectors.toList()); }; @@ -241,8 +236,7 @@ public DataFetcher serviceId() { @Override public DataFetcher shapeId() { return environment -> - Optional - .ofNullable(getSource(environment).getShapeId()) + Optional.ofNullable(getSource(environment).getShapeId()) .map(FeedScopedId::toString) .orElse(null); } diff --git a/application/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/TripOnServiceDateImpl.java b/application/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/TripOnServiceDateImpl.java index 9960687c6a9..10b81ed7cf1 100644 --- a/application/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/TripOnServiceDateImpl.java +++ b/application/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/TripOnServiceDateImpl.java @@ -109,9 +109,10 @@ private FromTripTimesArguments getFromTripTimesArguments(DataFetchingEnvironment Trip trip = getTrip(environment); var serviceDate = getSource(environment).getServiceDate(); - Instant midnight = ServiceDateUtils - .asStartOfService(serviceDate, transitService.getTimeZone()) - .toInstant(); + Instant midnight = ServiceDateUtils.asStartOfService( + serviceDate, + transitService.getTimeZone() + ).toInstant(); Timetable timetable = getTimetable(environment, trip, serviceDate); return new FromTripTimesArguments(trip, serviceDate, midnight, timetable); } diff --git a/application/src/main/java/org/opentripplanner/apis/gtfs/generated/GraphQLDataFetchers.java b/application/src/main/java/org/opentripplanner/apis/gtfs/generated/GraphQLDataFetchers.java index 4a29f62e84d..5f7c72c1377 100644 --- a/application/src/main/java/org/opentripplanner/apis/gtfs/generated/GraphQLDataFetchers.java +++ b/application/src/main/java/org/opentripplanner/apis/gtfs/generated/GraphQLDataFetchers.java @@ -401,7 +401,9 @@ public interface GraphQLEntrance { public DataFetcher publicCode(); - public DataFetcher wheelchairAccessible(); + public DataFetcher< + org.opentripplanner.apis.gtfs.generated.GraphQLTypes.GraphQLWheelchairBoarding + > wheelchairAccessible(); } /** Real-time estimates for an arrival or departure at a certain place. */ @@ -850,9 +852,13 @@ public interface GraphQLQueryType { public DataFetcher> patterns(); - public DataFetcher> plan(); + public DataFetcher< + graphql.execution.DataFetcherResult + > plan(); - public DataFetcher> planConnection(); + public DataFetcher< + graphql.execution.DataFetcherResult + > planConnection(); public DataFetcher rentalVehicle(); @@ -946,9 +952,13 @@ public interface GraphQLRentalVehicleFuel { } public interface GraphQLRentalVehicleType { - public DataFetcher formFactor(); + public DataFetcher< + org.opentripplanner.apis.gtfs.generated.GraphQLTypes.GraphQLFormFactor + > formFactor(); - public DataFetcher propulsionType(); + public DataFetcher< + org.opentripplanner.apis.gtfs.generated.GraphQLTypes.GraphQLPropulsionType + > propulsionType(); } public interface GraphQLRentalVehicleTypeCount { @@ -1106,7 +1116,9 @@ public interface GraphQLStop { public DataFetcher vehicleType(); - public DataFetcher wheelchairBoarding(); + public DataFetcher< + org.opentripplanner.apis.gtfs.generated.GraphQLTypes.GraphQLWheelchairBoarding + > wheelchairBoarding(); public DataFetcher zoneId(); } @@ -1275,7 +1287,9 @@ public interface GraphQLTrip { public DataFetcher tripShortName(); - public DataFetcher wheelchairAccessible(); + public DataFetcher< + org.opentripplanner.apis.gtfs.generated.GraphQLTypes.GraphQLWheelchairBoarding + > wheelchairAccessible(); } /** @@ -1541,7 +1555,9 @@ public interface GraphQLStep { public DataFetcher distance(); - public DataFetcher> elevationProfile(); + public DataFetcher< + Iterable + > elevationProfile(); public DataFetcher exit(); diff --git a/application/src/main/java/org/opentripplanner/apis/gtfs/generated/GraphQLTypes.java b/application/src/main/java/org/opentripplanner/apis/gtfs/generated/GraphQLTypes.java index c12ccb82888..7973b909b3a 100644 --- a/application/src/main/java/org/opentripplanner/apis/gtfs/generated/GraphQLTypes.java +++ b/application/src/main/java/org/opentripplanner/apis/gtfs/generated/GraphQLTypes.java @@ -25,8 +25,9 @@ public static class GraphQLAccessibilityPreferencesInput { public GraphQLAccessibilityPreferencesInput(Map args) { if (args != null) { - this.wheelchair = - new GraphQLWheelchairPreferencesInput((Map) args.get("wheelchair")); + this.wheelchair = new GraphQLWheelchairPreferencesInput( + (Map) args.get("wheelchair") + ); } } @@ -46,15 +47,14 @@ public static class GraphQLAgencyAlertsArgs { public GraphQLAgencyAlertsArgs(Map args) { if (args != null) { if (args.get("types") != null) { - this.types = - ((List) args.get("types")).stream() - .map(item -> - item instanceof GraphQLAgencyAlertType - ? item - : GraphQLAgencyAlertType.valueOf((String) item) - ) - .map(GraphQLAgencyAlertType.class::cast) - .collect(Collectors.toList()); + this.types = ((List) args.get("types")).stream() + .map(item -> + item instanceof GraphQLAgencyAlertType + ? item + : GraphQLAgencyAlertType.valueOf((String) item) + ) + .map(GraphQLAgencyAlertType.class::cast) + .collect(Collectors.toList()); } } } @@ -204,8 +204,9 @@ public GraphQLBicycleParkingPreferencesInput(Map args) { if (args.get("preferred") != null) { this.preferred = (List) args.get("preferred"); } - this.unpreferredCost = - (org.opentripplanner.framework.model.Cost) args.get("unpreferredCost"); + this.unpreferredCost = (org.opentripplanner.framework.model.Cost) args.get( + "unpreferredCost" + ); } } @@ -249,13 +250,16 @@ public static class GraphQLBicyclePreferencesInput { public GraphQLBicyclePreferencesInput(Map args) { if (args != null) { this.boardCost = (org.opentripplanner.framework.model.Cost) args.get("boardCost"); - this.optimization = - new GraphQLCyclingOptimizationInput((Map) args.get("optimization")); - this.parking = - new GraphQLBicycleParkingPreferencesInput((Map) args.get("parking")); + this.optimization = new GraphQLCyclingOptimizationInput( + (Map) args.get("optimization") + ); + this.parking = new GraphQLBicycleParkingPreferencesInput( + (Map) args.get("parking") + ); this.reluctance = (Double) args.get("reluctance"); - this.rental = - new GraphQLBicycleRentalPreferencesInput((Map) args.get("rental")); + this.rental = new GraphQLBicycleRentalPreferencesInput( + (Map) args.get("rental") + ); this.speed = (Double) args.get("speed"); this.walk = new GraphQLBicycleWalkPreferencesInput((Map) args.get("walk")); } @@ -328,10 +332,9 @@ public GraphQLBicycleRentalPreferencesInput(Map args) { if (args != null) { this.allowedNetworks = (List) args.get("allowedNetworks"); this.bannedNetworks = (List) args.get("bannedNetworks"); - this.destinationBicyclePolicy = - new GraphQLDestinationBicyclePolicyInput( - (Map) args.get("destinationBicyclePolicy") - ); + this.destinationBicyclePolicy = new GraphQLDestinationBicyclePolicyInput( + (Map) args.get("destinationBicyclePolicy") + ); } } @@ -369,8 +372,9 @@ public static class GraphQLBicycleWalkPreferencesCostInput { public GraphQLBicycleWalkPreferencesCostInput(Map args) { if (args != null) { - this.mountDismountCost = - (org.opentripplanner.framework.model.Cost) args.get("mountDismountCost"); + this.mountDismountCost = (org.opentripplanner.framework.model.Cost) args.get( + "mountDismountCost" + ); this.reluctance = (Double) args.get("reluctance"); } } @@ -402,8 +406,9 @@ public static class GraphQLBicycleWalkPreferencesInput { public GraphQLBicycleWalkPreferencesInput(Map args) { if (args != null) { - this.cost = - new GraphQLBicycleWalkPreferencesCostInput((Map) args.get("cost")); + this.cost = new GraphQLBicycleWalkPreferencesCostInput( + (Map) args.get("cost") + ); this.mountDismountTime = (java.time.Duration) args.get("mountDismountTime"); this.speed = (Double) args.get("speed"); } @@ -521,8 +526,9 @@ public GraphQLCarParkingPreferencesInput(Map args) { if (args.get("preferred") != null) { this.preferred = (List) args.get("preferred"); } - this.unpreferredCost = - (org.opentripplanner.framework.model.Cost) args.get("unpreferredCost"); + this.unpreferredCost = (org.opentripplanner.framework.model.Cost) args.get( + "unpreferredCost" + ); } } @@ -563,11 +569,13 @@ public static class GraphQLCarPreferencesInput { public GraphQLCarPreferencesInput(Map args) { if (args != null) { this.boardCost = (org.opentripplanner.framework.model.Cost) args.get("boardCost"); - this.parking = - new GraphQLCarParkingPreferencesInput((Map) args.get("parking")); + this.parking = new GraphQLCarParkingPreferencesInput( + (Map) args.get("parking") + ); this.reluctance = (Double) args.get("reluctance"); - this.rental = - new GraphQLCarRentalPreferencesInput((Map) args.get("rental")); + this.rental = new GraphQLCarRentalPreferencesInput( + (Map) args.get("rental") + ); } } @@ -640,8 +648,9 @@ public static class GraphQLCyclingOptimizationInput { public GraphQLCyclingOptimizationInput(Map args) { if (args != null) { - this.triangle = - new GraphQLTriangleCyclingFactorsInput((Map) args.get("triangle")); + this.triangle = new GraphQLTriangleCyclingFactorsInput( + (Map) args.get("triangle") + ); if (args.get("type") instanceof GraphQLCyclingOptimizationType) { this.type = (GraphQLCyclingOptimizationType) args.get("type"); } else if (args.get("type") != null) { @@ -802,15 +811,14 @@ public static class GraphQLFeedAlertsArgs { public GraphQLFeedAlertsArgs(Map args) { if (args != null) { if (args.get("types") != null) { - this.types = - ((List) args.get("types")).stream() - .map(item -> - item instanceof GraphQLFeedAlertType - ? item - : GraphQLFeedAlertType.valueOf((String) item) - ) - .map(GraphQLFeedAlertType.class::cast) - .collect(Collectors.toList()); + this.types = ((List) args.get("types")).stream() + .map(item -> + item instanceof GraphQLFeedAlertType + ? item + : GraphQLFeedAlertType.valueOf((String) item) + ) + .map(GraphQLFeedAlertType.class::cast) + .collect(Collectors.toList()); } } } @@ -1192,8 +1200,9 @@ public static class GraphQLInputPreferredInput { public GraphQLInputPreferredInput(Map args) { if (args != null) { this.agencies = (String) args.get("agencies"); - this.otherThanPreferredRoutesPenalty = - (Integer) args.get("otherThanPreferredRoutesPenalty"); + this.otherThanPreferredRoutesPenalty = (Integer) args.get( + "otherThanPreferredRoutesPenalty" + ); this.routes = (String) args.get("routes"); } } @@ -1331,27 +1340,25 @@ public static class GraphQLLegNextLegsArgs { public GraphQLLegNextLegsArgs(Map args) { if (args != null) { if (args.get("destinationModesWithParentStation") != null) { - this.destinationModesWithParentStation = - ((List) args.get("destinationModesWithParentStation")).stream() - .map(item -> - item instanceof GraphQLTransitMode - ? item - : GraphQLTransitMode.valueOf((String) item) - ) - .map(GraphQLTransitMode.class::cast) - .collect(Collectors.toList()); + this.destinationModesWithParentStation = ((List) args.get( + "destinationModesWithParentStation" + )).stream() + .map(item -> + item instanceof GraphQLTransitMode ? item : GraphQLTransitMode.valueOf((String) item) + ) + .map(GraphQLTransitMode.class::cast) + .collect(Collectors.toList()); } this.numberOfLegs = (Integer) args.get("numberOfLegs"); if (args.get("originModesWithParentStation") != null) { - this.originModesWithParentStation = - ((List) args.get("originModesWithParentStation")).stream() - .map(item -> - item instanceof GraphQLTransitMode - ? item - : GraphQLTransitMode.valueOf((String) item) - ) - .map(GraphQLTransitMode.class::cast) - .collect(Collectors.toList()); + this.originModesWithParentStation = ((List) args.get( + "originModesWithParentStation" + )).stream() + .map(item -> + item instanceof GraphQLTransitMode ? item : GraphQLTransitMode.valueOf((String) item) + ) + .map(GraphQLTransitMode.class::cast) + .collect(Collectors.toList()); } } } @@ -1394,27 +1401,25 @@ public static class GraphQLLegPreviousLegsArgs { public GraphQLLegPreviousLegsArgs(Map args) { if (args != null) { if (args.get("destinationModesWithParentStation") != null) { - this.destinationModesWithParentStation = - ((List) args.get("destinationModesWithParentStation")).stream() - .map(item -> - item instanceof GraphQLTransitMode - ? item - : GraphQLTransitMode.valueOf((String) item) - ) - .map(GraphQLTransitMode.class::cast) - .collect(Collectors.toList()); + this.destinationModesWithParentStation = ((List) args.get( + "destinationModesWithParentStation" + )).stream() + .map(item -> + item instanceof GraphQLTransitMode ? item : GraphQLTransitMode.valueOf((String) item) + ) + .map(GraphQLTransitMode.class::cast) + .collect(Collectors.toList()); } this.numberOfLegs = (Integer) args.get("numberOfLegs"); if (args.get("originModesWithParentStation") != null) { - this.originModesWithParentStation = - ((List) args.get("originModesWithParentStation")).stream() - .map(item -> - item instanceof GraphQLTransitMode - ? item - : GraphQLTransitMode.valueOf((String) item) - ) - .map(GraphQLTransitMode.class::cast) - .collect(Collectors.toList()); + this.originModesWithParentStation = ((List) args.get( + "originModesWithParentStation" + )).stream() + .map(item -> + item instanceof GraphQLTransitMode ? item : GraphQLTransitMode.valueOf((String) item) + ) + .map(GraphQLTransitMode.class::cast) + .collect(Collectors.toList()); } } } @@ -1608,15 +1613,14 @@ public static class GraphQLPatternAlertsArgs { public GraphQLPatternAlertsArgs(Map args) { if (args != null) { if (args.get("types") != null) { - this.types = - ((List) args.get("types")).stream() - .map(item -> - item instanceof GraphQLPatternAlertType - ? item - : GraphQLPatternAlertType.valueOf((String) item) - ) - .map(GraphQLPatternAlertType.class::cast) - .collect(Collectors.toList()); + this.types = ((List) args.get("types")).stream() + .map(item -> + item instanceof GraphQLPatternAlertType + ? item + : GraphQLPatternAlertType.valueOf((String) item) + ) + .map(GraphQLPatternAlertType.class::cast) + .collect(Collectors.toList()); } } } @@ -1775,16 +1779,17 @@ public GraphQLPlanItineraryFilterInput(Map args) { if (args != null) { this.groupSimilarityKeepOne = (Double) args.get("groupSimilarityKeepOne"); this.groupSimilarityKeepThree = (Double) args.get("groupSimilarityKeepThree"); - this.groupedOtherThanSameLegsMaxCostMultiplier = - (Double) args.get("groupedOtherThanSameLegsMaxCostMultiplier"); + this.groupedOtherThanSameLegsMaxCostMultiplier = (Double) args.get( + "groupedOtherThanSameLegsMaxCostMultiplier" + ); if (args.get("itineraryFilterDebugProfile") instanceof GraphQLItineraryFilterDebugProfile) { - this.itineraryFilterDebugProfile = - (GraphQLItineraryFilterDebugProfile) args.get("itineraryFilterDebugProfile"); + this.itineraryFilterDebugProfile = (GraphQLItineraryFilterDebugProfile) args.get( + "itineraryFilterDebugProfile" + ); } else if (args.get("itineraryFilterDebugProfile") != null) { - this.itineraryFilterDebugProfile = - GraphQLItineraryFilterDebugProfile.valueOf( - (String) args.get("itineraryFilterDebugProfile") - ); + this.itineraryFilterDebugProfile = GraphQLItineraryFilterDebugProfile.valueOf( + (String) args.get("itineraryFilterDebugProfile") + ); } } } @@ -1862,10 +1867,12 @@ public static class GraphQLPlanLocationInput { public GraphQLPlanLocationInput(Map args) { if (args != null) { - this.coordinate = - new GraphQLPlanCoordinateInput((Map) args.get("coordinate")); - this.stopLocation = - new GraphQLPlanStopLocationInput((Map) args.get("stopLocation")); + this.coordinate = new GraphQLPlanCoordinateInput( + (Map) args.get("coordinate") + ); + this.stopLocation = new GraphQLPlanStopLocationInput( + (Map) args.get("stopLocation") + ); } } @@ -1896,15 +1903,14 @@ public static class GraphQLPlanModesInput { public GraphQLPlanModesInput(Map args) { if (args != null) { if (args.get("direct") != null) { - this.direct = - ((List) args.get("direct")).stream() - .map(item -> - item instanceof GraphQLPlanDirectMode - ? item - : GraphQLPlanDirectMode.valueOf((String) item) - ) - .map(GraphQLPlanDirectMode.class::cast) - .collect(Collectors.toList()); + this.direct = ((List) args.get("direct")).stream() + .map(item -> + item instanceof GraphQLPlanDirectMode + ? item + : GraphQLPlanDirectMode.valueOf((String) item) + ) + .map(GraphQLPlanDirectMode.class::cast) + .collect(Collectors.toList()); } this.directOnly = (Boolean) args.get("directOnly"); this.transit = new GraphQLPlanTransitModesInput((Map) args.get("transit")); @@ -1982,12 +1988,15 @@ public static class GraphQLPlanPreferencesInput { public GraphQLPlanPreferencesInput(Map args) { if (args != null) { - this.accessibility = - new GraphQLAccessibilityPreferencesInput((Map) args.get("accessibility")); - this.street = - new GraphQLPlanStreetPreferencesInput((Map) args.get("street")); - this.transit = - new GraphQLTransitPreferencesInput((Map) args.get("transit")); + this.accessibility = new GraphQLAccessibilityPreferencesInput( + (Map) args.get("accessibility") + ); + this.street = new GraphQLPlanStreetPreferencesInput( + (Map) args.get("street") + ); + this.transit = new GraphQLTransitPreferencesInput( + (Map) args.get("transit") + ); } } @@ -2044,11 +2053,13 @@ public static class GraphQLPlanStreetPreferencesInput { public GraphQLPlanStreetPreferencesInput(Map args) { if (args != null) { - this.bicycle = - new GraphQLBicyclePreferencesInput((Map) args.get("bicycle")); + this.bicycle = new GraphQLBicyclePreferencesInput( + (Map) args.get("bicycle") + ); this.car = new GraphQLCarPreferencesInput((Map) args.get("car")); - this.scooter = - new GraphQLScooterPreferencesInput((Map) args.get("scooter")); + this.scooter = new GraphQLScooterPreferencesInput( + (Map) args.get("scooter") + ); this.walk = new GraphQLWalkPreferencesInput((Map) args.get("walk")); } } @@ -2099,8 +2110,9 @@ public static class GraphQLPlanTransitModePreferenceInput { public GraphQLPlanTransitModePreferenceInput(Map args) { if (args != null) { - this.cost = - new GraphQLTransitModePreferenceCostInput((Map) args.get("cost")); + this.cost = new GraphQLTransitModePreferenceCostInput( + (Map) args.get("cost") + ); if (args.get("mode") instanceof GraphQLTransitMode) { this.mode = (GraphQLTransitMode) args.get("mode"); } else if (args.get("mode") != null) { @@ -2136,37 +2148,34 @@ public static class GraphQLPlanTransitModesInput { public GraphQLPlanTransitModesInput(Map args) { if (args != null) { if (args.get("access") != null) { - this.access = - ((List) args.get("access")).stream() - .map(item -> - item instanceof GraphQLPlanAccessMode - ? item - : GraphQLPlanAccessMode.valueOf((String) item) - ) - .map(GraphQLPlanAccessMode.class::cast) - .collect(Collectors.toList()); + this.access = ((List) args.get("access")).stream() + .map(item -> + item instanceof GraphQLPlanAccessMode + ? item + : GraphQLPlanAccessMode.valueOf((String) item) + ) + .map(GraphQLPlanAccessMode.class::cast) + .collect(Collectors.toList()); } if (args.get("egress") != null) { - this.egress = - ((List) args.get("egress")).stream() - .map(item -> - item instanceof GraphQLPlanEgressMode - ? item - : GraphQLPlanEgressMode.valueOf((String) item) - ) - .map(GraphQLPlanEgressMode.class::cast) - .collect(Collectors.toList()); + this.egress = ((List) args.get("egress")).stream() + .map(item -> + item instanceof GraphQLPlanEgressMode + ? item + : GraphQLPlanEgressMode.valueOf((String) item) + ) + .map(GraphQLPlanEgressMode.class::cast) + .collect(Collectors.toList()); } if (args.get("transfer") != null) { - this.transfer = - ((List) args.get("transfer")).stream() - .map(item -> - item instanceof GraphQLPlanTransferMode - ? item - : GraphQLPlanTransferMode.valueOf((String) item) - ) - .map(GraphQLPlanTransferMode.class::cast) - .collect(Collectors.toList()); + this.transfer = ((List) args.get("transfer")).stream() + .map(item -> + item instanceof GraphQLPlanTransferMode + ? item + : GraphQLPlanTransferMode.valueOf((String) item) + ) + .map(GraphQLPlanTransferMode.class::cast) + .collect(Collectors.toList()); } if (args.get("transit") != null) { this.transit = (List) args.get("transit"); @@ -2214,8 +2223,9 @@ public static class GraphQLPlanViaLocationInput { public GraphQLPlanViaLocationInput(Map args) { if (args != null) { - this.passThrough = - new GraphQLPlanPassThroughViaLocationInput((Map) args.get("passThrough")); + this.passThrough = new GraphQLPlanPassThroughViaLocationInput( + (Map) args.get("passThrough") + ); this.visit = new GraphQLPlanVisitViaLocationInput((Map) args.get("visit")); } } @@ -2335,39 +2345,36 @@ public static class GraphQLQueryTypeAlertsArgs { public GraphQLQueryTypeAlertsArgs(Map args) { if (args != null) { if (args.get("cause") != null) { - this.cause = - ((List) args.get("cause")).stream() - .map(item -> - item instanceof GraphQLAlertCauseType - ? item - : GraphQLAlertCauseType.valueOf((String) item) - ) - .map(GraphQLAlertCauseType.class::cast) - .collect(Collectors.toList()); + this.cause = ((List) args.get("cause")).stream() + .map(item -> + item instanceof GraphQLAlertCauseType + ? item + : GraphQLAlertCauseType.valueOf((String) item) + ) + .map(GraphQLAlertCauseType.class::cast) + .collect(Collectors.toList()); } if (args.get("effect") != null) { - this.effect = - ((List) args.get("effect")).stream() - .map(item -> - item instanceof GraphQLAlertEffectType - ? item - : GraphQLAlertEffectType.valueOf((String) item) - ) - .map(GraphQLAlertEffectType.class::cast) - .collect(Collectors.toList()); + this.effect = ((List) args.get("effect")).stream() + .map(item -> + item instanceof GraphQLAlertEffectType + ? item + : GraphQLAlertEffectType.valueOf((String) item) + ) + .map(GraphQLAlertEffectType.class::cast) + .collect(Collectors.toList()); } this.feeds = (List) args.get("feeds"); this.route = (List) args.get("route"); if (args.get("severityLevel") != null) { - this.severityLevel = - ((List) args.get("severityLevel")).stream() - .map(item -> - item instanceof GraphQLAlertSeverityLevelType - ? item - : GraphQLAlertSeverityLevelType.valueOf((String) item) - ) - .map(GraphQLAlertSeverityLevelType.class::cast) - .collect(Collectors.toList()); + this.severityLevel = ((List) args.get("severityLevel")).stream() + .map(item -> + item instanceof GraphQLAlertSeverityLevelType + ? item + : GraphQLAlertSeverityLevelType.valueOf((String) item) + ) + .map(GraphQLAlertSeverityLevelType.class::cast) + .collect(Collectors.toList()); } this.stop = (List) args.get("stop"); } @@ -2800,26 +2807,25 @@ public GraphQLQueryTypeNearestArgs(Map args) { if (args != null) { this.after = (String) args.get("after"); this.before = (String) args.get("before"); - this.filterByIds = - new GraphQLInputFiltersInput((Map) args.get("filterByIds")); + this.filterByIds = new GraphQLInputFiltersInput( + (Map) args.get("filterByIds") + ); if (args.get("filterByModes") != null) { - this.filterByModes = - ((List) args.get("filterByModes")).stream() - .map(item -> item instanceof GraphQLMode ? item : GraphQLMode.valueOf((String) item)) - .map(GraphQLMode.class::cast) - .collect(Collectors.toList()); + this.filterByModes = ((List) args.get("filterByModes")).stream() + .map(item -> item instanceof GraphQLMode ? item : GraphQLMode.valueOf((String) item)) + .map(GraphQLMode.class::cast) + .collect(Collectors.toList()); } this.filterByNetwork = (List) args.get("filterByNetwork"); if (args.get("filterByPlaceTypes") != null) { - this.filterByPlaceTypes = - ((List) args.get("filterByPlaceTypes")).stream() - .map(item -> - item instanceof GraphQLFilterPlaceType - ? item - : GraphQLFilterPlaceType.valueOf((String) item) - ) - .map(GraphQLFilterPlaceType.class::cast) - .collect(Collectors.toList()); + this.filterByPlaceTypes = ((List) args.get("filterByPlaceTypes")).stream() + .map(item -> + item instanceof GraphQLFilterPlaceType + ? item + : GraphQLFilterPlaceType.valueOf((String) item) + ) + .map(GraphQLFilterPlaceType.class::cast) + .collect(Collectors.toList()); } this.first = (Integer) args.get("first"); this.last = (Integer) args.get("last"); @@ -3036,8 +3042,9 @@ public GraphQLQueryTypePlanArgs(Map args) { if (args != null) { this.alightSlack = (Integer) args.get("alightSlack"); this.allowBikeRental = (Boolean) args.get("allowBikeRental"); - this.allowKeepingRentedBicycleAtDestination = - (Boolean) args.get("allowKeepingRentedBicycleAtDestination"); + this.allowKeepingRentedBicycleAtDestination = (Boolean) args.get( + "allowKeepingRentedBicycleAtDestination" + ); this.allowedBikeRentalNetworks = (List) args.get("allowedBikeRentalNetworks"); this.allowedTicketTypes = (List) args.get("allowedTicketTypes"); this.allowedVehicleRentalNetworks = (List) args.get("allowedVehicleRentalNetworks"); @@ -3058,26 +3065,30 @@ public GraphQLQueryTypePlanArgs(Map args) { this.compactLegsByReversedSearch = (Boolean) args.get("compactLegsByReversedSearch"); this.date = (String) args.get("date"); this.debugItineraryFilter = (Boolean) args.get("debugItineraryFilter"); - this.disableRemainingWeightHeuristic = - (Boolean) args.get("disableRemainingWeightHeuristic"); + this.disableRemainingWeightHeuristic = (Boolean) args.get( + "disableRemainingWeightHeuristic" + ); this.from = new GraphQLInputCoordinatesInput((Map) args.get("from")); this.fromPlace = (String) args.get("fromPlace"); this.heuristicStepsPerMainStep = (Integer) args.get("heuristicStepsPerMainStep"); this.ignoreRealtimeUpdates = (Boolean) args.get("ignoreRealtimeUpdates"); if (args.get("intermediatePlaces") != null) { - this.intermediatePlaces = - (List) args.get("intermediatePlaces"); + this.intermediatePlaces = (List) args.get( + "intermediatePlaces" + ); } this.itineraryFiltering = (Double) args.get("itineraryFiltering"); - this.keepingRentedBicycleAtDestinationCost = - (Integer) args.get("keepingRentedBicycleAtDestinationCost"); + this.keepingRentedBicycleAtDestinationCost = (Integer) args.get( + "keepingRentedBicycleAtDestinationCost" + ); this.locale = (String) args.get("locale"); this.maxPreTransitTime = (Integer) args.get("maxPreTransitTime"); this.maxTransfers = (Integer) args.get("maxTransfers"); this.maxWalkDistance = (Double) args.get("maxWalkDistance"); this.minTransferTime = (Integer) args.get("minTransferTime"); - this.modeWeight = - new GraphQLInputModeWeightInput((Map) args.get("modeWeight")); + this.modeWeight = new GraphQLInputModeWeightInput( + (Map) args.get("modeWeight") + ); this.nonpreferredTransferPenalty = (Integer) args.get("nonpreferredTransferPenalty"); this.numItineraries = (Integer) args.get("numItineraries"); this.omitCanceled = (Boolean) args.get("omitCanceled"); @@ -3088,8 +3099,9 @@ public GraphQLQueryTypePlanArgs(Map args) { } this.pageCursor = (String) args.get("pageCursor"); this.parking = new GraphQLVehicleParkingInput((Map) args.get("parking")); - this.preferred = - new GraphQLInputPreferredInput((Map) args.get("preferred")); + this.preferred = new GraphQLInputPreferredInput( + (Map) args.get("preferred") + ); this.reverseOptimizeOnTheFly = (Boolean) args.get("reverseOptimizeOnTheFly"); this.searchWindow = (Long) args.get("searchWindow"); this.startTransitStopId = (String) args.get("startTransitStopId"); @@ -3102,8 +3114,9 @@ public GraphQLQueryTypePlanArgs(Map args) { this.transportModes = (List) args.get("transportModes"); } this.triangle = new GraphQLInputTriangleInput((Map) args.get("triangle")); - this.unpreferred = - new GraphQLInputUnpreferredInput((Map) args.get("unpreferred")); + this.unpreferred = new GraphQLInputUnpreferredInput( + (Map) args.get("unpreferred") + ); if (args.get("via") != null) { this.via = (List) args.get("via"); } @@ -3658,17 +3671,20 @@ public GraphQLQueryTypePlanConnectionArgs(Map args) { this.after = (String) args.get("after"); this.before = (String) args.get("before"); this.dateTime = new GraphQLPlanDateTimeInput((Map) args.get("dateTime")); - this.destination = - new GraphQLPlanLabeledLocationInput((Map) args.get("destination")); + this.destination = new GraphQLPlanLabeledLocationInput( + (Map) args.get("destination") + ); this.first = (Integer) args.get("first"); - this.itineraryFilter = - new GraphQLPlanItineraryFilterInput((Map) args.get("itineraryFilter")); + this.itineraryFilter = new GraphQLPlanItineraryFilterInput( + (Map) args.get("itineraryFilter") + ); this.last = (Integer) args.get("last"); this.locale = (java.util.Locale) args.get("locale"); this.modes = new GraphQLPlanModesInput((Map) args.get("modes")); this.origin = new GraphQLPlanLabeledLocationInput((Map) args.get("origin")); - this.preferences = - new GraphQLPlanPreferencesInput((Map) args.get("preferences")); + this.preferences = new GraphQLPlanPreferencesInput( + (Map) args.get("preferences") + ); this.searchWindow = (java.time.Duration) args.get("searchWindow"); if (args.get("via") != null) { this.via = (List) args.get("via"); @@ -3808,13 +3824,12 @@ public static class GraphQLQueryTypeRentalVehiclesArgs { public GraphQLQueryTypeRentalVehiclesArgs(Map args) { if (args != null) { if (args.get("formFactors") != null) { - this.formFactors = - ((List) args.get("formFactors")).stream() - .map(item -> - item instanceof GraphQLFormFactor ? item : GraphQLFormFactor.valueOf((String) item) - ) - .map(GraphQLFormFactor.class::cast) - .collect(Collectors.toList()); + this.formFactors = ((List) args.get("formFactors")).stream() + .map(item -> + item instanceof GraphQLFormFactor ? item : GraphQLFormFactor.valueOf((String) item) + ) + .map(GraphQLFormFactor.class::cast) + .collect(Collectors.toList()); } this.ids = (List) args.get("ids"); } @@ -3869,14 +3884,14 @@ public GraphQLQueryTypeRoutesArgs(Map args) { this.feeds = (List) args.get("feeds"); this.ids = (List) args.get("ids"); this.name = (String) args.get("name"); - this.serviceDates = - new GraphQLLocalDateRangeInput((Map) args.get("serviceDates")); + this.serviceDates = new GraphQLLocalDateRangeInput( + (Map) args.get("serviceDates") + ); if (args.get("transportModes") != null) { - this.transportModes = - ((List) args.get("transportModes")).stream() - .map(item -> item instanceof GraphQLMode ? item : GraphQLMode.valueOf((String) item)) - .map(GraphQLMode.class::cast) - .collect(Collectors.toList()); + this.transportModes = ((List) args.get("transportModes")).stream() + .map(item -> item instanceof GraphQLMode ? item : GraphQLMode.valueOf((String) item)) + .map(GraphQLMode.class::cast) + .collect(Collectors.toList()); } } } @@ -4368,15 +4383,14 @@ public static class GraphQLRouteAlertsArgs { public GraphQLRouteAlertsArgs(Map args) { if (args != null) { if (args.get("types") != null) { - this.types = - ((List) args.get("types")).stream() - .map(item -> - item instanceof GraphQLRouteAlertType - ? item - : GraphQLRouteAlertType.valueOf((String) item) - ) - .map(GraphQLRouteAlertType.class::cast) - .collect(Collectors.toList()); + this.types = ((List) args.get("types")).stream() + .map(item -> + item instanceof GraphQLRouteAlertType + ? item + : GraphQLRouteAlertType.valueOf((String) item) + ) + .map(GraphQLRouteAlertType.class::cast) + .collect(Collectors.toList()); } } } @@ -4415,8 +4429,9 @@ public static class GraphQLRoutePatternsArgs { public GraphQLRoutePatternsArgs(Map args) { if (args != null) { - this.serviceDates = - new GraphQLLocalDateRangeInput((Map) args.get("serviceDates")); + this.serviceDates = new GraphQLLocalDateRangeInput( + (Map) args.get("serviceDates") + ); } } @@ -4457,8 +4472,9 @@ public static class GraphQLScooterOptimizationInput { public GraphQLScooterOptimizationInput(Map args) { if (args != null) { - this.triangle = - new GraphQLTriangleScooterFactorsInput((Map) args.get("triangle")); + this.triangle = new GraphQLTriangleScooterFactorsInput( + (Map) args.get("triangle") + ); if (args.get("type") instanceof GraphQLScooterOptimizationType) { this.type = (GraphQLScooterOptimizationType) args.get("type"); } else if (args.get("type") != null) { @@ -4504,11 +4520,13 @@ public static class GraphQLScooterPreferencesInput { public GraphQLScooterPreferencesInput(Map args) { if (args != null) { - this.optimization = - new GraphQLScooterOptimizationInput((Map) args.get("optimization")); + this.optimization = new GraphQLScooterOptimizationInput( + (Map) args.get("optimization") + ); this.reluctance = (Double) args.get("reluctance"); - this.rental = - new GraphQLScooterRentalPreferencesInput((Map) args.get("rental")); + this.rental = new GraphQLScooterRentalPreferencesInput( + (Map) args.get("rental") + ); this.speed = (Double) args.get("speed"); } } @@ -4556,10 +4574,9 @@ public GraphQLScooterRentalPreferencesInput(Map args) { if (args != null) { this.allowedNetworks = (List) args.get("allowedNetworks"); this.bannedNetworks = (List) args.get("bannedNetworks"); - this.destinationScooterPolicy = - new GraphQLDestinationScooterPolicyInput( - (Map) args.get("destinationScooterPolicy") - ); + this.destinationScooterPolicy = new GraphQLDestinationScooterPolicyInput( + (Map) args.get("destinationScooterPolicy") + ); } } @@ -4597,15 +4614,14 @@ public static class GraphQLStopAlertsArgs { public GraphQLStopAlertsArgs(Map args) { if (args != null) { if (args.get("types") != null) { - this.types = - ((List) args.get("types")).stream() - .map(item -> - item instanceof GraphQLStopAlertType - ? item - : GraphQLStopAlertType.valueOf((String) item) - ) - .map(GraphQLStopAlertType.class::cast) - .collect(Collectors.toList()); + this.types = ((List) args.get("types")).stream() + .map(item -> + item instanceof GraphQLStopAlertType + ? item + : GraphQLStopAlertType.valueOf((String) item) + ) + .map(GraphQLStopAlertType.class::cast) + .collect(Collectors.toList()); } } } @@ -4663,8 +4679,9 @@ public static class GraphQLStopRoutesArgs { public GraphQLStopRoutesArgs(Map args) { if (args != null) { - this.serviceDates = - new GraphQLLocalDateRangeInput((Map) args.get("serviceDates")); + this.serviceDates = new GraphQLLocalDateRangeInput( + (Map) args.get("serviceDates") + ); } } @@ -5111,10 +5128,12 @@ public GraphQLTransitPreferencesInput(Map args) { if (args != null) { this.alight = new GraphQLAlightPreferencesInput((Map) args.get("alight")); this.board = new GraphQLBoardPreferencesInput((Map) args.get("board")); - this.timetable = - new GraphQLTimetablePreferencesInput((Map) args.get("timetable")); - this.transfer = - new GraphQLTransferPreferencesInput((Map) args.get("transfer")); + this.timetable = new GraphQLTimetablePreferencesInput( + (Map) args.get("timetable") + ); + this.transfer = new GraphQLTransferPreferencesInput( + (Map) args.get("transfer") + ); } } @@ -5273,15 +5292,14 @@ public static class GraphQLTripAlertsArgs { public GraphQLTripAlertsArgs(Map args) { if (args != null) { if (args.get("types") != null) { - this.types = - ((List) args.get("types")).stream() - .map(item -> - item instanceof GraphQLTripAlertType - ? item - : GraphQLTripAlertType.valueOf((String) item) - ) - .map(GraphQLTripAlertType.class::cast) - .collect(Collectors.toList()); + this.types = ((List) args.get("types")).stream() + .map(item -> + item instanceof GraphQLTripAlertType + ? item + : GraphQLTripAlertType.valueOf((String) item) + ) + .map(GraphQLTripAlertType.class::cast) + .collect(Collectors.toList()); } } } diff --git a/application/src/main/java/org/opentripplanner/apis/gtfs/mapping/routerequest/ArgumentUtils.java b/application/src/main/java/org/opentripplanner/apis/gtfs/mapping/routerequest/ArgumentUtils.java index 8541bd1c3c5..e116026dca0 100644 --- a/application/src/main/java/org/opentripplanner/apis/gtfs/mapping/routerequest/ArgumentUtils.java +++ b/application/src/main/java/org/opentripplanner/apis/gtfs/mapping/routerequest/ArgumentUtils.java @@ -44,13 +44,10 @@ static List> getTransitModes(DataFetchingEnvironment environ @Nullable static Map getParking(DataFetchingEnvironment environment, String type) { return ( - (Map) ( - (Map) ( - (Map) ((Map) environment.getArgument("preferences")).get( - "street" - ) - ).get(type) - ).get("parking") + (Map) ((Map) ((Map) ((Map< + String, + Object + >) environment.getArgument("preferences")).get("street")).get(type)).get("parking") ); } diff --git a/application/src/main/java/org/opentripplanner/apis/gtfs/mapping/routerequest/LegacyRouteRequestMapper.java b/application/src/main/java/org/opentripplanner/apis/gtfs/mapping/routerequest/LegacyRouteRequestMapper.java index 19bee5e430d..3b7211351be 100644 --- a/application/src/main/java/org/opentripplanner/apis/gtfs/mapping/routerequest/LegacyRouteRequestMapper.java +++ b/application/src/main/java/org/opentripplanner/apis/gtfs/mapping/routerequest/LegacyRouteRequestMapper.java @@ -42,13 +42,11 @@ public static RouteRequest toRouteRequest( CallerWithEnvironment callWith = new CallerWithEnvironment(environment); - callWith.argument( - "fromPlace", - (String from) -> request.setFrom(LocationStringParser.fromOldStyleString(from)) + callWith.argument("fromPlace", (String from) -> + request.setFrom(LocationStringParser.fromOldStyleString(from)) ); - callWith.argument( - "toPlace", - (String to) -> request.setTo(LocationStringParser.fromOldStyleString(to)) + callWith.argument("toPlace", (String to) -> + request.setTo(LocationStringParser.fromOldStyleString(to)) ); callWith.argument("from", (Map v) -> request.setFrom(toGenericLocation(v))); @@ -128,12 +126,10 @@ public static RouteRequest toRouteRequest( callWith.argument("walkSafetyFactor", b::withSafetyFactor); }); // TODO Add support for all debug filter variants - callWith.argument( - "debugItineraryFilter", - (Boolean v) -> - preferences.withItineraryFilter(it -> - it.withDebug(ItineraryFilterDebugProfile.ofDebugEnabled(v)) - ) + callWith.argument("debugItineraryFilter", (Boolean v) -> + preferences.withItineraryFilter(it -> + it.withDebug(ItineraryFilterDebugProfile.ofDebugEnabled(v)) + ) ); preferences.withTransit(tr -> { callWith.argument("boardSlack", tr::withDefaultBoardSlackSec); @@ -143,23 +139,20 @@ public static RouteRequest toRouteRequest( tr::setOtherThanPreferredRoutesPenalty ); // This is deprecated, if both are set, the proper one will override this - callWith.argument( - "unpreferred.useUnpreferredRoutesPenalty", - (Integer v) -> tr.setUnpreferredCost(CostLinearFunction.of(Duration.ofSeconds(v), 0.0)) + callWith.argument("unpreferred.useUnpreferredRoutesPenalty", (Integer v) -> + tr.setUnpreferredCost(CostLinearFunction.of(Duration.ofSeconds(v), 0.0)) ); callWith.argument("unpreferred.unpreferredCost", tr::setUnpreferredCostString); callWith.argument("ignoreRealtimeUpdates", tr::setIgnoreRealtimeUpdates); - callWith.argument( - "modeWeight", - (Map modeWeights) -> - tr.setReluctanceForMode( - modeWeights - .entrySet() - .stream() - .collect( - Collectors.toMap(e -> TransitMode.valueOf(e.getKey()), e -> (Double) e.getValue()) - ) - ) + callWith.argument("modeWeight", (Map modeWeights) -> + tr.setReluctanceForMode( + modeWeights + .entrySet() + .stream() + .collect( + Collectors.toMap(e -> TransitMode.valueOf(e.getKey()), e -> (Double) e.getValue()) + ) + ) ); }); preferences.withTransfer(tx -> { @@ -195,16 +188,12 @@ public static RouteRequest toRouteRequest( if (hasArgument(environment, "banned") || hasArgument(environment, "transportModes")) { var filterRequestBuilder = TransitFilterRequest.of(); - callWith.argument( - "banned.routes", - s -> - filterRequestBuilder.addNot(SelectRequest.of().withRoutesFromString((String) s).build()) + callWith.argument("banned.routes", s -> + filterRequestBuilder.addNot(SelectRequest.of().withRoutesFromString((String) s).build()) ); - callWith.argument( - "banned.agencies", - s -> - filterRequestBuilder.addNot(SelectRequest.of().withAgenciesFromString((String) s).build()) + callWith.argument("banned.agencies", s -> + filterRequestBuilder.addNot(SelectRequest.of().withAgenciesFromString((String) s).build()) ); callWith.argument("banned.trips", request.journey().transit()::setBannedTripsFromString); @@ -212,17 +201,16 @@ public static RouteRequest toRouteRequest( if (hasArgument(environment, "transportModes")) { QualifiedModeSet modes = new QualifiedModeSet("WALK"); - modes.qModes = - environment - .>>getArgument("transportModes") - .stream() - .map(transportMode -> - new QualifiedMode( - transportMode.get("mode") + - (transportMode.get("qualifier") == null ? "" : "_" + transportMode.get("qualifier")) - ) + modes.qModes = environment + .>>getArgument("transportModes") + .stream() + .map(transportMode -> + new QualifiedMode( + transportMode.get("mode") + + (transportMode.get("qualifier") == null ? "" : "_" + transportMode.get("qualifier")) ) - .collect(Collectors.toSet()); + ) + .collect(Collectors.toSet()); var requestModes = modes.getRequestModes(); request.journey().access().setMode(requestModes.accessMode); @@ -250,9 +238,8 @@ public static RouteRequest toRouteRequest( // ((List)environment.getArgument("allowedTicketTypes")).forEach(ticketType -> request.allowedFares.add(ticketType.replaceFirst("_", ":"))); } - callWith.argument( - "locale", - (String v) -> request.setLocale(GraphQLUtils.getLocale(environment, v)) + callWith.argument("locale", (String v) -> + request.setLocale(GraphQLUtils.getLocale(environment, v)) ); return request; } @@ -289,21 +276,15 @@ private static void setParkingPreferences( ) { callWith.argument("parking.unpreferredCost", parking::withUnpreferredVehicleParkingTagCost); - callWith.argument( - "parking.filters", - (Collection> filters) -> { - parking.withRequiredVehicleParkingTags(parseSelectFilters(filters)); - parking.withBannedVehicleParkingTags(parseNotFilters(filters)); - } - ); + callWith.argument("parking.filters", (Collection> filters) -> { + parking.withRequiredVehicleParkingTags(parseSelectFilters(filters)); + parking.withBannedVehicleParkingTags(parseNotFilters(filters)); + }); - callWith.argument( - "parking.preferred", - (Collection> preferred) -> { - parking.withPreferredVehicleParkingTags(parseSelectFilters(preferred)); - parking.withNotPreferredVehicleParkingTags(parseNotFilters(preferred)); - } - ); + callWith.argument("parking.preferred", (Collection> preferred) -> { + parking.withPreferredVehicleParkingTags(parseSelectFilters(preferred)); + parking.withNotPreferredVehicleParkingTags(parseNotFilters(preferred)); + }); } private static void setRentalPreferences( @@ -322,17 +303,14 @@ private static void setRentalPreferences( ); // Deprecated, the next one will override this, if both are set - callWith.argument( - "allowedBikeRentalNetworks", - (Collection v) -> rental.withAllowedNetworks(new HashSet<>(v)) + callWith.argument("allowedBikeRentalNetworks", (Collection v) -> + rental.withAllowedNetworks(new HashSet<>(v)) ); - callWith.argument( - "allowedVehicleRentalNetworks", - (Collection v) -> rental.withAllowedNetworks(new HashSet<>(v)) + callWith.argument("allowedVehicleRentalNetworks", (Collection v) -> + rental.withAllowedNetworks(new HashSet<>(v)) ); - callWith.argument( - "bannedVehicleRentalNetworks", - (Collection v) -> rental.withBannedNetworks(new HashSet<>(v)) + callWith.argument("bannedVehicleRentalNetworks", (Collection v) -> + rental.withBannedNetworks(new HashSet<>(v)) ); } diff --git a/application/src/main/java/org/opentripplanner/apis/gtfs/mapping/routerequest/ViaLocationMapper.java b/application/src/main/java/org/opentripplanner/apis/gtfs/mapping/routerequest/ViaLocationMapper.java index 984f67855e8..fa673a715b9 100644 --- a/application/src/main/java/org/opentripplanner/apis/gtfs/mapping/routerequest/ViaLocationMapper.java +++ b/application/src/main/java/org/opentripplanner/apis/gtfs/mapping/routerequest/ViaLocationMapper.java @@ -22,8 +22,7 @@ class ViaLocationMapper { static final String FIELD_PASS_THROUGH = "passThrough"; static List mapToViaLocations(@Nullable List>> via) { - return ListUtils - .nullSafeImmutableList(via) + return ListUtils.nullSafeImmutableList(via) .stream() .map(ViaLocationMapper::mapViaLocation) .toList(); diff --git a/application/src/main/java/org/opentripplanner/apis/support/TileJson.java b/application/src/main/java/org/opentripplanner/apis/support/TileJson.java index 1f5c090c16d..02d12564f80 100644 --- a/application/src/main/java/org/opentripplanner/apis/support/TileJson.java +++ b/application/src/main/java/org/opentripplanner/apis/support/TileJson.java @@ -40,13 +40,12 @@ public TileJson(String tileUrl, WorldEnvelope envelope, String attribution) { this.attribution = attribution; tiles = new String[] { tileUrl }; - bounds = - new double[] { - envelope.lowerLeft().longitude(), - envelope.lowerLeft().latitude(), - envelope.upperRight().longitude(), - envelope.upperRight().latitude(), - }; + bounds = new double[] { + envelope.lowerLeft().longitude(), + envelope.lowerLeft().latitude(), + envelope.upperRight().longitude(), + envelope.upperRight().latitude(), + }; var c = envelope.center(); center = new double[] { c.longitude(), c.latitude(), 9 }; diff --git a/application/src/main/java/org/opentripplanner/apis/support/graphql/injectdoc/ApiDocumentationProfile.java b/application/src/main/java/org/opentripplanner/apis/support/graphql/injectdoc/ApiDocumentationProfile.java index 93452589ace..01ea7077bde 100644 --- a/application/src/main/java/org/opentripplanner/apis/support/graphql/injectdoc/ApiDocumentationProfile.java +++ b/application/src/main/java/org/opentripplanner/apis/support/graphql/injectdoc/ApiDocumentationProfile.java @@ -10,7 +10,7 @@ public enum ApiDocumentationProfile implements DocumentedEnum loadCustomDocumentationFromPropertiesFile( } map.put(key, value); } - return TextVariablesSubstitution.insertVariables( - map, - varName -> errorHandlerVariableSubstitution(varName, resource) + return TextVariablesSubstitution.insertVariables(map, varName -> + errorHandlerVariableSubstitution(varName, resource) ); } catch (IOException e) { throw new RuntimeException(e); diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/TransmodelAPI.java b/application/src/main/java/org/opentripplanner/apis/transmodel/TransmodelAPI.java index 62b9b5f0a45..29682d29d3d 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/TransmodelAPI.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/TransmodelAPI.java @@ -37,11 +37,11 @@ public class TransmodelAPI { // Note, the blank line at the end is intended private static final String SCHEMA_DOC_HEADER = """ -# THIS IS NOT INTENDED FOR PRODUCTION USE. We recommend using the GraphQL introspection instead. -# This is intended for the OTP Debug UI and can also be used by humans to get the schema with the -# OTP configured default-values injected. + # THIS IS NOT INTENDED FOR PRODUCTION USE. We recommend using the GraphQL introspection instead. + # This is intended for the OTP Debug UI and can also be used by humans to get the schema with the + # OTP configured default-values injected. -"""; + """; private static final Logger LOG = LoggerFactory.getLogger(TransmodelAPI.class); @@ -89,13 +89,12 @@ public static void setUp( } tracingHeaderTags = config.tracingHeaderTags(); maxNumberOfResultFields = config.maxNumberOfResultFields(); - schema = - TransmodelGraphQLSchema.create( - defaultRouteRequest, - timetableRepository.getTimeZone(), - documentationProfile, - transitRoutingConfig - ); + schema = TransmodelGraphQLSchema.create( + defaultRouteRequest, + timetableRepository.getTimeZone(), + documentationProfile, + transitRoutingConfig + ); } @POST diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/TransmodelGraph.java b/application/src/main/java/org/opentripplanner/apis/transmodel/TransmodelGraph.java index e7f3fc7b8e0..29f2a67a1f2 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/TransmodelGraph.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/TransmodelGraph.java @@ -39,8 +39,9 @@ class TransmodelGraph { final ExecutorService threadPool; TransmodelGraph(GraphQLSchema schema) { - this.threadPool = - Executors.newCachedThreadPool(OtpRequestThreadFactory.of("transmodel-api-%d")); + this.threadPool = Executors.newCachedThreadPool( + OtpRequestThreadFactory.of("transmodel-api-%d") + ); this.indexSchema = schema; } @@ -88,11 +89,10 @@ private static Instrumentation createInstrumentation( Instrumentation instrumentation = new MaxFieldsInResultInstrumentation(maxNumberOfResultFields); if (OTPFeature.ActuatorAPI.isOn()) { - instrumentation = - new ChainedInstrumentation( - new MicrometerGraphQLInstrumentation(Metrics.globalRegistry, tracingTags), - instrumentation - ); + instrumentation = new ChainedInstrumentation( + new MicrometerGraphQLInstrumentation(Metrics.globalRegistry, tracingTags), + instrumentation + ); } return instrumentation; } @@ -114,8 +114,7 @@ private static ExecutionInput createExecutionInput( String operationName, TransmodelRequestContext transmodelRequestContext ) { - return ExecutionInput - .newExecutionInput() + return ExecutionInput.newExecutionInput() .query(query) .operationName(operationName) .context(transmodelRequestContext) @@ -128,8 +127,7 @@ private GraphQL createGraphQL( Instrumentation instrumentation, ExecutionStrategy executionStrategy ) { - return GraphQL - .newGraphQL(indexSchema) + return GraphQL.newGraphQL(indexSchema) .instrumentation(instrumentation) .queryExecutionStrategy(executionStrategy) .defaultDataFetcherExceptionHandler(new LoggingDataFetcherExceptionHandler()) diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/TransmodelGraphQLPlanner.java b/application/src/main/java/org/opentripplanner/apis/transmodel/TransmodelGraphQLPlanner.java index 39c7aa9c851..742376c9232 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/TransmodelGraphQLPlanner.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/TransmodelGraphQLPlanner.java @@ -43,8 +43,7 @@ public DataFetcherResult plan(DataFetchingEnvironment environment) } Locale locale = request == null ? serverContext.defaultLocale() : request.locale(); - return DataFetcherResult - .newResult() + return DataFetcherResult.newResult() .data(response) .localContext(Map.of("locale", locale)) .build(); @@ -63,8 +62,7 @@ public DataFetcherResult planVia(DataFetchingEnvironment env Locale defaultLocale = ctx.getServerContext().defaultLocale(); Locale locale = request == null ? defaultLocale : request.locale(); - return DataFetcherResult - .newResult() + return DataFetcherResult.newResult() .data(response) .localContext(Map.of("locale", locale)) .build(); diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/TransmodelGraphQLSchema.java b/application/src/main/java/org/opentripplanner/apis/transmodel/TransmodelGraphQLSchema.java index 0136e8288ae..bc4d80559b2 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/TransmodelGraphQLSchema.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/TransmodelGraphQLSchema.java @@ -385,44 +385,38 @@ private GraphQLSchema create() { dateTimeScalar ); - GraphQLInputObjectType inputPlaceIds = GraphQLInputObjectType - .newInputObject() + GraphQLInputObjectType inputPlaceIds = GraphQLInputObjectType.newInputObject() .name("InputPlaceIds") .field( - GraphQLInputObjectField - .newInputObjectField() + GraphQLInputObjectField.newInputObjectField() .name("quays") .description("Quays to include by id.") .type(new GraphQLList(Scalars.GraphQLString)) .build() ) .field( - GraphQLInputObjectField - .newInputObjectField() + GraphQLInputObjectField.newInputObjectField() .name("lines") .description("Lines to include by id.") .type(new GraphQLList(Scalars.GraphQLString)) .build() ) .field( - GraphQLInputObjectField - .newInputObjectField() + GraphQLInputObjectField.newInputObjectField() .name("bikeRentalStations") .description("Bike rentals to include by id.") .type(new GraphQLList(Scalars.GraphQLString)) .build() ) .field( - GraphQLInputObjectField - .newInputObjectField() + GraphQLInputObjectField.newInputObjectField() .name("bikeParks") .description("Bike parks to include by id.") .type(new GraphQLList(Scalars.GraphQLString)) .build() ) .field( - GraphQLInputObjectField - .newInputObjectField() + GraphQLInputObjectField.newInputObjectField() .name("carParks") .description("Car parks to include by id.") .type(new GraphQLList(Scalars.GraphQLString)) @@ -430,21 +424,18 @@ private GraphQLSchema create() { ) .build(); - GraphQLObjectType queryType = GraphQLObjectType - .newObject() + GraphQLObjectType queryType = GraphQLObjectType.newObject() .name("QueryType") .field(tripQuery) .field(viaTripQuery) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("stopPlace") .description("Get a single stopPlace based on its id)") .withDirective(TransmodelDirectives.TIMING_DATA) .type(stopPlaceType) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("id") .type(new GraphQLNonNull(Scalars.GraphQLString)) .build() @@ -455,15 +446,13 @@ private GraphQLSchema create() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("stopPlaces") .description("Get all stopPlaces") .withDirective(TransmodelDirectives.TIMING_DATA) .type(new GraphQLNonNull(new GraphQLList(stopPlaceType))) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("ids") .type(new GraphQLList(Scalars.GraphQLString)) .build() @@ -488,36 +477,31 @@ private GraphQLSchema create() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("stopPlacesByBbox") .description("Get all stop places within the specified bounding box") .withDirective(TransmodelDirectives.TIMING_DATA) .type(new GraphQLNonNull(new GraphQLList(stopPlaceType))) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("minimumLatitude") .type(new GraphQLNonNull(Scalars.GraphQLFloat)) .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("minimumLongitude") .type(new GraphQLNonNull(Scalars.GraphQLFloat)) .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("maximumLatitude") .type(new GraphQLNonNull(Scalars.GraphQLFloat)) .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("maximumLongitude") .type(new GraphQLNonNull(Scalars.GraphQLFloat)) .build() @@ -526,8 +510,7 @@ private GraphQLSchema create() { GraphQLArgument.newArgument().name("authority").type(Scalars.GraphQLString).build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("multiModalMode") .type(MULTI_MODAL_MODE) .description( @@ -538,8 +521,7 @@ private GraphQLSchema create() { .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("filterByInUse") .description("If true only stop places with at least one visiting line are included.") .type(Scalars.GraphQLBoolean) @@ -569,36 +551,32 @@ private GraphQLSchema create() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("quay") .description("Get a single quay based on its id)") .withDirective(TransmodelDirectives.TIMING_DATA) .type(quayType) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("id") .type(new GraphQLNonNull(Scalars.GraphQLString)) .build() ) .dataFetcher(environment -> - GqlUtil - .getTransitService(environment) - .getStopLocation(mapIDToDomain(environment.getArgument("id"))) + GqlUtil.getTransitService(environment).getStopLocation( + mapIDToDomain(environment.getArgument("id")) + ) ) .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("quays") .description("Get all quays") .withDirective(TransmodelDirectives.TIMING_DATA) .type(new GraphQLNonNull(new GraphQLList(quayType))) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("ids") .type(new GraphQLList(Scalars.GraphQLString)) .build() @@ -616,8 +594,7 @@ private GraphQLSchema create() { return ids.stream().map(transitService::getStopLocation).toList(); } - FindStopLocationsRequest request = FindStopLocationsRequest - .of() + FindStopLocationsRequest request = FindStopLocationsRequest.of() .withName(environment.getArgument("name")) .build(); @@ -626,43 +603,37 @@ private GraphQLSchema create() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("quaysByBbox") .description("Get all quays within the specified bounding box") .withDirective(TransmodelDirectives.TIMING_DATA) .type(new GraphQLNonNull(new GraphQLList(quayType))) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("minimumLatitude") .type(new GraphQLNonNull(Scalars.GraphQLFloat)) .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("minimumLongitude") .type(new GraphQLNonNull(Scalars.GraphQLFloat)) .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("maximumLatitude") .type(new GraphQLNonNull(Scalars.GraphQLFloat)) .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("maximumLongitude") .type(new GraphQLNonNull(Scalars.GraphQLFloat)) .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("authority") .deprecate( "This is the Transmodel namespace or the GTFS feedID - avoid using this. Request a new field if necessary." @@ -671,8 +642,7 @@ private GraphQLSchema create() { .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("filterByInUse") .description("If true only quays with at least one visiting line are included.") .type(Scalars.GraphQLBoolean) @@ -694,21 +664,20 @@ private GraphQLSchema create() { var authority = environment.getArgument("authority"); var filterInUse = environment.getArgument("filterByInUse"); - FindRegularStopsByBoundingBoxRequest findRegularStopsByBoundingBoxRequest = FindRegularStopsByBoundingBoxRequest - .of(envelope) - .withFeedId(authority) - .filterByInUse(filterInUse) - .build(); + FindRegularStopsByBoundingBoxRequest findRegularStopsByBoundingBoxRequest = + FindRegularStopsByBoundingBoxRequest.of(envelope) + .withFeedId(authority) + .filterByInUse(filterInUse) + .build(); - return GqlUtil - .getTransitService(environment) - .findRegularStopsByBoundingBox(findRegularStopsByBoundingBoxRequest); + return GqlUtil.getTransitService(environment).findRegularStopsByBoundingBox( + findRegularStopsByBoundingBoxRequest + ); }) .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("quaysByRadius") .description( "Get all quays within the specified walking radius from a location. There are no maximum " + @@ -724,24 +693,21 @@ private GraphQLSchema create() { ) ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("latitude") .description("Latitude of the location") .type(new GraphQLNonNull(Scalars.GraphQLFloat)) .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("longitude") .description("Longitude of the location") .type(new GraphQLNonNull(Scalars.GraphQLFloat)) .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("radius") .description( "Radius via streets (in meters) to search for from the specified location" @@ -756,26 +722,25 @@ private GraphQLSchema create() { .dataFetcher(environment -> { List stops; try { - stops = - GqlUtil - .getGraphFinder(environment) - .findClosestStops( - new Coordinate( - environment.getArgument("longitude"), - environment.getArgument("latitude") - ), - environment.getArgument("radius") - ) - .stream() - .filter(stopAtDistance -> + stops = GqlUtil.getGraphFinder(environment) + .findClosestStops( + new Coordinate( + environment.getArgument("longitude"), + environment.getArgument("latitude") + ), + environment.getArgument("radius") + ) + .stream() + .filter( + stopAtDistance -> environment.getArgument("authority") == null || stopAtDistance.stop .getId() .getFeedId() .equalsIgnoreCase(environment.getArgument("authority")) - ) - .sorted(Comparator.comparing(s -> s.distance)) - .collect(Collectors.toList()); + ) + .sorted(Comparator.comparing(s -> s.distance)) + .collect(Collectors.toList()); } catch (RoutingValidationException e) { LOG.warn( "findClosestPlacesByWalking failed with exception, returning empty list of places. ", @@ -795,8 +760,7 @@ private GraphQLSchema create() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("nearest") .description( "Get all places (quays, stop places, car parks etc. with coordinates) within the specified radius from a location. The returned type has two fields place and distance. The search is done by walking so the distance is according to the network of walkables." @@ -810,24 +774,21 @@ private GraphQLSchema create() { ) ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("latitude") .description("Latitude of the location") .type(new GraphQLNonNull(Scalars.GraphQLFloat)) .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("longitude") .description("Longitude of the location") .type(new GraphQLNonNull(Scalars.GraphQLFloat)) .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("maximumDistance") .description( "Maximum distance (in meters) to search for from the specified location. Default is 2000m." @@ -837,8 +798,7 @@ private GraphQLSchema create() { .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("maximumResults") .description( "Maximum number of results. Search is stopped when this limit is reached. Default is 20." @@ -848,8 +808,7 @@ private GraphQLSchema create() { .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("filterByPlaceTypes") .description("Only include places of given types if set. Default accepts all types") .defaultValue(Arrays.asList(TransmodelPlaceType.values())) @@ -857,8 +816,7 @@ private GraphQLSchema create() { .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("filterByModes") .description( "Only include places that include this mode. Only checked for places with mode i.e. quays, departures." @@ -867,8 +825,7 @@ private GraphQLSchema create() { .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("filterByInUse") .description( "Only affects queries for quays and stop places. If true only quays and stop places with at least one visiting line are included." @@ -878,16 +835,14 @@ private GraphQLSchema create() { .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("filterByIds") .description("Only include places that match one of the given ids.") .type(inputPlaceIds) .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("multiModalMode") .type(MULTI_MODAL_MODE) .description( @@ -911,18 +866,15 @@ private GraphQLSchema create() { if (filterByIds != null) { filterByStops = toIdList(((List) filterByIds.get("quays"))); filterByRoutes = toIdList(((List) filterByIds.get("lines"))); - filterByBikeRentalStations = - filterByIds.get("bikeRentalStations") != null - ? (List) filterByIds.get("bikeRentalStations") - : List.of(); - filterByBikeParks = - filterByIds.get("bikeParks") != null - ? (List) filterByIds.get("bikeParks") - : List.of(); - filterByCarParks = - filterByIds.get("carParks") != null - ? (List) filterByIds.get("carParks") - : List.of(); + filterByBikeRentalStations = filterByIds.get("bikeRentalStations") != null + ? (List) filterByIds.get("bikeRentalStations") + : List.of(); + filterByBikeParks = filterByIds.get("bikeParks") != null + ? (List) filterByIds.get("bikeParks") + : List.of(); + filterByCarParks = filterByIds.get("carParks") != null + ? (List) filterByIds.get("carParks") + : List.of(); } List filterByTransportModes = environment.getArgument("filterByModes"); @@ -940,52 +892,45 @@ private GraphQLSchema create() { } List places; - places = - GqlUtil - .getGraphFinder(environment) - .findClosestPlaces( - environment.getArgument("latitude"), - environment.getArgument("longitude"), - environment.getArgument("maximumDistance"), - maxResults, - filterByTransportModes, - filterByPlaceTypes, - filterByStops, - filterByStations, - filterByRoutes, - filterByBikeRentalStations, - filterByNetwork, - GqlUtil.getTransitService(environment) - ); + places = GqlUtil.getGraphFinder(environment).findClosestPlaces( + environment.getArgument("latitude"), + environment.getArgument("longitude"), + environment.getArgument("maximumDistance"), + maxResults, + filterByTransportModes, + filterByPlaceTypes, + filterByStops, + filterByStations, + filterByRoutes, + filterByBikeRentalStations, + filterByNetwork, + GqlUtil.getTransitService(environment) + ); if (TRUE.equals(environment.getArgument("filterByInUse"))) { - places = - places - .stream() - .filter(placeAtDistance -> { - if (placeAtDistance.place() instanceof StopLocation stop) { - return !GqlUtil - .getTransitService(environment) - .findPatterns(stop, true) - .isEmpty(); - } else { - return true; - } - }) - .toList(); + places = places + .stream() + .filter(placeAtDistance -> { + if (placeAtDistance.place() instanceof StopLocation stop) { + return !GqlUtil.getTransitService(environment) + .findPatterns(stop, true) + .isEmpty(); + } else { + return true; + } + }) + .toList(); } - places = - PlaceAtDistanceType - .convertQuaysToStopPlaces( - placeTypes, - places, - environment.getArgument("multiModalMode"), - GqlUtil.getTransitService(environment) - ) - .stream() - .limit(orgMaxResults) - .collect(Collectors.toList()); + places = PlaceAtDistanceType.convertQuaysToStopPlaces( + placeTypes, + places, + environment.getArgument("multiModalMode"), + GqlUtil.getTransitService(environment) + ) + .stream() + .limit(orgMaxResults) + .collect(Collectors.toList()); if (places.isEmpty()) { return new DefaultConnection<>( List.of(), @@ -997,29 +942,26 @@ private GraphQLSchema create() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("authority") .description("Get an authority by ID") .withDirective(TransmodelDirectives.TIMING_DATA) .type(authorityType) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("id") .type(new GraphQLNonNull(Scalars.GraphQLString)) .build() ) .dataFetcher(environment -> { - return GqlUtil - .getTransitService(environment) - .getAgency(TransitIdMapper.mapIDToDomain(environment.getArgument("id"))); + return GqlUtil.getTransitService(environment).getAgency( + TransitIdMapper.mapIDToDomain(environment.getArgument("id")) + ); }) .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("authorities") .description("Get all authorities") .withDirective(TransmodelDirectives.TIMING_DATA) @@ -1030,29 +972,26 @@ private GraphQLSchema create() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("operator") .description("Get a operator by ID") .withDirective(TransmodelDirectives.TIMING_DATA) .type(operatorType) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("id") .type(new GraphQLNonNull(Scalars.GraphQLString)) .build() ) .dataFetcher(environment -> - GqlUtil - .getTransitService(environment) - .getOperator(TransitIdMapper.mapIDToDomain(environment.getArgument("id"))) + GqlUtil.getTransitService(environment).getOperator( + TransitIdMapper.mapIDToDomain(environment.getArgument("id")) + ) ) .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("operators") .description("Get all operators") .withDirective(TransmodelDirectives.TIMING_DATA) @@ -1063,15 +1002,13 @@ private GraphQLSchema create() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("line") .description("Get a single line based on its id") .withDirective(TransmodelDirectives.TIMING_DATA) .type(lineType) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("id") .type(new GraphQLNonNull(Scalars.GraphQLID)) .build() @@ -1081,22 +1018,20 @@ private GraphQLSchema create() { if (id.isBlank()) { return null; } - return GqlUtil - .getTransitService(environment) - .getRoute(TransitIdMapper.mapIDToDomain(id)); + return GqlUtil.getTransitService(environment).getRoute( + TransitIdMapper.mapIDToDomain(id) + ); }) .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("lines") .description("Get all _lines_") .withDirective(TransmodelDirectives.TIMING_DATA) .type(new GraphQLNonNull(new GraphQLList(lineType))) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("ids") .description( "Set of ids of _lines_ to fetch. If this is set, no other filters can be set." @@ -1105,8 +1040,7 @@ private GraphQLSchema create() { .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("name") .description( "Prefix of the _name_ of the _line_ to fetch. This filter is case insensitive." @@ -1115,40 +1049,35 @@ private GraphQLSchema create() { .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("publicCode") .description("_Public code_ of the _line_ to fetch.") .type(Scalars.GraphQLString) .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("publicCodes") .description("Set of _public codes_ to fetch _lines_ for.") .type(new GraphQLList(Scalars.GraphQLString)) .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("transportModes") .description("Set of _transport modes_ to fetch _lines_ for.") .type(new GraphQLList(TRANSPORT_MODE)) .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("authorities") .description("Set of ids of _authorities_ to fetch _lines_ for.") .type(new GraphQLList(Scalars.GraphQLString)) .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("flexibleOnly") .description( "Filter by _lines_ containing flexible / on demand _service journey_ only." @@ -1163,9 +1092,13 @@ private GraphQLSchema create() { // flexibleLines gets special treatment because it has a default value. if ( - Stream - .of("name", "publicCode", "publicCodes", "transportModes", "authorities") - .anyMatch(environment::containsArgument) || + Stream.of( + "name", + "publicCode", + "publicCodes", + "transportModes", + "authorities" + ).anyMatch(environment::containsArgument) || Boolean.TRUE.equals(environment.getArgument("flexibleOnly")) ) { throw new IllegalArgumentException("Unable to combine other filters with ids"); @@ -1190,8 +1123,7 @@ private GraphQLSchema create() { ); boolean flexibleOnly = Boolean.TRUE.equals(environment.getArgument("flexibleOnly")); - FindRoutesRequest findRoutesRequest = FindRoutesRequest - .of() + FindRoutesRequest findRoutesRequest = FindRoutesRequest.of() .withLongName(name) .withShortName(publicCode) .withShortNames(publicCodes) @@ -1205,28 +1137,25 @@ private GraphQLSchema create() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("groupOfLines") .description("Get a single group of lines based on its id") .type(groupOfLinesType) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("id") .type(new GraphQLNonNull(Scalars.GraphQLString)) .build() ) .dataFetcher(environment -> - GqlUtil - .getTransitService(environment) - .getGroupOfRoutes(TransitIdMapper.mapIDToDomain(environment.getArgument("id"))) + GqlUtil.getTransitService(environment).getGroupOfRoutes( + TransitIdMapper.mapIDToDomain(environment.getArgument("id")) + ) ) .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("groupsOfLines") .description("Get all groups of lines") .type(new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(groupOfLinesType)))) @@ -1234,60 +1163,53 @@ private GraphQLSchema create() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("serviceJourney") .description("Get a single service journey based on its id") .withDirective(TransmodelDirectives.TIMING_DATA) .type(serviceJourneyType) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("id") .type(new GraphQLNonNull(Scalars.GraphQLString)) .build() ) .dataFetcher(environment -> { - return GqlUtil - .getTransitService(environment) - .getTrip(TransitIdMapper.mapIDToDomain(environment.getArgument("id"))); + return GqlUtil.getTransitService(environment).getTrip( + TransitIdMapper.mapIDToDomain(environment.getArgument("id")) + ); }) .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("serviceJourneys") .description("Get all _service journeys_") .withDirective(TransmodelDirectives.TIMING_DATA) .type(new GraphQLNonNull(new GraphQLList(serviceJourneyType))) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("lines") .description("Set of ids of _lines_ to fetch _service journeys_ for.") .type(new GraphQLList(Scalars.GraphQLID)) .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("privateCodes") .description("Set of ids of _private codes_ to fetch _service journeys_ for.") .type(new GraphQLList(Scalars.GraphQLString)) .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("activeDates") .description("Set of _operating days_ to fetch _service journeys_ for.") .type(new GraphQLList(TransmodelScalars.DATE_SCALAR)) .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("authorities") .description("Set of ids of _authorities_ to fetch _service journeys_ for.") .type(new GraphQLList(Scalars.GraphQLString)) @@ -1311,8 +1233,7 @@ private GraphQLSchema create() { toListNullSafe(environment.>getArgument("activeDates")) ); - TripRequest tripRequest = TripRequest - .of() + TripRequest tripRequest = TripRequest.of() .withAgencies(authorities) .withRoutes(lineIds) .withNetexInternalPlanningCodes(privateCodes) @@ -1324,14 +1245,12 @@ private GraphQLSchema create() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("bikeRentalStations") .description("Get all bike rental stations") .withDirective(TransmodelDirectives.TIMING_DATA) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("ids") .type(new GraphQLList(Scalars.GraphQLString)) .build() @@ -1353,22 +1272,19 @@ private GraphQLSchema create() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("bikeRentalStation") .description("Get all bike rental stations") .withDirective(TransmodelDirectives.TIMING_DATA) .type(bikeRentalStationType) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("id") .type(new GraphQLNonNull(Scalars.GraphQLString)) .build() ) .dataFetcher(environment -> { - return GqlUtil - .getVehicleRentalService(environment) + return GqlUtil.getVehicleRentalService(environment) .getVehicleRentalStations() .stream() .filter(bikeRentalStation -> @@ -1380,8 +1296,7 @@ private GraphQLSchema create() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("bikeRentalStationsByBbox") .description("Get all bike rental stations within the specified bounding box.") .withDirective(TransmodelDirectives.TIMING_DATA) @@ -1390,8 +1305,7 @@ private GraphQLSchema create() { GraphQLArgument.newArgument().name("minimumLatitude").type(Scalars.GraphQLFloat).build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("minimumLongitude") .type(Scalars.GraphQLFloat) .build() @@ -1400,42 +1314,36 @@ private GraphQLSchema create() { GraphQLArgument.newArgument().name("maximumLatitude").type(Scalars.GraphQLFloat).build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("maximumLongitude") .type(Scalars.GraphQLFloat) .build() ) .dataFetcher(environment -> - GqlUtil - .getVehicleRentalService(environment) - .getVehicleRentalStationForEnvelope( - environment.getArgument("minimumLongitude"), - environment.getArgument("minimumLatitude"), - environment.getArgument("maximumLongitude"), - environment.getArgument("maximumLatitude") - ) + GqlUtil.getVehicleRentalService(environment).getVehicleRentalStationForEnvelope( + environment.getArgument("minimumLongitude"), + environment.getArgument("minimumLatitude"), + environment.getArgument("maximumLongitude"), + environment.getArgument("maximumLatitude") + ) ) .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("bikePark") .description("Get a single bike park based on its id") .withDirective(TransmodelDirectives.TIMING_DATA) .type(bikeParkType) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("id") .type(new GraphQLNonNull(Scalars.GraphQLString)) .build() ) .dataFetcher(environment -> { var bikeParkId = mapIDToDomain(environment.getArgument("id")); - return GqlUtil - .getVehicleParkingService(environment) + return GqlUtil.getVehicleParkingService(environment) .listBikeParks() .stream() .filter(bikePark -> bikePark.getId().equals(bikeParkId)) @@ -1445,15 +1353,13 @@ private GraphQLSchema create() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("bikeParks") .description("Get all bike parks") .withDirective(TransmodelDirectives.TIMING_DATA) .type(new GraphQLNonNull(new GraphQLList(bikeParkType))) .dataFetcher(environment -> - GqlUtil - .getVehicleParkingService(environment) + GqlUtil.getVehicleParkingService(environment) .listBikeParks() .stream() .collect(Collectors.toCollection(ArrayList::new)) @@ -1461,8 +1367,7 @@ private GraphQLSchema create() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("routingParameters") .description("Get default routing parameters.") .withDirective(TransmodelDirectives.TIMING_DATA) @@ -1471,15 +1376,13 @@ private GraphQLSchema create() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("situations") .description("Get all active situations.") .withDirective(TransmodelDirectives.TIMING_DATA) .type(new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(ptSituationElementType)))) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("authorities") .description("Filter by reporting authorities.") .deprecate( @@ -1489,24 +1392,21 @@ private GraphQLSchema create() { .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("codespaces") .description("Filter by reporting source.") .type(new GraphQLList(Scalars.GraphQLString)) .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("severities") .description("Filter by severity.") .type(new GraphQLList(EnumTypes.SEVERITY)) .build() ) .dataFetcher(environment -> { - Collection alerts = GqlUtil - .getTransitService(environment) + Collection alerts = GqlUtil.getTransitService(environment) .getTransitAlertService() .getAllAlerts(); @@ -1527,35 +1427,31 @@ private GraphQLSchema create() { } if (!codespaces.isEmpty()) { - alerts = - alerts - .stream() - .filter(alert -> codespaces.contains(alert.siriCodespace())) - .collect(Collectors.toSet()); + alerts = alerts + .stream() + .filter(alert -> codespaces.contains(alert.siriCodespace())) + .collect(Collectors.toSet()); } if (environment.getArgument("severities") instanceof List) { List severities = environment.getArgument("severities"); - alerts = - alerts - .stream() - .filter(alert -> severities.contains(getTransmodelSeverity(alert.severity()))) - .collect(Collectors.toSet()); + alerts = alerts + .stream() + .filter(alert -> severities.contains(getTransmodelSeverity(alert.severity()))) + .collect(Collectors.toSet()); } return alerts; }) .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("situation") .description("Get a single situation based on its situationNumber") .withDirective(TransmodelDirectives.TIMING_DATA) .type(ptSituationElementType) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("situationNumber") .type(new GraphQLNonNull(Scalars.GraphQLString)) .build() @@ -1565,23 +1461,20 @@ private GraphQLSchema create() { if (situationNumber.isBlank()) { return null; } - return GqlUtil - .getTransitService(environment) + return GqlUtil.getTransitService(environment) .getTransitAlertService() .getAlertById(mapIDToDomain(situationNumber)); }) .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("leg") .description("Refetch a single transit leg based on its id") .withDirective(TransmodelDirectives.TIMING_DATA) .type(LegType.REF) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("id") .type(new GraphQLNonNull(Scalars.GraphQLID)) .build() @@ -1600,8 +1493,7 @@ private GraphQLSchema create() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("serverInfo") .description( "Get OTP deployment information. This is only useful for developers of OTP itself not regular API users." @@ -1615,8 +1507,7 @@ private GraphQLSchema create() { .field(DatedServiceJourneyQuery.createQuery(datedServiceJourneyType)) .build(); - var schema = GraphQLSchema - .newSchema() + var schema = GraphQLSchema.newSchema() .query(queryType) .additionalType(placeInterface) .additionalType(timetabledPassingTime) diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/mapping/FilterMapper.java b/application/src/main/java/org/opentripplanner/apis/transmodel/mapping/FilterMapper.java index 71d2691e47a..265909bff48 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/mapping/FilterMapper.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/mapping/FilterMapper.java @@ -28,10 +28,8 @@ static void mapFilterOldWay( RouteRequest request ) { if ( - !( - GqlUtil.hasArgument(environment, "modes") && - ((Map) environment.getArgument("modes")).containsKey("transportModes") - ) && + !(GqlUtil.hasArgument(environment, "modes") && + ((Map) environment.getArgument("modes")).containsKey("transportModes")) && !GqlUtil.hasArgument(environment, "whiteListed") && !GqlUtil.hasArgument(environment, "banned") ) { @@ -41,18 +39,16 @@ static void mapFilterOldWay( var filterRequestBuilder = TransitFilterRequest.of(); var bannedAgencies = new ArrayList(); - callWith.argument( - "banned.authorities", - (Collection authorities) -> bannedAgencies.addAll(mapIDsToDomainNullSafe(authorities)) + callWith.argument("banned.authorities", (Collection authorities) -> + bannedAgencies.addAll(mapIDsToDomainNullSafe(authorities)) ); if (!bannedAgencies.isEmpty()) { filterRequestBuilder.addNot(SelectRequest.of().withAgencies(bannedAgencies).build()); } var bannedLines = new ArrayList(); - callWith.argument( - "banned.lines", - (List lines) -> bannedLines.addAll(mapIDsToDomainNullSafe(lines)) + callWith.argument("banned.lines", (List lines) -> + bannedLines.addAll(mapIDsToDomainNullSafe(lines)) ); if (!bannedLines.isEmpty()) { filterRequestBuilder.addNot(SelectRequest.of().withRoutes(bannedLines).build()); @@ -61,19 +57,16 @@ static void mapFilterOldWay( var selectors = new ArrayList(); var whiteListedAgencies = new ArrayList(); - callWith.argument( - "whiteListed.authorities", - (Collection authorities) -> - whiteListedAgencies.addAll(mapIDsToDomainNullSafe(authorities)) + callWith.argument("whiteListed.authorities", (Collection authorities) -> + whiteListedAgencies.addAll(mapIDsToDomainNullSafe(authorities)) ); if (!whiteListedAgencies.isEmpty()) { selectors.add(SelectRequest.of().withAgencies(whiteListedAgencies)); } var whiteListedLines = new ArrayList(); - callWith.argument( - "whiteListed.lines", - (List lines) -> whiteListedLines.addAll(mapIDsToDomainNullSafe(lines)) + callWith.argument("whiteListed.lines", (List lines) -> + whiteListedLines.addAll(mapIDsToDomainNullSafe(lines)) ); if (!whiteListedLines.isEmpty()) { selectors.add(SelectRequest.of().withRoutes(whiteListedLines)); diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/mapping/SeverityMapper.java b/application/src/main/java/org/opentripplanner/apis/transmodel/mapping/SeverityMapper.java index 782bd4b1ae3..261798b338d 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/mapping/SeverityMapper.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/mapping/SeverityMapper.java @@ -31,10 +31,9 @@ public static String getTransmodelSeverity(AlertSeverity severity) { case VERY_SEVERE: return "verySevere"; case WARNING: - default: - { - return "normal"; - } + default: { + return "normal"; + } } } } diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/mapping/TripRequestMapper.java b/application/src/main/java/org/opentripplanner/apis/transmodel/mapping/TripRequestMapper.java index abb548256a1..79d908d8c0a 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/mapping/TripRequestMapper.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/mapping/TripRequestMapper.java @@ -32,40 +32,28 @@ public static RouteRequest createRequest(DataFetchingEnvironment environment) { callWith.argument("locale", (String v) -> request.setLocale(Locale.forLanguageTag(v))); - callWith.argument( - "from", - (Map v) -> request.setFrom(GenericLocationMapper.toGenericLocation(v)) + callWith.argument("from", (Map v) -> + request.setFrom(GenericLocationMapper.toGenericLocation(v)) ); - callWith.argument( - "to", - (Map v) -> request.setTo(GenericLocationMapper.toGenericLocation(v)) + callWith.argument("to", (Map v) -> + request.setTo(GenericLocationMapper.toGenericLocation(v)) ); - callWith.argument( - "passThroughPoints", - (List> v) -> { - request.setViaLocations(TripViaLocationMapper.toLegacyPassThroughLocations(v)); - } - ); - callWith.argument( - TripQuery.TRIP_VIA_PARAMETER, - (List> v) -> { - request.setViaLocations(TripViaLocationMapper.mapToViaLocations(v)); - } - ); - - callWith.argument( - "dateTime", - millisSinceEpoch -> request.setDateTime(Instant.ofEpochMilli((long) millisSinceEpoch)) + callWith.argument("passThroughPoints", (List> v) -> { + request.setViaLocations(TripViaLocationMapper.toLegacyPassThroughLocations(v)); + }); + callWith.argument(TripQuery.TRIP_VIA_PARAMETER, (List> v) -> { + request.setViaLocations(TripViaLocationMapper.mapToViaLocations(v)); + }); + + callWith.argument("dateTime", millisSinceEpoch -> + request.setDateTime(Instant.ofEpochMilli((long) millisSinceEpoch)) ); - callWith.argument( - "bookingTime", - millisSinceEpoch -> request.setBookingTime(Instant.ofEpochMilli((long) millisSinceEpoch)) + callWith.argument("bookingTime", millisSinceEpoch -> + request.setBookingTime(Instant.ofEpochMilli((long) millisSinceEpoch)) ); - callWith.argument( - "searchWindow", - (Integer m) -> request.setSearchWindow(Duration.ofMinutes(m)) + callWith.argument("searchWindow", (Integer m) -> request.setSearchWindow(Duration.ofMinutes(m)) ); callWith.argument("pageCursor", request::setPageCursorFromEncoded); callWith.argument("timetableView", request::setTimetableView); @@ -73,26 +61,18 @@ public static RouteRequest createRequest(DataFetchingEnvironment environment) { callWith.argument("numTripPatterns", request::setNumItineraries); callWith.argument("arriveBy", request::setArriveBy); - callWith.argument( - "preferred.authorities", - (Collection authorities) -> - request.journey().transit().setPreferredAgencies(mapIDsToDomainNullSafe(authorities)) + callWith.argument("preferred.authorities", (Collection authorities) -> + request.journey().transit().setPreferredAgencies(mapIDsToDomainNullSafe(authorities)) ); - callWith.argument( - "unpreferred.authorities", - (Collection authorities) -> - request.journey().transit().setUnpreferredAgencies(mapIDsToDomainNullSafe(authorities)) + callWith.argument("unpreferred.authorities", (Collection authorities) -> + request.journey().transit().setUnpreferredAgencies(mapIDsToDomainNullSafe(authorities)) ); - callWith.argument( - "preferred.lines", - (List lines) -> - request.journey().transit().setPreferredRoutes(mapIDsToDomainNullSafe(lines)) + callWith.argument("preferred.lines", (List lines) -> + request.journey().transit().setPreferredRoutes(mapIDsToDomainNullSafe(lines)) ); - callWith.argument( - "unpreferred.lines", - (List lines) -> - request.journey().transit().setUnpreferredRoutes(mapIDsToDomainNullSafe(lines)) + callWith.argument("unpreferred.lines", (List lines) -> + request.journey().transit().setUnpreferredRoutes(mapIDsToDomainNullSafe(lines)) ); if (GqlUtil.hasArgument(environment, "modes")) { @@ -102,10 +82,8 @@ public static RouteRequest createRequest(DataFetchingEnvironment environment) { } var bannedTrips = new ArrayList(); - callWith.argument( - "banned.serviceJourneys", - (Collection serviceJourneys) -> - bannedTrips.addAll(mapIDsToDomainNullSafe(serviceJourneys)) + callWith.argument("banned.serviceJourneys", (Collection serviceJourneys) -> + bannedTrips.addAll(mapIDsToDomainNullSafe(serviceJourneys)) ); if (!bannedTrips.isEmpty()) { request.journey().transit().setBannedTrips(bannedTrips); diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/mapping/TripViaLocationMapper.java b/application/src/main/java/org/opentripplanner/apis/transmodel/mapping/TripViaLocationMapper.java index 50766866e19..bbbae370be1 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/mapping/TripViaLocationMapper.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/mapping/TripViaLocationMapper.java @@ -76,8 +76,7 @@ private static List mapStopLocationIds(Map map) { } private static List mapCoordinate(Map map) { - return CoordinateInputType - .mapToWgsCoordinate(ViaLocationInputType.FIELD_COORDINATE, map) + return CoordinateInputType.mapToWgsCoordinate(ViaLocationInputType.FIELD_COORDINATE, map) .map(List::of) .orElseGet(List::of); } diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/mapping/ViaRequestMapper.java b/application/src/main/java/org/opentripplanner/apis/transmodel/mapping/ViaRequestMapper.java index 082b96c1add..f5ffd29c2dd 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/mapping/ViaRequestMapper.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/mapping/ViaRequestMapper.java @@ -35,17 +35,15 @@ public static RouteViaRequest createRouteViaRequest(DataFetchingEnvironment envi List requests; if (environment.containsArgument("segments")) { List> segments = environment.getArgument("segments"); - requests = - segments - .stream() - .map(viaRequest -> ViaSegmentMapper.mapViaSegment(request, viaRequest)) - .toList(); + requests = segments + .stream() + .map(viaRequest -> ViaSegmentMapper.mapViaSegment(request, viaRequest)) + .toList(); } else { requests = Collections.nCopies(vias.size() + 1, request.journey()); } - return RouteViaRequest - .of(vias, requests) + return RouteViaRequest.of(vias, requests) .withDateTime( Instant.ofEpochMilli( environment.getArgumentOrDefault("dateTime", request.dateTime().toEpochMilli()) diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/mapping/preferences/BikePreferencesMapper.java b/application/src/main/java/org/opentripplanner/apis/transmodel/mapping/preferences/BikePreferencesMapper.java index 76826d31e2d..cdb05db1e70 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/mapping/preferences/BikePreferencesMapper.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/mapping/preferences/BikePreferencesMapper.java @@ -23,13 +23,10 @@ public static void mapBikePreferences( callWith.argument("bicycleOptimisationMethod", bike::withOptimizeType); // WALK reluctance is used for backwards compatibility, then overridden - callWith.argument( - "walkReluctance", - r -> { - bike.withReluctance((double) r); - bike.withWalking(w -> w.withReluctance(WALK_BIKE_RELATIVE_RELUCTANCE * (double) r)); - } - ); + callWith.argument("walkReluctance", r -> { + bike.withReluctance((double) r); + bike.withWalking(w -> w.withReluctance(WALK_BIKE_RELATIVE_RELUCTANCE * (double) r)); + }); // TODO: Override WALK reluctance with BIKE reluctance // callWith.argument("bike.reluctance", r -> { diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/mapping/preferences/ItineraryFilterPreferencesMapper.java b/application/src/main/java/org/opentripplanner/apis/transmodel/mapping/preferences/ItineraryFilterPreferencesMapper.java index aa875606704..6b90738b488 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/mapping/preferences/ItineraryFilterPreferencesMapper.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/mapping/preferences/ItineraryFilterPreferencesMapper.java @@ -13,9 +13,8 @@ public static void mapItineraryFilterPreferences( DataFetchingEnvironment environment, DataFetcherDecorator callWith ) { - callWith.argument( - "debugItineraryFilter", - (Boolean v) -> itineraryFilter.withDebug(ItineraryFilterDebugProfile.ofDebugEnabled(v)) + callWith.argument("debugItineraryFilter", (Boolean v) -> + itineraryFilter.withDebug(ItineraryFilterDebugProfile.ofDebugEnabled(v)) ); ItineraryFiltersInputType.mapToRequest(environment, callWith, itineraryFilter); } diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/mapping/preferences/RentalPreferencesMapper.java b/application/src/main/java/org/opentripplanner/apis/transmodel/mapping/preferences/RentalPreferencesMapper.java index b9ced6f0d6c..29178d32e78 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/mapping/preferences/RentalPreferencesMapper.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/mapping/preferences/RentalPreferencesMapper.java @@ -11,14 +11,12 @@ public static void mapRentalPreferences( VehicleRentalPreferences.Builder rental, DataFetcherDecorator callWith ) { - callWith.argument( - "whiteListed.rentalNetworks", - (List networks) -> rental.withAllowedNetworks(Set.copyOf(networks)) + callWith.argument("whiteListed.rentalNetworks", (List networks) -> + rental.withAllowedNetworks(Set.copyOf(networks)) ); - callWith.argument( - "banned.rentalNetworks", - (List networks) -> rental.withBannedNetworks(Set.copyOf(networks)) + callWith.argument("banned.rentalNetworks", (List networks) -> + rental.withBannedNetworks(Set.copyOf(networks)) ); callWith.argument( "useBikeRentalAvailabilityInformation", diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/mapping/preferences/ScooterPreferencesMapper.java b/application/src/main/java/org/opentripplanner/apis/transmodel/mapping/preferences/ScooterPreferencesMapper.java index d7d5c019f93..23770d4b506 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/mapping/preferences/ScooterPreferencesMapper.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/mapping/preferences/ScooterPreferencesMapper.java @@ -16,12 +16,9 @@ public static void mapScooterPreferences( callWith.argument("bicycleOptimisationMethod", scooter::withOptimizeType); // WALK reluctance is used for backwards compatibility, then overridden - callWith.argument( - "walkReluctance", - r -> { - scooter.withReluctance((double) r); - } - ); + callWith.argument("walkReluctance", r -> { + scooter.withReluctance((double) r); + }); if (scooter.optimizeType() == VehicleRoutingOptimizeType.TRIANGLE) { scooter.withOptimizeTriangle(triangle -> { diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/mapping/preferences/TransitPreferencesMapper.java b/application/src/main/java/org/opentripplanner/apis/transmodel/mapping/preferences/TransitPreferencesMapper.java index 28643bf8199..3ac77c93c38 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/mapping/preferences/TransitPreferencesMapper.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/mapping/preferences/TransitPreferencesMapper.java @@ -21,31 +21,25 @@ public static void mapTransitPreferences( ); transit.withBoardSlack(builder -> { callWith.argument("boardSlackDefault", builder::withDefaultSec); - callWith.argument( - "boardSlackList", - (Object v) -> TransportModeSlack.mapIntoDomain(builder, v) + callWith.argument("boardSlackList", (Object v) -> TransportModeSlack.mapIntoDomain(builder, v) ); }); transit.withAlightSlack(builder -> { callWith.argument("alightSlackDefault", builder::withDefaultSec); - callWith.argument( - "alightSlackList", - (Object v) -> TransportModeSlack.mapIntoDomain(builder, v) + callWith.argument("alightSlackList", (Object v) -> + TransportModeSlack.mapIntoDomain(builder, v) ); }); callWith.argument("ignoreRealtimeUpdates", transit::setIgnoreRealtimeUpdates); callWith.argument("includePlannedCancellations", transit::setIncludePlannedCancellations); callWith.argument("includeRealtimeCancellations", transit::setIncludeRealtimeCancellations); - callWith.argument( - "relaxTransitGroupPriority", - it -> - transit.withRelaxTransitGroupPriority( - RelaxCostType.mapToDomain((Map) it, CostLinearFunction.NORMAL) - ) + callWith.argument("relaxTransitGroupPriority", it -> + transit.withRelaxTransitGroupPriority( + RelaxCostType.mapToDomain((Map) it, CostLinearFunction.NORMAL) + ) ); - callWith.argument( - "relaxTransitSearchGeneralizedCostAtDestination", - (Double value) -> transit.withRaptor(it -> it.withRelaxGeneralizedCostAtDestination(value)) + callWith.argument("relaxTransitSearchGeneralizedCostAtDestination", (Double value) -> + transit.withRaptor(it -> it.withRelaxGeneralizedCostAtDestination(value)) ); } } diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/model/DefaultRouteRequestType.java b/application/src/main/java/org/opentripplanner/apis/transmodel/model/DefaultRouteRequestType.java index 6a7a29d8d92..6e88f3be7a1 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/model/DefaultRouteRequestType.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/model/DefaultRouteRequestType.java @@ -18,13 +18,11 @@ public DefaultRouteRequestType(RouteRequest request) { private GraphQLObjectType createGraphQLType() { var preferences = request.preferences(); - return GraphQLObjectType - .newObject() + return GraphQLObjectType.newObject() .name("RoutingParameters") .description("The default parameters used in travel searches.") .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("walkSpeed") .description("Max walk speed along streets, in meters per second") .type(Scalars.GraphQLFloat) @@ -32,8 +30,7 @@ private GraphQLObjectType createGraphQLType() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("bikeSpeed") .description("Max bike speed along streets, in meters per second") .type(Scalars.GraphQLFloat) @@ -41,8 +38,7 @@ private GraphQLObjectType createGraphQLType() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("carSpeed") .deprecate("This parameter is no longer configurable.") .description("Max car speed along streets, in meters per second") @@ -51,8 +47,7 @@ private GraphQLObjectType createGraphQLType() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("maxDirectStreetDuration") .description( "This is the maximum duration in seconds for a direct street search. " + @@ -64,8 +59,7 @@ private GraphQLObjectType createGraphQLType() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("wheelChairAccessible") .description("Whether the trip must be wheelchair accessible.") .type(Scalars.GraphQLBoolean) @@ -73,8 +67,7 @@ private GraphQLObjectType createGraphQLType() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("numItineraries") .description("The maximum number of itineraries to return.") .type(Scalars.GraphQLInt) @@ -82,8 +75,7 @@ private GraphQLObjectType createGraphQLType() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("maxSlope") .description("The maximum slope of streets for wheelchair trips.") .type(Scalars.GraphQLFloat) @@ -91,8 +83,7 @@ private GraphQLObjectType createGraphQLType() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("showIntermediateStops") .deprecate("Deprecated. This parameter is always enabled") .description( @@ -104,8 +95,7 @@ private GraphQLObjectType createGraphQLType() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("transferPenalty") .description( "An extra penalty added on transfers (i.e. all boardings except the first one)." @@ -115,8 +105,7 @@ private GraphQLObjectType createGraphQLType() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("walkReluctance") .description( "A multiplier for how bad walking is, compared to being in transit for equal lengths of time." @@ -126,8 +115,7 @@ private GraphQLObjectType createGraphQLType() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("stairsReluctance") .description("Used instead of walkReluctance for stairs.") .type(Scalars.GraphQLFloat) @@ -135,8 +123,7 @@ private GraphQLObjectType createGraphQLType() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("turnReluctance") .description("Multiplicative factor on expected turning time.") .type(Scalars.GraphQLFloat) @@ -144,8 +131,7 @@ private GraphQLObjectType createGraphQLType() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("elevatorBoardTime") .description("How long does it take to get on an elevator, on average.") .type(Scalars.GraphQLInt) @@ -153,8 +139,7 @@ private GraphQLObjectType createGraphQLType() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("elevatorBoardCost") .description("What is the cost of boarding a elevator?") .type(Scalars.GraphQLInt) @@ -162,8 +147,7 @@ private GraphQLObjectType createGraphQLType() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("elevatorHopTime") .description("How long does it take to advance one floor on an elevator?") .type(Scalars.GraphQLInt) @@ -171,8 +155,7 @@ private GraphQLObjectType createGraphQLType() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("elevatorHopCost") .description("What is the cost of travelling one floor on an elevator?") .type(Scalars.GraphQLInt) @@ -180,8 +163,7 @@ private GraphQLObjectType createGraphQLType() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("bikeRentalPickupTime") .description("Time to rent a bike.") .type(Scalars.GraphQLInt) @@ -189,8 +171,7 @@ private GraphQLObjectType createGraphQLType() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("bikeRentalPickupCost") .description("Cost to rent a bike.") .type(Scalars.GraphQLInt) @@ -198,8 +179,7 @@ private GraphQLObjectType createGraphQLType() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("bikeRentalDropOffTime") .description("Time to drop-off a rented bike.") .type(Scalars.GraphQLInt) @@ -207,8 +187,7 @@ private GraphQLObjectType createGraphQLType() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("bikeRentalDropOffCost") .description("Cost to drop-off a rented bike.") .type(Scalars.GraphQLInt) @@ -216,8 +195,7 @@ private GraphQLObjectType createGraphQLType() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("bikeParkTime") .description("Time to park a bike.") .type(Scalars.GraphQLInt) @@ -225,8 +203,7 @@ private GraphQLObjectType createGraphQLType() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("bikeParkCost") .description("Cost to park a bike.") .type(Scalars.GraphQLInt) @@ -234,8 +211,7 @@ private GraphQLObjectType createGraphQLType() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("carDropOffTime") .description( "Time to park a car in a park and ride, w/o taking into account driving and walking cost." @@ -245,8 +221,7 @@ private GraphQLObjectType createGraphQLType() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("waitReluctance") .description( "How much worse is waiting for a transit vehicle than being on a transit vehicle, as a multiplier." @@ -256,8 +231,7 @@ private GraphQLObjectType createGraphQLType() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("walkBoardCost") .description( "This prevents unnecessary transfers by adding a cost for boarding a vehicle." @@ -267,8 +241,7 @@ private GraphQLObjectType createGraphQLType() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("bikeBoardCost") .description( "Separate cost for boarding a vehicle with a bicycle, which is more difficult than on foot." @@ -278,8 +251,7 @@ private GraphQLObjectType createGraphQLType() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("otherThanPreferredRoutesPenalty") .description( "Penalty added for using every route that is not preferred if user set any route as preferred. We return number of seconds that we are willing to wait for preferred route." @@ -289,8 +261,7 @@ private GraphQLObjectType createGraphQLType() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("transferSlack") .description( "A global minimum transfer time (in seconds) that specifies the minimum amount of time that must pass between exiting one transit vehicle and boarding another." @@ -300,8 +271,7 @@ private GraphQLObjectType createGraphQLType() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("boardSlackDefault") .description(TransportModeSlack.boardSlackDescription("boardSlackList")) .type(Scalars.GraphQLInt) @@ -309,8 +279,7 @@ private GraphQLObjectType createGraphQLType() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("boardSlackList") .description(TransportModeSlack.slackByGroupDescription("boardSlack")) .type(TransportModeSlack.SLACK_LIST_OUTPUT_TYPE) @@ -318,8 +287,7 @@ private GraphQLObjectType createGraphQLType() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("alightSlackDefault") .description(TransportModeSlack.alightSlackDescription("alightSlackList")) .type(Scalars.GraphQLInt) @@ -327,8 +295,7 @@ private GraphQLObjectType createGraphQLType() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("alightSlackList") .description(TransportModeSlack.slackByGroupDescription("alightSlack")) .type(TransportModeSlack.SLACK_LIST_OUTPUT_TYPE) @@ -336,8 +303,7 @@ private GraphQLObjectType createGraphQLType() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("maxTransfers") .description("Maximum number of transfers returned in a trip plan.") .type(Scalars.GraphQLInt) @@ -345,8 +311,7 @@ private GraphQLObjectType createGraphQLType() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("maxAdditionalTransfers") .description( "Maximum number of transfers allowed in addition to the result with least number of transfers" @@ -356,8 +321,7 @@ private GraphQLObjectType createGraphQLType() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("reverseOptimizeOnTheFly") .deprecate("NOT IN USE IN OTP2.") .type(Scalars.GraphQLBoolean) @@ -365,8 +329,7 @@ private GraphQLObjectType createGraphQLType() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("compactLegsByReversedSearch") .deprecate("NOT IN USE IN OTP2.") .type(Scalars.GraphQLBoolean) @@ -374,8 +337,7 @@ private GraphQLObjectType createGraphQLType() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("carDecelerationSpeed") .description("The deceleration speed of an automobile, in meters per second per second.") .type(Scalars.GraphQLFloat) @@ -383,8 +345,7 @@ private GraphQLObjectType createGraphQLType() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("carAccelerationSpeed") .description("The acceleration speed of an automobile, in meters per second per second.") .type(Scalars.GraphQLFloat) @@ -392,8 +353,7 @@ private GraphQLObjectType createGraphQLType() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("ignoreRealTimeUpdates") .description("When true, real-time updates are ignored during this search.") .type(Scalars.GraphQLBoolean) @@ -401,8 +361,7 @@ private GraphQLObjectType createGraphQLType() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("includedPlannedCancellations") .description( "When true, service journeys cancelled in scheduled route data will be included during this search." @@ -412,8 +371,7 @@ private GraphQLObjectType createGraphQLType() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("disableRemainingWeightHeuristic") .description("If true, the remaining weight heuristic is disabled.") .type(Scalars.GraphQLBoolean) @@ -421,8 +379,7 @@ private GraphQLObjectType createGraphQLType() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("allowBikeRental") .description("") .type(Scalars.GraphQLBoolean) @@ -431,8 +388,7 @@ private GraphQLObjectType createGraphQLType() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("parkAndRide") .type(Scalars.GraphQLBoolean) .deprecate("Parking is specified by modes") @@ -440,8 +396,7 @@ private GraphQLObjectType createGraphQLType() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("kissAndRide") .type(Scalars.GraphQLBoolean) .deprecate("Parking is specified by modes") @@ -449,8 +404,7 @@ private GraphQLObjectType createGraphQLType() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("debugItineraryFilter") .type(Scalars.GraphQLBoolean) .deprecate("Use `itineraryFilter.debug` instead.") @@ -458,8 +412,7 @@ private GraphQLObjectType createGraphQLType() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("onlyTransitTrips") .description("Accept only paths that use transit (no street-only paths).") .deprecate("This is replaced by modes input object") @@ -468,8 +421,7 @@ private GraphQLObjectType createGraphQLType() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("disableAlertFiltering") .description("Option to disable the default filtering of GTFS-RT alerts by time.") .type(Scalars.GraphQLBoolean) @@ -478,8 +430,7 @@ private GraphQLObjectType createGraphQLType() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("geoIdElevation") .description( "Whether to apply the ellipsoid->geoid offset to all elevations in the response." diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/model/EnumTypes.java b/application/src/main/java/org/opentripplanner/apis/transmodel/model/EnumTypes.java index fba1a8f637a..fcb6c49bcd1 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/model/EnumTypes.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/model/EnumTypes.java @@ -31,8 +31,7 @@ public class EnumTypes { - public static final GraphQLEnumType ABSOLUTE_DIRECTION = GraphQLEnumType - .newEnum() + public static final GraphQLEnumType ABSOLUTE_DIRECTION = GraphQLEnumType.newEnum() .name("AbsoluteDirection") .value("north", AbsoluteDirection.NORTH) .value("northeast", AbsoluteDirection.NORTHEAST) @@ -44,8 +43,7 @@ public class EnumTypes { .value("northwest", AbsoluteDirection.NORTHWEST) .build(); - public static final GraphQLEnumType ALTERNATIVE_LEGS_FILTER = GraphQLEnumType - .newEnum() + public static final GraphQLEnumType ALTERNATIVE_LEGS_FILTER = GraphQLEnumType.newEnum() .name("AlternativeLegsFilter") .value("noFilter", AlternativeLegsFilter.NO_FILTER) .value("sameAuthority", AlternativeLegsFilter.SAME_AGENCY) @@ -54,16 +52,14 @@ public class EnumTypes { .value("sameLine", AlternativeLegsFilter.SAME_ROUTE) .build(); - public static final GraphQLEnumType ARRIVAL_DEPARTURE = GraphQLEnumType - .newEnum() + public static final GraphQLEnumType ARRIVAL_DEPARTURE = GraphQLEnumType.newEnum() .name("ArrivalDeparture") .value("arrivals", ArrivalDeparture.ARRIVALS, "Only show arrivals") .value("departures", ArrivalDeparture.DEPARTURES, "Only show departures") .value("both", ArrivalDeparture.BOTH, "Show both arrivals and departures") .build(); - public static final GraphQLEnumType BICYCLE_OPTIMISATION_METHOD = GraphQLEnumType - .newEnum() + public static final GraphQLEnumType BICYCLE_OPTIMISATION_METHOD = GraphQLEnumType.newEnum() .name("BicycleOptimisationMethod") .value("quick", VehicleRoutingOptimizeType.SHORTEST_DURATION) .value("safe", VehicleRoutingOptimizeType.SAFE_STREETS) @@ -72,8 +68,7 @@ public class EnumTypes { .value("triangle", VehicleRoutingOptimizeType.TRIANGLE) .build(); - public static final GraphQLEnumType BIKES_ALLOWED = GraphQLEnumType - .newEnum() + public static final GraphQLEnumType BIKES_ALLOWED = GraphQLEnumType.newEnum() .name("BikesAllowed") .value("noInformation", BikeAccess.UNKNOWN, "There is no bike information for the trip.") .value( @@ -84,8 +79,7 @@ public class EnumTypes { .value("notAllowed", BikeAccess.NOT_ALLOWED, "No bicycles are allowed on this trip.") .build(); - public static final GraphQLEnumType BOOKING_METHOD = GraphQLEnumType - .newEnum() + public static final GraphQLEnumType BOOKING_METHOD = GraphQLEnumType.newEnum() .name("BookingMethod") .value("callDriver", BookingMethod.CALL_DRIVER) .value("callOffice", BookingMethod.CALL_OFFICE) @@ -94,8 +88,7 @@ public class EnumTypes { .value("text", BookingMethod.TEXT_MESSAGE) .build(); - public static final GraphQLEnumType DIRECTION_TYPE = GraphQLEnumType - .newEnum() + public static final GraphQLEnumType DIRECTION_TYPE = GraphQLEnumType.newEnum() .name("DirectionType") .value("unknown", Direction.UNKNOWN) .value("outbound", Direction.OUTBOUND) @@ -104,8 +97,7 @@ public class EnumTypes { .value("anticlockwise", Direction.ANTICLOCKWISE) .build(); - public static final GraphQLEnumType FILTER_PLACE_TYPE_ENUM = GraphQLEnumType - .newEnum() + public static final GraphQLEnumType FILTER_PLACE_TYPE_ENUM = GraphQLEnumType.newEnum() .name("FilterPlaceType") .value("quay", TransmodelPlaceType.QUAY, "Quay") .value("stopPlace", TransmodelPlaceType.STOP_PLACE, "StopPlace") @@ -114,8 +106,7 @@ public class EnumTypes { .value("carPark", TransmodelPlaceType.CAR_PARK, "Car parks") .build(); - public static final GraphQLEnumType INPUT_FIELD = GraphQLEnumType - .newEnum() + public static final GraphQLEnumType INPUT_FIELD = GraphQLEnumType.newEnum() .name("InputField") .value("dateTime", InputField.DATE_TIME) .value("from", InputField.FROM_PLACE) @@ -123,8 +114,7 @@ public class EnumTypes { .value("intermediatePlace", InputField.INTERMEDIATE_PLACE) .build(); - public static final GraphQLEnumType INTERCHANGE_PRIORITY = GraphQLEnumType - .newEnum() + public static final GraphQLEnumType INTERCHANGE_PRIORITY = GraphQLEnumType.newEnum() .name("InterchangePriority") .value("preferred", TransferPriority.PREFERRED) .value("recommended", TransferPriority.RECOMMENDED) @@ -132,8 +122,7 @@ public class EnumTypes { .value("notAllowed", TransferPriority.NOT_ALLOWED) .build(); - public static final GraphQLEnumType INTERCHANGE_WEIGHTING = GraphQLEnumType - .newEnum() + public static final GraphQLEnumType INTERCHANGE_WEIGHTING = GraphQLEnumType.newEnum() .description("Deprecated. Use STOP_INTERCHANGE_PRIORITY") .name("InterchangeWeighting") .value("preferredInterchange", 2, "Highest priority interchange.") @@ -142,8 +131,7 @@ public class EnumTypes { .value("noInterchange", -1, "Interchange not allowed.") .build(); - public static final GraphQLEnumType STOP_INTERCHANGE_PRIORITY = GraphQLEnumType - .newEnum() + public static final GraphQLEnumType STOP_INTERCHANGE_PRIORITY = GraphQLEnumType.newEnum() .name("StopInterchangePriority") .value( "preferred", @@ -178,8 +166,7 @@ public class EnumTypes { ) ); - public static final GraphQLEnumType LEG_MODE = GraphQLEnumType - .newEnum() + public static final GraphQLEnumType LEG_MODE = GraphQLEnumType.newEnum() .name("Mode") .value("air", TransitMode.AIRPLANE) .value("bicycle", TraverseMode.BICYCLE) @@ -200,15 +187,13 @@ public class EnumTypes { .value("scooter", TraverseMode.SCOOTER) .build(); - public static final GraphQLEnumType LOCALE = GraphQLEnumType - .newEnum() + public static final GraphQLEnumType LOCALE = GraphQLEnumType.newEnum() .name("Locale") .value("no", "no") .value("us", "us") .build(); - public static final GraphQLEnumType MULTI_MODAL_MODE = GraphQLEnumType - .newEnum() + public static final GraphQLEnumType MULTI_MODAL_MODE = GraphQLEnumType.newEnum() .name("MultiModalMode") .value("parent", "parent", "Multi modal parent stop places without their mono modal children.") .value( @@ -233,8 +218,7 @@ public class EnumTypes { ) ); - public static final GraphQLEnumType PURCHASE_WHEN = GraphQLEnumType - .newEnum() + public static final GraphQLEnumType PURCHASE_WHEN = GraphQLEnumType.newEnum() .name("PurchaseWhen") .value("timeOfTravelOnly", "timeOfTravelOnly") .value("dayOfTravelOnly", "dayOfTravelOnly") @@ -243,8 +227,7 @@ public class EnumTypes { .value("other", "other") .build(); - public static final GraphQLEnumType REALTIME_STATE = GraphQLEnumType - .newEnum() + public static final GraphQLEnumType REALTIME_STATE = GraphQLEnumType.newEnum() .name("RealtimeState") .value( "scheduled", @@ -273,8 +256,7 @@ public class EnumTypes { ) .build(); - public static final GraphQLEnumType RELATIVE_DIRECTION = GraphQLEnumType - .newEnum() + public static final GraphQLEnumType RELATIVE_DIRECTION = GraphQLEnumType.newEnum() .name("RelativeDirection") .value("depart", RelativeDirection.DEPART) .value("hardLeft", RelativeDirection.HARD_LEFT) @@ -294,15 +276,13 @@ public class EnumTypes { .value("followSigns", RelativeDirection.FOLLOW_SIGNS) .build(); - public static final GraphQLEnumType REPORT_TYPE = GraphQLEnumType - .newEnum() + public static final GraphQLEnumType REPORT_TYPE = GraphQLEnumType.newEnum() .name("ReportType") //SIRI - ReportTypeEnumeration .value("general", "general", "Indicates a general info-message that should not affect trip.") .value("incident", "incident", "Indicates an incident that may affect trip.") .build(); - public static final GraphQLEnumType ROUTING_ERROR_CODE = GraphQLEnumType - .newEnum() + public static final GraphQLEnumType ROUTING_ERROR_CODE = GraphQLEnumType.newEnum() .name("RoutingErrorCode") .value( "locationNotFound", @@ -341,8 +321,7 @@ public class EnumTypes { ) .build(); - public static final GraphQLEnumType SERVICE_ALTERATION = GraphQLEnumType - .newEnum() + public static final GraphQLEnumType SERVICE_ALTERATION = GraphQLEnumType.newEnum() .name("ServiceAlteration") .value("cancellation", TripAlteration.CANCELLATION) .value("replaced", TripAlteration.REPLACED) @@ -350,8 +329,7 @@ public class EnumTypes { .value("planned", TripAlteration.PLANNED) .build(); - public static final GraphQLEnumType SEVERITY = GraphQLEnumType - .newEnum() + public static final GraphQLEnumType SEVERITY = GraphQLEnumType.newEnum() .name("Severity") //SIRI - SeverityEnumeration .value("unknown", "unknown", "Situation has unknown impact on trips.") .value("noImpact", "noImpact", "Situation has no impact on trips.") @@ -363,8 +341,7 @@ public class EnumTypes { .value("undefined", "undefined", "Severity is undefined.") .build(); - public static final GraphQLEnumType STOP_CONDITION_ENUM = GraphQLEnumType - .newEnum() + public static final GraphQLEnumType STOP_CONDITION_ENUM = GraphQLEnumType.newEnum() .name("StopCondition") //SIRI - RoutePointTypeEnumeration .value( "destination", @@ -393,8 +370,7 @@ public class EnumTypes { ) .build(); - public static final GraphQLEnumType STREET_MODE = GraphQLEnumType - .newEnum() + public static final GraphQLEnumType STREET_MODE = GraphQLEnumType.newEnum() .name("StreetMode") .value("foot", StreetMode.WALK, "Walk only") .value( @@ -453,8 +429,7 @@ public class EnumTypes { ) .build(); - public static final GraphQLEnumType TRANSPORT_MODE = GraphQLEnumType - .newEnum() + public static final GraphQLEnumType TRANSPORT_MODE = GraphQLEnumType.newEnum() .name("TransportMode") .value("air", TransitMode.AIRPLANE) .value("bus", TransitMode.BUS) @@ -478,8 +453,7 @@ public class EnumTypes { TransmodelTransportSubmode::getValue ); - public static final GraphQLEnumType VERTEX_TYPE = GraphQLEnumType - .newEnum() + public static final GraphQLEnumType VERTEX_TYPE = GraphQLEnumType.newEnum() .name("VertexType") .value("normal", VertexType.NORMAL) .value("transit", VertexType.TRANSIT) @@ -488,8 +462,7 @@ public class EnumTypes { //TODO QL: .value("parkAndRide", VertexType.PARKANDRIDE) .build(); - public static final GraphQLEnumType WHEELCHAIR_BOARDING = GraphQLEnumType - .newEnum() + public static final GraphQLEnumType WHEELCHAIR_BOARDING = GraphQLEnumType.newEnum() .name("WheelchairBoarding") .value( "noInformation", diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/model/TransmodelTransportSubmode.java b/application/src/main/java/org/opentripplanner/apis/transmodel/model/TransmodelTransportSubmode.java index e7b544b4e0f..43cf499bdda 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/model/TransmodelTransportSubmode.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/model/TransmodelTransportSubmode.java @@ -135,8 +135,7 @@ public enum TransmodelTransportSubmode { } public static TransmodelTransportSubmode fromValue(SubMode value) { - return Arrays - .stream(TransmodelTransportSubmode.values()) + return Arrays.stream(TransmodelTransportSubmode.values()) .filter(tp -> tp.getValue().equals(value.name())) .findFirst() .orElse(null); diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/model/TransportModeSlack.java b/application/src/main/java/org/opentripplanner/apis/transmodel/model/TransportModeSlack.java index dd2f72c0ec9..4d84f9d70c6 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/model/TransportModeSlack.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/model/TransportModeSlack.java @@ -48,36 +48,30 @@ public class TransportModeSlack { INT_TYPE = nonNull(Scalars.GraphQLInt); MODE_LIST_TYPE = nonNull(GraphQLList.list(nonNull(TRANSPORT_MODE))); - SLACK_INPUT_TYPE = - GraphQLInputObjectType - .newInputObject() - .name("TransportModeSlack") - .description("Used to specify board and alight slack for a given modes.") - .field( - newInputObjectField() - .name("slack") - .description("The slack used for all given modes.") - .type(INT_TYPE) - .build() - ) - .field( - newInputObjectField() - .name("modes") - .description("List of modes for which the given slack apply.") - .type(MODE_LIST_TYPE) - .build() - ) - .build(); - SLACK_OUTPUT_TYPE = - GraphQLObjectType - .newObject() - .name("TransportModeSlackType") - .description("Used to specify board and alight slack for a given modes.") - .field(GraphQLFieldDefinition.newFieldDefinition().name("slack").type(INT_TYPE).build()) - .field( - GraphQLFieldDefinition.newFieldDefinition().name("modes").type(MODE_LIST_TYPE).build() - ) - .build(); + SLACK_INPUT_TYPE = GraphQLInputObjectType.newInputObject() + .name("TransportModeSlack") + .description("Used to specify board and alight slack for a given modes.") + .field( + newInputObjectField() + .name("slack") + .description("The slack used for all given modes.") + .type(INT_TYPE) + .build() + ) + .field( + newInputObjectField() + .name("modes") + .description("List of modes for which the given slack apply.") + .type(MODE_LIST_TYPE) + .build() + ) + .build(); + SLACK_OUTPUT_TYPE = GraphQLObjectType.newObject() + .name("TransportModeSlackType") + .description("Used to specify board and alight slack for a given modes.") + .field(GraphQLFieldDefinition.newFieldDefinition().name("slack").type(INT_TYPE).build()) + .field(GraphQLFieldDefinition.newFieldDefinition().name("modes").type(MODE_LIST_TYPE).build()) + .build(); SLACK_LIST_INPUT_TYPE = GraphQLList.list(SLACK_INPUT_TYPE); SLACK_LIST_OUTPUT_TYPE = GraphQLList.list(SLACK_OUTPUT_TYPE); } @@ -109,8 +103,7 @@ public static String slackByGroupDescription( public static List mapToApiList(DurationForEnum domain) { // Group modes by slack value Multimap modesBySlack = ArrayListMultimap.create(); - Arrays - .stream(TransitMode.values()) + Arrays.stream(TransitMode.values()) .filter(domain::isSet) .forEach(m -> modesBySlack.put((int) domain.valueOf(m).toSeconds(), m)); @@ -162,8 +155,7 @@ private static String defaultDescription(String groupName) { private static String defaultsToString(DurationForEnum byMode) { List groups = new ArrayList<>(); - Arrays - .stream(TransitMode.values()) + Arrays.stream(TransitMode.values()) .filter(byMode::isSet) .forEach(m -> groups.add(serializeTransportMode(m) + " : " + byMode.valueOf(m))); Collections.sort(groups); diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/model/TripTimeOnDateHelper.java b/application/src/main/java/org/opentripplanner/apis/transmodel/model/TripTimeOnDateHelper.java index 67e23adec5e..91fbf80efeb 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/model/TripTimeOnDateHelper.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/model/TripTimeOnDateHelper.java @@ -86,8 +86,7 @@ public static List getAllTripTimeOnDatesForLegsTrip(Leg leg) { TripPattern tripPattern = transitLeg.getTripPattern(); Instant serviceDateMidnight = transitLeg.getServiceDateMidnight(); LocalDate serviceDate = transitLeg.getServiceDate(); - return IntStream - .range(0, tripPattern.numberOfStops()) + return IntStream.range(0, tripPattern.numberOfStops()) .mapToObj(i -> new TripTimeOnDate(tripTimes, i, tripPattern, serviceDate, serviceDateMidnight) ) .collect(Collectors.toList()); @@ -105,8 +104,7 @@ public static List getIntermediateTripTimeOnDatesForLeg(Leg leg) TripPattern tripPattern = transitLeg.getTripPattern(); Instant serviceDateMidnight = transitLeg.getServiceDateMidnight(); LocalDate serviceDate = transitLeg.getServiceDate(); - return IntStream - .range(leg.getBoardStopPosInPattern() + 1, leg.getAlightStopPosInPattern()) + return IntStream.range(leg.getBoardStopPosInPattern() + 1, leg.getAlightStopPosInPattern()) .mapToObj(i -> new TripTimeOnDate(tripTimes, i, tripPattern, serviceDate, serviceDateMidnight) ) .collect(Collectors.toList()); diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/model/framework/AuthorityType.java b/application/src/main/java/org/opentripplanner/apis/transmodel/model/framework/AuthorityType.java index d18b4da554f..499a68f7973 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/model/framework/AuthorityType.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/model/framework/AuthorityType.java @@ -19,16 +19,14 @@ public static GraphQLObjectType create( GraphQLOutputType lineType, GraphQLOutputType ptSituationElementType ) { - return GraphQLObjectType - .newObject() + return GraphQLObjectType.newObject() .name("Authority") .description( "Authority involved in public transportation. An organisation under which the responsibility of organising the transport service in a certain area is placed." ) .field(GqlUtil.newTransitIdField()) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("name") .type(new GraphQLNonNull(Scalars.GraphQLString)) .build() @@ -37,8 +35,7 @@ public static GraphQLObjectType create( GraphQLFieldDefinition.newFieldDefinition().name("url").type(Scalars.GraphQLString).build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("timezone") .type(new GraphQLNonNull(Scalars.GraphQLString)) .build() @@ -47,22 +44,19 @@ public static GraphQLObjectType create( GraphQLFieldDefinition.newFieldDefinition().name("lang").type(Scalars.GraphQLString).build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("phone") .type(Scalars.GraphQLString) .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("fareUrl") .type(Scalars.GraphQLString) .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("lines") .withDirective(TransmodelDirectives.TIMING_DATA) .type(new GraphQLNonNull(new GraphQLList(lineType))) @@ -76,8 +70,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("situations") .withDirective(TransmodelDirectives.TIMING_DATA) .description("Get all situations active for the authority.") diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/model/framework/BrandingType.java b/application/src/main/java/org/opentripplanner/apis/transmodel/model/framework/BrandingType.java index 59406f0a06f..0df62d3b79c 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/model/framework/BrandingType.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/model/framework/BrandingType.java @@ -9,20 +9,17 @@ public class BrandingType { public static GraphQLObjectType create() { - return GraphQLObjectType - .newObject() + return GraphQLObjectType.newObject() .name("Branding") .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("id") .type(Scalars.GraphQLID) .dataFetcher(env -> TransitIdMapper.mapEntityIDToApi(env.getSource())) .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("name") .description("Full name to be used for branding.") .type(Scalars.GraphQLString) @@ -30,8 +27,7 @@ public static GraphQLObjectType create() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("shortName") .description("Short name to be used for branding.") .type(Scalars.GraphQLString) @@ -39,8 +35,7 @@ public static GraphQLObjectType create() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("description") .description("Description of branding.") .type(Scalars.GraphQLString) @@ -48,8 +43,7 @@ public static GraphQLObjectType create() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("url") .description("URL to be used for branding") .type(Scalars.GraphQLString) @@ -57,8 +51,7 @@ public static GraphQLObjectType create() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("image") .description("URL to an image be used for branding") .type(Scalars.GraphQLString) diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/model/framework/CoordinateInputType.java b/application/src/main/java/org/opentripplanner/apis/transmodel/model/framework/CoordinateInputType.java index 2b95e850032..912b2110579 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/model/framework/CoordinateInputType.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/model/framework/CoordinateInputType.java @@ -15,21 +15,18 @@ public class CoordinateInputType { static final String LATITUDE = "latitude"; static final String LONGITUDE = "longitude"; - public static final GraphQLInputObjectType INPUT_TYPE = GraphQLInputObjectType - .newInputObject() + public static final GraphQLInputObjectType INPUT_TYPE = GraphQLInputObjectType.newInputObject() .name("InputCoordinates") .description("Input type for coordinates in the WGS84 system") .field( - GraphQLInputObjectField - .newInputObjectField() + GraphQLInputObjectField.newInputObjectField() .name(LATITUDE) .description("The latitude of the place.") .type(new GraphQLNonNull(Scalars.GraphQLFloat)) .build() ) .field( - GraphQLInputObjectField - .newInputObjectField() + GraphQLInputObjectField.newInputObjectField() .name(LONGITUDE) .description("The longitude of the place.") .type(new GraphQLNonNull(Scalars.GraphQLFloat)) diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/model/framework/InfoLinkType.java b/application/src/main/java/org/opentripplanner/apis/transmodel/model/framework/InfoLinkType.java index e0472a2ccf8..a369972cf05 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/model/framework/InfoLinkType.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/model/framework/InfoLinkType.java @@ -9,12 +9,10 @@ public class InfoLinkType { public static GraphQLObjectType create() { - return GraphQLObjectType - .newObject() + return GraphQLObjectType.newObject() .name("infoLink") .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("uri") .type(new GraphQLNonNull(Scalars.GraphQLString)) .description("URI") @@ -25,8 +23,7 @@ public static GraphQLObjectType create() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("label") .type(Scalars.GraphQLString) .description("Label") diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/model/framework/LocationInputType.java b/application/src/main/java/org/opentripplanner/apis/transmodel/model/framework/LocationInputType.java index e64c67d9910..050de3181cb 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/model/framework/LocationInputType.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/model/framework/LocationInputType.java @@ -6,8 +6,7 @@ public class LocationInputType { - public static final GraphQLInputObjectType INPUT_TYPE = GraphQLInputObjectType - .newInputObject() + public static final GraphQLInputObjectType INPUT_TYPE = GraphQLInputObjectType.newInputObject() .name("Location") .description( "Input format for specifying a location through either a place reference (id), coordinates " + @@ -15,8 +14,7 @@ public class LocationInputType { "coordinates will only be used if place is not known." ) .field( - GraphQLInputObjectField - .newInputObjectField() + GraphQLInputObjectField.newInputObjectField() .name("name") .description( "The name of the location. This is pass-through information" + @@ -26,8 +24,7 @@ public class LocationInputType { .build() ) .field( - GraphQLInputObjectField - .newInputObjectField() + GraphQLInputObjectField.newInputObjectField() .name("place") .description( "The id of an element in the OTP model. Currently supports" + @@ -37,8 +34,7 @@ public class LocationInputType { .build() ) .field( - GraphQLInputObjectField - .newInputObjectField() + GraphQLInputObjectField.newInputObjectField() .name("coordinates") .description( "Coordinates for the location. This can be used alone or as" + diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/model/framework/MultilingualStringType.java b/application/src/main/java/org/opentripplanner/apis/transmodel/model/framework/MultilingualStringType.java index 9bcaab1b4e5..211ea225803 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/model/framework/MultilingualStringType.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/model/framework/MultilingualStringType.java @@ -9,13 +9,11 @@ public class MultilingualStringType { public static GraphQLObjectType create() { - return GraphQLObjectType - .newObject() + return GraphQLObjectType.newObject() .name("MultilingualString") .description("Text with language") .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("value") .type(new GraphQLNonNull(Scalars.GraphQLString)) .dataFetcher(environment -> @@ -24,8 +22,7 @@ public static GraphQLObjectType create() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("language") .type(Scalars.GraphQLString) .dataFetcher(environment -> ((Map.Entry) environment.getSource()).getKey() diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/model/framework/NoticeType.java b/application/src/main/java/org/opentripplanner/apis/transmodel/model/framework/NoticeType.java index 15ac3fd2356..2d294de03d0 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/model/framework/NoticeType.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/model/framework/NoticeType.java @@ -9,21 +9,18 @@ public class NoticeType { public static GraphQLObjectType create() { - return GraphQLObjectType - .newObject() + return GraphQLObjectType.newObject() .name("Notice") .field(GqlUtil.newTransitIdField()) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("text") .type(Scalars.GraphQLString) .dataFetcher(environment -> ((Notice) environment.getSource()).text()) .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("publicCode") .type(Scalars.GraphQLString) .dataFetcher(environment -> ((Notice) environment.getSource()).publicCode()) diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/model/framework/OperatorType.java b/application/src/main/java/org/opentripplanner/apis/transmodel/model/framework/OperatorType.java index de58643f5dc..25c747ba901 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/model/framework/OperatorType.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/model/framework/OperatorType.java @@ -16,14 +16,12 @@ public static GraphQLObjectType create( GraphQLOutputType lineType, GraphQLOutputType serviceJourneyType ) { - return GraphQLObjectType - .newObject() + return GraphQLObjectType.newObject() .name("Operator") .description("Organisation providing public transport services.") .field(GqlUtil.newTransitIdField()) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("name") .type(new GraphQLNonNull(Scalars.GraphQLString)) .build() @@ -32,8 +30,7 @@ public static GraphQLObjectType create( GraphQLFieldDefinition.newFieldDefinition().name("url").type(Scalars.GraphQLString).build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("phone") .type(Scalars.GraphQLString) .build() @@ -44,14 +41,12 @@ public static GraphQLObjectType create( // .type(brandingType) // .build()) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("lines") .withDirective(TransmodelDirectives.TIMING_DATA) .type(new GraphQLNonNull(new GraphQLList(lineType))) .dataFetcher(environment -> - GqlUtil - .getTransitService(environment) + GqlUtil.getTransitService(environment) .listRoutes() .stream() .filter(route -> Objects.equals(route.getOperator(), environment.getSource())) @@ -60,14 +55,12 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("serviceJourney") .withDirective(TransmodelDirectives.TIMING_DATA) .type(new GraphQLNonNull(new GraphQLList(serviceJourneyType))) .dataFetcher(environment -> - GqlUtil - .getTransitService(environment) + GqlUtil.getTransitService(environment) .listTrips() .stream() .filter(trip -> Objects.equals(trip.getOperator(), environment.getSource())) diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/model/framework/PassThroughPointInputType.java b/application/src/main/java/org/opentripplanner/apis/transmodel/model/framework/PassThroughPointInputType.java index 3bc6d9d2f4c..89b5b133bbd 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/model/framework/PassThroughPointInputType.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/model/framework/PassThroughPointInputType.java @@ -8,13 +8,11 @@ public class PassThroughPointInputType { - public static final GraphQLInputObjectType INPUT_TYPE = GraphQLInputObjectType - .newInputObject() + public static final GraphQLInputObjectType INPUT_TYPE = GraphQLInputObjectType.newInputObject() .name("PassThroughPoint") .description("Defines one point which the journey must pass through.") .field( - GraphQLInputObjectField - .newInputObjectField() + GraphQLInputObjectField.newInputObjectField() .name("name") .description( "Optional name of the pass-through point for debugging and logging. It is not used in routing." @@ -23,8 +21,7 @@ public class PassThroughPointInputType { .build() ) .field( - GraphQLInputObjectField - .newInputObjectField() + GraphQLInputObjectField.newInputObjectField() .name("placeIds") .description( """ diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/model/framework/PenaltyForStreetModeType.java b/application/src/main/java/org/opentripplanner/apis/transmodel/model/framework/PenaltyForStreetModeType.java index c553fccf667..182f3b4aac6 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/model/framework/PenaltyForStreetModeType.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/model/framework/PenaltyForStreetModeType.java @@ -48,13 +48,11 @@ public class PenaltyForStreetModeType { private static final String FIELD_COST_FACTOR = "costFactor"; public static GraphQLInputObjectType create() { - return GraphQLInputObjectType - .newInputObject() + return GraphQLInputObjectType.newInputObject() .name("PenaltyForStreetMode") .description("A combination of street mode and penalty for time and cost.") .field( - GraphQLInputObjectField - .newInputObjectField() + GraphQLInputObjectField.newInputObjectField() .name(FIELD_STREET_MODE) .type(new GraphQLNonNull(EnumTypes.STREET_MODE)) .description( @@ -67,8 +65,7 @@ public static GraphQLInputObjectType create() { .build() ) .field( - GraphQLInputObjectField - .newInputObjectField() + GraphQLInputObjectField.newInputObjectField() .name(FIELD_TIME_PENALTY) .type(new GraphQLNonNull(TransmodelScalars.DOUBLE_FUNCTION_SCALAR)) .description( @@ -78,19 +75,15 @@ public static GraphQLInputObjectType create() { ) ) .field( - GraphQLInputObjectField - .newInputObjectField() + GraphQLInputObjectField.newInputObjectField() .name(FIELD_COST_FACTOR) .type(Scalars.GraphQLFloat) .defaultValueProgrammatic(1.0) .description( """ - This is used to take the time-penalty and multiply by the `{fieldCostFactorName}`. - The result is added to the generalized-cost. - """.replace( - "{fieldCostFactorName}", - FIELD_COST_FACTOR - ) + This is used to take the time-penalty and multiply by the `{fieldCostFactorName}`. + The result is added to the generalized-cost. + """.replace("{fieldCostFactorName}", FIELD_COST_FACTOR) ) ) .build(); @@ -98,8 +91,7 @@ public static GraphQLInputObjectType create() { /** Return a list of access-egress penalties */ public static Value mapToGraphQLValue(TimeAndCostPenaltyForEnum accessEgressPenalty) { - List values = EnumTypes.STREET_MODE - .getValues() + List values = EnumTypes.STREET_MODE.getValues() .stream() .map(gqlModeType -> { var mode = (StreetMode) gqlModeType.getValue(); @@ -134,25 +126,21 @@ private static Value mapPenaltyForStreetMode( GraphQLEnumValueDefinition streetModeGQL, TimeAndCostPenalty timeAndCostPenalty ) { - return ObjectValue - .newObjectValue() + return ObjectValue.newObjectValue() .objectField( - ObjectField - .newObjectField() + ObjectField.newObjectField() .name(FIELD_STREET_MODE) .value(EnumValue.of(streetModeGQL.getName())) .build() ) .objectField( - ObjectField - .newObjectField() + ObjectField.newObjectField() .name(FIELD_TIME_PENALTY) .value(StringValue.newStringValue(timeAndCostPenalty.timePenalty().serialize()).build()) .build() ) .objectField( - ObjectField - .newObjectField() + ObjectField.newObjectField() .name(FIELD_COST_FACTOR) .value(FloatValue.of(timeAndCostPenalty.costFactor())) .build() diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/model/framework/PointsOnLinkType.java b/application/src/main/java/org/opentripplanner/apis/transmodel/model/framework/PointsOnLinkType.java index 9807d041613..a6eda2923c0 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/model/framework/PointsOnLinkType.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/model/framework/PointsOnLinkType.java @@ -8,15 +8,13 @@ public class PointsOnLinkType { public static GraphQLObjectType create() { - return GraphQLObjectType - .newObject() + return GraphQLObjectType.newObject() .name("PointsOnLink") .description( "A list of coordinates encoded as a polyline string (see http://code.google.com/apis/maps/documentation/polylinealgorithm.html)" ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("length") .description("The number of points in the string") .type(Scalars.GraphQLInt) @@ -24,8 +22,7 @@ public static GraphQLObjectType create() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("points") .description( "The encoded points of the polyline. Be aware that the string could contain escape characters that need to be accounted for. " + diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/model/framework/RentalVehicleTypeType.java b/application/src/main/java/org/opentripplanner/apis/transmodel/model/framework/RentalVehicleTypeType.java index f0f4ab03419..fa2c07555f4 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/model/framework/RentalVehicleTypeType.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/model/framework/RentalVehicleTypeType.java @@ -11,44 +11,38 @@ public class RentalVehicleTypeType { public static final String NAME = "RentalVehicleType"; public static GraphQLObjectType create() { - return GraphQLObjectType - .newObject() + return GraphQLObjectType.newObject() .name(NAME) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("vehicleTypeId") .type(new GraphQLNonNull(Scalars.GraphQLString)) .dataFetcher(environment -> ((RentalVehicleType) environment.getSource()).id.getId()) .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("name") .type(Scalars.GraphQLString) .dataFetcher(environment -> ((RentalVehicleType) environment.getSource()).name) .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("formFactor") .type(new GraphQLNonNull(Scalars.GraphQLString)) .dataFetcher(environment -> ((RentalVehicleType) environment.getSource()).formFactor) .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("propulsionType") .type(new GraphQLNonNull(Scalars.GraphQLString)) .dataFetcher(environment -> ((RentalVehicleType) environment.getSource()).propulsionType) .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("maxRangeMeters") .type(Scalars.GraphQLFloat) .dataFetcher(environment -> ((RentalVehicleType) environment.getSource()).maxRangeMeters) diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/model/framework/ServerInfoType.java b/application/src/main/java/org/opentripplanner/apis/transmodel/model/framework/ServerInfoType.java index 8f679cafda3..adce878aa6d 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/model/framework/ServerInfoType.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/model/framework/ServerInfoType.java @@ -14,8 +14,7 @@ public class ServerInfoType { public static GraphQLOutputType create() { - return GraphQLObjectType - .newObject() + return GraphQLObjectType.newObject() .name("ServerInfo") .description( """ @@ -25,8 +24,7 @@ public static GraphQLOutputType create() { """ ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("version") .description("Maven version") .type(Scalars.GraphQLString) @@ -34,8 +32,7 @@ public static GraphQLOutputType create() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("buildTime") .description("OTP Build timestamp") .type(Scalars.GraphQLString) @@ -43,8 +40,7 @@ public static GraphQLOutputType create() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("gitBranch") .description("") .type(Scalars.GraphQLString) @@ -52,8 +48,7 @@ public static GraphQLOutputType create() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("gitCommit") .description("") .type(Scalars.GraphQLString) @@ -61,8 +56,7 @@ public static GraphQLOutputType create() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("gitCommitTime") .description("") .type(Scalars.GraphQLString) @@ -70,8 +64,7 @@ public static GraphQLOutputType create() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("otpConfigVersion") .description("The 'configVersion' of the " + OTP_CONFIG_FILENAME + " file.") .type(Scalars.GraphQLString) @@ -79,8 +72,7 @@ public static GraphQLOutputType create() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("buildConfigVersion") .description("The 'configVersion' of the " + BUILD_CONFIG_FILENAME + " file.") .type(Scalars.GraphQLString) @@ -88,8 +80,7 @@ public static GraphQLOutputType create() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("routerConfigVersion") .description("The 'configVersion' of the " + ROUTER_CONFIG_FILENAME + " file.") .type(Scalars.GraphQLString) @@ -97,8 +88,7 @@ public static GraphQLOutputType create() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("otpSerializationVersionId") .description( "The otp-serialization-version-id used to check graphs for compatibility with current version of OTP." @@ -108,13 +98,12 @@ public static GraphQLOutputType create() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("internalTransitModelTimeZone") .description( """ The internal time zone of the transit data. - + Note: The input data can be in several time zones, but OTP internally operates on a single one. """ ) diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/model/framework/StreetModeDurationInputType.java b/application/src/main/java/org/opentripplanner/apis/transmodel/model/framework/StreetModeDurationInputType.java index 9c92d7253d5..2e274e9142a 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/model/framework/StreetModeDurationInputType.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/model/framework/StreetModeDurationInputType.java @@ -27,20 +27,17 @@ public class StreetModeDurationInputType { private static final String FIELD_DURATION = "duration"; public static GraphQLInputObjectType create() { - return GraphQLInputObjectType - .newInputObject() + return GraphQLInputObjectType.newInputObject() .name("StreetModeDurationInput") .description("A combination of street mode and corresponding duration") .field( - GraphQLInputObjectField - .newInputObjectField() + GraphQLInputObjectField.newInputObjectField() .name(FIELD_STREET_MODE) .type(new GraphQLNonNull(EnumTypes.STREET_MODE)) .build() ) .field( - GraphQLInputObjectField - .newInputObjectField() + GraphQLInputObjectField.newInputObjectField() .name(FIELD_DURATION) .type(new GraphQLNonNull(TransmodelScalars.DURATION_SCALAR)) ) @@ -50,8 +47,7 @@ public static GraphQLInputObjectType create() { public static Value mapDurationForStreetModeGraphQLValue( DurationForEnum durationForStreetMode ) { - List list = EnumTypes.STREET_MODE - .getValues() + List list = EnumTypes.STREET_MODE.getValues() .stream() .map(gqlModeType -> { var mode = (StreetMode) gqlModeType.getValue(); @@ -65,18 +61,15 @@ public static Value mapDurationForStreetModeGraphQLValue( } static Value mapModeDuration(GraphQLEnumValueDefinition gqlModeType, Duration duration) { - return ObjectValue - .newObjectValue() + return ObjectValue.newObjectValue() .objectField( - ObjectField - .newObjectField() + ObjectField.newObjectField() .name(FIELD_STREET_MODE) .value(EnumValue.of(gqlModeType.getName())) .build() ) .objectField( - ObjectField - .newObjectField() + ObjectField.newObjectField() .name(FIELD_DURATION) .value(StringValue.newStringValue(duration.toString()).build()) .build() diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/model/framework/SystemNoticeType.java b/application/src/main/java/org/opentripplanner/apis/transmodel/model/framework/SystemNoticeType.java index 1cb237a1114..99263502676 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/model/framework/SystemNoticeType.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/model/framework/SystemNoticeType.java @@ -8,8 +8,7 @@ public class SystemNoticeType { public static GraphQLObjectType create() { - return GraphQLObjectType - .newObject() + return GraphQLObjectType.newObject() .name("SystemNotice") .description( """ @@ -19,21 +18,19 @@ public static GraphQLObjectType create() { them from the result. This make it possible to inspect the itinerary-filter-chain. A SystemNotice only have english text, because the primary user are technical staff, like testers and developers. - + **NOTE!** _A SystemNotice is for debugging the system, avoid putting logic on it in the client. The tags and usage may change without notice._""" ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("tag") .type(Scalars.GraphQLString) .dataFetcher(env -> ((SystemNotice) env.getSource()).tag()) .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("text") .type(Scalars.GraphQLString) .dataFetcher(env -> ((SystemNotice) env.getSource()).text()) diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/model/framework/TransmodelDirectives.java b/application/src/main/java/org/opentripplanner/apis/transmodel/model/framework/TransmodelDirectives.java index 98ee99a8a64..f99a9147a3c 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/model/framework/TransmodelDirectives.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/model/framework/TransmodelDirectives.java @@ -5,8 +5,7 @@ public class TransmodelDirectives { - public static final GraphQLDirective TIMING_DATA = GraphQLDirective - .newDirective() + public static final GraphQLDirective TIMING_DATA = GraphQLDirective.newDirective() .name("timingData") .description("Add timing data to prometheus, if Actuator API is enabled") .validLocation(Introspection.DirectiveLocation.FIELD_DEFINITION) diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/model/framework/ValidityPeriodType.java b/application/src/main/java/org/opentripplanner/apis/transmodel/model/framework/ValidityPeriodType.java index 956c24a60d5..ca027e0da99 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/model/framework/ValidityPeriodType.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/model/framework/ValidityPeriodType.java @@ -8,12 +8,10 @@ public class ValidityPeriodType { public static GraphQLObjectType create(GraphQLScalarType dateTimeScalar) { - return GraphQLObjectType - .newObject() + return GraphQLObjectType.newObject() .name("ValidityPeriod") .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("startTime") .type(dateTimeScalar) .description("Start of validity period") @@ -24,8 +22,7 @@ public static GraphQLObjectType create(GraphQLScalarType dateTimeScalar) { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("endTime") .type(dateTimeScalar) .description("End of validity period. Will return 'null' if validity is open-ended.") diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/model/network/DestinationDisplayType.java b/application/src/main/java/org/opentripplanner/apis/transmodel/model/network/DestinationDisplayType.java index ed5f82e58b0..b1696997d28 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/model/network/DestinationDisplayType.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/model/network/DestinationDisplayType.java @@ -9,15 +9,13 @@ public class DestinationDisplayType { public static GraphQLObjectType create() { - return GraphQLObjectType - .newObject() + return GraphQLObjectType.newObject() .name("DestinationDisplay") .description( "An advertised destination of a specific journey pattern, usually displayed on a head sign or at other on-board locations." ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("frontText") .description("Name of destination to show on front of vehicle.") .type(Scalars.GraphQLString) @@ -25,8 +23,7 @@ public static GraphQLObjectType create() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("via") .description( "Intermediary destinations which the vehicle will pass before reaching its final destination." diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/model/network/GroupOfLinesType.java b/application/src/main/java/org/opentripplanner/apis/transmodel/model/network/GroupOfLinesType.java index 6e52c6662a4..b1309c59610 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/model/network/GroupOfLinesType.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/model/network/GroupOfLinesType.java @@ -14,23 +14,20 @@ public class GroupOfLinesType { private static final String NAME = "GroupOfLines"; public static GraphQLObjectType create() { - return GraphQLObjectType - .newObject() + return GraphQLObjectType.newObject() .name(NAME) .description( "Additional (optional) grouping of lines for particular purposes such as e.g. fare harmonisation or public presentation." ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("id") .type(new GraphQLNonNull(Scalars.GraphQLID)) .dataFetcher(env -> TransitIdMapper.mapEntityIDToApi(env.getSource())) .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("privateCode") .description("For internal use by operator/authority.") .type(Scalars.GraphQLString) @@ -38,8 +35,7 @@ public static GraphQLObjectType create() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("shortName") .description("Short name for group of lines.") .type(Scalars.GraphQLString) @@ -47,8 +43,7 @@ public static GraphQLObjectType create() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("name") .description("Full name for group of lines.") .type(Scalars.GraphQLString) @@ -56,8 +51,7 @@ public static GraphQLObjectType create() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("description") .description("Description of group of lines") .type(Scalars.GraphQLString) @@ -65,8 +59,7 @@ public static GraphQLObjectType create() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("lines") .description("All lines part of this group of lines") .type(new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(LineType.REF)))) diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/model/network/JourneyPatternType.java b/application/src/main/java/org/opentripplanner/apis/transmodel/model/network/JourneyPatternType.java index dfde7427e5f..250b07f806d 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/model/network/JourneyPatternType.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/model/network/JourneyPatternType.java @@ -37,37 +37,32 @@ public static GraphQLObjectType create( GraphQLOutputType stopToStopGeometryType, GraphQLNamedOutputType ptSituationElementType ) { - return GraphQLObjectType - .newObject() + return GraphQLObjectType.newObject() .name("JourneyPattern") .field(GqlUtil.newTransitIdField()) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("line") .type(new GraphQLNonNull(lineType)) .dataFetcher(environment -> ((TripPattern) environment.getSource()).getRoute()) .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("directionType") .type(EnumTypes.DIRECTION_TYPE) .dataFetcher(environment -> ((TripPattern) environment.getSource()).getDirection()) .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("name") .type(Scalars.GraphQLString) .dataFetcher(environment -> ((TripPattern) environment.getSource()).getName()) .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("serviceJourneys") .withDirective(TransmodelDirectives.TIMING_DATA) .type(new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(serviceJourneyType)))) @@ -77,8 +72,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("serviceJourneysForDate") .withDirective(TransmodelDirectives.TIMING_DATA) .description("List of service journeys for the journey pattern for a given date") @@ -87,13 +81,11 @@ public static GraphQLObjectType create( ) .type(new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(serviceJourneyType)))) .dataFetcher(environment -> { - TIntSet services = GqlUtil - .getTransitService(environment) - .getServiceCodesRunningForDate( - Optional - .ofNullable((LocalDate) environment.getArgument("date")) - .orElse(LocalDate.now()) - ); + TIntSet services = GqlUtil.getTransitService(environment).getServiceCodesRunningForDate( + Optional.ofNullable((LocalDate) environment.getArgument("date")).orElse( + LocalDate.now() + ) + ); return ((TripPattern) environment.getSource()).getScheduledTimetable() .getTripTimes() @@ -105,8 +97,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("quays") .description("Quays visited by service journeys for this journey patterns") .type(new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(quayType)))) @@ -114,8 +105,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("pointsOnLink") .type(linkGeometryType) .dataFetcher(environment -> { @@ -129,8 +119,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("stopToStopGeometries") .description( "Detailed path travelled by journey pattern divided into stop-to-stop sections." @@ -142,15 +131,13 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("situations") .description("Get all situations active for the journey pattern.") .type(new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(ptSituationElementType)))) .dataFetcher(environment -> { TripPattern tripPattern = environment.getSource(); - return GqlUtil - .getTransitService(environment) + return GqlUtil.getTransitService(environment) .getTransitAlertService() .getDirectionAndRouteAlerts( tripPattern.getDirection(), @@ -160,8 +147,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("notices") .type(new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(noticeType)))) .dataFetcher(environment -> { diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/model/network/LineType.java b/application/src/main/java/org/opentripplanner/apis/transmodel/model/network/LineType.java index 9aa129b2abd..f6792e0eb24 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/model/network/LineType.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/model/network/LineType.java @@ -35,46 +35,40 @@ public static GraphQLObjectType create( GraphQLOutputType brandingType, GraphQLOutputType groupOfLinesType ) { - return GraphQLObjectType - .newObject() + return GraphQLObjectType.newObject() .name(NAME) .description( "A group of routes which is generally known to the public by a similar name or number" ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("id") .type(new GraphQLNonNull(Scalars.GraphQLID)) .dataFetcher(environment -> TransitIdMapper.mapEntityIDToApi(getSource(environment))) .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("authority") .type(authorityType) .dataFetcher(environment -> (getSource(environment).getAgency())) .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("operator") .type(operatorType) .dataFetcher(environment -> ((getSource(environment)).getOperator())) .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("branding") .type(brandingType) .dataFetcher(environment -> (getSource(environment)).getBranding()) ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("publicCode") .type(Scalars.GraphQLString) .description( @@ -84,24 +78,21 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("name") .type(Scalars.GraphQLString) .dataFetcher(environment -> (getSource(environment)).getLongName()) .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("transportMode") .type(EnumTypes.TRANSPORT_MODE) .dataFetcher(environment -> (getSource(environment)).getMode()) .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("transportSubmode") .type(EnumTypes.TRANSPORT_SUBMODE) .dataFetcher(environment -> @@ -110,8 +101,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("description") .type(Scalars.GraphQLString) .dataFetcher(environment -> (getSource(environment)).getDescription()) @@ -121,23 +111,20 @@ public static GraphQLObjectType create( GraphQLFieldDefinition.newFieldDefinition().name("url").type(Scalars.GraphQLString).build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("presentation") .type(presentationType) .dataFetcher(DataFetchingEnvironment::getSource) .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("bikesAllowed") .type(EnumTypes.BIKES_ALLOWED) .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("journeyPatterns") .type(new GraphQLList(journeyPatternType)) .dataFetcher(environment -> @@ -146,13 +133,11 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("quays") .type(new GraphQLNonNull(new GraphQLList(quayType))) .dataFetcher(environment -> - GqlUtil - .getTransitService(environment) + GqlUtil.getTransitService(environment) .findPatterns(getSource(environment)) .stream() .map(TripPattern::getStops) @@ -163,13 +148,11 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("serviceJourneys") .type(new GraphQLNonNull(new GraphQLList(serviceJourneyType))) .dataFetcher(environment -> - GqlUtil - .getTransitService(environment) + GqlUtil.getTransitService(environment) .findPatterns(getSource(environment)) .stream() .flatMap(TripPattern::scheduledTripsAsStream) @@ -179,8 +162,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("notices") .type(new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(noticeType)))) .dataFetcher(environment -> { @@ -190,22 +172,19 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("situations") .description("Get all situations active for the line.") .type(new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(ptSituationElementType)))) .dataFetcher(environment -> - GqlUtil - .getTransitService(environment) + GqlUtil.getTransitService(environment) .getTransitAlertService() .getRouteAlerts((getSource(environment)).getId()) ) .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("flexibleLineType") .description("Type of flexible line, or null if line is not flexible.") .type(Scalars.GraphQLString) @@ -213,8 +192,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("bookingArrangements") .description("Booking arrangements for flexible line.") .type(bookingArrangementType) @@ -225,8 +203,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("groupOfLines") .description("Groups of lines that line is a part of.") .type(new GraphQLNonNull(new GraphQLList(groupOfLinesType))) diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/model/network/PresentationType.java b/application/src/main/java/org/opentripplanner/apis/transmodel/model/network/PresentationType.java index 0632ba10c1d..03ff7b2b0c3 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/model/network/PresentationType.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/model/network/PresentationType.java @@ -8,21 +8,18 @@ public class PresentationType { public static GraphQLObjectType create() { - return GraphQLObjectType - .newObject() + return GraphQLObjectType.newObject() .name("Presentation") .description("Types describing common presentation properties") .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("colour") .type(Scalars.GraphQLString) .dataFetcher(environment -> ((Route) environment.getSource()).getColor()) .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("textColour") .type(Scalars.GraphQLString) .dataFetcher(environment -> ((Route) environment.getSource()).getTextColor()) diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/model/network/StopToStopGeometryType.java b/application/src/main/java/org/opentripplanner/apis/transmodel/model/network/StopToStopGeometryType.java index 98a965e50be..d1845e9ba1c 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/model/network/StopToStopGeometryType.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/model/network/StopToStopGeometryType.java @@ -11,13 +11,11 @@ public static GraphQLObjectType create( GraphQLOutputType linkGeometryType, GraphQLOutputType quayType ) { - return GraphQLObjectType - .newObject() + return GraphQLObjectType.newObject() .name("StopToStopGeometry") .description("List of coordinates between two stops as a polyline") .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("pointsOnLink") .description( "A list of coordinates encoded as a polyline string between two stops (see http://code.google.com/apis/maps/documentation/polylinealgorithm.html)" @@ -27,8 +25,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("fromQuay") .description("Origin Quay") .type(quayType) @@ -36,8 +33,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("toQuay") .description("Destination Quay") .type(quayType) diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/BannedInputType.java b/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/BannedInputType.java index ab78395a160..7098eab926e 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/BannedInputType.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/BannedInputType.java @@ -5,8 +5,7 @@ public class BannedInputType { - static final GraphQLInputObjectType INPUT_TYPE = GraphQLInputObjectType - .newInputObject() + static final GraphQLInputObjectType INPUT_TYPE = GraphQLInputObjectType.newInputObject() .name("InputBanned") .description( "Filter trips by disallowing lines involving certain elements. If both lines and " + diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/ElevationProfileStepType.java b/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/ElevationProfileStepType.java index bc1f1185463..d8ce0f144de 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/ElevationProfileStepType.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/ElevationProfileStepType.java @@ -16,23 +16,18 @@ public class ElevationProfileStepType { static String makeDescription(String name) { return """ - The %s's elevation profile. All elevation values, including the first one, are in meters - above sea level. The elevation is negative for places below sea level. The profile - includes both the start and end coordinate. - """.formatted( - name - ) - .stripIndent(); + The %s's elevation profile. All elevation values, including the first one, are in meters + above sea level. The elevation is negative for places below sea level. The profile + includes both the start and end coordinate. + """.formatted(name).stripIndent(); } public static GraphQLObjectType create() { - return GraphQLObjectType - .newObject() + return GraphQLObjectType.newObject() .name(NAME) .description("Individual step of an elevation profile.") .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("distance") .description("The horizontal distance from the start of the step, in meters.") .type(Scalars.GraphQLFloat) @@ -40,14 +35,13 @@ public static GraphQLObjectType create() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("elevation") .description( """ - The elevation at this distance, in meters above sea level. It is negative if the - location is below sea level. - """.stripIndent() + The elevation at this distance, in meters above sea level. It is negative if the + location is below sea level. + """.stripIndent() ) .type(Scalars.GraphQLFloat) .dataFetcher(env -> step(env).y()) diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/FilterInputType.java b/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/FilterInputType.java index 1e868eadb86..61d9c5e384a 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/FilterInputType.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/FilterInputType.java @@ -7,15 +7,13 @@ public class FilterInputType { - public static final GraphQLInputObjectType INPUT_TYPE = GraphQLInputObjectType - .newInputObject() + public static final GraphQLInputObjectType INPUT_TYPE = GraphQLInputObjectType.newInputObject() .name("TripFilterInput") .description( "A collection of selectors for what lines/trips should be included in / excluded from search" ) .field( - GraphQLInputObjectField - .newInputObjectField() + GraphQLInputObjectField.newInputObjectField() .name("select") .description( "A list of selectors for what lines/trips should be allowed during search. " + @@ -26,8 +24,7 @@ public class FilterInputType { .build() ) .field( - GraphQLInputObjectField - .newInputObjectField() + GraphQLInputObjectField.newInputObjectField() .name("not") .description( "A list of selectors for what lines/trips should be excluded during the search. " + diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/ItineraryFiltersInputType.java b/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/ItineraryFiltersInputType.java index 7f0d5b10215..fee7189b8ed 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/ItineraryFiltersInputType.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/ItineraryFiltersInputType.java @@ -28,8 +28,7 @@ public class ItineraryFiltersInputType { "groupSimilarityKeepNumOfItineraries"; public static GraphQLInputObjectType create(ItineraryFilterPreferences dft) { - return GraphQLInputObjectType - .newInputObject() + return GraphQLInputObjectType.newInputObject() .name("ItineraryFilters") .description( "Parameters for the OTP Itinerary Filter Chain. These parameters SHOULD be " + @@ -37,8 +36,7 @@ public static GraphQLInputObjectType create(ItineraryFilterPreferences dft) { "are made available here to be able to experiment and tune the server." ) .field( - GraphQLInputObjectField - .newInputObjectField() + GraphQLInputObjectField.newInputObjectField() .name(MIN_SAFE_TRANSFER_TIME_FACTOR) .type(Scalars.GraphQLFloat) .deprecate("This filter is removed, it has undesired side-effects") @@ -49,23 +47,19 @@ public static GraphQLInputObjectType create(ItineraryFilterPreferences dft) { .build() ) .field( - GraphQLInputObjectField - .newInputObjectField() + GraphQLInputObjectField.newInputObjectField() .name(TRANSIT_GENERALIZED_COST_LIMIT) .type( - GraphQLInputObjectType - .newInputObject() + GraphQLInputObjectType.newInputObject() .name("TransitGeneralizedCostFilterParams") .field( - GraphQLInputObjectField - .newInputObjectField() + GraphQLInputObjectField.newInputObjectField() .name("costLimitFunction") .type(new GraphQLNonNull(TransmodelScalars.DOUBLE_FUNCTION_SCALAR)) .build() ) .field( - GraphQLInputObjectField - .newInputObjectField() + GraphQLInputObjectField.newInputObjectField() .name("intervalRelaxFactor") .type(new GraphQLNonNull(Scalars.GraphQLFloat)) .build() @@ -92,8 +86,7 @@ public static GraphQLInputObjectType create(ItineraryFilterPreferences dft) { .build() ) .field( - GraphQLInputObjectField - .newInputObjectField() + GraphQLInputObjectField.newInputObjectField() .name(GROUP_SIMILARITY_KEEP_ONE) .type(Scalars.GraphQLFloat) .description( @@ -104,8 +97,7 @@ public static GraphQLInputObjectType create(ItineraryFilterPreferences dft) { .build() ) .field( - GraphQLInputObjectField - .newInputObjectField() + GraphQLInputObjectField.newInputObjectField() .type(Scalars.GraphQLFloat) .name(GROUP_SIMILARITY_KEEP_THREE) .description( @@ -118,8 +110,7 @@ public static GraphQLInputObjectType create(ItineraryFilterPreferences dft) { .build() ) .field( - GraphQLInputObjectField - .newInputObjectField() + GraphQLInputObjectField.newInputObjectField() .type(Scalars.GraphQLFloat) .name(GROUP_SIMILARITY_KEEP_N_ITINERARIES) .deprecate("Use " + GROUP_SIMILARITY_KEEP_THREE + " instead.") @@ -127,8 +118,7 @@ public static GraphQLInputObjectType create(ItineraryFilterPreferences dft) { .build() ) .field( - GraphQLInputObjectField - .newInputObjectField() + GraphQLInputObjectField.newInputObjectField() .type(Scalars.GraphQLFloat) .name(GROUPED_OTHER_THAN_SAME_LEGS_MAX_COST_MULTIPLIER) .description( @@ -141,8 +131,7 @@ public static GraphQLInputObjectType create(ItineraryFilterPreferences dft) { .build() ) .field( - GraphQLInputObjectField - .newInputObjectField() + GraphQLInputObjectField.newInputObjectField() .type(EnumTypes.ITINERARY_FILTER_DEBUG_PROFILE) .name(DEBUG) .description( @@ -176,16 +165,13 @@ public static void mapToRequest( GROUPED_OTHER_THAN_SAME_LEGS_MAX_COST_MULTIPLIER, builder::withGroupedOtherThanSameLegsMaxCostMultiplier ); - setField( - callWith, - TRANSIT_GENERALIZED_COST_LIMIT, - (Map v) -> - builder.withTransitGeneralizedCostLimit( - new TransitGeneralizedCostFilterParams( - ((DoubleFunction) v.get("costLimitFunction")).asCostLinearFunction(), - (double) v.get("intervalRelaxFactor") - ) + setField(callWith, TRANSIT_GENERALIZED_COST_LIMIT, (Map v) -> + builder.withTransitGeneralizedCostLimit( + new TransitGeneralizedCostFilterParams( + ((DoubleFunction) v.get("costLimitFunction")).asCostLinearFunction(), + (double) v.get("intervalRelaxFactor") ) + ) ); setField(callWith, DEBUG, builder::withDebug); } diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/JourneyWhiteListed.java b/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/JourneyWhiteListed.java index 75c1fe918dd..ba9952404c0 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/JourneyWhiteListed.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/JourneyWhiteListed.java @@ -18,8 +18,7 @@ public class JourneyWhiteListed { - public static final GraphQLInputObjectType INPUT_TYPE = GraphQLInputObjectType - .newInputObject() + public static final GraphQLInputObjectType INPUT_TYPE = GraphQLInputObjectType.newInputObject() .name("InputWhiteListed") .description( "Filter trips by only allowing lines involving certain " + @@ -46,8 +45,9 @@ public JourneyWhiteListed(DataFetchingEnvironment environment) { this.authorityIds = Set.of(); this.lineIds = Set.of(); } else { - this.authorityIds = - Set.copyOf(TransitIdMapper.mapIDsToDomainNullSafe(whiteList.get("authorities"))); + this.authorityIds = Set.copyOf( + TransitIdMapper.mapIDsToDomainNullSafe(whiteList.get("authorities")) + ); this.lineIds = Set.copyOf(TransitIdMapper.mapIDsToDomainNullSafe(whiteList.get("lines"))); } } diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/LegType.java b/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/LegType.java index 60d98c1bd24..96bd2d79ba9 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/LegType.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/LegType.java @@ -57,15 +57,13 @@ public static GraphQLObjectType create( GraphQLType elevationStepType, GraphQLScalarType dateTimeScalar ) { - return GraphQLObjectType - .newObject() + return GraphQLObjectType.newObject() .name("Leg") .description( "Part of a trip pattern. Either a ride on a public transport vehicle or access or path link to/from/between places" ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("id") .description( "An identifier for the leg, which can be used to re-fetch transit leg information." @@ -75,8 +73,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("aimedStartTime") .description("The aimed date and time this leg starts.") .type(new GraphQLNonNull(dateTimeScalar)) @@ -91,8 +88,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("expectedStartTime") .description("The expected, real-time adjusted date and time this leg starts.") .type(new GraphQLNonNull(dateTimeScalar)) @@ -100,8 +96,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("aimedEndTime") .description("The aimed date and time this leg ends.") .type(new GraphQLNonNull(dateTimeScalar)) @@ -115,8 +110,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("expectedEndTime") .description("The expected, real-time adjusted date and time this leg ends.") .type(new GraphQLNonNull(dateTimeScalar)) @@ -124,8 +118,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("mode") .description( "The mode of transport or access (e.g., foot) used when traversing this leg." @@ -135,8 +128,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("transportSubmode") .description( "The transport sub mode (e.g., localBus or expressBus) used when traversing this leg. Null if leg is not a ride" @@ -152,8 +144,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("duration") .description("The leg's duration in seconds") .type(new GraphQLNonNull(ExtendedScalars.GraphQLLong)) @@ -161,8 +152,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("directDuration") .type(new GraphQLNonNull(ExtendedScalars.GraphQLLong)) .description("NOT IMPLEMENTED") @@ -170,8 +160,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("pointsOnLink") .description("The leg's geometry.") .type(linkGeometryType) @@ -179,8 +168,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("authority") .description( "For ride legs, the service authority used for this legs. For non-ride legs, null." @@ -190,8 +178,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("operator") .description("For ride legs, the operator used for this legs. For non-ride legs, null.") .type(operatorType) @@ -199,8 +186,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("realtime") .description("Whether there is real-time data about this leg") .type(new GraphQLNonNull(Scalars.GraphQLBoolean)) @@ -208,8 +194,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("distance") .description("The distance traveled while traversing the leg in meters.") .type(new GraphQLNonNull(Scalars.GraphQLFloat)) @@ -217,8 +202,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("generalizedCost") .description("Generalized cost or weight of the leg. Used for debugging.") .type(Scalars.GraphQLInt) @@ -226,8 +210,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("ride") .description("Whether this leg is a ride leg or not.") .type(new GraphQLNonNull(Scalars.GraphQLBoolean)) @@ -235,8 +218,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("walkingBike") .description("Whether this leg is walking with a bike.") .type(Scalars.GraphQLBoolean) @@ -244,8 +226,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("rentedBike") .description("Whether this leg is with a rented bike.") .type(Scalars.GraphQLBoolean) @@ -253,8 +234,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("fromPlace") .description("The Place where the leg originates.") .type(new GraphQLNonNull(placeType)) @@ -262,8 +242,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("toPlace") .description("The Place where the leg ends.") .type(new GraphQLNonNull(placeType)) @@ -271,8 +250,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("fromEstimatedCall") .withDirective(TransmodelDirectives.TIMING_DATA) .description("EstimatedCall for the quay where the leg originates.") @@ -281,8 +259,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("toEstimatedCall") .withDirective(TransmodelDirectives.TIMING_DATA) .description("EstimatedCall for the quay where the leg ends.") @@ -291,8 +268,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("line") .description("For ride legs, the line. For non-ride legs, null.") .type(lineType) @@ -300,8 +276,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("serviceJourney") .description("For ride legs, the service journey. For non-ride legs, null.") .type(serviceJourneyType) @@ -309,8 +284,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("datedServiceJourney") .description("The dated service journey used for this leg.") .type(datedServiceJourneyType) @@ -318,8 +292,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("serviceDate") .description( "For transit legs, the service date of the trip. For non-transit legs, null." @@ -331,8 +304,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("intermediateQuays") .description( "For ride legs, intermediate quays between the Place where the leg originates and the Place where the leg ends. For non-ride legs, empty list." @@ -355,8 +327,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("intermediateEstimatedCalls") .withDirective(TransmodelDirectives.TIMING_DATA) .description( @@ -369,8 +340,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("serviceJourneyEstimatedCalls") .withDirective(TransmodelDirectives.TIMING_DATA) .description( @@ -388,8 +358,7 @@ public static GraphQLObjectType create( // .dataFetcher(env -> leg(env).intermediatePlace) // .build()) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("situations") .description("All relevant situations for this leg") .type(new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(ptSituationElementType)))) @@ -397,8 +366,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("steps") .description("Do we continue from a specified via place") .type(new GraphQLNonNull(new GraphQLList(pathGuidanceType))) @@ -406,32 +374,28 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("interchangeFrom") .type(interchangeType) .dataFetcher(env -> leg(env).getTransferFromPrevLeg()) .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("interchangeTo") .type(interchangeType) .dataFetcher(env -> leg(env).getTransferToNextLeg()) .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("bookingArrangements") .type(bookingArrangementType) .dataFetcher(env -> leg(env).getPickupBookingInfo()) .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("bikeRentalNetworks") .type(new GraphQLNonNull(new GraphQLList(Scalars.GraphQLString))) .dataFetcher(env -> @@ -442,8 +406,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .description(ElevationProfileStepType.makeDescription("leg")) .name("elevationProfile") .type(new GraphQLNonNull(new GraphQLList(elevationStepType))) @@ -453,24 +416,21 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("previousLegs") .description( "Fetch the previous legs, which can be used to replace this leg. The replacement legs do arrive/depart from/to the same stop places. It might be necessary to change other legs in an itinerary in order to be able to ride the returned legs." ) .type(new GraphQLList(new GraphQLNonNull(REF))) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("previous") .description("Number of earlier legs to return.") .defaultValueProgrammatic(1) .type(Scalars.GraphQLInt) ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("filter") .description("Whether the leg should be similar to this leg in some way.") .defaultValueProgrammatic("noFilter") @@ -493,24 +453,21 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("nextLegs") .description( "Fetch the next legs, which can be used to replace this leg. The replacement legs do arrive/depart from/to the same stop places. It might be necessary to change other legs in an itinerary in order to be able to ride the returned legs." ) .type(new GraphQLList(new GraphQLNonNull(REF))) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("next") .description("Number of later legs to return.") .defaultValueProgrammatic(1) .type(Scalars.GraphQLInt) ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("filter") .description("Whether the leg should be similar to this leg in some way.") .defaultValueProgrammatic("noFilter") diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/ModeAndSubModeInputType.java b/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/ModeAndSubModeInputType.java index d98108e6c7d..2c336d98c61 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/ModeAndSubModeInputType.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/ModeAndSubModeInputType.java @@ -9,12 +9,10 @@ public class ModeAndSubModeInputType { - static final GraphQLInputObjectType INPUT_TYPE = GraphQLInputObjectType - .newInputObject() + static final GraphQLInputObjectType INPUT_TYPE = GraphQLInputObjectType.newInputObject() .name("TransportModes") .field( - GraphQLInputObjectField - .newInputObjectField() + GraphQLInputObjectField.newInputObjectField() .name("transportMode") .description( "A transportMode that should be allowed for this search. You can further" + @@ -24,8 +22,7 @@ public class ModeAndSubModeInputType { .build() ) .field( - GraphQLInputObjectField - .newInputObjectField() + GraphQLInputObjectField.newInputObjectField() .name("transportSubModes") .description( "The allowed transportSubModes for this search. If this element is not" + diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/ModeInputType.java b/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/ModeInputType.java index a5b7b533e94..95bb057eae3 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/ModeInputType.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/ModeInputType.java @@ -7,8 +7,7 @@ class ModeInputType { - static final GraphQLInputObjectType INPUT_TYPE = GraphQLInputObjectType - .newInputObject() + static final GraphQLInputObjectType INPUT_TYPE = GraphQLInputObjectType.newInputObject() .name("Modes") .description( "Input format for specifying which modes will be allowed for this search. " + @@ -16,8 +15,7 @@ class ModeInputType { "of foot and all transport modes will be allowed." ) .field( - GraphQLInputObjectField - .newInputObjectField() + GraphQLInputObjectField.newInputObjectField() .name("accessMode") .description( "The mode used to get from the origin to the access stops in the transit " + @@ -28,8 +26,7 @@ class ModeInputType { .build() ) .field( - GraphQLInputObjectField - .newInputObjectField() + GraphQLInputObjectField.newInputObjectField() .name("egressMode") .description( "The mode used to get from the egress stops in the transit network to" + @@ -40,8 +37,7 @@ class ModeInputType { .build() ) .field( - GraphQLInputObjectField - .newInputObjectField() + GraphQLInputObjectField.newInputObjectField() .name("directMode") .description( "The mode used to get from the origin to the destination directly, " + @@ -52,8 +48,7 @@ class ModeInputType { .build() ) .field( - GraphQLInputObjectField - .newInputObjectField() + GraphQLInputObjectField.newInputObjectField() .name("transportModes") .description( "The allowed modes for the transit part of the trip. Use an empty list to " + diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/PathGuidanceType.java b/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/PathGuidanceType.java index 8840e8fedb8..4e2a47eb8ac 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/PathGuidanceType.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/PathGuidanceType.java @@ -13,13 +13,11 @@ public class PathGuidanceType { public static GraphQLObjectType create(GraphQLObjectType elevationStepType) { - return GraphQLObjectType - .newObject() + return GraphQLObjectType.newObject() .name("PathGuidance") .description("A series of turn by turn instructions used for walking, biking and driving.") .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("distance") .description("The distance in meters that this step takes.") .type(Scalars.GraphQLFloat) @@ -27,8 +25,7 @@ public static GraphQLObjectType create(GraphQLObjectType elevationStepType) { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("relativeDirection") .description("The relative direction of this step.") .type(EnumTypes.RELATIVE_DIRECTION) @@ -38,8 +35,7 @@ public static GraphQLObjectType create(GraphQLObjectType elevationStepType) { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("streetName") .description("The name of the street.") .type(Scalars.GraphQLString) @@ -52,8 +48,7 @@ public static GraphQLObjectType create(GraphQLObjectType elevationStepType) { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("heading") .description("The absolute direction of this step.") .type(EnumTypes.ABSOLUTE_DIRECTION) @@ -63,8 +58,7 @@ public static GraphQLObjectType create(GraphQLObjectType elevationStepType) { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("exit") .description("When exiting a highway or traffic circle, the exit name/number.") .type(Scalars.GraphQLString) @@ -74,8 +68,7 @@ public static GraphQLObjectType create(GraphQLObjectType elevationStepType) { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("stayOn") .description("Indicates whether or not a street changes direction at an intersection.") .type(Scalars.GraphQLBoolean) @@ -83,8 +76,7 @@ public static GraphQLObjectType create(GraphQLObjectType elevationStepType) { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("area") .description( "This step is on an open area, such as a plaza or train platform, and thus the directions should say something like \"cross\"" @@ -94,8 +86,7 @@ public static GraphQLObjectType create(GraphQLObjectType elevationStepType) { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("bogusName") .description( "The name of this street was generated by the system, so we should only display it once, and generally just display right/left directions" @@ -105,8 +96,7 @@ public static GraphQLObjectType create(GraphQLObjectType elevationStepType) { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("latitude") .description("The latitude of the step.") .type(Scalars.GraphQLFloat) @@ -116,8 +106,7 @@ public static GraphQLObjectType create(GraphQLObjectType elevationStepType) { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("longitude") .description("The longitude of the step.") .type(Scalars.GraphQLFloat) @@ -127,8 +116,7 @@ public static GraphQLObjectType create(GraphQLObjectType elevationStepType) { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("elevationProfile") .description(ElevationProfileStepType.makeDescription("step")) .type(new GraphQLNonNull(new GraphQLList(elevationStepType))) diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/PlanPlaceType.java b/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/PlanPlaceType.java index a39a25ae93d..db82cc2de98 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/PlanPlaceType.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/PlanPlaceType.java @@ -22,15 +22,13 @@ public static GraphQLObjectType create( GraphQLOutputType rentalVehicleType, GraphQLOutputType quayType ) { - return GraphQLObjectType - .newObject() + return GraphQLObjectType.newObject() .name("Place") .description( "Common super class for all places (stop places, quays, car parks, bike parks and bike rental stations )" ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("name") .description( "For transit quays, the name of the quay. For points of interest, the name of the POI." @@ -42,8 +40,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("vertexType") .description( "Type of vertex. (Normal, Bike sharing station, Bike P+R, Transit quay) Mostly used for better localization of bike sharing and P+R station names" @@ -53,8 +50,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("latitude") .description("The latitude of the place.") .type(new GraphQLNonNull(Scalars.GraphQLFloat)) @@ -70,8 +66,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("longitude") .description("The longitude of the place.") .type(new GraphQLNonNull(Scalars.GraphQLFloat)) @@ -87,8 +82,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("quay") .description("The quay related to the place.") .type(quayType) @@ -100,8 +94,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("flexibleArea") .description("The flexible area related to the place.") .type(GeoJSONCoordinatesScalar.getGraphQGeoJSONCoordinatesScalar()) @@ -113,8 +106,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("bikeRentalStation") .type(bikeRentalStationType) .description("The bike rental station related to the place") @@ -127,8 +119,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("rentalVehicle") .type(rentalVehicleType) .description("The rental vehicle related to the place") diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/RelaxCostType.java b/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/RelaxCostType.java index 9272bd86757..5fd501eba6a 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/RelaxCostType.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/RelaxCostType.java @@ -18,8 +18,7 @@ public class RelaxCostType { public static final String RATIO = "ratio"; public static final String CONSTANT = "constant"; - static final GraphQLInputObjectType INPUT_TYPE = GraphQLInputObjectType - .newInputObject() + static final GraphQLInputObjectType INPUT_TYPE = GraphQLInputObjectType.newInputObject() .name("RelaxCostInput") .description( """ @@ -33,8 +32,7 @@ public class RelaxCostType { """ ) .field( - GraphQLInputObjectField - .newInputObjectField() + GraphQLInputObjectField.newInputObjectField() .name(RATIO) .description("The factor to multiply with the 'other cost'. Minimum value is 1.0.") .defaultValueLiteral(FloatValue.of(1.0)) @@ -42,8 +40,7 @@ public class RelaxCostType { .build() ) .field( - GraphQLInputObjectField - .newInputObjectField() + GraphQLInputObjectField.newInputObjectField() .name(CONSTANT) .description( "The constant value to add to the limit. Must be a positive number. The value is " + @@ -57,14 +54,12 @@ public class RelaxCostType { .build(); public static ObjectValue valueOf(CostLinearFunction value) { - return ObjectValue - .newObjectValue() + return ObjectValue.newObjectValue() .objectField( ObjectField.newObjectField().name(RATIO).value(FloatValue.of(value.coefficient())).build() ) .objectField( - ObjectField - .newObjectField() + ObjectField.newObjectField() .name(CONSTANT) // We only use this to display the default value (this is an input type), so using // the lenient OTP version of duration is ok - it is slightly more readable. diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/RoutingErrorType.java b/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/RoutingErrorType.java index 215e1983ca0..3f29c7d6e74 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/RoutingErrorType.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/RoutingErrorType.java @@ -12,21 +12,18 @@ public class RoutingErrorType { public static GraphQLObjectType create() { - return GraphQLObjectType - .newObject() + return GraphQLObjectType.newObject() .name("RoutingError") .description("Description of the reason, why the planner did not return any results") .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("code") .description("An enum describing the reason") .type(new GraphQLNonNull(ROUTING_ERROR_CODE)) .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("inputField") .description( "An enum describing the field which should be changed, in order for the search to succeed" @@ -35,8 +32,7 @@ public static GraphQLObjectType create() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("description") .description( "A textual description of why the search failed. The clients are expected to have their own translations based on the code, for user visible error messages." diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/SelectInputType.java b/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/SelectInputType.java index 900e8c927fb..f54d2cfeb3b 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/SelectInputType.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/SelectInputType.java @@ -8,8 +8,7 @@ public class SelectInputType { - static final GraphQLInputObjectType INPUT_TYPE = GraphQLInputObjectType - .newInputObject() + static final GraphQLInputObjectType INPUT_TYPE = GraphQLInputObjectType.newInputObject() .name("TripFilterSelectInput") .description( "A list of selectors for filter allow-list / exclude-list. " + @@ -19,24 +18,21 @@ public class SelectInputType { "is applied to the existing set of lines. " ) .field( - GraphQLInputObjectField - .newInputObjectField() + GraphQLInputObjectField.newInputObjectField() .name("lines") .description("Set of ids for lines that should be included in/excluded from search") .type(new GraphQLList(new GraphQLNonNull(Scalars.GraphQLID))) .build() ) .field( - GraphQLInputObjectField - .newInputObjectField() + GraphQLInputObjectField.newInputObjectField() .name("authorities") .description("Set of ids for authorities that should be included in/excluded from search") .type(new GraphQLList(new GraphQLNonNull(Scalars.GraphQLID))) .build() ) .field( - GraphQLInputObjectField - .newInputObjectField() + GraphQLInputObjectField.newInputObjectField() .name("serviceJourneys") .description( "Set of ids for service journeys that should be included in/excluded from search" @@ -45,8 +41,7 @@ public class SelectInputType { .build() ) .field( - GraphQLInputObjectField - .newInputObjectField() + GraphQLInputObjectField.newInputObjectField() .name("transportModes") .description( "The allowed modes for the transit part of the trip. Use an empty list to " + @@ -57,8 +52,7 @@ public class SelectInputType { .build() ) .field( - GraphQLInputObjectField - .newInputObjectField() + GraphQLInputObjectField.newInputObjectField() .name("groupOfLines") .description( "Set of ids for group of lines that should be included in/excluded from the search" diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/TriangleFactorsInputType.java b/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/TriangleFactorsInputType.java index 73c96f7f726..9d5a467bfe0 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/TriangleFactorsInputType.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/TriangleFactorsInputType.java @@ -7,31 +7,27 @@ public class TriangleFactorsInputType { - public static final GraphQLInputObjectType INPUT_TYPE = GraphQLInputObjectType - .newInputObject() + public static final GraphQLInputObjectType INPUT_TYPE = GraphQLInputObjectType.newInputObject() .name("TriangleFactors") .description( "How much the factors safety, slope and distance are weighted relative to each other when routing bicycle legs. In total all three values need to add up to 1." ) .field( - GraphQLInputObjectField - .newInputObjectField() + GraphQLInputObjectField.newInputObjectField() .name("safety") .description("How important is bicycle safety expressed as a fraction of 1.") .type(new GraphQLNonNull(Scalars.GraphQLFloat)) .build() ) .field( - GraphQLInputObjectField - .newInputObjectField() + GraphQLInputObjectField.newInputObjectField() .name("slope") .description("How important is slope/elevation expressed as a fraction of 1.") .type(new GraphQLNonNull(Scalars.GraphQLFloat)) .build() ) .field( - GraphQLInputObjectField - .newInputObjectField() + GraphQLInputObjectField.newInputObjectField() .name("time") .description( "How important is time expressed as a fraction of 1. Note that what this really optimises for is distance (even if that means going over terrible surfaces, so I might be slower than the safe route)." diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/TripPatternTimePenaltyType.java b/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/TripPatternTimePenaltyType.java index 2ad88762408..e8e4bcd43a0 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/TripPatternTimePenaltyType.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/TripPatternTimePenaltyType.java @@ -9,20 +9,18 @@ public class TripPatternTimePenaltyType { public static GraphQLObjectType create() { - return GraphQLObjectType - .newObject() + return GraphQLObjectType.newObject() .name("TimePenaltyWithCost") .description( """ The time-penalty is applied to either the access-legs and/or egress-legs. Both access and egress may contain more than one leg; Hence, the penalty is not a field on leg. - + Note! This is for debugging only. This type can change without notice. """ ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("appliedTo") .description( """ @@ -36,8 +34,7 @@ public static GraphQLObjectType create() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("timePenalty") .description( """ @@ -53,8 +50,7 @@ public static GraphQLObjectType create() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("generalizedCostDelta") .description( """ diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/TripPatternType.java b/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/TripPatternType.java index 42899beca55..8b8fb39e887 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/TripPatternType.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/TripPatternType.java @@ -19,15 +19,13 @@ public static GraphQLObjectType create( GraphQLObjectType timePenaltyType, GraphQLScalarType dateTimeScalar ) { - return GraphQLObjectType - .newObject() + return GraphQLObjectType.newObject() .name("TripPattern") .description( "List of legs constituting a suggested sequence of rides and links for a specific trip." ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("startTime") .description("Time that the trip departs.") .type(dateTimeScalar) @@ -36,8 +34,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("endTime") .description("Time that the trip arrives.") .type(dateTimeScalar) @@ -46,8 +43,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("aimedStartTime") .description("The aimed date and time the trip starts.") .type(new GraphQLNonNull(dateTimeScalar)) @@ -62,8 +58,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("expectedStartTime") .description("The expected, real-time adjusted date and time the trip starts.") .type(new GraphQLNonNull(dateTimeScalar)) @@ -71,8 +66,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("aimedEndTime") .description("The aimed date and time the trip ends.") .type(new GraphQLNonNull(dateTimeScalar)) @@ -87,8 +81,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("expectedEndTime") .description("The expected, real-time adjusted date and time the trip ends.") .type(new GraphQLNonNull(dateTimeScalar)) @@ -96,8 +89,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("duration") .description("Duration of the trip, in seconds.") .type(ExtendedScalars.GraphQLLong) @@ -105,8 +97,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("directDuration") .description("NOT IMPLEMENTED.") .type(ExtendedScalars.GraphQLLong) @@ -114,8 +105,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("waitingTime") .description("How much time is spent waiting for transit to arrive, in seconds.") .type(ExtendedScalars.GraphQLLong) @@ -123,8 +113,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("distance") .description("Total distance for the trip, in meters. NOT IMPLEMENTED") .type(Scalars.GraphQLFloat) @@ -132,8 +121,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("walkTime") .description("How much time is spent walking, in seconds.") .type(ExtendedScalars.GraphQLLong) @@ -141,8 +129,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("streetDistance") .description( "How far the user has to walk, bike and/or drive in meters. It includes " + @@ -153,8 +140,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("walkDistance") .deprecate("Replaced by `streetDistance`.") .type(Scalars.GraphQLFloat) @@ -162,8 +148,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("legs") .description( "A list of legs. Each leg is either a walking (cycling, car) " + @@ -176,8 +161,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("systemNotices") .description("Get all system notices.") .type(new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(systemNoticeType)))) @@ -185,8 +169,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("generalizedCost") .description("Generalized cost or weight of the itinerary. Used for debugging.") .type(Scalars.GraphQLInt) @@ -194,8 +177,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("generalizedCost2") .description( "A second cost or weight of the itinerary. Some use-cases like pass-through " + @@ -206,8 +188,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("waitTimeOptimizedCost") .description( "A cost calculated to distribute wait-time and avoid very " + @@ -218,8 +199,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("transferPriorityCost") .description( "A cost calculated to favor transfer with higher priority. This " + @@ -230,17 +210,16 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("timePenalty") .description( """ - A time and cost penalty applied to access and egress to favor regular scheduled - transit over potentially faster options with FLEX, Car, bike and scooter. - - Note! This field is meant for debugging only. The field can be removed without notice - in the future. - """ + A time and cost penalty applied to access and egress to favor regular scheduled + transit over potentially faster options with FLEX, Car, bike and scooter. + + Note! This field is meant for debugging only. The field can be removed without notice + in the future. + """ ) .type(new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(timePenaltyType)))) .dataFetcher(env -> TripPlanTimePenaltyDto.of(itinerary(env))) diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/TripPlanTimePenaltyDto.java b/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/TripPlanTimePenaltyDto.java index 0e83384157f..51c54482a25 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/TripPlanTimePenaltyDto.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/TripPlanTimePenaltyDto.java @@ -14,8 +14,10 @@ */ public record TripPlanTimePenaltyDto(String appliesTo, TimeAndCost penalty) { static List of(Itinerary itinerary) { - return Stream - .of(of("access", itinerary.getAccessPenalty()), of("egress", itinerary.getEgressPenalty())) + return Stream.of( + of("access", itinerary.getAccessPenalty()), + of("egress", itinerary.getEgressPenalty()) + ) .filter(Objects::nonNull) .toList(); } diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/TripQuery.java b/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/TripQuery.java index ac496131954..b6a4bfb0e0a 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/TripQuery.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/TripQuery.java @@ -46,8 +46,7 @@ public static GraphQLFieldDefinition create( ) { RoutingPreferences preferences = routing.request.preferences(); - return GraphQLFieldDefinition - .newFieldDefinition() + return GraphQLFieldDefinition.newFieldDefinition() .name("trip") .description( "Input type for executing a travel search for a trip between two locations. Returns " + @@ -56,8 +55,7 @@ public static GraphQLFieldDefinition create( .type(new GraphQLNonNull(tripType)) .withDirective(TransmodelDirectives.TIMING_DATA) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("dateTime") .description( "The date and time for the earliest time the user is willing to start the journey " + @@ -68,8 +66,7 @@ public static GraphQLFieldDefinition create( .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("bookingTime") .description( """ @@ -85,20 +82,19 @@ Normally this is when the search is performed (now), plus a small grace period t .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("searchWindow") .description( """ The length of the search-window in minutes. This parameter is optional. - + The search-window is defined as the duration between the earliest-departure-time(EDT) and the latest-departure-time(LDT). OTP will search for all itineraries in this departure window. If `arriveBy=true` the `dateTime` parameter is the latest-arrival-time, so OTP will dynamically calculate the EDT. Using a short search-window is faster than using a longer one, but the search duration is not linear. Using a \"too\" short search-window will waste resources server side, while using a search-window that is too long will be slow. - + OTP will dynamically calculate a reasonable value for the search-window, if not provided. The calculation comes with a significant overhead (10-20%% extra). Whether you should use the dynamic calculated value or pass in a value depends on your use-case. For a travel planner @@ -107,19 +103,19 @@ calculation comes with a significant overhead (10-20%% extra). Whether you shoul so that the number of itineraries on average is around the wanted `numTripPatterns`. Make sure you set the `numTripPatterns` to a high number while testing. For a country wide area like Norway, using the dynamic search-window is the best. - + When paginating, the search-window is calculated using the `numTripPatterns` in the original search together with statistics from the search for the last page. This behaviour is configured server side, and can not be overridden from the client. The paging may even exceed the maximum value. - + The search-window used is returned to the response metadata as `searchWindowUsed`. This can be used by the client to calculate the when the next page start/end. - + Note! In some cases you may have to page many times to get all the results you want. This is intended. Increasing the search-window beyond the max value is NOT going to be much faster. Instead the client can inform the user about the progress. - + Maximum value: %d minutes (%dh) """.formatted( transitTuningParameters.maxSearchWindow().toMinutes(), @@ -130,23 +126,21 @@ calculation comes with a significant overhead (10-20%% extra). Whether you shoul .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("pageCursor") .description( """ Use the cursor to go to the next \"page\" of itineraries. Copy the cursor from the last response and keep the original request as is. This will enable you to search for itineraries in the next or previous search-window. The paging will automatically scale - up/down the search-window to fit the `numTripPatterns`. + up/down the search-window to fit the `numTripPatterns`. """ ) .type(Scalars.GraphQLString) .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("timetableView") .description( "Search for the best trip options within a time window. If `true` two " + @@ -178,24 +172,21 @@ calculation comes with a significant overhead (10-20%% extra). Whether you shoul .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("from") .description("The start location") .type(new GraphQLNonNull(LocationInputType.INPUT_TYPE)) .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("to") .description("The destination location") .type(new GraphQLNonNull(LocationInputType.INPUT_TYPE)) .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("passThroughPoints") .deprecate("Use via instead") .description("The list of points the journey is required to pass through.") @@ -203,16 +194,14 @@ calculation comes with a significant overhead (10-20%% extra). Whether you shoul .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name(TRIP_VIA_PARAMETER) .description(DOC_VIA) .type(new GraphQLList(new GraphQLNonNull(ViaLocationInputType.VIA_LOCATION_INPUT))) .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("arriveBy") .description( "Whether the trip should depart at dateTime (false, the default), or arrive at " + @@ -223,8 +212,7 @@ calculation comes with a significant overhead (10-20%% extra). Whether you shoul .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("wheelchairAccessible") .description( "Whether the trip must be wheelchair accessible. Supported for the street part to " + @@ -235,8 +223,7 @@ calculation comes with a significant overhead (10-20%% extra). Whether you shoul .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("ignoreRealtimeUpdates") .description("When true, real-time updates are ignored during this search.") .type(Scalars.GraphQLBoolean) @@ -244,8 +231,7 @@ calculation comes with a significant overhead (10-20%% extra). Whether you shoul .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("includePlannedCancellations") .description( "When true, service journeys cancelled in scheduled route data will be included during this search." @@ -255,8 +241,7 @@ calculation comes with a significant overhead (10-20%% extra). Whether you shoul .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("includeRealtimeCancellations") .description( "When true, service journeys cancelled by real-time updates will be included during this search." @@ -266,8 +251,7 @@ calculation comes with a significant overhead (10-20%% extra). Whether you shoul .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("locale") .description( "The preferable language to use for text targeted the end user. Note! The data " + @@ -279,8 +263,7 @@ calculation comes with a significant overhead (10-20%% extra). Whether you shoul .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("modes") .description( "The set of access/egress/direct/transit modes to be used for this search. " + @@ -291,8 +274,7 @@ calculation comes with a significant overhead (10-20%% extra). Whether you shoul .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("banned") .description("Banned") .description( @@ -302,8 +284,7 @@ calculation comes with a significant overhead (10-20%% extra). Whether you shoul .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("whiteListed") .description( "Parameters for indicating the only authorities, lines or quays to be used in the trip patterns" @@ -312,8 +293,7 @@ calculation comes with a significant overhead (10-20%% extra). Whether you shoul .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("filters") .description( "A list of filters for which trips should be included. " + @@ -325,8 +305,7 @@ calculation comes with a significant overhead (10-20%% extra). Whether you shoul .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("relaxTransitGroupPriority") .description( """ @@ -334,15 +313,15 @@ calculation comes with a significant overhead (10-20%% extra). Whether you shoul transit-group-priorities. The groups are set server side for service-journey and can not be configured in the API. This mainly helps to return competition neutral services. Long distance authorities are put in different transit-groups. - + This relaxes the comparison inside the routing engine for each stop-arrival. If two paths have a different set of transit-group-priorities, then the generalized-cost comparison is relaxed. The final set of paths are filtered through the normal itinerary-filters. - + - The `ratio` must be greater or equal to 1.0 and less then 1.2. - The `constant` must be greater or equal to '0s' and less then '1h'. - + THIS IS STILL AN EXPERIMENTAL FEATURE - IT MAY CHANGE WITHOUT ANY NOTICE! """.stripIndent() ) @@ -355,8 +334,7 @@ calculation comes with a significant overhead (10-20%% extra). Whether you shoul .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("walkSpeed") .description("The maximum walk speed along streets, in meters per second.") .type(Scalars.GraphQLFloat) @@ -364,8 +342,7 @@ calculation comes with a significant overhead (10-20%% extra). Whether you shoul .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("walkReluctance") .description( "Walk cost is multiplied by this value. This is the main parameter to use for limiting walking." @@ -375,8 +352,7 @@ calculation comes with a significant overhead (10-20%% extra). Whether you shoul .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("waitReluctance") .description( "Wait cost is multiplied by this value. Setting this to a value lower than 1 " + @@ -389,8 +365,7 @@ calculation comes with a significant overhead (10-20%% extra). Whether you shoul .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("bikeSpeed") .description("The maximum bike speed along streets, in meters per second") .type(Scalars.GraphQLFloat) @@ -398,8 +373,7 @@ calculation comes with a significant overhead (10-20%% extra). Whether you shoul .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("bicycleOptimisationMethod") .description( "The set of characteristics that the user wants to optimise for during bicycle " + @@ -414,8 +388,7 @@ calculation comes with a significant overhead (10-20%% extra). Whether you shoul .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("triangleFactors") .description( "When setting the " + @@ -431,8 +404,7 @@ calculation comes with a significant overhead (10-20%% extra). Whether you shoul .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("useBikeRentalAvailabilityInformation") .description( "Whether or not bike rental availability information will be used to plan bike " + @@ -443,8 +415,7 @@ calculation comes with a significant overhead (10-20%% extra). Whether you shoul .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("transferPenalty") .description( "An extra penalty added on transfers (i.e. all boardings except the first one). " + @@ -464,8 +435,7 @@ calculation comes with a significant overhead (10-20%% extra). Whether you shoul .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("transferSlack") .description( "An expected transfer time (in seconds) that specifies the amount of time that " + @@ -477,8 +447,7 @@ calculation comes with a significant overhead (10-20%% extra). Whether you shoul .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("boardSlackDefault") .description(TransportModeSlack.boardSlackDescription("boardSlackList")) .type(Scalars.GraphQLInt) @@ -486,8 +455,7 @@ calculation comes with a significant overhead (10-20%% extra). Whether you shoul .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("boardSlackList") .description( TransportModeSlack.slackByGroupDescription( @@ -499,8 +467,7 @@ calculation comes with a significant overhead (10-20%% extra). Whether you shoul .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("alightSlackDefault") .description(TransportModeSlack.alightSlackDescription("alightSlackList")) .type(Scalars.GraphQLInt) @@ -508,8 +475,7 @@ calculation comes with a significant overhead (10-20%% extra). Whether you shoul .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("alightSlackList") .description( TransportModeSlack.slackByGroupDescription( @@ -521,8 +487,7 @@ calculation comes with a significant overhead (10-20%% extra). Whether you shoul .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("numTripPatterns") .description( "The maximum number of trip patterns to return. Note! This reduce the number of " + @@ -535,8 +500,7 @@ calculation comes with a significant overhead (10-20%% extra). Whether you shoul .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("maximumTransfers") .description( "Maximum number of transfers. Note! The best way to reduce the number of " + @@ -547,8 +511,7 @@ calculation comes with a significant overhead (10-20%% extra). Whether you shoul .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("maximumAdditionalTransfers") .description( "Maximum number of additional transfers compared to the best number of transfers " + @@ -560,8 +523,7 @@ calculation comes with a significant overhead (10-20%% extra). Whether you shoul .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("debugItineraryFilter") .description( "Debug the itinerary-filter-chain. OTP will attach a system notice to itineraries " + @@ -573,23 +535,22 @@ calculation comes with a significant overhead (10-20%% extra). Whether you shoul .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("relaxTransitSearchGeneralizedCostAtDestination") .deprecate("This is replaced by 'relaxTransitGroupPriority'.") .description( """ - Whether non-optimal transit paths at the destination should be returned. Let c be the - existing minimum pareto optimal generalized-cost to beat. Then a trip with cost c' is - accepted if the following is true: - - `c' < Math.round(c * relaxTransitSearchGeneralizedCostAtDestination)` - - The parameter is optional. If not set, a normal comparison is performed. - - Values less than 1.0 is not allowed, and values greater than 2.0 are not - supported, due to performance reasons. - """ + Whether non-optimal transit paths at the destination should be returned. Let c be the + existing minimum pareto optimal generalized-cost to beat. Then a trip with cost c' is + accepted if the following is true: + + `c' < Math.round(c * relaxTransitSearchGeneralizedCostAtDestination)` + + The parameter is optional. If not set, a normal comparison is performed. + + Values less than 1.0 is not allowed, and values greater than 2.0 are not + supported, due to performance reasons. + """ ) .type(Scalars.GraphQLFloat) .defaultValueProgrammatic( @@ -598,8 +559,7 @@ calculation comes with a significant overhead (10-20%% extra). Whether you shoul .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("itineraryFilters") .description( "Configure the itinerary-filter-chain. NOTE! THESE PARAMETERS ARE USED " + @@ -609,8 +569,7 @@ calculation comes with a significant overhead (10-20%% extra). Whether you shoul .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name(ACCESS_EGRESS_PENALTY) .description("Time and cost penalty on access/egress modes.") .type(new GraphQLList(new GraphQLNonNull(penaltyForStreetMode))) @@ -622,8 +581,7 @@ calculation comes with a significant overhead (10-20%% extra). Whether you shoul .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name(MAX_ACCESS_EGRESS_DURATION_FOR_MODE) .description( "Maximum duration for access/egress for street searches per respective mode. " + @@ -636,8 +594,7 @@ calculation comes with a significant overhead (10-20%% extra). Whether you shoul .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name(MAX_DIRECT_DURATION_FOR_MODE) .description( "Maximum duration for direct street searchers per respective mode. " + diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/TripType.java b/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/TripType.java index d214bed983f..e5940849082 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/TripType.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/TripType.java @@ -23,13 +23,11 @@ public static GraphQLObjectType create( GraphQLObjectType routingErrorType, GraphQLScalarType dateTimeScalar ) { - return GraphQLObjectType - .newObject() + return GraphQLObjectType.newObject() .name("Trip") .description("Description of a travel between two places.") .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("dateTime") .description("The time and date of travel") .type(dateTimeScalar) @@ -37,8 +35,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("metadata") .description("The trip request metadata.") .type(tripMetadataType) @@ -46,8 +43,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("fromPlace") .description("The origin") .type(new GraphQLNonNull(placeType)) @@ -55,8 +51,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("toPlace") .description("The destination") .type(new GraphQLNonNull(placeType)) @@ -64,8 +59,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("tripPatterns") .description("A list of possible trip patterns") .type(new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(tripPatternType)))) @@ -73,8 +67,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("messageEnums") .description("A list of possible error messages as enum") .deprecate("Use routingErrors instead") @@ -88,8 +81,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("messageStrings") .deprecate("Use routingErrors instead") .description("A list of possible error messages in cleartext") @@ -106,8 +98,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("routingErrors") .description("A list of routing errors, and fields which caused them") .type(new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(routingErrorType)))) @@ -115,18 +106,15 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("debugOutput") .description("Information about the timings for the trip generation") .type( new GraphQLNonNull( - GraphQLObjectType - .newObject() + GraphQLObjectType.newObject() .name("debugOutput") .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("totalTime") .type(ExtendedScalars.GraphQLLong) .build() @@ -138,8 +126,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("previousPageCursor") .description( "Use the cursor to get the previous page of results. Use this cursor for " + @@ -155,8 +142,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("nextPageCursor") .description( "Use the cursor to get the next page of results. Use this cursor for " + diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/ViaLocationInputType.java b/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/ViaLocationInputType.java index f7313a2bbf2..eb9c1481103 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/ViaLocationInputType.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/ViaLocationInputType.java @@ -68,56 +68,56 @@ be accepted. To visit a coordinate, the traveler must walk(bike or drive) to the """; private static final String DOC_COORDINATE = "A coordinate to route through."; - static final GraphQLInputObjectType VISIT_VIA_LOCATION_INPUT = GraphQLInputObjectType - .newInputObject() - .name(INPUT_VISIT_VIA_LOCATION) - .description(DOC_VISIT_VIA_LOCATION) - .field(b -> b.name(FIELD_LABEL).description(DOC_LABEL).type(GraphQLString)) - .field(b -> - b - .name(FIELD_MINIMUM_WAIT_TIME) - .description(DOC_MINIMUM_WAIT_TIME) - .type(TransmodelScalars.DURATION_SCALAR) - .defaultValueLiteral(StringValue.of(Duration.ZERO.toString())) - ) - .field(b -> - b - .name(FIELD_STOP_LOCATION_IDS) - .description(DOC_STOP_LOCATION_IDS) - .type(optionalListOfNonNullStrings()) - ) - .field(b -> - b.name(FIELD_COORDINATE).description(DOC_COORDINATE).type(CoordinateInputType.INPUT_TYPE) - ) - .build(); + static final GraphQLInputObjectType VISIT_VIA_LOCATION_INPUT = + GraphQLInputObjectType.newInputObject() + .name(INPUT_VISIT_VIA_LOCATION) + .description(DOC_VISIT_VIA_LOCATION) + .field(b -> b.name(FIELD_LABEL).description(DOC_LABEL).type(GraphQLString)) + .field(b -> + b + .name(FIELD_MINIMUM_WAIT_TIME) + .description(DOC_MINIMUM_WAIT_TIME) + .type(TransmodelScalars.DURATION_SCALAR) + .defaultValueLiteral(StringValue.of(Duration.ZERO.toString())) + ) + .field(b -> + b + .name(FIELD_STOP_LOCATION_IDS) + .description(DOC_STOP_LOCATION_IDS) + .type(optionalListOfNonNullStrings()) + ) + .field(b -> + b.name(FIELD_COORDINATE).description(DOC_COORDINATE).type(CoordinateInputType.INPUT_TYPE) + ) + .build(); - static final GraphQLInputObjectType PASS_THROUGH_VIA_LOCATION_INPUT = GraphQLInputObjectType - .newInputObject() - .name(INPUT_PASS_THROUGH_VIA_LOCATION) - .description(DOC_PASS_THROUGH_VIA_LOCATION) - .field(b -> b.name(FIELD_LABEL).description(DOC_LABEL).type(GraphQLString)) - .field(b -> - // This is NOT nonNull, because we might add other parameters later, like 'list of line-ids' - b - .name(FIELD_STOP_LOCATION_IDS) - .description(DOC_STOP_LOCATION_IDS) - .type(requiredListOfNonNullStrings()) - ) - .build(); + static final GraphQLInputObjectType PASS_THROUGH_VIA_LOCATION_INPUT = + GraphQLInputObjectType.newInputObject() + .name(INPUT_PASS_THROUGH_VIA_LOCATION) + .description(DOC_PASS_THROUGH_VIA_LOCATION) + .field(b -> b.name(FIELD_LABEL).description(DOC_LABEL).type(GraphQLString)) + .field(b -> + // This is NOT nonNull, because we might add other parameters later, like 'list of line-ids' + b + .name(FIELD_STOP_LOCATION_IDS) + .description(DOC_STOP_LOCATION_IDS) + .type(requiredListOfNonNullStrings()) + ) + .build(); - public static final GraphQLInputObjectType VIA_LOCATION_INPUT = GraphQLInputObjectType - .newInputObject() - .name(INPUT_VIA_LOCATION) - .description(DOC_VIA_LOCATION) - .withDirective(OneOfDirective) - .field(b -> b.name(FIELD_VISIT).description(DOC_FIELD_VISIT).type(VISIT_VIA_LOCATION_INPUT)) - .field(b -> - b - .name(FIELD_PASS_THROUGH) - .description(DOC_FIELD_PASS_THROUGH) - .type(PASS_THROUGH_VIA_LOCATION_INPUT) - ) - .build(); + public static final GraphQLInputObjectType VIA_LOCATION_INPUT = + GraphQLInputObjectType.newInputObject() + .name(INPUT_VIA_LOCATION) + .description(DOC_VIA_LOCATION) + .withDirective(OneOfDirective) + .field(b -> b.name(FIELD_VISIT).description(DOC_FIELD_VISIT).type(VISIT_VIA_LOCATION_INPUT)) + .field(b -> + b + .name(FIELD_PASS_THROUGH) + .description(DOC_FIELD_PASS_THROUGH) + .type(PASS_THROUGH_VIA_LOCATION_INPUT) + ) + .build(); private static GraphQLInputType requiredListOfNonNullStrings() { return new GraphQLNonNull(optionalListOfNonNullStrings()); diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/legacyvia/ViaLocationInputType.java b/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/legacyvia/ViaLocationInputType.java index 1f26d12e7f7..0ba4d74041e 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/legacyvia/ViaLocationInputType.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/legacyvia/ViaLocationInputType.java @@ -10,8 +10,7 @@ public class ViaLocationInputType { public static GraphQLInputObjectType create() { - return GraphQLInputObjectType - .newInputObject() + return GraphQLInputObjectType.newInputObject() .name("ViaLocationInput") .description( "Input format for specifying a location through either a place reference (id), " + @@ -21,8 +20,7 @@ public static GraphQLInputObjectType create() { "the via location." ) .field( - GraphQLInputObjectField - .newInputObjectField() + GraphQLInputObjectField.newInputObjectField() .name("name") .description( "The name of the location. This is pass-through information" + @@ -32,8 +30,7 @@ public static GraphQLInputObjectType create() { .build() ) .field( - GraphQLInputObjectField - .newInputObjectField() + GraphQLInputObjectField.newInputObjectField() .name("place") .description( "The id of an element in the OTP model. Currently supports" + @@ -43,8 +40,7 @@ public static GraphQLInputObjectType create() { .build() ) .field( - GraphQLInputObjectField - .newInputObjectField() + GraphQLInputObjectField.newInputObjectField() .name("coordinates") .description( "Coordinates for the location. This can be used alone or as" + @@ -54,8 +50,7 @@ public static GraphQLInputObjectType create() { .build() ) .field( - GraphQLInputObjectField - .newInputObjectField() + GraphQLInputObjectField.newInputObjectField() .name("minSlack") .defaultValue(ViaLocationDeprecated.DEFAULT_MIN_SLACK) .description( @@ -64,8 +59,7 @@ public static GraphQLInputObjectType create() { .type(TransmodelScalars.DURATION_SCALAR) ) .field( - GraphQLInputObjectField - .newInputObjectField() + GraphQLInputObjectField.newInputObjectField() .name("maxSlack") .defaultValue(ViaLocationDeprecated.DEFAULT_MAX_SLACK) .description( diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/legacyvia/ViaSegmentInputType.java b/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/legacyvia/ViaSegmentInputType.java index a2ada7487c3..1e00659143a 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/legacyvia/ViaSegmentInputType.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/legacyvia/ViaSegmentInputType.java @@ -10,16 +10,14 @@ public class ViaSegmentInputType { public static GraphQLInputObjectType create() { - final GraphQLInputObjectType streetModes = GraphQLInputObjectType - .newInputObject() + final GraphQLInputObjectType streetModes = GraphQLInputObjectType.newInputObject() .name("StreetModes") .description( "Input format for specifying which modes will be allowed for this search. " + "If this element is not present, it will default to all to foot." ) .field( - GraphQLInputObjectField - .newInputObjectField() + GraphQLInputObjectField.newInputObjectField() .name("accessMode") .description( "The mode used to get from the origin to the access stops in the transit " + @@ -30,8 +28,7 @@ public static GraphQLInputObjectType create() { .build() ) .field( - GraphQLInputObjectField - .newInputObjectField() + GraphQLInputObjectField.newInputObjectField() .name("egressMode") .description( "The mode used to get from the egress stops in the transit network to" + @@ -42,8 +39,7 @@ public static GraphQLInputObjectType create() { .build() ) .field( - GraphQLInputObjectField - .newInputObjectField() + GraphQLInputObjectField.newInputObjectField() .name("directMode") .description( "The mode used to get from the origin to the destination directly, " + @@ -55,20 +51,17 @@ public static GraphQLInputObjectType create() { ) .build(); - return GraphQLInputObjectType - .newInputObject() + return GraphQLInputObjectType.newInputObject() .name("ViaSegmentInput") .field( - GraphQLInputObjectField - .newInputObjectField() + GraphQLInputObjectField.newInputObjectField() .name("modes") .description("The set of access/egress/direct modes to be used for this search.") .type(streetModes) .build() ) .field( - GraphQLInputObjectField - .newInputObjectField() + GraphQLInputObjectField.newInputObjectField() .name("filters") .description( "A list of filters for which trips should be included. A trip will be included if it " + diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/legacyvia/ViaTripQuery.java b/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/legacyvia/ViaTripQuery.java index 745470c2220..0412b471466 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/legacyvia/ViaTripQuery.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/legacyvia/ViaTripQuery.java @@ -24,8 +24,7 @@ public static GraphQLFieldDefinition create( GraphQLInputObjectType viaSegmentInputType, GraphQLScalarType dateTimeScalar ) { - return GraphQLFieldDefinition - .newFieldDefinition() + return GraphQLFieldDefinition.newFieldDefinition() .name("viaTrip") .description( "Via trip search. Find trip patterns traveling via one or more intermediate (via) locations." @@ -34,8 +33,7 @@ public static GraphQLFieldDefinition create( .type(new GraphQLNonNull(viaTripType)) .withDirective(TransmodelDirectives.TIMING_DATA) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("dateTime") .description( "Date and time for the earliest time the user is willing to start the journey " + @@ -46,8 +44,7 @@ public static GraphQLFieldDefinition create( .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("searchWindow") .description( "The length of the search-window. This parameter is optional." + @@ -79,8 +76,7 @@ public static GraphQLFieldDefinition create( .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("pageCursor") .description( "Use the cursor to go to the next \"page\" of itineraries. Copy the cursor from " + @@ -91,31 +87,27 @@ public static GraphQLFieldDefinition create( .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("from") .description("The start location") .type(new GraphQLNonNull(LocationInputType.INPUT_TYPE)) .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("to") .description("The destination location") .type(new GraphQLNonNull(LocationInputType.INPUT_TYPE)) .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("via") .description("The locations needed to be visited along the route.") .type(new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(viaLocationInputType)))) ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("segments") .description( "The requests for the individual segments of the search. The first segment is from " + @@ -126,8 +118,7 @@ public static GraphQLFieldDefinition create( .type(new GraphQLList(new GraphQLNonNull(viaSegmentInputType))) ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("numTripPatterns") .description( "The maximum number of trip patterns segment to return. Note! This reduces the number " + @@ -140,8 +131,7 @@ public static GraphQLFieldDefinition create( .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("wheelchairAccessible") .description( "Whether the trip must be wheelchair accessible. Supported for the street part to " + @@ -152,8 +142,7 @@ public static GraphQLFieldDefinition create( .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("locale") .description( "The preferable language to use for text targeted the end user. Note! The data " + diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/legacyvia/ViaTripType.java b/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/legacyvia/ViaTripType.java index 740664c02f0..ab7d36892a1 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/legacyvia/ViaTripType.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/legacyvia/ViaTripType.java @@ -16,8 +16,7 @@ public static GraphQLOutputType create( GraphQLObjectType tripPatternType, GraphQLObjectType routingErrorType ) { - var viaTripPatternSegment = GraphQLObjectType - .newObject() + var viaTripPatternSegment = GraphQLObjectType.newObject() .name("ViaTripPatternSegment") .description( "A segment of the via search. The first segment is from the start location to the first " + @@ -25,8 +24,7 @@ public static GraphQLOutputType create( "to the end location." ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("tripPatterns") .description("A list of trip patterns for this segment of the search") .type(new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(tripPatternType)))) @@ -35,15 +33,13 @@ public static GraphQLOutputType create( ) .build(); - var viaTripPatternCombinations = GraphQLObjectType - .newObject() + var viaTripPatternCombinations = GraphQLObjectType.newObject() .name("ViaConnection") .description( "An acceptable combination of trip patterns between two segments of the via search" ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("from") .description("The index of the trip pattern in the segment before the via point") .type(Scalars.GraphQLInt) @@ -53,8 +49,7 @@ public static GraphQLOutputType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("to") .description("The index of the trip pattern in the segment after the via point") .type(Scalars.GraphQLInt) @@ -65,16 +60,14 @@ public static GraphQLOutputType create( ) .build(); - return GraphQLObjectType - .newObject() + return GraphQLObjectType.newObject() .name("ViaTrip") .description( "Description of a trip via one or more intermediate locations. " + "For example from A, via B, then C to D." ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("tripPatternsPerSegment") .description( "A list of segments of the via search. The first segment is from the start location " + @@ -86,8 +79,7 @@ public static GraphQLOutputType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("tripPatternCombinations") .description( "A list of the acceptable combinations of the trip patterns in this segment and the " + @@ -104,8 +96,7 @@ public static GraphQLOutputType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("routingErrors") .description("A list of routing errors, and fields which caused them") .type(new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(routingErrorType)))) diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/model/scalars/DateTimeScalarFactory.java b/application/src/main/java/org/opentripplanner/apis/transmodel/model/scalars/DateTimeScalarFactory.java index 19681987199..017d56a6eb4 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/model/scalars/DateTimeScalarFactory.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/model/scalars/DateTimeScalarFactory.java @@ -18,11 +18,11 @@ public final class DateTimeScalarFactory { private static final String DOCUMENTATION = """ - DateTime format accepting ISO 8601 dates with time zone offset. + DateTime format accepting ISO 8601 dates with time zone offset. - Format: `YYYY-MM-DD'T'hh:mm[:ss](Z|±01:00)` + Format: `YYYY-MM-DD'T'hh:mm[:ss](Z|±01:00)` - Example: `2017-04-23T18:25:43+02:00` or `2017-04-23T16:25:43Z`"""; + Example: `2017-04-23T18:25:43+02:00` or `2017-04-23T16:25:43Z`"""; private static final DateTimeFormatter PARSER = OffsetDateTimeParser.LENIENT_PARSER; @@ -33,8 +33,7 @@ private DateTimeScalarFactory() {} public static GraphQLScalarType createMillisecondsSinceEpochAsDateTimeStringScalar( ZoneId timeZone ) { - return GraphQLScalarType - .newScalar() + return GraphQLScalarType.newScalar() .name("DateTime") .description(DOCUMENTATION) .coercing( diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/model/scalars/DoubleFunctionFactory.java b/application/src/main/java/org/opentripplanner/apis/transmodel/model/scalars/DoubleFunctionFactory.java index 5259c0dd9db..1e1b3c7b84a 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/model/scalars/DoubleFunctionFactory.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/model/scalars/DoubleFunctionFactory.java @@ -22,7 +22,7 @@ public class DoubleFunctionFactory { be the duration/time or cost for a leg or section of a path/itinerary. The function `f(t) = a + bt` has a constant(a) and a coefficient(b) that will be used in OTP to compute `f(t)`. - + Format: `a + b t`. Example: `30m + 2.0 t`. The constant `a` accept both whole numbers and duration input format like: `60` = `60s` = `1m` and `3791` = `1h3m11s`. `b` must be a positive decimal number between `0.0` and `100.0`. @@ -31,8 +31,7 @@ public class DoubleFunctionFactory { private DoubleFunctionFactory() {} public static GraphQLScalarType createDoubleFunctionScalar() { - return GraphQLScalarType - .newScalar() + return GraphQLScalarType.newScalar() .name(TYPENAME) .description(DOCUMENTATION) .coercing( diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/model/scalars/GeoJSONCoordinatesScalar.java b/application/src/main/java/org/opentripplanner/apis/transmodel/model/scalars/GeoJSONCoordinatesScalar.java index 2cb44433d50..64a18b33ce8 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/model/scalars/GeoJSONCoordinatesScalar.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/model/scalars/GeoJSONCoordinatesScalar.java @@ -27,8 +27,7 @@ public class GeoJSONCoordinatesScalar { private static final String DOCUMENTATION = "List of coordinates like: [[60.89, 11.12], [62.56, 12.10]]"; - private static final GraphQLScalarType INSTANCE = GraphQLScalarType - .newScalar() + private static final GraphQLScalarType INSTANCE = GraphQLScalarType.newScalar() .name("Coordinates") .description(DOCUMENTATION) .coercing( @@ -57,11 +56,10 @@ public Coordinate[] parseValue(Object input) { Coordinate[] coordinates = new Coordinate[coordinateList.size()]; for (int i = 0; i < coordinateList.size(); i++) { - coordinates[i] = - new Coordinate( - coordinateList.get(i).get(0).doubleValue(), - coordinateList.get(i).get(1).doubleValue() - ); + coordinates[i] = new Coordinate( + coordinateList.get(i).get(0).doubleValue(), + coordinateList.get(i).get(1).doubleValue() + ); } return coordinates; @@ -78,11 +76,10 @@ public Object parseLiteral(Object input) { FloatValue longitude = (FloatValue) v.getValues().get(0); FloatValue latitude = (FloatValue) v.getValues().get(1); - coordinates[i] = - new Coordinate( - longitude.getValue().doubleValue(), - latitude.getValue().doubleValue() - ); + coordinates[i] = new Coordinate( + longitude.getValue().doubleValue(), + latitude.getValue().doubleValue() + ); } return coordinates; } diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/model/scalars/LocalTimeScalarFactory.java b/application/src/main/java/org/opentripplanner/apis/transmodel/model/scalars/LocalTimeScalarFactory.java index 1dbf2dce8e8..85060f34b8f 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/model/scalars/LocalTimeScalarFactory.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/model/scalars/LocalTimeScalarFactory.java @@ -19,8 +19,7 @@ public class LocalTimeScalarFactory { private LocalTimeScalarFactory() {} public static GraphQLScalarType createLocalTimeScalar() { - return GraphQLScalarType - .newScalar() + return GraphQLScalarType.newScalar() .name("LocalTime") .description(DATE_SCALAR_DESCRIPTION) .coercing( diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/model/scalars/TimeScalarFactory.java b/application/src/main/java/org/opentripplanner/apis/transmodel/model/scalars/TimeScalarFactory.java index 318ceea034f..0ddb2dbd9c1 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/model/scalars/TimeScalarFactory.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/model/scalars/TimeScalarFactory.java @@ -23,13 +23,12 @@ public final class TimeScalarFactory { private TimeScalarFactory() {} public static GraphQLObjectType createSecondsSinceMidnightAsTimeObject() { - GraphQLScalarType secondsSinceMidnightAsTimeStringScalar = TimeScalarFactory.createSecondsSinceMidnightAsTimeStringScalar(); - return GraphQLObjectType - .newObject() + GraphQLScalarType secondsSinceMidnightAsTimeStringScalar = + TimeScalarFactory.createSecondsSinceMidnightAsTimeStringScalar(); + return GraphQLObjectType.newObject() .name("TimeAndDayOffset") .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("time") .description("Local time") .type(secondsSinceMidnightAsTimeStringScalar) @@ -37,8 +36,7 @@ public static GraphQLObjectType createSecondsSinceMidnightAsTimeObject() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("dayOffset") .description("Number of days offset from base line time") .type(Scalars.GraphQLInt) @@ -49,8 +47,7 @@ public static GraphQLObjectType createSecondsSinceMidnightAsTimeObject() { } public static GraphQLScalarType createSecondsSinceMidnightAsTimeStringScalar() { - return GraphQLScalarType - .newScalar() + return GraphQLScalarType.newScalar() .name("Time") .description(DOCUMENTATION) .coercing( diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/model/siri/et/EstimatedCallType.java b/application/src/main/java/org/opentripplanner/apis/transmodel/model/siri/et/EstimatedCallType.java index 593782af9d8..70c0af73087 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/model/siri/et/EstimatedCallType.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/model/siri/et/EstimatedCallType.java @@ -46,38 +46,33 @@ public static GraphQLObjectType create( GraphQLOutputType datedServiceJourneyType, GraphQLScalarType dateTimeScalar ) { - return GraphQLObjectType - .newObject() + return GraphQLObjectType.newObject() .name("EstimatedCall") .description( "List of visits to quays as part of vehicle journeys. Updated with real time information where available" ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("quay") .type(new GraphQLNonNull(quayType)) .dataFetcher(environment -> ((TripTimeOnDate) environment.getSource()).getStop()) .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("aimedArrivalTime") .description("Scheduled time of arrival at quay. Not affected by read time updated") .type(new GraphQLNonNull(dateTimeScalar)) - .dataFetcher(environment -> - 1000 * - ( - ((TripTimeOnDate) environment.getSource()).getServiceDayMidnight() + - ((TripTimeOnDate) environment.getSource()).getScheduledArrival() - ) + .dataFetcher( + environment -> + 1000 * + (((TripTimeOnDate) environment.getSource()).getServiceDayMidnight() + + ((TripTimeOnDate) environment.getSource()).getScheduledArrival()) ) .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("expectedArrivalTime") .type(new GraphQLNonNull(dateTimeScalar)) .description( @@ -92,8 +87,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("actualArrivalTime") .type(dateTimeScalar) .description( @@ -111,23 +105,20 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("aimedDepartureTime") .description("Scheduled time of departure from quay. Not affected by read time updated") .type(new GraphQLNonNull(dateTimeScalar)) - .dataFetcher(environment -> - 1000 * - ( - ((TripTimeOnDate) environment.getSource()).getServiceDayMidnight() + - ((TripTimeOnDate) environment.getSource()).getScheduledDeparture() - ) + .dataFetcher( + environment -> + 1000 * + (((TripTimeOnDate) environment.getSource()).getServiceDayMidnight() + + ((TripTimeOnDate) environment.getSource()).getScheduledDeparture()) ) .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("expectedDepartureTime") .type(new GraphQLNonNull(dateTimeScalar)) .description( @@ -143,8 +134,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("actualDepartureTime") .type(dateTimeScalar) .description( @@ -162,8 +152,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("timingPoint") .type(new GraphQLNonNull(Scalars.GraphQLBoolean)) .description( @@ -173,8 +162,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("realtime") .type(new GraphQLNonNull(Scalars.GraphQLBoolean)) .description("Whether this call has been updated with real time information.") @@ -182,8 +170,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("predictionInaccurate") .type(new GraphQLNonNull(Scalars.GraphQLBoolean)) .description("Whether the updated estimates are expected to be inaccurate.") @@ -193,16 +180,14 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("realtimeState") .type(new GraphQLNonNull(EnumTypes.REALTIME_STATE)) .dataFetcher(environment -> ((TripTimeOnDate) environment.getSource()).getRealTimeState()) .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("occupancyStatus") .type(new GraphQLNonNull(EnumTypes.OCCUPANCY_STATUS)) .dataFetcher(environment -> @@ -213,16 +198,14 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("stopPositionInPattern") .type(new GraphQLNonNull(Scalars.GraphQLInt)) .dataFetcher(environment -> ((TripTimeOnDate) environment.getSource()).getStopIndex()) .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("forBoarding") .type(new GraphQLNonNull(Scalars.GraphQLBoolean)) .description("Whether vehicle may be boarded at quay.") @@ -232,8 +215,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("forAlighting") .type(new GraphQLNonNull(Scalars.GraphQLBoolean)) .description("Whether vehicle may be alighted at quay.") @@ -243,19 +225,18 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("requestStop") .type(new GraphQLNonNull(Scalars.GraphQLBoolean)) .description("Whether vehicle will only stop on request.") - .dataFetcher(environment -> - ((TripTimeOnDate) environment.getSource()).getDropoffType() == COORDINATE_WITH_DRIVER + .dataFetcher( + environment -> + ((TripTimeOnDate) environment.getSource()).getDropoffType() == COORDINATE_WITH_DRIVER ) .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("cancellation") .type(new GraphQLNonNull(Scalars.GraphQLBoolean)) .description( @@ -271,8 +252,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("date") .type(new GraphQLNonNull(TransmodelScalars.DATE_SCALAR)) .description("The date the estimated call is valid for.") @@ -280,54 +260,47 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("serviceJourney") .type(new GraphQLNonNull(serviceJourneyType)) .dataFetcher(environment -> ((TripTimeOnDate) environment.getSource()).getTrip()) .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("datedServiceJourney") .type(datedServiceJourneyType) .dataFetcher(environment -> - GqlUtil - .getTransitService(environment) - .getTripOnServiceDate( - new TripIdAndServiceDate( - environment.getSource().getTrip().getId(), - environment.getSource().getServiceDay() - ) + GqlUtil.getTransitService(environment).getTripOnServiceDate( + new TripIdAndServiceDate( + environment.getSource().getTrip().getId(), + environment.getSource().getServiceDay() ) + ) ) .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("destinationDisplay") .type(destinationDisplayType) .dataFetcher(DataFetchingEnvironment::getSource) .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("notices") .type(new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(noticeType)))) .dataFetcher(environment -> { TripTimeOnDate tripTimeOnDate = environment.getSource(); - return GqlUtil - .getTransitService(environment) - .findNotices(tripTimeOnDate.getStopTimeKey()); + return GqlUtil.getTransitService(environment).findNotices( + tripTimeOnDate.getStopTimeKey() + ); }) .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("situations") .withDirective(TransmodelDirectives.TIMING_DATA) .type(new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(ptSituationElementType)))) @@ -338,8 +311,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("bookingArrangements") .description("Booking arrangements for this EstimatedCall.") .type(bookingArrangementType) @@ -430,9 +402,11 @@ private static void filterSituationsByDateAndStopConditions( ) { if (alertPatches != null) { // First and last period - alertPatches.removeIf(alert -> - (alert.getEffectiveStartDate() != null && alert.getEffectiveStartDate().isAfter(toTime)) || - (alert.getEffectiveEndDate() != null && alert.getEffectiveEndDate().isBefore(fromTime)) + alertPatches.removeIf( + alert -> + (alert.getEffectiveStartDate() != null && + alert.getEffectiveStartDate().isAfter(toTime)) || + (alert.getEffectiveEndDate() != null && alert.getEffectiveEndDate().isBefore(fromTime)) ); // Handle repeating validityPeriods diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/model/siri/sx/AffectsType.java b/application/src/main/java/org/opentripplanner/apis/transmodel/model/siri/sx/AffectsType.java index e8cbec6ade0..909e0faa2ac 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/model/siri/sx/AffectsType.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/model/siri/sx/AffectsType.java @@ -26,12 +26,10 @@ public static GraphQLOutputType create( GraphQLOutputType serviceJourneyType, GraphQLOutputType datedServiceJourneyType ) { - GraphQLObjectType affectedStopPlace = GraphQLObjectType - .newObject() + GraphQLObjectType affectedStopPlace = GraphQLObjectType.newObject() .name("AffectedStopPlace") .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("quay") .type(quayType) .dataFetcher(environment -> { @@ -41,8 +39,7 @@ public static GraphQLOutputType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("stopPlace") .type(stopPlaceType) .dataFetcher(environment -> { @@ -52,8 +49,7 @@ public static GraphQLOutputType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("stopConditions") .type( new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(EnumTypes.STOP_CONDITION_ENUM))) @@ -62,12 +58,10 @@ public static GraphQLOutputType create( ) .build(); - GraphQLObjectType affectedLine = GraphQLObjectType - .newObject() + GraphQLObjectType affectedLine = GraphQLObjectType.newObject() .name("AffectedLine") .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("line") .type(lineType) .dataFetcher(environment -> { @@ -78,12 +72,10 @@ public static GraphQLOutputType create( ) .build(); - GraphQLObjectType affectedServiceJourney = GraphQLObjectType - .newObject() + GraphQLObjectType affectedServiceJourney = GraphQLObjectType.newObject() .name("AffectedServiceJourney") .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("serviceJourney") .type(serviceJourneyType) .dataFetcher(environment -> { @@ -93,36 +85,30 @@ public static GraphQLOutputType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("operatingDay") .type(TransmodelScalars.DATE_SCALAR) .dataFetcher(environment -> environment.getSource().serviceDate()) .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("datedServiceJourney") .type(datedServiceJourneyType) .dataFetcher(environment -> { EntitySelector.Trip entitySelector = environment.getSource(); - return GqlUtil - .getTransitService(environment) - .getTripOnServiceDate( - new TripIdAndServiceDate(entitySelector.tripId(), entitySelector.serviceDate()) - ); + return GqlUtil.getTransitService(environment).getTripOnServiceDate( + new TripIdAndServiceDate(entitySelector.tripId(), entitySelector.serviceDate()) + ); }) .build() ) .build(); - GraphQLObjectType affectedStopPlaceOnLine = GraphQLObjectType - .newObject() + GraphQLObjectType affectedStopPlaceOnLine = GraphQLObjectType.newObject() .name("AffectedStopPlaceOnLine") .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("quay") .type(quayType) .dataFetcher(environment -> { @@ -132,8 +118,7 @@ public static GraphQLOutputType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("stopPlace") .type(stopPlaceType) .dataFetcher(environment -> { @@ -143,8 +128,7 @@ public static GraphQLOutputType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("line") .type(lineType) .dataFetcher(environment -> { @@ -154,8 +138,7 @@ public static GraphQLOutputType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("stopConditions") .type( new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(EnumTypes.STOP_CONDITION_ENUM))) @@ -164,12 +147,10 @@ public static GraphQLOutputType create( ) .build(); - GraphQLObjectType affectedStopPlaceOnServiceJourney = GraphQLObjectType - .newObject() + GraphQLObjectType affectedStopPlaceOnServiceJourney = GraphQLObjectType.newObject() .name("AffectedStopPlaceOnServiceJourney") .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("quay") .type(quayType) .dataFetcher(environment -> { @@ -179,8 +160,7 @@ public static GraphQLOutputType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("stopPlace") .type(stopPlaceType) .dataFetcher(environment -> { @@ -190,8 +170,7 @@ public static GraphQLOutputType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("serviceJourney") .type(serviceJourneyType) .dataFetcher(environment -> { @@ -201,8 +180,7 @@ public static GraphQLOutputType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("operatingDay") .type(TransmodelScalars.DATE_SCALAR) .dataFetcher(environment -> @@ -211,23 +189,19 @@ public static GraphQLOutputType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("datedServiceJourney") .type(datedServiceJourneyType) .dataFetcher(environment -> { EntitySelector.StopAndTrip entitySelector = environment.getSource(); - return GqlUtil - .getTransitService(environment) - .getTripOnServiceDate( - new TripIdAndServiceDate(entitySelector.tripId(), entitySelector.serviceDate()) - ); + return GqlUtil.getTransitService(environment).getTripOnServiceDate( + new TripIdAndServiceDate(entitySelector.tripId(), entitySelector.serviceDate()) + ); }) .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("stopConditions") .type( new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(EnumTypes.STOP_CONDITION_ENUM))) @@ -236,12 +210,10 @@ public static GraphQLOutputType create( ) .build(); - GraphQLObjectType affectedUnknown = GraphQLObjectType - .newObject() + GraphQLObjectType affectedUnknown = GraphQLObjectType.newObject() .name("AffectedUnknown") .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("description") .type(Scalars.GraphQLString) .dataFetcher(environment -> { @@ -258,8 +230,7 @@ public static GraphQLOutputType create( ) .build(); - return GraphQLUnionType - .newUnionType() + return GraphQLUnionType.newUnionType() .name(NAME) .possibleType(affectedStopPlace) .possibleType(affectedLine) diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/model/siri/sx/PtSituationElementType.java b/application/src/main/java/org/opentripplanner/apis/transmodel/model/siri/sx/PtSituationElementType.java index 4d8e4ed6390..4712b7edc81 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/model/siri/sx/PtSituationElementType.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/model/siri/sx/PtSituationElementType.java @@ -45,13 +45,11 @@ public static GraphQLObjectType create( GraphQLScalarType dateTimeScalar, Relay relay ) { - return GraphQLObjectType - .newObject() + return GraphQLObjectType.newObject() .name(NAME) .description("Simple public transport situation element") .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("id") .type(new GraphQLNonNull(Scalars.GraphQLID)) .dataFetcher(environment -> @@ -60,30 +58,26 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("authority") .type(authorityType) .description("Get affected authority for this situation element") .deprecate("Use affects instead") .dataFetcher(environment -> - GqlUtil - .getTransitService(environment) - .getAgency( - ((TransitAlert) environment.getSource()).entities() - .stream() - .filter(EntitySelector.Agency.class::isInstance) - .map(EntitySelector.Agency.class::cast) - .findAny() - .map(EntitySelector.Agency::agencyId) - .orElse(null) - ) + GqlUtil.getTransitService(environment).getAgency( + ((TransitAlert) environment.getSource()).entities() + .stream() + .filter(EntitySelector.Agency.class::isInstance) + .map(EntitySelector.Agency.class::cast) + .findAny() + .map(EntitySelector.Agency::agencyId) + .orElse(null) + ) ) .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("lines") .type(new GraphQLNonNull(new GraphQLList(lineType))) .deprecate("Use affects instead") @@ -100,8 +94,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("serviceJourneys") .type(new GraphQLNonNull(new GraphQLList(serviceJourneyType))) .deprecate("Use affects instead") @@ -118,8 +111,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("quays") .type(new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(quayType)))) .deprecate("Use affects instead") @@ -137,8 +129,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("stopPlaces") .type(new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(stopPlaceType)))) .deprecate("Use affects instead") @@ -159,8 +150,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("affects") .description("Get all affected entities for the situation") .type(new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(affectsType)))) @@ -168,8 +158,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("summary") .type(new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(multilingualStringType)))) .description("Summary of situation in all different translations available") @@ -189,8 +178,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("description") .type(new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(multilingualStringType)))) .description("Description of situation in all different translations available") @@ -210,8 +198,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("advice") .type(new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(multilingualStringType)))) .description("Advice of situation in all different translations available") @@ -228,8 +215,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("infoLinks") .type(new GraphQLList(new GraphQLNonNull(infoLinkType))) .description("Optional links to more information.") @@ -243,8 +229,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("validityPeriod") .type(validityPeriodType) .description("Period this situation is in effect") @@ -261,8 +246,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("reportType") .type(EnumTypes.REPORT_TYPE) .description("ReportType of this situation") @@ -270,8 +254,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("situationNumber") .type(Scalars.GraphQLString) .description("Operator's internal id for this situation") @@ -279,8 +262,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("severity") .type(EnumTypes.SEVERITY) .description("Severity of this situation ") @@ -290,8 +272,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("priority") .type(Scalars.GraphQLInt) .description("Priority of this situation ") @@ -299,8 +280,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("creationTime") .type(dateTimeScalar) .description("Timestamp for when the situation was created.") @@ -311,8 +291,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("versionedAtTime") .type(dateTimeScalar) .description("Timestamp when the situation element was updated.") @@ -323,8 +302,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("version") .type(Scalars.GraphQLInt) .description("Operator's version number for the situation element.") @@ -332,8 +310,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("participant") .type(Scalars.GraphQLString) .description("Codespace of the data source.") @@ -341,8 +318,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("reportAuthority") .type(authorityType) .description( @@ -356,8 +332,7 @@ public static GraphQLObjectType create( if (codespace == null) { return null; } - return GqlUtil - .getTransitService(environment) + return GqlUtil.getTransitService(environment) .listAgencies() .stream() .filter(agency -> agency.getId().getFeedId().equals(feedId)) diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/model/stop/BikeParkType.java b/application/src/main/java/org/opentripplanner/apis/transmodel/model/stop/BikeParkType.java index 8a9c965f4a2..c5d9f9aaf3c 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/model/stop/BikeParkType.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/model/stop/BikeParkType.java @@ -13,13 +13,11 @@ public class BikeParkType { public static final String NAME = "BikePark"; public static GraphQLObjectType createB(GraphQLInterfaceType placeInterface) { - return GraphQLObjectType - .newObject() + return GraphQLObjectType.newObject() .name(NAME) .withInterface(placeInterface) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("id") .type(new GraphQLNonNull(Scalars.GraphQLID)) .dataFetcher(environment -> @@ -28,8 +26,7 @@ public static GraphQLObjectType createB(GraphQLInterfaceType placeInterface) { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("name") .type(new GraphQLNonNull(Scalars.GraphQLString)) .dataFetcher(environment -> @@ -38,8 +35,7 @@ public static GraphQLObjectType createB(GraphQLInterfaceType placeInterface) { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("spacesAvailable") .type(Scalars.GraphQLInt) .dataFetcher(environment -> { @@ -54,16 +50,14 @@ public static GraphQLObjectType createB(GraphQLInterfaceType placeInterface) { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("realtime") .type(Scalars.GraphQLBoolean) .dataFetcher(environment -> ((VehicleParking) environment.getSource()).hasRealTimeData()) .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("longitude") .type(Scalars.GraphQLFloat) .dataFetcher(environment -> @@ -72,8 +66,7 @@ public static GraphQLObjectType createB(GraphQLInterfaceType placeInterface) { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("latitude") .type(Scalars.GraphQLFloat) .dataFetcher(environment -> diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/model/stop/BikeRentalStationType.java b/application/src/main/java/org/opentripplanner/apis/transmodel/model/stop/BikeRentalStationType.java index 3f2988a95d7..47434a41585 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/model/stop/BikeRentalStationType.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/model/stop/BikeRentalStationType.java @@ -14,13 +14,11 @@ public class BikeRentalStationType { public static final String NAME = "BikeRentalStation"; public static GraphQLObjectType create(GraphQLInterfaceType placeInterface) { - return GraphQLObjectType - .newObject() + return GraphQLObjectType.newObject() .name(NAME) .withInterface(placeInterface) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("id") .type(new GraphQLNonNull(Scalars.GraphQLID)) .dataFetcher(environment -> @@ -29,8 +27,7 @@ public static GraphQLObjectType create(GraphQLInterfaceType placeInterface) { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("name") .type(new GraphQLNonNull(Scalars.GraphQLString)) .dataFetcher(environment -> @@ -44,8 +41,7 @@ public static GraphQLObjectType create(GraphQLInterfaceType placeInterface) { // .dataFetcher(environment -> ((VehicleRentalPlace) environment.getSource()).description) // .build()) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("bikesAvailable") .type(Scalars.GraphQLInt) .dataFetcher(environment -> @@ -54,8 +50,7 @@ public static GraphQLObjectType create(GraphQLInterfaceType placeInterface) { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("spacesAvailable") .type(Scalars.GraphQLInt) .dataFetcher(environment -> @@ -64,8 +59,7 @@ public static GraphQLObjectType create(GraphQLInterfaceType placeInterface) { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("realtimeOccupancyAvailable") .type(Scalars.GraphQLBoolean) .dataFetcher(environment -> @@ -74,8 +68,7 @@ public static GraphQLObjectType create(GraphQLInterfaceType placeInterface) { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("allowDropoff") .type(Scalars.GraphQLBoolean) .dataFetcher(environment -> @@ -84,8 +77,7 @@ public static GraphQLObjectType create(GraphQLInterfaceType placeInterface) { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("networks") .type(new GraphQLNonNull(new GraphQLList(Scalars.GraphQLString))) .dataFetcher(environment -> @@ -94,8 +86,7 @@ public static GraphQLObjectType create(GraphQLInterfaceType placeInterface) { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("longitude") .type(Scalars.GraphQLFloat) .dataFetcher(environment -> @@ -104,8 +95,7 @@ public static GraphQLObjectType create(GraphQLInterfaceType placeInterface) { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("latitude") .type(Scalars.GraphQLFloat) .dataFetcher(environment -> ((VehicleRentalStation) environment.getSource()).getLatitude() diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/model/stop/PlaceAtDistanceType.java b/application/src/main/java/org/opentripplanner/apis/transmodel/model/stop/PlaceAtDistanceType.java index 882c1491bb7..dfe8aaaf46b 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/model/stop/PlaceAtDistanceType.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/model/stop/PlaceAtDistanceType.java @@ -26,12 +26,10 @@ public class PlaceAtDistanceType { public static final String NAME = "PlaceAtDistance"; public static GraphQLObjectType create(Relay relay, GraphQLInterfaceType placeInterface) { - return GraphQLObjectType - .newObject() + return GraphQLObjectType.newObject() .name(NAME) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("id") .type(new GraphQLNonNull(Scalars.GraphQLID)) .deprecate("Id is not referable or meaningful and will be removed") @@ -39,16 +37,14 @@ public static GraphQLObjectType create(Relay relay, GraphQLInterfaceType placeIn .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("place") .type(placeInterface) .dataFetcher(environment -> ((PlaceAtDistance) environment.getSource()).place()) .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("distance") .type(Scalars.GraphQLFloat) .dataFetcher(environment -> ((PlaceAtDistance) environment.getSource()).distance()) @@ -93,11 +89,10 @@ public static List convertQuaysToStopPlaces( if (placeTypes != null && !placeTypes.contains(TransmodelPlaceType.QUAY)) { // Remove quays if only stop places are requested - places = - places - .stream() - .filter(p -> !(p.place() instanceof RegularStop)) - .collect(Collectors.toList()); + places = places + .stream() + .filter(p -> !(p.place() instanceof RegularStop)) + .collect(Collectors.toList()); } } places.sort(Comparator.comparing(PlaceAtDistance::distance)); diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/model/stop/PlaceInterfaceType.java b/application/src/main/java/org/opentripplanner/apis/transmodel/model/stop/PlaceInterfaceType.java index f05113f9f74..0ff66c27dd8 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/model/stop/PlaceInterfaceType.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/model/stop/PlaceInterfaceType.java @@ -13,27 +13,23 @@ public class PlaceInterfaceType { public static GraphQLInterfaceType create() { - return GraphQLInterfaceType - .newInterface() + return GraphQLInterfaceType.newInterface() .name("PlaceInterface") .description("Interface for places, i.e. quays, stop places, parks") .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("id") .type(new GraphQLNonNull(Scalars.GraphQLID)) .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("latitude") .type(Scalars.GraphQLFloat) .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("longitude") .type(Scalars.GraphQLFloat) .build() diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/model/stop/QuayAtDistanceType.java b/application/src/main/java/org/opentripplanner/apis/transmodel/model/stop/QuayAtDistanceType.java index 51f62141e33..2236d936fb8 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/model/stop/QuayAtDistanceType.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/model/stop/QuayAtDistanceType.java @@ -13,12 +13,10 @@ public class QuayAtDistanceType { public static GraphQLObjectType createQD(GraphQLOutputType quayType, Relay relay) { - return GraphQLObjectType - .newObject() + return GraphQLObjectType.newObject() .name("QuayAtDistance") .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("id") .type(new GraphQLNonNull(Scalars.GraphQLID)) .dataFetcher(environment -> @@ -34,16 +32,14 @@ public static GraphQLObjectType createQD(GraphQLOutputType quayType, Relay relay .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("quay") .type(quayType) .dataFetcher(environment -> ((NearbyStop) environment.getSource()).stop) .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("distance") .type(Scalars.GraphQLFloat) .description("The distance in meters to the given quay.") diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/model/stop/QuayType.java b/application/src/main/java/org/opentripplanner/apis/transmodel/model/stop/QuayType.java index bea8f5de6bf..3b474811f88 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/model/stop/QuayType.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/model/stop/QuayType.java @@ -48,8 +48,7 @@ public static GraphQLObjectType create( GraphQLOutputType tariffZoneType, GraphQLScalarType dateTimeScalar ) { - return GraphQLObjectType - .newObject() + return GraphQLObjectType.newObject() .name(NAME) .description( "A place such as platform, stance, or quayside where passengers have access to PT vehicles." @@ -57,13 +56,11 @@ public static GraphQLObjectType create( .withInterface(placeInterface) .field(GqlUtil.newTransitIdField()) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("name") .type(new GraphQLNonNull(Scalars.GraphQLString)) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("lang") .deprecate("Use 'language' instead") .description( @@ -73,8 +70,7 @@ public static GraphQLObjectType create( .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("language") .description( "Fetch the name in the language given. The language should be represented as a ISO-639 language code. If the translation does not exits, the default name is returned." @@ -88,24 +84,21 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("latitude") .type(Scalars.GraphQLFloat) .dataFetcher(env -> (((StopLocation) env.getSource()).getLat())) .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("longitude") .type(Scalars.GraphQLFloat) .dataFetcher(env -> (((StopLocation) env.getSource()).getLon())) .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("description") .type(Scalars.GraphQLString) .dataFetcher(env -> @@ -114,8 +107,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("stopPlace") .description("The stop place to which this quay belongs to.") .type(stopPlaceType) @@ -133,8 +125,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("wheelchairAccessible") .type(EnumTypes.WHEELCHAIR_BOARDING) .description("Whether this quay is suitable for wheelchair boarding.") @@ -147,8 +138,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("timeZone") .type(Scalars.GraphQLString) .dataFetcher(env -> @@ -157,8 +147,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("publicCode") .type(Scalars.GraphQLString) .description( @@ -168,15 +157,13 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("lines") .withDirective(TransmodelDirectives.TIMING_DATA) .description("List of lines servicing this quay") .type(new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(lineType)))) .dataFetcher(env -> - GqlUtil - .getTransitService(env) + GqlUtil.getTransitService(env) .findPatterns(env.getSource(), true) .stream() .map(TripPattern::getRoute) @@ -186,8 +173,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("journeyPatterns") .withDirective(TransmodelDirectives.TIMING_DATA) .description("List of journey patterns servicing this quay") @@ -196,15 +182,13 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("estimatedCalls") .withDirective(TransmodelDirectives.TIMING_DATA) .description("List of visits to this quay as part of vehicle journeys.") .type(new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(estimatedCallType)))) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("startTime") .type(dateTimeScalar) .description( @@ -213,8 +197,7 @@ public static GraphQLObjectType create( .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("timeRange") .description( "Duration in seconds from start time to search forward for estimated calls. Must be a positive value. Default value is 24 hours" @@ -224,8 +207,7 @@ public static GraphQLObjectType create( .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("numberOfDepartures") .description("Limit the total number of departures returned.") .type(Scalars.GraphQLInt) @@ -233,8 +215,7 @@ public static GraphQLObjectType create( .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("numberOfDeparturesPerLineAndDestinationDisplay") .description( "Limit the number of departures per line and destination display returned. The parameter is only applied " + @@ -244,8 +225,7 @@ public static GraphQLObjectType create( .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("omitNonBoarding") .type(Scalars.GraphQLBoolean) .deprecate("Non-functional. Use arrivalDeparture instead.") @@ -253,8 +233,7 @@ public static GraphQLObjectType create( .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("arrivalDeparture") .type(EnumTypes.ARRIVAL_DEPARTURE) .description( @@ -270,8 +249,7 @@ public static GraphQLObjectType create( .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("whiteListed") .description("Whitelisted") .description( @@ -281,16 +259,14 @@ public static GraphQLObjectType create( .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("whiteListedModes") .description("Only show estimated calls for selected modes.") .type(GraphQLList.list(EnumTypes.TRANSPORT_MODE)) .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("includeCancelledTrips") .description("Indicates that real-time-cancelled trips should also be included.") .type(Scalars.GraphQLBoolean) @@ -316,20 +292,19 @@ public static GraphQLObjectType create( ? Instant.ofEpochMilli(startTimeInput) : Instant.now(); - return StopPlaceType - .getTripTimesForStop( - stop, - startTime, - timeRange, - arrivalDeparture, - includeCancelledTrips, - numberOfDepartures, - departuresPerLineAndDestinationDisplay, - whiteListed.authorityIds, - whiteListed.lineIds, - transitModes, - environment - ) + return StopPlaceType.getTripTimesForStop( + stop, + startTime, + timeRange, + arrivalDeparture, + includeCancelledTrips, + numberOfDepartures, + departuresPerLineAndDestinationDisplay, + whiteListed.authorityIds, + whiteListed.lineIds, + transitModes, + environment + ) .sorted(TripTimeOnDate.compareByDeparture()) .distinct() .limit(numberOfDepartures) @@ -338,22 +313,19 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("situations") .description("Get all situations active for the quay.") .type(new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(ptSituationElementType)))) .dataFetcher(env -> - GqlUtil - .getTransitService(env) + GqlUtil.getTransitService(env) .getTransitAlertService() .getStopAlerts(((StopLocation) env.getSource()).getId()) ) .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("stopType") .type(Scalars.GraphQLString) .dataFetcher(env -> @@ -362,8 +334,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("flexibleArea") .description("Geometry for flexible area.") .type(GeoJSONCoordinatesScalar.getGraphQGeoJSONCoordinatesScalar()) @@ -377,8 +348,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("flexibleGroup") .description("the Quays part of a flexible group.") .type(GraphQLList.list(REF)) @@ -386,8 +356,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("tariffZones") .type(new GraphQLNonNull(new GraphQLList(tariffZoneType))) .dataFetcher(env -> ((StopLocation) env.getSource()).getFareZones()) diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/model/stop/RentalVehicleType.java b/application/src/main/java/org/opentripplanner/apis/transmodel/model/stop/RentalVehicleType.java index a142873cd97..3e5fba1b677 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/model/stop/RentalVehicleType.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/model/stop/RentalVehicleType.java @@ -16,13 +16,11 @@ public static GraphQLObjectType create( GraphQLOutputType vehicleTypeType, GraphQLInterfaceType placeInterface ) { - return GraphQLObjectType - .newObject() + return GraphQLObjectType.newObject() .name(NAME) .withInterface(placeInterface) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("id") .type(new GraphQLNonNull(Scalars.GraphQLID)) .dataFetcher(environment -> @@ -31,24 +29,21 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("vehicleType") .type(new GraphQLNonNull(vehicleTypeType)) .dataFetcher(environment -> ((VehicleRentalVehicle) environment.getSource()).vehicleType) .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("network") .type(new GraphQLNonNull(Scalars.GraphQLString)) .dataFetcher(environment -> ((VehicleRentalVehicle) environment.getSource()).getNetwork()) .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("longitude") .type(new GraphQLNonNull(Scalars.GraphQLFloat)) .dataFetcher(environment -> @@ -57,8 +52,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("latitude") .type(new GraphQLNonNull(Scalars.GraphQLFloat)) .dataFetcher(environment -> ((VehicleRentalVehicle) environment.getSource()).getLatitude() @@ -66,8 +60,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("currentRangeMeters") .type(Scalars.GraphQLFloat) .dataFetcher(environment -> diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/model/stop/StopPlaceType.java b/application/src/main/java/org/opentripplanner/apis/transmodel/model/stop/StopPlaceType.java index 9b8fd25c68a..8ce019d6077 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/model/stop/StopPlaceType.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/model/stop/StopPlaceType.java @@ -60,16 +60,14 @@ public static GraphQLObjectType create( GraphQLOutputType ptSituationElementType, GraphQLScalarType dateTimeScalar ) { - return GraphQLObjectType - .newObject() + return GraphQLObjectType.newObject() .name(NAME) .description( "Named place where public transport may be accessed. May be a building complex (e.g. a station) or an on-street location." ) .withInterface(placeInterface) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("id") .type(new GraphQLNonNull(Scalars.GraphQLID)) .dataFetcher(env -> @@ -78,13 +76,11 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("name") .type(new GraphQLNonNull(Scalars.GraphQLString)) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("lang") .deprecate("Use 'language' instead") .description( @@ -94,8 +90,7 @@ public static GraphQLObjectType create( .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("language") .description( "Fetch the name in the language given. The language should be represented as a ISO-639 language code. If the translation does not exist, the default name is returned." @@ -104,16 +99,13 @@ public static GraphQLObjectType create( .build() ) .dataFetcher(environment -> - ( - ((MonoOrMultiModalStation) environment.getSource()).getName() - .toString(GqlUtil.getLocale(environment)) - ) + (((MonoOrMultiModalStation) environment.getSource()).getName() + .toString(GqlUtil.getLocale(environment))) ) .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("latitude") .type(Scalars.GraphQLFloat) .dataFetcher(environment -> (((MonoOrMultiModalStation) environment.getSource()).getLat()) @@ -121,8 +113,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("longitude") .type(Scalars.GraphQLFloat) .dataFetcher(environment -> (((MonoOrMultiModalStation) environment.getSource()).getLon()) @@ -130,8 +121,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("description") .type(Scalars.GraphQLString) .dataFetcher(environment -> @@ -143,8 +133,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("weighting") .description( "Relative weighting of this stop with regards to interchanges. NOT IMPLEMENTED" @@ -155,8 +144,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("stopInterchangePriority") .description("Specify the priority of interchanges at this stop") .type(EnumTypes.STOP_INTERCHANGE_PRIORITY) @@ -166,8 +154,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("tariffZones") .type(new GraphQLNonNull(new GraphQLList(tariffZoneType))) .description("NOT IMPLEMENTED") @@ -175,8 +162,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("transportMode") .description("The transport modes of quays under this stop place.") .type(new GraphQLList(EnumTypes.TRANSPORT_MODE)) @@ -190,8 +176,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("transportSubmode") .description("The transport submode serviced by this stop place.") .type(new GraphQLList(EnumTypes.TRANSPORT_SUBMODE)) @@ -214,27 +199,24 @@ public static GraphQLObjectType create( // TODO stopPlaceType? .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("timeZone") .type(Scalars.GraphQLString) .dataFetcher(environment -> - Optional - .ofNullable(((MonoOrMultiModalStation) environment.getSource()).getTimezone()) - .map(ZoneId::getId) + Optional.ofNullable( + ((MonoOrMultiModalStation) environment.getSource()).getTimezone() + ).map(ZoneId::getId) ) .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("quays") .withDirective(TransmodelDirectives.TIMING_DATA) .description("Returns all quays that are children of this stop place") .type(new GraphQLList(quayType)) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("filterByInUse") .description("If true only quays with at least one visiting line are included.") .type(Scalars.GraphQLBoolean) @@ -244,24 +226,19 @@ public static GraphQLObjectType create( .dataFetcher(environment -> { var quays = ((MonoOrMultiModalStation) environment.getSource()).getChildStops(); if (TRUE.equals(environment.getArgument("filterByInUse"))) { - quays = - quays - .stream() - .filter(stop -> { - return !GqlUtil - .getTransitService(environment) - .findPatterns(stop, true) - .isEmpty(); - }) - .collect(Collectors.toList()); + quays = quays + .stream() + .filter(stop -> { + return !GqlUtil.getTransitService(environment).findPatterns(stop, true).isEmpty(); + }) + .collect(Collectors.toList()); } return quays; }) .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("parent") .description("Returns parent stop for this stop") .type(new GraphQLTypeReference(NAME)) @@ -271,8 +248,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("tariffZones") .type(new GraphQLNonNull(new GraphQLList(tariffZoneType))) .dataFetcher(environment -> @@ -284,15 +260,13 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("estimatedCalls") .withDirective(TransmodelDirectives.TIMING_DATA) .description("List of visits to this stop place as part of vehicle journeys.") .type(new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(estimatedCallType)))) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("startTime") .type(dateTimeScalar) .description( @@ -301,8 +275,7 @@ public static GraphQLObjectType create( .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("timeRange") .description( "Duration in seconds from start time to search forward for estimated calls. Must be a positive value. Default value is 24 hours" @@ -312,8 +285,7 @@ public static GraphQLObjectType create( .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("numberOfDepartures") .description("Limit the total number of departures returned.") .type(Scalars.GraphQLInt) @@ -321,8 +293,7 @@ public static GraphQLObjectType create( .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("numberOfDeparturesPerLineAndDestinationDisplay") .description( "Limit the number of departures per line and destination display returned. The parameter is only applied " + @@ -332,16 +303,14 @@ public static GraphQLObjectType create( .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("arrivalDeparture") .type(EnumTypes.ARRIVAL_DEPARTURE) .defaultValue(ArrivalDeparture.DEPARTURES) .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("whiteListed") .description("Whitelisted") .description( @@ -351,16 +320,14 @@ public static GraphQLObjectType create( .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("whiteListedModes") .description("Only show estimated calls for selected modes.") .type(GraphQLList.list(EnumTypes.TRANSPORT_MODE)) .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("includeCancelledTrips") .description("Indicates that real-time-cancelled trips should also be included.") .type(Scalars.GraphQLBoolean) @@ -416,16 +383,14 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("situations") .description( "Get all situations active for the stop place. Situations affecting individual quays are not returned, and should be fetched directly from the quay." ) .type(new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(ptSituationElementType)))) .dataFetcher(env -> - GqlUtil - .getTransitService(env) + GqlUtil.getTransitService(env) .getTransitAlertService() .getStopAlerts(((MonoOrMultiModalStation) env.getSource()).getId()) ) @@ -466,12 +431,11 @@ public static Stream getTripTimesForStop( Stream tripTimesStream = stopTimesStream.flatMap(p -> p.times.stream()); - tripTimesStream = - JourneyWhiteListed.whiteListAuthoritiesAndOrLines( - tripTimesStream, - authorityIdsWhiteListed, - lineIdsWhiteListed - ); + tripTimesStream = JourneyWhiteListed.whiteListAuthoritiesAndOrLines( + tripTimesStream, + authorityIdsWhiteListed, + lineIdsWhiteListed + ); return limitPerLineAndDestinationDisplay( tripTimesStream, diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/model/stop/TariffZoneType.java b/application/src/main/java/org/opentripplanner/apis/transmodel/model/stop/TariffZoneType.java index c3953c7b88d..deb9c99851e 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/model/stop/TariffZoneType.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/model/stop/TariffZoneType.java @@ -11,13 +11,11 @@ public class TariffZoneType { private static final String NAME = "TariffZone"; public static GraphQLObjectType createTZ() { - return GraphQLObjectType - .newObject() + return GraphQLObjectType.newObject() .name(NAME) .field(GqlUtil.newTransitIdField()) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("name") .type(Scalars.GraphQLString) .dataFetcher(environment -> ((FareZone) environment.getSource()).getName()) diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/model/timetable/BookingArrangementType.java b/application/src/main/java/org/opentripplanner/apis/transmodel/model/timetable/BookingArrangementType.java index 097fa92baca..824d4848216 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/model/timetable/BookingArrangementType.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/model/timetable/BookingArrangementType.java @@ -16,12 +16,10 @@ public class BookingArrangementType { public static GraphQLObjectType create() { - GraphQLOutputType contactType = GraphQLObjectType - .newObject() + GraphQLOutputType contactType = GraphQLObjectType.newObject() .name("Contact") .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("contactPerson") .description("Name of person to contact") .type(Scalars.GraphQLString) // @@ -29,8 +27,7 @@ public static GraphQLObjectType create() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("email") .description("Email adress for contact") .type(Scalars.GraphQLString) // @@ -38,8 +35,7 @@ public static GraphQLObjectType create() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("url") .description("Url for contact") .type(Scalars.GraphQLString) // @@ -47,8 +43,7 @@ public static GraphQLObjectType create() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("phone") .description("Phone number for contact") .type(Scalars.GraphQLString) // @@ -56,8 +51,7 @@ public static GraphQLObjectType create() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("furtherDetails") .description("Textual description of how to get in contact") .type(Scalars.GraphQLString) // @@ -66,12 +60,10 @@ public static GraphQLObjectType create() { ) .build(); - return GraphQLObjectType - .newObject() + return GraphQLObjectType.newObject() .name("BookingArrangement") .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("bookingMethods") .description("How should service be booked?") .type(new GraphQLList(EnumTypes.BOOKING_METHOD)) @@ -79,8 +71,7 @@ public static GraphQLObjectType create() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("latestBookingTime") .description("Latest time the service can be booked. ISO 8601 timestamp") .type(TransmodelScalars.LOCAL_TIME_SCALAR) @@ -91,8 +82,7 @@ public static GraphQLObjectType create() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("latestBookingDay") .description("How many days prior to the travel the service needs to be booked") .type(Scalars.GraphQLInt) @@ -103,8 +93,7 @@ public static GraphQLObjectType create() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("bookWhen") .description("Time constraints for booking") .type(EnumTypes.PURCHASE_WHEN) @@ -112,8 +101,7 @@ public static GraphQLObjectType create() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("minimumBookingPeriod") .description("Minimum period in advance service can be booked as a ISO 8601 duration") .type(Scalars.GraphQLString) @@ -121,8 +109,7 @@ public static GraphQLObjectType create() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("bookingNote") .description("Textual description of booking arrangement for service") .type(Scalars.GraphQLString) @@ -130,8 +117,7 @@ public static GraphQLObjectType create() { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("bookingContact") .description("Who should ticket be contacted for booking") .type(contactType) diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/model/timetable/DatedServiceJourneyQuery.java b/application/src/main/java/org/opentripplanner/apis/transmodel/model/timetable/DatedServiceJourneyQuery.java index 2d381140b73..d79f37a2150 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/model/timetable/DatedServiceJourneyQuery.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/model/timetable/DatedServiceJourneyQuery.java @@ -26,8 +26,7 @@ public class DatedServiceJourneyQuery { public static GraphQLFieldDefinition createGetById(GraphQLOutputType datedServiceJourneyType) { - return GraphQLFieldDefinition - .newFieldDefinition() + return GraphQLFieldDefinition.newFieldDefinition() .name("datedServiceJourney") .type(datedServiceJourneyType) .description("Get a single dated service journey based on its id") @@ -41,52 +40,44 @@ public static GraphQLFieldDefinition createGetById(GraphQLOutputType datedServic } public static GraphQLFieldDefinition createQuery(GraphQLOutputType datedServiceJourneyType) { - return GraphQLFieldDefinition - .newFieldDefinition() + return GraphQLFieldDefinition.newFieldDefinition() .name("datedServiceJourneys") .type(new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(datedServiceJourneyType)))) .description("Get all dated service journeys, matching the filters") .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("lines") .type(new GraphQLList(new GraphQLNonNull(Scalars.GraphQLString))) ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("serviceJourneys") .type(new GraphQLList(new GraphQLNonNull(Scalars.GraphQLString))) ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("privateCodes") .type(new GraphQLList(new GraphQLNonNull(Scalars.GraphQLString))) ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("operatingDays") .type( new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(TransmodelScalars.DATE_SCALAR))) ) ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("alterations") .type(new GraphQLList(new GraphQLNonNull(EnumTypes.SERVICE_ALTERATION))) ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("authorities") .type(new GraphQLList(new GraphQLNonNull(Scalars.GraphQLString))) ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("replacementFor") .description( "Get all DatedServiceJourneys, which are replacing any of the given DatedServiceJourneys ids" @@ -126,22 +117,23 @@ public static GraphQLFieldDefinition createQuery(GraphQLOutputType datedServiceJ environment.>getArgument("alterations") ); - TripOnServiceDateRequestBuilder tripOnServiceDateRequestBuilder = TripOnServiceDateRequest - .of(operatingDays) - .withAgencies(authorities) - .withRoutes(lines) - .withServiceJourneys(serviceJourneys) - .withReplacementFor(replacementFor); + TripOnServiceDateRequestBuilder tripOnServiceDateRequestBuilder = + TripOnServiceDateRequest.of(operatingDays) + .withAgencies(authorities) + .withRoutes(lines) + .withServiceJourneys(serviceJourneys) + .withReplacementFor(replacementFor); tripOnServiceDateRequestBuilder = tripOnServiceDateRequestBuilder.withNetexInternalPlanningCodes(privateCodes); - tripOnServiceDateRequestBuilder = - tripOnServiceDateRequestBuilder.withAlterations(alterations); + tripOnServiceDateRequestBuilder = tripOnServiceDateRequestBuilder.withAlterations( + alterations + ); - return GqlUtil - .getTransitService(environment) - .findTripsOnServiceDate(tripOnServiceDateRequestBuilder.build()); + return GqlUtil.getTransitService(environment).findTripsOnServiceDate( + tripOnServiceDateRequestBuilder.build() + ); }) .build(); } diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/model/timetable/DatedServiceJourneyType.java b/application/src/main/java/org/opentripplanner/apis/transmodel/model/timetable/DatedServiceJourneyType.java index 2210c006f00..a09a0a8a205 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/model/timetable/DatedServiceJourneyType.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/model/timetable/DatedServiceJourneyType.java @@ -36,53 +36,46 @@ public static GraphQLObjectType create( GraphQLType estimatedCallType, GraphQLType quayType ) { - return GraphQLObjectType - .newObject() + return GraphQLObjectType.newObject() .name(NAME) .description("A planned journey on a specific day") .field(GqlUtil.newTransitIdField()) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("operatingDay") .description( "The date this service runs. The date used is based on the service date as opposed to calendar date." ) .type(TransmodelScalars.DATE_SCALAR) .dataFetcher(environment -> - Optional - .of(tripOnServiceDate(environment)) + Optional.of(tripOnServiceDate(environment)) .map(TripOnServiceDate::getServiceDate) .orElse(null) ) ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("serviceJourney") .description("The service journey this Dated Service Journey is based on") .type(new GraphQLNonNull(serviceJourneyType)) .dataFetcher(environment -> (tripOnServiceDate(environment).getTrip())) ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("tripAlteration") .description("Alterations specified on the Trip in the planned data") .type(EnumTypes.SERVICE_ALTERATION) .dataFetcher(environment -> tripOnServiceDate(environment).getTripAlteration()) ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("replacementFor") .description("List of the dated service journeys this dated service journeys replaces") .type(new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(REF)))) .dataFetcher(environment -> tripOnServiceDate(environment).getReplacementFor()) ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("journeyPattern") .description("JourneyPattern for the dated service journey.") .type(journeyPatternType) @@ -90,22 +83,19 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("quays") .description("Quays visited by the dated service journey.") .type(new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(quayType)))) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("first") .description("Only fetch the first n quays on the service journey") .type(Scalars.GraphQLInt) .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("last") .description("Only fetch the last n quays on the service journey") .type(Scalars.GraphQLInt) @@ -140,8 +130,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("estimatedCalls") .type(new GraphQLList(estimatedCallType)) .withDirective(TransmodelDirectives.TIMING_DATA) @@ -151,8 +140,7 @@ public static GraphQLObjectType create( ) .dataFetcher(environment -> { TripOnServiceDate tripOnServiceDate = tripOnServiceDate(environment); - return GqlUtil - .getTransitService(environment) + return GqlUtil.getTransitService(environment) .getTripTimeOnDates(tripOnServiceDate.getTrip(), tripOnServiceDate.getServiceDate()) .orElse(null); }) diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/model/timetable/InterchangeType.java b/application/src/main/java/org/opentripplanner/apis/transmodel/model/timetable/InterchangeType.java index 35d32c51522..ffff08d789b 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/model/timetable/InterchangeType.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/model/timetable/InterchangeType.java @@ -19,28 +19,24 @@ public static GraphQLObjectType create( GraphQLOutputType lineType, GraphQLOutputType serviceJourneyType ) { - return GraphQLObjectType - .newObject() + return GraphQLObjectType.newObject() .name("Interchange") .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("staySeated") .type(Scalars.GraphQLBoolean) .dataFetcher(env -> constraint(env).isStaySeated()) .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("guaranteed") .type(Scalars.GraphQLBoolean) .dataFetcher(env -> constraint(env).isGuaranteed()) .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("priority") .description( "The transfer priority is used to decide where a transfer should " + @@ -53,8 +49,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("maximumWaitTime") .description( "Maximum time after scheduled departure time the connecting " + @@ -66,8 +61,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("FromLine") .deprecate("This is the same as using the `fromServiceJourney { line }` field.") .type(lineType) @@ -75,8 +69,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("ToLine") .deprecate("This is the same as using the `toServiceJourney { line }` field.") .type(lineType) @@ -84,24 +77,21 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("fromServiceJourney") .type(serviceJourneyType) .dataFetcher(env -> transferTrip(env, ConstrainedTransfer::getFrom)) .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("toServiceJourney") .type(serviceJourneyType) .dataFetcher(env -> transferTrip(env, ConstrainedTransfer::getTo)) .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("FromServiceJourney") .type(serviceJourneyType) .deprecate("Use fromServiceJourney instead") @@ -109,8 +99,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("ToServiceJourney") .type(serviceJourneyType) .deprecate("Use toServiceJourney instead") diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/model/timetable/ServiceJourneyType.java b/application/src/main/java/org/opentripplanner/apis/transmodel/model/timetable/ServiceJourneyType.java index 1fb65be1520..526204461b8 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/model/timetable/ServiceJourneyType.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/model/timetable/ServiceJourneyType.java @@ -43,28 +43,24 @@ public static GraphQLObjectType create( GraphQLOutputType estimatedCallType, GraphQLOutputType timetabledPassingTimeType ) { - return GraphQLObjectType - .newObject() + return GraphQLObjectType.newObject() .name(NAME) .description("A planned vehicle journey with passengers.") .field(GqlUtil.newTransitIdField()) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("line") .type(new GraphQLNonNull(lineType)) .dataFetcher(environment -> (trip(environment)).getRoute()) .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("activeDates") .withDirective(TransmodelDirectives.TIMING_DATA) .type(new GraphQLNonNull(new GraphQLList(TransmodelScalars.DATE_SCALAR))) .dataFetcher(environment -> - GqlUtil - .getTransitService(environment) + GqlUtil.getTransitService(environment) .getCalendarService() .getServiceDatesForServiceId(((trip(environment)).getServiceId())) .stream() @@ -74,16 +70,14 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("transportMode") .type(EnumTypes.TRANSPORT_MODE) .dataFetcher(environment -> ((trip(environment)).getMode())) .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("transportSubmode") .type(EnumTypes.TRANSPORT_SUBMODE) .dataFetcher(environment -> @@ -92,8 +86,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("publicCode") .type(Scalars.GraphQLString) .description( @@ -103,8 +96,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("privateCode") .type(Scalars.GraphQLString) .description("For internal use by operators.") @@ -112,24 +104,21 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("operator") .type(operatorType) .dataFetcher(environment -> ((trip(environment)).getOperator())) .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("directionType") .type(EnumTypes.DIRECTION_TYPE) .dataFetcher(environment -> trip(environment).getDirection()) .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("serviceAlteration") .deprecate( "The service journey alteration will be moved out of SJ and grouped " + @@ -141,8 +130,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("wheelchairAccessible") .type(EnumTypes.WHEELCHAIR_BOARDING) .dataFetcher(environment -> trip(environment).getWheelchairBoarding()) @@ -150,16 +138,14 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("bikesAllowed") .type(EnumTypes.BIKES_ALLOWED) .description("Whether bikes are allowed on service journey.") .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("journeyPattern") .description( "JourneyPattern for the service journey, according to scheduled data. If the " + @@ -170,8 +156,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("quays") .description( "Quays visited by service journey, according to scheduled data. If the " + @@ -179,16 +164,14 @@ public static GraphQLObjectType create( ) .type(new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(quayType)))) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("first") .description("Only fetch the first n quays on the service journey") .type(Scalars.GraphQLInt) .build() ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("last") .description("Only fetch the last n quays on the service journey") .type(Scalars.GraphQLInt) @@ -225,8 +208,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("passingTimes") .type(new GraphQLNonNull(new GraphQLList(timetabledPassingTimeType))) .withDirective(TransmodelDirectives.TIMING_DATA) @@ -237,8 +219,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("estimatedCalls") .type(new GraphQLList(estimatedCallType)) .withDirective(TransmodelDirectives.TIMING_DATA) @@ -248,37 +229,33 @@ public static GraphQLObjectType create( "known when creating the request. For fetching estimatedCalls for a given trip.leg, use leg.serviceJourneyEstimatedCalls instead." ) .argument( - GraphQLArgument - .newArgument() + GraphQLArgument.newArgument() .name("date") .type(TransmodelScalars.DATE_SCALAR) .description("Date to get estimated calls for. Defaults to today.") .build() ) .dataFetcher(environment -> { - var serviceDate = Optional - .ofNullable(environment.getArgument("date")) + var serviceDate = Optional.ofNullable(environment.getArgument("date")) .map(LocalDate.class::cast) .orElse(LocalDate.now(GqlUtil.getTransitService(environment).getTimeZone())); - return GqlUtil - .getTransitService(environment) + return GqlUtil.getTransitService(environment) .getTripTimeOnDates(trip(environment), serviceDate) .orElse(null); }) .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("pointsOnLink") .type(linkGeometryType) .description( "Detailed path travelled by service journey. Not available for flexible trips." ) .dataFetcher(environment -> { - TripPattern tripPattern = GqlUtil - .getTransitService(environment) - .findPattern(trip(environment)); + TripPattern tripPattern = GqlUtil.getTransitService(environment).findPattern( + trip(environment) + ); if (tripPattern == null) { return null; } @@ -293,30 +270,26 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("notices") .type(new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(noticeType)))) .dataFetcher(env -> GqlUtil.getTransitService(env).findNotices(trip(env))) .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("situations") .description("Get all situations active for the service journey.") .type(new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(ptSituationElementType)))) .dataFetcher(environment -> - GqlUtil - .getTransitService(environment) + GqlUtil.getTransitService(environment) .getTransitAlertService() .getTripAlerts(trip(environment).getId(), null) ) .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("bookingArrangements") .description("Booking arrangements for flexible services.") .type(bookingArrangementType) diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/model/timetable/TimetabledPassingTimeType.java b/application/src/main/java/org/opentripplanner/apis/transmodel/model/timetable/TimetabledPassingTimeType.java index d7b59790f8e..b5beebf4634 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/model/timetable/TimetabledPassingTimeType.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/model/timetable/TimetabledPassingTimeType.java @@ -28,21 +28,18 @@ public static GraphQLObjectType create( GraphQLOutputType destinationDisplayType, GraphQLOutputType serviceJourneyType ) { - return GraphQLObjectType - .newObject() + return GraphQLObjectType.newObject() .name(NAME) .description("Scheduled passing times. These are not affected by real time updates.") .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("quay") .type(new GraphQLNonNull(quayType)) .dataFetcher(environment -> ((TripTimeOnDate) environment.getSource()).getStop()) .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("arrival") .type(TransmodelScalars.TIME_SCALAR) .description("Scheduled time of arrival at quay") @@ -52,8 +49,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("departure") .type(TransmodelScalars.TIME_SCALAR) .description("Scheduled time of departure from quay") @@ -63,8 +59,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("timingPoint") .type(new GraphQLNonNull(Scalars.GraphQLBoolean)) .description( @@ -74,42 +69,41 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("forBoarding") .type(new GraphQLNonNull(Scalars.GraphQLBoolean)) .description("Whether vehicle may be boarded at quay.") - .dataFetcher(environment -> - ((TripTimeOnDate) environment.getSource()).getPickupType() != PickDrop.NONE + .dataFetcher( + environment -> + ((TripTimeOnDate) environment.getSource()).getPickupType() != PickDrop.NONE ) .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("forAlighting") .type(new GraphQLNonNull(Scalars.GraphQLBoolean)) .description("Whether vehicle may be alighted at quay.") - .dataFetcher(environment -> - ((TripTimeOnDate) environment.getSource()).getDropoffType() != PickDrop.NONE + .dataFetcher( + environment -> + ((TripTimeOnDate) environment.getSource()).getDropoffType() != PickDrop.NONE ) .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("requestStop") .type(new GraphQLNonNull(Scalars.GraphQLBoolean)) .description("Whether vehicle will only stop on request.") - .dataFetcher(environment -> - ((TripTimeOnDate) environment.getSource()).getDropoffType() == - PickDrop.COORDINATE_WITH_DRIVER + .dataFetcher( + environment -> + ((TripTimeOnDate) environment.getSource()).getDropoffType() == + PickDrop.COORDINATE_WITH_DRIVER ) .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("earliestDepartureTime") .type(TransmodelScalars.TIME_SCALAR) .description( @@ -128,8 +122,7 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("latestArrivalTime") .type(TransmodelScalars.TIME_SCALAR) .description( @@ -146,37 +139,33 @@ public static GraphQLObjectType create( .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("serviceJourney") .type(new GraphQLNonNull(serviceJourneyType)) .dataFetcher(environment -> ((TripTimeOnDate) environment.getSource()).getTrip()) .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("destinationDisplay") .type(destinationDisplayType) .dataFetcher(DataFetchingEnvironment::getSource) .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("notices") .type(new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(noticeType)))) .dataFetcher(environment -> { TripTimeOnDate tripTimeOnDate = environment.getSource(); - return GqlUtil - .getTransitService(environment) - .findNotices(tripTimeOnDate.getStopTimeKey()); + return GqlUtil.getTransitService(environment).findNotices( + tripTimeOnDate.getStopTimeKey() + ); }) .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("bookingArrangements") .description("Booking arrangements for this passing time.") .type(bookingArrangementType) @@ -194,8 +183,7 @@ public static GraphQLObjectType create( if (OTPFeature.FlexRouting.isOff()) { return null; } - return GqlUtil - .getTransitService(environment) + return GqlUtil.getTransitService(environment) .getFlexIndex() .getTripById(tripTimeOnDate.getTrip().getId()); } diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/model/timetable/TripMetadataType.java b/application/src/main/java/org/opentripplanner/apis/transmodel/model/timetable/TripMetadataType.java index 4301b0721c2..ff4f3348be3 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/model/timetable/TripMetadataType.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/model/timetable/TripMetadataType.java @@ -12,13 +12,11 @@ public class TripMetadataType { private TripMetadataType() {} public static GraphQLObjectType create(GraphQLScalarType dateTimeScalar) { - return GraphQLObjectType - .newObject() + return GraphQLObjectType.newObject() .name("TripSearchData") .description("Trips search metadata.") .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("searchWindowUsed") .description( "This is the time window used by the raptor search. The input searchWindow " + @@ -33,8 +31,7 @@ public static GraphQLObjectType create(GraphQLScalarType dateTimeScalar) { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("nextDateTime") .description( "This is the suggested search time for the \"next page\" or time " + @@ -48,8 +45,7 @@ public static GraphQLObjectType create(GraphQLScalarType dateTimeScalar) { .build() ) .field( - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name("prevDateTime") .description( "This is the suggested search time for the \"previous page\" or " + diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/support/ExecutionResultMapper.java b/application/src/main/java/org/opentripplanner/apis/transmodel/support/ExecutionResultMapper.java index aac9cb1bb7c..17d8fd11de8 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/support/ExecutionResultMapper.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/support/ExecutionResultMapper.java @@ -13,21 +13,17 @@ */ public class ExecutionResultMapper { - private static final ErrorClassification API_PROCESSING_TIMEOUT = ErrorClassification.errorClassification( - "ApiProcessingTimeout" - ); + private static final ErrorClassification API_PROCESSING_TIMEOUT = + ErrorClassification.errorClassification("ApiProcessingTimeout"); - private static final ErrorClassification RESPONSE_TOO_LARGE = ErrorClassification.errorClassification( - "ResponseTooLarge" - ); + private static final ErrorClassification RESPONSE_TOO_LARGE = + ErrorClassification.errorClassification("ResponseTooLarge"); - private static final ErrorClassification BAD_REQUEST_ERROR = ErrorClassification.errorClassification( - "BadRequestError" - ); + private static final ErrorClassification BAD_REQUEST_ERROR = + ErrorClassification.errorClassification("BadRequestError"); - private static final ErrorClassification INTERNAL_SERVER_ERROR = ErrorClassification.errorClassification( - "InternalServerError" - ); + private static final ErrorClassification INTERNAL_SERVER_ERROR = + ErrorClassification.errorClassification("InternalServerError"); public static Response okResponse(ExecutionResult result) { return Response.ok(GraphQLResponseSerializer.serialize(result)).build(); @@ -54,8 +50,7 @@ public static Response systemErrorResponse(String message) { } public static Response response(ExecutionResult result, Response.StatusType status) { - return Response - .status(status.getStatusCode()) + return Response.status(status.getStatusCode()) .entity(GraphQLResponseSerializer.serialize(result)) .build(); } diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/support/GqlUtil.java b/application/src/main/java/org/opentripplanner/apis/transmodel/support/GqlUtil.java index fa82ee0cd02..82770dd7aae 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/support/GqlUtil.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/support/GqlUtil.java @@ -49,8 +49,7 @@ public static GraphFinder getGraphFinder(DataFetchingEnvironment environment) { } public static GraphQLFieldDefinition newTransitIdField() { - return GraphQLFieldDefinition - .newFieldDefinition() + return GraphQLFieldDefinition.newFieldDefinition() .name("id") .type(new GraphQLNonNull(Scalars.GraphQLID)) .dataFetcher(env -> TransitIdMapper.mapEntityIDToApi(env.getSource())) @@ -58,8 +57,7 @@ public static GraphQLFieldDefinition newTransitIdField() { } public static GraphQLInputObjectField newIdListInputField(String name, String description) { - return GraphQLInputObjectField - .newInputObjectField() + return GraphQLInputObjectField.newInputObjectField() .name(name) .description(description) .type(new GraphQLList(Scalars.GraphQLID)) diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/support/OneOfInputValidator.java b/application/src/main/java/org/opentripplanner/apis/transmodel/support/OneOfInputValidator.java index 0ea554d6b23..e386e8842f4 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/support/OneOfInputValidator.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/support/OneOfInputValidator.java @@ -30,8 +30,7 @@ public static String validateOneOf( String inputTypeName, String... definedFields ) { - var fieldsInInput = Arrays - .stream(definedFields) + var fieldsInInput = Arrays.stream(definedFields) .map(k -> map.containsKey(k) ? k : null) .filter(Objects::nonNull) .toList(); diff --git a/application/src/main/java/org/opentripplanner/apis/vectortiles/DebugStyleSpec.java b/application/src/main/java/org/opentripplanner/apis/vectortiles/DebugStyleSpec.java index caf08d09e05..ad1d36690ef 100644 --- a/application/src/main/java/org/opentripplanner/apis/vectortiles/DebugStyleSpec.java +++ b/application/src/main/java/org/opentripplanner/apis/vectortiles/DebugStyleSpec.java @@ -109,8 +109,7 @@ static StyleSpec build( VectorSourceLayer vertices, List extraLayers ) { - List vectorSources = Stream - .of(regularStops, edges, vertices) + List vectorSources = Stream.of(regularStops, edges, vertices) .map(VectorSourceLayer::vectorSource) .map(TileSource.class::cast) .toList(); @@ -146,12 +145,10 @@ static StyleSpec build( } private static List backgroundLayers(List extraLayers) { - return ListUtils - .combine(BACKGROUND_LAYERS, extraLayers) + return ListUtils.combine(BACKGROUND_LAYERS, extraLayers) .stream() .map(layer -> { - var builder = StyleBuilder - .ofId(layer.id()) + var builder = StyleBuilder.ofId(layer.id()) .displayName(layer.name()) .typeRaster() .source(layer) @@ -170,8 +167,7 @@ private static List stops( VectorSourceLayer groupStops ) { return List.of( - StyleBuilder - .ofId("area-stop") + StyleBuilder.ofId("area-stop") .group(STOPS_GROUP) .typeFill() .vectorSourceLayer(areaStops) @@ -180,8 +176,7 @@ private static List stops( .fillOutlineColor(BLACK) .minZoom(6) .maxZoom(MAX_ZOOM), - StyleBuilder - .ofId("group-stop") + StyleBuilder.ofId("group-stop") .group(STOPS_GROUP) .typeFill() .vectorSourceLayer(groupStops) @@ -190,8 +185,7 @@ private static List stops( .fillOutlineColor(BLACK) .minZoom(6) .maxZoom(MAX_ZOOM), - StyleBuilder - .ofId("regular-stop") + StyleBuilder.ofId("regular-stop") .group(STOPS_GROUP) .typeCircle() .vectorSourceLayer(regularStops) @@ -210,8 +204,7 @@ private static List stops( private static List vertices(VectorSourceLayer vertices) { return List.of( - StyleBuilder - .ofId("vertex") + StyleBuilder.ofId("vertex") .group(VERTICES_GROUP) .typeCircle() .vectorSourceLayer(vertices) @@ -223,8 +216,7 @@ private static List vertices(VectorSourceLayer vertices) { .minZoom(15) .maxZoom(MAX_ZOOM) .intiallyHidden(), - StyleBuilder - .ofId("parking-vertex") + StyleBuilder.ofId("parking-vertex") .group(VERTICES_GROUP) .typeCircle() .vectorSourceLayer(vertices) @@ -242,8 +234,7 @@ private static List vertices(VectorSourceLayer vertices) { private static List edges(VectorSourceLayer edges) { return List.of( - StyleBuilder - .ofId("edge") + StyleBuilder.ofId("edge") .group(EDGES_GROUP) .typeLine() .vectorSourceLayer(edges) @@ -254,8 +245,7 @@ private static List edges(VectorSourceLayer edges) { .minZoom(6) .maxZoom(MAX_ZOOM) .intiallyHidden(), - StyleBuilder - .ofId("edge-name") + StyleBuilder.ofId("edge-name") .group(EDGES_GROUP) .typeSymbol() .lineText("name") @@ -264,8 +254,7 @@ private static List edges(VectorSourceLayer edges) { .minZoom(17) .maxZoom(MAX_ZOOM) .intiallyHidden(), - StyleBuilder - .ofId("link") + StyleBuilder.ofId("link") .group(EDGES_GROUP) .typeLine() .vectorSourceLayer(edges) @@ -288,8 +277,7 @@ private static List edges(VectorSourceLayer edges) { private static List elevation(VectorSourceLayer edges, VectorSourceLayer vertices) { return List.of( - StyleBuilder - .ofId("maximum-slope") + StyleBuilder.ofId("maximum-slope") .group(ELEVATION_GROUP) .typeLine() .vectorSourceLayer(edges) @@ -301,8 +289,7 @@ private static List elevation(VectorSourceLayer edges, VectorSourc .minZoom(6) .maxZoom(MAX_ZOOM) .intiallyHidden(), - StyleBuilder - .ofId("vertex-elevation") + StyleBuilder.ofId("vertex-elevation") .group(ELEVATION_GROUP) .typeSymbol() .symbolText("elevation") @@ -315,8 +302,7 @@ private static List elevation(VectorSourceLayer edges, VectorSourc private static List safety(VectorSourceLayer edges) { return List.of( - StyleBuilder - .ofId("bicycle-safety") + StyleBuilder.ofId("bicycle-safety") .group(SAFETY_GROUP) .typeLine() .vectorSourceLayer(edges) @@ -327,8 +313,7 @@ private static List safety(VectorSourceLayer edges) { .minZoom(6) .maxZoom(MAX_ZOOM) .intiallyHidden(), - StyleBuilder - .ofId("walk-safety") + StyleBuilder.ofId("walk-safety") .group(SAFETY_GROUP) .typeLine() .vectorSourceLayer(edges) @@ -339,8 +324,7 @@ private static List safety(VectorSourceLayer edges) { .minZoom(6) .maxZoom(MAX_ZOOM) .intiallyHidden(), - StyleBuilder - .ofId("bicycle-safety-text") + StyleBuilder.ofId("bicycle-safety-text") .vectorSourceLayer(edges) .group(SAFETY_GROUP) .typeSymbol() @@ -350,8 +334,7 @@ private static List safety(VectorSourceLayer edges) { .minZoom(17) .maxZoom(MAX_ZOOM) .intiallyHidden(), - StyleBuilder - .ofId("walk-safety-text") + StyleBuilder.ofId("walk-safety-text") .vectorSourceLayer(edges) .group(SAFETY_GROUP) .typeSymbol() @@ -365,11 +348,9 @@ private static List safety(VectorSourceLayer edges) { } private static List traversalPermissions(VectorSourceLayer edges) { - var permissionStyles = Arrays - .stream(streetModes) + var permissionStyles = Arrays.stream(streetModes) .map(streetTraversalPermission -> - StyleBuilder - .ofId("permission " + streetTraversalPermission) + StyleBuilder.ofId("permission " + streetTraversalPermission) .vectorSourceLayer(edges) .group(PERMISSIONS_GROUP) .typeLine() @@ -388,8 +369,7 @@ private static List traversalPermissions(VectorSourceLayer edges) ) .toList(); - var textStyle = StyleBuilder - .ofId("permission-text") + var textStyle = StyleBuilder.ofId("permission-text") .vectorSourceLayer(edges) .group(PERMISSIONS_GROUP) .typeSymbol() @@ -404,11 +384,9 @@ private static List traversalPermissions(VectorSourceLayer edges) } private static List noThruTraffic(VectorSourceLayer edges) { - var noThruTrafficStyles = Arrays - .stream(streetModes) + var noThruTrafficStyles = Arrays.stream(streetModes) .map(streetTraversalPermission -> - StyleBuilder - .ofId("no-thru-traffic " + streetTraversalPermission) + StyleBuilder.ofId("no-thru-traffic " + streetTraversalPermission) .vectorSourceLayer(edges) .group(NO_THRU_TRAFFIC_GROUP) .typeLine() @@ -427,8 +405,7 @@ private static List noThruTraffic(VectorSourceLayer edges) { ) .toList(); - var textStyle = StyleBuilder - .ofId("no-thru-traffic-text") + var textStyle = StyleBuilder.ofId("no-thru-traffic-text") .vectorSourceLayer(edges) .group(NO_THRU_TRAFFIC_GROUP) .typeSymbol() @@ -443,16 +420,14 @@ private static List noThruTraffic(VectorSourceLayer edges) { } private static List permissionColors() { - return Arrays - .stream(StreetTraversalPermission.values()) + return Arrays.stream(StreetTraversalPermission.values()) .flatMap(p -> Stream.of(streetPermissionAsString(p), permissionColor(p))) .toList(); } private static List wheelchair(VectorSourceLayer edges) { return List.of( - StyleBuilder - .ofId("wheelchair-accessible") + StyleBuilder.ofId("wheelchair-accessible") .vectorSourceLayer(edges) .group(WHEELCHAIR_GROUP) .typeLine() @@ -463,8 +438,7 @@ private static List wheelchair(VectorSourceLayer edges) { .minZoom(6) .maxZoom(MAX_ZOOM) .intiallyHidden(), - StyleBuilder - .ofId("wheelchair-inaccessible") + StyleBuilder.ofId("wheelchair-inaccessible") .vectorSourceLayer(edges) .group(WHEELCHAIR_GROUP) .typeLine() diff --git a/application/src/main/java/org/opentripplanner/apis/vectortiles/GraphInspectorVectorTileResource.java b/application/src/main/java/org/opentripplanner/apis/vectortiles/GraphInspectorVectorTileResource.java index 0336a57c5de..0801699ffa5 100644 --- a/application/src/main/java/org/opentripplanner/apis/vectortiles/GraphInspectorVectorTileResource.java +++ b/application/src/main/java/org/opentripplanner/apis/vectortiles/GraphInspectorVectorTileResource.java @@ -180,15 +180,11 @@ private static LayerBuilder createLayerBuilder( OtpServerRequestContext context ) { return switch (layerParameters.type()) { - case RegularStop -> new StopLayerBuilder<>( - layerParameters, - locale, - e -> context.transitService().findRegularStopsByBoundingBox(e) + case RegularStop -> new StopLayerBuilder<>(layerParameters, locale, e -> + context.transitService().findRegularStopsByBoundingBox(e) ); - case AreaStop -> new StopLayerBuilder<>( - layerParameters, - locale, - e -> context.transitService().findAreaStops(e) + case AreaStop -> new StopLayerBuilder<>(layerParameters, locale, e -> + context.transitService().findAreaStops(e) ); case GroupStop -> new GroupStopLayerBuilder( layerParameters, diff --git a/application/src/main/java/org/opentripplanner/apis/vectortiles/model/StyleBuilder.java b/application/src/main/java/org/opentripplanner/apis/vectortiles/model/StyleBuilder.java index 6e137fb4ab6..73bb6c8bc43 100644 --- a/application/src/main/java/org/opentripplanner/apis/vectortiles/model/StyleBuilder.java +++ b/application/src/main/java/org/opentripplanner/apis/vectortiles/model/StyleBuilder.java @@ -337,9 +337,8 @@ private String validateColor(String color) { } private void validate() { - Stream - .of(TYPE) - .forEach(p -> Objects.requireNonNull(props.get(p), "%s must be set".formatted(p))); + Stream.of(TYPE).forEach(p -> Objects.requireNonNull(props.get(p), "%s must be set".formatted(p)) + ); } private void setLineColor(List valueSpecifier) { diff --git a/application/src/main/java/org/opentripplanner/astar/model/BinHeap.java b/application/src/main/java/org/opentripplanner/astar/model/BinHeap.java index 1e9b540a77a..2c37a11269d 100644 --- a/application/src/main/java/org/opentripplanner/astar/model/BinHeap.java +++ b/application/src/main/java/org/opentripplanner/astar/model/BinHeap.java @@ -34,13 +34,13 @@ public boolean empty() { } public double peek_min_key() { - if (size > 0) return prio[1]; else throw new IllegalStateException( - "An empty queue does not have a minimum key." - ); + if (size > 0) return prio[1]; + else throw new IllegalStateException("An empty queue does not have a minimum key."); } public T peek_min() { - if (size > 0) return elem[1]; else return null; + if (size > 0) return elem[1]; + else return null; } public void rekey(T e, double p) { diff --git a/application/src/main/java/org/opentripplanner/astar/model/ShortestPathTree.java b/application/src/main/java/org/opentripplanner/astar/model/ShortestPathTree.java index a6d7123cdfe..230cb806a04 100644 --- a/application/src/main/java/org/opentripplanner/astar/model/ShortestPathTree.java +++ b/application/src/main/java/org/opentripplanner/astar/model/ShortestPathTree.java @@ -102,7 +102,7 @@ public void dump() { " per vertex max: " + maxSize + " avg: " + - (statesCount * 1.0 / stateSets.size()) + ((statesCount * 1.0) / stateSets.size()) ); List nStates = new ArrayList<>(histogram.elementSet()); Collections.sort(nStates); diff --git a/application/src/main/java/org/opentripplanner/datastore/OtpDataStore.java b/application/src/main/java/org/opentripplanner/datastore/OtpDataStore.java index b85622de7f1..08721f2954f 100644 --- a/application/src/main/java/org/opentripplanner/datastore/OtpDataStore.java +++ b/application/src/main/java/org/opentripplanner/datastore/OtpDataStore.java @@ -106,8 +106,11 @@ public void open() { buildReportDir = findCompositeSource(config.reportDirectory(), BUILD_REPORT_DIR, REPORT); if (config.stopConsolidation() != null) { - stopConsolidation = - findSingleSource(config.stopConsolidation(), config.stopConsolidation().toString(), GTFS); + stopConsolidation = findSingleSource( + config.stopConsolidation(), + config.stopConsolidation().toString(), + GTFS + ); } addAll(Arrays.asList(streetGraph, graph, buildReportDir)); diff --git a/application/src/main/java/org/opentripplanner/datastore/file/ZipStreamDataSourceDecorator.java b/application/src/main/java/org/opentripplanner/datastore/file/ZipStreamDataSourceDecorator.java index 2dccbc2bb70..6a4689f79fb 100644 --- a/application/src/main/java/org/opentripplanner/datastore/file/ZipStreamDataSourceDecorator.java +++ b/application/src/main/java/org/opentripplanner/datastore/file/ZipStreamDataSourceDecorator.java @@ -197,8 +197,7 @@ private void uncompressEntry(ZipInputStream zis, ZipEntry entry) throws IOExcept byteArray.length, entry.getLastModifiedTime().toMillis(), false - ) - .withBytes(byteArray) + ).withBytes(byteArray) ); } else { LOG.info( diff --git a/application/src/main/java/org/opentripplanner/datastore/https/HttpsDataSourceMetadata.java b/application/src/main/java/org/opentripplanner/datastore/https/HttpsDataSourceMetadata.java index 8a84b0210b1..8e70583222d 100644 --- a/application/src/main/java/org/opentripplanner/datastore/https/HttpsDataSourceMetadata.java +++ b/application/src/main/java/org/opentripplanner/datastore/https/HttpsDataSourceMetadata.java @@ -84,8 +84,7 @@ private static long parseLong(String header) { @Override public String toString() { - return ToStringBuilder - .of(this.getClass()) + return ToStringBuilder.of(this.getClass()) .addObj("contentType", contentType) .addObj("contentLength", contentLength) .addObj("lastModified", lastModified) diff --git a/application/src/main/java/org/opentripplanner/framework/application/OTPFeature.java b/application/src/main/java/org/opentripplanner/framework/application/OTPFeature.java index ea46341d1b7..a0e5ec0cc47 100644 --- a/application/src/main/java/org/opentripplanner/framework/application/OTPFeature.java +++ b/application/src/main/java/org/opentripplanner/framework/application/OTPFeature.java @@ -27,12 +27,12 @@ public enum OTPFeature { false, false, """ - Turning this on guarantees that Rail stops without scheduled departures still get included - when generating transfers using `ConsiderPatternsForDirectTransfers`. It is common for stops - to be assign at real-time for Rail. Turning this on will help to avoid dropping transfers which - are needed, when the stop is in use later. Turning this on, if - ConsiderPatternsForDirectTransfers is off has no effect. - """ + Turning this on guarantees that Rail stops without scheduled departures still get included + when generating transfers using `ConsiderPatternsForDirectTransfers`. It is common for stops + to be assign at real-time for Rail. Turning this on will help to avoid dropping transfers which + are needed, when the stop is in use later. Turning this on, if + ConsiderPatternsForDirectTransfers is off has no effect. + """ ), ConsiderPatternsForDirectTransfers( true, @@ -43,10 +43,10 @@ public enum OTPFeature { true, false, """ - Enable the debug GraphQL client and web UI and located at the root of the web server as well as the debug map tiles it uses. - Be aware that the map tiles are not a stable API and can change without notice. - Use the [vector tiles feature if](sandbox/MapboxVectorTilesApi.md) you want a stable map tiles API. - """ + Enable the debug GraphQL client and web UI and located at the root of the web server as well as the debug map tiles it uses. + Be aware that the map tiles are not a stable API and can change without notice. + Use the [vector tiles feature if](sandbox/MapboxVectorTilesApi.md) you want a stable map tiles API. + """ ), ExtraTransferLegOnSameStop( false, @@ -260,8 +260,7 @@ private void testEnabled(boolean enabled, Runnable task) { } private static String valuesAsString(boolean enabled) { - return Arrays - .stream(values()) + return Arrays.stream(values()) .filter(it -> it.enabled == enabled) .map(Enum::name) .collect(Collectors.joining("\n\t")); diff --git a/application/src/main/java/org/opentripplanner/framework/geometry/CompactElevationProfile.java b/application/src/main/java/org/opentripplanner/framework/geometry/CompactElevationProfile.java index 105c79973cd..3c9d70b49e6 100644 --- a/application/src/main/java/org/opentripplanner/framework/geometry/CompactElevationProfile.java +++ b/application/src/main/java/org/opentripplanner/framework/geometry/CompactElevationProfile.java @@ -88,11 +88,10 @@ public static PackedCoordinateSequence uncompactElevationProfileWithRegularSampl int oiy = 0; for (int i = 0; i < c.length; i++) { int iy = oiy + coords[i]; - c[i] = - new Coordinate( - i == c.length - 1 ? lengthM : i * distanceBetweenSamplesM, - iy / FIXED_FLOAT_MULT - ); + c[i] = new Coordinate( + i == c.length - 1 ? lengthM : i * distanceBetweenSamplesM, + iy / FIXED_FLOAT_MULT + ); oiy = iy; } return new PackedCoordinateSequence.Double(c, 2); diff --git a/application/src/main/java/org/opentripplanner/framework/geometry/CompactLineStringUtils.java b/application/src/main/java/org/opentripplanner/framework/geometry/CompactLineStringUtils.java index 19bf9824726..cab7e5be4b8 100644 --- a/application/src/main/java/org/opentripplanner/framework/geometry/CompactLineStringUtils.java +++ b/application/src/main/java/org/opentripplanner/framework/geometry/CompactLineStringUtils.java @@ -113,12 +113,11 @@ public static byte[] compactLineString(LineString lineString, boolean reverse) { if (lineString == null) { return null; } - lineString = - GeometryUtils.addStartEndCoordinatesToLineString( - new Coordinate(0.0, 0.0), - lineString, - new Coordinate(0.0, 0.0) - ); + lineString = GeometryUtils.addStartEndCoordinatesToLineString( + new Coordinate(0.0, 0.0), + lineString, + new Coordinate(0.0, 0.0) + ); return compactLineString(0.0, 0.0, 0.0, 0.0, lineString, reverse); } diff --git a/application/src/main/java/org/opentripplanner/framework/geometry/DirectionUtils.java b/application/src/main/java/org/opentripplanner/framework/geometry/DirectionUtils.java index ab8585ff6ef..0a2bd6d0194 100644 --- a/application/src/main/java/org/opentripplanner/framework/geometry/DirectionUtils.java +++ b/application/src/main/java/org/opentripplanner/framework/geometry/DirectionUtils.java @@ -47,7 +47,7 @@ public static double getLastAngle(Geometry geometry) { } double az = getAzimuth(coord0, coord1); - return az * Math.PI / 180; + return (az * Math.PI) / 180; } /** @@ -76,6 +76,6 @@ public static double getFirstAngle(Geometry geometry) { } double az = getAzimuth(coord0, coord1); - return az * Math.PI / 180; + return (az * Math.PI) / 180; } } diff --git a/application/src/main/java/org/opentripplanner/framework/geometry/GeometryUtils.java b/application/src/main/java/org/opentripplanner/framework/geometry/GeometryUtils.java index 1c036035f4f..2affb23c714 100644 --- a/application/src/main/java/org/opentripplanner/framework/geometry/GeometryUtils.java +++ b/application/src/main/java/org/opentripplanner/framework/geometry/GeometryUtils.java @@ -228,7 +228,8 @@ public static Geometry convertGeoJsonToJtsGeometry(GeoJsonObject geoJsonGeom) org.geojson.LineString geoJsonLineString = (org.geojson.LineString) geoJsonGeom; return gf.createLineString(convertPath(geoJsonLineString.getCoordinates())); } else if (geoJsonGeom instanceof org.geojson.MultiLineString) { - org.geojson.MultiLineString geoJsonMultiLineString = (org.geojson.MultiLineString) geoJsonGeom; + org.geojson.MultiLineString geoJsonMultiLineString = + (org.geojson.MultiLineString) geoJsonGeom; LineString[] jtsLineStrings = new LineString[geoJsonMultiLineString.getCoordinates().size()]; int i = 0; for (List geoJsonPath : geoJsonMultiLineString.getCoordinates()) { diff --git a/application/src/main/java/org/opentripplanner/framework/geometry/HashGridSpatialIndex.java b/application/src/main/java/org/opentripplanner/framework/geometry/HashGridSpatialIndex.java index edda3fe4086..10b9fad4526 100644 --- a/application/src/main/java/org/opentripplanner/framework/geometry/HashGridSpatialIndex.java +++ b/application/src/main/java/org/opentripplanner/framework/geometry/HashGridSpatialIndex.java @@ -74,36 +74,28 @@ public HashGridSpatialIndex() { @Override public final void insert(Envelope envelope, final Object item) { - visit( - envelope, - true, - (bin, mapKey) -> { - /* - * Note: here we can end-up having several time the same object in the same bin, if - * the client insert multiple times the same object with different envelopes. - * However we do filter duplicated when querying, so apart for memory/performance - * reasons it should work. If this becomes a problem, we can use a set instead of a - * list. - */ - bin.add((T) item); - nEntries++; - return false; - } - ); + visit(envelope, true, (bin, mapKey) -> { + /* + * Note: here we can end-up having several time the same object in the same bin, if + * the client insert multiple times the same object with different envelopes. + * However we do filter duplicated when querying, so apart for memory/performance + * reasons it should work. If this becomes a problem, we can use a set instead of a + * list. + */ + bin.add((T) item); + nEntries++; + return false; + }); nObjects++; } @Override public final List query(Envelope envelope) { final Set ret = new HashSet<>(1024); - visit( - envelope, - false, - (bin, mapKey) -> { - ret.addAll(bin); - return false; - } - ); + visit(envelope, false, (bin, mapKey) -> { + ret.addAll(bin); + return false; + }); return new ArrayList<>(ret); } @@ -123,18 +115,14 @@ public final boolean remove(Envelope envelope, final Object item) { // mirroring the more efficient insert logic is not trivial and would require additional // testing of the spatial index. final IntBox removedCount = new IntBox(0); - visit( - envelope, - false, - (bin, mapKey) -> { - boolean removed = bin.remove(item); - if (removed) { - nEntries--; - removedCount.inc(); - } - return removed; + visit(envelope, false, (bin, mapKey) -> { + boolean removed = bin.remove(item); + if (removed) { + nEntries--; + removedCount.inc(); } - ); + return removed; + }); if (removedCount.get() > 0) { nObjects--; return true; @@ -150,14 +138,10 @@ public final void insert(LineString geom, final Object item) { // TODO Cut the segment if longer than bin size // to reduce the number of wrong bins Envelope env = new Envelope(coord[i], coord[i + 1]); - visit( - env, - true, - (bin, mapKey) -> { - keys.add(mapKey); - return false; - } - ); + visit(env, true, (bin, mapKey) -> { + keys.add(mapKey); + return false; + }); } keys.forEach(key -> { // Note: bins have been initialized in the previous visit @@ -188,8 +172,8 @@ public String toString() { this.nBins, this.nObjects, this.nEntries, - this.nEntries * 1.0 / this.nBins, - this.nEntries * 1.0 / this.nObjects + (this.nEntries * 1.0) / this.nBins, + (this.nEntries * 1.0) / this.nObjects ); } diff --git a/application/src/main/java/org/opentripplanner/framework/geometry/SphericalDistanceLibrary.java b/application/src/main/java/org/opentripplanner/framework/geometry/SphericalDistanceLibrary.java index 531170ad137..1218c91bd34 100644 --- a/application/src/main/java/org/opentripplanner/framework/geometry/SphericalDistanceLibrary.java +++ b/application/src/main/java/org/opentripplanner/framework/geometry/SphericalDistanceLibrary.java @@ -163,7 +163,7 @@ public static double fastDistance( * poles. */ public static double metersToDegrees(double distanceMeters) { - return 360 * distanceMeters / (2 * Math.PI * RADIUS_OF_EARTH_IN_M); + return (360 * distanceMeters) / (2 * Math.PI * RADIUS_OF_EARTH_IN_M); } /** @@ -172,7 +172,7 @@ public static double metersToDegrees(double distanceMeters) { * converge toward the poles. */ public static double degreesLatitudeToMeters(double degreesLatitude) { - return (2 * Math.PI * RADIUS_OF_EARTH_IN_M) * degreesLatitude / 360; + return ((2 * Math.PI * RADIUS_OF_EARTH_IN_M) * degreesLatitude) / 360; } /** @@ -182,7 +182,7 @@ public static double degreesLatitudeToMeters(double degreesLatitude) { * the number of degree of longitude for a given distance depends on the exact latitude. */ public static double metersToLonDegrees(double distanceMeters, double latDeg) { - double dLatDeg = 360 * distanceMeters / (2 * Math.PI * RADIUS_OF_EARTH_IN_M); + double dLatDeg = (360 * distanceMeters) / (2 * Math.PI * RADIUS_OF_EARTH_IN_M); /* * The computation below ensure that minCosLat is the minimum value of cos(lat) for lat in * the range [lat-dLat, lat+dLat]. diff --git a/application/src/main/java/org/opentripplanner/framework/graphql/scalar/CostScalarFactory.java b/application/src/main/java/org/opentripplanner/framework/graphql/scalar/CostScalarFactory.java index fc109444786..8be5ab61daf 100644 --- a/application/src/main/java/org/opentripplanner/framework/graphql/scalar/CostScalarFactory.java +++ b/application/src/main/java/org/opentripplanner/framework/graphql/scalar/CostScalarFactory.java @@ -30,8 +30,7 @@ public static GraphQLScalarType costScalar() { } private static GraphQLScalarType createCostScalar() { - return GraphQLScalarType - .newScalar() + return GraphQLScalarType.newScalar() .name(TYPENAME) .description(DOCUMENTATION) .coercing(createCoercing()) diff --git a/application/src/main/java/org/opentripplanner/framework/graphql/scalar/DateScalarFactory.java b/application/src/main/java/org/opentripplanner/framework/graphql/scalar/DateScalarFactory.java index 931a98fc5d9..1edf062e387 100644 --- a/application/src/main/java/org/opentripplanner/framework/graphql/scalar/DateScalarFactory.java +++ b/application/src/main/java/org/opentripplanner/framework/graphql/scalar/DateScalarFactory.java @@ -39,8 +39,7 @@ private static GraphQLScalarType createDateScalar( String scalarName, @Nullable String description ) { - return GraphQLScalarType - .newScalar() + return GraphQLScalarType.newScalar() .name(scalarName) .description(description) .coercing( diff --git a/application/src/main/java/org/opentripplanner/framework/graphql/scalar/DurationScalarFactory.java b/application/src/main/java/org/opentripplanner/framework/graphql/scalar/DurationScalarFactory.java index 5a61816ea06..e4698df049a 100644 --- a/application/src/main/java/org/opentripplanner/framework/graphql/scalar/DurationScalarFactory.java +++ b/application/src/main/java/org/opentripplanner/framework/graphql/scalar/DurationScalarFactory.java @@ -18,8 +18,7 @@ public class DurationScalarFactory { private DurationScalarFactory() {} public static GraphQLScalarType createDurationScalar() { - return GraphQLScalarType - .newScalar() + return GraphQLScalarType.newScalar() .name("Duration") .description(DOCUMENTATION) .coercing(new DurationCoercing()) diff --git a/application/src/main/java/org/opentripplanner/framework/io/FileUtils.java b/application/src/main/java/org/opentripplanner/framework/io/FileUtils.java index a4c9f14c60e..c58b9dc284d 100644 --- a/application/src/main/java/org/opentripplanner/framework/io/FileUtils.java +++ b/application/src/main/java/org/opentripplanner/framework/io/FileUtils.java @@ -64,13 +64,7 @@ public static void assertFileEquals(String expectedDoc, File newFile) { The file(%s) differ from the expected document. Expected (line: %3d): %s Result (line: %3d): %s - """.formatted( - newFile.getAbsolutePath(), - i, - expected, - j, - result - ) + """.formatted(newFile.getAbsolutePath(), i, expected, j, result) ); } ++i; diff --git a/application/src/main/java/org/opentripplanner/framework/io/JsonDataListDownloader.java b/application/src/main/java/org/opentripplanner/framework/io/JsonDataListDownloader.java index 81f8ee5b3c4..53cd1279fa0 100644 --- a/application/src/main/java/org/opentripplanner/framework/io/JsonDataListDownloader.java +++ b/application/src/main/java/org/opentripplanner/framework/io/JsonDataListDownloader.java @@ -52,22 +52,18 @@ public List download() { return null; } try { - return otpHttpClient.getAndMap( - URI.create(url), - headers, - is -> { - try { - return parseJSON(is); - } catch (IllegalArgumentException e) { - LOG.warn("Error parsing feed from {}", url, e); - } catch (JsonProcessingException e) { - LOG.warn("Error parsing feed from {} (bad JSON of some sort)", url, e); - } catch (IOException e) { - LOG.warn("Error reading feed from {}", url, e); - } - return null; + return otpHttpClient.getAndMap(URI.create(url), headers, is -> { + try { + return parseJSON(is); + } catch (IllegalArgumentException e) { + LOG.warn("Error parsing feed from {}", url, e); + } catch (JsonProcessingException e) { + LOG.warn("Error parsing feed from {} (bad JSON of some sort)", url, e); + } catch (IOException e) { + LOG.warn("Error reading feed from {}", url, e); } - ); + return null; + }); } catch (OtpHttpClientException e) { LOG.warn("Failed to get data from url {}", url); return null; diff --git a/application/src/main/java/org/opentripplanner/framework/io/OtpHttpClient.java b/application/src/main/java/org/opentripplanner/framework/io/OtpHttpClient.java index ccb88c3c74b..9f045495daa 100644 --- a/application/src/main/java/org/opentripplanner/framework/io/OtpHttpClient.java +++ b/application/src/main/java/org/opentripplanner/framework/io/OtpHttpClient.java @@ -119,18 +119,13 @@ public T getAndMapAsJsonObject( ObjectMapper objectMapper, Class clazz ) { - return getAndMap( - uri, - timeout, - headers, - is -> { - try { - return objectMapper.readValue(is, clazz); - } catch (Exception e) { - throw new OtpHttpClientException(e); - } + return getAndMap(uri, timeout, headers, is -> { + try { + return objectMapper.readValue(is, clazz); + } catch (Exception e) { + throw new OtpHttpClientException(e); } - ); + }); } /** @@ -154,18 +149,13 @@ public JsonNode getAndMapAsJsonNode( Map headers, ObjectMapper objectMapper ) { - return getAndMap( - uri, - timeout, - headers, - is -> { - try { - return objectMapper.readTree(is); - } catch (Exception e) { - throw new OtpHttpClientException(e); - } + return getAndMap(uri, timeout, headers, is -> { + try { + return objectMapper.readTree(is); + } catch (Exception e) { + throw new OtpHttpClientException(e); } - ); + }); } /** @@ -234,11 +224,8 @@ public T executeAndMap( Map headers, ResponseMapper contentMapper ) { - return executeAndMapWithResponseHandler( - httpRequest, - timeout, - headers, - response -> mapResponse(response, contentMapper) + return executeAndMapWithResponseHandler(httpRequest, timeout, headers, response -> + mapResponse(response, contentMapper) ); } @@ -252,17 +239,12 @@ public Optional executeAndMapOptional( Map headers, ResponseMapper contentMapper ) { - return executeAndMapWithResponseHandler( - httpRequest, - timeout, - headers, - response -> { - if (response.getCode() == 204) { - return Optional.empty(); - } - return Optional.of(mapResponse(response, contentMapper)); + return executeAndMapWithResponseHandler(httpRequest, timeout, headers, response -> { + if (response.getCode() == 204) { + return Optional.empty(); } - ); + return Optional.of(mapResponse(response, contentMapper)); + }); } /** @@ -374,8 +356,7 @@ private T sendAndMap( */ private static RequestConfig requestConfig(Duration timeout) { - return RequestConfig - .custom() + return RequestConfig.custom() .setResponseTimeout(Timeout.of(timeout)) .setConnectionRequestTimeout(Timeout.of(timeout)) .setProtocolUpgradeEnabled(false) diff --git a/application/src/main/java/org/opentripplanner/framework/io/OtpHttpClientFactory.java b/application/src/main/java/org/opentripplanner/framework/io/OtpHttpClientFactory.java index 8f7256f642f..26534ed2349 100644 --- a/application/src/main/java/org/opentripplanner/framework/io/OtpHttpClientFactory.java +++ b/application/src/main/java/org/opentripplanner/framework/io/OtpHttpClientFactory.java @@ -86,24 +86,22 @@ private OtpHttpClientFactory(Duration timeout, Duration connectionTtl, int maxCo Objects.requireNonNull(timeout); Objects.requireNonNull(connectionTtl); - PoolingHttpClientConnectionManager connectionManager = PoolingHttpClientConnectionManagerBuilder - .create() - .setDefaultSocketConfig(SocketConfig.custom().setSoTimeout(Timeout.of(timeout)).build()) - .setPoolConcurrencyPolicy(PoolConcurrencyPolicy.STRICT) - .setConnPoolPolicy(PoolReusePolicy.LIFO) - .setMaxConnTotal(maxConnections) - .setDefaultConnectionConfig( - ConnectionConfig - .custom() - .setSocketTimeout(Timeout.of(timeout)) - .setConnectTimeout(Timeout.of(timeout)) - .setTimeToLive(TimeValue.of(connectionTtl)) - .build() - ) - .build(); - - HttpClientBuilder httpClientBuilder = HttpClients - .custom() + PoolingHttpClientConnectionManager connectionManager = + PoolingHttpClientConnectionManagerBuilder.create() + .setDefaultSocketConfig(SocketConfig.custom().setSoTimeout(Timeout.of(timeout)).build()) + .setPoolConcurrencyPolicy(PoolConcurrencyPolicy.STRICT) + .setConnPoolPolicy(PoolReusePolicy.LIFO) + .setMaxConnTotal(maxConnections) + .setDefaultConnectionConfig( + ConnectionConfig.custom() + .setSocketTimeout(Timeout.of(timeout)) + .setConnectTimeout(Timeout.of(timeout)) + .setTimeToLive(TimeValue.of(connectionTtl)) + .build() + ) + .build(); + + HttpClientBuilder httpClientBuilder = HttpClients.custom() .setUserAgent("OpenTripPlanner") .setConnectionManager(connectionManager) .setDefaultRequestConfig(requestConfig(timeout)); @@ -128,8 +126,7 @@ public void close() { * Configures the request with a custom timeout. */ private static RequestConfig requestConfig(Duration timeout) { - return RequestConfig - .custom() + return RequestConfig.custom() .setResponseTimeout(Timeout.of(timeout)) .setConnectionRequestTimeout(Timeout.of(timeout)) .setProtocolUpgradeEnabled(false) diff --git a/application/src/main/java/org/opentripplanner/framework/token/Deserializer.java b/application/src/main/java/org/opentripplanner/framework/token/Deserializer.java index c48723d2e69..c88d036ed45 100644 --- a/application/src/main/java/org/opentripplanner/framework/token/Deserializer.java +++ b/application/src/main/java/org/opentripplanner/framework/token/Deserializer.java @@ -17,8 +17,9 @@ class Deserializer { Deserializer(String token) { byte[] bytes = Base64.getUrlDecoder().decode(token); var tokenFormatter = TokenFormatterConfiguration.tokenFormatter(); - this.values = - Stream.of(SPLIT_PATTERN.split(new String(bytes), -1)).map(tokenFormatter::decode).toList(); + this.values = Stream.of(SPLIT_PATTERN.split(new String(bytes), -1)) + .map(tokenFormatter::decode) + .toList(); } List deserialize(TokenDefinition definition) { diff --git a/application/src/main/java/org/opentripplanner/framework/token/Serializer.java b/application/src/main/java/org/opentripplanner/framework/token/Serializer.java index 3b48792c06d..0a9386a1c36 100644 --- a/application/src/main/java/org/opentripplanner/framework/token/Serializer.java +++ b/application/src/main/java/org/opentripplanner/framework/token/Serializer.java @@ -8,7 +8,8 @@ class Serializer { private final TokenDefinition definition; private final Object[] values; private final StringBuilder buf = new StringBuilder(); - private final CharacterEscapeFormatter tokenFormatter = TokenFormatterConfiguration.tokenFormatter(); + private final CharacterEscapeFormatter tokenFormatter = + TokenFormatterConfiguration.tokenFormatter(); private Serializer(TokenDefinition definition, Object[] values) { this.definition = definition; diff --git a/application/src/main/java/org/opentripplanner/framework/token/TokenDefinition.java b/application/src/main/java/org/opentripplanner/framework/token/TokenDefinition.java index e8e44f0f293..eadded7106e 100644 --- a/application/src/main/java/org/opentripplanner/framework/token/TokenDefinition.java +++ b/application/src/main/java/org/opentripplanner/framework/token/TokenDefinition.java @@ -49,8 +49,7 @@ public int hashCode() { @Override public String toString() { - return ToStringBuilder - .of(TokenDefinition.class) + return ToStringBuilder.of(TokenDefinition.class) .addNum("version", version, 0) .addCol("fields", listFields()) .toString(); diff --git a/application/src/main/java/org/opentripplanner/framework/token/TokenSchema.java b/application/src/main/java/org/opentripplanner/framework/token/TokenSchema.java index 35bb836251b..19d3b1893a8 100644 --- a/application/src/main/java/org/opentripplanner/framework/token/TokenSchema.java +++ b/application/src/main/java/org/opentripplanner/framework/token/TokenSchema.java @@ -73,8 +73,7 @@ public TokenDefinition currentDefinition() { @Override public String toString() { - return ToStringBuilder - .of(TokenSchema.class) + return ToStringBuilder.of(TokenSchema.class) .addObj("definition", currentDefinition()) .toString(); } diff --git a/application/src/main/java/org/opentripplanner/graph_builder/GraphBuilderDataSources.java b/application/src/main/java/org/opentripplanner/graph_builder/GraphBuilderDataSources.java index 3ed675c0da8..49d771fee01 100644 --- a/application/src/main/java/org/opentripplanner/graph_builder/GraphBuilderDataSources.java +++ b/application/src/main/java/org/opentripplanner/graph_builder/GraphBuilderDataSources.java @@ -199,10 +199,8 @@ public Optional stopConsolidation() { private boolean uriMatch(URI configURI, URI datasourceURI) { return ( configURI.equals(datasourceURI) || - ( - !configURI.isAbsolute() && - baseDirectory.toPath().resolve(configURI.toString()).toUri().equals(datasourceURI) - ) + (!configURI.isAbsolute() && + baseDirectory.toPath().resolve(configURI.toString()).toUri().equals(datasourceURI)) ); } diff --git a/application/src/main/java/org/opentripplanner/graph_builder/issue/api/Issue.java b/application/src/main/java/org/opentripplanner/graph_builder/issue/api/Issue.java index cb50320345c..45218806293 100644 --- a/application/src/main/java/org/opentripplanner/graph_builder/issue/api/Issue.java +++ b/application/src/main/java/org/opentripplanner/graph_builder/issue/api/Issue.java @@ -37,8 +37,7 @@ public String getMessage() { @Override public String toString() { - return ToStringBuilder - .of(this.getClass()) + return ToStringBuilder.of(this.getClass()) .addStr("type", type) .addStr("message", getMessage()) .toString(); diff --git a/application/src/main/java/org/opentripplanner/graph_builder/issues/ParkAndRideEntranceRemoved.java b/application/src/main/java/org/opentripplanner/graph_builder/issues/ParkAndRideEntranceRemoved.java index 0170d554358..349870710a6 100644 --- a/application/src/main/java/org/opentripplanner/graph_builder/issues/ParkAndRideEntranceRemoved.java +++ b/application/src/main/java/org/opentripplanner/graph_builder/issues/ParkAndRideEntranceRemoved.java @@ -21,8 +21,7 @@ public String getMessage() { @Override public Geometry getGeometry() { - return GeometryUtils - .getGeometryFactory() + return GeometryUtils.getGeometryFactory() .createPoint(vehicleParkingEntrance.getVertex().getCoordinate()); } } diff --git a/application/src/main/java/org/opentripplanner/graph_builder/module/AddTransitEntitiesToGraph.java b/application/src/main/java/org/opentripplanner/graph_builder/module/AddTransitEntitiesToGraph.java index 1d335d7ff4f..d66c26b6963 100644 --- a/application/src/main/java/org/opentripplanner/graph_builder/module/AddTransitEntitiesToGraph.java +++ b/application/src/main/java/org/opentripplanner/graph_builder/module/AddTransitEntitiesToGraph.java @@ -53,7 +53,8 @@ public class AddTransitEntitiesToGraph { private final OtpTransitService otpTransitService; // Map of all station elements and their vertices in the graph - private final Map, StationElementVertex> stationElementNodes = new HashMap<>(); + private final Map, StationElementVertex> stationElementNodes = + new HashMap<>(); private final int subwayAccessTime; private final VertexFactory vertexFactory; @@ -78,8 +79,9 @@ public static void addToGraph( Graph graph, TimetableRepository timetableRepository ) { - new AddTransitEntitiesToGraph(otpTransitService, subwayAccessTime, graph) - .applyToGraph(timetableRepository); + new AddTransitEntitiesToGraph(otpTransitService, subwayAccessTime, graph).applyToGraph( + timetableRepository + ); } private void applyToGraph(TimetableRepository timetableRepository) { @@ -199,8 +201,7 @@ private void createPathwayEdgesAndAddThemToGraph() { // the GTFS spec allows you to define a pathway which has neither traversal time, distance // nor steps. This would lead to traversal costs of 0, so we compute the distance from the // vertices as fallback. - double distance = Optional - .of(pathway.getLength()) + double distance = Optional.of(pathway.getLength()) .filter(l -> l > 0) .orElseGet(() -> distance(fromVertex.getCoordinate(), toVertex.getCoordinate())); diff --git a/application/src/main/java/org/opentripplanner/graph_builder/module/DirectTransferGenerator.java b/application/src/main/java/org/opentripplanner/graph_builder/module/DirectTransferGenerator.java index e8074651c1e..09e3d599991 100644 --- a/application/src/main/java/org/opentripplanner/graph_builder/module/DirectTransferGenerator.java +++ b/application/src/main/java/org/opentripplanner/graph_builder/module/DirectTransferGenerator.java @@ -96,7 +96,8 @@ public void buildGraph() { NearbyStopFinder nearbyStopFinder = createNearbyStopFinder(defaultMaxTransferDuration); List stops = graph.getVerticesOfType(TransitStopVertex.class); - Set carsAllowedStops = timetableRepository.getStopLocationsUsedForCarsAllowedTrips(); + Set carsAllowedStops = + timetableRepository.getStopLocationsUsedForCarsAllowedTrips(); LOG.info("Creating transfers based on requests:"); transferRequests.forEach(transferProfile -> LOG.info(transferProfile.toString())); @@ -285,7 +286,8 @@ private TransferConfiguration parseTransferParameters(NearbyStopFinder nearbySto } } // Create transfers between carsAllowedStops for the specific mode if carsAllowedStopMaxTransferDuration is set in the build config. - Duration carsAllowedStopMaxTransferDuration = transferParameters.carsAllowedStopMaxTransferDuration(); + Duration carsAllowedStopMaxTransferDuration = + transferParameters.carsAllowedStopMaxTransferDuration(); if (carsAllowedStopMaxTransferDuration != null) { carsAllowedStopTransferRequests.add(transferProfile); carsAllowedStopNearbyStopFinderForMode.put( diff --git a/application/src/main/java/org/opentripplanner/graph_builder/module/OsmBoardingLocationsModule.java b/application/src/main/java/org/opentripplanner/graph_builder/module/OsmBoardingLocationsModule.java index d014736bb5a..2337f243901 100644 --- a/application/src/main/java/org/opentripplanner/graph_builder/module/OsmBoardingLocationsModule.java +++ b/application/src/main/java/org/opentripplanner/graph_builder/module/OsmBoardingLocationsModule.java @@ -127,7 +127,7 @@ private boolean connectVertexToStop(TransitStopVertex ts, StreetIndex index) { private Envelope getEnvelope(TransitStopVertex ts) { Envelope envelope = new Envelope(ts.getCoordinate()); - double xscale = Math.cos(ts.getCoordinate().y * Math.PI / 180); + double xscale = Math.cos((ts.getCoordinate().y * Math.PI) / 180); envelope.expandBy(searchRadiusDegrees / xscale, searchRadiusDegrees); return envelope; } diff --git a/application/src/main/java/org/opentripplanner/graph_builder/module/StreetLinkerModule.java b/application/src/main/java/org/opentripplanner/graph_builder/module/StreetLinkerModule.java index 824bf74284f..3b3a66a07a3 100644 --- a/application/src/main/java/org/opentripplanner/graph_builder/module/StreetLinkerModule.java +++ b/application/src/main/java/org/opentripplanner/graph_builder/module/StreetLinkerModule.java @@ -95,7 +95,8 @@ public void linkTransitStops(Graph graph, TimetableRepository timetableRepositor stopLocationsUsedForFlexTrips = getStopLocationsUsedForFlexTrips(timetableRepository); } - Set stopLocationsUsedForCarsAllowedTrips = timetableRepository.getStopLocationsUsedForCarsAllowedTrips(); + Set stopLocationsUsedForCarsAllowedTrips = + timetableRepository.getStopLocationsUsedForCarsAllowedTrips(); for (TransitStopVertex tStop : vertices) { // Stops with pathways do not need to be connected to the street network, since there are explicit entrances defined for that @@ -111,9 +112,8 @@ public void linkTransitStops(Graph graph, TimetableRepository timetableRepositor StopLinkType linkType = StopLinkType.WALK_ONLY; if ( - ( - OTPFeature.FlexRouting.isOn() && stopLocationsUsedForFlexTrips.contains(tStop.getStop()) - ) || + (OTPFeature.FlexRouting.isOn() && + stopLocationsUsedForFlexTrips.contains(tStop.getStop())) || stopLocationsUsedForCarsAllowedTrips.contains(tStop.getStop()) ) { linkType = StopLinkType.WALK_AND_CAR; @@ -276,9 +276,9 @@ private void linkTransitEntrances(Graph graph) { private void linkStationCentroids(Graph graph) { BiFunction> stationAndStreetVertexLinker = ( - theStation, - streetVertex - ) -> + theStation, + streetVertex + ) -> List.of( StreetStationCentroidLink.createStreetStationLink( (StationCentroidVertex) theStation, diff --git a/application/src/main/java/org/opentripplanner/graph_builder/module/TransferParameters.java b/application/src/main/java/org/opentripplanner/graph_builder/module/TransferParameters.java index 0d7b31b4a81..a11d2268274 100644 --- a/application/src/main/java/org/opentripplanner/graph_builder/module/TransferParameters.java +++ b/application/src/main/java/org/opentripplanner/graph_builder/module/TransferParameters.java @@ -24,8 +24,7 @@ public record TransferParameters( } public String toString() { - return ToStringBuilder - .of(getClass()) + return ToStringBuilder.of(getClass()) .addDuration("maxTransferDuration", maxTransferDuration) .addDuration("carsAllowedStopMaxTransferDuration", carsAllowedStopMaxTransferDuration) .addBool("disableDefaultTransfers", disableDefaultTransfers) diff --git a/application/src/main/java/org/opentripplanner/graph_builder/module/TripPatternNamer.java b/application/src/main/java/org/opentripplanner/graph_builder/module/TripPatternNamer.java index 238ddc5dc67..7f72c8ad7ad 100644 --- a/application/src/main/java/org/opentripplanner/graph_builder/module/TripPatternNamer.java +++ b/application/src/main/java/org/opentripplanner/graph_builder/module/TripPatternNamer.java @@ -112,7 +112,7 @@ public static void generateUniqueNames(Collection tableTripPatterns vias.put(stop, pattern); } } - PATTERN:for (TripPattern pattern : routeTripPatterns) { + PATTERN: for (TripPattern pattern : routeTripPatterns) { if (pattern.getName() != null) { continue; } @@ -170,8 +170,7 @@ public static void generateUniqueNames(Collection tableTripPatterns sb.append(" express"); } else { // The final fallback: reference a specific trip ID. - Optional - .ofNullable(pattern.getScheduledTimetable().getRepresentativeTripTimes()) + Optional.ofNullable(pattern.getScheduledTimetable().getRepresentativeTripTimes()) .map(TripTimes::getTrip) .ifPresent(value -> sb.append(" like trip ").append(value.getId())); } diff --git a/application/src/main/java/org/opentripplanner/graph_builder/module/configure/GraphBuilderModules.java b/application/src/main/java/org/opentripplanner/graph_builder/module/configure/GraphBuilderModules.java index 39b68ca60ab..355c19a8ae1 100644 --- a/application/src/main/java/org/opentripplanner/graph_builder/module/configure/GraphBuilderModules.java +++ b/application/src/main/java/org/opentripplanner/graph_builder/module/configure/GraphBuilderModules.java @@ -68,7 +68,9 @@ static OsmModule provideOsmModule( StreetLimitationParameters streetLimitationParameters ) { List providers = new ArrayList<>(); - for (ConfiguredDataSource osmConfiguredDataSource : dataSources.getOsmConfiguredDatasource()) { + for (ConfiguredDataSource< + OsmExtractParameters + > osmConfiguredDataSource : dataSources.getOsmConfiguredDatasource()) { providers.add( new DefaultOsmProvider( osmConfiguredDataSource.dataSource(), @@ -81,8 +83,7 @@ static OsmModule provideOsmModule( ); } - return OsmModule - .of(providers, graph, osmInfoGraphBuildRepository, vehicleParkingRepository) + return OsmModule.of(providers, graph, osmInfoGraphBuildRepository, vehicleParkingRepository) .withEdgeNamer(config.edgeNamer) .withAreaVisibility(config.areaVisibility) .withPlatformEntriesLinking(config.platformEntriesLinking) @@ -106,7 +107,9 @@ static GtfsModule provideGtfsModule( DataImportIssueStore issueStore ) { List gtfsBundles = new ArrayList<>(); - for (ConfiguredDataSource gtfsData : dataSources.getGtfsConfiguredDatasource()) { + for (ConfiguredDataSource< + GtfsFeedParameters + > gtfsData : dataSources.getGtfsConfiguredDatasource()) { GtfsBundle gtfsBundle = new GtfsBundle(gtfsData); gtfsBundle.subwayAccessTime = config.getSubwayAccessTimeSeconds(); @@ -149,14 +152,13 @@ static NetexModule provideNetexModule( VehicleParkingRepository parkingService, DataImportIssueStore issueStore ) { - return new NetexConfigure(config) - .createNetexModule( - dataSources.getNetexConfiguredDatasource(), - timetableRepository, - parkingService, - graph, - issueStore - ); + return new NetexConfigure(config).createNetexModule( + dataSources.getNetexConfiguredDatasource(), + timetableRepository, + parkingService, + graph, + issueStore + ); } @Provides diff --git a/application/src/main/java/org/opentripplanner/graph_builder/module/geometry/GeometryProcessor.java b/application/src/main/java/org/opentripplanner/graph_builder/module/geometry/GeometryProcessor.java index 17b0f9d5367..362c4f4bd55 100644 --- a/application/src/main/java/org/opentripplanner/graph_builder/module/geometry/GeometryProcessor.java +++ b/application/src/main/java/org/opentripplanner/graph_builder/module/geometry/GeometryProcessor.java @@ -47,7 +47,8 @@ public class GeometryProcessor { private static final GeometryFactory geometryFactory = GeometryUtils.getGeometryFactory(); private final OtpTransitServiceBuilder transitService; // this is a thread-safe implementation - private final Map geometriesByShapeSegmentKey = new ConcurrentHashMap<>(); + private final Map geometriesByShapeSegmentKey = + new ConcurrentHashMap<>(); // this is a thread-safe implementation private final Map geometriesByShapeId = new ConcurrentHashMap<>(); // this is a thread-safe implementation @@ -63,8 +64,9 @@ public GeometryProcessor( DataImportIssueStore issueStore ) { this.transitService = transitService; - this.maxStopToShapeSnapDistance = - maxStopToShapeSnapDistance > 0 ? maxStopToShapeSnapDistance : 150; + this.maxStopToShapeSnapDistance = maxStopToShapeSnapDistance > 0 + ? maxStopToShapeSnapDistance + : 150; this.issueStore = issueStore; } @@ -367,17 +369,16 @@ private LineString getHopGeometryViaShapeDistTraveled( LineString line = getLineStringForShapeId(shapeId); LocationIndexedLine lol = new LocationIndexedLine(line); - geometry = - getSegmentGeometry( - shapeId, - lol, - startIndex, - endIndex, - startDistance, - endDistance, - st0, - st1 - ); + geometry = getSegmentGeometry( + shapeId, + lol, + startIndex, + endIndex, + startDistance, + endDistance, + st0, + st1 + ); return geometry; } diff --git a/application/src/main/java/org/opentripplanner/graph_builder/module/geometry/IndexedLineSegment.java b/application/src/main/java/org/opentripplanner/graph_builder/module/geometry/IndexedLineSegment.java index c0ec6814fa6..2371532e1b1 100644 --- a/application/src/main/java/org/opentripplanner/graph_builder/module/geometry/IndexedLineSegment.java +++ b/application/src/main/java/org/opentripplanner/graph_builder/module/geometry/IndexedLineSegment.java @@ -38,16 +38,13 @@ public double fraction(Coordinate coord) { // in radians static double bearing(Coordinate c1, Coordinate c2) { - double deltaLon = (c2.x - c1.x) * Math.PI / 180; - double lat1Radians = c1.y * Math.PI / 180; - double lat2Radians = c2.y * Math.PI / 180; + double deltaLon = ((c2.x - c1.x) * Math.PI) / 180; + double lat1Radians = (c1.y * Math.PI) / 180; + double lat2Radians = (c2.y * Math.PI) / 180; double y = Math.sin(deltaLon) * Math.cos(lat2Radians); double x = - Math.cos(lat1Radians) * - Math.sin(lat2Radians) - - Math.sin(lat1Radians) * - Math.cos(lat2Radians) * - Math.cos(deltaLon); + Math.cos(lat1Radians) * Math.sin(lat2Radians) - + Math.sin(lat1Radians) * Math.cos(lat2Radians) * Math.cos(deltaLon); return Math.atan2(y, x); } diff --git a/application/src/main/java/org/opentripplanner/graph_builder/module/islandpruning/PruneIslands.java b/application/src/main/java/org/opentripplanner/graph_builder/module/islandpruning/PruneIslands.java index 0f21299b59b..ffe364944e4 100644 --- a/application/src/main/java/org/opentripplanner/graph_builder/module/islandpruning/PruneIslands.java +++ b/application/src/main/java/org/opentripplanner/graph_builder/module/islandpruning/PruneIslands.java @@ -334,8 +334,7 @@ private void collectNeighbourVertices( if (State.isEmpty(states)) { continue; } - Arrays - .stream(states) + Arrays.stream(states) .map(State::getVertex) .forEach(out -> { var vertexList = neighborsForVertex.computeIfAbsent(gv, k -> new ArrayList<>()); diff --git a/application/src/main/java/org/opentripplanner/graph_builder/module/islandpruning/Subgraph.java b/application/src/main/java/org/opentripplanner/graph_builder/module/islandpruning/Subgraph.java index 94dcfaaf131..f3643ad7bc2 100644 --- a/application/src/main/java/org/opentripplanner/graph_builder/module/islandpruning/Subgraph.java +++ b/application/src/main/java/org/opentripplanner/graph_builder/module/islandpruning/Subgraph.java @@ -90,7 +90,7 @@ Iterator stopIterator() { // distances between graph edges. This is good enough for our heuristics. double distanceFromOtherGraph(StreetIndex index, double searchRadius) { Vertex v = getRepresentativeVertex(); - double xscale = Math.cos(v.getCoordinate().y * Math.PI / 180); + double xscale = Math.cos((v.getCoordinate().y * Math.PI) / 180); double searchRadiusDegrees = SphericalDistanceLibrary.metersToDegrees(searchRadius); Envelope envelope = new Envelope(); diff --git a/application/src/main/java/org/opentripplanner/graph_builder/module/nearbystops/StreetNearbyStopFinder.java b/application/src/main/java/org/opentripplanner/graph_builder/module/nearbystops/StreetNearbyStopFinder.java index 8277bd47e4c..74ab07f121f 100644 --- a/application/src/main/java/org/opentripplanner/graph_builder/module/nearbystops/StreetNearbyStopFinder.java +++ b/application/src/main/java/org/opentripplanner/graph_builder/module/nearbystops/StreetNearbyStopFinder.java @@ -119,8 +119,7 @@ public Collection findNearbyStops( } stopsFound = new ArrayList<>(stopsFound); - var streetSearch = StreetSearchBuilder - .of() + var streetSearch = StreetSearchBuilder.of() .setSkipEdgeStrategy(new DurationSkipEdgeStrategy<>(durationLimit)) .setDominanceFunction(new DominanceFunctions.MinimumWeight()) .setRequest(request) @@ -153,7 +152,8 @@ public Collection findNearbyStops( } if ( OTPFeature.FlexRouting.isOn() && - targetVertex instanceof StreetVertex streetVertex && !streetVertex.areaStops().isEmpty() + targetVertex instanceof StreetVertex streetVertex && + !streetVertex.areaStops().isEmpty() ) { for (AreaStop areaStop : ((StreetVertex) targetVertex).areaStops()) { // This is for a simplification, so that we only return one vertex from each diff --git a/application/src/main/java/org/opentripplanner/graph_builder/module/ned/ElevationModule.java b/application/src/main/java/org/opentripplanner/graph_builder/module/ned/ElevationModule.java index af8fb943072..11a075c4774 100644 --- a/application/src/main/java/org/opentripplanner/graph_builder/module/ned/ElevationModule.java +++ b/application/src/main/java/org/opentripplanner/graph_builder/module/ned/ElevationModule.java @@ -233,7 +233,7 @@ public void buildGraph() { int nPoints = nPointsEvaluated.get() + nPointsOutsideDEM.get(); if (nPoints > 0) { - double failurePercentage = (double) nPointsOutsideDEM.get() / nPoints * 100.0; + double failurePercentage = ((double) nPointsOutsideDEM.get() / nPoints) * 100.0; if (failurePercentage > 50) { issueStore.add( new Graphwide( @@ -289,8 +289,11 @@ public void buildGraph() { edgesWithCalculatedElevations ); - new MissingElevationHandler(issueStore, elevationsForVertices, maxElevationPropagationMeters) - .run(); + new MissingElevationHandler( + issueStore, + elevationsForVertices, + maxElevationPropagationMeters + ).run(); updateElevationMetadata(graph); @@ -529,8 +532,7 @@ private Coverage getThreadSpecificCoverageInterpolator() { private void setEdgeElevationProfile(StreetEdge ee, PackedCoordinateSequence elevPCS) { try { - StreetElevationExtensionBuilder - .of(ee) + StreetElevationExtensionBuilder.of(ee) .withElevationProfile(elevPCS) .withComputed(false) .build() @@ -624,11 +626,10 @@ private double getApproximateEllipsoidToGeoidDifference(double y, double x) int hash = yVal * 104729 + xVal; Double difference = geoidDifferenceCache.get(hash); if (difference == null) { - difference = - computeEllipsoidToGeoidDifference( - yVal / (1.0 * geoidDifferenceCoordinateValueMultiplier), - xVal / (1.0 * geoidDifferenceCoordinateValueMultiplier) - ); + difference = computeEllipsoidToGeoidDifference( + yVal / (1.0 * geoidDifferenceCoordinateValueMultiplier), + xVal / (1.0 * geoidDifferenceCoordinateValueMultiplier) + ); geoidDifferenceCache.put(hash, difference); } return difference; diff --git a/application/src/main/java/org/opentripplanner/graph_builder/module/ned/MissingElevationHandler.java b/application/src/main/java/org/opentripplanner/graph_builder/module/ned/MissingElevationHandler.java index e0f5672a6ca..9a457c18ed9 100644 --- a/application/src/main/java/org/opentripplanner/graph_builder/module/ned/MissingElevationHandler.java +++ b/application/src/main/java/org/opentripplanner/graph_builder/module/ned/MissingElevationHandler.java @@ -98,8 +98,7 @@ private BinHeap createPriorityQueue(Map el var pq = new BinHeap(); elevations.forEach( - ( - (vertex, elevation) -> { + ((vertex, elevation) -> { vertex .getIncoming() .forEach(edge -> { @@ -131,8 +130,7 @@ private BinHeap createPriorityQueue(Map el ); } }); - } - ) + }) ); return pq; @@ -254,8 +252,7 @@ private void assignElevationToEdgeIfPossible(Map elevations, Str PackedCoordinateSequence profile = new PackedCoordinateSequence.Double(coords); try { - StreetElevationExtensionBuilder - .of(edge) + StreetElevationExtensionBuilder.of(edge) .withElevationProfile(profile) .withComputed(true) .build() diff --git a/application/src/main/java/org/opentripplanner/graph_builder/module/ned/VerticalDatum.java b/application/src/main/java/org/opentripplanner/graph_builder/module/ned/VerticalDatum.java index 43abb58005b..c969e1e3d34 100644 --- a/application/src/main/java/org/opentripplanner/graph_builder/module/ned/VerticalDatum.java +++ b/application/src/main/java/org/opentripplanner/graph_builder/module/ned/VerticalDatum.java @@ -98,18 +98,10 @@ public static VerticalDatum fromGTX(InputStream inputStream) throws IOException double gridXFraction = longitudeNormalized * columns - x1; double gridYFraction = latitudeNormalized * rows - y1; return ( - datum[y1][x1] * - gridXFraction * - gridYFraction + - datum[y1][x1 + 1] * - (1 - gridXFraction) * - gridYFraction + - datum[y1 + 1][x1] * - gridXFraction * - (1 - gridYFraction) + - datum[y1 + 1][x1 + 1] * - (1 - gridXFraction) * - (1 - gridYFraction) + datum[y1][x1] * gridXFraction * gridYFraction + + datum[y1][x1 + 1] * (1 - gridXFraction) * gridYFraction + + datum[y1 + 1][x1] * gridXFraction * (1 - gridYFraction) + + datum[y1 + 1][x1 + 1] * (1 - gridXFraction) * (1 - gridYFraction) ); } diff --git a/application/src/main/java/org/opentripplanner/graph_builder/module/osm/ElevatorProcessor.java b/application/src/main/java/org/opentripplanner/graph_builder/module/osm/ElevatorProcessor.java index 6de97142a79..71a2f11f6f5 100644 --- a/application/src/main/java/org/opentripplanner/graph_builder/module/osm/ElevatorProcessor.java +++ b/application/src/main/java/org/opentripplanner/graph_builder/module/osm/ElevatorProcessor.java @@ -112,11 +112,11 @@ public void buildElevatorEdges(Graph graph) { while (elevators.hasNext()) { OsmWay elevatorWay = elevators.next(); - List nodes = Arrays - .stream(elevatorWay.getNodeRefs().toArray()) - .filter(nodeRef -> - vertexGenerator.intersectionNodes().containsKey(nodeRef) && - vertexGenerator.intersectionNodes().get(nodeRef) != null + List nodes = Arrays.stream(elevatorWay.getNodeRefs().toArray()) + .filter( + nodeRef -> + vertexGenerator.intersectionNodes().containsKey(nodeRef) && + vertexGenerator.intersectionNodes().get(nodeRef) != null ) .boxed() .toList(); @@ -223,17 +223,15 @@ private boolean isElevatorWay(OsmWay way) { } private OptionalInt parseDuration(OsmEntity element) { - return element.getTagAsInt( - "duration", - v -> - issueStore.add( - Issue.issue( - "InvalidDuration", - "Duration for osm node %d is not a number: '%s'; it's replaced with '-1' (unknown).", - element.getId(), - v - ) + return element.getTagAsInt("duration", v -> + issueStore.add( + Issue.issue( + "InvalidDuration", + "Duration for osm node %d is not a number: '%s'; it's replaced with '-1' (unknown).", + element.getId(), + v ) + ) ); } } diff --git a/application/src/main/java/org/opentripplanner/graph_builder/module/osm/EscalatorProcessor.java b/application/src/main/java/org/opentripplanner/graph_builder/module/osm/EscalatorProcessor.java index 40695e7c67c..9096b6eaa05 100644 --- a/application/src/main/java/org/opentripplanner/graph_builder/module/osm/EscalatorProcessor.java +++ b/application/src/main/java/org/opentripplanner/graph_builder/module/osm/EscalatorProcessor.java @@ -33,10 +33,9 @@ public EscalatorProcessor( } public void buildEscalatorEdge(OsmWay escalatorWay, double length) { - List nodes = Arrays - .stream(escalatorWay.getNodeRefs().toArray()) - .filter(nodeRef -> - intersectionNodes.containsKey(nodeRef) && intersectionNodes.get(nodeRef) != null + List nodes = Arrays.stream(escalatorWay.getNodeRefs().toArray()) + .filter( + nodeRef -> intersectionNodes.containsKey(nodeRef) && intersectionNodes.get(nodeRef) != null ) .boxed() .toList(); diff --git a/application/src/main/java/org/opentripplanner/graph_builder/module/osm/OsmArea.java b/application/src/main/java/org/opentripplanner/graph_builder/module/osm/OsmArea.java index bf732c78f6d..3ee7aae843e 100644 --- a/application/src/main/java/org/opentripplanner/graph_builder/module/osm/OsmArea.java +++ b/application/src/main/java/org/opentripplanner/graph_builder/module/osm/OsmArea.java @@ -61,7 +61,7 @@ class OsmArea { try { // now, ring grouping // first, find outermost rings - OUTER:for (Ring outer : outerRings) { + OUTER: for (Ring outer : outerRings) { for (Ring possibleContainer : outerRings) { if (outer != possibleContainer && outer.jtsPolygon.within(possibleContainer.jtsPolygon)) { continue OUTER; @@ -167,8 +167,7 @@ private MultiPolygon calculateJTSMultiPolygon() { for (Ring ring : outermostRings) { polygons.add(ring.jtsPolygon); } - MultiPolygon jtsMultiPolygon = GeometryUtils - .getGeometryFactory() + MultiPolygon jtsMultiPolygon = GeometryUtils.getGeometryFactory() .createMultiPolygon(polygons.toArray(new Polygon[0])); var validOp = new IsValidOp(jtsMultiPolygon); if (!validOp.isValid()) { diff --git a/application/src/main/java/org/opentripplanner/graph_builder/module/osm/OsmDatabase.java b/application/src/main/java/org/opentripplanner/graph_builder/module/osm/OsmDatabase.java index cb219daa28e..369c97eff6b 100644 --- a/application/src/main/java/org/opentripplanner/graph_builder/module/osm/OsmDatabase.java +++ b/application/src/main/java/org/opentripplanner/graph_builder/module/osm/OsmDatabase.java @@ -107,10 +107,12 @@ public class OsmDatabase { private final Map wayLevels = new HashMap<>(); /* Set of turn restrictions for each turn "from" way ID */ - private final Multimap turnRestrictionsByFromWay = ArrayListMultimap.create(); + private final Multimap turnRestrictionsByFromWay = + ArrayListMultimap.create(); /* Set of turn restrictions for each turn "to" way ID */ - private final Multimap turnRestrictionsByToWay = ArrayListMultimap.create(); + private final Multimap turnRestrictionsByToWay = + ArrayListMultimap.create(); /* * Map of all transit stop nodes that lie within an area and which are connected to the area by @@ -218,11 +220,9 @@ public void addNode(OsmNode node) { carParkingNodes.put(node.getId(), node); } if ( - !( - waysNodeIds.contains(node.getId()) || + !(waysNodeIds.contains(node.getId()) || areaNodeIds.contains(node.getId()) || - node.isBoardingLocation() - ) + node.isBoardingLocation()) ) { return; } @@ -279,8 +279,7 @@ public void addRelation(OsmRelation relation) { } if ( - relation.isMultiPolygon() && - (relation.isRoutable() || relation.isParkAndRide()) || + (relation.isMultiPolygon() && (relation.isRoutable() || relation.isParkAndRide())) || relation.isBikeParking() ) { // OSM MultiPolygons are ferociously complicated, and in fact cannot be processed @@ -647,12 +646,22 @@ private void applyLevelsForWay(OsmEntity way) { OsmLevel level = OsmLevel.DEFAULT; if (way.hasTag("level")) { // TODO: floating-point levels &c. levelName = way.getTag("level"); - level = - OsmLevel.fromString(levelName, OsmLevel.Source.LEVEL_TAG, noZeroLevels, issueStore, way); + level = OsmLevel.fromString( + levelName, + OsmLevel.Source.LEVEL_TAG, + noZeroLevels, + issueStore, + way + ); } else if (way.hasTag("layer")) { levelName = way.getTag("layer"); - level = - OsmLevel.fromString(levelName, OsmLevel.Source.LAYER_TAG, noZeroLevels, issueStore, way); + level = OsmLevel.fromString( + levelName, + OsmLevel.Source.LAYER_TAG, + noZeroLevels, + issueStore, + way + ); } if (level == null || (!level.reliable)) { issueStore.add(new LevelAmbiguous(levelName, way)); @@ -676,7 +685,7 @@ private void markNodesForKeeping(Collection osmWays, TLongSet nodeSet) { * Create areas from single ways. */ private void processSingleWayAreas() { - AREA:for (OsmWay way : singleWayAreas) { + AREA: for (OsmWay way : singleWayAreas) { if (processedAreas.contains(way)) { continue; } @@ -709,15 +718,13 @@ private void processSingleWayAreas() { * the used ways. */ private void processMultipolygonRelations() { - RELATION:for (OsmRelation relation : relationsById.valueCollection()) { + RELATION: for (OsmRelation relation : relationsById.valueCollection()) { if (processedAreas.contains(relation)) { continue; } if ( - !( - relation.isMultiPolygon() && - (relation.isRoutable() || relation.isParkAndRide() || relation.isBikeParking()) - ) + !(relation.isMultiPolygon() && + (relation.isRoutable() || relation.isParkAndRide() || relation.isBikeParking())) ) { continue; } @@ -887,48 +894,56 @@ private void processRestriction(OsmRelation relation) { TurnRestrictionTag tag; if (relation.isTag("restriction", "no_right_turn")) { - tag = - new TurnRestrictionTag(via, TurnRestrictionType.NO_TURN, Direction.RIGHT, relation.getId()); + tag = new TurnRestrictionTag( + via, + TurnRestrictionType.NO_TURN, + Direction.RIGHT, + relation.getId() + ); } else if (relation.isTag("restriction", "no_left_turn")) { - tag = - new TurnRestrictionTag(via, TurnRestrictionType.NO_TURN, Direction.LEFT, relation.getId()); + tag = new TurnRestrictionTag( + via, + TurnRestrictionType.NO_TURN, + Direction.LEFT, + relation.getId() + ); } else if (relation.isTag("restriction", "no_straight_on")) { - tag = - new TurnRestrictionTag( - via, - TurnRestrictionType.NO_TURN, - Direction.STRAIGHT, - relation.getId() - ); + tag = new TurnRestrictionTag( + via, + TurnRestrictionType.NO_TURN, + Direction.STRAIGHT, + relation.getId() + ); } else if (relation.isTag("restriction", "no_u_turn")) { tag = new TurnRestrictionTag(via, TurnRestrictionType.NO_TURN, Direction.U, relation.getId()); } else if (relation.isTag("restriction", "only_straight_on")) { - tag = - new TurnRestrictionTag( - via, - TurnRestrictionType.ONLY_TURN, - Direction.STRAIGHT, - relation.getId() - ); + tag = new TurnRestrictionTag( + via, + TurnRestrictionType.ONLY_TURN, + Direction.STRAIGHT, + relation.getId() + ); } else if (relation.isTag("restriction", "only_right_turn")) { - tag = - new TurnRestrictionTag( - via, - TurnRestrictionType.ONLY_TURN, - Direction.RIGHT, - relation.getId() - ); + tag = new TurnRestrictionTag( + via, + TurnRestrictionType.ONLY_TURN, + Direction.RIGHT, + relation.getId() + ); } else if (relation.isTag("restriction", "only_left_turn")) { - tag = - new TurnRestrictionTag( - via, - TurnRestrictionType.ONLY_TURN, - Direction.LEFT, - relation.getId() - ); + tag = new TurnRestrictionTag( + via, + TurnRestrictionType.ONLY_TURN, + Direction.LEFT, + relation.getId() + ); } else if (relation.isTag("restriction", "only_u_turn")) { - tag = - new TurnRestrictionTag(via, TurnRestrictionType.ONLY_TURN, Direction.U, relation.getId()); + tag = new TurnRestrictionTag( + via, + TurnRestrictionType.ONLY_TURN, + Direction.U, + relation.getId() + ); } else { issueStore.add(new TurnRestrictionUnknown(relation, relation.getTag("restriction"))); return; @@ -943,14 +958,13 @@ private void processRestriction(OsmRelation relation) { relation.hasTag("hour_off") ) { try { - tag.time = - RepeatingTimePeriod.parseFromOsmTurnRestriction( - relation.getTag("day_on"), - relation.getTag("day_off"), - relation.getTag("hour_on"), - relation.getTag("hour_off"), - relation.getOsmProvider()::getZoneId - ); + tag.time = RepeatingTimePeriod.parseFromOsmTurnRestriction( + relation.getTag("day_on"), + relation.getTag("day_off"), + relation.getTag("hour_on"), + relation.getTag("hour_off"), + relation.getOsmProvider()::getZoneId + ); } catch (NumberFormatException e) { LOG.info("Unparseable turn restriction: {}", relation.getId()); } diff --git a/application/src/main/java/org/opentripplanner/graph_builder/module/osm/OsmModule.java b/application/src/main/java/org/opentripplanner/graph_builder/module/osm/OsmModule.java index e48a6a00400..6c62c7fe587 100644 --- a/application/src/main/java/org/opentripplanner/graph_builder/module/osm/OsmModule.java +++ b/application/src/main/java/org/opentripplanner/graph_builder/module/osm/OsmModule.java @@ -83,13 +83,12 @@ public class OsmModule implements GraphBuilderModule { this.issueStore = issueStore; this.params = params; this.osmdb = new OsmDatabase(issueStore); - this.vertexGenerator = - new VertexGenerator( - osmdb, - graph, - params.boardingAreaRefTags(), - params.includeOsmSubwayEntrances() - ); + this.vertexGenerator = new VertexGenerator( + osmdb, + graph, + params.boardingAreaRefTags(), + params.includeOsmSubwayEntrances() + ); this.normalizer = new SafetyValueNormalizer(graph, issueStore); this.streetLimitationParameters = Objects.requireNonNull(streetLimitationParameters); } @@ -287,7 +286,7 @@ private void buildBasicGraph() { issueStore ); - WAY:for (OsmWay way : osmdb.getWays()) { + WAY: for (OsmWay way : osmdb.getWays()) { WayProperties wayData = way.getOsmProvider().getWayPropertySet().getDataForWay(way); setWayName(way); @@ -380,10 +379,8 @@ private void buildBasicGraph() { ) { segmentCoordinates.add(osmEndNode.getCoordinate()); - geometry = - GeometryUtils - .getGeometryFactory() - .createLineString(segmentCoordinates.toArray(new Coordinate[0])); + geometry = GeometryUtils.getGeometryFactory() + .createLineString(segmentCoordinates.toArray(new Coordinate[0])); segmentCoordinates.clear(); } else { segmentCoordinates.add(osmEndNode.getCoordinate()); @@ -553,30 +550,28 @@ private StreetEdgePair getEdgesForStreet( var permissionsBack = permissionPair.back(); if (permissionsFront.allowsAnything()) { - street = - getEdgeForStreet( - startEndpoint, - endEndpoint, - way, - index, - length, - permissionsFront, - geometry, - false - ); + street = getEdgeForStreet( + startEndpoint, + endEndpoint, + way, + index, + length, + permissionsFront, + geometry, + false + ); } if (permissionsBack.allowsAnything()) { - backStreet = - getEdgeForStreet( - endEndpoint, - startEndpoint, - way, - index, - length, - permissionsBack, - backGeometry, - true - ); + backStreet = getEdgeForStreet( + endEndpoint, + startEndpoint, + way, + index, + length, + permissionsBack, + backGeometry, + true + ); } if (street != null && backStreet != null) { backStreet.shareData(street); diff --git a/application/src/main/java/org/opentripplanner/graph_builder/module/osm/ParkingProcessor.java b/application/src/main/java/org/opentripplanner/graph_builder/module/osm/ParkingProcessor.java index 6e08e5930df..3e1714d2f0b 100644 --- a/application/src/main/java/org/opentripplanner/graph_builder/module/osm/ParkingProcessor.java +++ b/application/src/main/java/org/opentripplanner/graph_builder/module/osm/ParkingProcessor.java @@ -55,8 +55,10 @@ public ParkingProcessor( ) { this.issueStore = issueStore; this.getVertexForOsmNode = getVertexForOsmNode; - this.osmOpeningHoursParser = - new OsmOpeningHoursParser(graph.getOpeningHoursCalendarService(), issueStore); + this.osmOpeningHoursParser = new OsmOpeningHoursParser( + graph.getOpeningHoursCalendarService(), + issueStore + ); this.vertexFactory = new VertexFactory(graph); this.vehicleParkingHelper = new VehicleParkingHelper(graph); } @@ -259,11 +261,8 @@ private VehicleParking buildParkAndRideAreasForGroup( } } - List entrances = createParkingEntrancesFromAccessVertices( - accessVertices, - creativeName, - entity - ); + List entrances = + createParkingEntrancesFromAccessVertices(accessVertices, creativeName, entity); if (entrances.isEmpty()) { entrances = createArtificialEntrances(group, creativeName, entity, isCarParkAndRide); @@ -339,17 +338,15 @@ VehicleParking createVehicleParkingObjectFromOsmEntity( carCapacity.isPresent() || wheelchairAccessibleCarCapacity.isPresent() ) { - vehicleParkingSpaces = - VehicleParkingSpaces - .builder() - .bicycleSpaces(bicycleCapacity.isPresent() ? bicycleCapacity.getAsInt() : null) - .carSpaces(carCapacity.isPresent() ? carCapacity.getAsInt() : null) - .wheelchairAccessibleCarSpaces( - wheelchairAccessibleCarCapacity.isPresent() - ? wheelchairAccessibleCarCapacity.getAsInt() - : null - ) - .build(); + vehicleParkingSpaces = VehicleParkingSpaces.builder() + .bicycleSpaces(bicycleCapacity.isPresent() ? bicycleCapacity.getAsInt() : null) + .carSpaces(carCapacity.isPresent() ? carCapacity.getAsInt() : null) + .wheelchairAccessibleCarSpaces( + wheelchairAccessibleCarCapacity.isPresent() + ? wheelchairAccessibleCarCapacity.getAsInt() + : null + ) + .build(); } var bicyclePlaces = !isCarParkAndRide || bicycleCapacity.orElse(0) > 0; @@ -382,8 +379,7 @@ VehicleParking createVehicleParkingObjectFromOsmEntity( tags.add("osm:surveillance"); } - return VehicleParking - .builder() + return VehicleParking.builder() .id(id) .name(creativeName) .coordinate(new WgsCoordinate(coordinate)) @@ -404,14 +400,15 @@ private I18NString nameParkAndRideEntity(OsmEntity osmEntity) { I18NString creativeName = osmEntity.getAssumedName(); if (creativeName == null) { // ... otherwise resort to "CreativeNamer"s - creativeName = - osmEntity.getOsmProvider().getWayPropertySet().getCreativeNameForWay(osmEntity); + creativeName = osmEntity + .getOsmProvider() + .getWayPropertySet() + .getCreativeNameForWay(osmEntity); } if (creativeName == null) { - creativeName = - new NonLocalizedString( - "Park & Ride (%s/%d)".formatted(osmEntity.getClass().getSimpleName(), osmEntity.getId()) - ); + creativeName = new NonLocalizedString( + "Park & Ride (%s/%d)".formatted(osmEntity.getClass().getSimpleName(), osmEntity.getId()) + ); } return creativeName; } @@ -421,13 +418,14 @@ private OptionalInt parseCapacity(OsmEntity element) { } private OptionalInt parseCapacity(OsmEntity element, String capacityTag) { - return element.parseIntOrBoolean( - capacityTag, - v -> issueStore.add(new InvalidVehicleParkingCapacity(element, v)) + return element.parseIntOrBoolean(capacityTag, v -> + issueStore.add(new InvalidVehicleParkingCapacity(element, v)) ); } - private List createParkingEntrancesFromAccessVertices( + private List< + VehicleParking.VehicleParkingEntranceCreator + > createParkingEntrancesFromAccessVertices( Set accessVertices, I18NString vehicleParkingName, OsmEntity entity diff --git a/application/src/main/java/org/opentripplanner/graph_builder/module/osm/Ring.java b/application/src/main/java/org/opentripplanner/graph_builder/module/osm/Ring.java index e266980220c..9ccf7bb8480 100644 --- a/application/src/main/java/org/opentripplanner/graph_builder/module/osm/Ring.java +++ b/application/src/main/java/org/opentripplanner/graph_builder/module/osm/Ring.java @@ -52,8 +52,7 @@ public Ring(List osmNodes) { public Ring(TLongList osmNodes, TLongObjectMap _nodes) { // The collection needs to be mutable, so collect into an ArrayList this( - LongStream - .of(osmNodes.toArray()) + LongStream.of(osmNodes.toArray()) .mapToObj(_nodes::get) .collect(Collectors.toCollection(ArrayList::new)) ); @@ -77,10 +76,7 @@ boolean isNodeConvex(int i) { OsmNode prev = nodes.get((i + n - 1) % n); OsmNode next = nodes.get((i + 1) % n); return ( - (cur.lon - prev.lon) * - (next.lat - cur.lat) - - (cur.lat - prev.lat) * - (next.lon - cur.lon) > + (cur.lon - prev.lon) * (next.lat - cur.lat) - (cur.lat - prev.lat) * (next.lon - cur.lon) > 0.00000000001 ); } diff --git a/application/src/main/java/org/opentripplanner/graph_builder/module/osm/SafetyValueNormalizer.java b/application/src/main/java/org/opentripplanner/graph_builder/module/osm/SafetyValueNormalizer.java index f38e47c7242..92fb14dee12 100644 --- a/application/src/main/java/org/opentripplanner/graph_builder/module/osm/SafetyValueNormalizer.java +++ b/application/src/main/java/org/opentripplanner/graph_builder/module/osm/SafetyValueNormalizer.java @@ -84,9 +84,8 @@ void applyWayProperties( Set notes = way.getOsmProvider().getWayPropertySet().getNoteForWay(way); - boolean motorVehicleNoThrough = tagMapperForWay.isMotorVehicleThroughTrafficExplicitlyDisallowed( - way - ); + boolean motorVehicleNoThrough = + tagMapperForWay.isMotorVehicleThroughTrafficExplicitlyDisallowed(way); boolean bicycleNoThrough = tagMapperForWay.isBicycleThroughTrafficExplicitlyDisallowed(way); boolean walkNoThrough = tagMapperForWay.isWalkThroughTrafficExplicitlyDisallowed(way); diff --git a/application/src/main/java/org/opentripplanner/graph_builder/module/osm/VertexGenerator.java b/application/src/main/java/org/opentripplanner/graph_builder/module/osm/VertexGenerator.java index e397ae6d35e..c1aec357f20 100644 --- a/application/src/main/java/org/opentripplanner/graph_builder/module/osm/VertexGenerator.java +++ b/application/src/main/java/org/opentripplanner/graph_builder/module/osm/VertexGenerator.java @@ -86,13 +86,12 @@ IntersectionVertex getVertexForOsmNode(OsmNode node, OsmEntity way) { var refs = node.getMultiTagValues(boardingAreaRefTags); if (!refs.isEmpty()) { String name = node.getTag("name"); - iv = - vertexFactory.osmBoardingLocation( - coordinate, - label, - refs, - NonLocalizedString.ofNullable(name) - ); + iv = vertexFactory.osmBoardingLocation( + coordinate, + label, + refs, + NonLocalizedString.ofNullable(name) + ); } } @@ -108,13 +107,12 @@ IntersectionVertex getVertexForOsmNode(OsmNode node, OsmEntity way) { } if (iv == null) { - iv = - vertexFactory.osm( - coordinate, - node, - node.hasHighwayTrafficLight(), - node.hasCrossingTrafficLight() - ); + iv = vertexFactory.osm( + coordinate, + node, + node.hasHighwayTrafficLight(), + node.hasCrossingTrafficLight() + ); } intersectionNodes.put(nid, iv); diff --git a/application/src/main/java/org/opentripplanner/graph_builder/module/osm/WalkableAreaBuilder.java b/application/src/main/java/org/opentripplanner/graph_builder/module/osm/WalkableAreaBuilder.java index 432012ec94a..f9919d086eb 100644 --- a/application/src/main/java/org/opentripplanner/graph_builder/module/osm/WalkableAreaBuilder.java +++ b/application/src/main/java/org/opentripplanner/graph_builder/module/osm/WalkableAreaBuilder.java @@ -64,7 +64,8 @@ class WalkableAreaBuilder { private final VertexGenerator vertexBuilder; - private final HashMap areaBoundaryVertexForCoordinate = new HashMap<>(); + private final HashMap areaBoundaryVertexForCoordinate = + new HashMap<>(); private final boolean platformEntriesLinking; @@ -100,16 +101,15 @@ public WalkableAreaBuilder( this.maxAreaNodes = maxAreaNodes; this.platformEntriesLinking = platformEntriesLinking; this.boardingLocationRefTags = boardingLocationRefTags; - this.platformLinkingPoints = - platformEntriesLinking - ? graph - .getVertices() - .stream() - .filter(OsmVertex.class::isInstance) - .map(OsmVertex.class::cast) - .filter(this::isPlatformLinkingPoint) - .collect(Collectors.toList()) - : List.of(); + this.platformLinkingPoints = platformEntriesLinking + ? graph + .getVertices() + .stream() + .filter(OsmVertex.class::isInstance) + .map(OsmVertex.class::cast) + .filter(this::isPlatformLinkingPoint) + .collect(Collectors.toList()) + : List.of(); } /** @@ -145,8 +145,7 @@ public void buildWithoutVisibility(OsmAreaGroup group) { var vertices = edges .stream() .flatMap(v -> - Stream - .of(v.getFromVertex(), v.getToVertex()) + Stream.of(v.getFromVertex(), v.getToVertex()) .filter(IntersectionVertex.class::isInstance) .map(IntersectionVertex.class::cast) ) @@ -369,8 +368,7 @@ private void pruneAreaEdges( RouteRequest options = new RouteRequest(); Set usedEdges = new HashSet<>(); for (Vertex vertex : startingVertices) { - ShortestPathTree spt = StreetSearchBuilder - .of() + ShortestPathTree spt = StreetSearchBuilder.of() .setSkipEdgeStrategy(new ListedEdgesOnly(edges)) .setDominanceFunction(new DominanceFunctions.EarliestArrival()) .setRequest(options) diff --git a/application/src/main/java/org/opentripplanner/graph_builder/module/osm/naming/SidewalkNamer.java b/application/src/main/java/org/opentripplanner/graph_builder/module/osm/naming/SidewalkNamer.java index e4f05a095ad..5835d649bea 100644 --- a/application/src/main/java/org/opentripplanner/graph_builder/module/osm/naming/SidewalkNamer.java +++ b/application/src/main/java/org/opentripplanner/graph_builder/module/osm/naming/SidewalkNamer.java @@ -115,7 +115,7 @@ public void postprocess() { "Assigned names to {} of {} of sidewalks ({}%)", namesApplied.get(), unnamedSidewalks.size(), - DoubleUtils.roundTo2Decimals((double) namesApplied.get() / unnamedSidewalks.size() * 100) + DoubleUtils.roundTo2Decimals(((double) namesApplied.get() / unnamedSidewalks.size()) * 100) ); LOG.info(progress.completeMessage()); @@ -228,8 +228,7 @@ private record CandidateGroup(I18NString name, List edges, Set SphericalDistanceLibrary.length(ls); - case MultiLineString mls -> GeometryUtils - .getLineStrings(mls) + case MultiLineString mls -> GeometryUtils.getLineStrings(mls) .stream() .mapToDouble(this::intersectionLength) .sum(); diff --git a/application/src/main/java/org/opentripplanner/gtfs/GenerateTripPatternsOperation.java b/application/src/main/java/org/opentripplanner/gtfs/GenerateTripPatternsOperation.java index e647bc4cb9e..fbb41e430cd 100644 --- a/application/src/main/java/org/opentripplanner/gtfs/GenerateTripPatternsOperation.java +++ b/application/src/main/java/org/opentripplanner/gtfs/GenerateTripPatternsOperation.java @@ -50,10 +50,8 @@ public class GenerateTripPatternsOperation { // TODO the linked hashset configuration ensures that TripPatterns are created in the same order // as Trips are imported, as a workaround for issue #6067 - private final Multimap tripPatternBuilders = MultimapBuilder - .linkedHashKeys() - .linkedHashSetValues() - .build(); + private final Multimap tripPatternBuilders = + MultimapBuilder.linkedHashKeys().linkedHashSetValues().build(); private final ListMultimap frequenciesForTrip = ArrayListMultimap.create(); private int freqCount = 0; @@ -184,8 +182,7 @@ private TripPatternBuilder findOrCreateTripPattern(StopPattern stopPattern, Trip } } FeedScopedId patternId = generateUniqueIdForTripPattern(route, direction); - TripPatternBuilder tripPatternBuilder = TripPattern - .of(patternId) + TripPatternBuilder tripPatternBuilder = TripPattern.of(patternId) .withRoute(route) .withStopPattern(stopPattern) .withMode(trip.getMode()) diff --git a/application/src/main/java/org/opentripplanner/gtfs/graphbuilder/GtfsBundle.java b/application/src/main/java/org/opentripplanner/gtfs/graphbuilder/GtfsBundle.java index 1c606a6d0c3..9931ad28b7b 100644 --- a/application/src/main/java/org/opentripplanner/gtfs/graphbuilder/GtfsBundle.java +++ b/application/src/main/java/org/opentripplanner/gtfs/graphbuilder/GtfsBundle.java @@ -64,21 +64,20 @@ public GtfsBundle(ConfiguredDataSource configuredDataSource) public CsvInputSource getCsvInputSource() { if (csvInputSource == null) { - csvInputSource = - new CsvInputSource() { - @Override - public boolean hasResource(String s) { - return dataSource.content().stream().anyMatch(it -> it.name().equals(s)); - } - - @Override - public InputStream getResource(String s) { - return dataSource.entry(s).asInputStream(); - } - - @Override - public void close() {} - }; + csvInputSource = new CsvInputSource() { + @Override + public boolean hasResource(String s) { + return dataSource.content().stream().anyMatch(it -> it.name().equals(s)); + } + + @Override + public InputStream getResource(String s) { + return dataSource.entry(s).asInputStream(); + } + + @Override + public void close() {} + }; } return csvInputSource; } diff --git a/application/src/main/java/org/opentripplanner/gtfs/graphbuilder/GtfsModule.java b/application/src/main/java/org/opentripplanner/gtfs/graphbuilder/GtfsModule.java index 3548312b79a..52ed91d2bb9 100644 --- a/application/src/main/java/org/opentripplanner/gtfs/graphbuilder/GtfsModule.java +++ b/application/src/main/java/org/opentripplanner/gtfs/graphbuilder/GtfsModule.java @@ -196,8 +196,7 @@ public void buildGraph() { gtfsBundle.maxInterlineDistance(), issueStore, calendarServiceData - ) - .run(otpTransitService.getTripPatterns()); + ).run(otpTransitService.getTripPatterns()); } fareServiceFactory.processGtfs(fareRulesService, otpTransitService); @@ -264,8 +263,7 @@ private void validateAndInterpolateStopTimesForEachTrip( true, removeRepeatedStops, issueStore - ) - .run(); + ).run(); } /** diff --git a/application/src/main/java/org/opentripplanner/gtfs/interlining/InterlineProcessor.java b/application/src/main/java/org/opentripplanner/gtfs/interlining/InterlineProcessor.java index dbfe3af1c9b..e88761adae7 100644 --- a/application/src/main/java/org/opentripplanner/gtfs/interlining/InterlineProcessor.java +++ b/application/src/main/java/org/opentripplanner/gtfs/interlining/InterlineProcessor.java @@ -54,11 +54,10 @@ public InterlineProcessor( this.maxInterlineDistance = maxInterlineDistance > 0 ? maxInterlineDistance : 200; this.issueStore = issueStore; this.transitServiceStart = calendarServiceData.getFirstDate().orElse(null); - this.daysInTransitService = - calendarServiceData - .getLastDate() - .map(lastDate -> (int) ChronoUnit.DAYS.between(transitServiceStart, lastDate) + 1) - .orElse(0); + this.daysInTransitService = calendarServiceData + .getLastDate() + .map(lastDate -> (int) ChronoUnit.DAYS.between(transitServiceStart, lastDate) + 1) + .orElse(0); this.calendarServiceData = calendarServiceData; } @@ -110,8 +109,9 @@ private boolean staySeatedAllowed(Map.Entry p) { var toTrip = p.getValue().to(); return staySeatedNotAllowed .stream() - .noneMatch(t -> - t.fromTrip().getId().equals(fromTrip.getId()) && t.toTrip().getId().equals(toTrip.getId()) + .noneMatch( + t -> + t.fromTrip().getId().equals(fromTrip.getId()) && t.toTrip().getId().equals(toTrip.getId()) ); } diff --git a/application/src/main/java/org/opentripplanner/gtfs/mapping/AgencyMapper.java b/application/src/main/java/org/opentripplanner/gtfs/mapping/AgencyMapper.java index 5eaadd8881f..eed8248944a 100644 --- a/application/src/main/java/org/opentripplanner/gtfs/mapping/AgencyMapper.java +++ b/application/src/main/java/org/opentripplanner/gtfs/mapping/AgencyMapper.java @@ -28,8 +28,7 @@ Agency map(org.onebusaway.gtfs.model.Agency orginal) { } private Agency doMap(org.onebusaway.gtfs.model.Agency rhs) { - return Agency - .of(new FeedScopedId(feedId, rhs.getId())) + return Agency.of(new FeedScopedId(feedId, rhs.getId())) .withName(rhs.getName()) .withTimezone(rhs.getTimezone()) .withUrl(rhs.getUrl()) diff --git a/application/src/main/java/org/opentripplanner/gtfs/mapping/BoardingAreaMapper.java b/application/src/main/java/org/opentripplanner/gtfs/mapping/BoardingAreaMapper.java index d757a08d6df..2d0a0bd96ee 100644 --- a/application/src/main/java/org/opentripplanner/gtfs/mapping/BoardingAreaMapper.java +++ b/application/src/main/java/org/opentripplanner/gtfs/mapping/BoardingAreaMapper.java @@ -19,7 +19,8 @@ class BoardingAreaMapper { static final String DEFAULT_NAME = "Boarding area"; - private final Map mappedBoardingAreas = new HashMap<>(); + private final Map mappedBoardingAreas = + new HashMap<>(); private final TranslationHelper translationHelper; private final Function stationLookUp; @@ -50,8 +51,7 @@ private BoardingArea doMap(org.onebusaway.gtfs.model.Stop gtfsStop) { StopMappingWrapper base = new StopMappingWrapper(gtfsStop); - var builder = BoardingArea - .of(base.getId()) + var builder = BoardingArea.of(base.getId()) .withCode(base.getCode()) .withCoordinate(base.getCoordinate()) .withWheelchairAccessibility(base.getWheelchairAccessibility()) diff --git a/application/src/main/java/org/opentripplanner/gtfs/mapping/BookingRuleMapper.java b/application/src/main/java/org/opentripplanner/gtfs/mapping/BookingRuleMapper.java index 74efdd52202..2ed2bc4f1e5 100644 --- a/application/src/main/java/org/opentripplanner/gtfs/mapping/BookingRuleMapper.java +++ b/application/src/main/java/org/opentripplanner/gtfs/mapping/BookingRuleMapper.java @@ -23,27 +23,23 @@ BookingInfo map(BookingRule rule) { return null; } - return cachedBookingInfos.computeIfAbsent( - rule.getId(), - k -> - BookingInfo - .of() - .withContactInfo(contactInfo(rule)) - .withBookingMethods(bookingMethods()) - .withEarliestBookingTime(earliestBookingTime(rule)) - .withLatestBookingTime(latestBookingTime(rule)) - .withMinimumBookingNotice(minimumBookingNotice(rule)) - .withMaximumBookingNotice(maximumBookingNotice(rule)) - .withMessage(message(rule)) - .withPickupMessage(pickupMessage(rule)) - .withDropOffMessage(dropOffMessage(rule)) - .build() + return cachedBookingInfos.computeIfAbsent(rule.getId(), k -> + BookingInfo.of() + .withContactInfo(contactInfo(rule)) + .withBookingMethods(bookingMethods()) + .withEarliestBookingTime(earliestBookingTime(rule)) + .withLatestBookingTime(latestBookingTime(rule)) + .withMinimumBookingNotice(minimumBookingNotice(rule)) + .withMaximumBookingNotice(maximumBookingNotice(rule)) + .withMessage(message(rule)) + .withPickupMessage(pickupMessage(rule)) + .withDropOffMessage(dropOffMessage(rule)) + .build() ); } private ContactInfo contactInfo(BookingRule rule) { - return ContactInfo - .of() + return ContactInfo.of() .withPhoneNumber(rule.getPhoneNumber()) .withInfoUrl(rule.getInfoUrl()) .withBookingUrl(rule.getUrl()) diff --git a/application/src/main/java/org/opentripplanner/gtfs/mapping/EntranceMapper.java b/application/src/main/java/org/opentripplanner/gtfs/mapping/EntranceMapper.java index eb005ebd641..ec2600da113 100644 --- a/application/src/main/java/org/opentripplanner/gtfs/mapping/EntranceMapper.java +++ b/application/src/main/java/org/opentripplanner/gtfs/mapping/EntranceMapper.java @@ -48,8 +48,7 @@ private Entrance doMap(org.onebusaway.gtfs.model.Stop gtfsStop) { StopMappingWrapper base = new StopMappingWrapper(gtfsStop); - var builder = Entrance - .of(base.getId()) + var builder = Entrance.of(base.getId()) .withCode(base.getCode()) .withCoordinate(base.getCoordinate()) .withWheelchairAccessibility(base.getWheelchairAccessibility()) @@ -64,15 +63,14 @@ private Entrance doMap(org.onebusaway.gtfs.model.Stop gtfsStop) { ) ); - builder = - builder.withDescription( - translationHelper.getTranslation( - org.onebusaway.gtfs.model.Stop.class, - "desc", - base.getId().getId(), - base.getDescription() - ) - ); + builder = builder.withDescription( + translationHelper.getTranslation( + org.onebusaway.gtfs.model.Stop.class, + "desc", + base.getId().getId(), + base.getDescription() + ) + ); if (gtfsStop.getParentStation() != null) { builder.withParentStation(stationLookUp.apply(base.getParentStationId())); diff --git a/application/src/main/java/org/opentripplanner/gtfs/mapping/FareAttributeMapper.java b/application/src/main/java/org/opentripplanner/gtfs/mapping/FareAttributeMapper.java index 87b06edb82b..c4f58b62a31 100644 --- a/application/src/main/java/org/opentripplanner/gtfs/mapping/FareAttributeMapper.java +++ b/application/src/main/java/org/opentripplanner/gtfs/mapping/FareAttributeMapper.java @@ -15,7 +15,8 @@ /** Responsible for mapping GTFS FareAttribute into the OTP model. */ class FareAttributeMapper { - private final Map mappedStops = new HashMap<>(); + private final Map mappedStops = + new HashMap<>(); Collection map(Collection allStops) { return MapUtils.mapToList(allStops, this::map); @@ -31,8 +32,7 @@ private FareAttribute doMap(org.onebusaway.gtfs.model.FareAttribute rhs) { Currency.getInstance(rhs.getCurrencyType()), rhs.getPrice() ); - FareAttributeBuilder builder = FareAttribute - .of(mapAgencyAndId(rhs.getId())) + FareAttributeBuilder builder = FareAttribute.of(mapAgencyAndId(rhs.getId())) .setPrice(price) .setPaymentMethod(rhs.getPaymentMethod()); diff --git a/application/src/main/java/org/opentripplanner/gtfs/mapping/FareLegRuleMapper.java b/application/src/main/java/org/opentripplanner/gtfs/mapping/FareLegRuleMapper.java index 31fcf95d3cb..1985b79322f 100644 --- a/application/src/main/java/org/opentripplanner/gtfs/mapping/FareLegRuleMapper.java +++ b/application/src/main/java/org/opentripplanner/gtfs/mapping/FareLegRuleMapper.java @@ -36,8 +36,7 @@ public Collection map( if (!productsForRule.isEmpty()) { FareDistance fareDistance = createFareDistance(r); var ruleId = new FeedScopedId(fareProductId.getFeedId(), r.getId()); - return FareLegRule - .of(ruleId, productsForRule) + return FareLegRule.of(ruleId, productsForRule) .withLegGroupId(mapAgencyAndId(r.getLegGroupId())) .withNetworkId(r.getNetworkId()) .withFromAreaId(areaId(r.getFromArea())) @@ -79,28 +78,20 @@ private static FareDistance createFareDistance( fareLegRule.getMaxDistance().intValue() ); case 1 -> new FareDistance.LinearDistance( - Distance - .ofMetersBoxed( + Distance.ofMetersBoxed(fareLegRule.getMinDistance(), error -> + LOG.warn( + "Fare leg rule min distance not valid: {} - {}", fareLegRule.getMinDistance(), - error -> - LOG.warn( - "Fare leg rule min distance not valid: {} - {}", - fareLegRule.getMinDistance(), - error - ) + error ) - .orElse(null), - Distance - .ofMetersBoxed( + ).orElse(null), + Distance.ofMetersBoxed(fareLegRule.getMaxDistance(), error -> + LOG.warn( + "Fare leg rule max distance not valid: {} - {}", fareLegRule.getMaxDistance(), - error -> - LOG.warn( - "Fare leg rule max distance not valid: {} - {}", - fareLegRule.getMaxDistance(), - error - ) + error ) - .orElse(null) + ).orElse(null) ); default -> null; }; diff --git a/application/src/main/java/org/opentripplanner/gtfs/mapping/FrequencyMapper.java b/application/src/main/java/org/opentripplanner/gtfs/mapping/FrequencyMapper.java index 18927d67000..c2798b35d5a 100644 --- a/application/src/main/java/org/opentripplanner/gtfs/mapping/FrequencyMapper.java +++ b/application/src/main/java/org/opentripplanner/gtfs/mapping/FrequencyMapper.java @@ -11,7 +11,8 @@ class FrequencyMapper { private final TripMapper tripMapper; - private final Map mappedFrequencys = new HashMap<>(); + private final Map mappedFrequencys = + new HashMap<>(); FrequencyMapper(TripMapper tripMapper) { this.tripMapper = tripMapper; diff --git a/application/src/main/java/org/opentripplanner/gtfs/mapping/GTFSToOtpTransitServiceMapper.java b/application/src/main/java/org/opentripplanner/gtfs/mapping/GTFSToOtpTransitServiceMapper.java index 8e3718be4c6..247f1b87214 100644 --- a/application/src/main/java/org/opentripplanner/gtfs/mapping/GTFSToOtpTransitServiceMapper.java +++ b/application/src/main/java/org/opentripplanner/gtfs/mapping/GTFSToOtpTransitServiceMapper.java @@ -44,7 +44,8 @@ public class GTFSToOtpTransitServiceMapper { private final FareAttributeMapper fareAttributeMapper = new FareAttributeMapper(); - private final ServiceCalendarDateMapper serviceCalendarDateMapper = new ServiceCalendarDateMapper(); + private final ServiceCalendarDateMapper serviceCalendarDateMapper = + new ServiceCalendarDateMapper(); private final FeedInfoMapper feedInfoMapper; @@ -110,23 +111,29 @@ public GTFSToOtpTransitServiceMapper( pathwayNodeMapper = new PathwayNodeMapper(translationHelper, stationLookup); boardingAreaMapper = new BoardingAreaMapper(translationHelper, stopLookup); locationMapper = new LocationMapper(builder.siteRepository(), issueStore); - locationGroupMapper = - new LocationGroupMapper(stopMapper, locationMapper, builder.siteRepository()); - pathwayMapper = - new PathwayMapper(stopMapper, entranceMapper, pathwayNodeMapper, boardingAreaMapper); + locationGroupMapper = new LocationGroupMapper( + stopMapper, + locationMapper, + builder.siteRepository() + ); + pathwayMapper = new PathwayMapper( + stopMapper, + entranceMapper, + pathwayNodeMapper, + boardingAreaMapper + ); routeMapper = new RouteMapper(agencyMapper, issueStore, translationHelper); directionMapper = new DirectionMapper(issueStore); tripMapper = new TripMapper(routeMapper, directionMapper, translationHelper); bookingRuleMapper = new BookingRuleMapper(); - stopTimeMapper = - new StopTimeMapper( - stopMapper, - locationMapper, - locationGroupMapper, - tripMapper, - bookingRuleMapper, - translationHelper - ); + stopTimeMapper = new StopTimeMapper( + stopMapper, + locationMapper, + locationGroupMapper, + tripMapper, + bookingRuleMapper, + translationHelper + ); frequencyMapper = new FrequencyMapper(tripMapper); fareRuleMapper = new FareRuleMapper(routeMapper, fareAttributeMapper); fareProductMapper = new FareProductMapper(); diff --git a/application/src/main/java/org/opentripplanner/gtfs/mapping/PathwayMapper.java b/application/src/main/java/org/opentripplanner/gtfs/mapping/PathwayMapper.java index 3f5633a3da4..b8f83568f52 100644 --- a/application/src/main/java/org/opentripplanner/gtfs/mapping/PathwayMapper.java +++ b/application/src/main/java/org/opentripplanner/gtfs/mapping/PathwayMapper.java @@ -44,8 +44,7 @@ Pathway map(org.onebusaway.gtfs.model.Pathway orginal) { } private Pathway doMap(org.onebusaway.gtfs.model.Pathway rhs) { - PathwayBuilder pathway = Pathway - .of(AgencyAndIdMapper.mapAgencyAndId(rhs.getId())) + PathwayBuilder pathway = Pathway.of(AgencyAndIdMapper.mapAgencyAndId(rhs.getId())) .withPathwayMode(PathwayModeMapper.map(rhs.getPathwayMode())) .withFromStop(mapStationElement(rhs.getFromStop())) .withToStop(mapStationElement(rhs.getToStop())) diff --git a/application/src/main/java/org/opentripplanner/gtfs/mapping/PathwayNodeMapper.java b/application/src/main/java/org/opentripplanner/gtfs/mapping/PathwayNodeMapper.java index ab74d4c8e58..842d9f167aa 100644 --- a/application/src/main/java/org/opentripplanner/gtfs/mapping/PathwayNodeMapper.java +++ b/application/src/main/java/org/opentripplanner/gtfs/mapping/PathwayNodeMapper.java @@ -48,8 +48,7 @@ private PathwayNode doMap(org.onebusaway.gtfs.model.Stop gtfsStop) { } StopMappingWrapper base = new StopMappingWrapper(gtfsStop); - var builder = PathwayNode - .of(base.getId()) + var builder = PathwayNode.of(base.getId()) .withCode(base.getCode()) .withCoordinate(base.getCoordinate()) .withWheelchairAccessibility(base.getWheelchairAccessibility()) @@ -64,15 +63,14 @@ private PathwayNode doMap(org.onebusaway.gtfs.model.Stop gtfsStop) { ) ); - builder = - builder.withDescription( - translationHelper.getTranslation( - org.onebusaway.gtfs.model.Stop.class, - "desc", - base.getId().getId(), - base.getDescription() - ) - ); + builder = builder.withDescription( + translationHelper.getTranslation( + org.onebusaway.gtfs.model.Stop.class, + "desc", + base.getId().getId(), + base.getDescription() + ) + ); if (gtfsStop.getParentStation() != null) { builder.withParentStation(stationLookUp.apply(base.getParentStationId())); diff --git a/application/src/main/java/org/opentripplanner/gtfs/mapping/RouteMapper.java b/application/src/main/java/org/opentripplanner/gtfs/mapping/RouteMapper.java index 278ece825df..41a1c88355a 100644 --- a/application/src/main/java/org/opentripplanner/gtfs/mapping/RouteMapper.java +++ b/application/src/main/java/org/opentripplanner/gtfs/mapping/RouteMapper.java @@ -45,13 +45,12 @@ private Route doMap(org.onebusaway.gtfs.model.Route rhs) { var lhs = Route.of(AgencyAndIdMapper.mapAgencyAndId(rhs.getId())); I18NString longName = null; if (rhs.getLongName() != null) { - longName = - translationHelper.getTranslation( - org.onebusaway.gtfs.model.Route.class, - "longName", - rhs.getId().getId(), - rhs.getLongName() - ); + longName = translationHelper.getTranslation( + org.onebusaway.gtfs.model.Route.class, + "longName", + rhs.getId().getId(), + rhs.getLongName() + ); } lhs.withAgency(agencyMapper.map(rhs.getAgency())); lhs.withShortName(rhs.getShortName()); @@ -81,9 +80,9 @@ private Route doMap(org.onebusaway.gtfs.model.Route rhs) { lhs.withTextColor(rhs.getTextColor()); lhs.withBikesAllowed(BikeAccessMapper.mapForRoute(rhs)); if (rhs.getNetworkId() != null) { - var networkId = GroupOfRoutes - .of(new FeedScopedId(rhs.getId().getAgencyId(), rhs.getNetworkId())) - .build(); + var networkId = GroupOfRoutes.of( + new FeedScopedId(rhs.getId().getAgencyId(), rhs.getNetworkId()) + ).build(); lhs.getGroupsOfRoutes().add(networkId); } diff --git a/application/src/main/java/org/opentripplanner/gtfs/mapping/ServiceCalendarDateMapper.java b/application/src/main/java/org/opentripplanner/gtfs/mapping/ServiceCalendarDateMapper.java index 53e35380198..6563940d562 100644 --- a/application/src/main/java/org/opentripplanner/gtfs/mapping/ServiceCalendarDateMapper.java +++ b/application/src/main/java/org/opentripplanner/gtfs/mapping/ServiceCalendarDateMapper.java @@ -9,7 +9,10 @@ /** Responsible for mapping GTFS ServiceCalendarDate into the OTP model. */ class ServiceCalendarDateMapper { - private final Map mappedServiceDates = new HashMap<>(); + private final Map< + org.onebusaway.gtfs.model.ServiceCalendarDate, + ServiceCalendarDate + > mappedServiceDates = new HashMap<>(); Collection map( Collection allServiceDates diff --git a/application/src/main/java/org/opentripplanner/gtfs/mapping/ServiceCalendarMapper.java b/application/src/main/java/org/opentripplanner/gtfs/mapping/ServiceCalendarMapper.java index 0bb1f220a30..9b2759bed74 100644 --- a/application/src/main/java/org/opentripplanner/gtfs/mapping/ServiceCalendarMapper.java +++ b/application/src/main/java/org/opentripplanner/gtfs/mapping/ServiceCalendarMapper.java @@ -11,7 +11,8 @@ /** Responsible for mapping GTFS ServiceCalendar into the OTP model. */ class ServiceCalendarMapper { - private final Map mappedCalendars = new HashMap<>(); + private final Map mappedCalendars = + new HashMap<>(); Collection map( Collection allServiceCalendars diff --git a/application/src/main/java/org/opentripplanner/gtfs/mapping/ShapePointMapper.java b/application/src/main/java/org/opentripplanner/gtfs/mapping/ShapePointMapper.java index 8b24bc8f4ea..ec37f5db305 100644 --- a/application/src/main/java/org/opentripplanner/gtfs/mapping/ShapePointMapper.java +++ b/application/src/main/java/org/opentripplanner/gtfs/mapping/ShapePointMapper.java @@ -9,7 +9,8 @@ /** Responsible for mapping GTFS ShapePoint into the OTP model. */ class ShapePointMapper { - private final Map mappedShapePoints = new HashMap<>(); + private final Map mappedShapePoints = + new HashMap<>(); Collection map(Collection allShapePoints) { return MapUtils.mapToList(allShapePoints, this::map); diff --git a/application/src/main/java/org/opentripplanner/gtfs/mapping/StationMapper.java b/application/src/main/java/org/opentripplanner/gtfs/mapping/StationMapper.java index 1308994c414..3f8f9a4e319 100644 --- a/application/src/main/java/org/opentripplanner/gtfs/mapping/StationMapper.java +++ b/application/src/main/java/org/opentripplanner/gtfs/mapping/StationMapper.java @@ -50,8 +50,7 @@ private Station doMap(Stop rhs) { ) ); } - StationBuilder builder = Station - .of(mapAgencyAndId(rhs.getId())) + StationBuilder builder = Station.of(mapAgencyAndId(rhs.getId())) .withCoordinate(WgsCoordinateMapper.mapToDomain(rhs)) .withCode(rhs.getCode()); diff --git a/application/src/main/java/org/opentripplanner/gtfs/mapping/StopTimeMapper.java b/application/src/main/java/org/opentripplanner/gtfs/mapping/StopTimeMapper.java index 2b1d30c09bd..b695b06ab59 100644 --- a/application/src/main/java/org/opentripplanner/gtfs/mapping/StopTimeMapper.java +++ b/application/src/main/java/org/opentripplanner/gtfs/mapping/StopTimeMapper.java @@ -74,14 +74,13 @@ private StopTime doMap(org.onebusaway.gtfs.model.StopTime rhs) { I18NString stopHeadsign = null; if (rhs.getStopHeadsign() != null) { - stopHeadsign = - translationHelper.getTranslation( - org.onebusaway.gtfs.model.StopTime.class, - "stopHeadsign", - rhs.getTrip().getId().toString(), - Integer.toString(rhs.getStopSequence()), - rhs.getStopHeadsign() - ); + stopHeadsign = translationHelper.getTranslation( + org.onebusaway.gtfs.model.StopTime.class, + "stopHeadsign", + rhs.getTrip().getId().toString(), + Integer.toString(rhs.getStopSequence()), + rhs.getStopHeadsign() + ); } lhs.setArrivalTime(rhs.getArrivalTime()); diff --git a/application/src/main/java/org/opentripplanner/gtfs/mapping/TranslationHelper.java b/application/src/main/java/org/opentripplanner/gtfs/mapping/TranslationHelper.java index ce61c01b05e..7f1c62f48a0 100644 --- a/application/src/main/java/org/opentripplanner/gtfs/mapping/TranslationHelper.java +++ b/application/src/main/java/org/opentripplanner/gtfs/mapping/TranslationHelper.java @@ -116,8 +116,7 @@ I18NString getTranslation( // Fields with default name are initialized with an empty string. // Without any configuration, no annotation is used. - String csvFieldName = Optional - .ofNullable(field.getAnnotation(CsvField.class)) + String csvFieldName = Optional.ofNullable(field.getAnnotation(CsvField.class)) .map(CsvField::name) .orElse(""); diff --git a/application/src/main/java/org/opentripplanner/gtfs/mapping/TripMapper.java b/application/src/main/java/org/opentripplanner/gtfs/mapping/TripMapper.java index 7b1614aa4d5..9bd07e3391d 100644 --- a/application/src/main/java/org/opentripplanner/gtfs/mapping/TripMapper.java +++ b/application/src/main/java/org/opentripplanner/gtfs/mapping/TripMapper.java @@ -57,13 +57,12 @@ private Trip doMap(org.onebusaway.gtfs.model.Trip rhs) { lhs.withShortName(rhs.getTripShortName()); I18NString tripHeadsign = null; if (rhs.getTripHeadsign() != null) { - tripHeadsign = - translationHelper.getTranslation( - org.onebusaway.gtfs.model.Trip.class, - "tripHeadsign", - rhs.getId().getId(), - rhs.getTripHeadsign() - ); + tripHeadsign = translationHelper.getTranslation( + org.onebusaway.gtfs.model.Trip.class, + "tripHeadsign", + rhs.getId().getId(), + rhs.getTripHeadsign() + ); } lhs.withHeadsign(tripHeadsign); lhs.withDirection(directionMapper.map(rhs.getDirectionId(), lhs.getId())); diff --git a/application/src/main/java/org/opentripplanner/inspector/vector/VectorTileResponseFactory.java b/application/src/main/java/org/opentripplanner/inspector/vector/VectorTileResponseFactory.java index e0df4aa0d91..1c4a9f19bbd 100644 --- a/application/src/main/java/org/opentripplanner/inspector/vector/VectorTileResponseFactory.java +++ b/application/src/main/java/org/opentripplanner/inspector/vector/VectorTileResponseFactory.java @@ -38,8 +38,7 @@ public static > Response create( .map(LayerParameters::name) .collect(Collectors.toSet()); if (!availableLayerNames.containsAll(requestedLayers)) { - return Response - .status(Response.Status.NOT_FOUND) + return Response.status(Response.Status.NOT_FOUND) .header(HttpHeaders.CONTENT_TYPE, HttpUtils.TEXT_PLAIN) .entity( "Could not find vector tile layer(s). Requested layers: %s. Available layers: %s.".formatted( @@ -68,8 +67,7 @@ public static > Response create( if (cacheMaxSeconds != Integer.MAX_VALUE) { cacheControl.setMaxAge(cacheMaxSeconds); } - return Response - .status(Response.Status.OK) + return Response.status(Response.Status.OK) .cacheControl(cacheControl) .entity(mvtBuilder.build().toByteArray()) .build(); diff --git a/application/src/main/java/org/opentripplanner/inspector/vector/stop/GroupStopLayerBuilder.java b/application/src/main/java/org/opentripplanner/inspector/vector/stop/GroupStopLayerBuilder.java index 1e66397bc05..33ae72b922f 100644 --- a/application/src/main/java/org/opentripplanner/inspector/vector/stop/GroupStopLayerBuilder.java +++ b/application/src/main/java/org/opentripplanner/inspector/vector/stop/GroupStopLayerBuilder.java @@ -31,16 +31,15 @@ public GroupStopLayerBuilder( ); // Because there are very few GroupStops with relevant geometries, we can precompute the // geometries and store them in a list at the time of construction. - this.geometries = - groupStops - .stream() - .filter(groupStop -> groupStop.getEncompassingAreaGeometry().isPresent()) - .map(stop -> { - Geometry geometry = stop.getEncompassingAreaGeometry().get().copy(); - geometry.setUserData(stop); - return geometry; - }) - .toList(); + this.geometries = groupStops + .stream() + .filter(groupStop -> groupStop.getEncompassingAreaGeometry().isPresent()) + .map(stop -> { + Geometry geometry = stop.getEncompassingAreaGeometry().get().copy(); + geometry.setUserData(stop); + return geometry; + }) + .toList(); } @Override diff --git a/application/src/main/java/org/opentripplanner/inspector/vector/vertex/VertexPropertyMapper.java b/application/src/main/java/org/opentripplanner/inspector/vector/vertex/VertexPropertyMapper.java index adb2e68df1e..8abdfa217ee 100644 --- a/application/src/main/java/org/opentripplanner/inspector/vector/vertex/VertexPropertyMapper.java +++ b/application/src/main/java/org/opentripplanner/inspector/vector/vertex/VertexPropertyMapper.java @@ -66,24 +66,23 @@ private Set traversalPermissions(VehicleParkingEntrance entrance) } private Double findElevationForVertex(Vertex v) { - return Stream - .concat( - v - .getIncomingStreetEdges() - .stream() - .filter(StreetEdge::hasElevationExtension) - .map(streetEdge -> - streetEdge - .getElevationProfile() - .getCoordinate(streetEdge.getElevationProfile().size() - 1) - .y - ), - v - .getOutgoingStreetEdges() - .stream() - .filter(StreetEdge::hasElevationExtension) - .map(streetEdge -> streetEdge.getElevationProfile().getCoordinate(0).y) - ) + return Stream.concat( + v + .getIncomingStreetEdges() + .stream() + .filter(StreetEdge::hasElevationExtension) + .map(streetEdge -> + streetEdge + .getElevationProfile() + .getCoordinate(streetEdge.getElevationProfile().size() - 1) + .y + ), + v + .getOutgoingStreetEdges() + .stream() + .filter(StreetEdge::hasElevationExtension) + .map(streetEdge -> streetEdge.getElevationProfile().getCoordinate(0).y) + ) .findAny() .orElse(null); } diff --git a/application/src/main/java/org/opentripplanner/model/Frequency.java b/application/src/main/java/org/opentripplanner/model/Frequency.java index fd50219d865..cff7b6ff241 100644 --- a/application/src/main/java/org/opentripplanner/model/Frequency.java +++ b/application/src/main/java/org/opentripplanner/model/Frequency.java @@ -92,8 +92,7 @@ public boolean equals(Object o) { } public String toString() { - return ToStringBuilder - .of(Frequency.class) + return ToStringBuilder.of(Frequency.class) .addObjOp("trip", trip, AbstractTransitEntity::getId) .addServiceTime("start", startTime) .addServiceTime("end", endTime) diff --git a/application/src/main/java/org/opentripplanner/model/PathTransfer.java b/application/src/main/java/org/opentripplanner/model/PathTransfer.java index c4676fdf06f..260e9e75320 100644 --- a/application/src/main/java/org/opentripplanner/model/PathTransfer.java +++ b/application/src/main/java/org/opentripplanner/model/PathTransfer.java @@ -69,8 +69,7 @@ public PathTransfer withAddedMode(StreetMode mode) { @Override public String toString() { - return ToStringBuilder - .of(getClass()) + return ToStringBuilder.of(getClass()) .addObj("from", from) .addObj("to", to) .addNum("distance", distanceMeters) diff --git a/application/src/main/java/org/opentripplanner/model/SystemNotice.java b/application/src/main/java/org/opentripplanner/model/SystemNotice.java index 6e6b910665a..394c9cc9d36 100644 --- a/application/src/main/java/org/opentripplanner/model/SystemNotice.java +++ b/application/src/main/java/org/opentripplanner/model/SystemNotice.java @@ -41,8 +41,7 @@ public String text() { @Override public String toString() { - return ToStringBuilder - .of(SystemNotice.class) + return ToStringBuilder.of(SystemNotice.class) .addStr("tag", tag) .addStr("text", text) .toString(); diff --git a/application/src/main/java/org/opentripplanner/model/Timetable.java b/application/src/main/java/org/opentripplanner/model/Timetable.java index e4906de2673..936e0388592 100644 --- a/application/src/main/java/org/opentripplanner/model/Timetable.java +++ b/application/src/main/java/org/opentripplanner/model/Timetable.java @@ -187,8 +187,7 @@ static Direction getDirection( Collection scheduledTripTimes, Collection frequencies ) { - return Optional - .ofNullable(getRepresentativeTripTimes(scheduledTripTimes, frequencies)) + return Optional.ofNullable(getRepresentativeTripTimes(scheduledTripTimes, frequencies)) .map(TripTimes::getTrip) .map(Trip::getDirection) .orElse(Direction.UNKNOWN); diff --git a/application/src/main/java/org/opentripplanner/model/TimetableSnapshot.java b/application/src/main/java/org/opentripplanner/model/TimetableSnapshot.java index 4f0e842e054..40793ba2398 100644 --- a/application/src/main/java/org/opentripplanner/model/TimetableSnapshot.java +++ b/application/src/main/java/org/opentripplanner/model/TimetableSnapshot.java @@ -143,7 +143,10 @@ public class TimetableSnapshot { private final Map realTimeAddedPatternForTrip; private final Multimap realTimeAddedPatternsForRoute; private final Map realTimeAddedTripOnServiceDateById; - private final Map realTimeAddedTripOnServiceDateForTripAndDay; + private final Map< + TripIdAndServiceDate, + TripOnServiceDate + > realTimeAddedTripOnServiceDateForTripAndDay; /** * Boolean value indicating that timetable snapshot is read only if true. Once it is true, it @@ -517,9 +520,8 @@ public boolean purgeExpiredData(LocalDate serviceDate) { // Also remove last added trip pattern for days that are purged for ( - Iterator> iterator = realTimeNewTripPatternsForModifiedTrips - .entrySet() - .iterator(); + Iterator> iterator = + realTimeNewTripPatternsForModifiedTrips.entrySet().iterator(); iterator.hasNext(); ) { TripIdAndServiceDate tripIdAndServiceDate = iterator.next().getKey(); @@ -658,8 +660,7 @@ private void validateNotReadOnly() { } private TripOnServiceDate mapToTripOnServiceDate(TripTimes tripTimes, Timetable timetable) { - return TripOnServiceDate - .of(tripTimes.getTrip().getId()) + return TripOnServiceDate.of(tripTimes.getTrip().getId()) .withServiceDate(timetable.getServiceDate()) .withTrip(tripTimes.getTrip()) .build(); diff --git a/application/src/main/java/org/opentripplanner/model/calendar/CalendarServiceData.java b/application/src/main/java/org/opentripplanner/model/calendar/CalendarServiceData.java index 81011f03bd0..cf9298f1b21 100644 --- a/application/src/main/java/org/opentripplanner/model/calendar/CalendarServiceData.java +++ b/application/src/main/java/org/opentripplanner/model/calendar/CalendarServiceData.java @@ -89,9 +89,8 @@ private static List sortedImmutableList(Collection c) { private void addDatesToServiceIdsByDate(FeedScopedId serviceId, List serviceDates) { for (LocalDate serviceDate : serviceDates) { - Set serviceIds = serviceIdsByDate.computeIfAbsent( - serviceDate, - k -> new HashSet<>() + Set serviceIds = serviceIdsByDate.computeIfAbsent(serviceDate, k -> + new HashSet<>() ); serviceIds.add(serviceId); } diff --git a/application/src/main/java/org/opentripplanner/model/calendar/ServiceCalendarDate.java b/application/src/main/java/org/opentripplanner/model/calendar/ServiceCalendarDate.java index 9d6ddb748cf..a5eb93c64a2 100644 --- a/application/src/main/java/org/opentripplanner/model/calendar/ServiceCalendarDate.java +++ b/application/src/main/java/org/opentripplanner/model/calendar/ServiceCalendarDate.java @@ -80,8 +80,7 @@ public boolean equals(Object o) { @Override public String toString() { - return ToStringBuilder - .of(ServiceCalendarDate.class) + return ToStringBuilder.of(ServiceCalendarDate.class) .addObj("serviceId", this.serviceId) .addObj("date", this.date) .addObj("exception", this.exceptionType) diff --git a/application/src/main/java/org/opentripplanner/model/calendar/impl/CalendarServiceDataFactoryImpl.java b/application/src/main/java/org/opentripplanner/model/calendar/impl/CalendarServiceDataFactoryImpl.java index 9237398e45b..11e311f680b 100644 --- a/application/src/main/java/org/opentripplanner/model/calendar/impl/CalendarServiceDataFactoryImpl.java +++ b/application/src/main/java/org/opentripplanner/model/calendar/impl/CalendarServiceDataFactoryImpl.java @@ -38,10 +38,12 @@ private CalendarServiceDataFactoryImpl( Collection calendarDates, Collection serviceCalendars ) { - this.calendarDatesByServiceId = - calendarDates.stream().collect(groupingBy(ServiceCalendarDate::getServiceId)); - this.calendarsByServiceId = - serviceCalendars.stream().collect(groupingBy(ServiceCalendar::getServiceId)); + this.calendarDatesByServiceId = calendarDates + .stream() + .collect(groupingBy(ServiceCalendarDate::getServiceId)); + this.calendarsByServiceId = serviceCalendars + .stream() + .collect(groupingBy(ServiceCalendar::getServiceId)); this.serviceIds = merge(calendarDatesByServiceId.keySet(), calendarsByServiceId.keySet()); } diff --git a/application/src/main/java/org/opentripplanner/model/calendar/openinghours/OHCalendar.java b/application/src/main/java/org/opentripplanner/model/calendar/openinghours/OHCalendar.java index 1881ed72dcc..f3d6026a436 100644 --- a/application/src/main/java/org/opentripplanner/model/calendar/openinghours/OHCalendar.java +++ b/application/src/main/java/org/opentripplanner/model/calendar/openinghours/OHCalendar.java @@ -69,8 +69,7 @@ public boolean equals(Object o) { @Override public String toString() { - return ToStringBuilder - .of(OHCalendar.class) + return ToStringBuilder.of(OHCalendar.class) .addObj("zoneId", zoneId) .addCol("openingHours", openingHours) .toString(); diff --git a/application/src/main/java/org/opentripplanner/model/fare/FareProduct.java b/application/src/main/java/org/opentripplanner/model/fare/FareProduct.java index 8aa86e5af89..dd3dfb678d1 100644 --- a/application/src/main/java/org/opentripplanner/model/fare/FareProduct.java +++ b/application/src/main/java/org/opentripplanner/model/fare/FareProduct.java @@ -48,8 +48,7 @@ public boolean coversDuration(Duration journeyDuration) { @Override public String toString() { - return ToStringBuilder - .of(FareProduct.class) + return ToStringBuilder.of(FareProduct.class) .addStr("id", id.toString()) .addStr("name", name) .addObj("amount", price) diff --git a/application/src/main/java/org/opentripplanner/model/fare/ItineraryFares.java b/application/src/main/java/org/opentripplanner/model/fare/ItineraryFares.java index d39180ac3a9..47ab07ffb17 100644 --- a/application/src/main/java/org/opentripplanner/model/fare/ItineraryFares.java +++ b/application/src/main/java/org/opentripplanner/model/fare/ItineraryFares.java @@ -76,8 +76,7 @@ public boolean equals(Object o) { @Override public String toString() { - return ToStringBuilder - .of(this.getClass()) + return ToStringBuilder.of(this.getClass()) .addObj("itineraryProducts", itineraryProducts) .addObj("legProducts", legProducts) .toString(); diff --git a/application/src/main/java/org/opentripplanner/model/impl/OtpTransitServiceBuilder.java b/application/src/main/java/org/opentripplanner/model/impl/OtpTransitServiceBuilder.java index 41af51d6f9d..89942c8d528 100644 --- a/application/src/main/java/org/opentripplanner/model/impl/OtpTransitServiceBuilder.java +++ b/application/src/main/java/org/opentripplanner/model/impl/OtpTransitServiceBuilder.java @@ -80,7 +80,8 @@ public class OtpTransitServiceBuilder { private final SiteRepositoryBuilder siteRepositoryBuilder; - private final Multimap noticeAssignments = ArrayListMultimap.create(); + private final Multimap noticeAssignments = + ArrayListMultimap.create(); private final EntityById operatorsById = new DefaultEntityById<>(); @@ -114,7 +115,8 @@ public class OtpTransitServiceBuilder { private final EntityById brandingsById = new DefaultEntityById<>(); - private final Multimap groupsOfRoutesByRouteId = ArrayListMultimap.create(); + private final Multimap groupsOfRoutesByRouteId = + ArrayListMultimap.create(); private final EntityById tripOnServiceDates = new DefaultEntityById<>(); diff --git a/application/src/main/java/org/opentripplanner/model/impl/OtpTransitServiceImpl.java b/application/src/main/java/org/opentripplanner/model/impl/OtpTransitServiceImpl.java index 6f2ec4f4a2f..de14860cd86 100644 --- a/application/src/main/java/org/opentripplanner/model/impl/OtpTransitServiceImpl.java +++ b/application/src/main/java/org/opentripplanner/model/impl/OtpTransitServiceImpl.java @@ -93,8 +93,9 @@ class OtpTransitServiceImpl implements OtpTransitService { this.tripPatterns = immutableList(builder.getTripPatterns().values()); this.trips = immutableList(builder.getTripsById().values()); this.flexTrips = immutableList(builder.getFlexTripsById().values()); - this.stopsByScheduledStopPoint = - Collections.unmodifiableMap(builder.stopsByScheduledStopPoints()); + this.stopsByScheduledStopPoint = Collections.unmodifiableMap( + builder.stopsByScheduledStopPoints() + ); } @Override diff --git a/application/src/main/java/org/opentripplanner/model/modes/AllowMainAndSubModeFilter.java b/application/src/main/java/org/opentripplanner/model/modes/AllowMainAndSubModeFilter.java index a6f75ac0ed9..7b1a3e13ce1 100644 --- a/application/src/main/java/org/opentripplanner/model/modes/AllowMainAndSubModeFilter.java +++ b/application/src/main/java/org/opentripplanner/model/modes/AllowMainAndSubModeFilter.java @@ -61,8 +61,7 @@ public boolean equals(Object o) { @Override public String toString() { - return ToStringBuilder - .of(AllowMainAndSubModeFilter.class) + return ToStringBuilder.of(AllowMainAndSubModeFilter.class) .addEnum("mainMode", mainMode) .addObj("subMode", subMode) .toString(); diff --git a/application/src/main/java/org/opentripplanner/model/modes/AllowMainAndSubModesFilter.java b/application/src/main/java/org/opentripplanner/model/modes/AllowMainAndSubModesFilter.java index 5d40b365204..bff056fdd99 100644 --- a/application/src/main/java/org/opentripplanner/model/modes/AllowMainAndSubModesFilter.java +++ b/application/src/main/java/org/opentripplanner/model/modes/AllowMainAndSubModesFilter.java @@ -58,14 +58,12 @@ public boolean equals(Object o) { public String toString() { // Sort the list of sub-modes to make sure the order is the same every time, this // allows using the toString in tests - List subModes = SubMode - .getByIndex(this.subModes) + List subModes = SubMode.getByIndex(this.subModes) .stream() .sorted(Comparator.comparing(SubMode::name)) .toList(); - return ToStringBuilder - .of(AllowMainAndSubModesFilter.class) + return ToStringBuilder.of(AllowMainAndSubModesFilter.class) .addEnum("mainMode", mainMode) .addCol("subModes", subModes) .toString(); diff --git a/application/src/main/java/org/opentripplanner/model/modes/FilterFactory.java b/application/src/main/java/org/opentripplanner/model/modes/FilterFactory.java index 57d4bb8e02b..b32cf7b5536 100644 --- a/application/src/main/java/org/opentripplanner/model/modes/FilterFactory.java +++ b/application/src/main/java/org/opentripplanner/model/modes/FilterFactory.java @@ -70,8 +70,9 @@ static AllowTransitModeFilter create(Collection allowedModes) { } // else ignore empty list - var subModeFiltersByMainMode = stream(map, AllowMainAndSubModeFilter.class) - .collect(Collectors.groupingBy(AllowMainAndSubModeFilter::mainMode)); + var subModeFiltersByMainMode = stream(map, AllowMainAndSubModeFilter.class).collect( + Collectors.groupingBy(AllowMainAndSubModeFilter::mainMode) + ); var mainModes = mainModeFilters.isEmpty() ? EnumSet.noneOf(TransitMode.class) diff --git a/application/src/main/java/org/opentripplanner/model/plan/Itinerary.java b/application/src/main/java/org/opentripplanner/model/plan/Itinerary.java index 5ff936f3118..55f268701ae 100644 --- a/application/src/main/java/org/opentripplanner/model/plan/Itinerary.java +++ b/application/src/main/java/org/opentripplanner/model/plan/Itinerary.java @@ -324,17 +324,16 @@ public List getLegs() { * NOTE: The itinerary is mutable so the transformation is done in-place! */ public void transformTransitLegs(Function mapper) { - legs = - legs - .stream() - .map(l -> { - if (l instanceof TransitLeg tl) { - return mapper.apply(tl); - } else { - return l; - } - }) - .toList(); + legs = legs + .stream() + .map(l -> { + if (l instanceof TransitLeg tl) { + return mapper.apply(tl); + } else { + return l; + } + }) + .toList(); } public Stream getStreetLegs() { @@ -646,8 +645,7 @@ public final boolean equals(Object o) { @Override public String toString() { - return ToStringBuilder - .of(Itinerary.class) + return ToStringBuilder.of(Itinerary.class) .addStr("from", firstLeg().getFrom().toStringShort()) .addStr("to", lastLeg().getTo().toStringShort()) .addTime("start", firstLeg().getStartTime()) diff --git a/application/src/main/java/org/opentripplanner/model/plan/ItinerarySortKey.java b/application/src/main/java/org/opentripplanner/model/plan/ItinerarySortKey.java index 6df5d828633..4ea9fce5215 100644 --- a/application/src/main/java/org/opentripplanner/model/plan/ItinerarySortKey.java +++ b/application/src/main/java/org/opentripplanner/model/plan/ItinerarySortKey.java @@ -21,8 +21,7 @@ public interface ItinerarySortKey { boolean isOnStreetAllTheWay(); default String keyAsString() { - return ValueObjectToStringBuilder - .of() + return ValueObjectToStringBuilder.of() .addText("[") .addTime(startTimeAsInstant()) .addText(", ") diff --git a/application/src/main/java/org/opentripplanner/model/plan/Place.java b/application/src/main/java/org/opentripplanner/model/plan/Place.java index 4e2e2a425f1..5323087a767 100644 --- a/application/src/main/java/org/opentripplanner/model/plan/Place.java +++ b/application/src/main/java/org/opentripplanner/model/plan/Place.java @@ -144,8 +144,7 @@ public static Place forVehicleParkingEntrance(VehicleParkingEntranceVertex verte VertexType.VEHICLEPARKING, null, null, - VehicleParkingWithEntrance - .builder() + VehicleParkingWithEntrance.builder() .vehicleParking(vertex.getVehicleParking()) .entrance(vertex.getParkingEntrance()) .realtime(realTime) @@ -184,8 +183,7 @@ public String toStringShort() { @Override public String toString() { - return ToStringBuilder - .of(Place.class) + return ToStringBuilder.of(Place.class) .addObj("name", name) .addObj("stop", stop) .addObj("coordinate", coordinate) diff --git a/application/src/main/java/org/opentripplanner/model/plan/ScheduledTransitLeg.java b/application/src/main/java/org/opentripplanner/model/plan/ScheduledTransitLeg.java index 387cfd673ef..512be3d5ee4 100644 --- a/application/src/main/java/org/opentripplanner/model/plan/ScheduledTransitLeg.java +++ b/application/src/main/java/org/opentripplanner/model/plan/ScheduledTransitLeg.java @@ -91,14 +91,12 @@ protected ScheduledTransitLeg(ScheduledTransitLegBuilder builder) { ); this.legGeometry = GeometryUtils.makeLineString(transitLegCoordinates); - this.distanceMeters = - DoubleUtils.roundTo2Decimals( - Objects.requireNonNull(builder.distanceMeters(), "distanceMeters") - ); - this.directDistanceMeters = - GeometryUtils.sumDistances( - List.of(transitLegCoordinates.getFirst(), transitLegCoordinates.getLast()) - ); + this.distanceMeters = DoubleUtils.roundTo2Decimals( + Objects.requireNonNull(builder.distanceMeters(), "distanceMeters") + ); + this.directDistanceMeters = GeometryUtils.sumDistances( + List.of(transitLegCoordinates.getFirst(), transitLegCoordinates.getLast()) + ); this.transitAlerts = Set.copyOf(builder.alerts()); this.fareProducts = List.copyOf(builder.fareProducts()); } @@ -407,8 +405,7 @@ public ScheduledTransitLegBuilder copy() { */ @Override public String toString() { - return ToStringBuilder - .of(ScheduledTransitLeg.class) + return ToStringBuilder.of(ScheduledTransitLeg.class) .addObj("from", getFrom()) .addObj("to", getTo()) .addTime("startTime", startTime) diff --git a/application/src/main/java/org/opentripplanner/model/plan/StopArrival.java b/application/src/main/java/org/opentripplanner/model/plan/StopArrival.java index 478c8eea379..e1d20c81cd5 100644 --- a/application/src/main/java/org/opentripplanner/model/plan/StopArrival.java +++ b/application/src/main/java/org/opentripplanner/model/plan/StopArrival.java @@ -38,8 +38,7 @@ public StopArrival( @Override public String toString() { - return ToStringBuilder - .of(StopArrival.class) + return ToStringBuilder.of(StopArrival.class) .addObj("arrival", arrival) .addObj("departure", departure) .addObj("place", place) diff --git a/application/src/main/java/org/opentripplanner/model/plan/StreetLeg.java b/application/src/main/java/org/opentripplanner/model/plan/StreetLeg.java index ef16c3bd76d..1f837fb73e4 100644 --- a/application/src/main/java/org/opentripplanner/model/plan/StreetLeg.java +++ b/application/src/main/java/org/opentripplanner/model/plan/StreetLeg.java @@ -174,8 +174,7 @@ public LegCallTime end() { @Override public Leg withTimeShift(Duration duration) { - return StreetLegBuilder - .of(this) + return StreetLegBuilder.of(this) .withStartTime(startTime.plus(duration)) .withEndTime(endTime.plus(duration)) .build(); @@ -198,8 +197,7 @@ public StreetLeg withAccessibilityScore(float accessibilityScore) { */ @Override public String toString() { - return ToStringBuilder - .of(StreetLeg.class) + return ToStringBuilder.of(StreetLeg.class) .addObj("from", from) .addObj("to", to) .addTime("startTime", startTime) diff --git a/application/src/main/java/org/opentripplanner/model/plan/TripPlan.java b/application/src/main/java/org/opentripplanner/model/plan/TripPlan.java index ccd2af8b333..84b0a53da2e 100644 --- a/application/src/main/java/org/opentripplanner/model/plan/TripPlan.java +++ b/application/src/main/java/org/opentripplanner/model/plan/TripPlan.java @@ -30,8 +30,7 @@ public TripPlan(Place from, Place to, Instant date, Collection itiner @Override public String toString() { - return ToStringBuilder - .of(TripPlan.class) + return ToStringBuilder.of(TripPlan.class) .addObj("date", date) .addObj("from", from) .addObj("to", to) diff --git a/application/src/main/java/org/opentripplanner/model/plan/UnknownTransitPathLeg.java b/application/src/main/java/org/opentripplanner/model/plan/UnknownTransitPathLeg.java index 8027857e02e..df649b5728f 100644 --- a/application/src/main/java/org/opentripplanner/model/plan/UnknownTransitPathLeg.java +++ b/application/src/main/java/org/opentripplanner/model/plan/UnknownTransitPathLeg.java @@ -117,8 +117,7 @@ public String description() { @Override public String toString() { - return ToStringBuilder - .of(UnknownTransitPathLeg.class) + return ToStringBuilder.of(UnknownTransitPathLeg.class) .addObj("from", from) .addObj("to", to) .addTime("startTime", startTime) diff --git a/application/src/main/java/org/opentripplanner/model/plan/WalkStep.java b/application/src/main/java/org/opentripplanner/model/plan/WalkStep.java index 7ade16de39a..af20a4d9e42 100644 --- a/application/src/main/java/org/opentripplanner/model/plan/WalkStep.java +++ b/application/src/main/java/org/opentripplanner/model/plan/WalkStep.java @@ -197,8 +197,7 @@ public static WalkStepBuilder builder() { @Override public String toString() { - return ToStringBuilder - .of(this.getClass()) + return ToStringBuilder.of(this.getClass()) .addEnum("absoluteDirection", absoluteDirection) .addEnum("relativeDirection", relativeDirection) .addStr("streetName", directionText.toString()) diff --git a/application/src/main/java/org/opentripplanner/model/plan/WalkStepBuilder.java b/application/src/main/java/org/opentripplanner/model/plan/WalkStepBuilder.java index 75589718861..293e7b16dcd 100644 --- a/application/src/main/java/org/opentripplanner/model/plan/WalkStepBuilder.java +++ b/application/src/main/java/org/opentripplanner/model/plan/WalkStepBuilder.java @@ -93,7 +93,7 @@ public WalkStepBuilder withDirections(double lastAngle, double thisAngle, boolea } public WalkStepBuilder withAbsoluteDirection(double thisAngle) { - int octant = (8 + IntUtils.round(thisAngle * 8 / (Math.PI * 2))) % 8; + int octant = (8 + IntUtils.round((thisAngle * 8) / (Math.PI * 2))) % 8; absoluteDirection = AbsoluteDirection.values()[octant]; return this; } diff --git a/application/src/main/java/org/opentripplanner/model/plan/legreference/LegReferenceSerializer.java b/application/src/main/java/org/opentripplanner/model/plan/legreference/LegReferenceSerializer.java index 0ceae6cb456..4f93225fc64 100644 --- a/application/src/main/java/org/opentripplanner/model/plan/legreference/LegReferenceSerializer.java +++ b/application/src/main/java/org/opentripplanner/model/plan/legreference/LegReferenceSerializer.java @@ -28,9 +28,9 @@ public static String encode(LegReference legReference) { if (legReference == null) { return null; } - LegReferenceType typeEnum = LegReferenceType - .forClass(legReference.getClass()) - .orElseThrow(() -> new IllegalArgumentException("Unknown LegReference type")); + LegReferenceType typeEnum = LegReferenceType.forClass(legReference.getClass()).orElseThrow(() -> + new IllegalArgumentException("Unknown LegReference type") + ); var buf = new ByteArrayOutputStream(); try (var out = new ObjectOutputStream(buf)) { diff --git a/application/src/main/java/org/opentripplanner/model/plan/legreference/LegReferenceType.java b/application/src/main/java/org/opentripplanner/model/plan/legreference/LegReferenceType.java index 079f526676d..62af6e05215 100644 --- a/application/src/main/java/org/opentripplanner/model/plan/legreference/LegReferenceType.java +++ b/application/src/main/java/org/opentripplanner/model/plan/legreference/LegReferenceType.java @@ -53,8 +53,7 @@ enum LegReferenceType { * Return the latest LegReferenceType version for a given leg reference class. */ static Optional forClass(Class legReferenceClass) { - return Arrays - .stream(LegReferenceType.values()) + return Arrays.stream(LegReferenceType.values()) .filter(legReferenceType -> legReferenceType.legReferenceClass.equals(legReferenceClass)) .reduce((legReferenceType, other) -> { if (legReferenceType.version > other.version) { diff --git a/application/src/main/java/org/opentripplanner/model/plan/legreference/ScheduledTransitLegReference.java b/application/src/main/java/org/opentripplanner/model/plan/legreference/ScheduledTransitLegReference.java index 071d1e8d7e5..1b2b2c69f76 100644 --- a/application/src/main/java/org/opentripplanner/model/plan/legreference/ScheduledTransitLegReference.java +++ b/application/src/main/java/org/opentripplanner/model/plan/legreference/ScheduledTransitLegReference.java @@ -180,8 +180,7 @@ public ScheduledTransitLeg getLeg(TransitService transitService) { return (ScheduledTransitLeg) new AlertToLegMapper( transitService.getTransitAlertService(), transitService::findMultiModalStation - ) - .decorateWithAlerts(leg, false); + ).decorateWithAlerts(leg, false); } /** diff --git a/application/src/main/java/org/opentripplanner/model/plan/paging/PagingSearchWindowAdjuster.java b/application/src/main/java/org/opentripplanner/model/plan/paging/PagingSearchWindowAdjuster.java index f9e939532bb..3b1aabb36b4 100644 --- a/application/src/main/java/org/opentripplanner/model/plan/paging/PagingSearchWindowAdjuster.java +++ b/application/src/main/java/org/opentripplanner/model/plan/paging/PagingSearchWindowAdjuster.java @@ -30,8 +30,10 @@ public PagingSearchWindowAdjuster( ) { this.minSearchWindow = minSearchWindow; this.maxSearchWindow = maxSearchWindow; - this.pagingSearchWindowAdjustments = - pagingSearchWindowAdjustments.stream().mapToInt(d -> (int) d.toMinutes()).toArray(); + this.pagingSearchWindowAdjustments = pagingSearchWindowAdjustments + .stream() + .mapToInt(d -> (int) d.toMinutes()) + .toArray(); } /** @@ -81,8 +83,7 @@ public Duration increaseOrKeepSearchWindow( return normalizeSearchWindow( // Multiply minutes with 60 to get seconds (int) searchWindowUsed.getSeconds() + - 60 * - pagingSearchWindowAdjustments[nActualItinerariesFound] + 60 * pagingSearchWindowAdjustments[nActualItinerariesFound] ); } // No change diff --git a/application/src/main/java/org/opentripplanner/model/plan/paging/cursor/PageCursor.java b/application/src/main/java/org/opentripplanner/model/plan/paging/cursor/PageCursor.java index ead71fbeb38..dba9d21dbe7 100644 --- a/application/src/main/java/org/opentripplanner/model/plan/paging/cursor/PageCursor.java +++ b/application/src/main/java/org/opentripplanner/model/plan/paging/cursor/PageCursor.java @@ -62,8 +62,7 @@ public ListSection cropItinerariesAt() { @Override public String toString() { - return ToStringBuilder - .of(PageCursor.class) + return ToStringBuilder.of(PageCursor.class) .addEnum("type", type) .addEnum("sortOrder", originalSortOrder) .addDateTime("edt", earliestDepartureTime) diff --git a/application/src/main/java/org/opentripplanner/model/plan/paging/cursor/PageCursorFactory.java b/application/src/main/java/org/opentripplanner/model/plan/paging/cursor/PageCursorFactory.java index 4e2fad2a398..deba0c5c955 100644 --- a/application/src/main/java/org/opentripplanner/model/plan/paging/cursor/PageCursorFactory.java +++ b/application/src/main/java/org/opentripplanner/model/plan/paging/cursor/PageCursorFactory.java @@ -40,8 +40,9 @@ public PageCursorFactory withOriginalSearch( Instant lat, Duration searchWindow ) { - this.currentPageType = - pageType == null ? resolvePageTypeForTheFirstSearch(sortOrder) : pageType; + this.currentPageType = pageType == null + ? resolvePageTypeForTheFirstSearch(sortOrder) + : pageType; this.currentEdt = edt; this.currentLat = lat; @@ -79,8 +80,7 @@ public PageCursor nextPageCursor() { @Override public String toString() { - return ToStringBuilder - .of(PageCursorFactory.class) + return ToStringBuilder.of(PageCursorFactory.class) .addEnum("sortOrder", sortOrder) .addEnum("currentPageType", currentPageType) .addDateTime("currentEdt", currentEdt) @@ -129,17 +129,22 @@ private void createPageCursors() { nextEdt = edtAfterUsedSw(); } } - prevCursor = - new PageCursor( - PREVIOUS_PAGE, - sortOrder, - prevEdt, - currentLat, - newSearchWindow, - itineraryPageCut - ); - nextCursor = - new PageCursor(NEXT_PAGE, sortOrder, nextEdt, null, newSearchWindow, itineraryPageCut); + prevCursor = new PageCursor( + PREVIOUS_PAGE, + sortOrder, + prevEdt, + currentLat, + newSearchWindow, + itineraryPageCut + ); + nextCursor = new PageCursor( + NEXT_PAGE, + sortOrder, + nextEdt, + null, + newSearchWindow, + itineraryPageCut + ); } private Instant edtBeforeNewSw() { diff --git a/application/src/main/java/org/opentripplanner/model/plan/paging/cursor/PageCursorSerializer.java b/application/src/main/java/org/opentripplanner/model/plan/paging/cursor/PageCursorSerializer.java index ac2a8e1df0b..c34081d65da 100644 --- a/application/src/main/java/org/opentripplanner/model/plan/paging/cursor/PageCursorSerializer.java +++ b/application/src/main/java/org/opentripplanner/model/plan/paging/cursor/PageCursorSerializer.java @@ -24,8 +24,7 @@ final class PageCursorSerializer { private static final String CUT_N_TRANSFERS_FIELD = "cutTx"; private static final String CUT_COST_FIELD = "cutCost"; - private static final TokenSchema SCHEMA_TOKEN = TokenSchema - .ofVersion(VERSION) + private static final TokenSchema SCHEMA_TOKEN = TokenSchema.ofVersion(VERSION) .addEnum(TYPE_FIELD) .addTimeInstant(EDT_FIELD) .addTimeInstant(LAT_FIELD) @@ -43,8 +42,7 @@ private PageCursorSerializer() {} @Nullable public static String encode(PageCursor cursor) { - var tokenBuilder = SCHEMA_TOKEN - .encode() + var tokenBuilder = SCHEMA_TOKEN.encode() .withEnum(TYPE_FIELD, cursor.type()) .withTimeInstant(EDT_FIELD, cursor.earliestDepartureTime()) .withTimeInstant(LAT_FIELD, cursor.latestArrivalTime()) @@ -86,14 +84,13 @@ public static PageCursor decode(String cursor) { var cutDepartureTime = token.getTimeInstant(CUT_DEPARTURE_TIME_FIELD); if (cutDepartureTime != null) { - itineraryPageCut = - new DeduplicationPageCut( - cutDepartureTime, - token.getTimeInstant(CUT_ARRIVAL_TIME_FIELD), - token.getInt(CUT_COST_FIELD), - token.getInt(CUT_N_TRANSFERS_FIELD), - token.getBoolean(CUT_ON_STREET_FIELD) - ); + itineraryPageCut = new DeduplicationPageCut( + cutDepartureTime, + token.getTimeInstant(CUT_ARRIVAL_TIME_FIELD), + token.getInt(CUT_COST_FIELD), + token.getInt(CUT_N_TRANSFERS_FIELD), + token.getBoolean(CUT_ON_STREET_FIELD) + ); } // Add logic to read in data from next version here. diff --git a/application/src/main/java/org/opentripplanner/model/projectinfo/VersionControlInfo.java b/application/src/main/java/org/opentripplanner/model/projectinfo/VersionControlInfo.java index 6cd6a47f5ef..0fc0aa8d177 100644 --- a/application/src/main/java/org/opentripplanner/model/projectinfo/VersionControlInfo.java +++ b/application/src/main/java/org/opentripplanner/model/projectinfo/VersionControlInfo.java @@ -33,8 +33,7 @@ public VersionControlInfo( @Override public String toString() { - return ToStringBuilder - .of(VersionControlInfo.class) + return ToStringBuilder.of(VersionControlInfo.class) .addStr("commit", commit) .addStr("branch", branch) .addStr("commitTime", commitTime) diff --git a/application/src/main/java/org/opentripplanner/model/transfer/ConstrainedTransfer.java b/application/src/main/java/org/opentripplanner/model/transfer/ConstrainedTransfer.java index a5e6c624d9c..9d377619537 100644 --- a/application/src/main/java/org/opentripplanner/model/transfer/ConstrainedTransfer.java +++ b/application/src/main/java/org/opentripplanner/model/transfer/ConstrainedTransfer.java @@ -102,10 +102,8 @@ public boolean noConstraints() { */ public int getSpecificityRanking() { return ( - from.getSpecificityRanking() * - FROM_RANKING_COEFFICIENT + - to.getSpecificityRanking() * - TO_RANKING_COEFFICIENT + from.getSpecificityRanking() * FROM_RANKING_COEFFICIENT + + to.getSpecificityRanking() * TO_RANKING_COEFFICIENT ); } @@ -131,8 +129,7 @@ public boolean equals(Object o) { } public String toString() { - return ToStringBuilder - .of(ConstrainedTransfer.class) + return ToStringBuilder.of(ConstrainedTransfer.class) .addObj("from", from) .addObj("to", to) .addObj("constraint", constraint) diff --git a/application/src/main/java/org/opentripplanner/model/transfer/RouteStopTransferPoint.java b/application/src/main/java/org/opentripplanner/model/transfer/RouteStopTransferPoint.java index 627d82f7ccd..bf1f590d5a8 100644 --- a/application/src/main/java/org/opentripplanner/model/transfer/RouteStopTransferPoint.java +++ b/application/src/main/java/org/opentripplanner/model/transfer/RouteStopTransferPoint.java @@ -40,8 +40,7 @@ public boolean isRouteStopTransferPoint() { @Override public String toString() { - return ValueObjectToStringBuilder - .of() + return ValueObjectToStringBuilder.of() .addText("RouteTP{") .addObj(route.getId()) .addText(", stop ") diff --git a/application/src/main/java/org/opentripplanner/model/transfer/StationTransferPoint.java b/application/src/main/java/org/opentripplanner/model/transfer/StationTransferPoint.java index 4af961ff0f4..fbc0dd34185 100644 --- a/application/src/main/java/org/opentripplanner/model/transfer/StationTransferPoint.java +++ b/application/src/main/java/org/opentripplanner/model/transfer/StationTransferPoint.java @@ -32,8 +32,7 @@ public boolean isStationTransferPoint() { } public String toString() { - return ValueObjectToStringBuilder - .of() + return ValueObjectToStringBuilder.of() .addText("StationTP{") .addObj(station.getId()) .addText("}") diff --git a/application/src/main/java/org/opentripplanner/model/transfer/TransferConstraint.java b/application/src/main/java/org/opentripplanner/model/transfer/TransferConstraint.java index e6509c7d8ca..1b74396b7a0 100644 --- a/application/src/main/java/org/opentripplanner/model/transfer/TransferConstraint.java +++ b/application/src/main/java/org/opentripplanner/model/transfer/TransferConstraint.java @@ -265,8 +265,7 @@ public String toString() { return "{no constraints}"; } - return ToStringBuilder - .of() + return ToStringBuilder.of() .addEnum("priority", priority, ALLOWED) .addBoolIfTrue("staySeated", staySeated) .addBoolIfTrue("guaranteed", guaranteed) diff --git a/application/src/main/java/org/opentripplanner/model/transfer/TransferPointMap.java b/application/src/main/java/org/opentripplanner/model/transfer/TransferPointMap.java index 9f231d06aab..94643bc4544 100644 --- a/application/src/main/java/org/opentripplanner/model/transfer/TransferPointMap.java +++ b/application/src/main/java/org/opentripplanner/model/transfer/TransferPointMap.java @@ -46,15 +46,13 @@ void put(TransferPoint point, E e) { E computeIfAbsent(TransferPoint point, Supplier creator) { if (point.isTripTransferPoint()) { var tp = point.asTripTransferPoint(); - return tripMap.computeIfAbsent( - new TripKey(tp.getTrip(), tp.getStopPositionInPattern()), - k -> creator.get() + return tripMap.computeIfAbsent(new TripKey(tp.getTrip(), tp.getStopPositionInPattern()), k -> + creator.get() ); } else if (point.isRouteStopTransferPoint()) { var rp = point.asRouteStopTransferPoint(); - return routeStopMap.computeIfAbsent( - new RouteStopKey(rp.getRoute(), rp.getStop()), - k -> creator.get() + return routeStopMap.computeIfAbsent(new RouteStopKey(rp.getRoute(), rp.getStop()), k -> + creator.get() ); } else if (point.isRouteStationTransferPoint()) { var rp = point.asRouteStationTransferPoint(); @@ -76,14 +74,13 @@ E computeIfAbsent(TransferPoint point, Supplier creator) { * List all elements which matches any of the transfer points added to the map. */ List get(Trip trip, StopLocation stop, int stopPointInPattern) { - return Stream - .of( - tripMap.get(new TripKey(trip, stopPointInPattern)), - routeStopMap.get(new RouteStopKey(trip.getRoute(), stop)), - routeStationMap.get(new RouteStationKey(trip.getRoute(), stop.getParentStation())), - stopMap.get(stop), - stationMap.get(stop.getParentStation()) - ) + return Stream.of( + tripMap.get(new TripKey(trip, stopPointInPattern)), + routeStopMap.get(new RouteStopKey(trip.getRoute(), stop)), + routeStationMap.get(new RouteStationKey(trip.getRoute(), stop.getParentStation())), + stopMap.get(stop), + stationMap.get(stop.getParentStation()) + ) .filter(Objects::nonNull) .collect(Collectors.toList()); } diff --git a/application/src/main/java/org/opentripplanner/model/transfer/TripTransferPoint.java b/application/src/main/java/org/opentripplanner/model/transfer/TripTransferPoint.java index 5dd23269779..22ee9dbbf85 100644 --- a/application/src/main/java/org/opentripplanner/model/transfer/TripTransferPoint.java +++ b/application/src/main/java/org/opentripplanner/model/transfer/TripTransferPoint.java @@ -39,8 +39,7 @@ public boolean isTripTransferPoint() { @Override public String toString() { - return ValueObjectToStringBuilder - .of() + return ValueObjectToStringBuilder.of() .addText("TripTP{") .addObj(trip.getId()) .addText(", stopPos ") diff --git a/application/src/main/java/org/opentripplanner/netex/NetexBundle.java b/application/src/main/java/org/opentripplanner/netex/NetexBundle.java index b061c9e9352..0d994359ddb 100644 --- a/application/src/main/java/org/opentripplanner/netex/NetexBundle.java +++ b/application/src/main/java/org/opentripplanner/netex/NetexBundle.java @@ -91,17 +91,16 @@ public OtpTransitServiceBuilder loadBundle( // init parser and mapper xmlParser = new NetexXmlParser(); - mapper = - new NetexMapper( - transitBuilder, - feedId, - deduplicator, - issueStore, - ferryIdsNotAllowedForBicycle, - routeToCentroidStopPlaceIds, - maxStopToShapeSnapDistance, - noTransfersOnIsolatedStops - ); + mapper = new NetexMapper( + transitBuilder, + feedId, + deduplicator, + issueStore, + ferryIdsNotAllowedForBicycle, + routeToCentroidStopPlaceIds, + maxStopToShapeSnapDistance, + noTransfersOnIsolatedStops + ); // Load data loadFileEntries(); diff --git a/application/src/main/java/org/opentripplanner/netex/config/NetexFeedParameters.java b/application/src/main/java/org/opentripplanner/netex/config/NetexFeedParameters.java index 604a28b1ab5..c5b5584129b 100644 --- a/application/src/main/java/org/opentripplanner/netex/config/NetexFeedParameters.java +++ b/application/src/main/java/org/opentripplanner/netex/config/NetexFeedParameters.java @@ -170,8 +170,7 @@ public int hashCode() { @Override public String toString() { - return ToStringBuilder - .of(NetexFeedParameters.class) + return ToStringBuilder.of(NetexFeedParameters.class) .addObj("source", source, null) .addObj("feedId", feedId, DEFAULT.feedId) .addStr("sharedFilePattern", sharedFilePattern, DEFAULT.sharedFilePattern) diff --git a/application/src/main/java/org/opentripplanner/netex/configure/NetexConfigure.java b/application/src/main/java/org/opentripplanner/netex/configure/NetexConfigure.java index 5771828395e..69c5054613a 100644 --- a/application/src/main/java/org/opentripplanner/netex/configure/NetexConfigure.java +++ b/application/src/main/java/org/opentripplanner/netex/configure/NetexConfigure.java @@ -87,12 +87,11 @@ private NetexDataSourceHierarchy hierarchy( CompositeDataSource source, NetexFeedParameters params ) { - return new NetexDataSourceHierarchy(source) - .prepare( - params.ignoreFilePattern(), - params.sharedFilePattern(), - params.sharedGroupFilePattern(), - params.groupFilePattern() - ); + return new NetexDataSourceHierarchy(source).prepare( + params.ignoreFilePattern(), + params.sharedFilePattern(), + params.sharedGroupFilePattern(), + params.groupFilePattern() + ); } } diff --git a/application/src/main/java/org/opentripplanner/netex/index/NetexEntityIndex.java b/application/src/main/java/org/opentripplanner/netex/index/NetexEntityIndex.java index 0cb94f66a77..76e82327040 100644 --- a/application/src/main/java/org/opentripplanner/netex/index/NetexEntityIndex.java +++ b/application/src/main/java/org/opentripplanner/netex/index/NetexEntityIndex.java @@ -156,8 +156,9 @@ public NetexEntityIndex(NetexEntityIndex parent) { this.parent = parent; this.authoritiesById = new HierarchicalMapById<>(parent.authoritiesById); this.dayTypeById = new HierarchicalMapById<>(parent.dayTypeById); - this.dayTypeAssignmentByDayTypeId = - new HierarchicalMultimap<>(parent.dayTypeAssignmentByDayTypeId); + this.dayTypeAssignmentByDayTypeId = new HierarchicalMultimap<>( + parent.dayTypeAssignmentByDayTypeId + ); this.datedServiceJourneys = new HierarchicalMapById<>(parent.datedServiceJourneys); this.destinationDisplayById = new HierarchicalMapById<>(parent.destinationDisplayById); this.flexibleStopPlaceById = new HierarchicalMapById<>(parent.flexibleStopPlaceById); @@ -175,14 +176,16 @@ public NetexEntityIndex(NetexEntityIndex parent) { this.operatingPeriodById = new HierarchicalMapById<>(parent.operatingPeriodById); this.operatorsById = new HierarchicalMapById<>(parent.operatorsById); this.quayById = new HierarchicalVersionMapById<>(parent.quayById); - this.flexibleStopPlaceByStopPointRef = - new HierarchicalMap<>(parent.flexibleStopPlaceByStopPointRef); + this.flexibleStopPlaceByStopPointRef = new HierarchicalMap<>( + parent.flexibleStopPlaceByStopPointRef + ); this.quayIdByStopPointRef = new HierarchicalMap<>(parent.quayIdByStopPointRef); this.routeById = new HierarchicalMapById<>(parent.routeById); this.serviceJourneyById = new HierarchicalMapById<>(parent.serviceJourneyById); this.serviceLinkById = new HierarchicalMapById<>(parent.serviceLinkById); - this.serviceJourneyInterchangeById = - new HierarchicalMapById<>(parent.serviceJourneyInterchangeById); + this.serviceJourneyInterchangeById = new HierarchicalMapById<>( + parent.serviceJourneyInterchangeById + ); this.stopPlaceById = new HierarchicalVersionMapById<>(parent.stopPlaceById); this.tariffZonesById = new HierarchicalVersionMapById<>(parent.tariffZonesById); this.brandingById = new HierarchicalMapById<>(parent.brandingById); @@ -248,7 +251,10 @@ public ReadOnlyHierarchicalMapById getDayTypeById() { * mapper is responsible for indexing its data, except for entities by id. */ @Deprecated - public ReadOnlyHierarchicalMap> getDayTypeAssignmentByDayTypeId() { + public ReadOnlyHierarchicalMap< + String, + Collection + > getDayTypeAssignmentByDayTypeId() { return dayTypeAssignmentByDayTypeId; } @@ -308,7 +314,9 @@ public ReadOnlyHierarchicalMapById getOperatingDayById() { } @Override - public ReadOnlyHierarchicalMapById getOperatingPeriodById() { + public ReadOnlyHierarchicalMapById< + OperatingPeriod_VersionStructure + > getOperatingPeriodById() { return operatingPeriodById; } @@ -343,7 +351,9 @@ public ReadOnlyHierarchicalMapById getServiceJourneyById() { } @Override - public ReadOnlyHierarchicalMapById getServiceJourneyInterchangeById() { + public ReadOnlyHierarchicalMapById< + ServiceJourneyInterchange + > getServiceJourneyInterchangeById() { return serviceJourneyInterchangeById; } diff --git a/application/src/main/java/org/opentripplanner/netex/loader/NetexDataSourceHierarchy.java b/application/src/main/java/org/opentripplanner/netex/loader/NetexDataSourceHierarchy.java index d106f33c821..eeecfbfa7ef 100644 --- a/application/src/main/java/org/opentripplanner/netex/loader/NetexDataSourceHierarchy.java +++ b/application/src/main/java/org/opentripplanner/netex/loader/NetexDataSourceHierarchy.java @@ -50,8 +50,7 @@ public NetexDataSourceHierarchy prepare( sharedFilePattern, sharedGroupFilePattern, groupFilePattern - ) - .execute(); + ).execute(); return this; } diff --git a/application/src/main/java/org/opentripplanner/netex/loader/parser/ServiceCalendarFrameParser.java b/application/src/main/java/org/opentripplanner/netex/loader/parser/ServiceCalendarFrameParser.java index 958c092695f..0843b3508ed 100644 --- a/application/src/main/java/org/opentripplanner/netex/loader/parser/ServiceCalendarFrameParser.java +++ b/application/src/main/java/org/opentripplanner/netex/loader/parser/ServiceCalendarFrameParser.java @@ -31,7 +31,8 @@ class ServiceCalendarFrameParser extends NetexParser dayTypes = new ArrayList<>(); private final Collection operatingPeriods = new ArrayList<>(); private final Collection operatingDays = new ArrayList<>(); - private final Multimap dayTypeAssignmentByDayTypeId = ArrayListMultimap.create(); + private final Multimap dayTypeAssignmentByDayTypeId = + ArrayListMultimap.create(); @Override void parse(ServiceCalendarFrame_VersionFrameStructure frame) { diff --git a/application/src/main/java/org/opentripplanner/netex/loader/parser/SiteFrameParser.java b/application/src/main/java/org/opentripplanner/netex/loader/parser/SiteFrameParser.java index 38cd91ded98..f08eca4ed1e 100644 --- a/application/src/main/java/org/opentripplanner/netex/loader/parser/SiteFrameParser.java +++ b/application/src/main/java/org/opentripplanner/netex/loader/parser/SiteFrameParser.java @@ -144,9 +144,10 @@ private boolean isMultiModalStopPlace(StopPlace stopPlace) { .getKeyList() .getKeyValue() .stream() - .anyMatch(keyValueStructure -> - keyValueStructure.getKey().equals("IS_PARENT_STOP_PLACE") && - keyValueStructure.getValue().equals("true") + .anyMatch( + keyValueStructure -> + keyValueStructure.getKey().equals("IS_PARENT_STOP_PLACE") && + keyValueStructure.getValue().equals("true") ) ); } diff --git a/application/src/main/java/org/opentripplanner/netex/mapping/AuthorityToAgencyMapper.java b/application/src/main/java/org/opentripplanner/netex/mapping/AuthorityToAgencyMapper.java index f954c3a4c24..7af46bcb739 100644 --- a/application/src/main/java/org/opentripplanner/netex/mapping/AuthorityToAgencyMapper.java +++ b/application/src/main/java/org/opentripplanner/netex/mapping/AuthorityToAgencyMapper.java @@ -38,18 +38,14 @@ Agency mapAuthorityToAgency(Authority source) { String shortName = MultilingualStringMapper.nullableValueOf(source.getShortName()); String agencyName = StringUtils.hasValue(name) ? name : shortName; - AgencyBuilder target = Agency - .of(idFactory.createId(source.getId())) + AgencyBuilder target = Agency.of(idFactory.createId(source.getId())) .withName(agencyName) .withTimezone(timeZone); - withOptional( - source.getContactDetails(), - c -> { - target.withUrl(c.getUrl()); - target.withPhone(c.getPhone()); - } - ); + withOptional(source.getContactDetails(), c -> { + target.withUrl(c.getUrl()); + target.withPhone(c.getPhone()); + }); return target.build(); } @@ -58,8 +54,7 @@ Agency mapAuthorityToAgency(Authority source) { * {@code "Dummy-" + timeZone}. */ Agency createDummyAgency() { - return Agency - .of(idFactory.createId(dummyAgencyId)) + return Agency.of(idFactory.createId(dummyAgencyId)) .withName("N/A") .withTimezone(timeZone) .withUrl("N/A") diff --git a/application/src/main/java/org/opentripplanner/netex/mapping/BookingInfoMapper.java b/application/src/main/java/org/opentripplanner/netex/mapping/BookingInfoMapper.java index d6c81c76e3d..b17d3624ab7 100644 --- a/application/src/main/java/org/opentripplanner/netex/mapping/BookingInfoMapper.java +++ b/application/src/main/java/org/opentripplanner/netex/mapping/BookingInfoMapper.java @@ -85,7 +85,8 @@ private NetexBookingInfoBuilder withServiceJourney(ServiceJourney serviceJourney if (serviceJourney != null && serviceJourney.getFlexibleServiceProperties() != null) { this.hasBookingInfo = true; this.serviceJourneyRef = ref("ServiceJourney", serviceJourney); - FlexibleServiceProperties flexibleServiceProperties = serviceJourney.getFlexibleServiceProperties(); + FlexibleServiceProperties flexibleServiceProperties = + serviceJourney.getFlexibleServiceProperties(); setIfNotEmpty( flexibleServiceProperties.getBookingContact(), flexibleServiceProperties.getBookingMethods(), @@ -174,8 +175,7 @@ private BookingInfo build( return null; } - ContactInfo contactInfo = ContactInfo - .of() + ContactInfo contactInfo = ContactInfo.of() .withContactPerson( contactStructure.getContactPerson() != null ? contactStructure.getContactPerson().getValue() @@ -220,8 +220,7 @@ private BookingInfo build( } String bookingInfoMessage = bookingNote != null ? bookingNote.getValue() : null; - return BookingInfo - .of() + return BookingInfo.of() .withContactInfo(contactInfo) .withBookingMethods(filteredBookingMethods) .withEarliestBookingTime(otpEarliestBookingTime) diff --git a/application/src/main/java/org/opentripplanner/netex/mapping/GroupOfRoutesMapper.java b/application/src/main/java/org/opentripplanner/netex/mapping/GroupOfRoutesMapper.java index 0a6e0917fba..a59af2fc2bf 100644 --- a/application/src/main/java/org/opentripplanner/netex/mapping/GroupOfRoutesMapper.java +++ b/application/src/main/java/org/opentripplanner/netex/mapping/GroupOfRoutesMapper.java @@ -22,8 +22,7 @@ public GroupOfRoutesMapper(FeedScopedIdFactory idFactory) { * @return OTP GroupOfRoutes model */ public GroupOfRoutes mapGroupOfRoutes(GroupOfLines gol) { - return GroupOfRoutes - .of(idFactory.createId(gol.getId())) + return GroupOfRoutes.of(idFactory.createId(gol.getId())) .withPrivateCode(gol.getPrivateCode() != null ? gol.getPrivateCode().getValue() : null) .withShortName(MultilingualStringMapper.nullableValueOf(gol.getShortName())) .withName(MultilingualStringMapper.nullableValueOf(gol.getName())) diff --git a/application/src/main/java/org/opentripplanner/netex/mapping/GroupOfStationsMapper.java b/application/src/main/java/org/opentripplanner/netex/mapping/GroupOfStationsMapper.java index 6eeaf7126f5..8e00528b85e 100644 --- a/application/src/main/java/org/opentripplanner/netex/mapping/GroupOfStationsMapper.java +++ b/application/src/main/java/org/opentripplanner/netex/mapping/GroupOfStationsMapper.java @@ -59,9 +59,9 @@ GroupOfStations map(GroupOfStopPlaces groupOfStopPlaces) { .getValue(); name = stations.get(idFactory.createId(ref.getRef())).getName(); } - GroupOfStationsBuilder groupOfStations = GroupOfStations - .of(idFactory.createId(groupOfStopPlaces.getId())) - .withName(name); + GroupOfStationsBuilder groupOfStations = GroupOfStations.of( + idFactory.createId(groupOfStopPlaces.getId()) + ).withName(name); // TODO Map PurposeOfGrouping from NeTEx diff --git a/application/src/main/java/org/opentripplanner/netex/mapping/MultiModalStationMapper.java b/application/src/main/java/org/opentripplanner/netex/mapping/MultiModalStationMapper.java index 5a4fb23bbb9..8b92eb900dc 100644 --- a/application/src/main/java/org/opentripplanner/netex/mapping/MultiModalStationMapper.java +++ b/application/src/main/java/org/opentripplanner/netex/mapping/MultiModalStationMapper.java @@ -24,8 +24,9 @@ public MultiModalStationMapper(DataImportIssueStore issueStore, FeedScopedIdFact @Nullable MultiModalStation map(StopPlace stopPlace, Collection childStations) { - MultiModalStationBuilder multiModalStation = MultiModalStation - .of(idFactory.createId(stopPlace.getId())) + MultiModalStationBuilder multiModalStation = MultiModalStation.of( + idFactory.createId(stopPlace.getId()) + ) .withChildStations(childStations) .withName( NonLocalizedString.ofNullable(stopPlace.getName(), MultilingualString::getValue, "N/A") diff --git a/application/src/main/java/org/opentripplanner/netex/mapping/NetexMapper.java b/application/src/main/java/org/opentripplanner/netex/mapping/NetexMapper.java index 03b900343e9..7a0b2f4adc5 100644 --- a/application/src/main/java/org/opentripplanner/netex/mapping/NetexMapper.java +++ b/application/src/main/java/org/opentripplanner/netex/mapping/NetexMapper.java @@ -258,8 +258,7 @@ private void mapGroupsOfLines() { .forEach(gol -> { GroupOfRoutes model = mapper.mapGroupOfRoutes(gol); - Optional - .ofNullable(gol.getMembers()) + Optional.ofNullable(gol.getMembers()) .stream() .map(LineRefs_RelStructure::getLineRef) .filter(Objects::nonNull) diff --git a/application/src/main/java/org/opentripplanner/netex/mapping/NoticeAssignmentMapper.java b/application/src/main/java/org/opentripplanner/netex/mapping/NoticeAssignmentMapper.java index fc8cb3804f6..3f1a1c30d0e 100644 --- a/application/src/main/java/org/opentripplanner/netex/mapping/NoticeAssignmentMapper.java +++ b/application/src/main/java/org/opentripplanner/netex/mapping/NoticeAssignmentMapper.java @@ -32,7 +32,8 @@ class NoticeAssignmentMapper { private final FeedScopedIdFactory idFactory; - private final Multimap passingTimeByStopPointId = ArrayListMultimap.create(); + private final Multimap passingTimeByStopPointId = + ArrayListMultimap.create(); private final ReadOnlyHierarchicalMap noticesById; diff --git a/application/src/main/java/org/opentripplanner/netex/mapping/NoticeMapper.java b/application/src/main/java/org/opentripplanner/netex/mapping/NoticeMapper.java index 2cc99f64586..310a3279ef0 100644 --- a/application/src/main/java/org/opentripplanner/netex/mapping/NoticeMapper.java +++ b/application/src/main/java/org/opentripplanner/netex/mapping/NoticeMapper.java @@ -28,12 +28,10 @@ Notice map(org.rutebanken.netex.model.Notice netexNotice) { Notice otpNotice = cache.get(id); if (otpNotice == null) { - otpNotice = - Notice - .of(id) - .withPublicCode(netexNotice.getPublicCode()) - .withText(netexNotice.getText().getValue()) - .build(); + otpNotice = Notice.of(id) + .withPublicCode(netexNotice.getPublicCode()) + .withText(netexNotice.getText().getValue()) + .build(); cache.add(otpNotice); } diff --git a/application/src/main/java/org/opentripplanner/netex/mapping/QuayMapper.java b/application/src/main/java/org/opentripplanner/netex/mapping/QuayMapper.java index db67941e323..fdf2d73768a 100644 --- a/application/src/main/java/org/opentripplanner/netex/mapping/QuayMapper.java +++ b/application/src/main/java/org/opentripplanner/netex/mapping/QuayMapper.java @@ -45,9 +45,8 @@ RegularStop mapQuayToStop( Accessibility wheelchair ) { var id = idFactory.createId(quay.getId()); - return siteRepositoryBuilder.computeRegularStopIfAbsent( - id, - it -> map(it, quay, parentStation, fareZones, transitMode, wheelchair) + return siteRepositoryBuilder.computeRegularStopIfAbsent(id, it -> + map(it, quay, parentStation, fareZones, transitMode, wheelchair) ); } diff --git a/application/src/main/java/org/opentripplanner/netex/mapping/ServiceLinkMapper.java b/application/src/main/java/org/opentripplanner/netex/mapping/ServiceLinkMapper.java index 090f475e22e..9b946be65e8 100644 --- a/application/src/main/java/org/opentripplanner/netex/mapping/ServiceLinkMapper.java +++ b/application/src/main/java/org/opentripplanner/netex/mapping/ServiceLinkMapper.java @@ -97,7 +97,8 @@ private LineString[] generateGeometriesFromServiceLinks( for (int i = 0; i < linksInJourneyPattern.size(); i++) { var linkInLinkSequence = linksInJourneyPattern.get(i); if ( - linkInLinkSequence instanceof ServiceLinkInJourneyPattern_VersionedChildStructure serviceLinkInJourneyPattern + linkInLinkSequence instanceof + ServiceLinkInJourneyPattern_VersionedChildStructure serviceLinkInJourneyPattern ) { String serviceLinkRef = serviceLinkInJourneyPattern.getServiceLinkRef().getRef(); ServiceLink serviceLink = serviceLinkById.lookup(serviceLinkRef); diff --git a/application/src/main/java/org/opentripplanner/netex/mapping/StationMapper.java b/application/src/main/java/org/opentripplanner/netex/mapping/StationMapper.java index 27773a9f66c..163772fd93e 100644 --- a/application/src/main/java/org/opentripplanner/netex/mapping/StationMapper.java +++ b/application/src/main/java/org/opentripplanner/netex/mapping/StationMapper.java @@ -58,15 +58,13 @@ class StationMapper { Station map(StopPlace stopPlace) { var id = idFactory.createId(stopPlace.getId()); - return siteRepositoryBuilder.computeStationIfAbsent( - id, - it -> mapStopPlaceToStation(it, stopPlace) + return siteRepositoryBuilder.computeStationIfAbsent(id, it -> + mapStopPlaceToStation(it, stopPlace) ); } Station mapStopPlaceToStation(FeedScopedId id, StopPlace stopPlace) { - var builder = Station - .of(id) + var builder = Station.of(id) .withName(resolveName(stopPlace)) .withCoordinate(mapCoordinate(stopPlace)) .withShouldRouteToCentroid(shouldRouteToCentroid(id)) @@ -75,8 +73,7 @@ Station mapStopPlaceToStation(FeedScopedId id, StopPlace stopPlace) { ) .withPriority(StopTransferPriorityMapper.mapToDomain(stopPlace.getWeighting())) .withTimezone( - Optional - .ofNullable(stopPlace.getLocale()) + Optional.ofNullable(stopPlace.getLocale()) .map(LocaleStructure::getTimeZone) .map(zoneId -> ofZoneId(stopPlace.getId(), zoneId)) .orElse(defaultTimeZone) @@ -145,8 +142,10 @@ private WgsCoordinate mapCoordinate(StopPlace stopPlace) { "Station %s does not contain any coordinates.", stopPlace.getId() + " " + stopPlace.getName() ); - List coordinates = JAXBUtils - .streamJAXBElementValue(Quay.class, stopPlace.getQuays().getQuayRefOrQuay()) + List coordinates = JAXBUtils.streamJAXBElementValue( + Quay.class, + stopPlace.getQuays().getQuayRefOrQuay() + ) .map(Zone_VersionStructure::getCentroid) .filter(Objects::nonNull) .map(WgsCoordinateMapper::mapToDomain) diff --git a/application/src/main/java/org/opentripplanner/netex/mapping/StopAndStationMapper.java b/application/src/main/java/org/opentripplanner/netex/mapping/StopAndStationMapper.java index 0a5ab4ba16c..0e85b6efd6b 100644 --- a/application/src/main/java/org/opentripplanner/netex/mapping/StopAndStationMapper.java +++ b/application/src/main/java/org/opentripplanner/netex/mapping/StopAndStationMapper.java @@ -74,15 +74,14 @@ class StopAndStationMapper { boolean noTransfersOnIsolatedStops, Set routeToCentroidStopPlaceIds ) { - this.stationMapper = - new StationMapper( - issueStore, - idFactory, - defaultTimeZone, - noTransfersOnIsolatedStops, - routeToCentroidStopPlaceIds, - siteRepositoryBuilder - ); + this.stationMapper = new StationMapper( + issueStore, + idFactory, + defaultTimeZone, + noTransfersOnIsolatedStops, + routeToCentroidStopPlaceIds, + siteRepositoryBuilder + ); this.quayMapper = new QuayMapper(idFactory, issueStore, siteRepositoryBuilder); this.tariffZoneMapper = tariffZoneMapper; this.quayIndex = quayIndex; @@ -241,11 +240,10 @@ private Accessibility wheelchairAccessibilityFromQuay(Quay quay, StopPlace stopP var defaultWheelChairBoarding = Accessibility.NO_INFORMATION; if (stopPlace != null) { - defaultWheelChairBoarding = - WheelChairMapper.wheelchairAccessibility( - stopPlace.getAccessibilityAssessment(), - Accessibility.NO_INFORMATION - ); + defaultWheelChairBoarding = WheelChairMapper.wheelchairAccessibility( + stopPlace.getAccessibilityAssessment(), + Accessibility.NO_INFORMATION + ); } return WheelChairMapper.wheelchairAccessibility( diff --git a/application/src/main/java/org/opentripplanner/netex/mapping/StopTimesMapper.java b/application/src/main/java/org/opentripplanner/netex/mapping/StopTimesMapper.java index 676ab053da4..9d641ed5a9e 100644 --- a/application/src/main/java/org/opentripplanner/netex/mapping/StopTimesMapper.java +++ b/application/src/main/java/org/opentripplanner/netex/mapping/StopTimesMapper.java @@ -162,8 +162,11 @@ StopTimesMapperResult mapToStopTimes( return null; } - BookingInfo bookingInfo = new BookingInfoMapper(issueStore) - .map(stopPoint, serviceJourney, lookUpFlexibleLine(serviceJourney, journeyPattern)); + BookingInfo bookingInfo = new BookingInfoMapper(issueStore).map( + stopPoint, + serviceJourney, + lookUpFlexibleLine(serviceJourney, journeyPattern) + ); stopTime.setDropOffBookingInfo(bookingInfo); stopTime.setPickupBookingInfo(bookingInfo); @@ -318,21 +321,20 @@ private StopTime mapToStopTime( currentHeadSign = new NonLocalizedString(destinationDisplay.getFrontText().getValue()); Vias_RelStructure viaValues = destinationDisplay.getVias(); if (viaValues != null && viaValues.getVia() != null) { - currentHeadSignVias = - viaValues - .getVia() - .stream() - .map(Via_VersionedChildStructure::getDestinationDisplayRef) - .filter(Objects::nonNull) - .map(VersionOfObjectRefStructure::getRef) - .filter(Objects::nonNull) - .map(destinationDisplayById::lookup) - .filter(Objects::nonNull) - .map(DestinationDisplay_VersionStructure::getFrontText) - .filter(Objects::nonNull) - .map(MultilingualString::getValue) - .filter(Objects::nonNull) - .collect(Collectors.toList()); + currentHeadSignVias = viaValues + .getVia() + .stream() + .map(Via_VersionedChildStructure::getDestinationDisplayRef) + .filter(Objects::nonNull) + .map(VersionOfObjectRefStructure::getRef) + .filter(Objects::nonNull) + .map(destinationDisplayById::lookup) + .filter(Objects::nonNull) + .map(DestinationDisplay_VersionStructure::getFrontText) + .filter(Objects::nonNull) + .map(MultilingualString::getValue) + .filter(Objects::nonNull) + .collect(Collectors.toList()); if (currentHeadSignVias.isEmpty()) { currentHeadSignVias = null; diff --git a/application/src/main/java/org/opentripplanner/netex/mapping/TripMapper.java b/application/src/main/java/org/opentripplanner/netex/mapping/TripMapper.java index 02b5de80bb3..9d21cf9bef5 100644 --- a/application/src/main/java/org/opentripplanner/netex/mapping/TripMapper.java +++ b/application/src/main/java/org/opentripplanner/netex/mapping/TripMapper.java @@ -37,7 +37,10 @@ class TripMapper { private final DataImportIssueStore issueStore; private final EntityById otpRouteById; private final ReadOnlyHierarchicalMap routeById; - private final ReadOnlyHierarchicalMap journeyPatternsById; + private final ReadOnlyHierarchicalMap< + String, + JourneyPattern_VersionStructure + > journeyPatternsById; private final Map serviceIds; private final EntityById operatorsById; private final TransportModeMapper transportModeMapper = new TransportModeMapper(); @@ -112,11 +115,10 @@ Trip mapServiceJourney(ServiceJourney serviceJourney, Supplier headsign) if (serviceJourney.getTransportMode() != null) { NetexMainAndSubMode transitMode = null; try { - transitMode = - transportModeMapper.map( - serviceJourney.getTransportMode(), - serviceJourney.getTransportSubmode() - ); + transitMode = transportModeMapper.map( + serviceJourney.getTransportMode(), + serviceJourney.getTransportSubmode() + ); } catch (TransportModeMapper.UnsupportedModeException e) { issueStore.add( "UnsupportedModeInServiceJourney", diff --git a/application/src/main/java/org/opentripplanner/netex/mapping/TripPatternMapper.java b/application/src/main/java/org/opentripplanner/netex/mapping/TripPatternMapper.java index c7b85e72af8..44f0334f901 100644 --- a/application/src/main/java/org/opentripplanner/netex/mapping/TripPatternMapper.java +++ b/application/src/main/java/org/opentripplanner/netex/mapping/TripPatternMapper.java @@ -67,7 +67,8 @@ class TripPatternMapper { private final ReadOnlyHierarchicalMap routeById; - private final Multimap serviceJourneysByPatternId = ArrayListMultimap.create(); + private final Multimap serviceJourneysByPatternId = + ArrayListMultimap.create(); private final ReadOnlyHierarchicalMapById operatingDayById; @@ -114,38 +115,35 @@ class TripPatternMapper { this.otpRouteById = otpRouteById; this.operatingDayById = operatingDayById; this.datedServiceJourneysBySJId = datedServiceJourneysBySJId; - this.tripMapper = - new TripMapper( - idFactory, - issueStore, - operatorById, - otpRouteById, - routeById, - journeyPatternById, - serviceIds - ); - this.stopTimesMapper = - new StopTimesMapper( - issueStore, - idFactory, - stopById, - areaStopById, - groupStopById, - destinationDisplayById, - quayIdByStopPointRef, - flexibleStopPlaceIdByStopPointRef, - flexibleLineById, - routeById - ); - this.serviceLinkMapper = - new ServiceLinkMapper( - idFactory, - serviceLinkById, - quayIdByStopPointRef, - stopById, - issueStore, - maxStopToShapeSnapDistance - ); + this.tripMapper = new TripMapper( + idFactory, + issueStore, + operatorById, + otpRouteById, + routeById, + journeyPatternById, + serviceIds + ); + this.stopTimesMapper = new StopTimesMapper( + issueStore, + idFactory, + stopById, + areaStopById, + groupStopById, + destinationDisplayById, + quayIdByStopPointRef, + flexibleStopPlaceIdByStopPointRef, + flexibleLineById, + routeById + ); + this.serviceLinkMapper = new ServiceLinkMapper( + idFactory, + serviceLinkById, + quayIdByStopPointRef, + stopById, + issueStore, + maxStopToShapeSnapDistance + ); this.deduplicator = deduplicator; this.datedServiceJourneyById = datedServiceJourneyById; @@ -244,8 +242,7 @@ Optional mapTripPattern(JourneyPattern_VersionStructure ); } - var tripPattern = TripPattern - .of(idFactory.createId(journeyPattern.getId())) + var tripPattern = TripPattern.of(idFactory.createId(journeyPattern.getId())) .withRoute(lookupRoute(journeyPattern)) .withStopPattern(stopPattern) .withMode(trips.get(0).getMode()) @@ -342,8 +339,7 @@ private TripOnServiceDate mapDatedServiceJourney( .filter(Objects::nonNull) .toList(); - return TripOnServiceDate - .of(id) + return TripOnServiceDate.of(id) .withTrip(trip) .withServiceDate(serviceDate) .withTripAlteration(alteration) @@ -396,9 +392,8 @@ private Trip mapTrip( ) { return deduplicator.deduplicateObject( Trip.class, - tripMapper.mapServiceJourney( - serviceJourney, - () -> findTripHeadsign(journeyPattern, serviceJourney) + tripMapper.mapServiceJourney(serviceJourney, () -> + findTripHeadsign(journeyPattern, serviceJourney) ) ); } diff --git a/application/src/main/java/org/opentripplanner/netex/mapping/VehicleParkingMapper.java b/application/src/main/java/org/opentripplanner/netex/mapping/VehicleParkingMapper.java index f29d9760077..5b0e6c7c4c6 100644 --- a/application/src/main/java/org/opentripplanner/netex/mapping/VehicleParkingMapper.java +++ b/application/src/main/java/org/opentripplanner/netex/mapping/VehicleParkingMapper.java @@ -43,8 +43,7 @@ VehicleParking map(Parking parking) { ); return null; } - return VehicleParking - .builder() + return VehicleParking.builder() .id(idFactory.createId(parking.getId())) .name(NonLocalizedString.ofNullable(parking.getName().getValue())) .coordinate(WgsCoordinateMapper.mapToDomain(parking.getCentroid())) diff --git a/application/src/main/java/org/opentripplanner/netex/mapping/WheelChairMapper.java b/application/src/main/java/org/opentripplanner/netex/mapping/WheelChairMapper.java index 3735f22bda3..a9892916bd9 100644 --- a/application/src/main/java/org/opentripplanner/netex/mapping/WheelChairMapper.java +++ b/application/src/main/java/org/opentripplanner/netex/mapping/WheelChairMapper.java @@ -26,8 +26,7 @@ public static Accessibility wheelchairAccessibility( defaultValue = Accessibility.NO_INFORMATION; } - return Optional - .ofNullable(accessibilityAssessment) + return Optional.ofNullable(accessibilityAssessment) .map(AccessibilityAssessment::getLimitations) .map(AccessibilityLimitations_RelStructure::getAccessibilityLimitation) .map(AccessibilityLimitation::getWheelchairAccess) diff --git a/application/src/main/java/org/opentripplanner/netex/mapping/support/NetexMapperIndexes.java b/application/src/main/java/org/opentripplanner/netex/mapping/support/NetexMapperIndexes.java index 0af5527cfc8..62f23275e2f 100644 --- a/application/src/main/java/org/opentripplanner/netex/mapping/support/NetexMapperIndexes.java +++ b/application/src/main/java/org/opentripplanner/netex/mapping/support/NetexMapperIndexes.java @@ -37,10 +37,9 @@ public NetexMapperIndexes(NetexEntityIndexReadOnlyView index, NetexMapperIndexes } else { // Cached by level(shared files, shared group files and group files). If any entries exist at // the current level, then they will hide entries at a higher level. - this.datedServiceJourneysBySjId = - index.getDatedServiceJourneys().localKeys().isEmpty() - ? parent.datedServiceJourneysBySjId - : indexDSJBySJId(index.getDatedServiceJourneys()); + this.datedServiceJourneysBySjId = index.getDatedServiceJourneys().localKeys().isEmpty() + ? parent.datedServiceJourneysBySjId + : indexDSJBySJId(index.getDatedServiceJourneys()); // Feed global instances. These fields contain mapping from a netex id to a OTP domain // model object, hence we are not adding a lot of data to memory - only the id to object diff --git a/application/src/main/java/org/opentripplanner/netex/mapping/support/ServiceAlterationFilter.java b/application/src/main/java/org/opentripplanner/netex/mapping/support/ServiceAlterationFilter.java index f44add2c677..a6b2f3d6b73 100644 --- a/application/src/main/java/org/opentripplanner/netex/mapping/support/ServiceAlterationFilter.java +++ b/application/src/main/java/org/opentripplanner/netex/mapping/support/ServiceAlterationFilter.java @@ -7,10 +7,8 @@ public class ServiceAlterationFilter { public static boolean isRunning(ServiceAlterationEnumeration serviceAlteration) { return ( serviceAlteration == null || - ( - !serviceAlteration.equals(ServiceAlterationEnumeration.CANCELLATION) && - !serviceAlteration.equals(ServiceAlterationEnumeration.REPLACED) - ) + (!serviceAlteration.equals(ServiceAlterationEnumeration.CANCELLATION) && + !serviceAlteration.equals(ServiceAlterationEnumeration.REPLACED)) ); } } diff --git a/application/src/main/java/org/opentripplanner/netex/support/ServiceJourneyHelper.java b/application/src/main/java/org/opentripplanner/netex/support/ServiceJourneyHelper.java index 6ea6d93da28..8495f813443 100644 --- a/application/src/main/java/org/opentripplanner/netex/support/ServiceJourneyHelper.java +++ b/application/src/main/java/org/opentripplanner/netex/support/ServiceJourneyHelper.java @@ -22,8 +22,7 @@ public static int elapsedTimeSinceMidnight(LocalTime time, BigInteger dayOffset) private static int elapsedTimeSinceMidnight(LocalTime time, int dayOffset) { Objects.requireNonNull(time); - return (int) Duration - .between(LocalTime.MIDNIGHT, time) + return (int) Duration.between(LocalTime.MIDNIGHT, time) .plus(Duration.ofDays(dayOffset)) .toSeconds(); } diff --git a/application/src/main/java/org/opentripplanner/netex/support/ServiceJourneyInfo.java b/application/src/main/java/org/opentripplanner/netex/support/ServiceJourneyInfo.java index 16f936bdfdb..77c28278bd1 100644 --- a/application/src/main/java/org/opentripplanner/netex/support/ServiceJourneyInfo.java +++ b/application/src/main/java/org/opentripplanner/netex/support/ServiceJourneyInfo.java @@ -99,9 +99,8 @@ private Map scheduledStopPointIdByStopPointId() { .getPointInJourneyPatternOrStopPointInJourneyPatternOrTimingPointInJourneyPattern() .stream() .collect( - Collectors.toMap( - EntityStructure::getId, - p -> ((StopPointInJourneyPattern) p).getScheduledStopPointRef().getValue().getRef() + Collectors.toMap(EntityStructure::getId, p -> + ((StopPointInJourneyPattern) p).getScheduledStopPointRef().getValue().getRef() ) ); } diff --git a/application/src/main/java/org/opentripplanner/netex/validation/ServiceJourneyNonIncreasingPassingTime.java b/application/src/main/java/org/opentripplanner/netex/validation/ServiceJourneyNonIncreasingPassingTime.java index 3d3c0d6b544..383c9bbf681 100644 --- a/application/src/main/java/org/opentripplanner/netex/validation/ServiceJourneyNonIncreasingPassingTime.java +++ b/application/src/main/java/org/opentripplanner/netex/validation/ServiceJourneyNonIncreasingPassingTime.java @@ -36,7 +36,8 @@ class ServiceJourneyNonIncreasingPassingTime @Override public Status validate(ServiceJourney sj) { ServiceJourneyInfo serviceJourneyInfo = new ServiceJourneyInfo(sj, index); - List orderedPassingTimes = serviceJourneyInfo.orderedTimetabledPassingTimeInfos(); + List orderedPassingTimes = + serviceJourneyInfo.orderedTimetabledPassingTimeInfos(); var previousPassingTime = orderedPassingTimes.get(0); if (!previousPassingTime.isComplete()) { diff --git a/application/src/main/java/org/opentripplanner/osm/DefaultOsmProvider.java b/application/src/main/java/org/opentripplanner/osm/DefaultOsmProvider.java index f7dc0b2ebfd..131952b6797 100644 --- a/application/src/main/java/org/opentripplanner/osm/DefaultOsmProvider.java +++ b/application/src/main/java/org/opentripplanner/osm/DefaultOsmProvider.java @@ -88,8 +88,7 @@ public void readOsm(OsmDatabase osmdb) { @Override public String toString() { - return ToStringBuilder - .of(DefaultOsmProvider.class) + return ToStringBuilder.of(DefaultOsmProvider.class) .addObj("source", source) .addBool("cacheDataInMem", cacheDataInMem) .toString(); diff --git a/application/src/main/java/org/opentripplanner/osm/OsmOpeningHoursParser.java b/application/src/main/java/org/opentripplanner/osm/OsmOpeningHoursParser.java index 2391eb9aab4..7a4927ba694 100644 --- a/application/src/main/java/org/opentripplanner/osm/OsmOpeningHoursParser.java +++ b/application/src/main/java/org/opentripplanner/osm/OsmOpeningHoursParser.java @@ -416,9 +416,8 @@ private List splitPreviousBuilders( return previousOpeningHoursBuilders .stream() .flatMap(openingHoursBuilder -> { - var openingHoursBuilderAndNewBuilders = openingHoursBuilder.createBuildersForRelativeComplement( - closedOpeningHoursBuilder - ); + var openingHoursBuilderAndNewBuilders = + openingHoursBuilder.createBuildersForRelativeComplement(closedOpeningHoursBuilder); return openingHoursBuilderAndNewBuilders.newBuilders().stream(); }) .filter(Objects::nonNull) @@ -488,18 +487,14 @@ private boolean hasTimes(Rule rule) { private boolean is247Rule(Rule rule) { return ( (isOpenRule(rule) || isClosedRule(rule)) && - ( - rule.isTwentyfourseven() || - ( - rule.getHolidays() == null && + (rule.isTwentyfourseven() || + (rule.getHolidays() == null && rule.getYears() == null && rule.getDays() == null && rule.getTimes() == null && rule.getDates() == null && rule.getWeeks() == null && - rule.getComment() == null - ) - ) + rule.getComment() == null)) ); } diff --git a/application/src/main/java/org/opentripplanner/osm/model/OsmEntity.java b/application/src/main/java/org/opentripplanner/osm/model/OsmEntity.java index f9b30a1b211..80492ab9800 100644 --- a/application/src/main/java/org/opentripplanner/osm/model/OsmEntity.java +++ b/application/src/main/java/org/opentripplanner/osm/model/OsmEntity.java @@ -555,10 +555,8 @@ public boolean isParkAndRide() { String parkAndRide = getTag("park_ride"); return ( isParking() && - ( - (parkingType != null && parkingType.contains("park_and_ride")) || - (parkAndRide != null && !parkAndRide.equalsIgnoreCase("no")) - ) + ((parkingType != null && parkingType.contains("park_and_ride")) || + (parkAndRide != null && !parkAndRide.equalsIgnoreCase("no"))) ); } @@ -605,12 +603,10 @@ public boolean isRailwayPlatform() { */ public boolean isEntrance() { return ( - ( - isTag("railway", "subway_entrance") || + (isTag("railway", "subway_entrance") || isTag("highway", "elevator") || isTag("entrance", "yes") || - isTag("entrance", "main") - ) && + isTag("entrance", "main")) && !isTag("access", "private") && !isTag("access", "no") ); diff --git a/application/src/main/java/org/opentripplanner/osm/model/OsmWay.java b/application/src/main/java/org/opentripplanner/osm/model/OsmWay.java index 49f48c13981..c36bef12431 100644 --- a/application/src/main/java/org/opentripplanner/osm/model/OsmWay.java +++ b/application/src/main/java/org/opentripplanner/osm/model/OsmWay.java @@ -153,13 +153,11 @@ public boolean isBackwardEscalator() { public boolean isRoutableArea() { return ( !isTag("area", "no") && - ( - isTag("area", "yes") || + (isTag("area", "yes") || isParking() || isBikeParking() || isBoardingArea() || - isIndoorRoutable() - ) && + isIndoorRoutable()) && getNodeRefs().size() > 2 ); } diff --git a/application/src/main/java/org/opentripplanner/osm/tagmapping/FinlandMapper.java b/application/src/main/java/org/opentripplanner/osm/tagmapping/FinlandMapper.java index 32282f1d525..ae1d721d90d 100644 --- a/application/src/main/java/org/opentripplanner/osm/tagmapping/FinlandMapper.java +++ b/application/src/main/java/org/opentripplanner/osm/tagmapping/FinlandMapper.java @@ -37,11 +37,12 @@ class FinlandMapper extends OsmTagMapper { @Override public void populateProperties(WayPropertySet props) { - TriFunction defaultWalkSafetyForPermission = ( - permission, - speedLimit, - way - ) -> + TriFunction< + StreetTraversalPermission, + Float, + OsmEntity, + Double + > defaultWalkSafetyForPermission = (permission, speedLimit, way) -> switch (permission) { case ALL, PEDESTRIAN_AND_CAR -> { // ~35kph or under diff --git a/application/src/main/java/org/opentripplanner/osm/tagmapping/NorwayMapper.java b/application/src/main/java/org/opentripplanner/osm/tagmapping/NorwayMapper.java index 7f1e676c87d..cb996198162 100644 --- a/application/src/main/java/org/opentripplanner/osm/tagmapping/NorwayMapper.java +++ b/application/src/main/java/org/opentripplanner/osm/tagmapping/NorwayMapper.java @@ -151,7 +151,8 @@ else if (speedLimit >= 11.1f) { // 30 km/h or lower, or lower road class than unclassified if ( this.isMotorVehicleThroughTrafficExplicitlyDisallowed(way) - ) return cycleSafetyVeryLowTraffic; else return cycleSafetyLowTraffic; + ) return cycleSafetyVeryLowTraffic; + else return cycleSafetyLowTraffic; }; props.setDefaultBicycleSafetyForPermission((permission, speedLimit, way) -> diff --git a/application/src/main/java/org/opentripplanner/osm/wayproperty/WayPropertySet.java b/application/src/main/java/org/opentripplanner/osm/wayproperty/WayPropertySet.java index c26773765ab..5558dc605af 100644 --- a/application/src/main/java/org/opentripplanner/osm/wayproperty/WayPropertySet.java +++ b/application/src/main/java/org/opentripplanner/osm/wayproperty/WayPropertySet.java @@ -37,8 +37,12 @@ public class WayPropertySet { private static final Logger LOG = LoggerFactory.getLogger(WayPropertySet.class); /** Sets 1.0 as default safety value for all permissions. */ - private final TriFunction DEFAULT_SAFETY_RESOLVER = - ((permission, speedLimit, osmWay) -> 1.0); + private final TriFunction< + StreetTraversalPermission, + Float, + OsmEntity, + Double + > DEFAULT_SAFETY_RESOLVER = ((permission, speedLimit, osmWay) -> 1.0); private final List wayProperties; @@ -64,9 +68,19 @@ public class WayPropertySet { */ public float maxUsedCarSpeed = 0f; /** Resolves walk safety value for each {@link StreetTraversalPermission}. */ - private TriFunction defaultWalkSafetyForPermission; + private TriFunction< + StreetTraversalPermission, + Float, + OsmEntity, + Double + > defaultWalkSafetyForPermission; /** Resolves bicycle safety value for each {@link StreetTraversalPermission}. */ - private TriFunction defaultBicycleSafetyForPermission; + private TriFunction< + StreetTraversalPermission, + Float, + OsmEntity, + Double + > defaultBicycleSafetyForPermission; /** The WayProperties applied to all ways that do not match any WayPropertyPicker. */ private final WayProperties defaultProperties; private final DataImportIssueStore issueStore; @@ -236,8 +250,9 @@ public float getCarSpeedForWay(OsmEntity way, boolean backward) { } } - if (way.hasTag("maxspeed") && speed == null) speed = - getMetersSecondFromSpeed(way.getTag("maxspeed")); + if (way.hasTag("maxspeed") && speed == null) speed = getMetersSecondFromSpeed( + way.getTag("maxspeed") + ); if (speed != null) { // Too low (less than 5 km/h) or too high speed limit indicates an error in the data, @@ -431,7 +446,12 @@ public void setDefaultWalkSafetyForPermission( * provide a default for each permission. Safety can vary based on car speed limit on a way. */ public void setDefaultBicycleSafetyForPermission( - TriFunction defaultBicycleSafetyForPermission + TriFunction< + StreetTraversalPermission, + Float, + OsmEntity, + Double + > defaultBicycleSafetyForPermission ) { if (!this.defaultBicycleSafetyForPermission.equals(DEFAULT_SAFETY_RESOLVER)) { throw new IllegalStateException("A custom default cycling safety resolver was already set"); diff --git a/application/src/main/java/org/opentripplanner/osm/wayproperty/specifier/OsmSpecifier.java b/application/src/main/java/org/opentripplanner/osm/wayproperty/specifier/OsmSpecifier.java index 1fa8eddacf0..81add104220 100644 --- a/application/src/main/java/org/opentripplanner/osm/wayproperty/specifier/OsmSpecifier.java +++ b/application/src/main/java/org/opentripplanner/osm/wayproperty/specifier/OsmSpecifier.java @@ -11,8 +11,7 @@ */ public interface OsmSpecifier { static Condition[] parseConditions(String spec, String separator) { - return Arrays - .stream(spec.split(separator)) + return Arrays.stream(spec.split(separator)) .filter(p -> !p.isEmpty()) .map(pair -> { var kv = pair.split("="); diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/RoutingWorker.java b/application/src/main/java/org/opentripplanner/routing/algorithm/RoutingWorker.java index e0b06eab561..1ad51163a7f 100644 --- a/application/src/main/java/org/opentripplanner/routing/algorithm/RoutingWorker.java +++ b/application/src/main/java/org/opentripplanner/routing/algorithm/RoutingWorker.java @@ -74,20 +74,21 @@ public RoutingWorker(OtpServerRequestContext serverContext, RouteRequest request request.applyPageCursor(); this.request = request; this.serverContext = serverContext; - this.debugTimingAggregator = - new DebugTimingAggregator( - serverContext.meterRegistry(), - request.preferences().system().tags() - ); + this.debugTimingAggregator = new DebugTimingAggregator( + serverContext.meterRegistry(), + request.preferences().system().tags() + ); this.transitSearchTimeZero = ServiceDateUtils.asStartOfService(request.dateTime(), zoneId); - this.additionalSearchDays = - createAdditionalSearchDays(serverContext.raptorTuningParameters(), zoneId, request); - this.transitGroupPriorityService = - TransitGroupPriorityService.of( - request.preferences().transit().relaxTransitGroupPriority(), - request.journey().transit().priorityGroupsByAgency(), - request.journey().transit().priorityGroupsGlobal() - ); + this.additionalSearchDays = createAdditionalSearchDays( + serverContext.raptorTuningParameters(), + zoneId, + request + ); + this.transitGroupPriorityService = TransitGroupPriorityService.of( + request.preferences().transit().relaxTransitGroupPriority(), + request.journey().transit().priorityGroupsByAgency(), + request.journey().transit().priorityGroupsGlobal() + ); } public RoutingResponse route() { @@ -110,13 +111,11 @@ public RoutingResponse route() { // TODO: This is not using {@link OtpRequestThreadFactory} which means we do not get // log-trace-parameters-propagation and graceful timeout handling here. try { - CompletableFuture - .allOf( - CompletableFuture.runAsync(() -> routeDirectStreet(itineraries, routingErrors)), - CompletableFuture.runAsync(() -> routeDirectFlex(itineraries, routingErrors)), - CompletableFuture.runAsync(() -> routeTransit(itineraries, routingErrors)) - ) - .join(); + CompletableFuture.allOf( + CompletableFuture.runAsync(() -> routeDirectStreet(itineraries, routingErrors)), + CompletableFuture.runAsync(() -> routeDirectFlex(itineraries, routingErrors)), + CompletableFuture.runAsync(() -> routeTransit(itineraries, routingErrors)) + ).join(); } catch (CompletionException e) { RoutingValidationException.unwrapAndRethrowCompletionException(e); } diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/filterchain/api/GroupBySimilarity.java b/application/src/main/java/org/opentripplanner/routing/algorithm/filterchain/api/GroupBySimilarity.java index 5cec3046710..d43dfd22bf9 100644 --- a/application/src/main/java/org/opentripplanner/routing/algorithm/filterchain/api/GroupBySimilarity.java +++ b/application/src/main/java/org/opentripplanner/routing/algorithm/filterchain/api/GroupBySimilarity.java @@ -100,8 +100,7 @@ public static GroupBySimilarity createWithMoreThanOneItineraryPerGroup( @Override public String toString() { - return ToStringBuilder - .of(GroupBySimilarity.class) + return ToStringBuilder.of(GroupBySimilarity.class) .addNum("groupByP", groupByP) .addNum("maxNumOfItinerariesPerGroup", maxNumOfItinerariesPerGroup) .addBoolIfTrue("nestedGroupingByAllSameStations", nestedGroupingByAllSameStations) diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/filterchain/filters/system/NumItinerariesFilter.java b/application/src/main/java/org/opentripplanner/routing/algorithm/filterchain/filters/system/NumItinerariesFilter.java index 77c297fcfa5..5282a5e7526 100644 --- a/application/src/main/java/org/opentripplanner/routing/algorithm/filterchain/filters/system/NumItinerariesFilter.java +++ b/application/src/main/java/org/opentripplanner/routing/algorithm/filterchain/filters/system/NumItinerariesFilter.java @@ -30,8 +30,9 @@ public NumItinerariesFilter( ) { this.maxLimit = maxLimit; this.cropSection = cropSection; - this.pageCursorInputSubscriber = - pageCursorInputSubscriber == null ? IGNORE_SUBSCRIBER : pageCursorInputSubscriber; + this.pageCursorInputSubscriber = pageCursorInputSubscriber == null + ? IGNORE_SUBSCRIBER + : pageCursorInputSubscriber; } @Override diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/filterchain/filters/system/NumItinerariesFilterResults.java b/application/src/main/java/org/opentripplanner/routing/algorithm/filterchain/filters/system/NumItinerariesFilterResults.java index 401dc95026d..50bd83c7ead 100644 --- a/application/src/main/java/org/opentripplanner/routing/algorithm/filterchain/filters/system/NumItinerariesFilterResults.java +++ b/application/src/main/java/org/opentripplanner/routing/algorithm/filterchain/filters/system/NumItinerariesFilterResults.java @@ -58,8 +58,7 @@ public ItinerarySortKey pageCut() { @Override public String toString() { - return ToStringBuilder - .of(NumItinerariesFilterResults.class) + return ToStringBuilder.of(NumItinerariesFilterResults.class) .addDateTime("earliestRemovedDeparture", earliestRemovedDeparture) .addDateTime("latestRemovedDeparture", latestRemovedDeparture) .addObjOp("pageCut", pageCut, ItinerarySortKey::keyAsString) diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/filterchain/filters/system/SingleCriteriaComparator.java b/application/src/main/java/org/opentripplanner/routing/algorithm/filterchain/filters/system/SingleCriteriaComparator.java index fdaaf0d7657..632089f5557 100644 --- a/application/src/main/java/org/opentripplanner/routing/algorithm/filterchain/filters/system/SingleCriteriaComparator.java +++ b/application/src/main/java/org/opentripplanner/routing/algorithm/filterchain/filters/system/SingleCriteriaComparator.java @@ -21,7 +21,8 @@ */ @FunctionalInterface public interface SingleCriteriaComparator { - DefaultTransitGroupPriorityCalculator GROUP_PRIORITY_CALCULATOR = new DefaultTransitGroupPriorityCalculator(); + DefaultTransitGroupPriorityCalculator GROUP_PRIORITY_CALCULATOR = + new DefaultTransitGroupPriorityCalculator(); /** * The left criteria dominates the right criteria. Note! The right criteria may dominate @@ -48,8 +49,7 @@ static SingleCriteriaComparator compareGeneralizedCost() { @SuppressWarnings("OptionalGetWithoutIsPresent") static SingleCriteriaComparator compareTransitGroupsPriority() { return (left, right) -> - GROUP_PRIORITY_CALCULATOR - .dominanceFunction() + GROUP_PRIORITY_CALCULATOR.dominanceFunction() .leftDominateRight(left.getGeneralizedCost2().get(), right.getGeneralizedCost2().get()); } diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/filterchain/filters/transit/group/RemoveIfFirstOrLastTripIsTheSame.java b/application/src/main/java/org/opentripplanner/routing/algorithm/filterchain/filters/transit/group/RemoveIfFirstOrLastTripIsTheSame.java index bc72aada043..c894b72d9ac 100644 --- a/application/src/main/java/org/opentripplanner/routing/algorithm/filterchain/filters/transit/group/RemoveIfFirstOrLastTripIsTheSame.java +++ b/application/src/main/java/org/opentripplanner/routing/algorithm/filterchain/filters/transit/group/RemoveIfFirstOrLastTripIsTheSame.java @@ -23,7 +23,7 @@ public List flagForRemoval(List itineraries) { List filtered = new ArrayList<>(); List groups = new ArrayList<>(); - OUTER_LOOP:for (Itinerary it : itineraries) { + OUTER_LOOP: for (Itinerary it : itineraries) { GroupBySameFirstOrLastTrip currentGroup = new GroupBySameFirstOrLastTrip(it); for (GroupBySameFirstOrLastTrip group : groups) { diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/filterchain/framework/filter/RemoveFilter.java b/application/src/main/java/org/opentripplanner/routing/algorithm/filterchain/framework/filter/RemoveFilter.java index e83aa237cab..9607c9bc759 100644 --- a/application/src/main/java/org/opentripplanner/routing/algorithm/filterchain/framework/filter/RemoveFilter.java +++ b/application/src/main/java/org/opentripplanner/routing/algorithm/filterchain/framework/filter/RemoveFilter.java @@ -29,11 +29,10 @@ public String name() { public List filter(List itineraries) { List filterInput; if (flagger.skipAlreadyFlaggedItineraries()) { - filterInput = - itineraries - .stream() - .filter(Predicate.not(Itinerary::isFlaggedForDeletion)) - .collect(Collectors.toList()); + filterInput = itineraries + .stream() + .filter(Predicate.not(Itinerary::isFlaggedForDeletion)) + .collect(Collectors.toList()); } else { filterInput = itineraries; } diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/filterchain/framework/groupids/GroupByAllSameStations.java b/application/src/main/java/org/opentripplanner/routing/algorithm/filterchain/framework/groupids/GroupByAllSameStations.java index 83a5e15c802..258613bf729 100644 --- a/application/src/main/java/org/opentripplanner/routing/algorithm/filterchain/framework/groupids/GroupByAllSameStations.java +++ b/application/src/main/java/org/opentripplanner/routing/algorithm/filterchain/framework/groupids/GroupByAllSameStations.java @@ -20,18 +20,17 @@ public class GroupByAllSameStations implements GroupId { private final List keySet; public GroupByAllSameStations(Itinerary itinerary) { - keySet = - itinerary - .getLegs() - .stream() - .filter(Leg::isTransitLeg) - .map(leg -> - new FeedScopedIdPair( - leg.getFrom().stop.getStationOrStopId(), - leg.getTo().stop.getStationOrStopId() - ) + keySet = itinerary + .getLegs() + .stream() + .filter(Leg::isTransitLeg) + .map(leg -> + new FeedScopedIdPair( + leg.getFrom().stop.getStationOrStopId(), + leg.getTo().stop.getStationOrStopId() ) - .collect(Collectors.toList()); + ) + .collect(Collectors.toList()); } @Override diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/filterchain/framework/groupids/GroupByDistance.java b/application/src/main/java/org/opentripplanner/routing/algorithm/filterchain/framework/groupids/GroupByDistance.java index eb25cf9275c..af406126fe4 100644 --- a/application/src/main/java/org/opentripplanner/routing/algorithm/filterchain/framework/groupids/GroupByDistance.java +++ b/application/src/main/java/org/opentripplanner/routing/algorithm/filterchain/framework/groupids/GroupByDistance.java @@ -76,8 +76,7 @@ public GroupByDistance merge(GroupByDistance other) { @Override public String toString() { - return ToStringBuilder - .of(GroupByDistance.class) + return ToStringBuilder.of(GroupByDistance.class) .addBoolIfTrue("streetOnly", streetOnly) .addCol("keySet", keySet, GroupByDistance::keySetToString) .toString(); @@ -96,8 +95,10 @@ static double calculateTotalDistance(List legs) { /** package local to be unit-testable */ static List createKeySetOfLegsByLimit(List legs, double distanceLimitMeters) { // Sort legs descending on distance - legs = - legs.stream().sorted(Comparator.comparingDouble(Leg::getDistanceMeters).reversed()).toList(); + legs = legs + .stream() + .sorted(Comparator.comparingDouble(Leg::getDistanceMeters).reversed()) + .toList(); double sum = 0.0; int i = 0; @@ -140,8 +141,7 @@ private void assertPIsValid(double p) { } private static String keySetToString(Leg leg) { - var builder = ToStringBuilder - .of(leg.getClass()) + var builder = ToStringBuilder.of(leg.getClass()) .addTime("start", leg.getStartTime()) .addTime("end", leg.getStartTime()); diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/filterchain/framework/groupids/GroupBySameRoutesAndStops.java b/application/src/main/java/org/opentripplanner/routing/algorithm/filterchain/framework/groupids/GroupBySameRoutesAndStops.java index ac95ae87db7..b27c6200b77 100644 --- a/application/src/main/java/org/opentripplanner/routing/algorithm/filterchain/framework/groupids/GroupBySameRoutesAndStops.java +++ b/application/src/main/java/org/opentripplanner/routing/algorithm/filterchain/framework/groupids/GroupBySameRoutesAndStops.java @@ -20,19 +20,18 @@ public class GroupBySameRoutesAndStops implements GroupId keySet; public GroupBySameRoutesAndStops(Itinerary itinerary) { - keySet = - itinerary - .getLegs() - .stream() - .filter(Leg::isTransitLeg) - .flatMap(leg -> - Stream.of( - leg.getFrom().stop.getStationOrStopId(), - leg.getRoute().getId(), - leg.getTo().stop.getStationOrStopId() - ) + keySet = itinerary + .getLegs() + .stream() + .filter(Leg::isTransitLeg) + .flatMap(leg -> + Stream.of( + leg.getFrom().stop.getStationOrStopId(), + leg.getRoute().getId(), + leg.getTo().stop.getStationOrStopId() ) - .toList(); + ) + .toList(); } @Override diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/filterchain/framework/sort/SortOrderComparator.java b/application/src/main/java/org/opentripplanner/routing/algorithm/filterchain/framework/sort/SortOrderComparator.java index a904a6990ca..2a213975442 100644 --- a/application/src/main/java/org/opentripplanner/routing/algorithm/filterchain/framework/sort/SortOrderComparator.java +++ b/application/src/main/java/org/opentripplanner/routing/algorithm/filterchain/framework/sort/SortOrderComparator.java @@ -32,8 +32,7 @@ public class SortOrderComparator extends CompositeComparator { static final Comparator DEPARTURE_TIME_COMP = comparing( ItinerarySortKey::startTimeAsInstant - ) - .reversed(); + ).reversed(); static final Comparator GENERALIZED_COST_COMP = comparingInt( ItinerarySortKey::getGeneralizedCostIncludingPenalty diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/mapping/AlertToLegMapper.java b/application/src/main/java/org/opentripplanner/routing/algorithm/mapping/AlertToLegMapper.java index 1fceed4dc11..bd784d68914 100644 --- a/application/src/main/java/org/opentripplanner/routing/algorithm/mapping/AlertToLegMapper.java +++ b/application/src/main/java/org/opentripplanner/routing/algorithm/mapping/AlertToLegMapper.java @@ -86,9 +86,8 @@ public TransitLeg decorateWithAlerts(TransitLeg leg, boolean isFirstLeg) { Collection alerts = getAlertsForStopAndRoute(stop, routeId, stopConditions); alerts.addAll(getAlertsForStopAndTrip(stop, tripId, serviceDate, stopConditions)); alerts.addAll( - getAlertsForRelatedStops( - stop, - id -> transitAlertService.getStopAlerts(id, stopConditions) + getAlertsForRelatedStops(stop, id -> + transitAlertService.getStopAlerts(id, stopConditions) ) ); @@ -141,9 +140,8 @@ private Collection getAlertsForStopAndRoute( FeedScopedId routeId, Set stopConditions ) { - return getAlertsForRelatedStops( - stop, - id -> transitAlertService.getStopAndRouteAlerts(id, routeId, stopConditions) + return getAlertsForRelatedStops(stop, id -> + transitAlertService.getStopAndRouteAlerts(id, routeId, stopConditions) ); } @@ -153,9 +151,8 @@ private Collection getAlertsForStopAndTrip( LocalDate serviceDate, Set stopConditions ) { - return getAlertsForRelatedStops( - stop, - id -> transitAlertService.getStopAndTripAlerts(id, tripId, serviceDate, stopConditions) + return getAlertsForRelatedStops(stop, id -> + transitAlertService.getStopAndTripAlerts(id, tripId, serviceDate, stopConditions) ); } diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/mapping/GraphPathToItineraryMapper.java b/application/src/main/java/org/opentripplanner/routing/algorithm/mapping/GraphPathToItineraryMapper.java index 484a43da40c..36bb63fc084 100644 --- a/application/src/main/java/org/opentripplanner/routing/algorithm/mapping/GraphPathToItineraryMapper.java +++ b/application/src/main/java/org/opentripplanner/routing/algorithm/mapping/GraphPathToItineraryMapper.java @@ -84,10 +84,8 @@ public static boolean isRentalStationDropOff(State state) { public static boolean isFloatingRentalDropoff(State state) { return ( !state.isRentingVehicle() && - ( - state.getBackState() != null && - state.getBackState().getVehicleRentalState() == RENTING_FLOATING - ) + (state.getBackState() != null && + state.getBackState().getVehicleRentalState() == RENTING_FLOATING) ); } @@ -267,8 +265,7 @@ private static ElevationProfile encodeElevationProfileWithNaN( ) { var elevations = encodeElevationProfile(edge, distanceOffset, heightOffset); if (elevations.isEmpty()) { - return ElevationProfile - .of() + return ElevationProfile.of() .stepYUnknown(distanceOffset) .stepYUnknown(distanceOffset + edge.getDistanceMeters()) .build(); @@ -336,8 +333,7 @@ private Leg generateFlexLeg(List states) { ZonedDateTime endTime = toState.getTime().atZone(timeZone); int generalizedCost = (int) (toState.getWeight() - fromState.getWeight()); - return FlexibleTransitLeg - .of() + return FlexibleTransitLeg.of() .withFlexTripEdge(flexEdge) .withStartTime(startTime) .withEndTime(endTime) @@ -390,8 +386,7 @@ private StreetLeg generateLeg(List states, WalkStep previousStep) { State startTimeState = previousStateIsVehicleParking ? firstState.getBackState() : firstState; - StreetLegBuilder leg = StreetLeg - .create() + StreetLegBuilder leg = StreetLeg.create() .withMode(resolveMode(states)) .withStartTime(startTimeState.getTime().atZone(timeZone)) .withEndTime(lastState.getTime().atZone(timeZone)) diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/mapping/RaptorPathToItineraryMapper.java b/application/src/main/java/org/opentripplanner/routing/algorithm/mapping/RaptorPathToItineraryMapper.java index 86b4eefb2d9..310b2f32160 100644 --- a/application/src/main/java/org/opentripplanner/routing/algorithm/mapping/RaptorPathToItineraryMapper.java +++ b/application/src/main/java/org/opentripplanner/routing/algorithm/mapping/RaptorPathToItineraryMapper.java @@ -88,12 +88,11 @@ public RaptorPathToItineraryMapper( this.transferMode = request.journey().transfer().mode(); this.request = request; this.transferStreetRequest = StreetSearchRequestMapper.mapToTransferRequest(request).build(); - this.graphPathToItineraryMapper = - new GraphPathToItineraryMapper( - transitService.getTimeZone(), - graph.streetNotesService, - graph.ellipsoidToGeoidDifference - ); + this.graphPathToItineraryMapper = new GraphPathToItineraryMapper( + transitService.getTimeZone(), + graph.streetNotesService, + graph.ellipsoidToGeoidDifference + ); this.transitService = transitService; } @@ -301,8 +300,7 @@ private boolean isFree(EgressPathLeg egressPathLeg) { */ private Leg createTransferLegAtSameStop(PathLeg previousLeg, PathLeg nextLeg) { var transferStop = Place.forStop(raptorTransitData.getStopByIndex(previousLeg.toStop())); - return StreetLeg - .create() + return StreetLeg.create() .withMode(TraverseMode.WALK) .withStartTime(createZonedDateTime(previousLeg.toTime())) .withEndTime(createZonedDateTime(nextLeg.fromTime())) @@ -358,8 +356,7 @@ private List mapTransferLeg( List edges = transfer.getEdges(); if (edges == null || edges.isEmpty()) { return List.of( - StreetLeg - .create() + StreetLeg.create() .withMode(transferMode) .withStartTime(createZonedDateTime(pathLeg.fromTime())) .withEndTime(createZonedDateTime(pathLeg.toTime())) diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/mapping/RouteRequestToFilterChainMapper.java b/application/src/main/java/org/opentripplanner/routing/algorithm/mapping/RouteRequestToFilterChainMapper.java index 277efda3810..c81544319e8 100644 --- a/application/src/main/java/org/opentripplanner/routing/algorithm/mapping/RouteRequestToFilterChainMapper.java +++ b/application/src/main/java/org/opentripplanner/routing/algorithm/mapping/RouteRequestToFilterChainMapper.java @@ -127,9 +127,9 @@ public static ItineraryListFilterChain createFilterChain( private static double minBikeParkingDistance(RouteRequest request) { var modes = request.journey().modes(); - boolean hasBikePark = List - .of(modes.accessMode, modes.egressMode) - .contains(StreetMode.BIKE_TO_PARK); + boolean hasBikePark = List.of(modes.accessMode, modes.egressMode).contains( + StreetMode.BIKE_TO_PARK + ); double minBikeParkingDistance = 0; if (hasBikePark) { diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/mapping/StatesToWalkStepsMapper.java b/application/src/main/java/org/opentripplanner/routing/algorithm/mapping/StatesToWalkStepsMapper.java index 8ec6ac07e34..a0b7b18f1b0 100644 --- a/application/src/main/java/org/opentripplanner/routing/algorithm/mapping/StatesToWalkStepsMapper.java +++ b/application/src/main/java/org/opentripplanner/routing/algorithm/mapping/StatesToWalkStepsMapper.java @@ -108,14 +108,10 @@ private static boolean isUTurn(WalkStepBuilder twoBack, WalkStepBuilder lastStep RelativeDirection d1 = lastStep.relativeDirection(); RelativeDirection d2 = twoBack.relativeDirection(); return ( - ( - (d1 == RelativeDirection.RIGHT || d1 == RelativeDirection.HARD_RIGHT) && - (d2 == RelativeDirection.RIGHT || d2 == RelativeDirection.HARD_RIGHT) - ) || - ( - (d1 == RelativeDirection.LEFT || d1 == RelativeDirection.HARD_LEFT) && - (d2 == RelativeDirection.LEFT || d2 == RelativeDirection.HARD_LEFT) - ) + ((d1 == RelativeDirection.RIGHT || d1 == RelativeDirection.HARD_RIGHT) && + (d2 == RelativeDirection.RIGHT || d2 == RelativeDirection.HARD_RIGHT)) || + ((d1 == RelativeDirection.LEFT || d1 == RelativeDirection.HARD_LEFT) && + (d2 == RelativeDirection.LEFT || d2 == RelativeDirection.HARD_LEFT)) ); } @@ -207,8 +203,7 @@ private void processState(State backState, State forwardState) { // went on to or off of a roundabout edge.isRoundabout() != (roundaboutExit > 0) || - isLink(edge) && - !isLink(backState.getBackEdge()) + (isLink(edge) && !isLink(backState.getBackEdge())) ) { // Street name has changed, or we've gone on to or off of a roundabout. @@ -533,8 +528,7 @@ private WalkStepBuilder createStationEntranceWalkStep( State forwardState, StationEntranceVertex vertex ) { - Entrance entrance = Entrance - .of(vertex.id()) + Entrance entrance = Entrance.of(vertex.id()) .withCode(vertex.code()) .withCoordinate(new WgsCoordinate(vertex.getCoordinate())) .withWheelchairAccessibility(vertex.wheelchairAccessibility()) @@ -574,8 +568,7 @@ private void createAndSaveStep( private WalkStepBuilder createWalkStep(State forwardState, State backState) { Edge en = forwardState.getBackEdge(); - return WalkStep - .builder() + return WalkStep.builder() .withDirectionText(en.getName()) .withStartLocation(new WgsCoordinate(backState.getVertex().getCoordinate())) .withNameIsDerived(en.nameIsDerived()) diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/mapping/TripPlanMapper.java b/application/src/main/java/org/opentripplanner/routing/algorithm/mapping/TripPlanMapper.java index e9b4abe1ee7..f56792b7e71 100644 --- a/application/src/main/java/org/opentripplanner/routing/algorithm/mapping/TripPlanMapper.java +++ b/application/src/main/java/org/opentripplanner/routing/algorithm/mapping/TripPlanMapper.java @@ -21,16 +21,14 @@ public static TripPlan mapTripPlan(RouteRequest request, List itinera Place to; if (itineraries.isEmpty()) { - from = - placeFromGeoLocation( - request != null ? request.from() : null, - new LocalizedString("origin") - ); - to = - placeFromGeoLocation( - request != null ? request.to() : null, - new LocalizedString("destination") - ); + from = placeFromGeoLocation( + request != null ? request.from() : null, + new LocalizedString("origin") + ); + to = placeFromGeoLocation( + request != null ? request.to() : null, + new LocalizedString("destination") + ); } else { List legs = itineraries.get(0).getLegs(); from = legs.get(0).getFrom(); diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/path/PathDiff.java b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/path/PathDiff.java index a2e9a59f394..93088c82284 100644 --- a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/path/PathDiff.java +++ b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/path/PathDiff.java @@ -45,12 +45,11 @@ public class PathDiff { private PathDiff(RaptorPath path) { this.path = path; - this.walkDuration = - path - .legStream() - .filter(l -> l.isAccessLeg() || l.isTransferLeg() || l.isEgressLeg()) - .mapToInt(PathLeg::duration) - .sum(); + this.walkDuration = path + .legStream() + .filter(l -> l.isAccessLeg() || l.isTransferLeg() || l.isEgressLeg()) + .mapToInt(PathLeg::duration) + .sum(); this.routes.addAll(path.transitLegs().map(l -> l.trip().pattern().debugInfo()).toList()); this.stops.addAll(path.listStops()); } @@ -68,8 +67,7 @@ public static void logDiff( // Walk* is access + transfer + egress time, independent of street mode - could be flex // or bycycle as well. - TableBuilder tbl = Table - .of() + TableBuilder tbl = Table.of() .withAlights(Center, Right, Right, Right, Right, Right, Right, Left) .withHeaders("STATUS", "TX", "Duration", "Cost", "Walk*", "Start", "End", "Path"); diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/router/TransitRouter.java b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/router/TransitRouter.java index efb1e4d4021..142240607a3 100644 --- a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/router/TransitRouter.java +++ b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/router/TransitRouter.java @@ -207,12 +207,10 @@ private AccessEgresses fetchAccessEgresses() { try { // TODO: This is not using {@link OtpRequestThreadFactory} which mean we do not get // log-trace-parameters-propagation and graceful timeout handling here. - CompletableFuture - .allOf( - CompletableFuture.runAsync(() -> accessList.addAll(fetchAccess())), - CompletableFuture.runAsync(() -> egressList.addAll(fetchEgress())) - ) - .join(); + CompletableFuture.allOf( + CompletableFuture.runAsync(() -> accessList.addAll(fetchAccess())), + CompletableFuture.runAsync(() -> egressList.addAll(fetchEgress())) + ).join(); } catch (CompletionException e) { RoutingValidationException.unwrapAndRethrowCompletionException(e); } diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/router/performance/PerformanceTimersForRaptor.java b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/router/performance/PerformanceTimersForRaptor.java index d693b442eb8..39f3a1e3f93 100644 --- a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/router/performance/PerformanceTimersForRaptor.java +++ b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/router/performance/PerformanceTimersForRaptor.java @@ -25,10 +25,12 @@ public PerformanceTimersForRaptor( this.routingTags = routingTags; var tags = MicrometerUtils.mapTimingTags(routingTags); timerRoute = Timer.builder("raptor." + namePrefix + ".route").tags(tags).register(registry); - findTransitPerRound = - Timer.builder("raptor." + namePrefix + ".minute.transit").tags(tags).register(registry); - findTransfersPerRound = - Timer.builder("raptor." + namePrefix + ".minute.transfers").tags(tags).register(registry); + findTransitPerRound = Timer.builder("raptor." + namePrefix + ".minute.transit") + .tags(tags) + .register(registry); + findTransfersPerRound = Timer.builder("raptor." + namePrefix + ".minute.transfers") + .tags(tags) + .register(registry); } public Timer timerRoute() { diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/router/street/AccessEgressRouter.java b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/router/street/AccessEgressRouter.java index 0ae2df4e105..54014a8cb8e 100644 --- a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/router/street/AccessEgressRouter.java +++ b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/router/street/AccessEgressRouter.java @@ -63,8 +63,7 @@ public static Collection findAccessEgresses( maxStopCount, dataOverlayContext, ignoreVertices - ) - .findNearbyStops(originVertices, request, streetRequest, accessOrEgress.isEgress()); + ).findNearbyStops(originVertices, request, streetRequest, accessOrEgress.isEgress()); var results = ListUtils.combine(zeroDistanceAccessEgress, streetAccessEgress); LOG.debug("Found {} {} stops", results.size(), accessOrEgress); diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/Transfer.java b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/Transfer.java index 39922a63894..6e51846d470 100644 --- a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/Transfer.java +++ b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/Transfer.java @@ -150,8 +150,7 @@ private int costLimitSanityCheck(double cost) { @Override public String toString() { - return ToStringBuilder - .of(Transfer.class) + return ToStringBuilder.of(Transfer.class) .addNum("toStop", toStop) .addNum("distance", distanceMeters, "m") .toString(); diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/TripPatternForDate.java b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/TripPatternForDate.java index eeaf1312677..f254eb49ce3 100644 --- a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/TripPatternForDate.java +++ b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/TripPatternForDate.java @@ -69,39 +69,31 @@ public TripPatternForDate( // TODO: We expect a pattern only containing trips or frequencies, fix ability to merge if (hasFrequencies()) { - this.startOfRunningPeriod = - ServiceDateUtils - .asDateTime( - serviceDate, - frequencies - .stream() - .mapToInt(frequencyEntry -> frequencyEntry.startTime) - .min() - .orElseThrow() - ) - .toLocalDate(); - - this.endOfRunningPeriod = - ServiceDateUtils - .asDateTime( - serviceDate, - frequencies - .stream() - .mapToInt(frequencyEntry -> frequencyEntry.endTime) - .max() - .orElseThrow() - ) - .toLocalDate(); + this.startOfRunningPeriod = ServiceDateUtils.asDateTime( + serviceDate, + frequencies + .stream() + .mapToInt(frequencyEntry -> frequencyEntry.startTime) + .min() + .orElseThrow() + ).toLocalDate(); + + this.endOfRunningPeriod = ServiceDateUtils.asDateTime( + serviceDate, + frequencies.stream().mapToInt(frequencyEntry -> frequencyEntry.endTime).max().orElseThrow() + ).toLocalDate(); } else { // These depend on the tripTimes array being sorted var first = tripTimes.get(0); - this.startOfRunningPeriod = - ServiceDateUtils.asDateTime(serviceDate, first.getDepartureTime(0)).toLocalDate(); + this.startOfRunningPeriod = ServiceDateUtils.asDateTime( + serviceDate, + first.getDepartureTime(0) + ).toLocalDate(); var last = tripTimes.get(tripTimes.size() - 1); - this.endOfRunningPeriod = - ServiceDateUtils - .asDateTime(serviceDate, last.getArrivalTime(last.getNumStops() - 1)) - .toLocalDate(); + this.endOfRunningPeriod = ServiceDateUtils.asDateTime( + serviceDate, + last.getArrivalTime(last.getNumStops() - 1) + ).toLocalDate(); assertValidRunningPeriod(startOfRunningPeriod, endOfRunningPeriod, first, last); } } diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/constrainedtransfer/ConstrainedBoardingSearch.java b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/constrainedtransfer/ConstrainedBoardingSearch.java index 4e30aac24b4..feb29436748 100644 --- a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/constrainedtransfer/ConstrainedBoardingSearch.java +++ b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/constrainedtransfer/ConstrainedBoardingSearch.java @@ -27,9 +27,12 @@ public final class ConstrainedBoardingSearch */ private static final int ABORT_SEARCH_AFTER_N_VALID_NORMAL_TRIPS = 5; - private static final ConstrainedBoardingSearchStrategy FORWARD_STRATEGY = new ConstrainedBoardingSearchForward(); - private static final ConstrainedBoardingSearchStrategy REVERSE_STRATEGY = new ConstrainedBoardingSearchReverse(); - public static final RaptorConstrainedBoardingSearch NOOP_SEARCH = new NoopRaptorConstrainedBoardingSearch(); + private static final ConstrainedBoardingSearchStrategy FORWARD_STRATEGY = + new ConstrainedBoardingSearchForward(); + private static final ConstrainedBoardingSearchStrategy REVERSE_STRATEGY = + new ConstrainedBoardingSearchReverse(); + public static final RaptorConstrainedBoardingSearch NOOP_SEARCH = + new NoopRaptorConstrainedBoardingSearch(); /** Handle forward and reverse specific tasks */ private final ConstrainedBoardingSearchStrategy searchStrategy; @@ -163,7 +166,7 @@ private boolean findTimetableTripInfo( boolean useNextNormalTrip = false; var index = searchStrategy.scheduleIndexIterator(timetable); - outer:while (index.hasNext()) { + outer: while (index.hasNext()) { onTripIndex = index.next(); var it = timetable.getTripSchedule(onTripIndex); @@ -181,13 +184,12 @@ private boolean findTimetableTripInfo( for (TransferForPattern tx : transfers) { onTripTxConstraint = (TransferConstraint) tx.getTransferConstraint(); - onTripEarliestBoardTime = - onTripTxConstraint.calculateTransferTargetTime( - sourceTransitArrivalTime, - transferSlack, - () -> earliestBoardTime, - searchStrategy.direction() - ); + onTripEarliestBoardTime = onTripTxConstraint.calculateTransferTargetTime( + sourceTransitArrivalTime, + transferSlack, + () -> earliestBoardTime, + searchStrategy.direction() + ); if (!onTripTxConstraint.isFacilitated()) { if (searchStrategy.timeIsBefore(time, onTripEarliestBoardTime)) { diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/constrainedtransfer/ConstrainedTransfersForPatterns.java b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/constrainedtransfer/ConstrainedTransfersForPatterns.java index 670c223e87d..b201bdaba7d 100644 --- a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/constrainedtransfer/ConstrainedTransfersForPatterns.java +++ b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/constrainedtransfer/ConstrainedTransfersForPatterns.java @@ -47,8 +47,7 @@ public int hashCode() { @Override public String toString() { - return ToStringBuilder - .of(ConstrainedTransfersForPatterns.class) + return ToStringBuilder.of(ConstrainedTransfersForPatterns.class) .addCol("to", transfersToStop) .addCol("from", transfersFromStop) .toString(); diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/constrainedtransfer/TransferPointForPatternFactory.java b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/constrainedtransfer/TransferPointForPatternFactory.java index cad5373500c..a382b4993ad 100644 --- a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/constrainedtransfer/TransferPointForPatternFactory.java +++ b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/constrainedtransfer/TransferPointForPatternFactory.java @@ -45,10 +45,9 @@ private static class StationSP implements TransferPointMatcher { private final TIntSet childStops; private StationSP(Station station) { - this.childStops = - new TIntHashSet( - station.getChildStops().stream().mapToInt(StopLocation::getIndex).toArray() - ); + this.childStops = new TIntHashSet( + station.getChildStops().stream().mapToInt(StopLocation::getIndex).toArray() + ); } @Override diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/cost/CostCalculatorFactory.java b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/cost/CostCalculatorFactory.java index a10cf828b45..aee2a23b94a 100644 --- a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/cost/CostCalculatorFactory.java +++ b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/cost/CostCalculatorFactory.java @@ -15,21 +15,19 @@ public static RaptorCostCalculator createCost ); if (generalizedCostParameters.wheelchairEnabled()) { - calculator = - new WheelchairCostCalculator<>( - calculator, - generalizedCostParameters.wheelchairAccessibility() - ); + calculator = new WheelchairCostCalculator<>( + calculator, + generalizedCostParameters.wheelchairAccessibility() + ); } // append RouteCostCalculator to calculator stack if (un)preferred routes exist if (!generalizedCostParameters.unpreferredPatterns().isEmpty()) { - calculator = - new PatternCostCalculator<>( - calculator, - generalizedCostParameters.unpreferredPatterns(), - generalizedCostParameters.unnpreferredCost() - ); + calculator = new PatternCostCalculator<>( + calculator, + generalizedCostParameters.unpreferredPatterns(), + generalizedCostParameters.unnpreferredCost() + ); } return calculator; diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/cost/DefaultCostCalculator.java b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/cost/DefaultCostCalculator.java index 3c07161e67e..c51b15d94ab 100644 --- a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/cost/DefaultCostCalculator.java +++ b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/cost/DefaultCostCalculator.java @@ -48,10 +48,9 @@ public DefaultCostCalculator( this.boardAndTransferCost = transferCostOnly + boardCostOnly; this.waitFactor = RaptorCostConverter.toRaptorCost(waitReluctanceFactor); - this.transitFactors = - transitReluctanceFactors == null - ? new SingleValueFactorStrategy(GeneralizedCostParameters.DEFAULT_TRANSIT_RELUCTANCE) - : new IndexBasedFactorStrategy(transitReluctanceFactors); + this.transitFactors = transitReluctanceFactors == null + ? new SingleValueFactorStrategy(GeneralizedCostParameters.DEFAULT_TRANSIT_RELUCTANCE) + : new IndexBasedFactorStrategy(transitReluctanceFactors); this.stopBoardAlightTransferCosts = stopBoardAlightTransferCosts; } @@ -111,10 +110,8 @@ public int transitArrivalCost( ) { int cost = boardCost + - transitFactors.factor(trip.transitReluctanceFactorIndex()) * - transitTime + - waitFactor * - alightSlack; + transitFactors.factor(trip.transitReluctanceFactorIndex()) * transitTime + + waitFactor * alightSlack; // Add transfer cost on all alighting events. // If it turns out to be the last one this cost will be removed during costEgress phase. @@ -135,10 +132,8 @@ public int calculateRemainingMinCost(int minTravelTime, int minNumTransfers, int if (minNumTransfers > -1) { return ( boardCostOnly + - boardAndTransferCost * - minNumTransfers + - transitFactors.minFactor() * - minTravelTime + boardAndTransferCost * minNumTransfers + + transitFactors.minFactor() * minTravelTime ); } else { // Remove cost that was added during alighting similar as we do in the costEgress() method diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/cost/GeneralizedCostParameters.java b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/cost/GeneralizedCostParameters.java index eee0fbf36c0..9af6e384026 100644 --- a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/cost/GeneralizedCostParameters.java +++ b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/cost/GeneralizedCostParameters.java @@ -127,8 +127,7 @@ public boolean equals(Object o) { @Override public String toString() { - return ToStringBuilder - .of(GeneralizedCostParameters.class) + return ToStringBuilder.of(GeneralizedCostParameters.class) .addNum("boardCost", boardCost, DEFAULTS.boardCost) .addNum("transferCost", transferCost, DEFAULTS.transferCost) .addNum("waitReluctanceFactor", waitReluctanceFactor, DEFAULTS.waitReluctanceFactor) diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/cost/WheelchairCostCalculator.java b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/cost/WheelchairCostCalculator.java index 693cac45031..69e27d5fe50 100644 --- a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/cost/WheelchairCostCalculator.java +++ b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/cost/WheelchairCostCalculator.java @@ -82,12 +82,11 @@ private static int[] createWheelchairCost(AccessibilityPreferences requirements) int[] costIndex = new int[Accessibility.values().length]; for (var it : Accessibility.values()) { - costIndex[it.ordinal()] = - switch (it) { - case POSSIBLE -> RaptorCostCalculator.ZERO_COST; - case NO_INFORMATION -> RaptorCostConverter.toRaptorCost(requirements.unknownCost()); - case NOT_POSSIBLE -> RaptorCostConverter.toRaptorCost(requirements.inaccessibleCost()); - }; + costIndex[it.ordinal()] = switch (it) { + case POSSIBLE -> RaptorCostCalculator.ZERO_COST; + case NO_INFORMATION -> RaptorCostConverter.toRaptorCost(requirements.unknownCost()); + case NOT_POSSIBLE -> RaptorCostConverter.toRaptorCost(requirements.inaccessibleCost()); + }; } return costIndex; } diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/GeneralizedCostParametersMapper.java b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/GeneralizedCostParametersMapper.java index 49f348fb753..295816f213d 100644 --- a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/GeneralizedCostParametersMapper.java +++ b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/GeneralizedCostParametersMapper.java @@ -52,10 +52,8 @@ public static GeneralizedCostParameters map( for (var pattern : patternIndex) { if ( pattern != null && - ( - unpreferredRoutes.contains(pattern.route().getId()) || - unpreferredAgencies.contains(pattern.route().getAgency().getId()) - ) + (unpreferredRoutes.contains(pattern.route().getId()) || + unpreferredAgencies.contains(pattern.route().getAgency().getId())) ) { unpreferredPatterns.set(pattern.patternIndex()); } diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/RaptorRequestMapper.java b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/RaptorRequestMapper.java index 43956616915..6c3d118fe72 100644 --- a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/RaptorRequestMapper.java +++ b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/RaptorRequestMapper.java @@ -84,8 +84,7 @@ public static RaptorRequest mapRequest( meterRegistry, viaTransferResolver, lookUpStopIndex - ) - .doMap(); + ).doMap(); } private RaptorRequest doMap() { diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/RaptorTransitDataMapper.java b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/RaptorTransitDataMapper.java index 55ff80e7b30..632af1ce1a3 100644 --- a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/RaptorTransitDataMapper.java +++ b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/RaptorTransitDataMapper.java @@ -75,8 +75,10 @@ private RaptorTransitData map(TransitTuningParameters tuningParameters) { TransferIndexGenerator transferIndexGenerator = null; if (OTPFeature.TransferConstraints.isOn()) { - transferIndexGenerator = - new TransferIndexGenerator(transitService.getTransferService().listAll(), allTripPatterns); + transferIndexGenerator = new TransferIndexGenerator( + transitService.getTransferService().listAll(), + allTripPatterns + ); constrainedTransfers = transferIndexGenerator.generateTransfers(); } diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/RealTimeRaptorTransitDataUpdater.java b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/RealTimeRaptorTransitDataUpdater.java index 81e4fbac2c3..575a6dc32d3 100644 --- a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/RealTimeRaptorTransitDataUpdater.java +++ b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/RealTimeRaptorTransitDataUpdater.java @@ -45,15 +45,22 @@ public class RealTimeRaptorTransitDataUpdater { * Cache the TripPatternForDates indexed on the original TripPatterns in order to avoid this * expensive operation being done each time the update method is called. */ - private final Map> tripPatternsStartingOnDateMapCache = new HashMap<>(); + private final Map< + LocalDate, + Map + > tripPatternsStartingOnDateMapCache = new HashMap<>(); /** * Cache the TripPatternForDate currently in use for a trip and service date. Only one TripPatternForDate is allowed * for a trip id and service date. This cache is used to clean up extra tripPatternsForDate. */ - private final Map tripPatternsForTripIdAndServiceDateCache = new HashMap<>(); + private final Map< + TripIdAndServiceDate, + TripPatternForDate + > tripPatternsForTripIdAndServiceDateCache = new HashMap<>(); - private final Map> tripPatternsRunningOnDateMapCache = new HashMap<>(); + private final Map> tripPatternsRunningOnDateMapCache = + new HashMap<>(); public RealTimeRaptorTransitDataUpdater(TimetableRepository timetableRepository) { this.timetableRepository = timetableRepository; @@ -137,10 +144,8 @@ public void update( triptimes.getTrip().getId(), timetable.getServiceDate() ); - TripPatternForDate previousTripPatternForDate = tripPatternsForTripIdAndServiceDateCache.put( - id, - newTripPatternForDate - ); + TripPatternForDate previousTripPatternForDate = + tripPatternsForTripIdAndServiceDateCache.put(id, newTripPatternForDate); if (previousTripPatternForDate != null) { previouslyUsedPatterns.add(previousTripPatternForDate); } else { @@ -157,9 +162,8 @@ public void update( // Now loop through all running period dates of old and new TripPatternsForDate and update // the tripPatternsByRunningPeriodDate accordingly for (LocalDate date : datesToBeUpdated) { - tripPatternsRunningOnDateMapCache.computeIfAbsent( - date, - p -> new HashSet<>(realtimeRaptorTransitData.getTripPatternsRunningOnDateCopy(date)) + tripPatternsRunningOnDateMapCache.computeIfAbsent(date, p -> + new HashSet<>(realtimeRaptorTransitData.getTripPatternsRunningOnDateCopy(date)) ); // Remove old cached tripPatterns where tripTimes are no longer running diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/TransfersMapper.java b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/TransfersMapper.java index 9fc49c5c5e1..6c9af35d48e 100644 --- a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/TransfersMapper.java +++ b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/TransfersMapper.java @@ -34,15 +34,17 @@ static List> mapTransfers( int toStopIndex = pathTransfer.to.getIndex(); Transfer newTransfer; if (pathTransfer.getEdges() != null) { - newTransfer = - new Transfer(toStopIndex, pathTransfer.getEdges(), pathTransfer.getModes()); + newTransfer = new Transfer( + toStopIndex, + pathTransfer.getEdges(), + pathTransfer.getModes() + ); } else { - newTransfer = - new Transfer( - toStopIndex, - (int) Math.ceil(pathTransfer.getDistanceMeters()), - pathTransfer.getModes() - ); + newTransfer = new Transfer( + toStopIndex, + (int) Math.ceil(pathTransfer.getDistanceMeters()), + pathTransfer.getModes() + ); } list.add(newTransfer); diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/RaptorRequestTransferCache.java b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/RaptorRequestTransferCache.java index 80814fdeee2..3e2f457998c 100644 --- a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/RaptorRequestTransferCache.java +++ b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/RaptorRequestTransferCache.java @@ -123,14 +123,14 @@ public StreetRelevantOptions(StreetSearchRequest request) { this.walk = preferences.walk(); this.bike = transferMode.includesBiking() ? preferences.bike() : BikePreferences.DEFAULT; this.street = preferences.street(); - this.wheelchairPreferences = - this.wheelchair ? preferences.wheelchair() : WheelchairPreferences.DEFAULT; + this.wheelchairPreferences = this.wheelchair + ? preferences.wheelchair() + : WheelchairPreferences.DEFAULT; } @Override public String toString() { - return ToStringBuilder - .of(StreetRelevantOptions.class) + return ToStringBuilder.of(StreetRelevantOptions.class) .addEnum("transferMode", transferMode) .addBoolIfTrue("wheelchair", wheelchair) .addObj("walk", walk, WalkPreferences.DEFAULT) diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/RaptorRoutingRequestTransitData.java b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/RaptorRoutingRequestTransitData.java index 5d109d77455..b41866be613 100644 --- a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/RaptorRoutingRequestTransitData.java +++ b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/RaptorRoutingRequestTransitData.java @@ -102,30 +102,26 @@ public RaptorRoutingRequestTransitData( var mcCostParams = GeneralizedCostParametersMapper.map(request, patternIndex); - this.generalizedCostCalculator = - CostCalculatorFactory.createCostCalculator( - mcCostParams, - raptorTransitData.getStopBoardAlightTransferCosts() - ); - - this.slackProvider = - new SlackProvider( - (int) request.preferences().transfer().slack().toSeconds(), - request.preferences().transit().boardSlack(), - request.preferences().transit().alightSlack() - ); - - this.validTransitDataStartTime = - ServiceDateUtils.secondsSinceStartOfTime( - this.transitSearchTimeZero, - this.transitSearchTimeZero.minusDays(additionalPastSearchDays).toInstant() - ); + this.generalizedCostCalculator = CostCalculatorFactory.createCostCalculator( + mcCostParams, + raptorTransitData.getStopBoardAlightTransferCosts() + ); + + this.slackProvider = new SlackProvider( + (int) request.preferences().transfer().slack().toSeconds(), + request.preferences().transit().boardSlack(), + request.preferences().transit().alightSlack() + ); + + this.validTransitDataStartTime = ServiceDateUtils.secondsSinceStartOfTime( + this.transitSearchTimeZero, + this.transitSearchTimeZero.minusDays(additionalPastSearchDays).toInstant() + ); // The +1 is due to the validity being to the end of the day - this.validTransitDataEndTime = - ServiceDateUtils.secondsSinceStartOfTime( - this.transitSearchTimeZero, - this.transitSearchTimeZero.plusDays(additionalFutureSearchDays + 1).toInstant() - ); + this.validTransitDataEndTime = ServiceDateUtils.secondsSinceStartOfTime( + this.transitSearchTimeZero, + this.transitSearchTimeZero.plusDays(additionalFutureSearchDays + 1).toInstant() + ); } public RaptorRoutingRequestTransitData( diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/RaptorRoutingRequestTransitDataCreator.java b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/RaptorRoutingRequestTransitDataCreator.java index d00d4747f09..3980c65071d 100644 --- a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/RaptorRoutingRequestTransitDataCreator.java +++ b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/RaptorRoutingRequestTransitDataCreator.java @@ -111,7 +111,10 @@ static List merge( // For each TripPattern, time expand each TripPatternForDate and merge into a single // TripPatternForDates - for (Map.Entry> patternEntry : patternForDateByPattern.entrySet()) { + for (Map.Entry< + RoutingTripPattern, + List + > patternEntry : patternForDateByPattern.entrySet()) { // Sort by date. We can mutate the array, as it was created above in the grouping. TripPatternForDate[] patternsSorted = patternEntry .getValue() @@ -186,9 +189,8 @@ private static List filterActiveTripPatterns( filter.tripTimesPredicate(tripTimes, filter.hasSubModeFilters()); Predicate tripTimesWithoutSubmodesPredicate = tripTimes -> filter.tripTimesPredicate(tripTimes, false); - Collection tripPatternsForDate = raptorTransitData.getTripPatternsForRunningDate( - date - ); + Collection tripPatternsForDate = + raptorTransitData.getTripPatternsForRunningDate(date); List result = new ArrayList<>(tripPatternsForDate.size()); for (TripPatternForDate p : tripPatternsForDate) { if (firstDay || p.getStartOfRunningPeriod().equals(date)) { diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/TripPatternForDates.java b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/TripPatternForDates.java index a94aa0850ba..35c46478111 100644 --- a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/TripPatternForDates.java +++ b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/TripPatternForDates.java @@ -263,8 +263,7 @@ public RaptorTripScheduleSearch createCustomizedTripSearch( @Override public String toString() { - return ToStringBuilder - .of(TripPatternForDates.class) + return ToStringBuilder.of(TripPatternForDates.class) .addObj("pattern", debugInfo()) .addServiceTimeSchedule("offsets", offsets) .addNum("nTrips", numberOfTripSchedules) diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/TripScheduleAlightSearch.java b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/TripScheduleAlightSearch.java index 628a16511ce..e91c4bb9f4b 100644 --- a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/TripScheduleAlightSearch.java +++ b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/TripScheduleAlightSearch.java @@ -122,8 +122,7 @@ public RaptorBoardOrAlightEvent search( @Override public String toString() { - return ToStringBuilder - .of(TripScheduleAlightSearch.class) + return ToStringBuilder.of(TripScheduleAlightSearch.class) .addObj("nTrips", nTrips) .addObj("latestAlightTime", latestAlightTime) .addObj("stopPos", stopPositionInPattern) diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/TripScheduleBoardSearch.java b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/TripScheduleBoardSearch.java index 7bd5062d8dc..ac498a42d72 100644 --- a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/TripScheduleBoardSearch.java +++ b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/TripScheduleBoardSearch.java @@ -121,8 +121,7 @@ public RaptorBoardOrAlightEvent search( @Override public String toString() { - return ToStringBuilder - .of(TripScheduleBoardSearch.class) + return ToStringBuilder.of(TripScheduleBoardSearch.class) .addObj("nTrips", nTrips) .addObj("earliestBoardTime", earliestBoardTime) .addObj("stopPos", stopPositionInPattern) diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/TripScheduleWithOffset.java b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/TripScheduleWithOffset.java index d692f0079f6..58ac2a7314e 100644 --- a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/TripScheduleWithOffset.java +++ b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/TripScheduleWithOffset.java @@ -105,8 +105,7 @@ public int getSecondsOffset() { @Override public String toString() { - return ToStringBuilder - .of(TripScheduleWithOffset.class) + return ToStringBuilder.of(TripScheduleWithOffset.class) .addObj("info", pattern.debugInfo()) .addObjOpSafe("id", () -> tripTimes.getTrip().getId()) .addObjOpSafe("pattern.id", () -> pattern.getTripPattern().getPattern().getId()) diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/transferoptimization/api/OptimizedPath.java b/application/src/main/java/org/opentripplanner/routing/algorithm/transferoptimization/api/OptimizedPath.java index f2a36e1678c..dd9a8f5773f 100644 --- a/application/src/main/java/org/opentripplanner/routing/algorithm/transferoptimization/api/OptimizedPath.java +++ b/application/src/main/java/org/opentripplanner/routing/algorithm/transferoptimization/api/OptimizedPath.java @@ -104,9 +104,8 @@ private static int priorityCost(RaptorPath path) { private static int priorityCost(PathLeg leg) { // Only calculate priority cost for transit legs which are followed by at least one // other transit leg. - return priorityCost( - leg.isTransitLeg() && leg.nextTransitLeg() != null, - () -> leg.asTransitLeg().getConstrainedTransferAfterLeg() + return priorityCost(leg.isTransitLeg() && leg.nextTransitLeg() != null, () -> + leg.asTransitLeg().getConstrainedTransferAfterLeg() ); } diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/transferoptimization/configure/TransferOptimizationServiceConfigurator.java b/application/src/main/java/org/opentripplanner/routing/algorithm/transferoptimization/configure/TransferOptimizationServiceConfigurator.java index 2945fc1b1df..c962e837630 100644 --- a/application/src/main/java/org/opentripplanner/routing/algorithm/transferoptimization/configure/TransferOptimizationServiceConfigurator.java +++ b/application/src/main/java/org/opentripplanner/routing/algorithm/transferoptimization/configure/TransferOptimizationServiceConfigurator.java @@ -58,9 +58,9 @@ private TransferOptimizationServiceConfigurator( /** * Scope: Request */ - public static < - T extends RaptorTripSchedule - > OptimizeTransferService createOptimizeTransferService( + public static OptimizeTransferService< + T + > createOptimizeTransferService( IntFunction stopLookup, RaptorStopNameResolver stopNameResolver, TransferService transferService, @@ -77,8 +77,7 @@ > OptimizeTransferService createOptimizeTransferService( stopBoardAlightTransferCosts, config, viaLocations - ) - .createOptimizeTransferService(); + ).createOptimizeTransferService(); } private OptimizeTransferService createOptimizeTransferService() { @@ -148,8 +147,7 @@ private PathTailFilter createFilter() { var filter = new MinCostPathTailFilterFactory( config.optimizeTransferPriority(), config.optimizeTransferWaitTime() - ) - .createFilter(); + ).createFilter(); if (!viaLocations.isEmpty()) { filter = new PassThroughPathTailFilter<>(filter, viaLocations); diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/transferoptimization/model/BasicStopTime.java b/application/src/main/java/org/opentripplanner/routing/algorithm/transferoptimization/model/BasicStopTime.java index 5fd9e73e398..26c4f6a2f69 100644 --- a/application/src/main/java/org/opentripplanner/routing/algorithm/transferoptimization/model/BasicStopTime.java +++ b/application/src/main/java/org/opentripplanner/routing/algorithm/transferoptimization/model/BasicStopTime.java @@ -43,8 +43,7 @@ public boolean equals(Object o) { @Override public String toString() { - return ValueObjectToStringBuilder - .of() + return ValueObjectToStringBuilder.of() .addText("[") .addNum(stop) .addServiceTime(time) diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/transferoptimization/model/MinSafeTransferTimeCalculator.java b/application/src/main/java/org/opentripplanner/routing/algorithm/transferoptimization/model/MinSafeTransferTimeCalculator.java index fde6b3d4a64..c63ba3e5143 100644 --- a/application/src/main/java/org/opentripplanner/routing/algorithm/transferoptimization/model/MinSafeTransferTimeCalculator.java +++ b/application/src/main/java/org/opentripplanner/routing/algorithm/transferoptimization/model/MinSafeTransferTimeCalculator.java @@ -87,7 +87,7 @@ public static int minSafeTransferTimeOp( return MIN_SAFE_TRANSFER_TIME_LIMIT_UPPER_BOUND; } int minTransitTime = list.stream().mapToInt(transitTimeSeconds).min().getAsInt(); - int minSafeTransitTime = IntUtils.round(minTransitTime * P / 100.0); + int minSafeTransitTime = IntUtils.round((minTransitTime * P) / 100.0); return bound( minSafeTransitTime, MIN_SAFE_TRANSFER_TIME_LIMIT_LOWER_BOUND, diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/transferoptimization/model/OptimizedPathTail.java b/application/src/main/java/org/opentripplanner/routing/algorithm/transferoptimization/model/OptimizedPathTail.java index efe53d8e090..a69e36b426b 100644 --- a/application/src/main/java/org/opentripplanner/routing/algorithm/transferoptimization/model/OptimizedPathTail.java +++ b/application/src/main/java/org/opentripplanner/routing/algorithm/transferoptimization/model/OptimizedPathTail.java @@ -51,13 +51,13 @@ public OptimizedPathTail( ) { super(slackProvider, iterationDepartureTime, costCalculator, stopNameResolver, null); this.waitTimeCostCalculator = waitTimeCostCalculator; - this.stopPriorityCostCalculator = - (stopBoardAlightTransferCosts != null && extraStopBoardAlightCostsFactor > 0.01) - ? new StopPriorityCostCalculator( - extraStopBoardAlightCostsFactor, - stopBoardAlightTransferCosts - ) - : null; + this.stopPriorityCostCalculator = (stopBoardAlightTransferCosts != null && + extraStopBoardAlightCostsFactor > 0.01) + ? new StopPriorityCostCalculator( + extraStopBoardAlightCostsFactor, + stopBoardAlightTransferCosts + ) + : null; } private OptimizedPathTail(OptimizedPathTail other) { @@ -215,16 +215,19 @@ private void updateGeneralizedCost() { if (skipCostCalc()) { return; } - this.generalizedCost = - legsAsStream().mapToInt(it -> it.c1(costCalculator(), slackProvider())).sum(); + this.generalizedCost = legsAsStream() + .mapToInt(it -> it.c1(costCalculator(), slackProvider())) + .sum(); } /*private methods */ private void addTransferPriorityCost(PathBuilderLeg pathLeg) { boolean transferExist = pathLeg.isTransit() && pathLeg.nextTransitLeg() != null; - this.transferPriorityCost += - OptimizedPath.priorityCost(transferExist, pathLeg::constrainedTransferAfterLeg); + this.transferPriorityCost += OptimizedPath.priorityCost( + transferExist, + pathLeg::constrainedTransferAfterLeg + ); } /** diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/transferoptimization/model/TransferWaitTimeCostCalculator.java b/application/src/main/java/org/opentripplanner/routing/algorithm/transferoptimization/model/TransferWaitTimeCostCalculator.java index ee33f1d86c3..b7353da807c 100644 --- a/application/src/main/java/org/opentripplanner/routing/algorithm/transferoptimization/model/TransferWaitTimeCostCalculator.java +++ b/application/src/main/java/org/opentripplanner/routing/algorithm/transferoptimization/model/TransferWaitTimeCostCalculator.java @@ -160,7 +160,7 @@ public void setMinSafeTransferTime(int minSafeTransferTime) { } double avoidShortWaitTimeCost(int waitTime) { - return n * t0 / (1d + (n - 1d) * Math.log1p(a * waitTime)); + return (n * t0) / (1d + (n - 1d) * Math.log1p(a * waitTime)); } double avoidBackTravelCost(int waitTime) { diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/transferoptimization/model/TripStopTime.java b/application/src/main/java/org/opentripplanner/routing/algorithm/transferoptimization/model/TripStopTime.java index 27299e407f4..16fda0922fe 100644 --- a/application/src/main/java/org/opentripplanner/routing/algorithm/transferoptimization/model/TripStopTime.java +++ b/application/src/main/java/org/opentripplanner/routing/algorithm/transferoptimization/model/TripStopTime.java @@ -79,8 +79,7 @@ public boolean equals(Object o) { @Override public String toString() { - return ValueObjectToStringBuilder - .of() + return ValueObjectToStringBuilder.of() .addText("[") .addNum(stop()) .addText(" ") diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/transferoptimization/model/TripToTripTransfer.java b/application/src/main/java/org/opentripplanner/routing/algorithm/transferoptimization/model/TripToTripTransfer.java index 2aa13d0cd16..3b4fc928164 100644 --- a/application/src/main/java/org/opentripplanner/routing/algorithm/transferoptimization/model/TripToTripTransfer.java +++ b/application/src/main/java/org/opentripplanner/routing/algorithm/transferoptimization/model/TripToTripTransfer.java @@ -64,8 +64,7 @@ public ConstrainedTransfer constrainedTransfer() { @Override public String toString() { - return ToStringBuilder - .of(TripToTripTransfer.class) + return ToStringBuilder.of(TripToTripTransfer.class) .addObj("from", from) .addObj("to", to) .addObj("transfer", pathTransfer) diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/transferoptimization/model/costfilter/MinCostPathTailFilter.java b/application/src/main/java/org/opentripplanner/routing/algorithm/transferoptimization/model/costfilter/MinCostPathTailFilter.java index 6b8dbef7f4e..d9a3f141a3c 100644 --- a/application/src/main/java/org/opentripplanner/routing/algorithm/transferoptimization/model/costfilter/MinCostPathTailFilter.java +++ b/application/src/main/java/org/opentripplanner/routing/algorithm/transferoptimization/model/costfilter/MinCostPathTailFilter.java @@ -68,8 +68,7 @@ private Set> filter( @Override public String toString() { - return ToStringBuilder - .of(MinCostPathTailFilter.class) + return ToStringBuilder.of(MinCostPathTailFilter.class) .addCol("costFunctions", costFunctions) .toString(); } diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/transferoptimization/model/passthrough/PassThroughPathTailFilter.java b/application/src/main/java/org/opentripplanner/routing/algorithm/transferoptimization/model/passthrough/PassThroughPathTailFilter.java index a56c369ffed..226531f3494 100644 --- a/application/src/main/java/org/opentripplanner/routing/algorithm/transferoptimization/model/passthrough/PassThroughPathTailFilter.java +++ b/application/src/main/java/org/opentripplanner/routing/algorithm/transferoptimization/model/passthrough/PassThroughPathTailFilter.java @@ -94,8 +94,7 @@ public Set> filterFinalResult(Set> ele @Override public String toString() { - return ToStringBuilder - .of(PassThroughPathTailFilter.class) + return ToStringBuilder.of(PassThroughPathTailFilter.class) .addObj("c2Calculator", c2Calculator) .addObj("filterChain", filterChain) .toString(); diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/transferoptimization/services/OptimizePathDomainService.java b/application/src/main/java/org/opentripplanner/routing/algorithm/transferoptimization/services/OptimizePathDomainService.java index 56a5dc5e100..eddbcc77e05 100644 --- a/application/src/main/java/org/opentripplanner/routing/algorithm/transferoptimization/services/OptimizePathDomainService.java +++ b/application/src/main/java/org/opentripplanner/routing/algorithm/transferoptimization/services/OptimizePathDomainService.java @@ -145,8 +145,7 @@ private Set> findBestTransferOption( stopBoardAlightTransferCosts, extraStopBoardAlightCostsFactor, stopNameTranslator - ) - .addTransitTail(last(originalTransitLegs)) + ).addTransitTail(last(originalTransitLegs)) ); // Cache accessArrivalTime, any event before the access-arrival-time is safe to ignore @@ -193,9 +192,9 @@ private Set> findBestTransferOption( } // Filter tails one final time - tails = - new TransitPathLegSelector<>(filter, tails) - .next(originalPath.accessLeg().nextTransitLeg().getFromStopPosition()); + tails = new TransitPathLegSelector<>(filter, tails).next( + originalPath.accessLeg().nextTransitLeg().getFromStopPosition() + ); // Insert the access leg and the following transfer insertAccess(originalPath, tails); diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/transferoptimization/services/TransitPathLegSelector.java b/application/src/main/java/org/opentripplanner/routing/algorithm/transferoptimization/services/TransitPathLegSelector.java index 646939a9ac5..9d2baa335f5 100644 --- a/application/src/main/java/org/opentripplanner/routing/algorithm/transferoptimization/services/TransitPathLegSelector.java +++ b/application/src/main/java/org/opentripplanner/routing/algorithm/transferoptimization/services/TransitPathLegSelector.java @@ -79,8 +79,7 @@ Set> next(final int fromStopPosition) { @Override public String toString() { - return ToStringBuilder - .of(TransitPathLegSelector.class) + return ToStringBuilder.of(TransitPathLegSelector.class) .addObj("filter", filter) .addCol("remindingLegs", remindingLegs) .addCol("selectedLegs", selectedLegs) diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/via/ViaRoutingWorker.java b/application/src/main/java/org/opentripplanner/routing/algorithm/via/ViaRoutingWorker.java index a4ff6753d5a..c6abe24e871 100644 --- a/application/src/main/java/org/opentripplanner/routing/algorithm/via/ViaRoutingWorker.java +++ b/application/src/main/java/org/opentripplanner/routing/algorithm/via/ViaRoutingWorker.java @@ -139,16 +139,14 @@ private Predicate withinSlackTest(Itinerary i, ViaLocationDeprecated } private Optional firstArrival(RoutingResponse response) { - return Optional - .ofNullable(response.getTripPlan()) + return Optional.ofNullable(response.getTripPlan()) .map(t -> t.itineraries) .flatMap(i -> i.stream().min(Comparator.comparing(Itinerary::endTime))) .map(Itinerary::endTime); } private Optional lastArrival(RoutingResponse response) { - return Optional - .ofNullable(response.getTripPlan()) + return Optional.ofNullable(response.getTripPlan()) .map(t -> t.itineraries) .flatMap(i -> i.stream().max(Comparator.comparing(Itinerary::endTime))) .map(Itinerary::endTime); diff --git a/application/src/main/java/org/opentripplanner/routing/alternativelegs/AlternativeLegs.java b/application/src/main/java/org/opentripplanner/routing/alternativelegs/AlternativeLegs.java index 8d3d8c55b4a..f94619910c7 100644 --- a/application/src/main/java/org/opentripplanner/routing/alternativelegs/AlternativeLegs.java +++ b/application/src/main/java/org/opentripplanner/routing/alternativelegs/AlternativeLegs.java @@ -137,8 +137,8 @@ private static Stream generateLegs( // TODO: What should we have here ZoneId timeZone = transitService.getTimeZone(); - Comparator comparator = Comparator.comparing((TripTimeOnDate tts) -> - tts.getServiceDayMidnight() + tts.getRealtimeDeparture() + Comparator comparator = Comparator.comparing( + (TripTimeOnDate tts) -> tts.getServiceDayMidnight() + tts.getRealtimeDeparture() ); if (direction == NavigationDirection.PREVIOUS) { @@ -258,20 +258,17 @@ private static Stream withBoardingAlightingPositions( List stops = tripPattern.getStops(); // Find out all alighting positions - var alightingPositions = IntStream - .iterate(stops.size() - 1, i -> i - 1) + var alightingPositions = IntStream.iterate(stops.size() - 1, i -> i - 1) .limit(stops.size()) .filter(i -> destinations.contains(stops.get(i)) && tripPattern.canAlight(i)) .toArray(); // Find out all boarding positions - return IntStream - .range(0, stops.size()) + return IntStream.range(0, stops.size()) .filter(i -> origins.contains(stops.get(i)) && tripPattern.canBoard(i)) .boxed() .flatMap(boardingPosition -> - Arrays - .stream(alightingPositions) + Arrays.stream(alightingPositions) // Filter out the impossible combinations .filter(alightingPosition -> boardingPosition < alightingPosition) .min() diff --git a/application/src/main/java/org/opentripplanner/routing/alternativelegs/AlternativeLegsFilter.java b/application/src/main/java/org/opentripplanner/routing/alternativelegs/AlternativeLegsFilter.java index 9f883603e77..b8d8239c40f 100644 --- a/application/src/main/java/org/opentripplanner/routing/alternativelegs/AlternativeLegsFilter.java +++ b/application/src/main/java/org/opentripplanner/routing/alternativelegs/AlternativeLegsFilter.java @@ -7,17 +7,20 @@ public enum AlternativeLegsFilter { NO_FILTER((Leg leg) -> (TripPattern tripPattern) -> true), - SAME_AGENCY((Leg leg) -> - (TripPattern tripPattern) -> leg.getAgency().equals(tripPattern.getRoute().getAgency()) + SAME_AGENCY( + (Leg leg) -> + (TripPattern tripPattern) -> leg.getAgency().equals(tripPattern.getRoute().getAgency()) ), - SAME_ROUTE((Leg leg) -> (TripPattern tripPattern) -> leg.getRoute().equals(tripPattern.getRoute()) + SAME_ROUTE( + (Leg leg) -> (TripPattern tripPattern) -> leg.getRoute().equals(tripPattern.getRoute()) ), - SAME_MODE((Leg leg) -> - (TripPattern tripPattern) -> leg.getTrip().getMode().equals(tripPattern.getMode()) + SAME_MODE( + (Leg leg) -> (TripPattern tripPattern) -> leg.getTrip().getMode().equals(tripPattern.getMode()) ), - SAME_SUBMODE((Leg leg) -> - (TripPattern tripPattern) -> - leg.getTrip().getNetexSubMode().equals(tripPattern.getNetexSubmode()) + SAME_SUBMODE( + (Leg leg) -> + (TripPattern tripPattern) -> + leg.getTrip().getNetexSubMode().equals(tripPattern.getNetexSubmode()) ); public final Function> predicateGenerator; diff --git a/application/src/main/java/org/opentripplanner/routing/api/request/DebugRaptor.java b/application/src/main/java/org/opentripplanner/routing/api/request/DebugRaptor.java index a0d7bd6de2e..f8274f1a1fb 100644 --- a/application/src/main/java/org/opentripplanner/routing/api/request/DebugRaptor.java +++ b/application/src/main/java/org/opentripplanner/routing/api/request/DebugRaptor.java @@ -108,8 +108,7 @@ public DebugRaptor withEventTypes(Collection eventTypes) { @Override public String toString() { - return ToStringBuilder - .of(DebugRaptor.class) + return ToStringBuilder.of(DebugRaptor.class) .addObj("stops", toString(stops, FIRST_STOP_INDEX)) .addObj("path", toString(path, debugPathFromStopIndex)) .addCol("eventType", eventTypes) diff --git a/application/src/main/java/org/opentripplanner/routing/api/request/RequestModes.java b/application/src/main/java/org/opentripplanner/routing/api/request/RequestModes.java index f10686216a8..5b978b73f1e 100644 --- a/application/src/main/java/org/opentripplanner/routing/api/request/RequestModes.java +++ b/application/src/main/java/org/opentripplanner/routing/api/request/RequestModes.java @@ -34,8 +34,9 @@ private RequestModes( this.accessMode = (accessMode != null && accessMode.accessAllowed()) ? accessMode : NOT_SET; this.egressMode = (egressMode != null && egressMode.egressAllowed()) ? egressMode : NOT_SET; this.directMode = directMode != null ? directMode : NOT_SET; - this.transferMode = - (transferMode != null && transferMode.transferAllowed()) ? transferMode : NOT_SET; + this.transferMode = (transferMode != null && transferMode.transferAllowed()) + ? transferMode + : NOT_SET; } public RequestModes(RequestModesBuilder builder) { @@ -96,8 +97,7 @@ public int hashCode() { @Override public String toString() { - return ToStringBuilder - .of(RequestModes.class) + return ToStringBuilder.of(RequestModes.class) .addEnum("accessMode", accessMode) .addEnum("egressMode", egressMode) .addEnum("directMode", directMode) diff --git a/application/src/main/java/org/opentripplanner/routing/api/request/RouteRequest.java b/application/src/main/java/org/opentripplanner/routing/api/request/RouteRequest.java index cf38fb63260..6ba14cb1bdc 100644 --- a/application/src/main/java/org/opentripplanner/routing/api/request/RouteRequest.java +++ b/application/src/main/java/org/opentripplanner/routing/api/request/RouteRequest.java @@ -200,8 +200,9 @@ public void applyPageCursor() { if (pageCursor.latestArrivalTime() == null) { arriveBy = false; } - this.dateTime = - arriveBy ? pageCursor.latestArrivalTime() : pageCursor.earliestDepartureTime(); + this.dateTime = arriveBy + ? pageCursor.latestArrivalTime() + : pageCursor.earliestDepartureTime(); journey.setModes(journey.modes().copyOf().withDirectMode(StreetMode.NOT_SET).build()); LOG.debug("Request dateTime={} set from pageCursor.", dateTime); } @@ -364,12 +365,11 @@ public Duration maxSearchWindow() { * default route request is configured before the {@link TransitRoutingConfig}. */ public void initMaxSearchWindow(Duration maxSearchWindow) { - this.maxSearchWindow = - ObjectUtils.requireNotInitialized( - "maxSearchWindow", - this.maxSearchWindow, - Objects.requireNonNull(maxSearchWindow) - ); + this.maxSearchWindow = ObjectUtils.requireNotInitialized( + "maxSearchWindow", + this.maxSearchWindow, + Objects.requireNonNull(maxSearchWindow) + ); } public Locale locale() { @@ -461,8 +461,7 @@ public void setNumItineraries(int numItineraries) { } public String toString() { - return ToStringBuilder - .of(RouteRequest.class) + return ToStringBuilder.of(RouteRequest.class) .addObj("from", from) .addObj("to", to) .addDateTime("dateTime", dateTime) diff --git a/application/src/main/java/org/opentripplanner/routing/api/request/StreetMode.java b/application/src/main/java/org/opentripplanner/routing/api/request/StreetMode.java index cbc2764f030..9cf2796e670 100644 --- a/application/src/main/java/org/opentripplanner/routing/api/request/StreetMode.java +++ b/application/src/main/java/org/opentripplanner/routing/api/request/StreetMode.java @@ -131,7 +131,7 @@ public String typeDescription() { private static String GBFS_PREREQ = """ - + _Prerequisite:_ Vehicle or station locations need to be added to OTP from dynamic data feeds. See [Configuring GBFS](UpdaterConfig.md#gbfs-vehicle-rental-systems) on how to add one. """; @@ -142,47 +142,47 @@ public String enumValueDescription() { case NOT_SET -> ""; case WALK -> "Walking some or all of the way of the route."; case BIKE -> """ - Cycling for the entirety of the route or taking a bicycle onto the public transport and cycling from the arrival station to the destination. + Cycling for the entirety of the route or taking a bicycle onto the public transport and cycling from the arrival station to the destination. - Taking a bicycle onto transit is only possible if information about the permission to do so is supplied in the source data. In GTFS this field - is called `bikesAllowed`. - """; + Taking a bicycle onto transit is only possible if information about the permission to do so is supplied in the source data. In GTFS this field + is called `bikesAllowed`. + """; case BIKE_TO_PARK -> """ - Leaving the bicycle at the departure station and walking from the arrival station to the destination. - This mode needs to be combined with at least one transit mode otherwise it behaves like an ordinary bicycle journey. - - _Prerequisite:_ Bicycle parking stations present in the OSM file and visible to OTP by enabling the property `staticBikeParkAndRide` during graph build. - """; + Leaving the bicycle at the departure station and walking from the arrival station to the destination. + This mode needs to be combined with at least one transit mode otherwise it behaves like an ordinary bicycle journey. + + _Prerequisite:_ Bicycle parking stations present in the OSM file and visible to OTP by enabling the property `staticBikeParkAndRide` during graph build. + """; case BIKE_RENTAL -> """ - Taking a rented, shared-mobility bike for part or the entirety of the route. - """ + + Taking a rented, shared-mobility bike for part or the entirety of the route. + """ + GBFS_PREREQ; case SCOOTER_RENTAL -> """ - Walking to a scooter rental point, riding a scooter to a scooter rental drop-off point, and walking the rest of the way. - This can include scooter rental at fixed locations or free-floating services. - """ + + Walking to a scooter rental point, riding a scooter to a scooter rental drop-off point, and walking the rest of the way. + This can include scooter rental at fixed locations or free-floating services. + """ + GBFS_PREREQ; case CAR_RENTAL -> """ - Walk to a car rental point, drive to a car rental drop-off point and walk the rest of the way. - This can include car rental at fixed locations or free-floating services. - """ + + Walk to a car rental point, drive to a car rental drop-off point and walk the rest of the way. + This can include car rental at fixed locations or free-floating services. + """ + GBFS_PREREQ; case CAR -> """ - Driving your own car the entirety of the route. - This can be combined with transit, where will return routes with a [Kiss & Ride](https://en.wikipedia.org/wiki/Park_and_ride#Kiss_and_ride_/_kiss_and_fly) component. - This means that the car is not parked in a permanent parking area but rather the passenger is dropped off (for example, at an airport) and the driver continues driving the car away from the drop off location. - """; + Driving your own car the entirety of the route. + This can be combined with transit, where will return routes with a [Kiss & Ride](https://en.wikipedia.org/wiki/Park_and_ride#Kiss_and_ride_/_kiss_and_fly) component. + This means that the car is not parked in a permanent parking area but rather the passenger is dropped off (for example, at an airport) and the driver continues driving the car away from the drop off location. + """; case CAR_TO_PARK -> """ - Driving a car to the park-and-ride facilities near a station and taking publictransport. - This mode needs to be combined with at least one transit mode otherwise, it behaves like an ordinary car journey. - _Prerequisite:_ Park-and-ride areas near the stations need to be present in the OSM input file. - """; + Driving a car to the park-and-ride facilities near a station and taking publictransport. + This mode needs to be combined with at least one transit mode otherwise, it behaves like an ordinary car journey. + _Prerequisite:_ Park-and-ride areas near the stations need to be present in the OSM input file. + """; case CAR_PICKUP -> "Walking to a pickup point along the road, driving to a drop-off point along the road, and walking the rest of the way.
This can include various taxi-services or kiss & ride."; case CAR_HAILING -> """ - Using a car hailing app like Uber or Lyft to get to a train station or all the way to the destination. - - See [the sandbox documentation](sandbox/RideHailing.md) on how to configure it. - """; + Using a car hailing app like Uber or Lyft to get to a train station or all the way to the destination. + + See [the sandbox documentation](sandbox/RideHailing.md) on how to configure it. + """; case FLEXIBLE -> "Encompasses all types of on-demand and flexible transportation for example GTFS Flex or NeTEx Flexible Stop Places."; }; } diff --git a/application/src/main/java/org/opentripplanner/routing/api/request/framework/CostLinearFunction.java b/application/src/main/java/org/opentripplanner/routing/api/request/framework/CostLinearFunction.java index 8ff119b91ad..e6e8e8f1ba4 100644 --- a/application/src/main/java/org/opentripplanner/routing/api/request/framework/CostLinearFunction.java +++ b/application/src/main/java/org/opentripplanner/routing/api/request/framework/CostLinearFunction.java @@ -34,9 +34,9 @@ public static CostLinearFunction of(Duration constant, double coefficient) { } public static CostLinearFunction of(String text) { - return LinearFunctionSerialization - .parse(text, (Duration a, Double b) -> of(Cost.fromDuration(a), b)) - .orElseThrow(); + return LinearFunctionSerialization.parse(text, (Duration a, Double b) -> + of(Cost.fromDuration(a), b) + ).orElseThrow(); } public Cost calculate(Cost cost) { diff --git a/application/src/main/java/org/opentripplanner/routing/api/request/framework/DurationForEnum.java b/application/src/main/java/org/opentripplanner/routing/api/request/framework/DurationForEnum.java index 1a3de4f4175..74709e97b5e 100644 --- a/application/src/main/java/org/opentripplanner/routing/api/request/framework/DurationForEnum.java +++ b/application/src/main/java/org/opentripplanner/routing/api/request/framework/DurationForEnum.java @@ -68,8 +68,7 @@ public boolean isSet(E key) { @Override public String toString() { - var builder = ValueObjectToStringBuilder - .of() + var builder = ValueObjectToStringBuilder.of() .addText("DurationFor" + type.getSimpleName() + "{") .addText("default:") .addDuration(defaultValue); diff --git a/application/src/main/java/org/opentripplanner/routing/api/request/preference/AccessEgressPreferences.java b/application/src/main/java/org/opentripplanner/routing/api/request/preference/AccessEgressPreferences.java index 9a9bb7bdc3a..6a4c7e931e6 100644 --- a/application/src/main/java/org/opentripplanner/routing/api/request/preference/AccessEgressPreferences.java +++ b/application/src/main/java/org/opentripplanner/routing/api/request/preference/AccessEgressPreferences.java @@ -21,7 +21,8 @@ */ public final class AccessEgressPreferences implements Serializable { - private static final TimeAndCostPenaltyForEnum DEFAULT_TIME_AND_COST = createDefaultCarPenalty(); + private static final TimeAndCostPenaltyForEnum DEFAULT_TIME_AND_COST = + createDefaultCarPenalty(); public static final AccessEgressPreferences DEFAULT = new AccessEgressPreferences(); @@ -80,8 +81,7 @@ public int hashCode() { @Override public String toString() { - return ToStringBuilder - .of(AccessEgressPreferences.class) + return ToStringBuilder.of(AccessEgressPreferences.class) .addObj("penalty", penalty, DEFAULT.penalty) .addObj("maxDuration", maxDuration, DEFAULT.maxDuration) .addObj("maxStopCount", maxStopCountLimit, DEFAULT.maxStopCountLimit) diff --git a/application/src/main/java/org/opentripplanner/routing/api/request/preference/AccessibilityPreferences.java b/application/src/main/java/org/opentripplanner/routing/api/request/preference/AccessibilityPreferences.java index d4d232ab3f6..4dc6f4911c1 100644 --- a/application/src/main/java/org/opentripplanner/routing/api/request/preference/AccessibilityPreferences.java +++ b/application/src/main/java/org/opentripplanner/routing/api/request/preference/AccessibilityPreferences.java @@ -24,11 +24,8 @@ public final class AccessibilityPreferences { NOT_SET, NOT_SET ); - private static final AccessibilityPreferences ONLY_CONSIDER_ACCESSIBLE = new AccessibilityPreferences( - true, - NOT_SET, - NOT_SET - ); + private static final AccessibilityPreferences ONLY_CONSIDER_ACCESSIBLE = + new AccessibilityPreferences(true, NOT_SET, NOT_SET); private final boolean onlyConsiderAccessible; private final Cost unknownCost; @@ -122,8 +119,7 @@ public String toString(AccessibilityPreferences defaultCosts) { return "OnlyConsiderAccessible"; } - return ToStringBuilder - .of(AccessibilityPreferences.class) + return ToStringBuilder.of(AccessibilityPreferences.class) .addObj("unknownCost", unknownCost, defaultCosts.unknownCost) .addObj("inaccessibleCost", inaccessibleCost, defaultCosts.inaccessibleCost) .toString(); diff --git a/application/src/main/java/org/opentripplanner/routing/api/request/preference/BikePreferences.java b/application/src/main/java/org/opentripplanner/routing/api/request/preference/BikePreferences.java index 038d6c140da..15496eda373 100644 --- a/application/src/main/java/org/opentripplanner/routing/api/request/preference/BikePreferences.java +++ b/application/src/main/java/org/opentripplanner/routing/api/request/preference/BikePreferences.java @@ -142,8 +142,7 @@ public int hashCode() { @Override public String toString() { - return ToStringBuilder - .of(BikePreferences.class) + return ToStringBuilder.of(BikePreferences.class) .addNum("speed", speed, DEFAULT.speed) .addNum("reluctance", reluctance, DEFAULT.reluctance) .addObj("boardCost", boardCost, DEFAULT.boardCost) diff --git a/application/src/main/java/org/opentripplanner/routing/api/request/preference/CarPreferences.java b/application/src/main/java/org/opentripplanner/routing/api/request/preference/CarPreferences.java index 2e2c3bd9a23..2365e1294d5 100644 --- a/application/src/main/java/org/opentripplanner/routing/api/request/preference/CarPreferences.java +++ b/application/src/main/java/org/opentripplanner/routing/api/request/preference/CarPreferences.java @@ -144,8 +144,7 @@ public int hashCode() { @Override public String toString() { - return ToStringBuilder - .of(CarPreferences.class) + return ToStringBuilder.of(CarPreferences.class) .addNum("reluctance", reluctance, DEFAULT.reluctance) .addObj("boardCost", boardCost, DEFAULT.boardCost) .addObj("parking", parking, DEFAULT.parking) diff --git a/application/src/main/java/org/opentripplanner/routing/api/request/preference/ElevatorPreferences.java b/application/src/main/java/org/opentripplanner/routing/api/request/preference/ElevatorPreferences.java index 7e5e55d6263..4fa1110d78c 100644 --- a/application/src/main/java/org/opentripplanner/routing/api/request/preference/ElevatorPreferences.java +++ b/application/src/main/java/org/opentripplanner/routing/api/request/preference/ElevatorPreferences.java @@ -90,8 +90,7 @@ public int hashCode() { @Override public String toString() { - return ToStringBuilder - .of(ElevatorPreferences.class) + return ToStringBuilder.of(ElevatorPreferences.class) .addObj("boardCost", boardCost, DEFAULT.boardCost) .addDurationSec("boardTime", boardTime, DEFAULT.boardTime) .addObj("hopCost", hopCost, DEFAULT.hopCost) diff --git a/application/src/main/java/org/opentripplanner/routing/api/request/preference/EscalatorPreferences.java b/application/src/main/java/org/opentripplanner/routing/api/request/preference/EscalatorPreferences.java index 3c150b43417..9b945423555 100644 --- a/application/src/main/java/org/opentripplanner/routing/api/request/preference/EscalatorPreferences.java +++ b/application/src/main/java/org/opentripplanner/routing/api/request/preference/EscalatorPreferences.java @@ -60,8 +60,7 @@ public int hashCode() { @Override public String toString() { - return ToStringBuilder - .of(EscalatorPreferences.class) + return ToStringBuilder.of(EscalatorPreferences.class) .addNum("speed", speed, DEFAULT.speed) .addNum("reluctance", reluctance, DEFAULT.reluctance) .toString(); diff --git a/application/src/main/java/org/opentripplanner/routing/api/request/preference/ItineraryFilterPreferences.java b/application/src/main/java/org/opentripplanner/routing/api/request/preference/ItineraryFilterPreferences.java index f18cf5ce9c1..4c982c110da 100644 --- a/application/src/main/java/org/opentripplanner/routing/api/request/preference/ItineraryFilterPreferences.java +++ b/application/src/main/java/org/opentripplanner/routing/api/request/preference/ItineraryFilterPreferences.java @@ -45,13 +45,14 @@ private ItineraryFilterPreferences() { this.nonTransitGeneralizedCostLimit = CostLinearFunction.of(Duration.ofHours(1), 2.0); this.parkAndRideDurationRatio = 0.0; this.removeItinerariesWithSameRoutesAndStops = false; - this.transitGeneralizedCostLimit = - new TransitGeneralizedCostFilterParams( - CostLinearFunction.of(Duration.ofMinutes(15), 1.5), - 0.4 - ); - this.removeTransitWithHigherCostThanBestOnStreetOnly = - CostLinearFunction.of(Duration.ofMinutes(1), 1.3); + this.transitGeneralizedCostLimit = new TransitGeneralizedCostFilterParams( + CostLinearFunction.of(Duration.ofMinutes(15), 1.5), + 0.4 + ); + this.removeTransitWithHigherCostThanBestOnStreetOnly = CostLinearFunction.of( + Duration.ofMinutes(1), + 1.3 + ); this.filterDirectFlexBySearchWindow = true; } @@ -61,18 +62,21 @@ private ItineraryFilterPreferences(Builder builder) { this.debug = builder.debug; this.filterItinerariesWithSameFirstOrLastTrip = builder.filterItinerariesWithSameFirstOrLastTrip; - this.groupedOtherThanSameLegsMaxCostMultiplier = - Units.reluctance(builder.groupedOtherThanSameLegsMaxCostMultiplier); + this.groupedOtherThanSameLegsMaxCostMultiplier = Units.reluctance( + builder.groupedOtherThanSameLegsMaxCostMultiplier + ); this.groupSimilarityKeepOne = Units.reluctance(builder.groupSimilarityKeepOne); this.groupSimilarityKeepThree = Units.reluctance(builder.groupSimilarityKeepThree); this.minBikeParkingDistance = builder.minBikeParkingDistance; - this.nonTransitGeneralizedCostLimit = - Objects.requireNonNull(builder.nonTransitGeneralizedCostLimit); + this.nonTransitGeneralizedCostLimit = Objects.requireNonNull( + builder.nonTransitGeneralizedCostLimit + ); this.parkAndRideDurationRatio = Units.ratio(builder.parkAndRideDurationRatio); this.removeItinerariesWithSameRoutesAndStops = builder.removeItinerariesWithSameRoutesAndStops; this.transitGeneralizedCostLimit = Objects.requireNonNull(builder.transitGeneralizedCostLimit); - this.removeTransitWithHigherCostThanBestOnStreetOnly = - Objects.requireNonNull(builder.removeTransitWithHigherCostThanBestOnStreetOnly); + this.removeTransitWithHigherCostThanBestOnStreetOnly = Objects.requireNonNull( + builder.removeTransitWithHigherCostThanBestOnStreetOnly + ); this.filterDirectFlexBySearchWindow = builder.filterDirectFlexBySearchWindow; } @@ -142,8 +146,7 @@ public boolean filterDirectFlexBySearchWindow() { @Override public String toString() { - return ToStringBuilder - .of(ItineraryFilterPreferences.class) + return ToStringBuilder.of(ItineraryFilterPreferences.class) .addBoolIfTrue("accessibilityScore", accessibilityScore) .addNum("bikeRentalDistanceRatio", bikeRentalDistanceRatio, DEFAULT.bikeRentalDistanceRatio) .addEnum("debug", debug, ItineraryFilterDebugProfile.OFF) diff --git a/application/src/main/java/org/opentripplanner/routing/api/request/preference/MaxStopCountLimit.java b/application/src/main/java/org/opentripplanner/routing/api/request/preference/MaxStopCountLimit.java index 1bf6545855f..1784ce32105 100644 --- a/application/src/main/java/org/opentripplanner/routing/api/request/preference/MaxStopCountLimit.java +++ b/application/src/main/java/org/opentripplanner/routing/api/request/preference/MaxStopCountLimit.java @@ -53,8 +53,7 @@ public int defaultLimit() { @Override public String toString() { - return ToStringBuilder - .of(MaxStopCountLimit.class) + return ToStringBuilder.of(MaxStopCountLimit.class) .addNum("defaultLimit", defaultLimit, DEFAULT_LIMIT) .addObj("limitsForModes", limitsForModes, DEFAULT_FOR_MODES) .toString(); diff --git a/application/src/main/java/org/opentripplanner/routing/api/request/preference/RaptorPreferences.java b/application/src/main/java/org/opentripplanner/routing/api/request/preference/RaptorPreferences.java index e9318bc8dc3..afc4e4ef907 100644 --- a/application/src/main/java/org/opentripplanner/routing/api/request/preference/RaptorPreferences.java +++ b/application/src/main/java/org/opentripplanner/routing/api/request/preference/RaptorPreferences.java @@ -49,12 +49,11 @@ private RaptorPreferences(RaptorPreferences.Builder builder) { this.profile = Objects.requireNonNull(builder.profile); this.searchDirection = Objects.requireNonNull(builder.searchDirection); this.timeLimit = builder.timeLimit; - this.relaxGeneralizedCostAtDestination = - Units.normalizedOptionalFactor( - builder.relaxGeneralizedCostAtDestination, - MIN_RELAX_COST_AT_DESTINATION, - MAX_RELAX_COST_AT_DESTINATION - ); + this.relaxGeneralizedCostAtDestination = Units.normalizedOptionalFactor( + builder.relaxGeneralizedCostAtDestination, + MIN_RELAX_COST_AT_DESTINATION, + MAX_RELAX_COST_AT_DESTINATION + ); } public static Builder of() { @@ -126,8 +125,7 @@ public int hashCode() { @Override public String toString() { - return ToStringBuilder - .of(RaptorPreferences.class) + return ToStringBuilder.of(RaptorPreferences.class) .addCol("optimizations", optimizations, DEFAULT.optimizations) .addEnum("profile", profile, DEFAULT.profile) .addEnum("searchDirection", searchDirection, DEFAULT.searchDirection) @@ -161,10 +159,9 @@ public Builder(RaptorPreferences original) { } public Builder withOptimizations(Collection optimizations) { - this.optimizations = - optimizations.isEmpty() - ? EnumSet.noneOf(Optimization.class) - : EnumSet.copyOf(optimizations); + this.optimizations = optimizations.isEmpty() + ? EnumSet.noneOf(Optimization.class) + : EnumSet.copyOf(optimizations); return this; } diff --git a/application/src/main/java/org/opentripplanner/routing/api/request/preference/RoutingPreferences.java b/application/src/main/java/org/opentripplanner/routing/api/request/preference/RoutingPreferences.java index 5eccc970101..320fb1e7fd1 100644 --- a/application/src/main/java/org/opentripplanner/routing/api/request/preference/RoutingPreferences.java +++ b/application/src/main/java/org/opentripplanner/routing/api/request/preference/RoutingPreferences.java @@ -253,8 +253,10 @@ public Builder withWheelchair(WheelchairPreferences wheelchair) { } public Builder withWheelchair(Consumer body) { - this.wheelchair = - ifNotNull(this.wheelchair, original.wheelchair).copyOf().apply(body).build(); + this.wheelchair = ifNotNull(this.wheelchair, original.wheelchair) + .copyOf() + .apply(body) + .build(); return this; } @@ -299,8 +301,10 @@ public ItineraryFilterPreferences itineraryFilter() { } public Builder withItineraryFilter(Consumer body) { - this.itineraryFilter = - ifNotNull(this.itineraryFilter, original.itineraryFilter).copyOf().apply(body).build(); + this.itineraryFilter = ifNotNull(this.itineraryFilter, original.itineraryFilter) + .copyOf() + .apply(body) + .build(); return this; } diff --git a/application/src/main/java/org/opentripplanner/routing/api/request/preference/ScooterPreferences.java b/application/src/main/java/org/opentripplanner/routing/api/request/preference/ScooterPreferences.java index 6a20cbcd293..328ce6384ce 100644 --- a/application/src/main/java/org/opentripplanner/routing/api/request/preference/ScooterPreferences.java +++ b/application/src/main/java/org/opentripplanner/routing/api/request/preference/ScooterPreferences.java @@ -103,8 +103,7 @@ public int hashCode() { @Override public String toString() { - return ToStringBuilder - .of(ScooterPreferences.class) + return ToStringBuilder.of(ScooterPreferences.class) .addNum("speed", speed, DEFAULT.speed) .addNum("reluctance", reluctance, DEFAULT.reluctance) .addObj("rental", rental, DEFAULT.rental) diff --git a/application/src/main/java/org/opentripplanner/routing/api/request/preference/StreetPreferences.java b/application/src/main/java/org/opentripplanner/routing/api/request/preference/StreetPreferences.java index bb526ceaa31..fa238786369 100644 --- a/application/src/main/java/org/opentripplanner/routing/api/request/preference/StreetPreferences.java +++ b/application/src/main/java/org/opentripplanner/routing/api/request/preference/StreetPreferences.java @@ -132,8 +132,7 @@ public int hashCode() { @Override public String toString() { - return ToStringBuilder - .of(StreetPreferences.class) + return ToStringBuilder.of(StreetPreferences.class) .addNum("turnReluctance", turnReluctance, DEFAULT.turnReluctance) .addEnum("drivingDirection", drivingDirection, DEFAULT.drivingDirection) .addDuration("routingTimeout", routingTimeout, DEFAULT.routingTimeout()) diff --git a/application/src/main/java/org/opentripplanner/routing/api/request/preference/SystemPreferences.java b/application/src/main/java/org/opentripplanner/routing/api/request/preference/SystemPreferences.java index f35a65c2f03..a332cc7a4d9 100644 --- a/application/src/main/java/org/opentripplanner/routing/api/request/preference/SystemPreferences.java +++ b/application/src/main/java/org/opentripplanner/routing/api/request/preference/SystemPreferences.java @@ -95,8 +95,7 @@ public int hashCode() { @Override public String toString() { - return ToStringBuilder - .of(SystemPreferences.class) + return ToStringBuilder.of(SystemPreferences.class) .addCol("tags", tags, DEFAULT.tags) .addObj("dataOverlay", dataOverlay, DEFAULT.dataOverlay) .addBoolIfTrue("geoidElevation", geoidElevation) diff --git a/application/src/main/java/org/opentripplanner/routing/api/request/preference/TransferOptimizationPreferences.java b/application/src/main/java/org/opentripplanner/routing/api/request/preference/TransferOptimizationPreferences.java index 7ba6e609ce9..f9ac7aa2859 100644 --- a/application/src/main/java/org/opentripplanner/routing/api/request/preference/TransferOptimizationPreferences.java +++ b/application/src/main/java/org/opentripplanner/routing/api/request/preference/TransferOptimizationPreferences.java @@ -22,7 +22,8 @@ public final class TransferOptimizationPreferences private final double backTravelWaitTimeFactor; private final double extraStopBoardAlightCostsFactor; - public static final TransferOptimizationPreferences DEFAULT = new TransferOptimizationPreferences(); + public static final TransferOptimizationPreferences DEFAULT = + new TransferOptimizationPreferences(); private TransferOptimizationPreferences() { this.optimizeTransferWaitTime = true; @@ -35,8 +36,9 @@ private TransferOptimizationPreferences(Builder builder) { this.optimizeTransferWaitTime = builder.optimizeTransferWaitTime; this.minSafeWaitTimeFactor = Units.reluctance(builder.minSafeWaitTimeFactor); this.backTravelWaitTimeFactor = Units.reluctance(builder.backTravelWaitTimeFactor); - this.extraStopBoardAlightCostsFactor = - Units.reluctance(builder.extraStopBoardAlightCostsFactor); + this.extraStopBoardAlightCostsFactor = Units.reluctance( + builder.extraStopBoardAlightCostsFactor + ); } public static Builder of() { @@ -97,8 +99,7 @@ public int hashCode() { @Override public String toString() { - return ToStringBuilder - .of(TransferOptimizationPreferences.class) + return ToStringBuilder.of(TransferOptimizationPreferences.class) .addBoolIfTrue("skipOptimizeWaitTime", !optimizeTransferWaitTime) .addNum("minSafeWaitTimeFactor", minSafeWaitTimeFactor, DEFAULT.minSafeWaitTimeFactor) .addNum( diff --git a/application/src/main/java/org/opentripplanner/routing/api/request/preference/TransferPreferences.java b/application/src/main/java/org/opentripplanner/routing/api/request/preference/TransferPreferences.java index f996dd5e6f4..b8ca6efd000 100644 --- a/application/src/main/java/org/opentripplanner/routing/api/request/preference/TransferPreferences.java +++ b/application/src/main/java/org/opentripplanner/routing/api/request/preference/TransferPreferences.java @@ -47,8 +47,10 @@ private TransferPreferences(Builder builder) { this.slack = DurationUtils.requireNonNegative(builder.slack); this.waitReluctance = Units.reluctance(builder.waitReluctance); this.maxTransfers = Units.count(builder.maxTransfers, MAX_NUMBER_OF_TRANSFERS); - this.maxAdditionalTransfers = - Units.count(builder.maxAdditionalTransfers, MAX_NUMBER_OF_TRANSFERS); + this.maxAdditionalTransfers = Units.count( + builder.maxAdditionalTransfers, + MAX_NUMBER_OF_TRANSFERS + ); this.optimization = requireNonNull(builder.optimization); this.nonpreferredCost = builder.nonpreferredCost; } @@ -182,8 +184,7 @@ public int hashCode() { @Override public String toString() { - return ToStringBuilder - .of(TransferPreferences.class) + return ToStringBuilder.of(TransferPreferences.class) .addObj("cost", cost, DEFAULT.cost) .addDuration("slack", slack, DEFAULT.slack) .addNum("waitReluctance", waitReluctance, DEFAULT.waitReluctance) diff --git a/application/src/main/java/org/opentripplanner/routing/api/request/preference/TransitPreferences.java b/application/src/main/java/org/opentripplanner/routing/api/request/preference/TransitPreferences.java index a237dd53527..bd385ec741d 100644 --- a/application/src/main/java/org/opentripplanner/routing/api/request/preference/TransitPreferences.java +++ b/application/src/main/java/org/opentripplanner/routing/api/request/preference/TransitPreferences.java @@ -206,8 +206,7 @@ public int hashCode() { @Override public String toString() { - return ToStringBuilder - .of(TransitPreferences.class) + return ToStringBuilder.of(TransitPreferences.class) .addObj("boardSlack", boardSlack, DEFAULT.boardSlack) .addObj("alightSlack", alightSlack, DEFAULT.alightSlack) .addObj("reluctanceForMode", reluctanceForMode, DEFAULT.reluctanceForMode) diff --git a/application/src/main/java/org/opentripplanner/routing/api/request/preference/VehicleParkingPreferences.java b/application/src/main/java/org/opentripplanner/routing/api/request/preference/VehicleParkingPreferences.java index 732171c7b80..baf63f4e9ea 100644 --- a/application/src/main/java/org/opentripplanner/routing/api/request/preference/VehicleParkingPreferences.java +++ b/application/src/main/java/org/opentripplanner/routing/api/request/preference/VehicleParkingPreferences.java @@ -37,16 +37,14 @@ private VehicleParkingPreferences() { private VehicleParkingPreferences(Builder builder) { this.unpreferredVehicleParkingTagCost = builder.unpreferredVehicleParkingTagCost; - this.filter = - new VehicleParkingFilter( - builder.bannedVehicleParkingTags, - builder.requiredVehicleParkingTags - ); - this.preferred = - new VehicleParkingFilter( - builder.notPreferredVehicleParkingTags, - builder.preferredVehicleParkingTags - ); + this.filter = new VehicleParkingFilter( + builder.bannedVehicleParkingTags, + builder.requiredVehicleParkingTags + ); + this.preferred = new VehicleParkingFilter( + builder.notPreferredVehicleParkingTags, + builder.preferredVehicleParkingTags + ); this.time = builder.time; this.cost = builder.cost; } @@ -115,8 +113,7 @@ public int hashCode() { @Override public String toString() { - return ToStringBuilder - .of(VehicleParkingPreferences.class) + return ToStringBuilder.of(VehicleParkingPreferences.class) .addObj( "unpreferredVehicleParkingTagCost", unpreferredVehicleParkingTagCost, @@ -157,26 +154,30 @@ public Builder withUnpreferredVehicleParkingTagCost(int cost) { } public Builder withBannedVehicleParkingTags(Set bannedVehicleParkingTags) { - this.bannedVehicleParkingTags = - List.of(new VehicleParkingSelect.TagsSelect(bannedVehicleParkingTags)); + this.bannedVehicleParkingTags = List.of( + new VehicleParkingSelect.TagsSelect(bannedVehicleParkingTags) + ); return this; } public Builder withRequiredVehicleParkingTags(Set requiredVehicleParkingTags) { - this.requiredVehicleParkingTags = - List.of(new VehicleParkingSelect.TagsSelect(requiredVehicleParkingTags)); + this.requiredVehicleParkingTags = List.of( + new VehicleParkingSelect.TagsSelect(requiredVehicleParkingTags) + ); return this; } public Builder withPreferredVehicleParkingTags(Set preferredVehicleParkingTags) { - this.preferredVehicleParkingTags = - List.of(new VehicleParkingSelect.TagsSelect(preferredVehicleParkingTags)); + this.preferredVehicleParkingTags = List.of( + new VehicleParkingSelect.TagsSelect(preferredVehicleParkingTags) + ); return this; } public Builder withNotPreferredVehicleParkingTags(Set notPreferredVehicleParkingTags) { - this.notPreferredVehicleParkingTags = - List.of(new VehicleParkingSelect.TagsSelect(notPreferredVehicleParkingTags)); + this.notPreferredVehicleParkingTags = List.of( + new VehicleParkingSelect.TagsSelect(notPreferredVehicleParkingTags) + ); return this; } diff --git a/application/src/main/java/org/opentripplanner/routing/api/request/preference/VehicleRentalPreferences.java b/application/src/main/java/org/opentripplanner/routing/api/request/preference/VehicleRentalPreferences.java index 4c00014f30d..d6173f84ada 100644 --- a/application/src/main/java/org/opentripplanner/routing/api/request/preference/VehicleRentalPreferences.java +++ b/application/src/main/java/org/opentripplanner/routing/api/request/preference/VehicleRentalPreferences.java @@ -159,8 +159,7 @@ public int hashCode() { @Override public String toString() { - return ToStringBuilder - .of(VehicleRentalPreferences.class) + return ToStringBuilder.of(VehicleRentalPreferences.class) .addDuration("pickupTime", pickupTime, DEFAULT.pickupTime) .addObj("pickupCost", pickupCost, DEFAULT.pickupCost) .addDuration("dropOffTime", dropOffTime, DEFAULT.dropOffTime) @@ -250,8 +249,9 @@ public Builder withUseAvailabilityInformation(boolean useAvailabilityInformation public Builder withArrivingInRentalVehicleAtDestinationCost( int arrivingInRentalVehicleAtDestinationCost ) { - this.arrivingInRentalVehicleAtDestinationCost = - Cost.costOfSeconds(arrivingInRentalVehicleAtDestinationCost); + this.arrivingInRentalVehicleAtDestinationCost = Cost.costOfSeconds( + arrivingInRentalVehicleAtDestinationCost + ); return this; } diff --git a/application/src/main/java/org/opentripplanner/routing/api/request/preference/VehicleWalkingPreferences.java b/application/src/main/java/org/opentripplanner/routing/api/request/preference/VehicleWalkingPreferences.java index 50b3735a85d..3602c3bb0c6 100644 --- a/application/src/main/java/org/opentripplanner/routing/api/request/preference/VehicleWalkingPreferences.java +++ b/application/src/main/java/org/opentripplanner/routing/api/request/preference/VehicleWalkingPreferences.java @@ -108,8 +108,7 @@ public int hashCode() { @Override public String toString() { - return ToStringBuilder - .of(VehicleWalkingPreferences.class) + return ToStringBuilder.of(VehicleWalkingPreferences.class) .addNum("speed", speed, DEFAULT.speed) .addNum("reluctance", reluctance, DEFAULT.reluctance) .addObj("mountDismountTime", mountDismountTime, DEFAULT.mountDismountTime) diff --git a/application/src/main/java/org/opentripplanner/routing/api/request/preference/WalkPreferences.java b/application/src/main/java/org/opentripplanner/routing/api/request/preference/WalkPreferences.java index 5bc0a120d32..ed8ca2ce470 100644 --- a/application/src/main/java/org/opentripplanner/routing/api/request/preference/WalkPreferences.java +++ b/application/src/main/java/org/opentripplanner/routing/api/request/preference/WalkPreferences.java @@ -144,8 +144,7 @@ public int hashCode() { @Override public String toString() { - return ToStringBuilder - .of(WalkPreferences.class) + return ToStringBuilder.of(WalkPreferences.class) .addNum("speed", speed, DEFAULT.speed) .addNum("reluctance", reluctance, DEFAULT.reluctance) .addObj("boardCost", boardCost, DEFAULT.boardCost) diff --git a/application/src/main/java/org/opentripplanner/routing/api/request/preference/WheelchairPreferences.java b/application/src/main/java/org/opentripplanner/routing/api/request/preference/WheelchairPreferences.java index d8a53d8e098..370b73417e5 100644 --- a/application/src/main/java/org/opentripplanner/routing/api/request/preference/WheelchairPreferences.java +++ b/application/src/main/java/org/opentripplanner/routing/api/request/preference/WheelchairPreferences.java @@ -152,8 +152,7 @@ public int hashCode() { @Override public String toString() { - return ToStringBuilder - .of(WheelchairPreferences.class) + return ToStringBuilder.of(WheelchairPreferences.class) .addObjOp("trip", trip, DEFAULT.trip, i -> i.toString(DEFAULT_COSTS)) .addObjOp("stop", stop, DEFAULT.stop, i -> i.toString(DEFAULT_COSTS)) .addObjOp("elevator", elevator, DEFAULT.elevator, i -> i.toString(DEFAULT.elevator)) @@ -240,8 +239,9 @@ public Builder withElevator(AccessibilityPreferences elevator) { } public Builder withElevator(Consumer body) { - this.elevator = - this.elevator.copyOfWithDefaultCosts(DEFAULT_ELEVATOR_PREFERENCES).apply(body).build(); + this.elevator = this.elevator.copyOfWithDefaultCosts(DEFAULT_ELEVATOR_PREFERENCES) + .apply(body) + .build(); return this; } diff --git a/application/src/main/java/org/opentripplanner/routing/api/request/preference/filter/VehicleParkingFilter.java b/application/src/main/java/org/opentripplanner/routing/api/request/preference/filter/VehicleParkingFilter.java index c03d8d18bea..7a7f1c11291 100644 --- a/application/src/main/java/org/opentripplanner/routing/api/request/preference/filter/VehicleParkingFilter.java +++ b/application/src/main/java/org/opentripplanner/routing/api/request/preference/filter/VehicleParkingFilter.java @@ -66,8 +66,7 @@ public boolean matches(VehicleParking p) { @Override public String toString() { - return ToStringBuilder - .of(this.getClass()) + return ToStringBuilder.of(this.getClass()) .addCol("not", Arrays.asList(not)) .addCol("select", Arrays.asList(select)) .toString(); diff --git a/application/src/main/java/org/opentripplanner/routing/api/request/request/JourneyRequest.java b/application/src/main/java/org/opentripplanner/routing/api/request/request/JourneyRequest.java index 50e802690b3..562dbc4b362 100644 --- a/application/src/main/java/org/opentripplanner/routing/api/request/request/JourneyRequest.java +++ b/application/src/main/java/org/opentripplanner/routing/api/request/request/JourneyRequest.java @@ -40,8 +40,7 @@ public void setModes(RequestModes modes) { } public RequestModes modes() { - return RequestModes - .of() + return RequestModes.of() .withAccessMode(access.mode()) .withTransferMode(transfer.mode()) .withEgressMode(egress.mode()) diff --git a/application/src/main/java/org/opentripplanner/routing/api/request/request/filter/SelectRequest.java b/application/src/main/java/org/opentripplanner/routing/api/request/request/filter/SelectRequest.java index 8ae98b8dfc9..a17481fd415 100644 --- a/application/src/main/java/org/opentripplanner/routing/api/request/request/filter/SelectRequest.java +++ b/application/src/main/java/org/opentripplanner/routing/api/request/request/filter/SelectRequest.java @@ -96,8 +96,7 @@ public boolean matchesNot(TripTimes tripTimes) { @Override public String toString() { - return ToStringBuilder - .of(SelectRequest.class) + return ToStringBuilder.of(SelectRequest.class) .addObj("transportModes", transportModesToString(), null) .addCol("agencies", agencies, List.of()) .addObj("routes", routes, List.of()) diff --git a/application/src/main/java/org/opentripplanner/routing/api/request/request/filter/TransitFilterRequest.java b/application/src/main/java/org/opentripplanner/routing/api/request/request/filter/TransitFilterRequest.java index 6380ace7c83..c1cf9e44c7f 100644 --- a/application/src/main/java/org/opentripplanner/routing/api/request/request/filter/TransitFilterRequest.java +++ b/application/src/main/java/org/opentripplanner/routing/api/request/request/filter/TransitFilterRequest.java @@ -107,8 +107,7 @@ public boolean matchTripTimes(TripTimes tripTimes) { @Override public String toString() { - return ToStringBuilder - .of(TransitFilterRequest.class) + return ToStringBuilder.of(TransitFilterRequest.class) .addCol("select", Arrays.asList(select)) .addCol("not", Arrays.asList(not)) .toString(); diff --git a/application/src/main/java/org/opentripplanner/routing/api/request/request/filter/TransitGroupSelect.java b/application/src/main/java/org/opentripplanner/routing/api/request/request/filter/TransitGroupSelect.java index caa8c9e0d65..642439765f3 100644 --- a/application/src/main/java/org/opentripplanner/routing/api/request/request/filter/TransitGroupSelect.java +++ b/application/src/main/java/org/opentripplanner/routing/api/request/request/filter/TransitGroupSelect.java @@ -40,10 +40,9 @@ public TransitGroupSelect() { private TransitGroupSelect(Builder builder) { // Sort and keep only unique entries, this make this // implementation consistent for eq/hc/toString. - this.modes = - List.copyOf( - builder.modes.stream().sorted(Comparator.comparingInt(Enum::ordinal)).distinct().toList() - ); + this.modes = List.copyOf( + builder.modes.stream().sorted(Comparator.comparingInt(Enum::ordinal)).distinct().toList() + ); this.subModeRegexp = List.copyOf(builder.subModeRegexp.stream().sorted().distinct().toList()); this.agencyIds = List.copyOf(builder.agencyIds.stream().sorted().distinct().toList()); this.routeIds = List.copyOf(builder.routeIds.stream().sorted().distinct().toList()); @@ -95,8 +94,7 @@ public int hashCode() { public String toString() { return isEmpty() ? "TransitGroupSelect{ EMPTY }" - : ToStringBuilder - .of(TransitGroupSelect.class) + : ToStringBuilder.of(TransitGroupSelect.class) .addCol("modes", modes) .addCol("subModeRegexp", subModeRegexp) .addCol("agencyIds", agencyIds) diff --git a/application/src/main/java/org/opentripplanner/routing/api/request/via/PassThroughViaLocation.java b/application/src/main/java/org/opentripplanner/routing/api/request/via/PassThroughViaLocation.java index c570c18f62d..b01fc58739e 100644 --- a/application/src/main/java/org/opentripplanner/routing/api/request/via/PassThroughViaLocation.java +++ b/application/src/main/java/org/opentripplanner/routing/api/request/via/PassThroughViaLocation.java @@ -29,8 +29,7 @@ public boolean isPassThroughLocation() { @Override public String toString() { - return ToStringBuilder - .of(PassThroughViaLocation.class) + return ToStringBuilder.of(PassThroughViaLocation.class) .addObj("label", label()) .addCol("stopLocationIds", stopLocationIds()) .toString(); diff --git a/application/src/main/java/org/opentripplanner/routing/api/request/via/VisitViaLocation.java b/application/src/main/java/org/opentripplanner/routing/api/request/via/VisitViaLocation.java index c8dd853d8e5..ae8c82de38a 100644 --- a/application/src/main/java/org/opentripplanner/routing/api/request/via/VisitViaLocation.java +++ b/application/src/main/java/org/opentripplanner/routing/api/request/via/VisitViaLocation.java @@ -29,12 +29,11 @@ public VisitViaLocation( List coordinates ) { super(label, stopLocationIds); - this.minimumWaitTime = - DurationUtils.requireNonNegative( - minimumWaitTime == null ? Duration.ZERO : minimumWaitTime, - MINIMUM_WAIT_TIME_MAX_LIMIT, - "minimumWaitTime" - ); + this.minimumWaitTime = DurationUtils.requireNonNegative( + minimumWaitTime == null ? Duration.ZERO : minimumWaitTime, + MINIMUM_WAIT_TIME_MAX_LIMIT, + "minimumWaitTime" + ); this.coordinates = List.copyOf(coordinates); if (stopLocationIds().isEmpty() && coordinates().isEmpty()) { @@ -67,8 +66,7 @@ public List coordinates() { @Override public String toString() { - return ToStringBuilder - .of(VisitViaLocation.class) + return ToStringBuilder.of(VisitViaLocation.class) .addObj("label", label()) .addDuration("minimumWaitTime", minimumWaitTime, Duration.ZERO) .addCol("stopLocationIds", stopLocationIds()) diff --git a/application/src/main/java/org/opentripplanner/routing/api/response/RoutingError.java b/application/src/main/java/org/opentripplanner/routing/api/response/RoutingError.java index d5c8173f09e..741d3e8a30a 100644 --- a/application/src/main/java/org/opentripplanner/routing/api/response/RoutingError.java +++ b/application/src/main/java/org/opentripplanner/routing/api/response/RoutingError.java @@ -32,8 +32,7 @@ public boolean equals(Object o) { @Override public String toString() { - return ToStringBuilder - .of(RoutingError.class) + return ToStringBuilder.of(RoutingError.class) .addEnum("code", code) .addEnum("inputField", inputField) .toString(); diff --git a/application/src/main/java/org/opentripplanner/routing/api/response/RoutingResponse.java b/application/src/main/java/org/opentripplanner/routing/api/response/RoutingResponse.java index fe9f6457cf4..69313fda8be 100644 --- a/application/src/main/java/org/opentripplanner/routing/api/response/RoutingResponse.java +++ b/application/src/main/java/org/opentripplanner/routing/api/response/RoutingResponse.java @@ -64,8 +64,7 @@ public static RoutingResponse ofError(RoutingError error) { @Override public String toString() { - return ToStringBuilder - .of(RoutingResponse.class) + return ToStringBuilder.of(RoutingResponse.class) .addObj("tripPlan", tripPlan) .addObj("nextPageCursor", nextPageCursor) .addObj("previousPageCursor", previousPageCursor) diff --git a/application/src/main/java/org/opentripplanner/routing/api/response/TripSearchMetadata.java b/application/src/main/java/org/opentripplanner/routing/api/response/TripSearchMetadata.java index 704a1cb8e18..a838cc82f11 100644 --- a/application/src/main/java/org/opentripplanner/routing/api/response/TripSearchMetadata.java +++ b/application/src/main/java/org/opentripplanner/routing/api/response/TripSearchMetadata.java @@ -84,8 +84,7 @@ public static TripSearchMetadata createForDepartAfter( @Override public String toString() { - return ToStringBuilder - .of(TripSearchMetadata.class) + return ToStringBuilder.of(TripSearchMetadata.class) .addDuration("searchWindowUsed", searchWindowUsed) .addObj("nextDateTime", nextDateTime) .addObj("prevDateTime", prevDateTime) diff --git a/application/src/main/java/org/opentripplanner/routing/core/VehicleRoutingOptimizeType.java b/application/src/main/java/org/opentripplanner/routing/core/VehicleRoutingOptimizeType.java index cb8436b83b3..961567d766a 100644 --- a/application/src/main/java/org/opentripplanner/routing/core/VehicleRoutingOptimizeType.java +++ b/application/src/main/java/org/opentripplanner/routing/core/VehicleRoutingOptimizeType.java @@ -19,9 +19,8 @@ public enum VehicleRoutingOptimizeType { SAFEST_STREETS, TRIANGLE; - private static final Set NON_TRIANGLE_VALUES = Collections.unmodifiableSet( - EnumSet.complementOf(EnumSet.of(TRIANGLE)) - ); + private static final Set NON_TRIANGLE_VALUES = + Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(TRIANGLE))); /** * Return all values that are not {@link VehicleRoutingOptimizeType#TRIANGLE}. diff --git a/application/src/main/java/org/opentripplanner/routing/error/RoutingValidationException.java b/application/src/main/java/org/opentripplanner/routing/error/RoutingValidationException.java index 04dddf6b799..78d27ebfa29 100644 --- a/application/src/main/java/org/opentripplanner/routing/error/RoutingValidationException.java +++ b/application/src/main/java/org/opentripplanner/routing/error/RoutingValidationException.java @@ -61,9 +61,10 @@ private boolean isLocationNotFound(InputField location) { routingErrors != null && routingErrors .stream() - .anyMatch(routingError -> - routingError.code == RoutingErrorCode.LOCATION_NOT_FOUND && - routingError.inputField == location + .anyMatch( + routingError -> + routingError.code == RoutingErrorCode.LOCATION_NOT_FOUND && + routingError.inputField == location ) ); } diff --git a/application/src/main/java/org/opentripplanner/routing/framework/DebugTimingAggregator.java b/application/src/main/java/org/opentripplanner/routing/framework/DebugTimingAggregator.java index 072f8faa533..7934f4ab1fb 100644 --- a/application/src/main/java/org/opentripplanner/routing/framework/DebugTimingAggregator.java +++ b/application/src/main/java/org/opentripplanner/routing/framework/DebugTimingAggregator.java @@ -89,18 +89,22 @@ public DebugTimingAggregator(MeterRegistry registry, Collection rout renderingTimer = Timer.builder("routing.rendering").tags(tags).register(registry); filteringTimer = Timer.builder("routing.filtering").tags(tags).register(registry); transitRouterTimer = Timer.builder("routing.transit").tags(tags).register(registry); - itineraryCreationTimer = - Timer.builder("routing.itineraryCreation").tags(tags).register(registry); + itineraryCreationTimer = Timer.builder("routing.itineraryCreation") + .tags(tags) + .register(registry); raptorSearchTimer = Timer.builder(ROUTING_RAPTOR).tags(tags).register(registry); accessEgressTimer = Timer.builder("routing.accessEgress").tags(tags).register(registry); - tripPatternFilterTimer = - Timer.builder("routing.tripPatternFiltering").tags(tags).register(registry); + tripPatternFilterTimer = Timer.builder("routing.tripPatternFiltering") + .tags(tags) + .register(registry); preCalculationTimer = Timer.builder("routing.preCalculation").tags(tags).register(registry); - numEgressesDistribution = - DistributionSummary.builder("routing.numEgress").tags(tags).register(registry); - numAccessesDistribution = - DistributionSummary.builder("routing.numAccess").tags(tags).register(registry); + numEgressesDistribution = DistributionSummary.builder("routing.numEgress") + .tags(tags) + .register(registry); + numAccessesDistribution = DistributionSummary.builder("routing.numAccess") + .tags(tags) + .register(registry); egressTimer = Timer.builder("routing.egress").tags(tags).register(registry); accessTimer = Timer.builder("routing.access").tags(tags).register(registry); diff --git a/application/src/main/java/org/opentripplanner/routing/graph/index/StreetIndex.java b/application/src/main/java/org/opentripplanner/routing/graph/index/StreetIndex.java index 2fa5c0de7d8..3d22b259f0e 100644 --- a/application/src/main/java/org/opentripplanner/routing/graph/index/StreetIndex.java +++ b/application/src/main/java/org/opentripplanner/routing/graph/index/StreetIndex.java @@ -163,9 +163,10 @@ public List getVerticesForEnvelope(Envelope envelope) { public Collection getEdgesForEnvelope(Envelope envelope) { return edgeSpatialIndex .query(envelope, Scope.PERMANENT) - .filter(e -> - e.isReachableFromGraph() && - envelope.intersects(edgeGeometryOrStraightLine(e).getEnvelopeInternal()) + .filter( + e -> + e.isReachableFromGraph() && + envelope.intersects(edgeGeometryOrStraightLine(e).getEnvelopeInternal()) ) .toList(); } @@ -191,13 +192,12 @@ public Set getStreetVerticesForLocation( if (location.stopId != null && location.getCoordinate() == null) { var coordinate = siteRepository.getCoordinateById(location.stopId); if (coordinate != null) { - location = - new GenericLocation( - location.label, - location.stopId, - coordinate.latitude(), - coordinate.longitude() - ); + location = new GenericLocation( + location.label, + location.stopId, + coordinate.latitude(), + coordinate.longitude() + ); } } } else { diff --git a/application/src/main/java/org/opentripplanner/routing/graphfinder/NearbyStop.java b/application/src/main/java/org/opentripplanner/routing/graphfinder/NearbyStop.java index e0782ffd122..f8f96ddfba1 100644 --- a/application/src/main/java/org/opentripplanner/routing/graphfinder/NearbyStop.java +++ b/application/src/main/java/org/opentripplanner/routing/graphfinder/NearbyStop.java @@ -73,8 +73,7 @@ public static List nearbyStopsForTransitStopVertices( return List.of(); } - var streetSearchRequest = StreetSearchRequestMapper - .mapToTransferRequest(routeRequest) + var streetSearchRequest = StreetSearchRequestMapper.mapToTransferRequest(routeRequest) .withArriveBy(reverseDirection) .withMode(streetRequest.mode()) .build(); diff --git a/application/src/main/java/org/opentripplanner/routing/graphfinder/PatternAtStop.java b/application/src/main/java/org/opentripplanner/routing/graphfinder/PatternAtStop.java index ae1380c8f1a..54010ac6dd8 100644 --- a/application/src/main/java/org/opentripplanner/routing/graphfinder/PatternAtStop.java +++ b/application/src/main/java/org/opentripplanner/routing/graphfinder/PatternAtStop.java @@ -104,8 +104,7 @@ public boolean equals(Object o) { @Override public String toString() { - return ToStringBuilder - .of(getClass()) + return ToStringBuilder.of(getClass()) .addStr("id", id) .addObj("stop", stop) .addObj("pattern", pattern) diff --git a/application/src/main/java/org/opentripplanner/routing/graphfinder/PlaceFinderTraverseVisitor.java b/application/src/main/java/org/opentripplanner/routing/graphfinder/PlaceFinderTraverseVisitor.java index 1928d4f574b..27ae35701aa 100644 --- a/application/src/main/java/org/opentripplanner/routing/graphfinder/PlaceFinderTraverseVisitor.java +++ b/application/src/main/java/org/opentripplanner/routing/graphfinder/PlaceFinderTraverseVisitor.java @@ -237,8 +237,8 @@ private void handlePatternsAtStop(RegularStop stop, double distance) { .findPatterns(stop) .stream() .filter(pattern -> filterByModes.isEmpty() || filterByModes.contains(pattern.getMode())) - .filter(pattern -> - filterByRoutes.isEmpty() || filterByRoutes.contains(pattern.getRoute().getId()) + .filter( + pattern -> filterByRoutes.isEmpty() || filterByRoutes.contains(pattern.getRoute().getId()) ) .filter(pattern -> pattern.canBoard(stop)) .toList(); diff --git a/application/src/main/java/org/opentripplanner/routing/graphfinder/StreetGraphFinder.java b/application/src/main/java/org/opentripplanner/routing/graphfinder/StreetGraphFinder.java index 061e692fa3f..e7c8ba9fb46 100644 --- a/application/src/main/java/org/opentripplanner/routing/graphfinder/StreetGraphFinder.java +++ b/application/src/main/java/org/opentripplanner/routing/graphfinder/StreetGraphFinder.java @@ -101,8 +101,7 @@ private void findClosestUsingStreets( StreetMode.WALK ) ) { - StreetSearchBuilder - .of() + StreetSearchBuilder.of() .setSkipEdgeStrategy(skipEdgeStrategy) .setTraverseVisitor(visitor) .setDominanceFunction(new DominanceFunctions.LeastWalk()) diff --git a/application/src/main/java/org/opentripplanner/routing/impl/GraphPathFinder.java b/application/src/main/java/org/opentripplanner/routing/impl/GraphPathFinder.java index 77264af9212..4fec7840913 100644 --- a/application/src/main/java/org/opentripplanner/routing/impl/GraphPathFinder.java +++ b/application/src/main/java/org/opentripplanner/routing/impl/GraphPathFinder.java @@ -83,8 +83,7 @@ public List> getPaths( ) { StreetPreferences preferences = request.preferences().street(); - StreetSearchBuilder aStar = StreetSearchBuilder - .of() + StreetSearchBuilder aStar = StreetSearchBuilder.of() .setHeuristic(new EuclideanRemainingWeightHeuristic(maxCarSpeed)) .setSkipEdgeStrategy( new DurationSkipEdgeStrategy( diff --git a/application/src/main/java/org/opentripplanner/routing/linking/SameEdgeAdjuster.java b/application/src/main/java/org/opentripplanner/routing/linking/SameEdgeAdjuster.java index dff08342121..55b9ce75a82 100644 --- a/application/src/main/java/org/opentripplanner/routing/linking/SameEdgeAdjuster.java +++ b/application/src/main/java/org/opentripplanner/routing/linking/SameEdgeAdjuster.java @@ -106,8 +106,7 @@ private static Set overlappingParentStreetEdges(Vertex u, Vertex v) * ignored. */ private static Set getConnectedParentEdges(Vertex loc) { - return Stream - .concat(loc.getIncoming().stream(), loc.getOutgoing().stream()) + return Stream.concat(loc.getIncoming().stream(), loc.getOutgoing().stream()) .filter(it -> it instanceof TemporaryPartialStreetEdge) .map(it -> ((TemporaryPartialStreetEdge) it).getParentEdge()) .collect(Collectors.toSet()); diff --git a/application/src/main/java/org/opentripplanner/routing/linking/VertexLinker.java b/application/src/main/java/org/opentripplanner/routing/linking/VertexLinker.java index 627e1f26010..1b32be34397 100644 --- a/application/src/main/java/org/opentripplanner/routing/linking/VertexLinker.java +++ b/application/src/main/java/org/opentripplanner/routing/linking/VertexLinker.java @@ -199,15 +199,14 @@ private DisposableEdgeCollection link( tempEdges ); if (streetVertices.isEmpty()) { - streetVertices = - linkToStreetEdges( - vertex, - traverseModes, - direction, - scope, - MAX_SEARCH_RADIUS_METERS, - tempEdges - ); + streetVertices = linkToStreetEdges( + vertex, + traverseModes, + direction, + scope, + MAX_SEARCH_RADIUS_METERS, + tempEdges + ); } for (StreetVertex streetVertex : streetVertices) { @@ -294,7 +293,7 @@ private Set linkToStreetEdges( } private static double getXscale(Vertex vertex) { - return Math.cos(vertex.getLat() * Math.PI / 180); + return Math.cos((vertex.getLat() * Math.PI) / 180); } private Set linkToCandidateEdges( diff --git a/application/src/main/java/org/opentripplanner/routing/service/DefaultRoutingService.java b/application/src/main/java/org/opentripplanner/routing/service/DefaultRoutingService.java index 5f654d39deb..2dc4996bea1 100644 --- a/application/src/main/java/org/opentripplanner/routing/service/DefaultRoutingService.java +++ b/application/src/main/java/org/opentripplanner/routing/service/DefaultRoutingService.java @@ -49,10 +49,8 @@ public RoutingResponse route(RouteRequest request) { public ViaRoutingResponse route(RouteViaRequest request) { LOG.debug("Request: {}", request); OTPRequestTimeoutException.checkForTimeout(); - var viaRoutingWorker = new ViaRoutingWorker( - request, - req -> - new RoutingWorker(serverContext, req, serverContext.transitService().getTimeZone()).route() + var viaRoutingWorker = new ViaRoutingWorker(request, req -> + new RoutingWorker(serverContext, req, serverContext.transitService().getTimeZone()).route() ); // TODO: Add output logging here, see route(..) method return viaRoutingWorker.route(); @@ -67,8 +65,7 @@ private void logResponse(RoutingResponse response) { if (LOG.isDebugEnabled()) { var m = response.getMetadata(); - var text = MultiLineToStringBuilder - .of("Response") + var text = MultiLineToStringBuilder.of("Response") .addDuration("SearchWindowUsed", m == null ? null : m.searchWindowUsed) .add("NextPage", response.getNextPageCursor()) .add("PreviousPage", response.getPreviousPageCursor()) diff --git a/application/src/main/java/org/opentripplanner/routing/services/notes/StreetNoteModel.java b/application/src/main/java/org/opentripplanner/routing/services/notes/StreetNoteModel.java index 5bb87740a57..ad60a61ed5b 100644 --- a/application/src/main/java/org/opentripplanner/routing/services/notes/StreetNoteModel.java +++ b/application/src/main/java/org/opentripplanner/routing/services/notes/StreetNoteModel.java @@ -26,13 +26,17 @@ public class StreetNoteModel implements Serializable { * Notes for street edges. No need to synchronize access to the map as they will not be concurrent * write access (no notes for temporary edges, we use notes from parent). */ - private final SetMultimap notesForEdge = HashMultimap.create(); + private final SetMultimap notesForEdge = HashMultimap.< + Edge, + StreetNoteAndMatcher + >create(); /** * Set of unique matchers, kept during building phase, used for interning (lots of note/matchers * are identical). */ - private final transient Map uniqueMatchers = new HashMap<>(); + private final transient Map uniqueMatchers = + new HashMap<>(); StreetNoteModel() {} diff --git a/application/src/main/java/org/opentripplanner/routing/stoptimes/StopTimesHelper.java b/application/src/main/java/org/opentripplanner/routing/stoptimes/StopTimesHelper.java index b8fe8c9b216..406daed81cf 100644 --- a/application/src/main/java/org/opentripplanner/routing/stoptimes/StopTimesHelper.java +++ b/application/src/main/java/org/opentripplanner/routing/stoptimes/StopTimesHelper.java @@ -97,9 +97,10 @@ public static List stopTimesForStop( List ret = new ArrayList<>(); var servicesRunning = transitService.getServiceCodesRunningForDate(serviceDate); - Instant midnight = ServiceDateUtils - .asStartOfService(serviceDate, transitService.getTimeZone()) - .toInstant(); + Instant midnight = ServiceDateUtils.asStartOfService( + serviceDate, + transitService.getTimeZone() + ).toInstant(); for (TripPattern pattern : transitService.findPatterns(stop, true)) { StopTimesInPattern stopTimes = new StopTimesInPattern(pattern); @@ -212,12 +213,11 @@ private static Queue listTripTimeOnDatesForPatternAtStop( // ways to do it. // // The {@link MinMaxPriorityQueue} is marked beta, but we do not have a god alternative. - MinMaxPriorityQueue pq = MinMaxPriorityQueue - .orderedBy( - Comparator.comparing((TripTimeOnDate tts) -> - tts.getServiceDayMidnight() + tts.getRealtimeDeparture() - ) + MinMaxPriorityQueue pq = MinMaxPriorityQueue.orderedBy( + Comparator.comparing( + (TripTimeOnDate tts) -> tts.getServiceDayMidnight() + tts.getRealtimeDeparture() ) + ) .maximumSize(numberOfDepartures) .create(); diff --git a/application/src/main/java/org/opentripplanner/routing/util/ElevationUtils.java b/application/src/main/java/org/opentripplanner/routing/util/ElevationUtils.java index 910c6389a94..689668e42f1 100644 --- a/application/src/main/java/org/opentripplanner/routing/util/ElevationUtils.java +++ b/application/src/main/java/org/opentripplanner/routing/util/ElevationUtils.java @@ -134,13 +134,8 @@ public static SlopeCosts getSlopeCosts(CoordinateSequence elev, boolean slopeLim double hypotenuse = Math.sqrt(rise * rise + run * run); double energy = hypotenuse * - ( - ENERGY_PER_METER_ON_FLAT + - ENERGY_SLOPE_FACTOR * - slope_or_zero * - slope_or_zero * - slope_or_zero - ); + (ENERGY_PER_METER_ON_FLAT + + ENERGY_SLOPE_FACTOR * slope_or_zero * slope_or_zero * slope_or_zero); slopeWorkCost += energy; double slopeSpeedCoef = slopeSpeedCoefficient(slope, coordinates[i].y); slopeSpeedEffectiveLength += run / slopeSpeedCoef; diff --git a/application/src/main/java/org/opentripplanner/routing/via/service/DefaultViaCoordinateTransferFactory.java b/application/src/main/java/org/opentripplanner/routing/via/service/DefaultViaCoordinateTransferFactory.java index d59a184bb7e..eb0277d6896 100644 --- a/application/src/main/java/org/opentripplanner/routing/via/service/DefaultViaCoordinateTransferFactory.java +++ b/application/src/main/java/org/opentripplanner/routing/via/service/DefaultViaCoordinateTransferFactory.java @@ -63,21 +63,20 @@ public List createViaTransfers( var m = mapTransferMode(request.journey().modes().transferMode); - tempEdges = - graph - .getLinker() - .linkVertexForRequest( - viaVertex, - new TraverseModeSet(m), - LinkingDirection.BIDIRECTIONAL, - (via, street) -> { - var v = (TemporaryStreetLocation) via; - return List.of( - TemporaryFreeEdge.createTemporaryFreeEdge(street, v), - TemporaryFreeEdge.createTemporaryFreeEdge(v, street) - ); - } - ); + tempEdges = graph + .getLinker() + .linkVertexForRequest( + viaVertex, + new TraverseModeSet(m), + LinkingDirection.BIDIRECTIONAL, + (via, street) -> { + var v = (TemporaryStreetLocation) via; + return List.of( + TemporaryFreeEdge.createTemporaryFreeEdge(street, v), + TemporaryFreeEdge.createTemporaryFreeEdge(v, street) + ); + } + ); var toStops = findNearbyStops(nearbyStopFinder, viaVertex, request, false); var fromStops = findNearbyStops(nearbyStopFinder, viaVertex, request, true); diff --git a/application/src/main/java/org/opentripplanner/service/osminfo/internal/DefaultOsmInfoGraphBuildRepository.java b/application/src/main/java/org/opentripplanner/service/osminfo/internal/DefaultOsmInfoGraphBuildRepository.java index 1b3faceabe3..7b19e81eb43 100644 --- a/application/src/main/java/org/opentripplanner/service/osminfo/internal/DefaultOsmInfoGraphBuildRepository.java +++ b/application/src/main/java/org/opentripplanner/service/osminfo/internal/DefaultOsmInfoGraphBuildRepository.java @@ -47,8 +47,7 @@ public Optional findPlatform(Area area) { @Override public String toString() { - return ToStringBuilder - .of(DefaultOsmInfoGraphBuildRepository.class) + return ToStringBuilder.of(DefaultOsmInfoGraphBuildRepository.class) .addNum("Linear platforms", platforms.size()) .addNum("Area platforms", areaPlatforms.size()) .toString(); diff --git a/application/src/main/java/org/opentripplanner/service/paging/PagingService.java b/application/src/main/java/org/opentripplanner/service/paging/PagingService.java index b9a11ab5ffa..c9187f85e9c 100644 --- a/application/src/main/java/org/opentripplanner/service/paging/PagingService.java +++ b/application/src/main/java/org/opentripplanner/service/paging/PagingService.java @@ -55,12 +55,11 @@ public PagingService( this.pageCursorInput = pageCursorInput; this.itineraries = Objects.requireNonNull(itineraries); - this.searchWindowAdjuster = - createSearchWindowAdjuster( - pagingSearchWindowAdjustments, - minSearchWindowSize, - maxSearchWindowSize - ); + this.searchWindowAdjuster = createSearchWindowAdjuster( + pagingSearchWindowAdjustments, + minSearchWindowSize, + maxSearchWindowSize + ); } public PageCursor nextPageCursor() { @@ -161,8 +160,9 @@ private boolean doCropSearchWindowAtTail() { private PageCursorFactory pageCursorFactory() { if (pageCursorFactory == null) { - this.pageCursorFactory = - mapIntoPageCursorFactory(pageCursor == null ? null : pageCursor.type()); + this.pageCursorFactory = mapIntoPageCursorFactory( + pageCursor == null ? null : pageCursor.type() + ); } return pageCursorFactory; } @@ -177,13 +177,12 @@ private PageCursorFactory mapIntoPageCursorFactory(@Nullable PageType currentPag assertRequestPrerequisites(); - factory = - factory.withOriginalSearch( - currentPageType, - earliestDepartureTime, - latestArrivalTime, - searchWindowUsed - ); + factory = factory.withOriginalSearch( + currentPageType, + earliestDepartureTime, + latestArrivalTime, + searchWindowUsed + ); if (pageCursorInput != null) { factory = factory.withRemovedItineraries(pageCursorInput); @@ -209,8 +208,7 @@ private boolean noSuccessfulTransitSearchPerformed() { @Override public String toString() { - return ToStringBuilder - .of(PagingService.class) + return ToStringBuilder.of(PagingService.class) .addDuration("searchWindowUsed", searchWindowUsed) .addDateTime("earliestDepartureTime", earliestDepartureTime) .addDateTime("latestArrivalTime", latestArrivalTime) diff --git a/application/src/main/java/org/opentripplanner/service/realtimevehicles/model/RealtimeVehicle.java b/application/src/main/java/org/opentripplanner/service/realtimevehicles/model/RealtimeVehicle.java index fb0cbb28dbe..f550026b1b3 100644 --- a/application/src/main/java/org/opentripplanner/service/realtimevehicles/model/RealtimeVehicle.java +++ b/application/src/main/java/org/opentripplanner/service/realtimevehicles/model/RealtimeVehicle.java @@ -47,8 +47,7 @@ public class RealtimeVehicle { private final OccupancyStatus occupancyStatus; RealtimeVehicle(RealtimeVehicleBuilder builder) { - var stopRelationship = Optional - .ofNullable(builder.stop()) + var stopRelationship = Optional.ofNullable(builder.stop()) .map(s -> new StopRelationship(s, builder.stopStatus())) .orElse(null); this.vehicleId = builder.vehicleId(); diff --git a/application/src/main/java/org/opentripplanner/service/vehicleparking/internal/DefaultVehicleParkingRepository.java b/application/src/main/java/org/opentripplanner/service/vehicleparking/internal/DefaultVehicleParkingRepository.java index ef8f9db99bf..a8557e48988 100644 --- a/application/src/main/java/org/opentripplanner/service/vehicleparking/internal/DefaultVehicleParkingRepository.java +++ b/application/src/main/java/org/opentripplanner/service/vehicleparking/internal/DefaultVehicleParkingRepository.java @@ -31,7 +31,8 @@ public DefaultVehicleParkingRepository() {} *

* The volatile keyword is used to ensure safe publication by clearing CPU caches. */ - private volatile ImmutableListMultimap vehicleParkingGroups = ImmutableListMultimap.of(); + private volatile ImmutableListMultimap vehicleParkingGroups = + ImmutableListMultimap.of(); /** * Does atomic update of {@link VehicleParking} and index of {@link VehicleParkingGroup} in this @@ -43,9 +44,8 @@ public void updateVehicleParking( Collection parkingToAdd, Collection parkingToRemove ) { - Multimap updatedVehicleParkingGroups = ArrayListMultimap.create( - vehicleParkingGroups - ); + Multimap updatedVehicleParkingGroups = + ArrayListMultimap.create(vehicleParkingGroups); parkingToRemove.forEach(vehicleParking -> { var vehicleParkingGroup = vehicleParking.getVehicleParkingGroup(); if (vehicleParkingGroup != null) { diff --git a/application/src/main/java/org/opentripplanner/service/vehicleparking/model/VehicleParking.java b/application/src/main/java/org/opentripplanner/service/vehicleparking/model/VehicleParking.java index c9539f21eef..1fd8a5b8f9f 100644 --- a/application/src/main/java/org/opentripplanner/service/vehicleparking/model/VehicleParking.java +++ b/application/src/main/java/org/opentripplanner/service/vehicleparking/model/VehicleParking.java @@ -122,8 +122,10 @@ public class VehicleParking implements Serializable { VehicleParkingSpaces availability, VehicleParkingGroup vehicleParkingGroup ) { - this.id = - Objects.requireNonNull(id, "%s must have an ID".formatted(this.getClass().getSimpleName())); + this.id = Objects.requireNonNull( + id, + "%s must have an ID".formatted(this.getClass().getSimpleName()) + ); this.name = name; this.coordinate = Objects.requireNonNull(coordinate); this.detailsUrl = detailsUrl; @@ -313,8 +315,7 @@ public boolean equals(Object o) { } public String toString() { - return ToStringBuilder - .of(VehicleParking.class) + return ToStringBuilder.of(VehicleParking.class) .addStr("id", id.toString()) .addStr("name", name.toString()) .addObj("coordinate", coordinate) diff --git a/application/src/main/java/org/opentripplanner/service/vehicleparking/model/VehicleParkingEntrance.java b/application/src/main/java/org/opentripplanner/service/vehicleparking/model/VehicleParkingEntrance.java index d905441641b..6f4034023fe 100644 --- a/application/src/main/java/org/opentripplanner/service/vehicleparking/model/VehicleParkingEntrance.java +++ b/application/src/main/java/org/opentripplanner/service/vehicleparking/model/VehicleParkingEntrance.java @@ -100,8 +100,7 @@ public boolean equals(Object o) { } public String toString() { - return ToStringBuilder - .of(VehicleParkingEntrance.class) + return ToStringBuilder.of(VehicleParkingEntrance.class) .addObj("entranceId", entranceId) .addObj("name", name) .addObj("coordinate", coordinate) diff --git a/application/src/main/java/org/opentripplanner/service/vehicleparking/model/VehicleParkingGroup.java b/application/src/main/java/org/opentripplanner/service/vehicleparking/model/VehicleParkingGroup.java index 07548efa11a..ba18fe43e8c 100644 --- a/application/src/main/java/org/opentripplanner/service/vehicleparking/model/VehicleParkingGroup.java +++ b/application/src/main/java/org/opentripplanner/service/vehicleparking/model/VehicleParkingGroup.java @@ -75,8 +75,7 @@ public int hashCode() { } public String toString() { - return ToStringBuilder - .of(VehicleParkingGroup.class) + return ToStringBuilder.of(VehicleParkingGroup.class) .addStr("name", name.toString()) .addObj("coordinate", coordinate) .toString(); diff --git a/application/src/main/java/org/opentripplanner/service/vehicleparking/model/VehicleParkingHelper.java b/application/src/main/java/org/opentripplanner/service/vehicleparking/model/VehicleParkingHelper.java index 5832a8d5f91..0d5ddaca8a1 100644 --- a/application/src/main/java/org/opentripplanner/service/vehicleparking/model/VehicleParkingHelper.java +++ b/application/src/main/java/org/opentripplanner/service/vehicleparking/model/VehicleParkingHelper.java @@ -73,10 +73,8 @@ private static boolean isUsableForParking( var usableForCarParking = from.getVehicleParking().hasAnyCarPlaces() && - ( - (from.isCarAccessible() && to.isWalkAccessible()) || - (from.isWalkAccessible() && to.isCarAccessible()) - ); + ((from.isCarAccessible() && to.isWalkAccessible()) || + (from.isWalkAccessible() && to.isCarAccessible())); return usableForBikeParking || usableForCarParking; } diff --git a/application/src/main/java/org/opentripplanner/service/vehicleparking/model/VehicleParkingSpaces.java b/application/src/main/java/org/opentripplanner/service/vehicleparking/model/VehicleParkingSpaces.java index 6827e6af198..fb870fb7ebd 100644 --- a/application/src/main/java/org/opentripplanner/service/vehicleparking/model/VehicleParkingSpaces.java +++ b/application/src/main/java/org/opentripplanner/service/vehicleparking/model/VehicleParkingSpaces.java @@ -73,8 +73,7 @@ public boolean equals(Object o) { @Override public String toString() { - return ToStringBuilder - .of(VehicleParkingSpaces.class) + return ToStringBuilder.of(VehicleParkingSpaces.class) .addNum("carSpaces", carSpaces) .addNum("wheelchairAccessibleCarSpaces", wheelchairAccessibleCarSpaces) .addNum("bicycleSpaces", bicycleSpaces) diff --git a/application/src/main/java/org/opentripplanner/service/vehiclerental/model/RentalVehicleType.java b/application/src/main/java/org/opentripplanner/service/vehiclerental/model/RentalVehicleType.java index 0d26682395d..50807d3de76 100644 --- a/application/src/main/java/org/opentripplanner/service/vehiclerental/model/RentalVehicleType.java +++ b/application/src/main/java/org/opentripplanner/service/vehiclerental/model/RentalVehicleType.java @@ -39,16 +39,14 @@ public RentalVehicleType( public static RentalVehicleType getDefaultType(String systemId) { return defaultVehicleForSystem.computeIfAbsent( systemId, - ( - id -> + (id -> new RentalVehicleType( new FeedScopedId(id, "DEFAULT"), "Default vehicle type", RentalFormFactor.BICYCLE, PropulsionType.HUMAN, null - ) - ) + )) ); } diff --git a/application/src/main/java/org/opentripplanner/service/vehiclerental/model/VehicleRentalStation.java b/application/src/main/java/org/opentripplanner/service/vehiclerental/model/VehicleRentalStation.java index ff17ee00593..80ae3233c06 100644 --- a/application/src/main/java/org/opentripplanner/service/vehiclerental/model/VehicleRentalStation.java +++ b/application/src/main/java/org/opentripplanner/service/vehiclerental/model/VehicleRentalStation.java @@ -132,9 +132,10 @@ public boolean isFloatingVehicle() { @Override public boolean isCarStation() { - return Stream - .concat(vehicleTypesAvailable.keySet().stream(), vehicleSpacesAvailable.keySet().stream()) - .anyMatch(rentalVehicleType -> rentalVehicleType.formFactor.equals(RentalFormFactor.CAR)); + return Stream.concat( + vehicleTypesAvailable.keySet().stream(), + vehicleSpacesAvailable.keySet().stream() + ).anyMatch(rentalVehicleType -> rentalVehicleType.formFactor.equals(RentalFormFactor.CAR)); } @Override diff --git a/application/src/main/java/org/opentripplanner/service/vehiclerental/street/CompositeRentalRestrictionExtension.java b/application/src/main/java/org/opentripplanner/service/vehiclerental/street/CompositeRentalRestrictionExtension.java index 780f336dcf9..7fa8db86a4f 100644 --- a/application/src/main/java/org/opentripplanner/service/vehiclerental/street/CompositeRentalRestrictionExtension.java +++ b/application/src/main/java/org/opentripplanner/service/vehiclerental/street/CompositeRentalRestrictionExtension.java @@ -75,8 +75,7 @@ public static RentalRestrictionExtension of(RentalRestrictionExtension... exts) @Override public RentalRestrictionExtension remove(RentalRestrictionExtension toRemove) { - var newExts = Arrays - .stream(extensions) + var newExts = Arrays.stream(extensions) .filter(e -> !e.equals(toRemove)) .toArray(RentalRestrictionExtension[]::new); if (newExts.length == 0) { @@ -98,8 +97,7 @@ public boolean hasRestrictions() { @Override public Set noDropOffNetworks() { - return Arrays - .stream(extensions) + return Arrays.stream(extensions) .flatMap(e -> e.noDropOffNetworks().stream()) .collect(Collectors.toSet()); } diff --git a/application/src/main/java/org/opentripplanner/service/vehiclerental/street/GeofencingZoneExtension.java b/application/src/main/java/org/opentripplanner/service/vehiclerental/street/GeofencingZoneExtension.java index 02d529f60da..8ac874f1513 100644 --- a/application/src/main/java/org/opentripplanner/service/vehiclerental/street/GeofencingZoneExtension.java +++ b/application/src/main/java/org/opentripplanner/service/vehiclerental/street/GeofencingZoneExtension.java @@ -31,10 +31,8 @@ public boolean traversalBanned(State state) { if (state.isRentingVehicle()) { return ( zone.traversalBanned() && - ( - state.unknownRentalNetwork() || - zone.id().getFeedId().equals(state.getVehicleRentalNetwork()) - ) + (state.unknownRentalNetwork() || + zone.id().getFeedId().equals(state.getVehicleRentalNetwork())) ); } else { return false; diff --git a/application/src/main/java/org/opentripplanner/service/worldenvelope/model/WorldEnvelope.java b/application/src/main/java/org/opentripplanner/service/worldenvelope/model/WorldEnvelope.java index 55024b63982..34706fdddc5 100644 --- a/application/src/main/java/org/opentripplanner/service/worldenvelope/model/WorldEnvelope.java +++ b/application/src/main/java/org/opentripplanner/service/worldenvelope/model/WorldEnvelope.java @@ -79,8 +79,7 @@ public Optional medianCenter() { @Override public String toString() { - return ToStringBuilder - .of(WorldEnvelope.class) + return ToStringBuilder.of(WorldEnvelope.class) .addObj("lowerLeft", lowerLeft) .addObj("upperRight", upperRight) .addObj("meanCenter", meanCenter) diff --git a/application/src/main/java/org/opentripplanner/standalone/OTPMain.java b/application/src/main/java/org/opentripplanner/standalone/OTPMain.java index 25eea6df473..f9cbda60163 100644 --- a/application/src/main/java/org/opentripplanner/standalone/OTPMain.java +++ b/application/src/main/java/org/opentripplanner/standalone/OTPMain.java @@ -160,8 +160,7 @@ private static void startOTPServer(CommandLineParameters cli) { app.emissionsDataModel(), app.stopConsolidationRepository(), app.streetLimitationParameters() - ) - .save(app.graphOutputDataSource()); + ).save(app.graphOutputDataSource()); // Log size info for the deduplicator LOG.info("Memory optimized {}", app.graph().deduplicator.toString()); } @@ -237,17 +236,14 @@ private static void registerShutdownHookToGracefullyShutDownServer( TimetableRepository timetableRepository, RaptorConfig raptorConfig ) { - ApplicationShutdownSupport.addShutdownHook( - "server-shutdown", - () -> { - LOG.info("OTP shutdown started..."); - UpdaterConfigurator.shutdownGraph(timetableRepository); - raptorConfig.shutdown(); - WeakCollectionCleaner.DEFAULT.exit(); - DeferredAuthorityFactory.exit(); - LOG.info("OTP shutdown: resources released..."); - } - ); + ApplicationShutdownSupport.addShutdownHook("server-shutdown", () -> { + LOG.info("OTP shutdown started..."); + UpdaterConfigurator.shutdownGraph(timetableRepository); + raptorConfig.shutdown(); + WeakCollectionCleaner.DEFAULT.exit(); + DeferredAuthorityFactory.exit(); + LOG.info("OTP shutdown: resources released..."); + }); } private static void setOtpConfigVersionsOnServerInfo(ConstructApplication app) { diff --git a/application/src/main/java/org/opentripplanner/standalone/OtpStartupInfo.java b/application/src/main/java/org/opentripplanner/standalone/OtpStartupInfo.java index ddcc2c60212..3224dc0d88f 100644 --- a/application/src/main/java/org/opentripplanner/standalone/OtpStartupInfo.java +++ b/application/src/main/java/org/opentripplanner/standalone/OtpStartupInfo.java @@ -43,9 +43,8 @@ public static void logInfo(String cliTaskInfo) { projectInfo().getVersionString(), javaVersion() ); - ApplicationShutdownSupport.addShutdownHook( - "server-shutdown-info", - () -> LOG.info("OTP SHUTTING DOWN - {} - {}", cliTaskInfo, projectInfo().getVersionString()) + ApplicationShutdownSupport.addShutdownHook("server-shutdown-info", () -> + LOG.info("OTP SHUTTING DOWN - {} - {}", cliTaskInfo, projectInfo().getVersionString()) ); LOG.info(NEW_LINE + "{}", info()); } diff --git a/application/src/main/java/org/opentripplanner/standalone/config/BuildConfig.java b/application/src/main/java/org/opentripplanner/standalone/config/BuildConfig.java index f8533bd75ca..d9514a34206 100644 --- a/application/src/main/java/org/opentripplanner/standalone/config/BuildConfig.java +++ b/application/src/main/java/org/opentripplanner/standalone/config/BuildConfig.java @@ -204,320 +204,296 @@ public BuildConfig(JsonNode node, String source, boolean logUnusedParams) { public BuildConfig(NodeAdapter root, boolean logUnusedParams) { this.root = root; // Keep this list of BASIC parameters sorted alphabetically on config PARAMETER name - areaVisibility = - root - .of("areaVisibility") - .since(V1_5) - .summary("Perform visibility calculations.") - .description( - """ - If this is `true` OTP attempts to calculate a path straight through an OSM area using the - shortest way rather than around the edge of it. (These calculations can be time consuming). - """ - ) - .asBoolean(false); - configVersion = - root - .of("configVersion") - .since(V2_1) - .summary("Deployment version of the *" + BUILD_CONFIG_FILENAME + "*.") - .description(OtpConfig.CONFIG_VERSION_DESCRIPTION) - .asString(null); - dataImportReport = - root - .of("dataImportReport") - .since(V2_0) - .summary("Generate nice HTML report of Graph errors/warnings") - .description("The reports are stored in the same location as the graph.") - .asBoolean(false); - distanceBetweenElevationSamples = - root - .of("distanceBetweenElevationSamples") - .since(V2_0) - .summary("The distance between elevation samples in meters.") - .description( - "The default is the approximate resolution of 1/3 arc-second NED data. This should not " + - "be smaller than the horizontal resolution of the height data used." - ) - .asDouble(CompactElevationProfile.DEFAULT_DISTANCE_BETWEEN_SAMPLES_METERS); + areaVisibility = root + .of("areaVisibility") + .since(V1_5) + .summary("Perform visibility calculations.") + .description( + """ + If this is `true` OTP attempts to calculate a path straight through an OSM area using the + shortest way rather than around the edge of it. (These calculations can be time consuming). + """ + ) + .asBoolean(false); + configVersion = root + .of("configVersion") + .since(V2_1) + .summary("Deployment version of the *" + BUILD_CONFIG_FILENAME + "*.") + .description(OtpConfig.CONFIG_VERSION_DESCRIPTION) + .asString(null); + dataImportReport = root + .of("dataImportReport") + .since(V2_0) + .summary("Generate nice HTML report of Graph errors/warnings") + .description("The reports are stored in the same location as the graph.") + .asBoolean(false); + distanceBetweenElevationSamples = root + .of("distanceBetweenElevationSamples") + .since(V2_0) + .summary("The distance between elevation samples in meters.") + .description( + "The default is the approximate resolution of 1/3 arc-second NED data. This should not " + + "be smaller than the horizontal resolution of the height data used." + ) + .asDouble(CompactElevationProfile.DEFAULT_DISTANCE_BETWEEN_SAMPLES_METERS); elevationBucket = S3BucketConfig.fromConfig(root, "elevationBucket"); - embedRouterConfig = - root - .of("embedRouterConfig") - .since(V2_0) - .summary( - "Embed the Router config in the graph, which allows it to be sent to a server fully " + - "configured over the wire." - ) - .asBoolean(true); - includeEllipsoidToGeoidDifference = - root - .of("includeEllipsoidToGeoidDifference") - .since(V2_0) - .summary( - "Include the Ellipsoid to Geoid difference in the calculations of every point along " + - "every StreetWithElevationEdge." - ) - .description( - """ -When set to true (it is false by default), the elevation module will include the Ellipsoid to -Geoid difference in the calculations of every point along every StreetWithElevationEdge in the -graph. - -NOTE: if this is set to true for graph building, make sure to not set the value of -`RoutingResource#geoidElevation` to true otherwise OTP will add this geoid value again to -all of the elevation values in the street edges. -""" - ) - .asBoolean(false); + embedRouterConfig = root + .of("embedRouterConfig") + .since(V2_0) + .summary( + "Embed the Router config in the graph, which allows it to be sent to a server fully " + + "configured over the wire." + ) + .asBoolean(true); + includeEllipsoidToGeoidDifference = root + .of("includeEllipsoidToGeoidDifference") + .since(V2_0) + .summary( + "Include the Ellipsoid to Geoid difference in the calculations of every point along " + + "every StreetWithElevationEdge." + ) + .description( + """ + When set to true (it is false by default), the elevation module will include the Ellipsoid to + Geoid difference in the calculations of every point along every StreetWithElevationEdge in the + graph. + + NOTE: if this is set to true for graph building, make sure to not set the value of + `RoutingResource#geoidElevation` to true otherwise OTP will add this geoid value again to + all of the elevation values in the street edges. + """ + ) + .asBoolean(false); islandPruning = IslandPruningConfig.fromConfig(root); - maxDataImportIssuesPerFile = - root - .of("maxDataImportIssuesPerFile") - .since(V2_0) - .summary("When to split the import report.") - .description( - """ - If the number of issues is larger then `maxDataImportIssuesPerFile`, then the files will - be split in multiple files. Since browsers have problems opening large HTML files. - """ - ) - .asInt(1000); - maxTransferDuration = - root - .of("maxTransferDuration") - .since(V2_1) - .summary( - "Transfers up to this duration with a mode-specific speed value will be pre-calculated and included in the Graph." - ) - .asDuration(Duration.ofMinutes(30)); + maxDataImportIssuesPerFile = root + .of("maxDataImportIssuesPerFile") + .since(V2_0) + .summary("When to split the import report.") + .description( + """ + If the number of issues is larger then `maxDataImportIssuesPerFile`, then the files will + be split in multiple files. Since browsers have problems opening large HTML files. + """ + ) + .asInt(1000); + maxTransferDuration = root + .of("maxTransferDuration") + .since(V2_1) + .summary( + "Transfers up to this duration with a mode-specific speed value will be pre-calculated and included in the Graph." + ) + .asDuration(Duration.ofMinutes(30)); transferParametersForMode = TransferConfig.map(root, "transferParametersForMode"); - maxStopToShapeSnapDistance = - root - .of("maxStopToShapeSnapDistance") - .since(V2_1) - .summary("Maximum distance between route shapes and their stops.") - .description( - """ + maxStopToShapeSnapDistance = root + .of("maxStopToShapeSnapDistance") + .since(V2_1) + .summary("Maximum distance between route shapes and their stops.") + .description( + """ This field is used for mapping routes geometry shapes. It determines max distance between shape points and their stop sequence. If mapper cannot find any stops within this radius it will default to simple stop-to-stop geometry instead. """ - ) - .asDouble(150); - multiThreadElevationCalculations = - root - .of("multiThreadElevationCalculations") - .since(V2_0) - .summary("Configuring multi-threading during elevation calculations.") - .description( - """ + ) + .asDouble(150); + multiThreadElevationCalculations = root + .of("multiThreadElevationCalculations") + .since(V2_0) + .summary("Configuring multi-threading during elevation calculations.") + .description( + """ For unknown reasons that seem to depend on data and machine settings, it might be faster to use a single processor. If multi-threading is activated, parallel streams will be used to calculate the elevations. """ - ) - .asBoolean(false); - osmCacheDataInMem = - root - .of("osmCacheDataInMem") - .since(V2_0) - .summary("If OSM data should be cached in memory during processing.") - .description( - """ - When loading OSM data, the input is streamed 3 times - one phase for processing RELATIONS, one - for WAYS and last one for NODES. Instead of reading the data source 3 times it might be faster - to cache the entire osm file im memory. The trade off is of course that OTP might use more - memory while loading osm data. You can use this parameter to choose what is best for your - deployment depending on your infrastructure. Set the parameter to `true` to cache the - data, and to `false` to read the stream from the source each time. - """ - ) - .asBoolean(false); - platformEntriesLinking = - root - .of("platformEntriesLinking") - .since(V2_0) - .summary("Link unconnected entries to public transport platforms.") - .asBoolean(false); - readCachedElevations = - root - .of("readCachedElevations") - .since(V2_0) - .summary("Whether to read cached elevation data.") - .description( - """ + ) + .asBoolean(false); + osmCacheDataInMem = root + .of("osmCacheDataInMem") + .since(V2_0) + .summary("If OSM data should be cached in memory during processing.") + .description( + """ + When loading OSM data, the input is streamed 3 times - one phase for processing RELATIONS, one + for WAYS and last one for NODES. Instead of reading the data source 3 times it might be faster + to cache the entire osm file im memory. The trade off is of course that OTP might use more + memory while loading osm data. You can use this parameter to choose what is best for your + deployment depending on your infrastructure. Set the parameter to `true` to cache the + data, and to `false` to read the stream from the source each time. + """ + ) + .asBoolean(false); + platformEntriesLinking = root + .of("platformEntriesLinking") + .since(V2_0) + .summary("Link unconnected entries to public transport platforms.") + .asBoolean(false); + readCachedElevations = root + .of("readCachedElevations") + .since(V2_0) + .summary("Whether to read cached elevation data.") + .description( + """ When set to true, the elevation module will attempt to read this file in order to reuse calculations of elevation data for various coordinate sequences instead of recalculating them all over again. """ - ) - .asBoolean(true); - staticBikeParkAndRide = - root - .of("staticBikeParkAndRide") - .since(V1_5) - .summary("Whether we should create bike P+R stations from OSM data.") - .asBoolean(false); - staticParkAndRide = - root - .of("staticParkAndRide") - .since(V1_5) - .summary("Whether we should create car P+R stations from OSM data.") - .asBoolean(true); - subwayAccessTime = - root - .of("subwayAccessTime") - .since(V1_5) - .summary( - "Minutes necessary to reach stops served by trips on routes of route_type=1 (subway) from the street." - ) - .description( - """ -Note! The preferred way to do this is to update the OSM data. -See [In-station navigation](In-Station-Navigation.md). - -The ride locations for some modes of transport such as subways can be slow to reach from the street. -When planning a trip, we need to allow additional time to reach these locations to properly inform -the passenger. For example, this helps avoid suggesting short bus rides between two subway rides as -a way to improve travel time. You can specify how long it takes to reach a subway platform. - -This setting does not generalize to other modes like airplanes because you often need much longer time -to check in to a flight (2-3 hours for international flights) than to alight and exit the airport -(perhaps 1 hour). Use [`boardSlackForMode`](RouteRequest.md#rd_boardSlackForMode) and -[`alightSlackForMode`](RouteRequest.md#rd_alightSlackForMode) for this. -""" - ) - .asDouble(DEFAULT_SUBWAY_ACCESS_TIME_MINUTES); + ) + .asBoolean(true); + staticBikeParkAndRide = root + .of("staticBikeParkAndRide") + .since(V1_5) + .summary("Whether we should create bike P+R stations from OSM data.") + .asBoolean(false); + staticParkAndRide = root + .of("staticParkAndRide") + .since(V1_5) + .summary("Whether we should create car P+R stations from OSM data.") + .asBoolean(true); + subwayAccessTime = root + .of("subwayAccessTime") + .since(V1_5) + .summary( + "Minutes necessary to reach stops served by trips on routes of route_type=1 (subway) from the street." + ) + .description( + """ + Note! The preferred way to do this is to update the OSM data. + See [In-station navigation](In-Station-Navigation.md). + + The ride locations for some modes of transport such as subways can be slow to reach from the street. + When planning a trip, we need to allow additional time to reach these locations to properly inform + the passenger. For example, this helps avoid suggesting short bus rides between two subway rides as + a way to improve travel time. You can specify how long it takes to reach a subway platform. + + This setting does not generalize to other modes like airplanes because you often need much longer time + to check in to a flight (2-3 hours for international flights) than to alight and exit the airport + (perhaps 1 hour). Use [`boardSlackForMode`](RouteRequest.md#rd_boardSlackForMode) and + [`alightSlackForMode`](RouteRequest.md#rd_alightSlackForMode) for this. + """ + ) + .asDouble(DEFAULT_SUBWAY_ACCESS_TIME_MINUTES); // Time Zone dependent config { // We need a time zone for setting transit service start and end. Getting the wrong time-zone // will just shift the period with one day, so the consequences is limited. - transitModelTimeZone = - root - .of("transitModelTimeZone") - .since(V2_2) - .summary("Time zone for the graph.") - .description( - "This is used to store the timetables in the transit model, and to interpret times in incoming requests." - ) - .asZoneId(null); + transitModelTimeZone = root + .of("transitModelTimeZone") + .since(V2_2) + .summary("Time zone for the graph.") + .description( + "This is used to store the timetables in the transit model, and to interpret times in incoming requests." + ) + .asZoneId(null); var confZone = ObjectUtils.ifNotNull(transitModelTimeZone, ZoneId.systemDefault()); - transitServiceStart = - root - .of("transitServiceStart") - .since(V2_0) - .summary("Limit the import of transit services to the given START date.") - .description( - """ -See [Limit the transit service period](#limit-transit-service-period) for an introduction. - -The date is inclusive. If set, any transit service on a day BEFORE the given date is dropped and -will not be part of the graph. Use an absolute date or a period relative to the date the graph is -build(BUILD_DAY). - -Use an empty string to make unbounded. -""" - ) - .asDateOrRelativePeriod("-P1Y", confZone); - transitServiceEnd = - root - .of("transitServiceEnd") - .since(V2_0) - .summary("Limit the import of transit services to the given end date.") - .description( - """ -See [Limit the transit service period](#limit-transit-service-period) for an introduction. - -The date is inclusive. If set, any transit service on a day AFTER the given date is dropped and -will not be part of the graph. Use an absolute date or a period relative to the date the graph is -build(BUILD_DAY). - -Use an empty string to make it unbounded. -""" - ) - .asDateOrRelativePeriod("P3Y", confZone); - } - - transitRouteToStationCentroid = - root - .of("transitRouteToStationCentroid") - .since(V2_7) - .summary("List stations that should route to centroid.") + transitServiceStart = root + .of("transitServiceStart") + .since(V2_0) + .summary("Limit the import of transit services to the given START date.") .description( """ -This field contains a list of station ids for which street legs will start/end at the station -centroid instead of the child stops. - -When searching from/to a station the default behaviour is to route from/to any of the stations child -stops. This can cause strange results for stations that have stops spread over a large area. - -For some stations you might instead wish to use the centroid of the station as the -origin/destination. In this case the centroid will be used both for direct street search and for -access/egress street search where the station is used as the start/end of the access/egress. But -transit that starts/ends at the station will work as usual without any additional street leg from/to -the centroid. -""" - ) - .asFeedScopedIds(List.of()); + See [Limit the transit service period](#limit-transit-service-period) for an introduction. - writeCachedElevations = - root - .of("writeCachedElevations") + The date is inclusive. If set, any transit service on a day BEFORE the given date is dropped and + will not be part of the graph. Use an absolute date or a period relative to the date the graph is + build(BUILD_DAY). + + Use an empty string to make unbounded. + """ + ) + .asDateOrRelativePeriod("-P1Y", confZone); + transitServiceEnd = root + .of("transitServiceEnd") .since(V2_0) - .summary("Reusing elevation data from previous builds") + .summary("Limit the import of transit services to the given end date.") .description( """ -When set to true, the elevation module will create a file cache for calculated elevation data. -Subsequent graph builds can reuse the data in this file. - -After building the graph, a file called `cached_elevations.obj` will be written to the cache -directory. By default, this file is not written during graph builds. There is also a graph build -parameter called `readCachedElevations` which is set to `true` by default. - -In graph builds, the elevation module will attempt to read the `cached_elevations.obj` file from -the cache directory. The cache directory defaults to `/var/otp/cache`, but this can be overridden -via the CLI argument `--cache `. For the same graph build for multiple Northeast US -states, the time it took with using this pre-downloaded and precalculated data became roughly 9 -minutes. - -The cached data is a lookup table where the coordinate sequences of respective street edges are -used as keys for calculated data. It is assumed that all of the other input data except for the -OpenStreetMap data remains the same between graph builds. Therefore, if the underlying elevation -data is changed, or different configuration values for `elevationUnitMultiplier` or -`includeEllipsoidToGeoidDifference` are used, then this data becomes invalid and all elevation data -should be recalculated. Over time, various edits to OpenStreetMap will cause this cached data to -become stale and not include new OSM ways. Therefore, periodic update of this cached data is -recommended. -""" - ) - .asBoolean(false); - maxAreaNodes = - root - .of("maxAreaNodes") - .since(V2_1) - .summary( - "Visibility calculations for an area will not be done if there are more nodes than this limit." - ) - .asInt(150); - maxElevationPropagationMeters = - root - .of("maxElevationPropagationMeters") - .since(V1_5) - .summary("The maximum distance to propagate elevation to vertices which have no elevation.") - .asInt(2000); - boardingLocationTags = - root - .of("boardingLocationTags") - .since(V2_2) - .summary( - "What OSM tags should be looked on for the source of matching stops to platforms and stops." + See [Limit the transit service period](#limit-transit-service-period) for an introduction. + + The date is inclusive. If set, any transit service on a day AFTER the given date is dropped and + will not be part of the graph. Use an absolute date or a period relative to the date the graph is + build(BUILD_DAY). + + Use an empty string to make it unbounded. + """ ) - .description("[Detailed documentation](BoardingLocations.md)") - .asStringSet(List.copyOf(Set.of("ref"))); + .asDateOrRelativePeriod("P3Y", confZone); + } + + transitRouteToStationCentroid = root + .of("transitRouteToStationCentroid") + .since(V2_7) + .summary("List stations that should route to centroid.") + .description( + """ + This field contains a list of station ids for which street legs will start/end at the station + centroid instead of the child stops. + + When searching from/to a station the default behaviour is to route from/to any of the stations child + stops. This can cause strange results for stations that have stops spread over a large area. + + For some stations you might instead wish to use the centroid of the station as the + origin/destination. In this case the centroid will be used both for direct street search and for + access/egress street search where the station is used as the start/end of the access/egress. But + transit that starts/ends at the station will work as usual without any additional street leg from/to + the centroid. + """ + ) + .asFeedScopedIds(List.of()); + + writeCachedElevations = root + .of("writeCachedElevations") + .since(V2_0) + .summary("Reusing elevation data from previous builds") + .description( + """ + When set to true, the elevation module will create a file cache for calculated elevation data. + Subsequent graph builds can reuse the data in this file. + + After building the graph, a file called `cached_elevations.obj` will be written to the cache + directory. By default, this file is not written during graph builds. There is also a graph build + parameter called `readCachedElevations` which is set to `true` by default. + + In graph builds, the elevation module will attempt to read the `cached_elevations.obj` file from + the cache directory. The cache directory defaults to `/var/otp/cache`, but this can be overridden + via the CLI argument `--cache `. For the same graph build for multiple Northeast US + states, the time it took with using this pre-downloaded and precalculated data became roughly 9 + minutes. + + The cached data is a lookup table where the coordinate sequences of respective street edges are + used as keys for calculated data. It is assumed that all of the other input data except for the + OpenStreetMap data remains the same between graph builds. Therefore, if the underlying elevation + data is changed, or different configuration values for `elevationUnitMultiplier` or + `includeEllipsoidToGeoidDifference` are used, then this data becomes invalid and all elevation data + should be recalculated. Over time, various edits to OpenStreetMap will cause this cached data to + become stale and not include new OSM ways. Therefore, periodic update of this cached data is + recommended. + """ + ) + .asBoolean(false); + maxAreaNodes = root + .of("maxAreaNodes") + .since(V2_1) + .summary( + "Visibility calculations for an area will not be done if there are more nodes than this limit." + ) + .asInt(150); + maxElevationPropagationMeters = root + .of("maxElevationPropagationMeters") + .since(V1_5) + .summary("The maximum distance to propagate elevation to vertices which have no elevation.") + .asInt(2000); + boardingLocationTags = root + .of("boardingLocationTags") + .since(V2_2) + .summary( + "What OSM tags should be looked on for the source of matching stops to platforms and stops." + ) + .description("[Detailed documentation](BoardingLocations.md)") + .asStringSet(List.copyOf(Set.of("ref"))); var localFileNamePatternsConfig = root .of("localFileNamePatterns") @@ -525,118 +501,107 @@ to check in to a flight (2-3 hours for international flights) than to alight and .summary("Patterns for matching OTP file types in the base directory") .description( """ -When scanning the base directory for inputs, each file's name is checked against patterns to -detect what kind of file it is. - -OTP1 used to peek inside ZIP files and read the CSV tables to guess if a ZIP was indeed GTFS. Now -that we support remote input files (cloud storage or arbitrary URLs) not all data sources allow -seeking within files to guess what they are. Therefore, like all other file types GTFS is now -detected from a filename pattern. It is not sufficient to look for the `.zip` extension because -Netex data is also often supplied in a ZIP file. -""" + When scanning the base directory for inputs, each file's name is checked against patterns to + detect what kind of file it is. + + OTP1 used to peek inside ZIP files and read the CSV tables to guess if a ZIP was indeed GTFS. Now + that we support remote input files (cloud storage or arbitrary URLs) not all data sources allow + seeking within files to guess what they are. Therefore, like all other file types GTFS is now + detected from a filename pattern. It is not sufficient to look for the `.zip` extension because + Netex data is also often supplied in a ZIP file. + """ ) .asObject(); - gtfsLocalFilePattern = - localFileNamePatternsConfig - .of("gtfs") - .since(V2_0) - .summary("Patterns for matching GTFS zip-files or directories.") - .description( - """ - If the filename contains the given pattern it is considered a match. - Any legal Java Regular expression is allowed. - """ - ) - .asPattern(DEFAULT_GTFS_PATTERN); - netexLocalFilePattern = - localFileNamePatternsConfig - .of("netex") - .since(V2_0) - .summary("Patterns for matching NeTEx zip files or directories.") - .description( - """ - If the filename contains the given - pattern it is considered a match. Any legal Java Regular expression is allowed. - """ - ) - .asPattern(DEFAULT_NETEX_PATTERN); - osmLocalFilePattern = - localFileNamePatternsConfig - .of("osm") - .since(V2_0) - .summary("Pattern for matching Open Street Map input files.") - .description( - """ - If the filename contains the given pattern - it is considered a match. Any legal Java Regular expression is allowed. - """ - ) - .asPattern(DEFAULT_OSM_PATTERN); - demLocalFilePattern = - localFileNamePatternsConfig - .of("dem") - .since(V2_0) - .summary("Pattern for matching elevation DEM files.") - .description( - """ - If the filename contains the given pattern it is - considered a match. Any legal Java Regular expression is allowed. - """ - ) - .asPattern(DEFAULT_DEM_PATTERN); + gtfsLocalFilePattern = localFileNamePatternsConfig + .of("gtfs") + .since(V2_0) + .summary("Patterns for matching GTFS zip-files or directories.") + .description( + """ + If the filename contains the given pattern it is considered a match. + Any legal Java Regular expression is allowed. + """ + ) + .asPattern(DEFAULT_GTFS_PATTERN); + netexLocalFilePattern = localFileNamePatternsConfig + .of("netex") + .since(V2_0) + .summary("Patterns for matching NeTEx zip files or directories.") + .description( + """ + If the filename contains the given + pattern it is considered a match. Any legal Java Regular expression is allowed. + """ + ) + .asPattern(DEFAULT_NETEX_PATTERN); + osmLocalFilePattern = localFileNamePatternsConfig + .of("osm") + .since(V2_0) + .summary("Pattern for matching Open Street Map input files.") + .description( + """ + If the filename contains the given pattern + it is considered a match. Any legal Java Regular expression is allowed. + """ + ) + .asPattern(DEFAULT_OSM_PATTERN); + demLocalFilePattern = localFileNamePatternsConfig + .of("dem") + .since(V2_0) + .summary("Pattern for matching elevation DEM files.") + .description( + """ + If the filename contains the given pattern it is + considered a match. Any legal Java Regular expression is allowed. + """ + ) + .asPattern(DEFAULT_DEM_PATTERN); - gsCredentials = - root - .of("gsCredentials") - .since(V2_0) - .summary( - "Local file system path to Google Cloud Platform service accounts credentials file." - ) - .description( - """ - The credentials is used to access GCS urls. When using GCS from outside of Google Cloud you - need to provide a path the the service credentials. Environment variables in the path are - resolved. - - This is a path to a file on the local file system, not an URI. - """ - ) - .asString(null); - graph = - root - .of("graph") - .since(V2_0) - .summary("URI to the graph object file for reading and writing.") - .description("The file is created or overwritten if OTP saves the graph to the file.") - .asUri(null); - streetGraph = - root - .of("streetGraph") - .since(V2_0) - .summary("URI to the street graph object file for reading and writing.") - .description("The file is created or overwritten if OTP saves the graph to the file") - .asUri(null); - buildReportDir = - root - .of("buildReportDir") - .since(V2_0) - .summary("URI to the directory where the graph build report should be written to.") - .description( - """ - The html report is written into this directory. If the directory exist, any existing files are deleted. - If it does not exist, it is created. - """ - ) - .asUri(null); - - stopConsolidation = - root - .of("stopConsolidationFile") - .since(V2_5) - .summary( - "Name of the CSV-formatted file in the build directory which contains the configuration for stop consolidation." - ) - .asUri(null); + gsCredentials = root + .of("gsCredentials") + .since(V2_0) + .summary("Local file system path to Google Cloud Platform service accounts credentials file.") + .description( + """ + The credentials is used to access GCS urls. When using GCS from outside of Google Cloud you + need to provide a path the the service credentials. Environment variables in the path are + resolved. + + This is a path to a file on the local file system, not an URI. + """ + ) + .asString(null); + graph = root + .of("graph") + .since(V2_0) + .summary("URI to the graph object file for reading and writing.") + .description("The file is created or overwritten if OTP saves the graph to the file.") + .asUri(null); + streetGraph = root + .of("streetGraph") + .since(V2_0) + .summary("URI to the street graph object file for reading and writing.") + .description("The file is created or overwritten if OTP saves the graph to the file") + .asUri(null); + buildReportDir = root + .of("buildReportDir") + .since(V2_0) + .summary("URI to the directory where the graph build report should be written to.") + .description( + """ + The html report is written into this directory. If the directory exist, any existing files are deleted. + If it does not exist, it is created. + """ + ) + .asUri(null); + + stopConsolidation = root + .of("stopConsolidationFile") + .since(V2_5) + .summary( + "Name of the CSV-formatted file in the build directory which contains the configuration for stop consolidation." + ) + .asUri(null); osmDefaults = OsmConfig.mapOsmDefaults(root, "osmDefaults"); osm = OsmConfig.mapOsmConfig(root, "osm", osmDefaults); @@ -646,8 +611,12 @@ that we support remote input files (cloud storage or arbitrary URLs) not all dat netexDefaults = NetexConfig.mapNetexDefaultParameters(root, "netexDefaults"); gtfsDefaults = GtfsConfig.mapGtfsDefaultParameters(root, "gtfsDefaults"); - transitFeeds = - TransitFeedConfig.mapTransitFeeds(root, "transitFeeds", netexDefaults, gtfsDefaults); + transitFeeds = TransitFeedConfig.mapTransitFeeds( + root, + "transitFeeds", + netexDefaults, + gtfsDefaults + ); // List of complex parameters fareServiceFactory = FaresConfiguration.fromConfig(root, "fares"); diff --git a/application/src/main/java/org/opentripplanner/standalone/config/ConfigModel.java b/application/src/main/java/org/opentripplanner/standalone/config/ConfigModel.java index 390333f1374..11d0fdd293c 100644 --- a/application/src/main/java/org/opentripplanner/standalone/config/ConfigModel.java +++ b/application/src/main/java/org/opentripplanner/standalone/config/ConfigModel.java @@ -131,12 +131,10 @@ public static void initializeOtpFeatures(OtpConfig otpConfig) { */ public void abortOnUnknownParameters() { if ( - ( - otpConfig.hasUnknownParameters() || + (otpConfig.hasUnknownParameters() || buildConfig.hasUnknownParameters() || routerConfig.hasUnknownParameters() || - debugUiConfig.hasUnknownParameters() - ) + debugUiConfig.hasUnknownParameters()) ) { throw new OtpAppException( "Configuration contains unknown parameters (see above for details). " + diff --git a/application/src/main/java/org/opentripplanner/standalone/config/DebugUiConfig.java b/application/src/main/java/org/opentripplanner/standalone/config/DebugUiConfig.java index cca6d2359be..11db88a4ebc 100644 --- a/application/src/main/java/org/opentripplanner/standalone/config/DebugUiConfig.java +++ b/application/src/main/java/org/opentripplanner/standalone/config/DebugUiConfig.java @@ -37,45 +37,38 @@ public DebugUiConfig(JsonNode node, String source, boolean logUnusedParams) { DebugUiConfig(NodeAdapter root, boolean logUnusedParams) { this.root = root; - this.additionalBackgroundLayers = - root - .of("additionalBackgroundLayers") - .since(V2_7) - .summary("Additional background raster map layers.") - .description( - """ - Add additional background layers that will appear in the Debug UI as one of the choices. - - Currently only raster tile layers are supported. - """ - ) - .asObjects( - List.of(), - node -> - new BackgroundTileLayer( - node - .of("name") - .since(V2_7) - .summary("Name to appear in the layer selector.") - .asString(), - node - .of("templateUrl") - .since(V2_7) - .summary( - """ - The [Maplibre-compatible template URL](https://maplibre.org/maplibre-native/ios/api/tile-url-templates.html) - for the raster layer, for example `https://examples.com/tiles/{z}/{x}/{y}.png`. - """ - ) - .asString(), - node.of("tileSize").since(V2_7).summary("Size of the tile in pixels.").asInt(256), - node - .of("attribution") - .since(V2_7) - .summary("Attribution for the map data.") - .asString("© OpenTripPlanner") + this.additionalBackgroundLayers = root + .of("additionalBackgroundLayers") + .since(V2_7) + .summary("Additional background raster map layers.") + .description( + """ + Add additional background layers that will appear in the Debug UI as one of the choices. + + Currently only raster tile layers are supported. + """ + ) + .asObjects(List.of(), node -> + new BackgroundTileLayer( + node.of("name").since(V2_7).summary("Name to appear in the layer selector.").asString(), + node + .of("templateUrl") + .since(V2_7) + .summary( + """ + The [Maplibre-compatible template URL](https://maplibre.org/maplibre-native/ios/api/tile-url-templates.html) + for the raster layer, for example `https://examples.com/tiles/{z}/{x}/{y}.png`. + """ ) - ); + .asString(), + node.of("tileSize").since(V2_7).summary("Size of the tile in pixels.").asInt(256), + node + .of("attribution") + .since(V2_7) + .summary("Attribution for the map data.") + .asString("© OpenTripPlanner") + ) + ); if (logUnusedParams) { root.logAllWarnings(LOG::warn); diff --git a/application/src/main/java/org/opentripplanner/standalone/config/OtpConfig.java b/application/src/main/java/org/opentripplanner/standalone/config/OtpConfig.java index 2918cbc3884..39e8031b6e8 100644 --- a/application/src/main/java/org/opentripplanner/standalone/config/OtpConfig.java +++ b/application/src/main/java/org/opentripplanner/standalone/config/OtpConfig.java @@ -53,19 +53,17 @@ injected into the config in the (continuous) deployment pipeline. How this is do public OtpConfig(NodeAdapter nodeAdapter, boolean logUnusedParams) { this.root = nodeAdapter; - this.configVersion = - root - .of("configVersion") - .since(V2_1) - .summary("Deployment version of the *" + OtpFileNames.OTP_CONFIG_FILENAME + "*.") - .description(CONFIG_VERSION_DESCRIPTION) - .asString(null); - this.otpFeatures = - root - .of("otpFeatures") - .since(V2_0) - .summary("Turn features on/off.") - .asEnumMap(OTPFeature.class, Boolean.class); + this.configVersion = root + .of("configVersion") + .since(V2_1) + .summary("Deployment version of the *" + OtpFileNames.OTP_CONFIG_FILENAME + "*.") + .description(CONFIG_VERSION_DESCRIPTION) + .asString(null); + this.otpFeatures = root + .of("otpFeatures") + .since(V2_0) + .summary("Turn features on/off.") + .asEnumMap(OTPFeature.class, Boolean.class); if (logUnusedParams && LOG.isWarnEnabled()) { root.logAllWarnings(LOG::warn); diff --git a/application/src/main/java/org/opentripplanner/standalone/config/OtpConfigLoader.java b/application/src/main/java/org/opentripplanner/standalone/config/OtpConfigLoader.java index 9e24e56ca12..caf5734753e 100644 --- a/application/src/main/java/org/opentripplanner/standalone/config/OtpConfigLoader.java +++ b/application/src/main/java/org/opentripplanner/standalone/config/OtpConfigLoader.java @@ -121,8 +121,7 @@ private static void logConfigVersion(String configVersion, String filename) { } private JsonNode loadFromFile(String filename) { - return ConfigFileLoader - .of() + return ConfigFileLoader.of() .withConfigDir(configDir) .withJsonFallback(jsonFallback) .loadFromFile(filename); diff --git a/application/src/main/java/org/opentripplanner/standalone/config/RouterConfig.java b/application/src/main/java/org/opentripplanner/standalone/config/RouterConfig.java index cb00428284b..30c34a7fd07 100644 --- a/application/src/main/java/org/opentripplanner/standalone/config/RouterConfig.java +++ b/application/src/main/java/org/opentripplanner/standalone/config/RouterConfig.java @@ -57,13 +57,12 @@ public RouterConfig(JsonNode node, String source, boolean logUnusedParams) { /** protected to give unit-test access */ RouterConfig(NodeAdapter root, boolean logUnusedParams) { this.root = root; - this.configVersion = - root - .of("configVersion") - .since(V2_1) - .summary("Deployment version of the *" + ROUTER_CONFIG_FILENAME + "*.") - .description(OtpConfig.CONFIG_VERSION_DESCRIPTION) - .asString(null); + this.configVersion = root + .of("configVersion") + .since(V2_1) + .summary("Deployment version of the *" + ROUTER_CONFIG_FILENAME + "*.") + .description(OtpConfig.CONFIG_VERSION_DESCRIPTION) + .asString(null); this.server = new ServerConfig("server", root); this.transmodelApi = new TransmodelAPIConfig("transmodelApi", root); diff --git a/application/src/main/java/org/opentripplanner/standalone/config/buildconfig/IslandPruningConfig.java b/application/src/main/java/org/opentripplanner/standalone/config/buildconfig/IslandPruningConfig.java index 3af931b4d40..a1e0568b54c 100644 --- a/application/src/main/java/org/opentripplanner/standalone/config/buildconfig/IslandPruningConfig.java +++ b/application/src/main/java/org/opentripplanner/standalone/config/buildconfig/IslandPruningConfig.java @@ -28,56 +28,52 @@ public static IslandPruningConfig fromConfig(NodeAdapter root) { public static IslandPruningConfig fromSubConfig(NodeAdapter config) { IslandPruningConfig islandPruning = new IslandPruningConfig(); - islandPruning.pruningThresholdIslandWithStops = - config - .of("islandWithStopsMaxSize") - .since(V2_3) - .summary("When a graph island with stops in it should be pruned.") - .description( - """ + islandPruning.pruningThresholdIslandWithStops = config + .of("islandWithStopsMaxSize") + .since(V2_3) + .summary("When a graph island with stops in it should be pruned.") + .description( + """ This field indicates the pruning threshold for islands with stops. Any such island under this edge count will be pruned. """ - ) - .asInt(2); + ) + .asInt(2); - islandPruning.pruningThresholdIslandWithoutStops = - config - .of("islandWithoutStopsMaxSize") - .since(V2_3) - .summary("When a graph island without stops should be pruned.") - .description( - """ + islandPruning.pruningThresholdIslandWithoutStops = config + .of("islandWithoutStopsMaxSize") + .since(V2_3) + .summary("When a graph island without stops should be pruned.") + .description( + """ This field indicates the pruning threshold for islands without stops. Any such island under this edge count will be pruned. """ - ) - .asInt(10); + ) + .asInt(10); - islandPruning.adaptivePruningDistance = - config - .of("adaptivePruningDistance") - .since(V2_3) - .summary("Search distance for analyzing islands in pruning.") - .description( - """ + islandPruning.adaptivePruningDistance = config + .of("adaptivePruningDistance") + .since(V2_3) + .summary("Search distance for analyzing islands in pruning.") + .description( + """ The distance after which disconnected sub graph is considered as real island in pruning heuristics. """ - ) - .asInt(250); + ) + .asInt(250); - islandPruning.adaptivePruningFactor = - config - .of("adaptivePruningFactor") - .since(V2_3) - .summary("Defines how much pruning thresholds grow maximally by distance.") - .description( - """ + islandPruning.adaptivePruningFactor = config + .of("adaptivePruningFactor") + .since(V2_3) + .summary("Defines how much pruning thresholds grow maximally by distance.") + .description( + """ Expands the pruning thresholds as the distance of an island from the rest of the graph gets smaller. Even fairly large disconnected sub graphs should be removed if they are badly entangled with other graph. """ - ) - .asDouble(50); + ) + .asDouble(50); return islandPruning; } diff --git a/application/src/main/java/org/opentripplanner/standalone/config/buildconfig/NetexConfig.java b/application/src/main/java/org/opentripplanner/standalone/config/buildconfig/NetexConfig.java index 52bccf605d8..d4533f844a9 100644 --- a/application/src/main/java/org/opentripplanner/standalone/config/buildconfig/NetexConfig.java +++ b/application/src/main/java/org/opentripplanner/standalone/config/buildconfig/NetexConfig.java @@ -63,18 +63,18 @@ private static NetexFeedParameters.Builder mapFilePatternParameters( .summary("Pattern for matching shared NeTEx files in a NeTEx bundle.") .description( """ - This field is used to match *shared files*(zip file entries) in the module file. Shared - files are loaded first. Then the rest of the files are grouped and loaded. - - The pattern `"shared-data.xml"` matches `"shared-data.xml"` - - File names are matched in the following order - and treated accordingly to the first match: - - - `ignoreFilePattern` - - `sharedFilePattern` - - `sharedGroupFilePattern` - - `groupFilePattern` - """ + This field is used to match *shared files*(zip file entries) in the module file. Shared + files are loaded first. Then the rest of the files are grouped and loaded. + + The pattern `"shared-data.xml"` matches `"shared-data.xml"` + + File names are matched in the following order - and treated accordingly to the first match: + + - `ignoreFilePattern` + - `sharedFilePattern` + - `sharedGroupFilePattern` + - `groupFilePattern` + """ ) .docDefaultValue(dft.sharedFilePattern().pattern()) .asPattern(base.sharedFilePattern().pattern()) @@ -124,9 +124,9 @@ private static NetexFeedParameters.Builder mapFilePatternParameters( .summary("Pattern for matching ignored files in a NeTEx bundle.") .description( """ - This field is used to exclude matching *files* in the module file(zip file entries). - The *ignored* files are *not* loaded. - """ + This field is used to exclude matching *files* in the module file(zip file entries). + The *ignored* files are *not* loaded. + """ ) .docDefaultValue(dft.ignoreFilePattern().pattern()) .asPattern(base.ignoreFilePattern().pattern()) @@ -150,7 +150,7 @@ private static NetexFeedParameters.Builder mapFilePatternParameters( """ Bicycles are allowed on most ferries however the Nordic profile doesn't contain a place where bicycle conveyance can be defined. - + For this reason we allow bicycles on ferries by default and allow to override the rare case where this is not the case. """ diff --git a/application/src/main/java/org/opentripplanner/standalone/config/buildconfig/OsmConfig.java b/application/src/main/java/org/opentripplanner/standalone/config/buildconfig/OsmConfig.java index 5cc67844b50..fadd998b8cc 100644 --- a/application/src/main/java/org/opentripplanner/standalone/config/buildconfig/OsmConfig.java +++ b/application/src/main/java/org/opentripplanner/standalone/config/buildconfig/OsmConfig.java @@ -37,8 +37,8 @@ public static OsmExtractParametersList mapOsmConfig( .description( """ The osm section of build-config.json allows you to override the default behavior of scanning - for OpenStreetMap files in the base directory. You can specify data located outside the - local filesystem (including cloud storage services) or at various different locations around + for OpenStreetMap files in the base directory. You can specify data located outside the + local filesystem (including cloud storage services) or at various different locations around the local filesystem. """ ) diff --git a/application/src/main/java/org/opentripplanner/standalone/config/buildconfig/S3BucketConfig.java b/application/src/main/java/org/opentripplanner/standalone/config/buildconfig/S3BucketConfig.java index 6b6c89645ff..55b7e654ae8 100644 --- a/application/src/main/java/org/opentripplanner/standalone/config/buildconfig/S3BucketConfig.java +++ b/application/src/main/java/org/opentripplanner/standalone/config/buildconfig/S3BucketConfig.java @@ -27,24 +27,24 @@ public static S3BucketConfig fromConfig(NodeAdapter root, String elevationBucket .summary("Used to download NED elevation tiles from the given AWS S3 bucket.") .description( """ -In the United States, a high resolution [National Elevation Dataset](http://ned.usgs.gov/) is -available for the entire territory. It used to be possible for OTP to download NED tiles on the fly -from a rather complex USGS SOAP service. This process was somewhat unreliable and would greatly slow -down the graph building process. In any case the service has since been replaced. But the USGS would -also deliver the whole dataset in bulk if you -[sent them a hard drive](https://web.archive.org/web/20150811051917/http://ned.usgs.gov:80/faq.html#DATA). -We did this many years back and uploaded the entire data set to Amazon AWS S3. OpenTripPlanner -contains another module that can automatically fetch data in this format from any Amazon S3 copy of -the bulk data. + In the United States, a high resolution [National Elevation Dataset](http://ned.usgs.gov/) is + available for the entire territory. It used to be possible for OTP to download NED tiles on the fly + from a rather complex USGS SOAP service. This process was somewhat unreliable and would greatly slow + down the graph building process. In any case the service has since been replaced. But the USGS would + also deliver the whole dataset in bulk if you + [sent them a hard drive](https://web.archive.org/web/20150811051917/http://ned.usgs.gov:80/faq.html#DATA). + We did this many years back and uploaded the entire data set to Amazon AWS S3. OpenTripPlanner + contains another module that can automatically fetch data in this format from any Amazon S3 copy of + the bulk data. -This `ned13` bucket is still available on S3 under a "requester pays" policy. As long as you specify -valid AWS account credentials you should be able to download tiles, and any bandwidth costs will be -billed to your AWS account. + This `ned13` bucket is still available on S3 under a "requester pays" policy. As long as you specify + valid AWS account credentials you should be able to download tiles, and any bandwidth costs will be + billed to your AWS account. -Once the tiles are downloaded for a particular geographic area, OTP will keep them in local cache -for the next graph build operation. You should add the `--cache ` command line parameter -to specify your NED tile cache location. -""" + Once the tiles are downloaded for a particular geographic area, OTP will keep them in local cache + for the next graph build operation. You should add the `--cache ` command line parameter + to specify your NED tile cache location. + """ ) .asObject() ); @@ -58,26 +58,21 @@ public static S3BucketConfig fromConfig(NodeAdapter config) { } S3BucketConfig bucketConfig = new S3BucketConfig(); try { - bucketConfig.accessKey = - config - .of("accessKey") - .since(NA) - .summary("Credentials: the Amazon Web Services access key") - .asString(); - bucketConfig.secretKey = - config - .of("secretKey") - .since(NA) - .summary( - "Credentials: the Amazon Web Services secret key corresponding to the access key." - ) - .asString(); - bucketConfig.bucketName = - config - .of("bucketName") - .since(NA) - .summary("The bucket from which you want to download.") - .asString(); + bucketConfig.accessKey = config + .of("accessKey") + .since(NA) + .summary("Credentials: the Amazon Web Services access key") + .asString(); + bucketConfig.secretKey = config + .of("secretKey") + .since(NA) + .summary("Credentials: the Amazon Web Services secret key corresponding to the access key.") + .asString(); + bucketConfig.bucketName = config + .of("bucketName") + .since(NA) + .summary("The bucket from which you want to download.") + .asString(); } catch (OtpAppException ex) { LOG.error( "You must specify an accessKey, a secretKey, and a bucketName when " + diff --git a/application/src/main/java/org/opentripplanner/standalone/config/buildconfig/TransferConfig.java b/application/src/main/java/org/opentripplanner/standalone/config/buildconfig/TransferConfig.java index 5549e009c48..5103825c5ce 100644 --- a/application/src/main/java/org/opentripplanner/standalone/config/buildconfig/TransferConfig.java +++ b/application/src/main/java/org/opentripplanner/standalone/config/buildconfig/TransferConfig.java @@ -17,27 +17,27 @@ public static Map map(NodeAdapter root, String p .summary("Configures mode-specific properties for transfer calculations.") .description( """ -This field enables configuring mode-specific parameters for transfer calculations. -To configure mode-specific parameters, the modes should also be used in the `transferRequests` field in the build config. + This field enables configuring mode-specific parameters for transfer calculations. + To configure mode-specific parameters, the modes should also be used in the `transferRequests` field in the build config. -**Example** + **Example** -```JSON -// build-config.json -{ - "transferParametersForMode": { - "CAR": { - "disableDefaultTransfers": true, - "carsAllowedStopMaxTransferDuration": "3h" - }, - "BIKE": { - "maxTransferDuration": "30m", - "carsAllowedStopMaxTransferDuration": "3h" - } - } -} -``` -""" + ```JSON + // build-config.json + { + "transferParametersForMode": { + "CAR": { + "disableDefaultTransfers": true, + "carsAllowedStopMaxTransferDuration": "3h" + }, + "BIKE": { + "maxTransferDuration": "30m", + "carsAllowedStopMaxTransferDuration": "3h" + } + } + } + ``` + """ ) .asEnumMap(StreetMode.class, TransferParametersMapper::map, new EnumMap<>(StreetMode.class)); } diff --git a/application/src/main/java/org/opentripplanner/standalone/config/buildconfig/TransferParametersMapper.java b/application/src/main/java/org/opentripplanner/standalone/config/buildconfig/TransferParametersMapper.java index e9cce1a367d..ab186c5ba73 100644 --- a/application/src/main/java/org/opentripplanner/standalone/config/buildconfig/TransferParametersMapper.java +++ b/application/src/main/java/org/opentripplanner/standalone/config/buildconfig/TransferParametersMapper.java @@ -24,23 +24,23 @@ public static TransferParameters map(NodeAdapter c) { ) .description( """ -This parameter configures additional transfers to be calculated for the specified mode only between stops that have trips with cars. -The transfers are calculated for the mode in a range based on the given duration. -By default, these transfers are not calculated unless specified for a mode with this field. + This parameter configures additional transfers to be calculated for the specified mode only between stops that have trips with cars. + The transfers are calculated for the mode in a range based on the given duration. + By default, these transfers are not calculated unless specified for a mode with this field. -Calculating transfers only between stops that have trips with cars can be useful with car ferries, for example. -Using transit with cars can only occur between certain stops. -These kinds of stops require support for loading cars into ferries, for example. -The default transfers are calculated based on a configurable range (configurable by using the `maxTransferDuration` field) -which limits transfers from stops to only be calculated to other stops that are in range. -When compared to walking, using a car can cover larger distances within the same duration specified in the `maxTransferDuration` field. -This can lead to large amounts of transfers calculated between stops that do not require car transfers between them. -This in turn can lead to a large increase in memory for the stored graph, depending on the data used in the graph. + Calculating transfers only between stops that have trips with cars can be useful with car ferries, for example. + Using transit with cars can only occur between certain stops. + These kinds of stops require support for loading cars into ferries, for example. + The default transfers are calculated based on a configurable range (configurable by using the `maxTransferDuration` field) + which limits transfers from stops to only be calculated to other stops that are in range. + When compared to walking, using a car can cover larger distances within the same duration specified in the `maxTransferDuration` field. + This can lead to large amounts of transfers calculated between stops that do not require car transfers between them. + This in turn can lead to a large increase in memory for the stored graph, depending on the data used in the graph. -For cars, using this parameter in conjunction with `disableDefaultTransfers` allows calculating transfers only between relevant stops. -For bikes, using this parameter can enable transfers between ferry stops that would normally not be in range. -In Finland this is useful for bike routes that use ferries near the Turku archipelago, for example. -""" + For cars, using this parameter in conjunction with `disableDefaultTransfers` allows calculating transfers only between relevant stops. + For bikes, using this parameter can enable transfers between ferry stops that would normally not be in range. + In Finland this is useful for bike routes that use ferries near the Turku archipelago, for example. + """ ) .since(V2_7) .asDuration(TransferParameters.DEFAULT_CARS_ALLOWED_STOP_MAX_TRANSFER_DURATION) @@ -51,13 +51,13 @@ The default transfers are calculated based on a configurable range (configurable .summary("This disables default transfer calculations.") .description( """ -The default transfers are calculated based on a configurable range (configurable by using the `maxTransferDuration` field) -which limits transfers from stops to only be calculated to other stops that are in range. -This parameter disables these transfers. -A motivation to disable default transfers could be related to using the `carsAllowedStopMaxTransferDuration` field which only -calculates transfers between stops that have trips with cars. -For example, when using the `carsAllowedStopMaxTransferDuration` field with cars, the default transfers can be redundant. -""" + The default transfers are calculated based on a configurable range (configurable by using the `maxTransferDuration` field) + which limits transfers from stops to only be calculated to other stops that are in range. + This parameter disables these transfers. + A motivation to disable default transfers could be related to using the `carsAllowedStopMaxTransferDuration` field which only + calculates transfers between stops that have trips with cars. + For example, when using the `carsAllowedStopMaxTransferDuration` field with cars, the default transfers can be redundant. + """ ) .since(V2_7) .asBoolean(TransferParameters.DEFAULT_DISABLE_DEFAULT_TRANSFERS) diff --git a/application/src/main/java/org/opentripplanner/standalone/config/buildconfig/TransferRequestConfig.java b/application/src/main/java/org/opentripplanner/standalone/config/buildconfig/TransferRequestConfig.java index 3ba826bed4d..1d557166abd 100644 --- a/application/src/main/java/org/opentripplanner/standalone/config/buildconfig/TransferRequestConfig.java +++ b/application/src/main/java/org/opentripplanner/standalone/config/buildconfig/TransferRequestConfig.java @@ -16,25 +16,25 @@ public static List map(NodeAdapter root, String transferRequestsNa .summary("Routing requests to use for pre-calculating stop-to-stop transfers.") .description( """ -It will use the street network if OSM data has already been loaded into the graph. Otherwise it -will use straight-line distance between stops. + It will use the street network if OSM data has already been loaded into the graph. Otherwise it + will use straight-line distance between stops. -If not set, the default behavior is to generate stop-to-stop transfers using the default request -with street mode set to WALK. Use this to change the default or specify more than one way to -transfer. + If not set, the default behavior is to generate stop-to-stop transfers using the default request + with street mode set to WALK. Use this to change the default or specify more than one way to + transfer. -**Example** + **Example** -```JSON -// build-config.json -{ - "transferRequests": [ - { "modes": "WALK" }, - { "modes": "WALK", "wheelchairAccessibility": { "enabled": true }} - ] -} -``` -""" + ```JSON + // build-config.json + { + "transferRequests": [ + { "modes": "WALK" }, + { "modes": "WALK", "wheelchairAccessibility": { "enabled": true }} + ] + } + ``` + """ ) .asObjects(List.of(new RouteRequest()), RouteRequestConfig::mapRouteRequest); } diff --git a/application/src/main/java/org/opentripplanner/standalone/config/buildconfig/TransitFeedConfig.java b/application/src/main/java/org/opentripplanner/standalone/config/buildconfig/TransitFeedConfig.java index 7ddf9b8b156..e6e2b4a4f9a 100644 --- a/application/src/main/java/org/opentripplanner/standalone/config/buildconfig/TransitFeedConfig.java +++ b/application/src/main/java/org/opentripplanner/standalone/config/buildconfig/TransitFeedConfig.java @@ -26,7 +26,7 @@ public static TransitFeeds mapTransitFeeds( of scanning for transit data files in the [base directory](Configuration.md#Base-Directory). You can specify data located outside the local filesystem (including cloud storage services) or at various different locations around the local filesystem. - + When a feed of a particular type (`netex` or `gtfs`) is specified in the transitFeeds section, auto-scanning in the base directory for this feed type will be disabled. """ diff --git a/application/src/main/java/org/opentripplanner/standalone/config/framework/json/ConfigType.java b/application/src/main/java/org/opentripplanner/standalone/config/framework/json/ConfigType.java index 3796fcac645..cb293f02a61 100644 --- a/application/src/main/java/org/opentripplanner/standalone/config/framework/json/ConfigType.java +++ b/application/src/main/java/org/opentripplanner/standalone/config/framework/json/ConfigType.java @@ -74,41 +74,41 @@ public enum ConfigType { COST_LINEAR_FUNCTION( JsonType.string, """ - A cost-linear-function used to calculate a cost from another cost or time/duration. - - Given a function of time: - ``` - f(t) = a + b * t - ``` - then `a` is the constant time part, `b` is the time-coefficient, and `t` is the variable. - If `a=0s` and `b=0.0`, then the cost is always `0`(zero). - - Examples: `0s + 2.5t`, `10m + 0t` and `1h5m59s + 9.9t` - - The `constant` must be 0 or a positive number or duration. The unit is seconds unless - specified using the duration format. A duration is automatically converted to a cost. - The `coefficient` must be in range: [0.0, 100.0] - """ + A cost-linear-function used to calculate a cost from another cost or time/duration. + + Given a function of time: + ``` + f(t) = a + b * t + ``` + then `a` is the constant time part, `b` is the time-coefficient, and `t` is the variable. + If `a=0s` and `b=0.0`, then the cost is always `0`(zero). + + Examples: `0s + 2.5t`, `10m + 0t` and `1h5m59s + 9.9t` + + The `constant` must be 0 or a positive number or duration. The unit is seconds unless + specified using the duration format. A duration is automatically converted to a cost. + The `coefficient` must be in range: [0.0, 100.0] + """ ), TIME_PENALTY( JsonType.string, """ - A time-penalty is used to add a penalty to the duration/arrival-time/departure-time for - a path. It will be invisible to the end user, but used during the routing when comparing - stop-arrival/paths. - - Given a function of time: - ``` - f(t) = a + b * t - ``` - then `a` is the constant time part, `b` is the time-coefficient, and `t` is the variable. - If `a=0s` and `b=0.0`, then the cost is always `0`(zero). - - Examples: `0s + 2.5t`, `10m + 0 x` and `1h5m59s + 9.9t` - - The `constant` must be 0 or a positive number(seconds) or a duration. - The `coefficient` must be in range: [0.0, 100.0] - """ + A time-penalty is used to add a penalty to the duration/arrival-time/departure-time for + a path. It will be invisible to the end user, but used during the routing when comparing + stop-arrival/paths. + + Given a function of time: + ``` + f(t) = a + b * t + ``` + then `a` is the constant time part, `b` is the time-coefficient, and `t` is the variable. + If `a=0s` and `b=0.0`, then the cost is always `0`(zero). + + Examples: `0s + 2.5t`, `10m + 0 x` and `1h5m59s + 9.9t` + + The `constant` must be 0 or a positive number(seconds) or a duration. + The `coefficient` must be in range: [0.0, 100.0] + """ ), MAP( JsonType.object, @@ -141,8 +141,7 @@ public String description() { } public String examplesToMarkdown() { - return Arrays - .stream(examples) + return Arrays.stream(examples) .map(StringUtils::quoteReplace) .map(this::quote) .map(MarkdownFormatter::code) diff --git a/application/src/main/java/org/opentripplanner/standalone/config/framework/json/EnumMapper.java b/application/src/main/java/org/opentripplanner/standalone/config/framework/json/EnumMapper.java index c39c2ef7377..1b5a348d69b 100644 --- a/application/src/main/java/org/opentripplanner/standalone/config/framework/json/EnumMapper.java +++ b/application/src/main/java/org/opentripplanner/standalone/config/framework/json/EnumMapper.java @@ -28,8 +28,7 @@ public static Optional> mapToEnum2(String text, Class it.name().toUpperCase().equals(name)) .findFirst(); } diff --git a/application/src/main/java/org/opentripplanner/standalone/config/framework/json/NodeInfo.java b/application/src/main/java/org/opentripplanner/standalone/config/framework/json/NodeInfo.java index b9db7fb75c8..38b3c64a7c7 100644 --- a/application/src/main/java/org/opentripplanner/standalone/config/framework/json/NodeInfo.java +++ b/application/src/main/java/org/opentripplanner/standalone/config/framework/json/NodeInfo.java @@ -157,8 +157,7 @@ public int hashCode() { @Override public String toString() { - var builder = ValueObjectToStringBuilder - .of() + var builder = ValueObjectToStringBuilder.of() .addText(name) .addText(" : ") .addText(typeDescription()); diff --git a/application/src/main/java/org/opentripplanner/standalone/config/framework/json/ParameterBuilder.java b/application/src/main/java/org/opentripplanner/standalone/config/framework/json/ParameterBuilder.java index 784d381a2e6..f8f3f453e21 100644 --- a/application/src/main/java/org/opentripplanner/standalone/config/framework/json/ParameterBuilder.java +++ b/application/src/main/java/org/opentripplanner/standalone/config/framework/json/ParameterBuilder.java @@ -227,15 +227,15 @@ public > T asEnum(T defaultValue) { if (node.isMissingNode()) { return defaultValue; } - return parseOptionalEnum(node.asText(), (Class) defaultValue.getClass()) - .orElse(defaultValue); + return parseOptionalEnum(node.asText(), (Class) defaultValue.getClass()).orElse( + defaultValue + ); } public > Set asEnumSet(Class enumClass) { info.withOptional().withEnumSet(enumClass); - List> optionalList = buildAndListSimpleArrayElements( - List.of(), - it -> parseOptionalEnum(it.asText(), enumClass) + List> optionalList = buildAndListSimpleArrayElements(List.of(), it -> + parseOptionalEnum(it.asText(), enumClass) ); List result = optionalList.stream().filter(Optional::isPresent).map(Optional::get).toList(); // Set is immutable @@ -247,9 +247,8 @@ public > Set asEnumSet(Class enumClass, Collection de ? (List) defaultValues : List.copyOf(defaultValues); info.withOptional(dft.toString()).withEnumSet(enumClass); - List> optionalList = buildAndListSimpleArrayElements( - List.of(), - it -> parseOptionalEnum(it.asText(), enumClass) + List> optionalList = buildAndListSimpleArrayElements(List.of(), it -> + parseOptionalEnum(it.asText(), enumClass) ); List result = optionalList.stream().filter(Optional::isPresent).map(Optional::get).toList(); // Set is immutable @@ -642,16 +641,14 @@ private T parseConfigType(ConfigType elementType, JsonNode child) { } private > E parseRequiredEnum(String value, Class ofType) { - return EnumMapper - .mapToEnum(value, ofType) - .orElseThrow(() -> { - throw error( - "The parameter value '%s' is not legal. Expected one of %s.".formatted( - value, - List.of(ofType.getEnumConstants()) - ) - ); - }); + return EnumMapper.mapToEnum(value, ofType).orElseThrow(() -> { + throw error( + "The parameter value '%s' is not legal. Expected one of %s.".formatted( + value, + List.of(ofType.getEnumConstants()) + ) + ); + }); } private > Optional parseOptionalEnum(String value, Class ofType) { diff --git a/application/src/main/java/org/opentripplanner/standalone/config/framework/project/EnvironmentVariableReplacer.java b/application/src/main/java/org/opentripplanner/standalone/config/framework/project/EnvironmentVariableReplacer.java index c71c1237d3f..be0ba132dc1 100644 --- a/application/src/main/java/org/opentripplanner/standalone/config/framework/project/EnvironmentVariableReplacer.java +++ b/application/src/main/java/org/opentripplanner/standalone/config/framework/project/EnvironmentVariableReplacer.java @@ -76,10 +76,8 @@ public static String insertVariables( String source, Function variableResolver ) { - return TextVariablesSubstitution.insertVariables( - text, - variableResolver, - varName -> errorVariableNameNotFound(varName, source) + return TextVariablesSubstitution.insertVariables(text, variableResolver, varName -> + errorVariableNameNotFound(varName, source) ); } diff --git a/application/src/main/java/org/opentripplanner/standalone/config/routerconfig/ServerConfig.java b/application/src/main/java/org/opentripplanner/standalone/config/routerconfig/ServerConfig.java index 64921eb813b..1cb4bd33e14 100644 --- a/application/src/main/java/org/opentripplanner/standalone/config/routerconfig/ServerConfig.java +++ b/application/src/main/java/org/opentripplanner/standalone/config/routerconfig/ServerConfig.java @@ -25,92 +25,87 @@ public ServerConfig(String parameterName, NodeAdapter root) { .summary("Configuration for router server.") .description( """ -These parameters are used to configure the router server. Many parameters are specific to a -domain, these are set in the routing request. -""" + These parameters are used to configure the router server. Many parameters are specific to a + domain, these are set in the routing request. + """ ) .asObject(); - this.apiProcessingTimeout = - c - .of("apiProcessingTimeout") - .since(V2_4) - .summary("Maximum processing time for an API request") - .description( - """ -This timeout limits the server-side processing time for a given API request. This does not include -network latency nor waiting time in the HTTP server thread pool. The default value is -`-1s`(no timeout). The timeout is applied to all APIs (REST, Transmodel & GTFS GraphQL). -The timeout is not enforced when the parallel routing OTP feature is in use. -""" - ) - .asDuration(Duration.ofSeconds(-1)); + this.apiProcessingTimeout = c + .of("apiProcessingTimeout") + .since(V2_4) + .summary("Maximum processing time for an API request") + .description( + """ + This timeout limits the server-side processing time for a given API request. This does not include + network latency nor waiting time in the HTTP server thread pool. The default value is + `-1s`(no timeout). The timeout is applied to all APIs (REST, Transmodel & GTFS GraphQL). + The timeout is not enforced when the parallel routing OTP feature is in use. + """ + ) + .asDuration(Duration.ofSeconds(-1)); - this.apiDocumentationProfile = - c - .of("apiDocumentationProfile") - .since(V2_7) - .summary(ApiDocumentationProfile.DEFAULT.typeDescription()) - .description(docEnumValueList(ApiDocumentationProfile.values())) - .asEnum(ApiDocumentationProfile.DEFAULT); + this.apiDocumentationProfile = c + .of("apiDocumentationProfile") + .since(V2_7) + .summary(ApiDocumentationProfile.DEFAULT.typeDescription()) + .description(docEnumValueList(ApiDocumentationProfile.values())) + .asEnum(ApiDocumentationProfile.DEFAULT); - this.traceParameters = - c - .of("traceParameters") - .since(V2_4) - .summary( - "Trace OTP request using HTTP request/response parameter(s) combined with logging." - ) - .description( - """ -OTP supports tracing user requests across log events and "outside" services. OTP can insert -http-request-header parameters into all associated log events and into the http response. If the -value is not present in the request, a unique value can be generated. The OTP generated value is -a 6 characters long base 36[0-9a-z] character string. + this.traceParameters = c + .of("traceParameters") + .since(V2_4) + .summary("Trace OTP request using HTTP request/response parameter(s) combined with logging.") + .description( + """ + OTP supports tracing user requests across log events and "outside" services. OTP can insert + http-request-header parameters into all associated log events and into the http response. If the + value is not present in the request, a unique value can be generated. The OTP generated value is + a 6 characters long base 36[0-9a-z] character string. -**Use-case Correlation-ID** + **Use-case Correlation-ID** -A common use-case in a service oriented environment is to use a _correlation-id_ to identify all log -messages across multiple (micro-)services from the same user. This is done by setting the -"X-Correlation-ID" http header in the http facade/gateway. Use the "traceParameters" to configure -OTP to pick up the correlation id, insert it into the logs and return it. See the example below -on how-to configure the "server.traceParameters" instance. -""" + A common use-case in a service oriented environment is to use a _correlation-id_ to identify all log + messages across multiple (micro-)services from the same user. This is done by setting the + "X-Correlation-ID" http header in the http facade/gateway. Use the "traceParameters" to configure + OTP to pick up the correlation id, insert it into the logs and return it. See the example below + on how-to configure the "server.traceParameters" instance. + """ + ) + .asObjects(t -> + new RequestTraceParameter( + t + .of("httpRequestHeader") + .since(V2_4) + .summary("The header-key to use when fetching the trace parameter value") + .asString(null), + t + .of("httpResponseHeader") + .since(V2_4) + .summary("The header-key to use when saving the value back into the http response") + .asString(null), + t + .of("logKey") + .since(V2_4) + .summary("The log event key used.") + .description( + """ + OTP stores the key/value pair in the log MDC(Mapped Diagnostic Context). To use it you normally + include the key in the log pattern like this: `%X{LOG-KEY}`. See your log framework for details. + Only log4j and logback support this. + """ + ) + .asString(null), + t + .of("generateIdIfMissing") + .since(V2_4) + .summary( + "If `true` a unique value is generated if no http request header is provided, or " + + "the value is missing." + ) + .asBoolean(false) ) - .asObjects(t -> - new RequestTraceParameter( - t - .of("httpRequestHeader") - .since(V2_4) - .summary("The header-key to use when fetching the trace parameter value") - .asString(null), - t - .of("httpResponseHeader") - .since(V2_4) - .summary("The header-key to use when saving the value back into the http response") - .asString(null), - t - .of("logKey") - .since(V2_4) - .summary("The log event key used.") - .description( - """ -OTP stores the key/value pair in the log MDC(Mapped Diagnostic Context). To use it you normally -include the key in the log pattern like this: `%X{LOG-KEY}`. See your log framework for details. -Only log4j and logback support this. -""" - ) - .asString(null), - t - .of("generateIdIfMissing") - .since(V2_4) - .summary( - "If `true` a unique value is generated if no http request header is provided, or " + - "the value is missing." - ) - .asBoolean(false) - ) - ); + ); } public Duration apiProcessingTimeout() { diff --git a/application/src/main/java/org/opentripplanner/standalone/config/routerconfig/TransitRoutingConfig.java b/application/src/main/java/org/opentripplanner/standalone/config/routerconfig/TransitRoutingConfig.java index e6602a188f4..7e69825d7ec 100644 --- a/application/src/main/java/org/opentripplanner/standalone/config/routerconfig/TransitRoutingConfig.java +++ b/application/src/main/java/org/opentripplanner/standalone/config/routerconfig/TransitRoutingConfig.java @@ -46,185 +46,173 @@ public TransitRoutingConfig( .summary("Configuration for transit searches with RAPTOR.") .description( """ -Some of these parameters for tuning transit routing are only available through configuration and -cannot be set in the routing request. These parameters work together with the default routing -request and the actual routing request. - """ + Some of these parameters for tuning transit routing are only available through configuration and + cannot be set in the routing request. These parameters work together with the default routing + request and the actual routing request. + """ ) .asObject(); RaptorTuningParameters dft = new RaptorTuningParameters() {}; - this.maxNumberOfTransfers = - c - .of("maxNumberOfTransfers") - .since(NA) - .summary("This parameter is used to allocate enough memory space for Raptor.") - .description( - """ -Set it to the maximum number of transfers for any given itinerary expected to be found within the -entire transit network. The memory overhead of setting this higher than the maximum number of -transfers is very little so it is better to set it too high than to low. -""" - ) - .asInt(dft.maxNumberOfTransfers()); - this.scheduledTripBinarySearchThreshold = - c - .of("scheduledTripBinarySearchThreshold") - .since(NA) - .summary( - "This threshold is used to determine when to perform a binary trip schedule search." - ) - .description( - """ -This reduce the number of trips departure time lookups and comparisons. When testing with data from -Entur and all of Norway as a Graph, the optimal value was about 50. If you calculate the departure -time every time or want to fine tune the performance, changing this may improve the performance a -few percents. -""" - ) - .asInt(dft.scheduledTripBinarySearchThreshold()); - this.iterationDepartureStepInSeconds = - c - .of("iterationDepartureStepInSeconds") - .since(NA) - .summary("Step for departure times between each RangeRaptor iterations.") - .description( - """ -This is a performance optimization parameter. A transit network usually uses minute resolution for -the timetables, so to match that, set this variable to 60 seconds. Setting it to less than 60 will -not give better result, but degrade performance. Setting it to 120 seconds will improve performance, -but you might get a slack of 60 seconds somewhere in the result. -""" - ) - .asInt(dft.iterationDepartureStepInSeconds()); - this.searchThreadPoolSize = - c - .of("searchThreadPoolSize") - .since(NA) - .summary( - "Split a travel search in smaller jobs and run them in parallel to improve performance." - ) - .description( - """ -Use this parameter to set the total number of executable threads available across all searches. -Multiple searches can run in parallel - this parameter has no effect with regard to that. If 0, -no extra threads are started and the search is done in one thread. -""" - ) - .asInt(0); + this.maxNumberOfTransfers = c + .of("maxNumberOfTransfers") + .since(NA) + .summary("This parameter is used to allocate enough memory space for Raptor.") + .description( + """ + Set it to the maximum number of transfers for any given itinerary expected to be found within the + entire transit network. The memory overhead of setting this higher than the maximum number of + transfers is very little so it is better to set it too high than to low. + """ + ) + .asInt(dft.maxNumberOfTransfers()); + this.scheduledTripBinarySearchThreshold = c + .of("scheduledTripBinarySearchThreshold") + .since(NA) + .summary("This threshold is used to determine when to perform a binary trip schedule search.") + .description( + """ + This reduce the number of trips departure time lookups and comparisons. When testing with data from + Entur and all of Norway as a Graph, the optimal value was about 50. If you calculate the departure + time every time or want to fine tune the performance, changing this may improve the performance a + few percents. + """ + ) + .asInt(dft.scheduledTripBinarySearchThreshold()); + this.iterationDepartureStepInSeconds = c + .of("iterationDepartureStepInSeconds") + .since(NA) + .summary("Step for departure times between each RangeRaptor iterations.") + .description( + """ + This is a performance optimization parameter. A transit network usually uses minute resolution for + the timetables, so to match that, set this variable to 60 seconds. Setting it to less than 60 will + not give better result, but degrade performance. Setting it to 120 seconds will improve performance, + but you might get a slack of 60 seconds somewhere in the result. + """ + ) + .asInt(dft.iterationDepartureStepInSeconds()); + this.searchThreadPoolSize = c + .of("searchThreadPoolSize") + .since(NA) + .summary( + "Split a travel search in smaller jobs and run them in parallel to improve performance." + ) + .description( + """ + Use this parameter to set the total number of executable threads available across all searches. + Multiple searches can run in parallel - this parameter has no effect with regard to that. If 0, + no extra threads are started and the search is done in one thread. + """ + ) + .asInt(0); // Dynamic Search Window - this.stopBoardAlightDuringTransferCost = - c - .of("stopBoardAlightDuringTransferCost") - .since(V2_0) - .summary( - "Costs for boarding and alighting during transfers at stops with a given transfer priority." - ) - .description( - """ -This cost is applied **both to boarding and alighting** at stops during transfers. All stops have a -transfer cost priority set, the default is `allowed`. The `stopBoardAlightDuringTransferCost` -parameter is optional, but if listed all values must be set. - -When a transfer occurs at the same stop, the cost will be applied twice since the cost is both for -boarding and alighting, - -If not set the `stopBoardAlightDuringTransferCost` is ignored. This is only available for NeTEx -imported Stops. - -The cost is a scalar, but is equivalent to the felt cost of riding a transit trip for 1 second. - -| Config key | Description | Type | -|---------------|-----------------------------------------------------------------------------------------------|:----:| -| `discouraged` | Use a very high cost like `72 000` to eliminate transfers at the stop if not the only option. | int | -| `allowed` | Allowed, but not recommended. Use something like `150`. | int | -| `recommended` | Use a small cost penalty like `60`. | int | -| `preferred` | The best place to do transfers. Should be set to `0`(zero). | int | - -Use values in a range from `0` to `100 000`. **All key/value pairs are required if the -`stopBoardAlightDuringTransferCost` is listed.** -""" - ) - .asEnumMapAllKeysRequired(StopTransferPriority.class, Integer.class); - this.transferCacheMaxSize = - c - .of("transferCacheMaxSize") - .since(NA) - .summary( - "The maximum number of distinct transfers parameters to cache pre-calculated transfers for." - ) - .description( - " If too low, requests may be slower. If too high, more memory may be used then required." - ) - .asInt(25); + this.stopBoardAlightDuringTransferCost = c + .of("stopBoardAlightDuringTransferCost") + .since(V2_0) + .summary( + "Costs for boarding and alighting during transfers at stops with a given transfer priority." + ) + .description( + """ + This cost is applied **both to boarding and alighting** at stops during transfers. All stops have a + transfer cost priority set, the default is `allowed`. The `stopBoardAlightDuringTransferCost` + parameter is optional, but if listed all values must be set. - this.transferCacheRequests = - c - .of("transferCacheRequests") - .since(V2_3) - .summary("Routing requests to use for pre-filling the stop-to-stop transfer cache.") - .description( - """ -If not set, the default behavior is to cache stop-to-stop transfers using the default route request -(`routingDefaults`). Use this to change the default or specify more than one `RouteRequest`. - -**Example** - -```JSON -// router-config.json -{ - "transit": { - "transferCacheRequests": [ - { "modes": "WALK" }, - { "modes": "WALK", "wheelchairAccessibility": { "enabled": true } } - ] - } -} -``` -""" - ) - .docDefaultValue("`routingDefaults`") - .asObjects( - List.of(routingRequestDefaults), - n -> RouteRequestConfig.mapRouteRequest(n, routingRequestDefaults) - ); - this.pagingSearchWindowAdjustments = - c - .of("pagingSearchWindowAdjustments") - .since(NA) - .summary( - "The provided array of durations is used to increase the search-window for the " + - "next/previous page." - ) - .description( - """ -The search window is expanded when the current page return few options. If ZERO result is returned -the first duration in the list is used, if ONE result is returned then the second duration is used -and so on. The duration is added to the existing search-window and inserted into the next and -previous page cursor. See JavaDoc for [TransitTuningParameters#pagingSearchWindowAdjustments](https://github.com/opentripplanner/OpenTripPlanner/blob/dev-2.x/src/main/java/org/opentripplanner/routing/algorithm/raptor/transit/TransitTuningParameters.java)" + -for more info." -""" - ) - .asDurations(PAGING_SEARCH_WINDOW_ADJUSTMENTS); + When a transfer occurs at the same stop, the cost will be applied twice since the cost is both for + boarding and alighting, - this.maxSearchWindow = - c - .of("maxSearchWindow") - .since(V2_4) - .summary("Upper limit of the request parameter searchWindow.") - .description( - """ - Maximum search window that can be set through the searchWindow API parameter. - Due to the way timetable data are collected before a Raptor trip search, - using a search window larger than 24 hours may lead to inconsistent search results. - Limiting the search window prevents also potential performance issues. - The recommended maximum value is 24 hours. - This parameter does not restrict the maximum duration of a dynamic search window (use - the parameter `transit.dynamicSearchWindow.maxWindow` to specify such a restriction). - """ - ) - .asDuration(Duration.ofHours(24)); + If not set the `stopBoardAlightDuringTransferCost` is ignored. This is only available for NeTEx + imported Stops. + + The cost is a scalar, but is equivalent to the felt cost of riding a transit trip for 1 second. + + | Config key | Description | Type | + |---------------|-----------------------------------------------------------------------------------------------|:----:| + | `discouraged` | Use a very high cost like `72 000` to eliminate transfers at the stop if not the only option. | int | + | `allowed` | Allowed, but not recommended. Use something like `150`. | int | + | `recommended` | Use a small cost penalty like `60`. | int | + | `preferred` | The best place to do transfers. Should be set to `0`(zero). | int | + + Use values in a range from `0` to `100 000`. **All key/value pairs are required if the + `stopBoardAlightDuringTransferCost` is listed.** + """ + ) + .asEnumMapAllKeysRequired(StopTransferPriority.class, Integer.class); + this.transferCacheMaxSize = c + .of("transferCacheMaxSize") + .since(NA) + .summary( + "The maximum number of distinct transfers parameters to cache pre-calculated transfers for." + ) + .description( + " If too low, requests may be slower. If too high, more memory may be used then required." + ) + .asInt(25); + + this.transferCacheRequests = c + .of("transferCacheRequests") + .since(V2_3) + .summary("Routing requests to use for pre-filling the stop-to-stop transfer cache.") + .description( + """ + If not set, the default behavior is to cache stop-to-stop transfers using the default route request + (`routingDefaults`). Use this to change the default or specify more than one `RouteRequest`. + + **Example** + + ```JSON + // router-config.json + { + "transit": { + "transferCacheRequests": [ + { "modes": "WALK" }, + { "modes": "WALK", "wheelchairAccessibility": { "enabled": true } } + ] + } + } + ``` + """ + ) + .docDefaultValue("`routingDefaults`") + .asObjects(List.of(routingRequestDefaults), n -> + RouteRequestConfig.mapRouteRequest(n, routingRequestDefaults) + ); + this.pagingSearchWindowAdjustments = c + .of("pagingSearchWindowAdjustments") + .since(NA) + .summary( + "The provided array of durations is used to increase the search-window for the " + + "next/previous page." + ) + .description( + """ + The search window is expanded when the current page return few options. If ZERO result is returned + the first duration in the list is used, if ONE result is returned then the second duration is used + and so on. The duration is added to the existing search-window and inserted into the next and + previous page cursor. See JavaDoc for [TransitTuningParameters#pagingSearchWindowAdjustments](https://github.com/opentripplanner/OpenTripPlanner/blob/dev-2.x/src/main/java/org/opentripplanner/routing/algorithm/raptor/transit/TransitTuningParameters.java)" + + for more info." + """ + ) + .asDurations(PAGING_SEARCH_WINDOW_ADJUSTMENTS); + + this.maxSearchWindow = c + .of("maxSearchWindow") + .since(V2_4) + .summary("Upper limit of the request parameter searchWindow.") + .description( + """ + Maximum search window that can be set through the searchWindow API parameter. + Due to the way timetable data are collected before a Raptor trip search, + using a search window larger than 24 hours may lead to inconsistent search results. + Limiting the search window prevents also potential performance issues. + The recommended maximum value is 24 hours. + This parameter does not restrict the maximum duration of a dynamic search window (use + the parameter `transit.dynamicSearchWindow.maxWindow` to specify such a restriction). + """ + ) + .asDuration(Duration.ofHours(24)); this.dynamicSearchWindowCoefficients = new DynamicSearchWindowConfig("dynamicSearchWindow", c); } @@ -298,99 +286,94 @@ public DynamicSearchWindowConfig(String parameterName, NodeAdapter root) { .summary("The dynamic search window coefficients used to calculate the EDT, LAT and SW.") .description( """ -The dynamic search window coefficients is used to calculate EDT(*earliest-departure-time*), -LAT(*latest-arrival-time*) and SW(*raptor-search-window*) request parameters using heuristics. The -heuristics perform a Raptor search (one-iteration) to find a trip which we use to find a lower -bound for the travel duration time - the "minTransitTime". The heuristic search is used for other -purposes too, and is very fast. + The dynamic search window coefficients is used to calculate EDT(*earliest-departure-time*), + LAT(*latest-arrival-time*) and SW(*raptor-search-window*) request parameters using heuristics. The + heuristics perform a Raptor search (one-iteration) to find a trip which we use to find a lower + bound for the travel duration time - the "minTransitTime". The heuristic search is used for other + purposes too, and is very fast. -At least the EDT or the LAT must be passed into Raptor to perform a Range Raptor search. If -unknown/missing the parameters(EDT, LAT, DW) are dynamically calculated. The dynamic coefficients -affect the performance and should be tuned to match the deployment. + At least the EDT or the LAT must be passed into Raptor to perform a Range Raptor search. If + unknown/missing the parameters(EDT, LAT, DW) are dynamically calculated. The dynamic coefficients + affect the performance and should be tuned to match the deployment. -The request parameters are calculated like this: + The request parameters are calculated like this: -``` - DW = round_N(C + T * minTransitTime + W * minWaitTime) - LAT = EDT + DW + minTransitTime - EDT = LAT - (DW + minTransitTime) -``` + ``` + DW = round_N(C + T * minTransitTime + W * minWaitTime) + LAT = EDT + DW + minTransitTime + EDT = LAT - (DW + minTransitTime) + ``` -The `round_N(...)` method rounds the input to the closest multiplication of N. + The `round_N(...)` method rounds the input to the closest multiplication of N. -The 3 coefficients above are: + The 3 coefficients above are: - - `C` is parameter: `minWindow` - - `T` is parameter: `minTransitTimeCoefficient` - - `W` is parameter: `minWaitTimeCoefficient` - - `N` is parameter: `stepMinutes` + - `C` is parameter: `minWindow` + - `T` is parameter: `minTransitTimeCoefficient` + - `W` is parameter: `minWaitTimeCoefficient` + - `N` is parameter: `stepMinutes` -In addition there is an upper bound on the calculation of the search window: -`maxWindow`. -""" + In addition there is an upper bound on the calculation of the search window: + `maxWindow`. + """ ) .asObject(); DynamicSearchWindowCoefficients dsWinDft = new DynamicSearchWindowCoefficients() {}; - this.minTransitTimeCoefficient = - dsWin - .of("minTransitTimeCoefficient") - .since(V2_1) - .summary("The coefficient to multiply with `minTransitTime`.") - .description( - "Use a value between `0.0` and `3.0`. Using `0.0` will eliminate the `minTransitTime` " + - "from the dynamic raptor-search-window calculation." - ) - .asDouble(dsWinDft.minTransitTimeCoefficient()); - this.minWaitTimeCoefficient = - dsWin - .of("minWaitTimeCoefficient") - .since(V2_1) - .summary("The coefficient to multiply with `minWaitTime`.") - .description( - "Use a value between `0.0` and `1.0`. Using `0.0` will eliminate the `minWaitTime` " + - "from the dynamic raptor-search-window calculation." - ) - .asDouble(dsWinDft.minWaitTimeCoefficient()); - this.minWindow = - dsWin - .of("minWindow") - .since(V2_2) - .summary("The constant minimum duration for a raptor-search-window. ") - .description("Use a value between 20 and 180 minutes in a normal deployment.") - .asDuration(dsWinDft.minWindow()); - this.maxWindow = - dsWin - .of("maxWindow") - .since(V2_2) - .summary("Upper limit for the search-window calculation.") - .description( - """ -Long search windows consume a lot of resources and may take a long time. Use this parameter to -tune the desired maximum search time. - -This is the parameter that affects the response time most, the downside is that a search is only -guaranteed to be pareto-optimal within a search-window. -""" - ) - .asDuration(dsWinDft.maxWindow()); - this.stepMinutes = - dsWin - .of("stepMinutes") - .since(V2_1) - .summary("Used to set the steps the search-window is rounded to.") - .description( - """ -The search window is rounded off to the closest multiplication of `stepMinutes`. If `stepMinutes` = -10 minutes, the search-window can be 10, 20, 30 ... minutes. It the computed search-window is 5 -minutes and 17 seconds it will be rounded up to 10 minutes. - - -Use a value between `1` and `60`. This should be less than the `min-raptor-search-window` -coefficient. -""" - ) - .asInt(dsWinDft.stepMinutes()); + this.minTransitTimeCoefficient = dsWin + .of("minTransitTimeCoefficient") + .since(V2_1) + .summary("The coefficient to multiply with `minTransitTime`.") + .description( + "Use a value between `0.0` and `3.0`. Using `0.0` will eliminate the `minTransitTime` " + + "from the dynamic raptor-search-window calculation." + ) + .asDouble(dsWinDft.minTransitTimeCoefficient()); + this.minWaitTimeCoefficient = dsWin + .of("minWaitTimeCoefficient") + .since(V2_1) + .summary("The coefficient to multiply with `minWaitTime`.") + .description( + "Use a value between `0.0` and `1.0`. Using `0.0` will eliminate the `minWaitTime` " + + "from the dynamic raptor-search-window calculation." + ) + .asDouble(dsWinDft.minWaitTimeCoefficient()); + this.minWindow = dsWin + .of("minWindow") + .since(V2_2) + .summary("The constant minimum duration for a raptor-search-window. ") + .description("Use a value between 20 and 180 minutes in a normal deployment.") + .asDuration(dsWinDft.minWindow()); + this.maxWindow = dsWin + .of("maxWindow") + .since(V2_2) + .summary("Upper limit for the search-window calculation.") + .description( + """ + Long search windows consume a lot of resources and may take a long time. Use this parameter to + tune the desired maximum search time. + + This is the parameter that affects the response time most, the downside is that a search is only + guaranteed to be pareto-optimal within a search-window. + """ + ) + .asDuration(dsWinDft.maxWindow()); + this.stepMinutes = dsWin + .of("stepMinutes") + .since(V2_1) + .summary("Used to set the steps the search-window is rounded to.") + .description( + """ + The search window is rounded off to the closest multiplication of `stepMinutes`. If `stepMinutes` = + 10 minutes, the search-window can be 10, 20, 30 ... minutes. It the computed search-window is 5 + minutes and 17 seconds it will be rounded up to 10 minutes. + + + Use a value between `1` and `60`. This should be less than the `min-raptor-search-window` + coefficient. + """ + ) + .asInt(dsWinDft.stepMinutes()); } @Override diff --git a/application/src/main/java/org/opentripplanner/standalone/config/routerconfig/UpdatersConfig.java b/application/src/main/java/org/opentripplanner/standalone/config/routerconfig/UpdatersConfig.java index e59aec50ae5..bc53db8b35a 100644 --- a/application/src/main/java/org/opentripplanner/standalone/config/routerconfig/UpdatersConfig.java +++ b/application/src/main/java/org/opentripplanner/standalone/config/routerconfig/UpdatersConfig.java @@ -77,14 +77,13 @@ public UpdatersConfig(NodeAdapter rootAdapter) { rootAdapter ); - timetableUpdates = - timetableUpdates( - rootAdapter - .of("timetableUpdates") - .since(V2_2) - .summary("Global configuration for timetable updaters.") - .asObject() - ); + timetableUpdates = timetableUpdates( + rootAdapter + .of("timetableUpdates") + .since(V2_2) + .summary("Global configuration for timetable updaters.") + .asObject() + ); rootAdapter .of("updaters") diff --git a/application/src/main/java/org/opentripplanner/standalone/config/routerconfig/VectorTileConfig.java b/application/src/main/java/org/opentripplanner/standalone/config/routerconfig/VectorTileConfig.java index 26d56dc0dba..8e126575442 100644 --- a/application/src/main/java/org/opentripplanner/standalone/config/routerconfig/VectorTileConfig.java +++ b/application/src/main/java/org/opentripplanner/standalone/config/routerconfig/VectorTileConfig.java @@ -67,16 +67,16 @@ public static VectorTileConfig mapVectorTilesParameters(NodeAdapter node, String .description( """ This is useful if you have a proxy setup and rewrite the path that is passed to OTP. - - If you don't configure this optional value then the path returned in `tilejson.json` is in - the format `/otp/routers/default/vectorTiles/layer1,layer2/{z}/{x}/{x}.pbf`. - If you, for example, set a value of `/otp_test/tiles` then the returned path changes to + + If you don't configure this optional value then the path returned in `tilejson.json` is in + the format `/otp/routers/default/vectorTiles/layer1,layer2/{z}/{x}/{x}.pbf`. + If you, for example, set a value of `/otp_test/tiles` then the returned path changes to `/otp_test/tiles/layer1,layer2/{z}/{x}/{x}.pbf`. - - The protocol and host are always read from the incoming HTTP request. If you run OTP behind + + The protocol and host are always read from the incoming HTTP request. If you run OTP behind a proxy then make sure to set the headers `X-Forwarded-Proto` and `X-Forwarded-Host` to make OTP return the protocol and host for the original request and not the proxied one. - + **Note:** This does _not_ change the path that OTP itself serves the tiles or `tilejson.json` responses but simply changes the URLs listed in `tilejson.json`. The rewriting of the path is expected to be handled by a proxy. @@ -89,11 +89,11 @@ public static VectorTileConfig mapVectorTilesParameters(NodeAdapter node, String .summary("Custom attribution to be returned in `tilejson.json`") .description( """ - By default the, `attribution` property in `tilejson.json` is computed from the names and + By default the, `attribution` property in `tilejson.json` is computed from the names and URLs of the feed publishers. - If the OTP deployment contains many feeds, this can become very unwieldy. - - This configuration parameter allows you to set the `attribution` to any string you wish + If the OTP deployment contains many feeds, this can become very unwieldy. + + This configuration parameter allows you to set the `attribution` to any string you wish including HTML tags, for example `Regional Partners`. """ diff --git a/application/src/main/java/org/opentripplanner/standalone/config/routerconfig/updaters/MqttGtfsRealtimeUpdaterConfig.java b/application/src/main/java/org/opentripplanner/standalone/config/routerconfig/updaters/MqttGtfsRealtimeUpdaterConfig.java index f846a8a6597..381761a962d 100644 --- a/application/src/main/java/org/opentripplanner/standalone/config/routerconfig/updaters/MqttGtfsRealtimeUpdaterConfig.java +++ b/application/src/main/java/org/opentripplanner/standalone/config/routerconfig/updaters/MqttGtfsRealtimeUpdaterConfig.java @@ -27,19 +27,19 @@ public static MqttGtfsRealtimeUpdaterParameters create(String configRef, NodeAda .summary("How backwards propagation should be handled.") .description( """ - REQUIRED_NO_DATA: - Default value. Only propagates delays backwards when it is required to ensure that the times - are increasing, and it sets the NO_DATA flag on the stops so these automatically updated times - are not exposed through APIs. - - REQUIRED: - Only propagates delays backwards when it is required to ensure that the times are increasing. - The updated times are exposed through APIs. - - ALWAYS: - Propagates delays backwards on stops with no estimates regardless if it's required or not. - The updated times are exposed through APIs. -""" + REQUIRED_NO_DATA: + Default value. Only propagates delays backwards when it is required to ensure that the times + are increasing, and it sets the NO_DATA flag on the stops so these automatically updated times + are not exposed through APIs. + + REQUIRED: + Only propagates delays backwards when it is required to ensure that the times are increasing. + The updated times are exposed through APIs. + + ALWAYS: + Propagates delays backwards on stops with no estimates regardless if it's required or not. + The updated times are exposed through APIs. + """ ) .asEnum(BackwardsDelayPropagationType.REQUIRED_NO_DATA) ); diff --git a/application/src/main/java/org/opentripplanner/standalone/config/routerconfig/updaters/PollingTripUpdaterConfig.java b/application/src/main/java/org/opentripplanner/standalone/config/routerconfig/updaters/PollingTripUpdaterConfig.java index 467bbb47159..cacfe8cd6c3 100644 --- a/application/src/main/java/org/opentripplanner/standalone/config/routerconfig/updaters/PollingTripUpdaterConfig.java +++ b/application/src/main/java/org/opentripplanner/standalone/config/routerconfig/updaters/PollingTripUpdaterConfig.java @@ -41,19 +41,19 @@ public static PollingTripUpdaterParameters create(String configRef, NodeAdapter .summary("How backwards propagation should be handled.") .description( """ - REQUIRED_NO_DATA: - Default value. Only propagates delays backwards when it is required to ensure that the times - are increasing, and it sets the NO_DATA flag on the stops so these automatically updated times - are not exposed through APIs. - - REQUIRED: - Only propagates delays backwards when it is required to ensure that the times are increasing. - The updated times are exposed through APIs. - - ALWAYS - Propagates delays backwards on stops with no estimates regardless if it's required or not. - The updated times are exposed through APIs. -""" + REQUIRED_NO_DATA: + Default value. Only propagates delays backwards when it is required to ensure that the times + are increasing, and it sets the NO_DATA flag on the stops so these automatically updated times + are not exposed through APIs. + + REQUIRED: + Only propagates delays backwards when it is required to ensure that the times are increasing. + The updated times are exposed through APIs. + + ALWAYS + Propagates delays backwards on stops with no estimates regardless if it's required or not. + The updated times are exposed through APIs. + """ ) .asEnum(BackwardsDelayPropagationType.REQUIRED_NO_DATA), c.of("feedId").since(V1_5).summary("Which feed the updates apply to.").asString(), diff --git a/application/src/main/java/org/opentripplanner/standalone/config/routerconfig/updaters/SiriETGooglePubsubUpdaterConfig.java b/application/src/main/java/org/opentripplanner/standalone/config/routerconfig/updaters/SiriETGooglePubsubUpdaterConfig.java index 5659dd7cbd3..e695ed12ad9 100644 --- a/application/src/main/java/org/opentripplanner/standalone/config/routerconfig/updaters/SiriETGooglePubsubUpdaterConfig.java +++ b/application/src/main/java/org/opentripplanner/standalone/config/routerconfig/updaters/SiriETGooglePubsubUpdaterConfig.java @@ -24,11 +24,11 @@ public static SiriETGooglePubsubUpdaterParameters create(String configRef, NodeA .summary("The Google Cloud project that hosts the PubSub subscription.") .description( """ - During startup, the updater creates a PubSub subscription that listens - to the PubSub topic that publishes SIRI-ET updates. - This parameter specifies in which Google Cloud project the subscription will be created. - The topic and the subscription can be hosted in two different projects. - """ + During startup, the updater creates a PubSub subscription that listens + to the PubSub topic that publishes SIRI-ET updates. + This parameter specifies in which Google Cloud project the subscription will be created. + The topic and the subscription can be hosted in two different projects. + """ ) .asString(), c @@ -59,9 +59,9 @@ If this parameter is set, the updater will be marked as initialized (primed) onl .summary("Wait this amount of time before trying to reconnect to the PubSub subscription.") .description( """ - In case of a network error, the updater will try periodically to reconnect to the - Google PubSub subscription. - """ + In case of a network error, the updater will try periodically to reconnect to the + Google PubSub subscription. + """ ) .asDuration(RECONNECT_PERIOD), c diff --git a/application/src/main/java/org/opentripplanner/standalone/config/routerconfig/updaters/SiriSXUpdaterConfig.java b/application/src/main/java/org/opentripplanner/standalone/config/routerconfig/updaters/SiriSXUpdaterConfig.java index b23d3a301f9..27a713ac186 100644 --- a/application/src/main/java/org/opentripplanner/standalone/config/routerconfig/updaters/SiriSXUpdaterConfig.java +++ b/application/src/main/java/org/opentripplanner/standalone/config/routerconfig/updaters/SiriSXUpdaterConfig.java @@ -14,9 +14,9 @@ public class SiriSXUpdaterConfig { Use the file protocol to set a directory for reading updates from a directory. The file loader will look for xml files: '*.xml' in the configured directory. The files are renamed by the loader when processed: - +     _a.xml_   ➞   _a.xml.inProgress_   ➞   _a.xml.ok_   or   _a.xml.failed_ - + """; public static SiriSXUpdaterParameters create(String configRef, NodeAdapter c) { diff --git a/application/src/main/java/org/opentripplanner/standalone/config/routerconfig/updaters/VehicleParkingUpdaterConfig.java b/application/src/main/java/org/opentripplanner/standalone/config/routerconfig/updaters/VehicleParkingUpdaterConfig.java index e07f5a81216..ef14682ae09 100644 --- a/application/src/main/java/org/opentripplanner/standalone/config/routerconfig/updaters/VehicleParkingUpdaterConfig.java +++ b/application/src/main/java/org/opentripplanner/standalone/config/routerconfig/updaters/VehicleParkingUpdaterConfig.java @@ -97,12 +97,12 @@ public static VehicleParkingUpdaterParameters create(String updaterRef, NodeAdap .summary("URL of the SIRI-FM Light endpoint.") .description( """ - SIRI Light means that it must be available as a HTTP GET request rather than the usual - SIRI request mechanism of HTTP POST. - - The contents must also conform to the [Italian SIRI profile](https://github.com/5Tsrl/siri-italian-profile) - which requires SIRI 2.1. - """ + SIRI Light means that it must be available as a HTTP GET request rather than the usual + SIRI request mechanism of HTTP POST. + + The contents must also conform to the [Italian SIRI profile](https://github.com/5Tsrl/siri-italian-profile) + which requires SIRI 2.1. + """ ) .asUri(), feedId, diff --git a/application/src/main/java/org/opentripplanner/standalone/config/routerconfig/updaters/sources/VehicleRentalSourceFactory.java b/application/src/main/java/org/opentripplanner/standalone/config/routerconfig/updaters/sources/VehicleRentalSourceFactory.java index e58b5e96ae8..5c1c76a80e5 100644 --- a/application/src/main/java/org/opentripplanner/standalone/config/routerconfig/updaters/sources/VehicleRentalSourceFactory.java +++ b/application/src/main/java/org/opentripplanner/standalone/config/routerconfig/updaters/sources/VehicleRentalSourceFactory.java @@ -91,15 +91,15 @@ private boolean allowKeepingRentedVehicleAtDestination() { .summary("If a vehicle should be allowed to be kept at the end of a station-based rental.") .description( """ - In some cases it may be useful to not drop off the rented vehicle before arriving at the destination. - This is useful if vehicles may only be rented for round trips, or the destination is an intermediate place. - - For this to be possible three things need to be configured: - - - In the updater configuration `allowKeepingRentedVehicleAtDestination` should be set to `true`. - - `allowKeepingRentedVehicleAtDestination` should also be set for each request, either using routing defaults, or per-request. - - If keeping the vehicle at the destination should be discouraged, then `keepingRentedVehicleAtDestinationCost` (default: 0) may also be set in the routing defaults. - """ + In some cases it may be useful to not drop off the rented vehicle before arriving at the destination. + This is useful if vehicles may only be rented for round trips, or the destination is an intermediate place. + + For this to be possible three things need to be configured: + + - In the updater configuration `allowKeepingRentedVehicleAtDestination` should be set to `true`. + - `allowKeepingRentedVehicleAtDestination` should also be set for each request, either using routing defaults, or per-request. + - If keeping the vehicle at the destination should be discouraged, then `keepingRentedVehicleAtDestinationCost` (default: 0) may also be set in the routing defaults. + """ ) .asBoolean(false); } @@ -120,7 +120,7 @@ private boolean geofencingZones() { .description( """ This feature is somewhat experimental and therefore turned off by default for the following reasons: - + - It delays start up of OTP. How long is dependent on the complexity of the zones. For example in Oslo it takes 6 seconds to compute while Portland takes 25 seconds. - It's easy for a malformed or unintended geofencing zone to make routing impossible. If you encounter such a case, please file a bug report. """ diff --git a/application/src/main/java/org/opentripplanner/standalone/config/routerequest/ItineraryFiltersConfig.java b/application/src/main/java/org/opentripplanner/standalone/config/routerequest/ItineraryFiltersConfig.java index c021de88a8e..3aa5cb4e690 100644 --- a/application/src/main/java/org/opentripplanner/standalone/config/routerequest/ItineraryFiltersConfig.java +++ b/application/src/main/java/org/opentripplanner/standalone/config/routerequest/ItineraryFiltersConfig.java @@ -28,36 +28,36 @@ public static void mapItineraryFilterParams( ) .description( """ -The purpose of the itinerary filter chain is to post process the result returned by the routing -search. The filters may modify itineraries, sort them, and filter away less preferable results. - -OTP2 may produce numerous _pareto-optimal_ results when using `time`, `number-of-transfers` and -`generalized-cost` as criteria. Use the parameters listed here to reduce/filter the itineraries -return by the search engine before returning the results to client. There is also a few mandatory -non-configurable filters removing none optimal results. You may see these filters pop-up in the -filter debugging. + The purpose of the itinerary filter chain is to post process the result returned by the routing + search. The filters may modify itineraries, sort them, and filter away less preferable results. -#### Group by similarity filters + OTP2 may produce numerous _pareto-optimal_ results when using `time`, `number-of-transfers` and + `generalized-cost` as criteria. Use the parameters listed here to reduce/filter the itineraries + return by the search engine before returning the results to client. There is also a few mandatory + non-configurable filters removing none optimal results. You may see these filters pop-up in the + filter debugging. -The group-by-filter is a bit complex, but should be simple to use. Set `debug=true` and experiment -with `searchWindow` and the three group-by parameters(`groupSimilarityKeepOne`, -`groupSimilarityKeepThree` and `groupedOtherThanSameLegsMaxCostMultiplier`). + #### Group by similarity filters -The group-by-filter work by grouping itineraries together and then reducing the number of -itineraries in each group, keeping the itinerary/itineraries with the best itinerary -_generalized-cost_. The group-by function first pick all transit legs that account for more than N% -of the itinerary based on distance traveled. This become the group-key. Two keys are the same if all -legs in one of the keys also exist in the other. Note, one key may have a larger set of legs than the -other, but they can still be the same. When comparing two legs we compare the `tripId` and make sure -the legs overlap in place and time. Two legs are the same if both legs ride at least a common -subsection of the same trip. The `keepOne` filter will keep ONE itinerary in each group. The -`keepThree` keeps 3 itineraries for each group. + The group-by-filter is a bit complex, but should be simple to use. Set `debug=true` and experiment + with `searchWindow` and the three group-by parameters(`groupSimilarityKeepOne`, + `groupSimilarityKeepThree` and `groupedOtherThanSameLegsMaxCostMultiplier`). -The grouped itineraries can be further reduced by using `groupedOtherThanSameLegsMaxCostMultiplier`. -This parameter filters out itineraries, where the legs that are not common for all the grouped -itineraries have a much higher cost, than the lowest in the group. By default, it filters out -itineraries that are at least double in cost for the non-grouped legs. -""" + The group-by-filter work by grouping itineraries together and then reducing the number of + itineraries in each group, keeping the itinerary/itineraries with the best itinerary + _generalized-cost_. The group-by function first pick all transit legs that account for more than N% + of the itinerary based on distance traveled. This become the group-key. Two keys are the same if all + legs in one of the keys also exist in the other. Note, one key may have a larger set of legs than the + other, but they can still be the same. When comparing two legs we compare the `tripId` and make sure + the legs overlap in place and time. Two legs are the same if both legs ride at least a common + subsection of the same trip. The `keepOne` filter will keep ONE itinerary in each group. The + `keepThree` keeps 3 itineraries for each group. + + The grouped itineraries can be further reduced by using `groupedOtherThanSameLegsMaxCostMultiplier`. + This parameter filters out itineraries, where the legs that are not common for all the grouped + itineraries have a much higher cost, than the lowest in the group. By default, it filters out + itineraries that are at least double in cost for the non-grouped legs. + """ ) .asObject(); @@ -102,10 +102,10 @@ public static void mapItineraryFilterParams( ) .description( """ -Of the itineraries grouped to maximum of three itineraries, how much worse can the non-grouped legs -be compared to the lowest cost. 2.0 means that they can be double the cost, and any itineraries -having a higher cost will be filtered. -""" + Of the itineraries grouped to maximum of three itineraries, how much worse can the non-grouped legs + be compared to the lowest cost. 2.0 means that they can be double the cost, and any itineraries + having a higher cost will be filtered. + """ ) .asDouble(dft.groupedOtherThanSameLegsMaxCostMultiplier()) ) @@ -117,13 +117,13 @@ public static void mapItineraryFilterParams( .summary("A relative limit for the generalized-cost for transit itineraries.") .description( """ -The filter compares all itineraries against every other itinerary. If the generalized-cost plus a -`transitGeneralizedCostLimit` is higher than the other generalized-cost, then the itinerary is -dropped. The `transitGeneralizedCostLimit` is calculated using the `costLimitFunction` plus a -*relative cost* for the distance in time between the itineraries. The *relative cost* is the -`intervalRelaxFactor` multiplied with the interval in seconds. To set the `costLimitFunction` to be -_1 hour plus 2 times cost_ use: `3600 + 2.0 x`. To set an absolute value(3000s) use: `3000 + 0x` -""" + The filter compares all itineraries against every other itinerary. If the generalized-cost plus a + `transitGeneralizedCostLimit` is higher than the other generalized-cost, then the itinerary is + dropped. The `transitGeneralizedCostLimit` is calculated using the `costLimitFunction` plus a + *relative cost* for the distance in time between the itineraries. The *relative cost* is the + `intervalRelaxFactor` multiplied with the interval in seconds. To set the `costLimitFunction` to be + _1 hour plus 2 times cost_ use: `3600 + 2.0 x`. To set an absolute value(3000s) use: `3000 + 0x` + """ ) .asObject(), dft.transitGeneralizedCostLimit() @@ -138,16 +138,16 @@ public static void mapItineraryFilterParams( ) .description( """ -The max-limit is applied to itineraries with *no transit legs*, however *all* itineraries -(including those with transit legs) are considered when calculating the minimum cost. The smallest -generalized-cost value is used as input to the function. The function is used to calculate a -*max-limit*. The max-limit is then used to filter *non-transit* itineraries by -*generalized-cost*. Itineraries with a cost higher than the max-limit are dropped from the result -set. + The max-limit is applied to itineraries with *no transit legs*, however *all* itineraries + (including those with transit legs) are considered when calculating the minimum cost. The smallest + generalized-cost value is used as input to the function. The function is used to calculate a + *max-limit*. The max-limit is then used to filter *non-transit* itineraries by + *generalized-cost*. Itineraries with a cost higher than the max-limit are dropped from the result + set. -For example if the function is `f(x) = 30m + 2.0 x` and the smallest cost is `30m = 1800s`, then -all non-transit itineraries with a cost larger than `1800 + 2 * 5000 = 11 800` are dropped. -""" + For example if the function is `f(x) = 30m + 2.0 x` and the smallest cost is `30m = 1800s`, then + all non-transit itineraries with a cost larger than `1800 + 2 * 5000 = 11 800` are dropped. + """ ) .asCostLinearFunction(dft.nonTransitGeneralizedCostLimit()) ) @@ -160,14 +160,14 @@ public static void mapItineraryFilterParams( ) .description( """ -The max-limit is applied to itineraries with transit *legs*, and only itineraries -without transit legs are considered when calculating the minimum cost. The smallest -generalized-cost value is used as input to the function. The function is used to calculate a -*max-limit*. The max-limit is then used to filter *transit* itineraries by -*generalized-cost*. Itineraries with a cost higher than the max-limit are dropped from the result -set. Walking is handled with a different logic: if a transit itinerary has higher cost than -a plain walk itinerary, it will be removed even if the cost limit function would keep it. -""" + The max-limit is applied to itineraries with transit *legs*, and only itineraries + without transit legs are considered when calculating the minimum cost. The smallest + generalized-cost value is used as input to the function. The function is used to calculate a + *max-limit*. The max-limit is then used to filter *transit* itineraries by + *generalized-cost*. Itineraries with a cost higher than the max-limit are dropped from the result + set. Walking is handled with a different logic: if a transit itinerary has higher cost than + a plain walk itinerary, it will be removed even if the cost limit function would keep it. + """ ) .asCostLinearFunction(dft.removeTransitWithHigherCostThanBestOnStreetOnly()) ) @@ -181,10 +181,10 @@ public static void mapItineraryFilterParams( ) .description( """ -This filters out results that consist of a long walk plus a relatively short bike rental leg. A -value of `0.3` means that a minimum of 30% of the total distance must be spent on the bike in order -for the result to be included. -""" + This filters out results that consist of a long walk plus a relatively short bike rental leg. A + value of `0.3` means that a minimum of 30% of the total distance must be spent on the bike in order + for the result to be included. + """ ) .asDouble(dft.bikeRentalDistanceRatio()) ) @@ -198,10 +198,10 @@ public static void mapItineraryFilterParams( ) .description( """ -This filters out results that consist of driving plus a very long walk leg at the end. A value of -`0.3` means that a minimum of 30% of the total time must be spent in the car in order for the -result to be included. However, if there is only a single result, it is never filtered. - """ + This filters out results that consist of driving plus a very long walk leg at the end. A value of + `0.3` means that a minimum of 30% of the total time must be spent in the car in order for the + result to be included. However, if there is only a single result, it is never filtered. + """ ) .asDouble(dft.parkAndRideDurationRatio()) ) @@ -215,11 +215,11 @@ public static void mapItineraryFilterParams( ) .description( """ -Trips are considered equal if they have same id and same service day. Non-transit legs are skipped -during comparison. Before filtering, trips are sorted by their generalized cost. The algorithm loops -through the list from top to bottom. If an itinerary matches from any other itinerary from above, it is -removed from list. - """ + Trips are considered equal if they have same id and same service day. Non-transit legs are skipped + during comparison. Before filtering, trips are sorted by their generalized cost. The algorithm loops + through the list from top to bottom. If an itinerary matches from any other itinerary from above, it is + removed from list. + """ ) .asBoolean(dft.filterItinerariesWithSameFirstOrLastTrip()) ) @@ -268,17 +268,17 @@ public static void mapItineraryFilterParams( .since(V2_7) .summary( """ - Filter direct flex results by the search window. The search-window is not used + Filter direct flex results by the search window. The search-window is not used during flex routing, but we use one end to align it with transit results.""" ) .description( """ - When direct flex is mixed with a transit search in the same request, then the direct + When direct flex is mixed with a transit search in the same request, then the direct flex results are filtered by the search window of the transit results. - - Depart-at searches are filtered by latest-arrival-time and arrive-by searches are + + Depart-at searches are filtered by latest-arrival-time and arrive-by searches are filtered by earliest-departure-time. - + Use this configuration to turn this feature off. """ ) diff --git a/application/src/main/java/org/opentripplanner/standalone/config/routerequest/RouteRequestConfig.java b/application/src/main/java/org/opentripplanner/standalone/config/routerequest/RouteRequestConfig.java index edea5c6b408..6878d1b25d3 100644 --- a/application/src/main/java/org/opentripplanner/standalone/config/routerequest/RouteRequestConfig.java +++ b/application/src/main/java/org/opentripplanner/standalone/config/routerequest/RouteRequestConfig.java @@ -86,10 +86,8 @@ public static RouteRequest mapRouteRequest(NodeAdapter c, RouteRequest dft) { .summary( "The set of access/egress/direct/transfer modes (separated by a comma) to be used for the route search." ) - .asCustomStringType( - RequestModes.defaultRequestModes(), - "WALK", - s -> new QualifiedModeSet(s).getRequestModes() + .asCustomStringType(RequestModes.defaultRequestModes(), "WALK", s -> + new QualifiedModeSet(s).getRequestModes() ) ); @@ -107,25 +105,25 @@ public static RouteRequest mapRouteRequest(NodeAdapter c, RouteRequest dft) { .summary("The duration of the search-window.") .description( """ - This is the time/duration in seconds from the earliest-departure-time(EDT) to the - latest-departure-time(LDT). In case of a reverse search it will be the time from earliest to - latest arrival time (LAT - EAT). + This is the time/duration in seconds from the earliest-departure-time(EDT) to the + latest-departure-time(LDT). In case of a reverse search it will be the time from earliest to + latest arrival time (LAT - EAT). - All optimal travels that depart within the search window is guaranteed to be found. + All optimal travels that depart within the search window is guaranteed to be found. - This is sometimes referred to as the Range Raptor Search Window - but could be used in a none - Transit search as well; Hence this is named search-window and not raptor-search-window. + This is sometimes referred to as the Range Raptor Search Window - but could be used in a none + Transit search as well; Hence this is named search-window and not raptor-search-window. - This is normally dynamically calculated by the server. Use `null` to unset, and *zero* to do one - Raptor iteration. The value is dynamically assigned a suitable value, if not set. In a small to - medium size operation you may use a fixed value, like 60 minutes. If you have a mixture of high - frequency cities routes and infrequent long distant journeys, the best option is normally to use - the dynamic auto assignment. If not provided the value is resolved depending on the other input - parameters, available transit options and realtime changes. + This is normally dynamically calculated by the server. Use `null` to unset, and *zero* to do one + Raptor iteration. The value is dynamically assigned a suitable value, if not set. In a small to + medium size operation you may use a fixed value, like 60 minutes. If you have a mixture of high + frequency cities routes and infrequent long distant journeys, the best option is normally to use + the dynamic auto assignment. If not provided the value is resolved depending on the other input + parameters, available transit options and realtime changes. - There is no need to set this when going to the next/previous page. The OTP Server will - increase/decrease the search-window when paging to match the requested number of itineraries. - """ + There is no need to set this when going to the next/previous page. The OTP Server will + increase/decrease the search-window when paging to match the requested number of itineraries. + """ ) .asDuration(dft.searchWindow()) ); @@ -140,13 +138,13 @@ latest arrival time (LAT - EAT). ) .description( """ -A cost is applied to boarding nonpreferred authorities or routes. + A cost is applied to boarding nonpreferred authorities or routes. -The routing engine will add extra penalty - on the *unpreferred* routes and/or agencies using a -cost function. The cost function (`unpreferredCost`) is defined as a linear function of the form -`A + B x`, where `A` is a fixed cost (in seconds) and `B` is reluctance multiplier for transit leg -travel time `x` (in seconds). -""" + The routing engine will add extra penalty - on the *unpreferred* routes and/or agencies using a + cost function. The cost function (`unpreferredCost`) is defined as a linear function of the form + `A + B x`, where `A` is a fixed cost (in seconds) and `B` is reluctance multiplier for transit leg + travel time `x` (in seconds). + """ ) .asObject(); request @@ -210,13 +208,13 @@ private static void mapTransitPreferences(NodeAdapter c, TransitPreferences.Buil .summary("The time safety margin when alighting from a vehicle.") .description( """ -This time slack is added to arrival time of the vehicle before any transfer or onward travel. + This time slack is added to arrival time of the vehicle before any transfer or onward travel. -This time slack helps model potential delays or procedures a passenger experiences during the process of passing through the alighting location. This -parameter is intended to be set by agencies not individual users. For specific modes, like airplane and -subway, that need more time than others, this is also configurable per mode with `alightSlackForMode`. -A related parameter (transferSlack) exists to help avoid missed connections when there are minor schedule variations. -""" + This time slack helps model potential delays or procedures a passenger experiences during the process of passing through the alighting location. This + parameter is intended to be set by agencies not individual users. For specific modes, like airplane and + subway, that need more time than others, this is also configurable per mode with `alightSlackForMode`. + A related parameter (transferSlack) exists to help avoid missed connections when there are minor schedule variations. + """ ) .asDuration(dft.alightSlack().defaultValue()) ) @@ -243,23 +241,23 @@ A related parameter (transferSlack) exists to help avoid missed connections when .summary("The time safety margin when boarding a vehicle.") .description( """ -The board slack is added to the passenger's arrival time at a stop, before evaluating which -vehicles can be boarded. + The board slack is added to the passenger's arrival time at a stop, before evaluating which + vehicles can be boarded. -This time slack helps model potential delays or procedures a passenger experiences during the process -of passing through the boarding location, as well as some minor schedule variation. This parameter is -intended to be set by agencies not individual users. + This time slack helps model potential delays or procedures a passenger experiences during the process + of passing through the boarding location, as well as some minor schedule variation. This parameter is + intended to be set by agencies not individual users. -Agencies can use this parameter to ensure that the trip planner does not instruct passengers to arrive -at the last second. This slack is added at every boarding including the first vehicle and transfers -except for in-seat transfers and guaranteed transfers. + Agencies can use this parameter to ensure that the trip planner does not instruct passengers to arrive + at the last second. This slack is added at every boarding including the first vehicle and transfers + except for in-seat transfers and guaranteed transfers. -For specific modes, like airplane and subway, that need more time than others, this is also -configurable per mode with `boardSlackForMode`. + For specific modes, like airplane and subway, that need more time than others, this is also + configurable per mode with `boardSlackForMode`. -A related parameter (transferSlack) also helps avoid missed connections when there are minor schedule -variations. -""" + A related parameter (transferSlack) also helps avoid missed connections when there are minor schedule + variations. + """ ) .asDuration(dft.boardSlack().defaultValue()) ) @@ -272,9 +270,9 @@ A related parameter (transferSlack) also helps avoid missed connections when the ) .description( """ -Sometimes there is a need to configure a board times for specific modes, such as airplanes or -ferries, where the check-in process needs to be done in good time before ride. -""" + Sometimes there is a need to configure a board times for specific modes, such as airplanes or + ferries, where the check-in process needs to be done in good time before ride. + """ ) .asEnumMap(TransitMode.class, Duration.class) ) @@ -344,15 +342,15 @@ A related parameter (transferSlack) also helps avoid missed connections when the .summary("Whether non-optimal transit paths at the destination should be returned") .description( """ - Let c be the existing minimum pareto optimal generalized cost to beat. Then a trip - with cost c' is accepted if the following is true: - `c' < Math.round(c * relaxRaptorCostCriteria)`. + Let c be the existing minimum pareto optimal generalized cost to beat. Then a trip + with cost c' is accepted if the following is true: + `c' < Math.round(c * relaxRaptorCostCriteria)`. - The parameter is optional. If not set a normal comparison is performed. + The parameter is optional. If not set a normal comparison is performed. - Values equals or less than zero is not allowed. Values greater than 2.0 are not - supported, due to performance reasons. - """ + Values equals or less than zero is not allowed. Values greater than 2.0 are not + supported, due to performance reasons. + """ ) .asDoubleOptional() .ifPresent(it::withRelaxGeneralizedCostAtDestination) @@ -475,32 +473,30 @@ private static void mapStreetPreferences(NodeAdapter c, StreetPreferences.Builde .summary("Penalty for access/egress by street mode.") .description( """ - Use this to add a time and cost penalty to an access/egress legs for a given street - mode. This will favour other street-modes and transit. This has a performance penalty, - since the search-window is increased with the same amount as the maximum penalty for - the access legs used. In other cases where the access(CAR) is faster than transit the - performance will be better. + Use this to add a time and cost penalty to an access/egress legs for a given street + mode. This will favour other street-modes and transit. This has a performance penalty, + since the search-window is increased with the same amount as the maximum penalty for + the access legs used. In other cases where the access(CAR) is faster than transit the + performance will be better. + + The default values are - The default values are - - %s + %s - Example: `"car-to-park" : { "timePenalty": "10m + 1.5t", "costFactor": 2.5 }` + Example: `"car-to-park" : { "timePenalty": "10m + 1.5t", "costFactor": 2.5 }` - **Time penalty** + **Time penalty** - The `timePenalty` is used to add a penalty to the access/egress duration/time. The - time including the penalty is used in the algorithm when comparing paths, but the - actual duration is used when presented to the end user. + The `timePenalty` is used to add a penalty to the access/egress duration/time. The + time including the penalty is used in the algorithm when comparing paths, but the + actual duration is used when presented to the end user. - **Cost factor** + **Cost factor** - The `costFactor` is used to add an additional cost to the leg´s generalized-cost. The - time-penalty is multiplied with the cost-factor. A cost-factor of zero, gives no - extra cost, while 1.0 will add the same amount to both time and cost. - """.formatted( - formatPenaltyDefaultValues(dftAccessEgress) - ) + The `costFactor` is used to add an additional cost to the leg´s generalized-cost. The + time-penalty is multiplied with the cost-factor. A cost-factor of zero, gives no + extra cost, while 1.0 will add the same amount to both time and cost. + """.formatted(formatPenaltyDefaultValues(dftAccessEgress)) ) .asEnumMap( StreetMode.class, @@ -515,12 +511,12 @@ the access legs used. In other cases where the access(CAR) is faster than transi .summary("This is the maximum duration for access/egress for street searches.") .description( """ -This is a performance limit and should therefore be set high. Results close to the limit are not -guaranteed to be optimal. Use itinerary-filters to limit what is presented to the client. The -duration can be set per mode(`maxDurationForMode`), because some street modes searches -are much more resource intensive than others. A default value is applied if the mode specific value -does not exist. -""" + This is a performance limit and should therefore be set high. Results close to the limit are not + guaranteed to be optimal. Use itinerary-filters to limit what is presented to the client. The + duration can be set per mode(`maxDurationForMode`), because some street modes searches + are much more resource intensive than others. A default value is applied if the mode specific value + does not exist. + """ ) .asDuration(dftAccessEgress.maxDuration().defaultValue()), cae @@ -529,9 +525,9 @@ duration can be set per mode(`maxDurationForMode`), because some street modes se .summary("Limit access/egress per street mode.") .description( """ - Override the settings in `maxDuration` for specific street modes. This is - done because some street modes searches are much more resource intensive than others. - """ + Override the settings in `maxDuration` for specific street modes. This is + done because some street modes searches are much more resource intensive than others. + """ ) .asEnumMap(StreetMode.class, Duration.class) ) @@ -542,8 +538,8 @@ duration can be set per mode(`maxDurationForMode`), because some street modes se .summary("Maximal number of stops collected in access/egress routing") .description( """ - Safety limit to prevent access to and egress from too many stops. - """ + Safety limit to prevent access to and egress from too many stops. + """ ) .asInt(dftAccessEgress.maxStopCountLimit().defaultLimit()), cae @@ -554,9 +550,9 @@ duration can be set per mode(`maxDurationForMode`), because some street modes se ) .description( """ - Safety limit to prevent access to and egress from too many stops. - Mode-specific version of `maxStopCount`. - """ + Safety limit to prevent access to and egress from too many stops. + Mode-specific version of `maxStopCount`. + """ ) .asEnumMap(StreetMode.class, Integer.class) ); @@ -568,12 +564,12 @@ duration can be set per mode(`maxDurationForMode`), because some street modes se .summary("This is the maximum duration for a direct street search for each mode.") .description( """ -This is a performance limit and should therefore be set high. Results close to the limit are not -guaranteed to be optimal. Use itinerary-filters to limit what is presented to the client. The -duration can be set per mode(`maxDirectStreetDurationForMode`), because some street modes searches -are much more resource intensive than others. A default value is applied if the mode specific value -does not exist." -""" + This is a performance limit and should therefore be set high. Results close to the limit are not + guaranteed to be optimal. Use itinerary-filters to limit what is presented to the client. The + duration can be set per mode(`maxDirectStreetDurationForMode`), because some street modes searches + are much more resource intensive than others. A default value is applied if the mode specific value + does not exist." + """ ) .asDuration(dft.maxDirectDuration().defaultValue()), c @@ -605,12 +601,12 @@ duration can be set per mode(`maxDirectStreetDurationForMode`), because some str ) .description( """ -The street search(AStar) aborts after this duration and any paths found are returned to the client. -The street part of the routing may take a long time if searching very long distances. You can set -the street routing timeout to avoid tying up server resources on pointless searches and ensure that -your users receive a timely response. You can also limit the max duration. There are is also a -'apiProcessingTimeout'. Make sure the street timeout is less than the 'apiProcessingTimeout'. - """ + The street search(AStar) aborts after this duration and any paths found are returned to the client. + The street part of the routing may take a long time if searching very long distances. You can set + the street routing timeout to avoid tying up server resources on pointless searches and ensure that + your users receive a timely response. You can also limit the max duration. There are is also a + 'apiProcessingTimeout'. Make sure the street timeout is less than the 'apiProcessingTimeout'. + """ ) .asDuration(dft.routingTimeout()) ); @@ -740,16 +736,16 @@ private static void mapSystemPreferences(NodeAdapter c, SystemPreferences.Builde ) .description( """ -Normally you would just do an estimate and add enough slack, so you are sure that there is no -journeys that falls outside this window. The parameter is used find all possible dates for the -journey and then search only the services which run on those dates. The duration must include -access, egress, wait-time and transit time for the whole journey. It should also take low frequency -days/periods like holidays into account. In other words, pick the two points within your area that -has the worst connection and then try to travel on the worst possible day, and find the maximum -journey duration. Using a value that is too high has the effect of including more patterns in the -search, hence, making it a bit slower. Recommended values would be from 12 hours(small town/city), -1 day (region) to 2 days (country like Norway)." -""" + Normally you would just do an estimate and add enough slack, so you are sure that there is no + journeys that falls outside this window. The parameter is used find all possible dates for the + journey and then search only the services which run on those dates. The duration must include + access, egress, wait-time and transit time for the whole journey. It should also take low frequency + days/periods like holidays into account. In other words, pick the two points within your area that + has the worst connection and then try to travel on the worst possible day, and find the maximum + journey duration. Using a value that is too high has the effect of including more patterns in the + search, hence, making it a bit slower. Recommended values would be from 12 hours(small town/city), + 1 day (region) to 2 days (country like Norway)." + """ ) .asDuration(dft.maxJourneyDuration()) ); @@ -813,12 +809,12 @@ private static void mapWalkPreferences(NodeAdapter root, WalkPreferences.Builder ) .description( """ -Empirically, values between 2 and 4 seem to correspond well to the concept of not wanting to walk -too much without asking for totally ridiculous itineraries, but this observation should in no way -be taken as scientific or definitive. Your mileage may vary. -See https://github.com/opentripplanner/OpenTripPlanner/issues/4090 for impact on performance with -high values. -""" + Empirically, values between 2 and 4 seem to correspond well to the concept of not wanting to walk + too much without asking for totally ridiculous itineraries, but this observation should in no way + be taken as scientific or definitive. Your mileage may vary. + See https://github.com/opentripplanner/OpenTripPlanner/issues/4090 for impact on performance with + high values. + """ ) .asDouble(dft.reluctance()) ) diff --git a/application/src/main/java/org/opentripplanner/standalone/config/routerequest/TransferConfig.java b/application/src/main/java/org/opentripplanner/standalone/config/routerequest/TransferConfig.java index 99b051e7941..8fb546a8cea 100644 --- a/application/src/main/java/org/opentripplanner/standalone/config/routerequest/TransferConfig.java +++ b/application/src/main/java/org/opentripplanner/standalone/config/routerequest/TransferConfig.java @@ -43,7 +43,7 @@ static void mapTransferPreferences(NodeAdapter c, TransferPreferences.Builder tx The extra buffer time/safety margin added to transfers to make sure the connection is safe, time wise. We recommend allowing the end-user to set this, and use `board-/alight-slack` to enforce agency policies. This time is in addition to how long it might take to walk, board and alight. - + It is useful for passengers on long distance travel, and people with mobility issues, but can be set close to zero for everyday commuters and short distance searches in high-frequency transit areas. """ @@ -67,36 +67,36 @@ static void mapTransferPreferences(NodeAdapter c, TransferPreferences.Builder tx .summary("Optimize where a transfer between to trip happens. ") .description( """ -The main purpose of transfer optimization is to handle cases where it is possible to transfer -between two routes at more than one point (pair of stops). The transfer optimization ensures that -transfers occur at the best possible location. By post-processing all paths returned by the router, -OTP can apply sophisticated calculations that are too slow or not algorithmically valid within -Raptor. Transfers are optimized is done after the Raptor search and before the paths are passed -to the itinerary-filter-chain. + The main purpose of transfer optimization is to handle cases where it is possible to transfer + between two routes at more than one point (pair of stops). The transfer optimization ensures that + transfers occur at the best possible location. By post-processing all paths returned by the router, + OTP can apply sophisticated calculations that are too slow or not algorithmically valid within + Raptor. Transfers are optimized is done after the Raptor search and before the paths are passed + to the itinerary-filter-chain. + + To toggle transfer optimization on or off use the OTPFeature `OptimizeTransfers` (default is on). + You should leave this on unless there is a critical issue with it. The OTPFeature + `GuaranteedTransfers` will toggle on and off the priority optimization (part of OptimizeTransfers). + + The optimized transfer service will try to, in order: -To toggle transfer optimization on or off use the OTPFeature `OptimizeTransfers` (default is on). -You should leave this on unless there is a critical issue with it. The OTPFeature -`GuaranteedTransfers` will toggle on and off the priority optimization (part of OptimizeTransfers). - -The optimized transfer service will try to, in order: - -1. Use transfer priority. This includes stay-seated and guaranteed transfers. -2. Use the transfers with the best distribution of the wait-time, and avoid very short transfers. -3. Avoid back-travel -4. Boost stop-priority to select preferred and recommended stops. - -If two paths have the same transfer priority level, then we break the tie by looking at waiting -times. The goal is to maximize the wait-time for each stop, avoiding situations where there is -little time available to make the transfer. This is balanced with the generalized-cost. The cost -is adjusted with a new cost for wait-time (optimized-wait-time-cost). - -The defaults should work fine, but if you have results with short wait-times dominating a better -option or "back-travel", then try to increase the `minSafeWaitTimeFactor`, -`backTravelWaitTimeFactor` and/or `extraStopBoardAlightCostsFactor`. + 1. Use transfer priority. This includes stay-seated and guaranteed transfers. + 2. Use the transfers with the best distribution of the wait-time, and avoid very short transfers. + 3. Avoid back-travel + 4. Boost stop-priority to select preferred and recommended stops. -For details on the logic/design see [transfer optimization](https://github.com/opentripplanner/OpenTripPlanner/blob/dev-2.x/src/main/java/org/opentripplanner/routing/algorithm/transferoptimization/package.md) -package documentation. -""" + If two paths have the same transfer priority level, then we break the tie by looking at waiting + times. The goal is to maximize the wait-time for each stop, avoiding situations where there is + little time available to make the transfer. This is balanced with the generalized-cost. The cost + is adjusted with a new cost for wait-time (optimized-wait-time-cost). + + The defaults should work fine, but if you have results with short wait-times dominating a better + option or "back-travel", then try to increase the `minSafeWaitTimeFactor`, + `backTravelWaitTimeFactor` and/or `extraStopBoardAlightCostsFactor`. + + For details on the logic/design see [transfer optimization](https://github.com/opentripplanner/OpenTripPlanner/blob/dev-2.x/src/main/java/org/opentripplanner/routing/algorithm/transferoptimization/package.md) + package documentation. + """ ) .asObject() ) @@ -105,8 +105,7 @@ between two routes at more than one point (pair of stops). The transfer optimiza private static TransferOptimizationPreferences mapTransferOptimization(NodeAdapter c) { var dft = TransferOptimizationPreferences.DEFAULT; - return TransferOptimizationPreferences - .of() + return TransferOptimizationPreferences.of() .withOptimizeTransferWaitTime( c .of("optimizeTransferWaitTime") diff --git a/application/src/main/java/org/opentripplanner/standalone/config/routerequest/TransitGroupPriorityConfig.java b/application/src/main/java/org/opentripplanner/standalone/config/routerequest/TransitGroupPriorityConfig.java index e5f1ccd784a..eb7d76b0263 100644 --- a/application/src/main/java/org/opentripplanner/standalone/config/routerequest/TransitGroupPriorityConfig.java +++ b/application/src/main/java/org/opentripplanner/standalone/config/routerequest/TransitGroupPriorityConfig.java @@ -27,7 +27,7 @@ public static void mapTransitRequest(NodeAdapter root, TransitRequest transit) { Hence, two paths with a different set of group-ids will BOTH be optimal unless the cost is worse than the relaxation specified in the `relaxTransitGroupPriority` parameter. This is only available in the TransmodelAPI for now. - + Unmatched patterns are put in the BASE priority-group. """ ) @@ -67,8 +67,7 @@ private static Collection mapList( } private static TransitGroupSelect mapTransitGroupSelect(NodeAdapter c) { - return TransitGroupSelect - .of() + return TransitGroupSelect.of() .addModes( c .of("modes") diff --git a/application/src/main/java/org/opentripplanner/standalone/config/routerequest/WheelchairConfig.java b/application/src/main/java/org/opentripplanner/standalone/config/routerequest/WheelchairConfig.java index f998c892b19..985a320cb27 100644 --- a/application/src/main/java/org/opentripplanner/standalone/config/routerequest/WheelchairConfig.java +++ b/application/src/main/java/org/opentripplanner/standalone/config/routerequest/WheelchairConfig.java @@ -10,8 +10,7 @@ public class WheelchairConfig { static boolean wheelchairEnabled(NodeAdapter root, String parameterName) { - return WheelchairConfig - .wheelchairRoot(root, parameterName) + return WheelchairConfig.wheelchairRoot(root, parameterName) .of("enabled") .since(V2_0) .summary("Enable wheelchair accessibility.") @@ -81,11 +80,11 @@ public static void mapWheelchairPreferences( .summary("How much streets with high slope should be avoided.") .description( """ - What factor should be given to street edges, which are over the - max slope. The penalty is not static but scales with how much you - exceed the maximum slope. Set to negative to disable routing on - too steep edges. - """ + What factor should be given to street edges, which are over the + max slope. The penalty is not static but scales with how much you + exceed the maximum slope. Set to negative to disable routing on + too steep edges. + """ ) .asDouble(dft.slopeExceededReluctance()) ) @@ -96,10 +95,10 @@ public static void mapWheelchairPreferences( .summary("How much stairs should be avoided.") .description( """ - Stairs are not completely excluded for wheelchair users but - severely punished. This value determines how much they are - punished. This should be a very high value as you want to only - include stairs as a last result.""" + Stairs are not completely excluded for wheelchair users but + severely punished. This value determines how much they are + punished. This should be a very high value as you want to only + include stairs as a last result.""" ) .asDouble(dft.stairsReluctance()) ); diff --git a/application/src/main/java/org/opentripplanner/standalone/config/sandbox/FlexConfig.java b/application/src/main/java/org/opentripplanner/standalone/config/sandbox/FlexConfig.java index 2521ca5e57b..67ca1c24697 100644 --- a/application/src/main/java/org/opentripplanner/standalone/config/sandbox/FlexConfig.java +++ b/application/src/main/java/org/opentripplanner/standalone/config/sandbox/FlexConfig.java @@ -15,7 +15,7 @@ public class FlexConfig implements FlexParameters { """ If you have multiple overlapping flex zones the high default value can lead to performance problems. A lower value means faster routing. - + Depending on your service this might be what you want to do anyway: many flex services are used by passengers with mobility problems so offering a long walk might be problematic. In other words, if you can walk 45 minutes to a flex stop/zone you're unlikely to be the target audience for those @@ -41,57 +41,53 @@ public FlexConfig(NodeAdapter root, String parameterName) { .summary("Configuration for flex routing.") .asObject(); - this.maxTransferDuration = - json - .of("maxTransferDuration") - .since(V2_3) - .summary( - "How long should a passenger be allowed to walk after getting out of a flex vehicle " + - "and transferring to a flex or transit one." - ) - .description( - """ - This was mainly introduced to improve performance which is also the reason for not - using the existing value with the same name: fixed schedule transfers are computed - during the graph build but flex ones are calculated at request time and are more - sensitive to slowdown. - - A lower value means that the routing is faster. - """ - ) - .asDuration(DEFAULT.maxTransferDuration()); - - maxFlexTripDuration = - json - .of("maxFlexTripDuration") - .since(V2_3) - .summary("How long can a non-scheduled flex trip at maximum be.") - .description( - "This is used for all trips which are of type `UnscheduledTrip`. The value includes " + - "the access/egress duration to the boarding/alighting of the flex trip, as well as the " + - "connection to the transit stop." - ) - .asDuration(DEFAULT.maxFlexTripDuration()); - - maxAccessWalkDuration = - json - .of("maxAccessWalkDuration") - .since(V2_3) - .summary( - "The maximum duration the passenger will be allowed to walk to reach a flex stop or zone." - ) - .description(ACCESS_EGRESS_DESCRIPTION) - .asDuration(DEFAULT.maxAccessWalkDuration()); - - maxEgressWalkDuration = - json - .of("maxEgressWalkDuration") - .since(V2_3) - .summary( - "The maximum duration the passenger will be allowed to walk after leaving the flex vehicle at the final destination." - ) - .description(ACCESS_EGRESS_DESCRIPTION) - .asDuration(DEFAULT.maxEgressWalkDuration()); + this.maxTransferDuration = json + .of("maxTransferDuration") + .since(V2_3) + .summary( + "How long should a passenger be allowed to walk after getting out of a flex vehicle " + + "and transferring to a flex or transit one." + ) + .description( + """ + This was mainly introduced to improve performance which is also the reason for not + using the existing value with the same name: fixed schedule transfers are computed + during the graph build but flex ones are calculated at request time and are more + sensitive to slowdown. + + A lower value means that the routing is faster. + """ + ) + .asDuration(DEFAULT.maxTransferDuration()); + + maxFlexTripDuration = json + .of("maxFlexTripDuration") + .since(V2_3) + .summary("How long can a non-scheduled flex trip at maximum be.") + .description( + "This is used for all trips which are of type `UnscheduledTrip`. The value includes " + + "the access/egress duration to the boarding/alighting of the flex trip, as well as the " + + "connection to the transit stop." + ) + .asDuration(DEFAULT.maxFlexTripDuration()); + + maxAccessWalkDuration = json + .of("maxAccessWalkDuration") + .since(V2_3) + .summary( + "The maximum duration the passenger will be allowed to walk to reach a flex stop or zone." + ) + .description(ACCESS_EGRESS_DESCRIPTION) + .asDuration(DEFAULT.maxAccessWalkDuration()); + + maxEgressWalkDuration = json + .of("maxEgressWalkDuration") + .since(V2_3) + .summary( + "The maximum duration the passenger will be allowed to walk after leaving the flex vehicle at the final destination." + ) + .description(ACCESS_EGRESS_DESCRIPTION) + .asDuration(DEFAULT.maxEgressWalkDuration()); } public Duration maxFlexTripDuration() { diff --git a/application/src/main/java/org/opentripplanner/standalone/config/sandbox/TransmodelAPIConfig.java b/application/src/main/java/org/opentripplanner/standalone/config/sandbox/TransmodelAPIConfig.java index 16b438a7c5a..12d26eb450f 100644 --- a/application/src/main/java/org/opentripplanner/standalone/config/sandbox/TransmodelAPIConfig.java +++ b/application/src/main/java/org/opentripplanner/standalone/config/sandbox/TransmodelAPIConfig.java @@ -24,31 +24,28 @@ public TransmodelAPIConfig(String parameterName, NodeAdapter root) { .summary("Configuration for the Transmodel GraphQL API.") .asObject(); - hideFeedId = - c - .of("hideFeedId") - .summary("Hide the FeedId in all API output, and add it to input.") - .description( - "Only turn this feature on if you have unique ids across all feeds, without the " + - "feedId prefix." - ) - .asBoolean(false); - tracingHeaderTags = - c - .of("tracingHeaderTags") - .summary("Used to group requests when monitoring OTP.") - .asStringList(Set.of()); + hideFeedId = c + .of("hideFeedId") + .summary("Hide the FeedId in all API output, and add it to input.") + .description( + "Only turn this feature on if you have unique ids across all feeds, without the " + + "feedId prefix." + ) + .asBoolean(false); + tracingHeaderTags = c + .of("tracingHeaderTags") + .summary("Used to group requests when monitoring OTP.") + .asStringList(Set.of()); - maxNumberOfResultFields = - c - .of("maxNumberOfResultFields") - .since(V2_6) - .summary("The maximum number of fields in a GraphQL result") - .description( - "Enforce rate limiting based on query complexity; Queries that return too much data are" + - " cancelled." - ) - .asInt(1_000_000); + maxNumberOfResultFields = c + .of("maxNumberOfResultFields") + .since(V2_6) + .summary("The maximum number of fields in a GraphQL result") + .description( + "Enforce rate limiting based on query complexity; Queries that return too much data are" + + " cancelled." + ) + .asInt(1_000_000); } @Override diff --git a/application/src/main/java/org/opentripplanner/standalone/config/sandbox/VehicleRentalServiceDirectoryFetcherConfig.java b/application/src/main/java/org/opentripplanner/standalone/config/sandbox/VehicleRentalServiceDirectoryFetcherConfig.java index f8ed1184c04..b0a87d6d5eb 100644 --- a/application/src/main/java/org/opentripplanner/standalone/config/sandbox/VehicleRentalServiceDirectoryFetcherConfig.java +++ b/application/src/main/java/org/opentripplanner/standalone/config/sandbox/VehicleRentalServiceDirectoryFetcherConfig.java @@ -92,7 +92,7 @@ private static List mapNetworkParameters( """ Configures if a vehicle rented from a station must be returned to another one or can be kept at the end of the trip. - + See the regular [GBFS documentation](../UpdaterConfig.md#gbfs-vehicle-rental-systems) for more information. """ ) diff --git a/application/src/main/java/org/opentripplanner/standalone/configure/ConstructApplication.java b/application/src/main/java/org/opentripplanner/standalone/configure/ConstructApplication.java index a20927f8656..4ffed3960c4 100644 --- a/application/src/main/java/org/opentripplanner/standalone/configure/ConstructApplication.java +++ b/application/src/main/java/org/opentripplanner/standalone/configure/ConstructApplication.java @@ -96,21 +96,19 @@ public class ConstructApplication { // use Dagger DI to do it - passing in a parameter to enable it or not. var graphVisualizer = cli.visualize ? new GraphVisualizer(graph) : null; - this.factory = - DaggerConstructApplicationFactory - .builder() - .configModel(config) - .graph(graph) - .timetableRepository(timetableRepository) - .graphVisualizer(graphVisualizer) - .worldEnvelopeRepository(worldEnvelopeRepository) - .vehicleParkingRepository(vehicleParkingRepository) - .emissionsDataModel(emissionsDataModel) - .dataImportIssueSummary(issueSummary) - .stopConsolidationRepository(stopConsolidationRepository) - .streetLimitationParameters(streetLimitationParameters) - .schema(config.routerConfig().routingRequestDefaults()) - .build(); + this.factory = DaggerConstructApplicationFactory.builder() + .configModel(config) + .graph(graph) + .timetableRepository(timetableRepository) + .graphVisualizer(graphVisualizer) + .worldEnvelopeRepository(worldEnvelopeRepository) + .vehicleParkingRepository(vehicleParkingRepository) + .emissionsDataModel(emissionsDataModel) + .dataImportIssueSummary(issueSummary) + .stopConsolidationRepository(stopConsolidationRepository) + .streetLimitationParameters(streetLimitationParameters) + .schema(config.routerConfig().routingRequestDefaults()) + .build(); } public ConstructApplicationFactory getFactory() { diff --git a/application/src/main/java/org/opentripplanner/standalone/server/AlertMetrics.java b/application/src/main/java/org/opentripplanner/standalone/server/AlertMetrics.java index 09c74104777..3f0ef75dd68 100644 --- a/application/src/main/java/org/opentripplanner/standalone/server/AlertMetrics.java +++ b/application/src/main/java/org/opentripplanner/standalone/server/AlertMetrics.java @@ -41,11 +41,9 @@ public AlertMetrics(Supplier serviceSupplier) { @Override public void bindTo(MeterRegistry meterRegistry) { - this.statuses = - MultiGauge - .builder("alerts") - .description("Total number of alerts (sourced from GTFS-Alerts and SIRI-SX) in the system.") - .register(meterRegistry); + this.statuses = MultiGauge.builder("alerts") + .description("Total number of alerts (sourced from GTFS-Alerts and SIRI-SX) in the system.") + .register(meterRegistry); ApplicationShutdownSupport.addShutdownHook("alert-metrics-shutdown", scheduler::shutdownNow); } @@ -73,10 +71,11 @@ private Iterable> summarizeAlerts(TransitAlertService ale ImmutableMultimap taggedAlerts = alerts .stream() .collect( - ImmutableListMultimap.flatteningToImmutableListMultimap( - AlertTags::of, - Stream::of - ) + ImmutableListMultimap.< + TransitAlert, + AlertTags, + TransitAlert + >flatteningToImmutableListMultimap(AlertTags::of, Stream::of) ); return taggedAlerts .keySet() diff --git a/application/src/main/java/org/opentripplanner/standalone/server/EtagRequestFilter.java b/application/src/main/java/org/opentripplanner/standalone/server/EtagRequestFilter.java index b53739084ae..d8a0d4074a4 100644 --- a/application/src/main/java/org/opentripplanner/standalone/server/EtagRequestFilter.java +++ b/application/src/main/java/org/opentripplanner/standalone/server/EtagRequestFilter.java @@ -26,7 +26,8 @@ public void filter(ContainerRequestContext request, ContainerResponseContext res if ( isEligibleForEtag(request, response) && hasAllowedContentType(response) && - response.getEntity() instanceof byte[] bytes && bytes.length > 0 + response.getEntity() instanceof byte[] bytes && + bytes.length > 0 ) { var clientEtag = request.getHeaderString(HEADER_IF_NONE_MATCH); var etag = generateETagHeaderValue(bytes); diff --git a/application/src/main/java/org/opentripplanner/standalone/server/GrizzlyServer.java b/application/src/main/java/org/opentripplanner/standalone/server/GrizzlyServer.java index 7dc7c87f735..6c68b28a9bd 100644 --- a/application/src/main/java/org/opentripplanner/standalone/server/GrizzlyServer.java +++ b/application/src/main/java/org/opentripplanner/standalone/server/GrizzlyServer.java @@ -70,8 +70,7 @@ public void run() { // will use a more efficient fixed-size thread pool implementation. // TODO we should probably use Grizzly async processing rather than tying up the HTTP handler threads. int nHandlerThreads = getMaxThreads(); - ThreadPoolConfig threadPoolConfig = ThreadPoolConfig - .defaultConfig() + ThreadPoolConfig threadPoolConfig = ThreadPoolConfig.defaultConfig() .setPoolName("grizzly") .setThreadFactory(new ThreadFactoryBuilder().setNameFormat("grizzly-%d").build()) .setCorePoolSize(nHandlerThreads) diff --git a/application/src/main/java/org/opentripplanner/standalone/server/MetricsLogging.java b/application/src/main/java/org/opentripplanner/standalone/server/MetricsLogging.java index b8c7912df7f..5301cd92d72 100644 --- a/application/src/main/java/org/opentripplanner/standalone/server/MetricsLogging.java +++ b/application/src/main/java/org/opentripplanner/standalone/server/MetricsLogging.java @@ -57,37 +57,32 @@ public MetricsLogging( timetableRepository.getRaptorTransitData().getTransferCache().getTransferCache(), "raptorTransfersCache", List.of(Tag.of("cache", "raptorTransfers")) - ) - .bindTo(Metrics.globalRegistry); + ).bindTo(Metrics.globalRegistry); } new ExecutorServiceMetrics( ForkJoinPool.commonPool(), "commonPool", List.of(Tag.of("pool", "commonPool")) - ) - .bindTo(Metrics.globalRegistry); + ).bindTo(Metrics.globalRegistry); if (timetableRepository.getUpdaterManager() != null) { new ExecutorServiceMetrics( timetableRepository.getUpdaterManager().getPollingUpdaterPool(), "pollingGraphUpdaters", List.of(Tag.of("pool", "pollingGraphUpdaters")) - ) - .bindTo(Metrics.globalRegistry); + ).bindTo(Metrics.globalRegistry); new ExecutorServiceMetrics( timetableRepository.getUpdaterManager().getNonPollingUpdaterPool(), "nonPollingGraphUpdaters", List.of(Tag.of("pool", "nonPollingGraphUpdaters")) - ) - .bindTo(Metrics.globalRegistry); + ).bindTo(Metrics.globalRegistry); new ExecutorServiceMetrics( timetableRepository.getUpdaterManager().getScheduler(), "graphUpdateScheduler", List.of(Tag.of("pool", "graphUpdateScheduler")) - ) - .bindTo(Metrics.globalRegistry); + ).bindTo(Metrics.globalRegistry); } if (raptorConfig.isMultiThreaded()) { @@ -95,8 +90,7 @@ public MetricsLogging( raptorConfig.threadPool(), "raptorHeuristics", List.of(Tag.of("pool", "raptorHeuristics")) - ) - .bindTo(Metrics.globalRegistry); + ).bindTo(Metrics.globalRegistry); } final Map issueCount = issueSummary.asMap(); diff --git a/application/src/main/java/org/opentripplanner/street/model/StreetTraversalPermission.java b/application/src/main/java/org/opentripplanner/street/model/StreetTraversalPermission.java index 98f7f2c3c91..366524c4cfc 100644 --- a/application/src/main/java/org/opentripplanner/street/model/StreetTraversalPermission.java +++ b/application/src/main/java/org/opentripplanner/street/model/StreetTraversalPermission.java @@ -16,8 +16,8 @@ public enum StreetTraversalPermission { BICYCLE_AND_CAR(4 | 2), ALL(4 | 2 | 1); - private static final StreetTraversalPermission[] lookup = new StreetTraversalPermission[StreetTraversalPermission.values() - .length]; + private static final StreetTraversalPermission[] lookup = + new StreetTraversalPermission[StreetTraversalPermission.values().length]; public final int code; static { diff --git a/application/src/main/java/org/opentripplanner/street/model/edge/CarPickupableEdge.java b/application/src/main/java/org/opentripplanner/street/model/edge/CarPickupableEdge.java index 8f69ef1c227..81e1ccd9707 100644 --- a/application/src/main/java/org/opentripplanner/street/model/edge/CarPickupableEdge.java +++ b/application/src/main/java/org/opentripplanner/street/model/edge/CarPickupableEdge.java @@ -9,11 +9,9 @@ default boolean canPickupAndDrive(State state) { return ( state.getRequest().mode().includesPickup() && state.getCarPickupState() == - ( - state.getRequest().arriveBy() + (state.getRequest().arriveBy() ? CarPickupState.WALK_FROM_DROP_OFF - : CarPickupState.WALK_TO_PICKUP - ) + : CarPickupState.WALK_TO_PICKUP) ); } diff --git a/application/src/main/java/org/opentripplanner/street/model/edge/ElevatorBoardEdge.java b/application/src/main/java/org/opentripplanner/street/model/edge/ElevatorBoardEdge.java index cacc97fc2f1..256776b09a0 100644 --- a/application/src/main/java/org/opentripplanner/street/model/edge/ElevatorBoardEdge.java +++ b/application/src/main/java/org/opentripplanner/street/model/edge/ElevatorBoardEdge.java @@ -26,10 +26,9 @@ public class ElevatorBoardEdge extends Edge implements BikeWalkableEdge, Elevato private ElevatorBoardEdge(ElevatorOffboardVertex from, ElevatorOnboardVertex to) { super(from, to); - geometry = - GeometryUtils.makeLineString( - List.of(new Coordinate(from.getX(), from.getY()), new Coordinate(to.getX(), to.getY())) - ); + geometry = GeometryUtils.makeLineString( + List.of(new Coordinate(from.getX(), from.getY()), new Coordinate(to.getX(), to.getY())) + ); } public static ElevatorBoardEdge createElevatorBoardEdge( diff --git a/application/src/main/java/org/opentripplanner/street/model/edge/PathwayEdge.java b/application/src/main/java/org/opentripplanner/street/model/edge/PathwayEdge.java index e6c653ff1dd..a207d58859f 100644 --- a/application/src/main/java/org/opentripplanner/street/model/edge/PathwayEdge.java +++ b/application/src/main/java/org/opentripplanner/street/model/edge/PathwayEdge.java @@ -115,31 +115,29 @@ public State[] traverse(State s0) { if (time_ms == 0) { if (distance > 0) { - time_ms = (long) (1000.0 * distance / preferences.walk().speed()); + time_ms = (long) ((1000.0 * distance) / preferences.walk().speed()); } else if (isStairs()) { // 1 step corresponds to 20cm, doubling that to compensate for elevation; - time_ms = (long) (1000.0 * 0.4 * Math.abs(steps) / preferences.walk().speed()); + time_ms = (long) ((1000.0 * 0.4 * Math.abs(steps)) / preferences.walk().speed()); } } if (time_ms > 0) { double weight = time_ms / 1000.0; if (s0.getRequest().wheelchair()) { - weight *= - StreetEdgeReluctanceCalculator.computeWheelchairReluctance( - preferences, - slope, - wheelchairAccessible, - isStairs() - ); + weight *= StreetEdgeReluctanceCalculator.computeWheelchairReluctance( + preferences, + slope, + wheelchairAccessible, + isStairs() + ); } else { - weight *= - StreetEdgeReluctanceCalculator.computeReluctance( - preferences, - TraverseMode.WALK, - s0.currentMode() == TraverseMode.BICYCLE, - isStairs() - ); + weight *= StreetEdgeReluctanceCalculator.computeReluctance( + preferences, + TraverseMode.WALK, + s0.currentMode() == TraverseMode.BICYCLE, + isStairs() + ); } s1.incrementTimeInMilliseconds(time_ms); s1.incrementWeight(weight); diff --git a/application/src/main/java/org/opentripplanner/street/model/edge/StreetEdge.java b/application/src/main/java/org/opentripplanner/street/model/edge/StreetEdge.java index 4f64bcb87aa..5194628339a 100644 --- a/application/src/main/java/org/opentripplanner/street/model/edge/StreetEdge.java +++ b/application/src/main/java/org/opentripplanner/street/model/edge/StreetEdge.java @@ -310,16 +310,14 @@ public double getEffectiveWalkSafetyDistance() { public String toString() { var nameString = name != null ? name.toString() : null; - return buildToString( - nameString, - b -> - b - .append(", length=") - .append(this.getDistanceMeters()) - .append(", carSpeed=") - .append(this.getCarSpeed()) - .append(", permission=") - .append(this.getPermission()) + return buildToString(nameString, b -> + b + .append(", length=") + .append(this.getDistanceMeters()) + .append(", carSpeed=") + .append(this.getCarSpeed()) + .append(", permission=") + .append(this.getPermission()) ); } @@ -610,12 +608,12 @@ public boolean isSlopeOverride() { * TODO change everything to clockwise from North */ public int getInAngle() { - return IntUtils.round(this.inAngle * 180 / 128.0); + return IntUtils.round((this.inAngle * 180) / 128.0); } /** Return the azimuth of the last segment in this edge in integer degrees clockwise from South. */ public int getOutAngle() { - return IntUtils.round(this.outAngle * 180 / 128.0); + return IntUtils.round((this.outAngle * 180) / 128.0); } public void setCostExtension(StreetEdgeCostExtension costExtension) { @@ -895,8 +893,7 @@ protected void copyPropertiesToSplitEdge( toDistance ); - StreetElevationExtensionBuilder - .of(seb) + StreetElevationExtensionBuilder.of(seb) .withDistanceInMeters(defaultMillimeterLength(seb.geometry()) / 1000.) .withElevationProfile(partialElevationProfileFromParent) .build() @@ -1101,15 +1098,14 @@ private boolean hasStartedWalkingInNoDropOffZoneAndIsExitingIt(State s0) { } private void setGeometry(LineString geometry) { - this.compactGeometry = - CompactLineStringUtils.compactLineString( - fromv.getLon(), - fromv.getLat(), - tov.getLon(), - tov.getLat(), - isBack() ? geometry.reverse() : geometry, - isBack() - ); + this.compactGeometry = CompactLineStringUtils.compactLineString( + fromv.getLon(), + fromv.getLat(), + tov.getLon(), + tov.getLat(), + isBack() ? geometry.reverse() : geometry, + isBack() + ); } private double getDistanceWithElevation() { @@ -1200,29 +1196,27 @@ private StateEditor doTraverse(State s0, TraverseMode traverseMode, boolean walk * the backEdge, rather than of the current edge. */ if (arriveBy && tov instanceof IntersectionVertex traversedVertex) { // arrive-by search - turnDuration = - s0 - .intersectionTraversalCalculator() - .computeTraversalDuration( - traversedVertex, - this, - backPSE, - backMode, - (float) speed, - (float) backSpeed - ); + turnDuration = s0 + .intersectionTraversalCalculator() + .computeTraversalDuration( + traversedVertex, + this, + backPSE, + backMode, + (float) speed, + (float) backSpeed + ); } else if (!arriveBy && fromv instanceof IntersectionVertex traversedVertex) { // depart-after search - turnDuration = - s0 - .intersectionTraversalCalculator() - .computeTraversalDuration( - traversedVertex, - backPSE, - this, - traverseMode, - (float) backSpeed, - (float) speed - ); + turnDuration = s0 + .intersectionTraversalCalculator() + .computeTraversalDuration( + traversedVertex, + backPSE, + this, + traverseMode, + (float) backSpeed, + (float) speed + ); } else { // In case this is a temporary edge not connected to an IntersectionVertex LOG.debug("Not computing turn duration for edge {}", this); @@ -1282,7 +1276,7 @@ private TraversalCosts bicycleOrScooterTraversalCost( : pref.scooter().optimizeType(); switch (optimizeType) { case SAFEST_STREETS -> { - weight = bicycleSafetyFactor * getDistanceMeters() / speed; + weight = (bicycleSafetyFactor * getDistanceMeters()) / speed; if (bicycleSafetyFactor <= SAFEST_STREETS_SAFETY_FACTOR) { // safest streets are treated as even safer than they really are weight *= 0.66; @@ -1344,20 +1338,17 @@ private TraversalCosts walkingTraversalCosts( // take slopes into account when walking time = getEffectiveWalkDistance() / speed; weight = - getEffectiveWalkSafetyDistance() * - preferences.walk().safetyFactor() + - getEffectiveWalkDistance() * - (1 - preferences.walk().safetyFactor()); + getEffectiveWalkSafetyDistance() * preferences.walk().safetyFactor() + + getEffectiveWalkDistance() * (1 - preferences.walk().safetyFactor()); weight /= speed; } - weight *= - StreetEdgeReluctanceCalculator.computeReluctance( - preferences, - traverseMode, - walkingBike, - isStairs() - ); + weight *= StreetEdgeReluctanceCalculator.computeReluctance( + preferences, + traverseMode, + walkingBike, + isStairs() + ); } return new TraversalCosts(time, weight); @@ -1433,7 +1424,7 @@ public static LineStringInOutAngles of(LineString geometry) { * 180 degrees exists as a negative rather than a positive due to the integer range. */ private static byte convertRadianToByte(double angleRadians) { - return (byte) Math.round(angleRadians * 128 / Math.PI + 128); + return (byte) Math.round((angleRadians * 128) / Math.PI + 128); } } } diff --git a/application/src/main/java/org/opentripplanner/street/model/edge/StreetElevationExtension.java b/application/src/main/java/org/opentripplanner/street/model/edge/StreetElevationExtension.java index d741fb0a763..fa6a0b2b59b 100644 --- a/application/src/main/java/org/opentripplanner/street/model/edge/StreetElevationExtension.java +++ b/application/src/main/java/org/opentripplanner/street/model/edge/StreetElevationExtension.java @@ -132,8 +132,7 @@ public boolean isFlattened() { } public String toString() { - return ToStringBuilder - .of(StreetElevationExtension.class) + return ToStringBuilder.of(StreetElevationExtension.class) .addBoolIfTrue("flattened", flattened) .addNum("distanceMeters", distanceMeters) .addNum("effectiveBicycleSafetyFactor", effectiveBicycleSafetyDistance) diff --git a/application/src/main/java/org/opentripplanner/street/model/edge/StreetElevationExtensionBuilder.java b/application/src/main/java/org/opentripplanner/street/model/edge/StreetElevationExtensionBuilder.java index 26a90bf1237..a0d97310961 100644 --- a/application/src/main/java/org/opentripplanner/street/model/edge/StreetElevationExtensionBuilder.java +++ b/application/src/main/java/org/opentripplanner/street/model/edge/StreetElevationExtensionBuilder.java @@ -105,9 +105,8 @@ private StreetElevationExtension buildInternal() { var maxSlope = (float) costs.maxSlope; var flattened = costs.flattened; - float effectiveBicycleSafetyFactor = (float) ( - bicycleSafetyFactor * costs.lengthMultiplier + costs.slopeSafetyCost / distanceInMeters - ); + float effectiveBicycleSafetyFactor = (float) (bicycleSafetyFactor * costs.lengthMultiplier + + costs.slopeSafetyCost / distanceInMeters); if ( Double.isInfinite(effectiveBicycleSafetyFactor) || Double.isNaN(effectiveBicycleSafetyFactor) diff --git a/application/src/main/java/org/opentripplanner/street/model/edge/StreetTransitEntityLink.java b/application/src/main/java/org/opentripplanner/street/model/edge/StreetTransitEntityLink.java index 5a62eda0f90..e0cbc130426 100644 --- a/application/src/main/java/org/opentripplanner/street/model/edge/StreetTransitEntityLink.java +++ b/application/src/main/java/org/opentripplanner/street/model/edge/StreetTransitEntityLink.java @@ -89,14 +89,12 @@ public State[] traverse(State s0) { // floating rental vehicles. else if ( s0.isRentingVehicleFromStation() && - !( - s0.mayKeepRentedVehicleAtDestination() && + !(s0.mayKeepRentedVehicleAtDestination() && s0 .getRequest() .preferences() .rental(s0.getRequest().mode()) - .allowArrivingInRentedVehicleAtDestination() - ) + .allowArrivingInRentedVehicleAtDestination()) ) { yield State.empty(); } diff --git a/application/src/main/java/org/opentripplanner/street/model/edge/TemporaryPartialStreetEdge.java b/application/src/main/java/org/opentripplanner/street/model/edge/TemporaryPartialStreetEdge.java index 31792614cde..c5ce8102b2a 100644 --- a/application/src/main/java/org/opentripplanner/street/model/edge/TemporaryPartialStreetEdge.java +++ b/application/src/main/java/org/opentripplanner/street/model/edge/TemporaryPartialStreetEdge.java @@ -55,10 +55,8 @@ public StreetEdge getParentEdge() { @Override public String toString() { - return buildToString( - this.getDefaultName(), - b -> - b.append(", length=").append(this.getCarSpeed()).append(", parentEdge=").append(parentEdge) + return buildToString(this.getDefaultName(), b -> + b.append(", length=").append(this.getCarSpeed()).append(", parentEdge=").append(parentEdge) ); } diff --git a/application/src/main/java/org/opentripplanner/street/model/elevation/ElevationUtils.java b/application/src/main/java/org/opentripplanner/street/model/elevation/ElevationUtils.java index 906398bcdd4..fd499f4beed 100644 --- a/application/src/main/java/org/opentripplanner/street/model/elevation/ElevationUtils.java +++ b/application/src/main/java/org/opentripplanner/street/model/elevation/ElevationUtils.java @@ -18,11 +18,10 @@ public class ElevationUtils { static { try { - mt = - new DefaultMathTransformFactory() - .createParameterizedTransform( - new EarthGravitationalModel.Provider().getParameters().createValue() - ); + mt = new DefaultMathTransformFactory() + .createParameterizedTransform( + new EarthGravitationalModel.Provider().getParameters().createValue() + ); } catch (FactoryException e) { e.printStackTrace(); } diff --git a/application/src/main/java/org/opentripplanner/street/model/note/StreetNoteAndMatcher.java b/application/src/main/java/org/opentripplanner/street/model/note/StreetNoteAndMatcher.java index 953645c46bc..2c40b223245 100644 --- a/application/src/main/java/org/opentripplanner/street/model/note/StreetNoteAndMatcher.java +++ b/application/src/main/java/org/opentripplanner/street/model/note/StreetNoteAndMatcher.java @@ -43,8 +43,7 @@ public int hashCode() { @Override public String toString() { - return ToStringBuilder - .of(StreetNoteAndMatcher.class) + return ToStringBuilder.of(StreetNoteAndMatcher.class) .addObj("note", note) .addObj("matcher", matcher) .toString(); diff --git a/application/src/main/java/org/opentripplanner/street/model/vertex/StationEntranceVertex.java b/application/src/main/java/org/opentripplanner/street/model/vertex/StationEntranceVertex.java index 7b9a94b0725..e829a0e447e 100644 --- a/application/src/main/java/org/opentripplanner/street/model/vertex/StationEntranceVertex.java +++ b/application/src/main/java/org/opentripplanner/street/model/vertex/StationEntranceVertex.java @@ -49,8 +49,7 @@ public Accessibility wheelchairAccessibility() { @Override public String toString() { - return ToStringBuilder - .of(StationEntranceVertex.class) + return ToStringBuilder.of(StationEntranceVertex.class) .addNum("nodeId", nodeId) .addStr("code", code) .toString(); diff --git a/application/src/main/java/org/opentripplanner/street/model/vertex/StreetVertex.java b/application/src/main/java/org/opentripplanner/street/model/vertex/StreetVertex.java index 8b58466a33c..7e2a148e9ef 100644 --- a/application/src/main/java/org/opentripplanner/street/model/vertex/StreetVertex.java +++ b/application/src/main/java/org/opentripplanner/street/model/vertex/StreetVertex.java @@ -60,8 +60,10 @@ public I18NString getIntersectionName() { public boolean isConnectedToWalkingEdge() { return this.getOutgoing() .stream() - .anyMatch(edge -> - edge instanceof StreetEdge && ((StreetEdge) edge).getPermission().allows(TraverseMode.WALK) + .anyMatch( + edge -> + edge instanceof StreetEdge && + ((StreetEdge) edge).getPermission().allows(TraverseMode.WALK) ); } @@ -71,8 +73,9 @@ public boolean isConnectedToWalkingEdge() { public boolean isConnectedToDriveableEdge() { return this.getOutgoing() .stream() - .anyMatch(edge -> - edge instanceof StreetEdge && ((StreetEdge) edge).getPermission().allows(TraverseMode.CAR) + .anyMatch( + edge -> + edge instanceof StreetEdge && ((StreetEdge) edge).getPermission().allows(TraverseMode.CAR) ); } @@ -96,10 +99,9 @@ public void addAreaStops(Collection toBeAdded) { if (areaStops == EMPTY_SET) { areaStops = Set.copyOf(toBeAdded); } else { - areaStops = - Stream - .concat(areaStops.stream(), toBeAdded.stream()) - .collect(Collectors.toUnmodifiableSet()); + areaStops = Stream.concat(areaStops.stream(), toBeAdded.stream()).collect( + Collectors.toUnmodifiableSet() + ); } } } diff --git a/application/src/main/java/org/opentripplanner/street/model/vertex/TransitStopVertex.java b/application/src/main/java/org/opentripplanner/street/model/vertex/TransitStopVertex.java index 5b1b1dfa6a8..4c32f9f1d1f 100644 --- a/application/src/main/java/org/opentripplanner/street/model/vertex/TransitStopVertex.java +++ b/application/src/main/java/org/opentripplanner/street/model/vertex/TransitStopVertex.java @@ -123,13 +123,14 @@ public boolean isLinkedToWalkableEdge() { private boolean isLinkedToEdgeWhichAllows(TraverseMode traverseMode) { return getOutgoing() .stream() - .anyMatch(edge -> - edge instanceof StreetTransitEntityLink link && - link - .getToVertex() - .getOutgoingStreetEdges() - .stream() - .anyMatch(se -> se.canTraverse(traverseMode)) + .anyMatch( + edge -> + edge instanceof StreetTransitEntityLink link && + link + .getToVertex() + .getOutgoingStreetEdges() + .stream() + .anyMatch(se -> se.canTraverse(traverseMode)) ); } } diff --git a/application/src/main/java/org/opentripplanner/street/model/vertex/Vertex.java b/application/src/main/java/org/opentripplanner/street/model/vertex/Vertex.java index 75fd5b7218e..d07ce47b6de 100644 --- a/application/src/main/java/org/opentripplanner/street/model/vertex/Vertex.java +++ b/application/src/main/java/org/opentripplanner/street/model/vertex/Vertex.java @@ -217,8 +217,9 @@ public boolean isConnected(Vertex v) { * @see org.opentripplanner.framework.geometry.WgsCoordinate#sameLocation(WgsCoordinate) **/ public boolean sameLocation(Vertex other) { - return new WgsCoordinate(getLat(), getLon()) - .sameLocation(new WgsCoordinate(other.getLat(), other.getLon())); + return new WgsCoordinate(getLat(), getLon()).sameLocation( + new WgsCoordinate(other.getLat(), other.getLon()) + ); } public boolean rentalTraversalBanned(State currentState) { diff --git a/application/src/main/java/org/opentripplanner/street/search/StreetSearchBuilder.java b/application/src/main/java/org/opentripplanner/street/search/StreetSearchBuilder.java index 68a71aef0a7..97f0e30503d 100644 --- a/application/src/main/java/org/opentripplanner/street/search/StreetSearchBuilder.java +++ b/application/src/main/java/org/opentripplanner/street/search/StreetSearchBuilder.java @@ -71,8 +71,7 @@ protected Duration streetRoutingTimeout() { @Override protected Collection createInitialStates(Set originVertices) { - StreetSearchRequest streetSearchRequest = StreetSearchRequestMapper - .map(routeRequest) + StreetSearchRequest streetSearchRequest = StreetSearchRequestMapper.map(routeRequest) .withMode(streetRequest.mode()) .withArriveBy(arriveBy()) .build(); @@ -84,11 +83,10 @@ protected Collection createInitialStates(Set originVertices) { protected void prepareInitialStates(Collection initialStates) { if (intersectionTraversalCalculator == null) { final StreetPreferences streetPreferences = routeRequest.preferences().street(); - intersectionTraversalCalculator = - IntersectionTraversalCalculator.create( - streetPreferences.intersectionTraversalModel(), - streetPreferences.drivingDirection() - ); + intersectionTraversalCalculator = IntersectionTraversalCalculator.create( + streetPreferences.intersectionTraversalModel(), + streetPreferences.drivingDirection() + ); } for (var state : initialStates) { diff --git a/application/src/main/java/org/opentripplanner/street/search/request/StreetSearchRequestMapper.java b/application/src/main/java/org/opentripplanner/street/search/request/StreetSearchRequestMapper.java index b4193e709e3..e1137b27f8b 100644 --- a/application/src/main/java/org/opentripplanner/street/search/request/StreetSearchRequestMapper.java +++ b/application/src/main/java/org/opentripplanner/street/search/request/StreetSearchRequestMapper.java @@ -6,8 +6,7 @@ public class StreetSearchRequestMapper { public static StreetSearchRequestBuilder map(RouteRequest opt) { - return StreetSearchRequest - .of() + return StreetSearchRequest.of() .withStartTime(opt.dateTime()) .withPreferences(opt.preferences()) .withWheelchair(opt.wheelchair()) @@ -16,8 +15,7 @@ public static StreetSearchRequestBuilder map(RouteRequest opt) { } public static StreetSearchRequestBuilder mapToTransferRequest(RouteRequest opt) { - return StreetSearchRequest - .of() + return StreetSearchRequest.of() .withStartTime(Instant.ofEpochSecond(0)) .withPreferences(opt.preferences()) .withWheelchair(opt.wheelchair()) diff --git a/application/src/main/java/org/opentripplanner/street/search/state/State.java b/application/src/main/java/org/opentripplanner/street/search/state/State.java index 19ef2ba1f9b..4303ea4f3b4 100644 --- a/application/src/main/java/org/opentripplanner/street/search/state/State.java +++ b/application/src/main/java/org/opentripplanner/street/search/state/State.java @@ -72,8 +72,9 @@ public State(Vertex vertex, Instant startTime, StateData stateData, StreetSearch this.backState = null; this.stateData = stateData; if (request.arriveBy() && !vertex.rentalRestrictions().noDropOffNetworks().isEmpty()) { - this.stateData.noRentalDropOffZonesAtStartOfReverseSearch = - vertex.rentalRestrictions().noDropOffNetworks(); + this.stateData.noRentalDropOffZonesAtStartOfReverseSearch = vertex + .rentalRestrictions() + .noDropOffNetworks(); } this.walkDistance = 0; this.time_ms = startTime.toEpochMilli(); @@ -221,18 +222,14 @@ public boolean isRentingVehicle() { private boolean vehicleRentalIsFinished() { return ( stateData.vehicleRentalState == VehicleRentalState.HAVE_RENTED || - ( - stateData.vehicleRentalState == VehicleRentalState.RENTING_FLOATING && - !stateData.insideNoRentalDropOffArea - ) || - ( - getRequest() + (stateData.vehicleRentalState == VehicleRentalState.RENTING_FLOATING && + !stateData.insideNoRentalDropOffArea) || + (getRequest() .preferences() .rental(getRequest().mode()) .allowArrivingInRentedVehicleAtDestination() && stateData.mayKeepRentedVehicleAtDestination && - stateData.vehicleRentalState == VehicleRentalState.RENTING_FROM_STATION - ) + stateData.vehicleRentalState == VehicleRentalState.RENTING_FROM_STATION) ); } @@ -490,8 +487,7 @@ protected State clone() { } public String toString() { - return ToStringBuilder - .of(State.class) + return ToStringBuilder.of(State.class) .addDateTime("time", getTime()) .addNum("weight", weight) .addObj("vertex", vertex) diff --git a/application/src/main/java/org/opentripplanner/street/search/state/StateData.java b/application/src/main/java/org/opentripplanner/street/search/state/StateData.java index 648b2f3110c..2b0fefb90ea 100644 --- a/application/src/main/java/org/opentripplanner/street/search/state/StateData.java +++ b/application/src/main/java/org/opentripplanner/street/search/state/StateData.java @@ -54,15 +54,14 @@ public class StateData implements Cloneable { /** Private constructor, use static methods to get a set of initial states. */ private StateData(StreetMode requestMode) { - currentMode = - switch (requestMode) { - // when renting or using a flex vehicle, you start on foot until you have found the vehicle - case NOT_SET, WALK, BIKE_RENTAL, SCOOTER_RENTAL, CAR_RENTAL, FLEXIBLE -> TraverseMode.WALK; - // when cycling all the way or to a stop, you start on your own bike - case BIKE, BIKE_TO_PARK -> TraverseMode.BICYCLE; - // when driving (not car rental) you start in your own car or your driver's car - case CAR, CAR_TO_PARK, CAR_PICKUP, CAR_HAILING -> TraverseMode.CAR; - }; + currentMode = switch (requestMode) { + // when renting or using a flex vehicle, you start on foot until you have found the vehicle + case NOT_SET, WALK, BIKE_RENTAL, SCOOTER_RENTAL, CAR_RENTAL, FLEXIBLE -> TraverseMode.WALK; + // when cycling all the way or to a stop, you start on your own bike + case BIKE, BIKE_TO_PARK -> TraverseMode.BICYCLE; + // when driving (not car rental) you start in your own car or your driver's car + case CAR, CAR_TO_PARK, CAR_PICKUP, CAR_HAILING -> TraverseMode.CAR; + }; } /** @@ -105,9 +104,10 @@ public static StateData getBaseCaseStateData(StreetSearchRequest request) { if (request.arriveBy()) { yield stateDatas .stream() - .filter(d -> - d.vehicleRentalState == RENTING_FROM_STATION || - d.vehicleRentalState == RENTING_FLOATING + .filter( + d -> + d.vehicleRentalState == RENTING_FROM_STATION || + d.vehicleRentalState == RENTING_FLOATING ) .toList(); } else { @@ -142,8 +142,9 @@ private static List getInitialStateDatas( inCarPickupStateData.currentMode = TraverseMode.CAR; res.add(inCarPickupStateData); var walkingPickupStateData = proto.clone(); - walkingPickupStateData.carPickupState = - arriveBy ? CarPickupState.WALK_FROM_DROP_OFF : CarPickupState.WALK_TO_PICKUP; + walkingPickupStateData.carPickupState = arriveBy + ? CarPickupState.WALK_FROM_DROP_OFF + : CarPickupState.WALK_TO_PICKUP; walkingPickupStateData.currentMode = TraverseMode.WALK; res.add(walkingPickupStateData); } @@ -184,10 +185,9 @@ else if (requestMode.includesRenting()) { else if (requestMode.includesParking()) { var parkAndRideStateData = proto.clone(); parkAndRideStateData.vehicleParked = arriveBy; - parkAndRideStateData.currentMode = - parkAndRideStateData.vehicleParked - ? TraverseMode.WALK - : requestMode.includesBiking() ? TraverseMode.BICYCLE : TraverseMode.CAR; + parkAndRideStateData.currentMode = parkAndRideStateData.vehicleParked + ? TraverseMode.WALK + : requestMode.includesBiking() ? TraverseMode.BICYCLE : TraverseMode.CAR; res.add(parkAndRideStateData); } else { res.add(proto.clone()); diff --git a/application/src/main/java/org/opentripplanner/street/search/state/StateEditor.java b/application/src/main/java/org/opentripplanner/street/search/state/StateEditor.java index 82bd46e152b..a925b903fff 100644 --- a/application/src/main/java/org/opentripplanner/street/search/state/StateEditor.java +++ b/application/src/main/java/org/opentripplanner/street/search/state/StateEditor.java @@ -322,8 +322,9 @@ public void dropFloatingVehicle(RentalFormFactor formFactor, String network, boo if (reverse) { child.stateData.mayKeepRentedVehicleAtDestination = false; child.stateData.vehicleRentalState = VehicleRentalState.RENTING_FLOATING; - child.stateData.currentMode = - formFactor != null ? formFactor.traverseMode : TraverseMode.BICYCLE; + child.stateData.currentMode = formFactor != null + ? formFactor.traverseMode + : TraverseMode.BICYCLE; child.stateData.vehicleRentalNetwork = network; child.stateData.rentalVehicleFormFactor = formFactor; } else { diff --git a/application/src/main/java/org/opentripplanner/transit/model/basic/Distance.java b/application/src/main/java/org/opentripplanner/transit/model/basic/Distance.java index 04c6c1bbf6f..cac86256b5d 100644 --- a/application/src/main/java/org/opentripplanner/transit/model/basic/Distance.java +++ b/application/src/main/java/org/opentripplanner/transit/model/basic/Distance.java @@ -25,13 +25,9 @@ private Distance(int distanceInMillimeters) { * {@link IllegalArgumentException} if the distance is negative. */ private static Distance of(int distanceInMillimeters) { - return of( - distanceInMillimeters, - errMsg -> { - throw new IllegalArgumentException(errMsg); - } - ) - .orElseThrow(); + return of(distanceInMillimeters, errMsg -> { + throw new IllegalArgumentException(errMsg); + }).orElseThrow(); } private static Optional of( @@ -98,13 +94,11 @@ public int hashCode() { @Override public String toString() { if (millimeters > MILLIMETERS_PER_KM) { - return ValueObjectToStringBuilder - .of() + return ValueObjectToStringBuilder.of() .addNum((double) this.millimeters / (double) MILLIMETERS_PER_KM, "km") .toString(); } else { - return ValueObjectToStringBuilder - .of() + return ValueObjectToStringBuilder.of() .addNum((double) this.millimeters / (double) MILLIMETERS_PER_M, "m") .toString(); } diff --git a/application/src/main/java/org/opentripplanner/transit/model/basic/MainAndSubMode.java b/application/src/main/java/org/opentripplanner/transit/model/basic/MainAndSubMode.java index 030e5b5ac63..2b45c65c98b 100644 --- a/application/src/main/java/org/opentripplanner/transit/model/basic/MainAndSubMode.java +++ b/application/src/main/java/org/opentripplanner/transit/model/basic/MainAndSubMode.java @@ -10,8 +10,7 @@ * Tupple of main- and sub-mode. */ public record MainAndSubMode(TransitMode mainMode, @Nullable SubMode subMode) { - private static final List ALL = Stream - .of(TransitMode.values()) + private static final List ALL = Stream.of(TransitMode.values()) .map(MainAndSubMode::new) .toList(); diff --git a/application/src/main/java/org/opentripplanner/transit/model/basic/Ratio.java b/application/src/main/java/org/opentripplanner/transit/model/basic/Ratio.java index 0ca16391475..b2519dd7456 100644 --- a/application/src/main/java/org/opentripplanner/transit/model/basic/Ratio.java +++ b/application/src/main/java/org/opentripplanner/transit/model/basic/Ratio.java @@ -23,13 +23,9 @@ private Ratio(double ratio) { * {@link IllegalArgumentException} if the ratio is not valid. */ public static Ratio of(double ratio) { - return of( - ratio, - errMsg -> { - throw new IllegalArgumentException(errMsg); - } - ) - .orElseThrow(); + return of(ratio, errMsg -> { + throw new IllegalArgumentException(errMsg); + }).orElseThrow(); } public static Optional of(double ratio, Consumer validationErrorHandler) { diff --git a/application/src/main/java/org/opentripplanner/transit/model/basic/TransitMode.java b/application/src/main/java/org/opentripplanner/transit/model/basic/TransitMode.java index 507b033f645..ef18e356539 100644 --- a/application/src/main/java/org/opentripplanner/transit/model/basic/TransitMode.java +++ b/application/src/main/java/org/opentripplanner/transit/model/basic/TransitMode.java @@ -75,10 +75,10 @@ public String enumValueDescription() { case TROLLEYBUS -> "Used for trolleybus systems which draw power from overhead wires using poles on the roof of the vehicle."; case MONORAIL -> "Used for any rail system that runs on a single rail."; case CARPOOL -> """ - Private car trips shared with others. - - This is currently not specified in GTFS so we use the mode type values 1550-1560 which are in the range of private taxis. - """; + Private car trips shared with others. + + This is currently not specified in GTFS so we use the mode type values 1550-1560 which are in the range of private taxis. + """; case TAXI -> "Using a taxi service"; }; } diff --git a/application/src/main/java/org/opentripplanner/transit/model/filter/transit/RouteMatcherFactory.java b/application/src/main/java/org/opentripplanner/transit/model/filter/transit/RouteMatcherFactory.java index da7a614deec..e28b78145f5 100644 --- a/application/src/main/java/org/opentripplanner/transit/model/filter/transit/RouteMatcherFactory.java +++ b/application/src/main/java/org/opentripplanner/transit/model/filter/transit/RouteMatcherFactory.java @@ -88,10 +88,7 @@ static Matcher longName(String name) { return new NullSafeWrapperMatcher<>( "longName", Route::getLongName, - new CaseInsensitiveStringPrefixMatcher<>( - "name", - name, - route -> route.getLongName().toString() + new CaseInsensitiveStringPrefixMatcher<>("name", name, route -> route.getLongName().toString() ) ); } diff --git a/application/src/main/java/org/opentripplanner/transit/model/filter/transit/TripOnServiceDateMatcherFactory.java b/application/src/main/java/org/opentripplanner/transit/model/filter/transit/TripOnServiceDateMatcherFactory.java index b9e3ff4d3b7..6f456810a6a 100644 --- a/application/src/main/java/org/opentripplanner/transit/model/filter/transit/TripOnServiceDateMatcherFactory.java +++ b/application/src/main/java/org/opentripplanner/transit/model/filter/transit/TripOnServiceDateMatcherFactory.java @@ -65,10 +65,8 @@ static Matcher replacementFor(FeedScopedId id) { } static Matcher netexInternalPlanningCode(String code) { - return new EqualityMatcher<>( - "netexInternalPlanningCode", - code, - t -> t.getTrip().getNetexInternalPlanningCode() + return new EqualityMatcher<>("netexInternalPlanningCode", code, t -> + t.getTrip().getNetexInternalPlanningCode() ); } diff --git a/application/src/main/java/org/opentripplanner/transit/model/framework/Deduplicator.java b/application/src/main/java/org/opentripplanner/transit/model/framework/Deduplicator.java index 69b5385ad86..b3402126f62 100644 --- a/application/src/main/java/org/opentripplanner/transit/model/framework/Deduplicator.java +++ b/application/src/main/java/org/opentripplanner/transit/model/framework/Deduplicator.java @@ -180,10 +180,9 @@ public List deduplicateImmutableList(Class clazz, List original) { Stream stream = original.stream().map(it -> deduplicateObject(clazz, it)); // The list may contain nulls, hence the use of the old unmodifiable wrapper //noinspection SimplifyStreamApiCallChains - canonical = - containsNull - ? Collections.unmodifiableList(stream.collect(Collectors.toList())) - : stream.collect(Collectors.toUnmodifiableList()); + canonical = containsNull + ? Collections.unmodifiableList(stream.collect(Collectors.toList())) + : stream.collect(Collectors.toUnmodifiableList()); canonicalLists.put(canonical, canonical); } @@ -196,8 +195,7 @@ public List deduplicateImmutableList(Class clazz, List original) { */ @Override public String toString() { - var builder = ToStringBuilder - .of(Deduplicator.class) + var builder = ToStringBuilder.of(Deduplicator.class) .addObj("BitSet", sizeAndCount(canonicalBitSets.size(), BitSet.class), ZERO_COUNT) .addObj("int[]", sizeAndCount(canonicalIntArrays.size(), IntArray.class), ZERO_COUNT) .addObj("String", sizeAndCount(canonicalStrings.size(), String.class), ZERO_COUNT) diff --git a/application/src/main/java/org/opentripplanner/transit/model/framework/FeedScopedId.java b/application/src/main/java/org/opentripplanner/transit/model/framework/FeedScopedId.java index 0b269220ae1..70cfbf79164 100644 --- a/application/src/main/java/org/opentripplanner/transit/model/framework/FeedScopedId.java +++ b/application/src/main/java/org/opentripplanner/transit/model/framework/FeedScopedId.java @@ -63,8 +63,7 @@ public static List parseList(String s) { "The input string '%s' contains invisible characters which is not allowed.".formatted(s) ); } - return Arrays - .stream(s.split(",")) + return Arrays.stream(s.split(",")) .map(String::strip) .filter(i -> !i.isBlank()) .map(FeedScopedId::parse) diff --git a/application/src/main/java/org/opentripplanner/transit/model/network/StopPattern.java b/application/src/main/java/org/opentripplanner/transit/model/network/StopPattern.java index 9df095d5170..1bd5ed0e286 100644 --- a/application/src/main/java/org/opentripplanner/transit/model/network/StopPattern.java +++ b/application/src/main/java/org/opentripplanner/transit/model/network/StopPattern.java @@ -294,13 +294,11 @@ boolean sameStations(StopPattern other, int index) { var origin = getStop(index).getParentStation(); var destionation = getStop(index + 1).getParentStation(); - var sameOrigin = Optional - .ofNullable(origin) + var sameOrigin = Optional.ofNullable(origin) .map(o -> o.equals(otherOrigin)) .orElse(getStop(index).equals(other.getStop(index))); - var sameDestination = Optional - .ofNullable(destionation) + var sameDestination = Optional.ofNullable(destionation) .map(o -> o.equals(otherDestination)) .orElse(getStop(index + 1).equals(other.getStop(index + 1))); diff --git a/application/src/main/java/org/opentripplanner/transit/model/network/TripPattern.java b/application/src/main/java/org/opentripplanner/transit/model/network/TripPattern.java index 88d48d741f3..2b952f451e0 100644 --- a/application/src/main/java/org/opentripplanner/transit/model/network/TripPattern.java +++ b/application/src/main/java/org/opentripplanner/transit/model/network/TripPattern.java @@ -136,8 +136,10 @@ public final class TripPattern } this.scheduledTimetable = builder.getScheduledTimetable(); } else { - this.scheduledTimetable = - builder.getScheduledTimetableBuilder().withTripPattern(this).build(); + this.scheduledTimetable = builder + .getScheduledTimetableBuilder() + .withTripPattern(this) + .build(); } this.originalTripPattern = builder.getOriginalTripPattern(); @@ -185,8 +187,7 @@ public LineString getHopGeometry(int stopPosInPattern) { if (hopGeometries != null) { return CompactLineStringUtils.uncompactLineString(hopGeometries[stopPosInPattern], false); } else { - return GeometryUtils - .getGeometryFactory() + return GeometryUtils.getGeometryFactory() .createLineString( new Coordinate[] { coordinate(stopPattern.getStop(stopPosInPattern)), diff --git a/application/src/main/java/org/opentripplanner/transit/model/network/TripPatternBuilder.java b/application/src/main/java/org/opentripplanner/transit/model/network/TripPatternBuilder.java index 66f695521c0..92acc2a8691 100644 --- a/application/src/main/java/org/opentripplanner/transit/model/network/TripPatternBuilder.java +++ b/application/src/main/java/org/opentripplanner/transit/model/network/TripPatternBuilder.java @@ -51,13 +51,11 @@ public final class TripPatternBuilder this.scheduledTimetable = original.getScheduledTimetable(); this.createdByRealtimeUpdate = original.isCreatedByRealtimeUpdater(); this.originalTripPattern = original.getOriginalTripPattern(); - this.hopGeometries = - original.getGeometry() == null - ? null - : IntStream - .range(0, original.numberOfStops() - 1) - .mapToObj(original::getHopGeometry) - .toList(); + this.hopGeometries = original.getGeometry() == null + ? null + : IntStream.range(0, original.numberOfStops() - 1) + .mapToObj(original::getHopGeometry) + .toList(); } public TripPatternBuilder withName(String name) { @@ -242,8 +240,7 @@ private List generateHopGeometriesFromOriginalTripPattern() { } else { // Create new straight-line geometry for hop hopGeometries.add( - GeometryUtils - .getGeometryFactory() + GeometryUtils.getGeometryFactory() .createLineString( new Coordinate[] { stopPattern.getStop(i).getCoordinate().asJtsCoordinate(), diff --git a/application/src/main/java/org/opentripplanner/transit/model/network/grouppriority/TransitGroupPriorityService.java b/application/src/main/java/org/opentripplanner/transit/model/network/grouppriority/TransitGroupPriorityService.java index e8172cdf546..3254ed4c4b7 100644 --- a/application/src/main/java/org/opentripplanner/transit/model/network/grouppriority/TransitGroupPriorityService.java +++ b/application/src/main/java/org/opentripplanner/transit/model/network/grouppriority/TransitGroupPriorityService.java @@ -66,8 +66,9 @@ public TransitGroupPriorityService( this.agencyMatchers = Matchers.of(byAgency); this.globalMatchers = Matchers.of(global); this.enabled = Stream.of(agencyMatchers, globalMatchers).anyMatch(ArrayUtils::hasContent); - this.globalMatchersIds = - Arrays.stream(globalMatchers).map(m -> new MatcherAndId(m, nextGroupId())).toList(); + this.globalMatchersIds = Arrays.stream(globalMatchers) + .map(m -> new MatcherAndId(m, nextGroupId())) + .toList(); // We need to populate this dynamically this.agencyMatchersIds = Arrays.stream(agencyMatchers).map(MatcherAgencyAndIds::new).toList(); } diff --git a/application/src/main/java/org/opentripplanner/transit/model/organization/Agency.java b/application/src/main/java/org/opentripplanner/transit/model/organization/Agency.java index 978cf0ca416..0a6431f2b40 100644 --- a/application/src/main/java/org/opentripplanner/transit/model/organization/Agency.java +++ b/application/src/main/java/org/opentripplanner/transit/model/organization/Agency.java @@ -25,17 +25,19 @@ public final class Agency extends AbstractTransitEntity i Agency(AgencyBuilder builder) { super(builder.getId()); // Required fields - this.name = - assertHasValue(builder.getName(), "Missing mandatory name on Agency %s", builder.getId()); - - this.timezone = - ZoneId.of( - assertHasValue( - builder.getTimezone(), - "Missing mandatory time zone on Agency %s", - builder.getId() - ) - ); + this.name = assertHasValue( + builder.getName(), + "Missing mandatory name on Agency %s", + builder.getId() + ); + + this.timezone = ZoneId.of( + assertHasValue( + builder.getTimezone(), + "Missing mandatory time zone on Agency %s", + builder.getId() + ) + ); // Optional fields this.url = builder.getUrl(); diff --git a/application/src/main/java/org/opentripplanner/transit/model/organization/ContactInfo.java b/application/src/main/java/org/opentripplanner/transit/model/organization/ContactInfo.java index d54b38dba24..ccdb0a846aa 100644 --- a/application/src/main/java/org/opentripplanner/transit/model/organization/ContactInfo.java +++ b/application/src/main/java/org/opentripplanner/transit/model/organization/ContactInfo.java @@ -106,8 +106,7 @@ public int hashCode() { @Override public String toString() { - return ToStringBuilder - .of(ContactInfo.class) + return ToStringBuilder.of(ContactInfo.class) .addStr("contactPerson", contactPerson) .addStr("phoneNumber", phoneNumber) .addStr("eMail", eMail) diff --git a/application/src/main/java/org/opentripplanner/transit/model/organization/Operator.java b/application/src/main/java/org/opentripplanner/transit/model/organization/Operator.java index 35461fd7498..998e7fdae87 100644 --- a/application/src/main/java/org/opentripplanner/transit/model/organization/Operator.java +++ b/application/src/main/java/org/opentripplanner/transit/model/organization/Operator.java @@ -25,8 +25,11 @@ public class Operator extends AbstractTransitEntity i Operator(OperatorBuilder builder) { super(builder.getId()); // Required fields - this.name = - assertHasValue(builder.getName(), "Missing mandatory name on Operator %s", builder.getId()); + this.name = assertHasValue( + builder.getName(), + "Missing mandatory name on Operator %s", + builder.getId() + ); // Optional fields this.url = builder.getUrl(); diff --git a/application/src/main/java/org/opentripplanner/transit/model/site/GroupStopBuilder.java b/application/src/main/java/org/opentripplanner/transit/model/site/GroupStopBuilder.java index c51b704aa33..08917434149 100644 --- a/application/src/main/java/org/opentripplanner/transit/model/site/GroupStopBuilder.java +++ b/application/src/main/java/org/opentripplanner/transit/model/site/GroupStopBuilder.java @@ -54,11 +54,10 @@ public GroupStopBuilder withName(I18NString name) { } public GroupStopBuilder withEncompassingAreaGeometries(List geometries) { - this.encompassingAreaGeometry = - new GeometryCollection( - geometries.toArray(new Geometry[0]), - GeometryUtils.getGeometryFactory() - ); + this.encompassingAreaGeometry = new GeometryCollection( + geometries.toArray(new Geometry[0]), + GeometryUtils.getGeometryFactory() + ); return this; } @@ -68,10 +67,8 @@ public I18NString name() { public GroupStopBuilder addLocation(StopLocation location) { if ( - !( - location.getStopType() == StopType.REGULAR || - location.getStopType() == StopType.FLEXIBLE_AREA - ) + !(location.getStopType() == StopType.REGULAR || + location.getStopType() == StopType.FLEXIBLE_AREA) ) { throw new RuntimeException( String.format( diff --git a/application/src/main/java/org/opentripplanner/transit/model/site/Station.java b/application/src/main/java/org/opentripplanner/transit/model/site/Station.java index c8d2558a5cd..78b2ff027b4 100644 --- a/application/src/main/java/org/opentripplanner/transit/model/site/Station.java +++ b/application/src/main/java/org/opentripplanner/transit/model/site/Station.java @@ -51,8 +51,10 @@ public class Station this.name = Objects.requireNonNull(builder.getName()); this.coordinate = Objects.requireNonNull(builder.getCoordinate()); this.shouldRouteToCentroid = builder.shouldRouteToCentroid(); - this.priority = - Objects.requireNonNullElse(builder.getPriority(), StopTransferPriority.defaultValue()); + this.priority = Objects.requireNonNullElse( + builder.getPriority(), + StopTransferPriority.defaultValue() + ); this.transfersNotAllowed = builder.isTransfersNotAllowed(); // Optional fields diff --git a/application/src/main/java/org/opentripplanner/transit/model/site/StationElement.java b/application/src/main/java/org/opentripplanner/transit/model/site/StationElement.java index f1bef4d6c34..5962b07ea97 100644 --- a/application/src/main/java/org/opentripplanner/transit/model/site/StationElement.java +++ b/application/src/main/java/org/opentripplanner/transit/model/site/StationElement.java @@ -35,8 +35,10 @@ public abstract class StationElement< super(builder.getId()); // Required fields this.name = builder.name(); - this.wheelchairAccessibility = - Objects.requireNonNullElse(builder.wheelchairAccessibility(), Accessibility.NO_INFORMATION); + this.wheelchairAccessibility = Objects.requireNonNullElse( + builder.wheelchairAccessibility(), + Accessibility.NO_INFORMATION + ); // Optional fields this.coordinate = builder.coordinate(); diff --git a/application/src/main/java/org/opentripplanner/transit/model/timetable/OccupancyStatus.java b/application/src/main/java/org/opentripplanner/transit/model/timetable/OccupancyStatus.java index fe760747ef4..ae1bc447f91 100644 --- a/application/src/main/java/org/opentripplanner/transit/model/timetable/OccupancyStatus.java +++ b/application/src/main/java/org/opentripplanner/transit/model/timetable/OccupancyStatus.java @@ -29,39 +29,39 @@ public String enumValueDescription() { return switch (this) { case NO_DATA_AVAILABLE -> "The vehicle or carriage doesn't have any occupancy data available."; case EMPTY -> """ - The vehicle is considered empty by most measures, and has few or no passengers onboard, but is - still accepting passengers. There isn't a big difference between this and `manySeatsAvailable` - so it's possible to handle them as the same value, if one wants to limit the number of different - values. - SIRI nordic profile: merge these into `manySeatsAvailable`. - """; + The vehicle is considered empty by most measures, and has few or no passengers onboard, but is + still accepting passengers. There isn't a big difference between this and `manySeatsAvailable` + so it's possible to handle them as the same value, if one wants to limit the number of different + values. + SIRI nordic profile: merge these into `manySeatsAvailable`. + """; case MANY_SEATS_AVAILABLE -> """ - The vehicle or carriage has a large number of seats available. - SIRI nordic profile: more than ~50% of seats available. - """; + The vehicle or carriage has a large number of seats available. + SIRI nordic profile: more than ~50% of seats available. + """; case FEW_SEATS_AVAILABLE -> """ - The vehicle or carriage has a few seats available. - SIRI nordic profile: less than ~50% of seats available. - """; + The vehicle or carriage has a few seats available. + SIRI nordic profile: less than ~50% of seats available. + """; case STANDING_ROOM_ONLY -> """ - The vehicle or carriage only has standing room available. - SIRI nordic profile: less than ~10% of seats available. - """; + The vehicle or carriage only has standing room available. + SIRI nordic profile: less than ~10% of seats available. + """; case CRUSHED_STANDING_ROOM_ONLY -> """ - The vehicle or carriage can currently accommodate only standing passengers and has limited - space for them. There isn't a big difference between this and `full` so it's possible to - handle them as the same value, if one wants to limit the number of different values. - SIRI nordic profile: merge into `standingRoomOnly`. - """; + The vehicle or carriage can currently accommodate only standing passengers and has limited + space for them. There isn't a big difference between this and `full` so it's possible to + handle them as the same value, if one wants to limit the number of different values. + SIRI nordic profile: merge into `standingRoomOnly`. + """; case FULL -> """ - The vehicle or carriage is considered full by most measures, but may still be allowing - passengers to board. - """; + The vehicle or carriage is considered full by most measures, but may still be allowing + passengers to board. + """; case NOT_ACCEPTING_PASSENGERS -> """ - The vehicle or carriage has no seats or standing room available. - SIRI nordic profile: if vehicle/carriage is not in use / unavailable, or passengers are only - allowed to alight due to e.g. crowding. - """; + The vehicle or carriage has no seats or standing room available. + SIRI nordic profile: if vehicle/carriage is not in use / unavailable, or passengers are only + allowed to alight due to e.g. crowding. + """; }; } } diff --git a/application/src/main/java/org/opentripplanner/transit/model/timetable/RealTimeTripTimes.java b/application/src/main/java/org/opentripplanner/transit/model/timetable/RealTimeTripTimes.java index 0568e48940c..34ef0883747 100644 --- a/application/src/main/java/org/opentripplanner/transit/model/timetable/RealTimeTripTimes.java +++ b/application/src/main/java/org/opentripplanner/transit/model/timetable/RealTimeTripTimes.java @@ -384,8 +384,10 @@ public int getServiceCode() { } public void setServiceCode(int serviceCode) { - this.scheduledTripTimes = - scheduledTripTimes.copyOfNoDuplication().withServiceCode(serviceCode).build(); + this.scheduledTripTimes = scheduledTripTimes + .copyOfNoDuplication() + .withServiceCode(serviceCode) + .build(); } @Override diff --git a/application/src/main/java/org/opentripplanner/transit/model/timetable/ScheduledTripTimesBuilder.java b/application/src/main/java/org/opentripplanner/transit/model/timetable/ScheduledTripTimesBuilder.java index acca4a6a526..f6e30e36d37 100644 --- a/application/src/main/java/org/opentripplanner/transit/model/timetable/ScheduledTripTimesBuilder.java +++ b/application/src/main/java/org/opentripplanner/transit/model/timetable/ScheduledTripTimesBuilder.java @@ -136,8 +136,10 @@ public List dropOffBookingInfos() { } public ScheduledTripTimesBuilder withDropOffBookingInfos(List dropOffBookingInfos) { - this.dropOffBookingInfos = - deduplicator.deduplicateImmutableList(BookingInfo.class, dropOffBookingInfos); + this.dropOffBookingInfos = deduplicator.deduplicateImmutableList( + BookingInfo.class, + dropOffBookingInfos + ); return this; } @@ -146,8 +148,10 @@ public List pickupBookingInfos() { } public ScheduledTripTimesBuilder withPickupBookingInfos(List pickupBookingInfos) { - this.pickupBookingInfos = - deduplicator.deduplicateImmutableList(BookingInfo.class, pickupBookingInfos); + this.pickupBookingInfos = deduplicator.deduplicateImmutableList( + BookingInfo.class, + pickupBookingInfos + ); return this; } diff --git a/application/src/main/java/org/opentripplanner/transit/model/timetable/Trip.java b/application/src/main/java/org/opentripplanner/transit/model/timetable/Trip.java index 057adacd7ed..810cf16b0f8 100644 --- a/application/src/main/java/org/opentripplanner/transit/model/timetable/Trip.java +++ b/application/src/main/java/org/opentripplanner/transit/model/timetable/Trip.java @@ -72,15 +72,16 @@ public final class Trip extends AbstractTransitEntity impleme // Route is done first, it is used as a fallback for some fields this.route = requireNonNull(builder.getRoute()); this.mode = requireNonNullElse(builder.getMode(), route.getMode()); - this.netexSubmode = - builder.getNetexSubmode() != null - ? SubMode.getOrBuildAndCacheForever(builder.getNetexSubmode()) - : route.getNetexSubmode(); + this.netexSubmode = builder.getNetexSubmode() != null + ? SubMode.getOrBuildAndCacheForever(builder.getNetexSubmode()) + : route.getNetexSubmode(); this.direction = requireNonNullElse(builder.getDirection(), Direction.UNKNOWN); this.bikesAllowed = requireNonNullElse(builder.getBikesAllowed(), route.getBikesAllowed()); this.carsAllowed = requireNonNullElse(builder.getCarsAllowed(), CarAccess.UNKNOWN); - this.wheelchairBoarding = - requireNonNullElse(builder.getWheelchairBoarding(), Accessibility.NO_INFORMATION); + this.wheelchairBoarding = requireNonNullElse( + builder.getWheelchairBoarding(), + Accessibility.NO_INFORMATION + ); this.netexAlteration = requireNonNullElse(builder.getNetexAlteration(), TripAlteration.PLANNED); // Optional fields diff --git a/application/src/main/java/org/opentripplanner/transit/model/timetable/booking/BookingInfo.java b/application/src/main/java/org/opentripplanner/transit/model/timetable/booking/BookingInfo.java index 8b48a61ffbe..8362633068e 100644 --- a/application/src/main/java/org/opentripplanner/transit/model/timetable/booking/BookingInfo.java +++ b/application/src/main/java/org/opentripplanner/transit/model/timetable/booking/BookingInfo.java @@ -125,8 +125,7 @@ public String getDropOffMessage() { @Override public String toString() { - return ToStringBuilder - .of(BookingInfo.class) + return ToStringBuilder.of(BookingInfo.class) .addObj("contactInfo", contactInfo) .addObj("bookingMethods", bookingMethods) .addObj("earliestBookingTime", earliestBookingTime) diff --git a/application/src/main/java/org/opentripplanner/transit/model/timetable/booking/RoutingBookingInfo.java b/application/src/main/java/org/opentripplanner/transit/model/timetable/booking/RoutingBookingInfo.java index 11ea27d48aa..8a6367f2035 100644 --- a/application/src/main/java/org/opentripplanner/transit/model/timetable/booking/RoutingBookingInfo.java +++ b/application/src/main/java/org/opentripplanner/transit/model/timetable/booking/RoutingBookingInfo.java @@ -111,8 +111,7 @@ public int hashCode() { @Override public String toString() { - return ToStringBuilder - .of(RoutingBookingInfo.class) + return ToStringBuilder.of(RoutingBookingInfo.class) .addServiceTime("latestBookingTime", latestBookingTime, NOT_SET) .addDurationSec("minimumBookingNotice", minimumBookingNotice, NOT_SET) .toString(); @@ -156,14 +155,16 @@ Builder withBookingInfo(@Nullable BookingInfo bookingInfo) { } public Builder withLatestBookingTime(@Nullable BookingTime latestBookingTime) { - this.latestBookingTime = - latestBookingTime == null ? NOT_SET : latestBookingTime.relativeTimeSeconds(); + this.latestBookingTime = latestBookingTime == null + ? NOT_SET + : latestBookingTime.relativeTimeSeconds(); return this; } public Builder withMinimumBookingNotice(@Nullable Duration minimumBookingNotice) { - this.minimumBookingNotice = - minimumBookingNotice == null ? NOT_SET : (int) minimumBookingNotice.toSeconds(); + this.minimumBookingNotice = minimumBookingNotice == null + ? NOT_SET + : (int) minimumBookingNotice.toSeconds(); return this; } diff --git a/application/src/main/java/org/opentripplanner/transit/service/DefaultTransitService.java b/application/src/main/java/org/opentripplanner/transit/service/DefaultTransitService.java index 3b69ee0f9ff..6517cced249 100644 --- a/application/src/main/java/org/opentripplanner/transit/service/DefaultTransitService.java +++ b/application/src/main/java/org/opentripplanner/transit/service/DefaultTransitService.java @@ -133,9 +133,10 @@ public Optional> getTripTimeOnDates(Trip trip, LocalDate se ) { return Optional.empty(); } else { - Instant midnight = ServiceDateUtils - .asStartOfService(serviceDate, this.getTimeZone()) - .toInstant(); + Instant midnight = ServiceDateUtils.asStartOfService( + serviceDate, + this.getTimeZone() + ).toInstant(); return Optional.of(TripTimeOnDate.fromTripTimes(timetable, trip, serviceDate, midnight)); } } @@ -400,9 +401,8 @@ public Collection findPatterns(Route route) { timetableRepositoryIndex.getPatternsForRoute(route) ); if (timetableSnapshot != null) { - Collection realTimeAddedPatternForRoute = timetableSnapshot.getRealTimeAddedPatternForRoute( - route - ); + Collection realTimeAddedPatternForRoute = + timetableSnapshot.getRealTimeAddedPatternForRoute(route); tripPatterns.addAll(realTimeAddedPatternForRoute); } return tripPatterns; @@ -603,9 +603,8 @@ public Collection listTripsOnServiceDate() { @Override public TripOnServiceDate getTripOnServiceDate(TripIdAndServiceDate tripIdAndServiceDate) { if (timetableSnapshot != null) { - TripOnServiceDate tripOnServiceDate = timetableSnapshot.getRealTimeAddedTripOnServiceDateForTripAndDay( - tripIdAndServiceDate - ); + TripOnServiceDate tripOnServiceDate = + timetableSnapshot.getRealTimeAddedTripOnServiceDateForTripAndDay(tripIdAndServiceDate); if (tripOnServiceDate != null) { return tripOnServiceDate; } @@ -737,9 +736,8 @@ public Collection findRegularStopsByBoundingBox( .getSiteRepository() .findRegularStops(request.envelope()); - Matcher matcher = RegularStopMatcherFactory.of( - request, - stop -> !findPatterns(stop, true).isEmpty() + Matcher matcher = RegularStopMatcherFactory.of(request, stop -> + !findPatterns(stop, true).isEmpty() ); return stops.stream().filter(matcher::match).toList(); } @@ -759,8 +757,7 @@ public GraphUpdaterStatus getUpdaterStatus() { public List findTransitModes(StopLocationsGroup station) { return sortByOccurrenceAndReduce( station.getChildStops().stream().flatMap(this::getPatternModesOfStop) - ) - .toList(); + ).toList(); } @Override diff --git a/application/src/main/java/org/opentripplanner/transit/service/SiteRepository.java b/application/src/main/java/org/opentripplanner/transit/service/SiteRepository.java index a2a4adea931..dc0ab3c9c1e 100644 --- a/application/src/main/java/org/opentripplanner/transit/service/SiteRepository.java +++ b/application/src/main/java/org/opentripplanner/transit/service/SiteRepository.java @@ -71,11 +71,15 @@ private SiteRepository(SiteRepository main, SiteRepository child) { this.stopIndexCounter = assertSameStopIndexCounterIsUsedToCreateBothModels(main, child); this.areaStopById = MapUtils.combine(main.areaStopById, child.areaStopById); this.regularStopById = MapUtils.combine(main.regularStopById, child.regularStopById); - this.groupOfStationsById = - MapUtils.combine(main.groupOfStationsById, child.groupOfStationsById); + this.groupOfStationsById = MapUtils.combine( + main.groupOfStationsById, + child.groupOfStationsById + ); this.groupStopById = MapUtils.combine(main.groupStopById, child.groupStopById); - this.multiModalStationById = - MapUtils.combine(main.multiModalStationById, child.multiModalStationById); + this.multiModalStationById = MapUtils.combine( + main.multiModalStationById, + child.multiModalStationById + ); this.stationById = MapUtils.combine(main.stationById, child.stationById); reindex(); } diff --git a/application/src/main/java/org/opentripplanner/transit/service/StopModelIndex.java b/application/src/main/java/org/opentripplanner/transit/service/StopModelIndex.java index effa8f95f7e..8f364bafd45 100644 --- a/application/src/main/java/org/opentripplanner/transit/service/StopModelIndex.java +++ b/application/src/main/java/org/opentripplanner/transit/service/StopModelIndex.java @@ -28,7 +28,8 @@ class SiteRepositoryIndex { private static final Logger LOG = LoggerFactory.getLogger(SiteRepositoryIndex.class); - private final HashGridSpatialIndex regularStopSpatialIndex = new HashGridSpatialIndex<>(); + private final HashGridSpatialIndex regularStopSpatialIndex = + new HashGridSpatialIndex<>(); private final Map multiModalStationForStations = new HashMap<>(); private final HashGridSpatialIndex locationIndex = new HashGridSpatialIndex<>(); private final StopLocation[] stopsByIndex; @@ -110,9 +111,11 @@ private void logHolesInIndex() { if (c > 0) { double p = (100.0 * c) / stopsByIndex.length; // Log this as warning if more than 5% of the space is null - LOG - .atLevel(p >= 5.0 ? Level.WARN : Level.INFO) - .log("The stop index contains holes in it. {} of {} is null.", c, stopsByIndex.length); + LOG.atLevel(p >= 5.0 ? Level.WARN : Level.INFO).log( + "The stop index contains holes in it. {} of {} is null.", + c, + stopsByIndex.length + ); } } } diff --git a/application/src/main/java/org/opentripplanner/transit/service/TimetableRepository.java b/application/src/main/java/org/opentripplanner/transit/service/TimetableRepository.java index 6e3c52430be..39460219b74 100644 --- a/application/src/main/java/org/opentripplanner/transit/service/TimetableRepository.java +++ b/application/src/main/java/org/opentripplanner/transit/service/TimetableRepository.java @@ -111,7 +111,8 @@ public class TimetableRepository implements Serializable { * An optionally present second RaptorTransitData representing the contents of this TimetableRepository plus * the results of realtime updates in the latest TimetableSnapshot. */ - private final transient ConcurrentPublished realtimeRaptorTransitData = new ConcurrentPublished<>(); + private final transient ConcurrentPublished realtimeRaptorTransitData = + new ConcurrentPublished<>(); private final transient Deduplicator deduplicator; @@ -354,10 +355,8 @@ public void validateTimeZones() { Collection zones = getAgencyTimeZones(); if (zones.size() > 1) { throw new IllegalStateException( - ( - "The graph contains agencies with different time zones: %s. " + - "Please configure the one to be used in the %s" - ).formatted(zones, BUILD_CONFIG_FILENAME) + ("The graph contains agencies with different time zones: %s. " + + "Please configure the one to be used in the %s").formatted(zones, BUILD_CONFIG_FILENAME) ); } } diff --git a/application/src/main/java/org/opentripplanner/transit/service/TimetableRepositoryIndex.java b/application/src/main/java/org/opentripplanner/transit/service/TimetableRepositoryIndex.java index ca52b710957..3e1c3c72ed3 100644 --- a/application/src/main/java/org/opentripplanner/transit/service/TimetableRepositoryIndex.java +++ b/application/src/main/java/org/opentripplanner/transit/service/TimetableRepositoryIndex.java @@ -51,7 +51,8 @@ class TimetableRepositoryIndex { private final Multimap patternsForStop = ArrayListMultimap.create(); private final Map serviceCodesRunningForDate = new HashMap<>(); - private final Map tripOnServiceDateForTripAndDay = new HashMap<>(); + private final Map tripOnServiceDateForTripAndDay = + new HashMap<>(); private final Multimap routesForGroupOfRoutes = ArrayListMultimap.create(); diff --git a/application/src/main/java/org/opentripplanner/updater/GraphUpdaterManager.java b/application/src/main/java/org/opentripplanner/updater/GraphUpdaterManager.java index c97e099a1f2..cd12f35bb03 100644 --- a/application/src/main/java/org/opentripplanner/updater/GraphUpdaterManager.java +++ b/application/src/main/java/org/opentripplanner/updater/GraphUpdaterManager.java @@ -76,11 +76,10 @@ public GraphUpdaterManager(RealTimeUpdateContext context, List upd var graphWriterThreadFactory = new ThreadFactoryBuilder().setNameFormat("graph-writer").build(); this.scheduler = Executors.newSingleThreadScheduledExecutor(graphWriterThreadFactory); var updaterThreadFactory = new ThreadFactoryBuilder().setNameFormat("updater-%d").build(); - this.pollingUpdaterPool = - Executors.newScheduledThreadPool( - Math.max(MIN_POLLING_UPDATER_THREADS, Runtime.getRuntime().availableProcessors()), - updaterThreadFactory - ); + this.pollingUpdaterPool = Executors.newScheduledThreadPool( + Math.max(MIN_POLLING_UPDATER_THREADS, Runtime.getRuntime().availableProcessors()), + updaterThreadFactory + ); this.nonPollingUpdaterPool = Executors.newCachedThreadPool(updaterThreadFactory); for (GraphUpdater updater : updaters) { @@ -265,30 +264,30 @@ public ScheduledExecutorService getScheduler() { * mostly idle, and it is short-lived, so the busy-wait is a compromise. */ private void reportReadinessForUpdaters() { - Executors - .newSingleThreadExecutor(new ThreadFactoryBuilder().setNameFormat("updater-ready").build()) - .submit(() -> { - boolean otpIsShuttingDown = false; + Executors.newSingleThreadExecutor( + new ThreadFactoryBuilder().setNameFormat("updater-ready").build() + ).submit(() -> { + boolean otpIsShuttingDown = false; - while (!otpIsShuttingDown) { - try { - if (updaterList.stream().allMatch(GraphUpdater::isPrimed)) { - LOG.info( - "OTP UPDATERS INITIALIZED ({} updaters) - OTP is ready for routing!", - updaterList.size() - ); - return; - } - //noinspection BusyWait - Thread.sleep(1000); - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - otpIsShuttingDown = true; - LOG.info("OTP is shutting down, cancelling wait for updaters readiness."); - } catch (Exception e) { - LOG.error(e.getMessage(), e); + while (!otpIsShuttingDown) { + try { + if (updaterList.stream().allMatch(GraphUpdater::isPrimed)) { + LOG.info( + "OTP UPDATERS INITIALIZED ({} updaters) - OTP is ready for routing!", + updaterList.size() + ); + return; } + //noinspection BusyWait + Thread.sleep(1000); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + otpIsShuttingDown = true; + LOG.info("OTP is shutting down, cancelling wait for updaters readiness."); + } catch (Exception e) { + LOG.error(e.getMessage(), e); } - }); + } + }); } } diff --git a/application/src/main/java/org/opentripplanner/updater/TimetableSnapshotParameters.java b/application/src/main/java/org/opentripplanner/updater/TimetableSnapshotParameters.java index 47b0ffc6ad8..3cb2e2903c4 100644 --- a/application/src/main/java/org/opentripplanner/updater/TimetableSnapshotParameters.java +++ b/application/src/main/java/org/opentripplanner/updater/TimetableSnapshotParameters.java @@ -12,10 +12,8 @@ public record TimetableSnapshotParameters(Duration maxSnapshotFrequency, boolean true ); - public static final TimetableSnapshotParameters PUBLISH_IMMEDIATELY = new TimetableSnapshotParameters( - Duration.ZERO, - false - ); + public static final TimetableSnapshotParameters PUBLISH_IMMEDIATELY = + new TimetableSnapshotParameters(Duration.ZERO, false); /* Factory functions, used instead of a builder - useful in tests. */ diff --git a/application/src/main/java/org/opentripplanner/updater/alert/gtfs/AlertsUpdateHandler.java b/application/src/main/java/org/opentripplanner/updater/alert/gtfs/AlertsUpdateHandler.java index 6fffd36aadd..0e4473336e5 100644 --- a/application/src/main/java/org/opentripplanner/updater/alert/gtfs/AlertsUpdateHandler.java +++ b/application/src/main/java/org/opentripplanner/updater/alert/gtfs/AlertsUpdateHandler.java @@ -79,8 +79,7 @@ private TransitAlert mapAlert( GtfsRealtime.Alert alert, GtfsRealtimeFuzzyTripMatcher fuzzyTripMatcher ) { - TransitAlertBuilder alertBuilder = TransitAlert - .of(new FeedScopedId(feedId, id)) + TransitAlertBuilder alertBuilder = TransitAlert.of(new FeedScopedId(feedId, id)) .withDescriptionText(deBuffer(alert.getDescriptionText())) .withHeaderText(deBuffer(alert.getHeaderText())) .withUrl(deBuffer(alert.getUrl())) diff --git a/application/src/main/java/org/opentripplanner/updater/alert/gtfs/mapping/GtfsRealtimeCauseMapper.java b/application/src/main/java/org/opentripplanner/updater/alert/gtfs/mapping/GtfsRealtimeCauseMapper.java index 94147d3c7a7..3ed922c1fe2 100644 --- a/application/src/main/java/org/opentripplanner/updater/alert/gtfs/mapping/GtfsRealtimeCauseMapper.java +++ b/application/src/main/java/org/opentripplanner/updater/alert/gtfs/mapping/GtfsRealtimeCauseMapper.java @@ -40,10 +40,9 @@ public static AlertCause getAlertCauseForGtfsRtCause(Cause cause) { case MEDICAL_EMERGENCY: return AlertCause.MEDICAL_EMERGENCY; case UNKNOWN_CAUSE: - default: - { - return AlertCause.UNKNOWN_CAUSE; - } + default: { + return AlertCause.UNKNOWN_CAUSE; + } } } } diff --git a/application/src/main/java/org/opentripplanner/updater/alert/gtfs/mapping/GtfsRealtimeEffectMapper.java b/application/src/main/java/org/opentripplanner/updater/alert/gtfs/mapping/GtfsRealtimeEffectMapper.java index 85c19cf1525..848bc2d5ee3 100644 --- a/application/src/main/java/org/opentripplanner/updater/alert/gtfs/mapping/GtfsRealtimeEffectMapper.java +++ b/application/src/main/java/org/opentripplanner/updater/alert/gtfs/mapping/GtfsRealtimeEffectMapper.java @@ -38,10 +38,9 @@ public static AlertEffect getAlertEffectForGtfsRtEffect(Effect effect) { case ACCESSIBILITY_ISSUE: return AlertEffect.ACCESSIBILITY_ISSUE; case UNKNOWN_EFFECT: - default: - { - return AlertEffect.UNKNOWN_EFFECT; - } + default: { + return AlertEffect.UNKNOWN_EFFECT; + } } } } diff --git a/application/src/main/java/org/opentripplanner/updater/alert/gtfs/mapping/GtfsRealtimeSeverityMapper.java b/application/src/main/java/org/opentripplanner/updater/alert/gtfs/mapping/GtfsRealtimeSeverityMapper.java index 04a0e74ed78..47a54bf0596 100644 --- a/application/src/main/java/org/opentripplanner/updater/alert/gtfs/mapping/GtfsRealtimeSeverityMapper.java +++ b/application/src/main/java/org/opentripplanner/updater/alert/gtfs/mapping/GtfsRealtimeSeverityMapper.java @@ -24,10 +24,9 @@ public static AlertSeverity getAlertSeverityForGtfsRtSeverity(SeverityLevel seve case SEVERE: return AlertSeverity.SEVERE; case UNKNOWN_SEVERITY: - default: - { - return AlertSeverity.UNKNOWN_SEVERITY; - } + default: { + return AlertSeverity.UNKNOWN_SEVERITY; + } } } } diff --git a/application/src/main/java/org/opentripplanner/updater/alert/siri/SiriAlertsUpdateHandler.java b/application/src/main/java/org/opentripplanner/updater/alert/siri/SiriAlertsUpdateHandler.java index 32b21fc2a38..7b881c5141c 100644 --- a/application/src/main/java/org/opentripplanner/updater/alert/siri/SiriAlertsUpdateHandler.java +++ b/application/src/main/java/org/opentripplanner/updater/alert/siri/SiriAlertsUpdateHandler.java @@ -76,10 +76,8 @@ public void update(ServiceDelivery delivery, RealTimeUpdateContext context) { int expiredCounter = 0; for (PtSituationElement sxElement : situations.getPtSituationElements()) { boolean expireSituation = - ( - sxElement.getProgress() != null && - sxElement.getProgress().equals(WorkflowStatusEnumeration.CLOSED) - ); + (sxElement.getProgress() != null && + sxElement.getProgress().equals(WorkflowStatusEnumeration.CLOSED)); if (sxElement.getSituationNumber() == null) { continue; @@ -185,8 +183,11 @@ private TransitAlert mapSituationToAlert( } alert.addEntites( - new AffectsMapper(feedId, context.siriFuzzyTripMatcher(), context.transitService()) - .mapAffects(situation.getAffects()) + new AffectsMapper( + feedId, + context.siriFuzzyTripMatcher(), + context.transitService() + ).mapAffects(situation.getAffects()) ); if (alert.entities().isEmpty()) { @@ -219,8 +220,7 @@ private long getEpochSecond(ZonedDateTime startTime) { * provided in the SIRI PtSituation. */ private TransitAlertBuilder createAlertWithTexts(PtSituationElement situation) { - return TransitAlert - .of(new FeedScopedId(feedId, situation.getSituationNumber().getValue())) + return TransitAlert.of(new FeedScopedId(feedId, situation.getSituationNumber().getValue())) .withDescriptionText(mapTranslatedString(situation.getDescriptions())) .withDetailText(mapTranslatedString(situation.getDetails())) .withAdviceText(mapTranslatedString(situation.getAdvices())) diff --git a/application/src/main/java/org/opentripplanner/updater/alert/siri/SiriSXUpdater.java b/application/src/main/java/org/opentripplanner/updater/alert/siri/SiriSXUpdater.java index 4d6df4e8631..73e886a7a31 100644 --- a/application/src/main/java/org/opentripplanner/updater/alert/siri/SiriSXUpdater.java +++ b/application/src/main/java/org/opentripplanner/updater/alert/siri/SiriSXUpdater.java @@ -61,19 +61,21 @@ public SiriSXUpdater( this.originalRequestorRef = requestorRef; this.blockReadinessUntilInitialized = config.blockReadinessUntilInitialized(); this.transitAlertService = new TransitAlertServiceImpl(timetableRepository); - this.updateHandler = - new SiriAlertsUpdateHandler(config.feedId(), transitAlertService, config.earlyStart()); + this.updateHandler = new SiriAlertsUpdateHandler( + config.feedId(), + transitAlertService, + config.earlyStart() + ); siriHttpLoader = siriLoader; - retry = - new OtpRetryBuilder() - .withName("SIRI-SX Update") - .withMaxAttempts(RETRY_MAX_ATTEMPTS) - .withInitialRetryInterval(RETRY_INITIAL_DELAY) - .withBackoffMultiplier(RETRY_BACKOFF) - .withRetryableException(OtpHttpClientException.class::isInstance) - .withOnRetry(this::updateRequestorRef) - .build(); + retry = new OtpRetryBuilder() + .withName("SIRI-SX Update") + .withMaxAttempts(RETRY_MAX_ATTEMPTS) + .withInitialRetryInterval(RETRY_INITIAL_DELAY) + .withBackoffMultiplier(RETRY_BACKOFF) + .withRetryableException(OtpHttpClientException.class::isInstance) + .withOnRetry(this::updateRequestorRef) + .build(); LOG.info("Creating SIRI-SX updater running every {}: {}", pollingPeriod(), url); } @@ -89,8 +91,7 @@ protected void runPolling() throws InterruptedException { @Override public String toString() { - return ToStringBuilder - .of(SiriSXUpdater.class) + return ToStringBuilder.of(SiriSXUpdater.class) .addStr("url", url) .addDuration("frequency", pollingPeriod()) .toString(); diff --git a/application/src/main/java/org/opentripplanner/updater/alert/siri/lite/SiriLiteHttpLoader.java b/application/src/main/java/org/opentripplanner/updater/alert/siri/lite/SiriLiteHttpLoader.java index 4c65a4c26d8..afb25106ff1 100644 --- a/application/src/main/java/org/opentripplanner/updater/alert/siri/lite/SiriLiteHttpLoader.java +++ b/application/src/main/java/org/opentripplanner/updater/alert/siri/lite/SiriLiteHttpLoader.java @@ -48,11 +48,8 @@ public Optional fetchETFeed(String ignored) { } private Optional fetchFeed() { - return otpHttpClient.getAndMap( - uri, - timeout, - headers.asMap(), - is -> Optional.of(SiriHelper.unmarshal(is)) + return otpHttpClient.getAndMap(uri, timeout, headers.asMap(), is -> + Optional.of(SiriHelper.unmarshal(is)) ); } } diff --git a/application/src/main/java/org/opentripplanner/updater/alert/siri/mapping/AffectsMapper.java b/application/src/main/java/org/opentripplanner/updater/alert/siri/mapping/AffectsMapper.java index c516c85c0e4..22a06bd0046 100644 --- a/application/src/main/java/org/opentripplanner/updater/alert/siri/mapping/AffectsMapper.java +++ b/application/src/main/java/org/opentripplanner/updater/alert/siri/mapping/AffectsMapper.java @@ -140,7 +140,8 @@ private List mapVehicleJourneys(AffectsScopeStructure.VehicleJou ); } - final FramedVehicleJourneyRefStructure framedVehicleJourneyRef = affectedVehicleJourney.getFramedVehicleJourneyRef(); + final FramedVehicleJourneyRefStructure framedVehicleJourneyRef = + affectedVehicleJourney.getFramedVehicleJourneyRef(); if (framedVehicleJourneyRef != null) { selectors.addAll( mapTripSelectors( @@ -151,7 +152,8 @@ private List mapVehicleJourneys(AffectsScopeStructure.VehicleJou ); } - final List datedVehicleJourneyReves = affectedVehicleJourney.getDatedVehicleJourneyReves(); + final List datedVehicleJourneyReves = + affectedVehicleJourney.getDatedVehicleJourneyReves(); if (isNotEmpty(datedVehicleJourneyReves)) { for (DatedVehicleJourneyRef datedVehicleJourneyRef : datedVehicleJourneyReves) { // Lookup provided reference as if it is a DSJ diff --git a/application/src/main/java/org/opentripplanner/updater/configure/UpdaterConfigurator.java b/application/src/main/java/org/opentripplanner/updater/configure/UpdaterConfigurator.java index dad6a8aacb3..8bb6a64c105 100644 --- a/application/src/main/java/org/opentripplanner/updater/configure/UpdaterConfigurator.java +++ b/application/src/main/java/org/opentripplanner/updater/configure/UpdaterConfigurator.java @@ -87,8 +87,7 @@ public static void configure( timetableRepository, snapshotManager, updatersParameters - ) - .configure(); + ).configure(); } private void configure() { @@ -152,7 +151,8 @@ private List fetchVehicleRentalServicesFromOnlineDirectory( * @return a list of GraphUpdaters created from the configuration */ private List createUpdatersFromConfig() { - OpeningHoursCalendarService openingHoursCalendarService = graph.getOpeningHoursCalendarService(); + OpeningHoursCalendarService openingHoursCalendarService = + graph.getOpeningHoursCalendarService(); List updaters = new ArrayList<>(); @@ -230,10 +230,8 @@ private SiriRealTimeTripUpdateAdapter provideSiriAdapter() { } private GtfsRealTimeTripUpdateAdapter provideGtfsAdapter() { - return new GtfsRealTimeTripUpdateAdapter( - timetableRepository, - snapshotManager, - () -> LocalDate.now(timetableRepository.getTimeZone()) + return new GtfsRealTimeTripUpdateAdapter(timetableRepository, snapshotManager, () -> + LocalDate.now(timetableRepository.getTimeZone()) ); } diff --git a/application/src/main/java/org/opentripplanner/updater/spi/GenericJsonDataSource.java b/application/src/main/java/org/opentripplanner/updater/spi/GenericJsonDataSource.java index 894c0a0466f..922644fdeec 100644 --- a/application/src/main/java/org/opentripplanner/updater/spi/GenericJsonDataSource.java +++ b/application/src/main/java/org/opentripplanner/updater/spi/GenericJsonDataSource.java @@ -26,14 +26,13 @@ protected GenericJsonDataSource( OtpHttpClient otpHttpClient ) { this.url = url; - jsonDataListDownloader = - new JsonDataListDownloader<>( - url, - jsonParsePath, - this::parseElement, - headers.asMap(), - otpHttpClient - ); + jsonDataListDownloader = new JsonDataListDownloader<>( + url, + jsonParsePath, + this::parseElement, + headers.asMap(), + otpHttpClient + ); } @Override diff --git a/application/src/main/java/org/opentripplanner/updater/spi/ResultLogger.java b/application/src/main/java/org/opentripplanner/updater/spi/ResultLogger.java index 9ea737fa0e7..e68aaf25113 100644 --- a/application/src/main/java/org/opentripplanner/updater/spi/ResultLogger.java +++ b/application/src/main/java/org/opentripplanner/updater/spi/ResultLogger.java @@ -24,7 +24,7 @@ public static void logUpdateResult(String feedId, String type, UpdateResult upda type, updateResult.successful(), totalUpdates, - DoubleUtils.roundTo2Decimals((double) updateResult.successful() / totalUpdates * 100) + DoubleUtils.roundTo2Decimals(((double) updateResult.successful() / totalUpdates) * 100) ); logUpdateResultErrors(feedId, type, updateResult); diff --git a/application/src/main/java/org/opentripplanner/updater/trip/gtfs/GtfsRealTimeTripUpdateAdapter.java b/application/src/main/java/org/opentripplanner/updater/trip/gtfs/GtfsRealTimeTripUpdateAdapter.java index fc1e7764e8e..862aff22bfa 100644 --- a/application/src/main/java/org/opentripplanner/updater/trip/gtfs/GtfsRealTimeTripUpdateAdapter.java +++ b/application/src/main/java/org/opentripplanner/updater/trip/gtfs/GtfsRealTimeTripUpdateAdapter.java @@ -115,8 +115,10 @@ public GtfsRealTimeTripUpdateAdapter( this.snapshotManager = snapshotManager; this.timeZone = timetableRepository.getTimeZone(); this.localDateNow = localDateNow; - this.transitEditorService = - new DefaultTransitService(timetableRepository, snapshotManager.getTimetableSnapshotBuffer()); + this.transitEditorService = new DefaultTransitService( + timetableRepository, + snapshotManager.getTimetableSnapshotBuffer() + ); this.deduplicator = timetableRepository.getDeduplicator(); this.serviceCodes = timetableRepository.getServiceCodes(); } @@ -221,41 +223,35 @@ public UpdateResult applyTripUpdates( Result result; try { - result = - switch (scheduleRelationship) { - case SCHEDULED -> handleScheduledTrip( - tripUpdate, - tripId, - serviceDate, - backwardsDelayPropagationType - ); - case ADDED -> validateAndHandleAddedTrip( - tripUpdate, - tripDescriptor, - tripId, - serviceDate - ); - case CANCELED -> handleCanceledTrip( - tripId, - serviceDate, - CancelationType.CANCEL, - updateIncrementality - ); - case DELETED -> handleCanceledTrip( - tripId, - serviceDate, - CancelationType.DELETE, - updateIncrementality - ); - case REPLACEMENT -> validateAndHandleModifiedTrip( - tripUpdate, - tripDescriptor, - tripId, - serviceDate - ); - case UNSCHEDULED -> UpdateError.result(tripId, NOT_IMPLEMENTED_UNSCHEDULED); - case DUPLICATED -> UpdateError.result(tripId, NOT_IMPLEMENTED_DUPLICATED); - }; + result = switch (scheduleRelationship) { + case SCHEDULED -> handleScheduledTrip( + tripUpdate, + tripId, + serviceDate, + backwardsDelayPropagationType + ); + case ADDED -> validateAndHandleAddedTrip(tripUpdate, tripDescriptor, tripId, serviceDate); + case CANCELED -> handleCanceledTrip( + tripId, + serviceDate, + CancelationType.CANCEL, + updateIncrementality + ); + case DELETED -> handleCanceledTrip( + tripId, + serviceDate, + CancelationType.DELETE, + updateIncrementality + ); + case REPLACEMENT -> validateAndHandleModifiedTrip( + tripUpdate, + tripDescriptor, + tripId, + serviceDate + ); + case UNSCHEDULED -> UpdateError.result(tripId, NOT_IMPLEMENTED_UNSCHEDULED); + case DUPLICATED -> UpdateError.result(tripId, NOT_IMPLEMENTED_DUPLICATED); + }; } catch (DataValidationException e) { result = DataValidationExceptionMapper.toResult(e); } @@ -297,10 +293,8 @@ private void purgePatternModifications( ); if ( !isPreviouslyAddedTrip(tripId, pattern, serviceDate) || - ( - tripScheduleRelationship != ScheduleRelationship.CANCELED && - tripScheduleRelationship != ScheduleRelationship.DELETED - ) + (tripScheduleRelationship != ScheduleRelationship.CANCELED && + tripScheduleRelationship != ScheduleRelationship.DELETED) ) { // Remove previous realtime updates for this trip. This is necessary to avoid previous // stop pattern modifications from persisting. If a trip was previously added with the ScheduleRelationship @@ -499,8 +493,14 @@ private Result validateAndHandleAddedTrip( // // Handle added trip // - return handleAddedTrip(tripUpdate, stopTimeUpdates, tripDescriptor, stops, tripId, serviceDate) - .mapSuccess(s -> s.addWarnings(warnings)); + return handleAddedTrip( + tripUpdate, + stopTimeUpdates, + tripDescriptor, + stops, + tripId, + serviceDate + ).mapSuccess(s -> s.addWarnings(warnings)); } /** @@ -655,10 +655,9 @@ private Result handleAddedTrip( Route route; boolean routeExists = routeExists(tripId.getFeedId(), tripDescriptor); if (routeExists) { - route = - transitEditorService.getRoute( - new FeedScopedId(tripId.getFeedId(), tripDescriptor.getRouteId()) - ); + route = transitEditorService.getRoute( + new FeedScopedId(tripId.getFeedId(), tripDescriptor.getRouteId()) + ); } else { route = createRoute(tripDescriptor, tripId); } @@ -745,8 +744,7 @@ private Route createRoute(TripDescriptor tripDescriptor, FeedScopedId tripId) { * Create dummy agency for added trips. */ private Agency fallbackAgency(String feedId) { - return Agency - .of(new FeedScopedId(feedId, "autogenerated-gtfs-rt-added-route")) + return Agency.of(new FeedScopedId(feedId, "autogenerated-gtfs-rt-added-route")) .withName("Agency automatically added by GTFS-RT update") .withTimezone(transitEditorService.getTimeZone().toString()) .build(); @@ -788,9 +786,10 @@ private Result addTripToGraphAndBuffer( ); // Calculate seconds since epoch on GTFS midnight (noon minus 12h) of service date - final long midnightSecondsSinceEpoch = ServiceDateUtils - .asStartOfService(serviceDate, timeZone) - .toEpochSecond(); + final long midnightSecondsSinceEpoch = ServiceDateUtils.asStartOfService( + serviceDate, + timeZone + ).toEpochSecond(); // Create StopTimes final List stopTimes = new ArrayList<>(stopTimeUpdates.size()); @@ -881,17 +880,19 @@ private Result addTripToGraphAndBuffer( if (vehicleDescriptor != null) { if (vehicleDescriptor.hasWheelchairAccessible()) { - GtfsRealtimeMapper - .mapWheelchairAccessible(vehicleDescriptor.getWheelchairAccessible()) - .ifPresent(newTripTimes::updateWheelchairAccessibility); + GtfsRealtimeMapper.mapWheelchairAccessible( + vehicleDescriptor.getWheelchairAccessible() + ).ifPresent(newTripTimes::updateWheelchairAccessibility); } } // create a TripOnServiceDate for added trips TripOnServiceDate tripOnServiceDate = null; if (realTimeState == RealTimeState.ADDED) { - tripOnServiceDate = - TripOnServiceDate.of(trip.getId()).withTrip(trip).withServiceDate(serviceDate).build(); + tripOnServiceDate = TripOnServiceDate.of(trip.getId()) + .withTrip(trip) + .withServiceDate(serviceDate) + .build(); } trace( diff --git a/application/src/main/java/org/opentripplanner/updater/trip/gtfs/TripPatternCache.java b/application/src/main/java/org/opentripplanner/updater/trip/gtfs/TripPatternCache.java index cfbc04138b9..9bda066fcfd 100644 --- a/application/src/main/java/org/opentripplanner/updater/trip/gtfs/TripPatternCache.java +++ b/application/src/main/java/org/opentripplanner/updater/trip/gtfs/TripPatternCache.java @@ -58,16 +58,14 @@ public synchronized TripPattern getOrCreateTripPattern( // Generate unique code for trip pattern var id = generateUniqueTripPatternCode(trip); - tripPattern = - TripPattern - .of(id) - .withRoute(route) - .withMode(trip.getMode()) - .withNetexSubmode(trip.getNetexSubMode()) - .withStopPattern(stopPattern) - .withCreatedByRealtimeUpdater(true) - .withOriginalTripPattern(originalTripPattern) - .build(); + tripPattern = TripPattern.of(id) + .withRoute(route) + .withMode(trip.getMode()) + .withNetexSubmode(trip.getNetexSubMode()) + .withStopPattern(stopPattern) + .withCreatedByRealtimeUpdater(true) + .withOriginalTripPattern(originalTripPattern) + .build(); // Add pattern to cache cache.put(stopPattern, tripPattern); diff --git a/application/src/main/java/org/opentripplanner/updater/trip/gtfs/TripTimesUpdater.java b/application/src/main/java/org/opentripplanner/updater/trip/gtfs/TripTimesUpdater.java index 0aacfc2d82a..9d28fd0cca5 100644 --- a/application/src/main/java/org/opentripplanner/updater/trip/gtfs/TripTimesUpdater.java +++ b/application/src/main/java/org/opentripplanner/updater/trip/gtfs/TripTimesUpdater.java @@ -107,9 +107,10 @@ public static Result createUpdatedTripTimesFromGTFS Integer delay = null; Integer firstUpdatedIndex = null; - final long today = ServiceDateUtils - .asStartOfService(updateServiceDate, timeZone) - .toEpochSecond(); + final long today = ServiceDateUtils.asStartOfService( + updateServiceDate, + timeZone + ).toEpochSecond(); for (int i = 0; i < numStops; i++) { boolean match = false; @@ -122,9 +123,10 @@ public static Result createUpdatedTripTimesFromGTFS } if (match) { - GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship scheduleRelationship = update.hasScheduleRelationship() - ? update.getScheduleRelationship() - : GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED; + GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship scheduleRelationship = + update.hasScheduleRelationship() + ? update.getScheduleRelationship() + : GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED; // Handle each schedule relationship case if ( scheduleRelationship == @@ -227,18 +229,12 @@ public static Result createUpdatedTripTimesFromGTFS // the first SCHEDULED stop sequence included in the GTFS-RT feed. if (firstUpdatedIndex != null && firstUpdatedIndex > 0) { if ( - ( - backwardsDelayPropagationType == BackwardsDelayPropagationType.REQUIRED_NO_DATA && - newTimes.adjustTimesBeforeWhenRequired(firstUpdatedIndex, true) - ) || - ( - backwardsDelayPropagationType == BackwardsDelayPropagationType.REQUIRED && - newTimes.adjustTimesBeforeWhenRequired(firstUpdatedIndex, false) - ) || - ( - backwardsDelayPropagationType == BackwardsDelayPropagationType.ALWAYS && - newTimes.adjustTimesBeforeAlways(firstUpdatedIndex) - ) + (backwardsDelayPropagationType == BackwardsDelayPropagationType.REQUIRED_NO_DATA && + newTimes.adjustTimesBeforeWhenRequired(firstUpdatedIndex, true)) || + (backwardsDelayPropagationType == BackwardsDelayPropagationType.REQUIRED && + newTimes.adjustTimesBeforeWhenRequired(firstUpdatedIndex, false)) || + (backwardsDelayPropagationType == BackwardsDelayPropagationType.ALWAYS && + newTimes.adjustTimesBeforeAlways(firstUpdatedIndex)) ) { LOG.debug( "Propagated delay from stop index {} backwards on trip {}.", @@ -264,9 +260,9 @@ public static Result createUpdatedTripTimesFromGTFS if (tripUpdate.hasVehicle()) { var vehicleDescriptor = tripUpdate.getVehicle(); if (vehicleDescriptor.hasWheelchairAccessible()) { - GtfsRealtimeMapper - .mapWheelchairAccessible(vehicleDescriptor.getWheelchairAccessible()) - .ifPresent(newTimes::updateWheelchairAccessibility); + GtfsRealtimeMapper.mapWheelchairAccessible( + vehicleDescriptor.getWheelchairAccessible() + ).ifPresent(newTimes::updateWheelchairAccessibility); } } diff --git a/application/src/main/java/org/opentripplanner/updater/trip/gtfs/updater/http/HttpTripUpdateSource.java b/application/src/main/java/org/opentripplanner/updater/trip/gtfs/updater/http/HttpTripUpdateSource.java index 40eed35b4c4..91d0226c7cc 100644 --- a/application/src/main/java/org/opentripplanner/updater/trip/gtfs/updater/http/HttpTripUpdateSource.java +++ b/application/src/main/java/org/opentripplanner/updater/trip/gtfs/updater/http/HttpTripUpdateSource.java @@ -48,12 +48,9 @@ public List getUpdates() { updateIncrementality = FULL_DATASET; try { // Decode message - feedMessage = - otpHttpClient.getAndMap( - URI.create(url), - this.headers.asMap(), - is -> FeedMessage.parseFrom(is, registry) - ); + feedMessage = otpHttpClient.getAndMap(URI.create(url), this.headers.asMap(), is -> + FeedMessage.parseFrom(is, registry) + ); feedEntityList = feedMessage.getEntityList(); // Change fullDataset value if this is an incremental update @@ -81,8 +78,7 @@ public List getUpdates() { @Override public String toString() { - return ToStringBuilder - .of(this.getClass()) + return ToStringBuilder.of(this.getClass()) .addStr("feedId", feedId) .addStr("url", url) .toString(); diff --git a/application/src/main/java/org/opentripplanner/updater/trip/gtfs/updater/http/PollingTripUpdater.java b/application/src/main/java/org/opentripplanner/updater/trip/gtfs/updater/http/PollingTripUpdater.java index 33f009f1ac2..7be0a6b52bf 100644 --- a/application/src/main/java/org/opentripplanner/updater/trip/gtfs/updater/http/PollingTripUpdater.java +++ b/application/src/main/java/org/opentripplanner/updater/trip/gtfs/updater/http/PollingTripUpdater.java @@ -89,8 +89,7 @@ public void runPolling() throws InterruptedException, ExecutionException { @Override public String toString() { - return ToStringBuilder - .of(this.getClass()) + return ToStringBuilder.of(this.getClass()) .addObj("updateSource", updateSource) .addStr("feedId", feedId) .addBool("fuzzyTripMatching", fuzzyTripMatching) diff --git a/application/src/main/java/org/opentripplanner/updater/trip/gtfs/updater/mqtt/MqttGtfsRealtimeUpdater.java b/application/src/main/java/org/opentripplanner/updater/trip/gtfs/updater/mqtt/MqttGtfsRealtimeUpdater.java index 69bf171231f..c890c42fb1e 100644 --- a/application/src/main/java/org/opentripplanner/updater/trip/gtfs/updater/mqtt/MqttGtfsRealtimeUpdater.java +++ b/application/src/main/java/org/opentripplanner/updater/trip/gtfs/updater/mqtt/MqttGtfsRealtimeUpdater.java @@ -192,8 +192,7 @@ public void deliveryComplete(IMqttDeliveryToken token) {} @Override public String toString() { - return ToStringBuilder - .of(MqttGtfsRealtimeUpdater.class) + return ToStringBuilder.of(MqttGtfsRealtimeUpdater.class) .addStr("url", url) .addStr("topic", topic) .addStr("feedId", feedId) diff --git a/application/src/main/java/org/opentripplanner/updater/trip/metrics/BatchTripUpdateMetrics.java b/application/src/main/java/org/opentripplanner/updater/trip/metrics/BatchTripUpdateMetrics.java index 6d640a21f3d..3fdca624cf4 100644 --- a/application/src/main/java/org/opentripplanner/updater/trip/metrics/BatchTripUpdateMetrics.java +++ b/application/src/main/java/org/opentripplanner/updater/trip/metrics/BatchTripUpdateMetrics.java @@ -33,16 +33,19 @@ public class BatchTripUpdateMetrics extends TripUpdateMetrics { public BatchTripUpdateMetrics(UrlUpdaterParameters parameters) { super(parameters); - this.successfulGauge = - getGauge( - "successful", - "Trip updates that were successfully applied at the most recent update" - ); - this.failureGauge = - getGauge("failed", "Trip updates that failed to apply at the most recent update"); + this.successfulGauge = getGauge( + "successful", + "Trip updates that were successfully applied at the most recent update" + ); + this.failureGauge = getGauge( + "failed", + "Trip updates that failed to apply at the most recent update" + ); - this.warningsGauge = - getGauge("warnings", "Number of warnings when successfully applying trip updates"); + this.warningsGauge = getGauge( + "warnings", + "Number of warnings when successfully applying trip updates" + ); } public void setGauges(UpdateResult result) { @@ -62,12 +65,11 @@ private void setWarnings(UpdateResult result) { for (var warningType : result.warnings()) { var counter = warningsByType.get(warningType); if (Objects.isNull(counter)) { - counter = - getGauge( - "warning_type", - "Warning types of the most recent update", - Tag.of("warningType", warningType.name()) - ); + counter = getGauge( + "warning_type", + "Warning types of the most recent update", + Tag.of("warningType", warningType.name()) + ); warningsByType.put(warningType, counter); } counter.getAndIncrement(); @@ -78,12 +80,11 @@ private void setFailureTypes(UpdateResult result) { for (var errorType : result.failures().keySet()) { var counter = failuresByType.get(errorType); if (Objects.isNull(counter)) { - counter = - getGauge( - "failure_type", - "Failure types of the most recent update", - Tag.of("errorType", errorType.name()) - ); + counter = getGauge( + "failure_type", + "Failure types of the most recent update", + Tag.of("errorType", errorType.name()) + ); failuresByType.put(errorType, counter); } counter.set(result.failures().get(errorType).size()); @@ -103,8 +104,7 @@ private void setFailureTypes(UpdateResult result) { private AtomicInteger getGauge(String name, String description, Tag... tags) { var finalTags = Tags.concat(Arrays.stream(tags).toList(), baseTags); var atomicInt = new AtomicInteger(0); - Gauge - .builder(METRICS_PREFIX + "." + name, atomicInt::get) + Gauge.builder(METRICS_PREFIX + "." + name, atomicInt::get) .description(description) .tags(finalTags) .register(Metrics.globalRegistry); diff --git a/application/src/main/java/org/opentripplanner/updater/trip/metrics/StreamingTripUpdateMetrics.java b/application/src/main/java/org/opentripplanner/updater/trip/metrics/StreamingTripUpdateMetrics.java index 0660f8d801b..7a24b0d4e7a 100644 --- a/application/src/main/java/org/opentripplanner/updater/trip/metrics/StreamingTripUpdateMetrics.java +++ b/application/src/main/java/org/opentripplanner/updater/trip/metrics/StreamingTripUpdateMetrics.java @@ -39,8 +39,7 @@ public void setCounters(UpdateResult result) { private void incrementWarningCounts(UpdateResult result) { for (var warningType : result.warnings()) { Tags tags = Tags.concat(baseTags, Tags.of("warningType", warningType.name())); - Counter - .builder(METRICS_PREFIX + "." + "warnings") + Counter.builder(METRICS_PREFIX + "." + "warnings") .description("Total warnings by type generated by successful trip updates") .tags(tags) .register(Metrics.globalRegistry) @@ -54,8 +53,7 @@ private void incrementFailureCounts(UpdateResult result) { if (producerMetrics && error.producer() != null) { tags = tags.and(Tag.of("producer", error.producer())); } - Counter - .builder(METRICS_PREFIX + "." + "failed") + Counter.builder(METRICS_PREFIX + "." + "failed") .description("Total failed trip updates") .tags(tags) .register(Metrics.globalRegistry) @@ -69,8 +67,7 @@ private void incrementSuccessCounts(UpdateResult result) { if (producerMetrics && success.producer() != null) { tags = tags.and(Tag.of("producer", success.producer())); } - Counter - .builder(METRICS_PREFIX + "." + "successful") + Counter.builder(METRICS_PREFIX + "." + "successful") .description("Total successfully applied trip updates") .tags(tags) .register(Metrics.globalRegistry) diff --git a/application/src/main/java/org/opentripplanner/updater/trip/metrics/TripUpdateMetrics.java b/application/src/main/java/org/opentripplanner/updater/trip/metrics/TripUpdateMetrics.java index b3f88f3af06..aad4e150745 100644 --- a/application/src/main/java/org/opentripplanner/updater/trip/metrics/TripUpdateMetrics.java +++ b/application/src/main/java/org/opentripplanner/updater/trip/metrics/TripUpdateMetrics.java @@ -14,12 +14,11 @@ public class TripUpdateMetrics { protected List baseTags; TripUpdateMetrics(UrlUpdaterParameters parameters) { - this.baseTags = - List.of( - Tag.of("configRef", parameters.configRef()), - Tag.of("url", parameters.url()), - Tag.of("feedId", parameters.feedId()) - ); + this.baseTags = List.of( + Tag.of("configRef", parameters.configRef()), + Tag.of("url", parameters.url()), + Tag.of("feedId", parameters.feedId()) + ); } public static Consumer batch(UrlUpdaterParameters parameters) { diff --git a/application/src/main/java/org/opentripplanner/updater/trip/siri/AddedTripBuilder.java b/application/src/main/java/org/opentripplanner/updater/trip/siri/AddedTripBuilder.java index 7255c7adff2..5d44f304362 100644 --- a/application/src/main/java/org/opentripplanner/updater/trip/siri/AddedTripBuilder.java +++ b/application/src/main/java/org/opentripplanner/updater/trip/siri/AddedTripBuilder.java @@ -228,8 +228,7 @@ Result build() { tripTimes.validateNonIncreasingTimes(); tripTimes.setServiceCode(transitService.getServiceCode(trip.getServiceId())); - TripPattern pattern = TripPattern - .of(getTripPatternId.apply(trip)) + TripPattern pattern = TripPattern.of(getTripPatternId.apply(trip)) .withRoute(trip.getRoute()) .withMode(trip.getMode()) .withNetexSubmode(trip.getNetexSubMode()) @@ -265,8 +264,7 @@ Result build() { return DataValidationExceptionMapper.toResult(e, dataSource); } - var tripOnServiceDate = TripOnServiceDate - .of(tripId) + var tripOnServiceDate = TripOnServiceDate.of(tripId) .withTrip(trip) .withServiceDate(serviceDate) .withReplacementFor(replacedTrips) @@ -400,9 +398,9 @@ private StopTime createStopTime( // Update pickup / dropoff PickDropMapper.mapPickUpType(call, stopTime.getPickupType()).ifPresent(stopTime::setPickupType); - PickDropMapper - .mapDropOffType(call, stopTime.getDropOffType()) - .ifPresent(stopTime::setDropOffType); + PickDropMapper.mapDropOffType(call, stopTime.getDropOffType()).ifPresent( + stopTime::setDropOffType + ); return stopTime; } diff --git a/application/src/main/java/org/opentripplanner/updater/trip/siri/DebugString.java b/application/src/main/java/org/opentripplanner/updater/trip/siri/DebugString.java index 12abd438dcf..2db92b716c7 100644 --- a/application/src/main/java/org/opentripplanner/updater/trip/siri/DebugString.java +++ b/application/src/main/java/org/opentripplanner/updater/trip/siri/DebugString.java @@ -18,8 +18,7 @@ static String of(EstimatedVehicleJourney estimatedVehicleJourney) { return null; } - return ToStringBuilder - .of(estimatedVehicleJourney.getClass()) + return ToStringBuilder.of(estimatedVehicleJourney.getClass()) .addStr( "EstimatedVehicleJourneyCode", estimatedVehicleJourney.getEstimatedVehicleJourneyCode() @@ -29,15 +28,11 @@ static String of(EstimatedVehicleJourney estimatedVehicleJourney) { estimatedVehicleJourney.getDatedVehicleJourneyRef(), DatedVehicleJourneyRef::getValue ) - .addObjOp( - "FramedVehicleJourney", - estimatedVehicleJourney.getFramedVehicleJourneyRef(), - it -> - ToStringBuilder - .of(it.getClass()) - .addStr("VehicleJourney", it.getDatedVehicleJourneyRef()) - .addObjOp("Date", it.getDataFrameRef(), DataFrameRefStructure::getValue) - .toString() + .addObjOp("FramedVehicleJourney", estimatedVehicleJourney.getFramedVehicleJourneyRef(), it -> + ToStringBuilder.of(it.getClass()) + .addStr("VehicleJourney", it.getDatedVehicleJourneyRef()) + .addObjOp("Date", it.getDataFrameRef(), DataFrameRefStructure::getValue) + .toString() ) .addObjOp( "Operator", diff --git a/application/src/main/java/org/opentripplanner/updater/trip/siri/EntityResolver.java b/application/src/main/java/org/opentripplanner/updater/trip/siri/EntityResolver.java index a104e948bd7..247b7f12071 100644 --- a/application/src/main/java/org/opentripplanner/updater/trip/siri/EntityResolver.java +++ b/application/src/main/java/org/opentripplanner/updater/trip/siri/EntityResolver.java @@ -126,7 +126,8 @@ public TripOnServiceDate resolveTripOnServiceDate(FeedScopedId datedServiceJourn public FeedScopedId resolveDatedServiceJourneyId( EstimatedVehicleJourney estimatedVehicleJourney ) { - DatedVehicleJourneyRef datedVehicleJourneyRef = estimatedVehicleJourney.getDatedVehicleJourneyRef(); + DatedVehicleJourneyRef datedVehicleJourneyRef = + estimatedVehicleJourney.getDatedVehicleJourneyRef(); if (datedVehicleJourneyRef != null) { return resolveId(datedVehicleJourneyRef.getValue()); } @@ -230,8 +231,7 @@ public LocalDate resolveServiceDate(EstimatedVehicleJourney vehicleJourney) { } } - var datetime = CallWrapper - .of(vehicleJourney) + var datetime = CallWrapper.of(vehicleJourney) .stream() .findFirst() .map(CallWrapper::getAimedDepartureTime); diff --git a/application/src/main/java/org/opentripplanner/updater/trip/siri/ModifiedTripBuilder.java b/application/src/main/java/org/opentripplanner/updater/trip/siri/ModifiedTripBuilder.java index 647fd9be54f..fa0d339e0f3 100644 --- a/application/src/main/java/org/opentripplanner/updater/trip/siri/ModifiedTripBuilder.java +++ b/application/src/main/java/org/opentripplanner/updater/trip/siri/ModifiedTripBuilder.java @@ -257,13 +257,13 @@ static StopPattern createStopPattern( final int stopIndex = i; builder.stops.with(stopIndex, callStop); - PickDropMapper - .mapPickUpType(call, builder.pickups.original(stopIndex)) - .ifPresent(value -> builder.pickups.with(stopIndex, value)); + PickDropMapper.mapPickUpType(call, builder.pickups.original(stopIndex)).ifPresent(value -> + builder.pickups.with(stopIndex, value) + ); - PickDropMapper - .mapDropOffType(call, builder.dropoffs.original(stopIndex)) - .ifPresent(value -> builder.dropoffs.with(stopIndex, value)); + PickDropMapper.mapDropOffType(call, builder.dropoffs.original(stopIndex)).ifPresent(value -> + builder.dropoffs.with(stopIndex, value) + ); alreadyVisited.add(call); break; diff --git a/application/src/main/java/org/opentripplanner/updater/trip/siri/SiriFuzzyTripMatcher.java b/application/src/main/java/org/opentripplanner/updater/trip/siri/SiriFuzzyTripMatcher.java index 343600a8553..c872ed1c27a 100644 --- a/application/src/main/java/org/opentripplanner/updater/trip/siri/SiriFuzzyTripMatcher.java +++ b/application/src/main/java/org/opentripplanner/updater/trip/siri/SiriFuzzyTripMatcher.java @@ -108,8 +108,10 @@ public Result match( var lineRef = journey.getLineRef().getValue(); Route route = entityResolver.resolveRoute(lineRef); if (route != null) { - trips = - trips.stream().filter(trip -> trip.getRoute().equals(route)).collect(Collectors.toSet()); + trips = trips + .stream() + .filter(trip -> trip.getRoute().equals(route)) + .collect(Collectors.toSet()); } } diff --git a/application/src/main/java/org/opentripplanner/updater/trip/siri/SiriRealTimeTripUpdateAdapter.java b/application/src/main/java/org/opentripplanner/updater/trip/siri/SiriRealTimeTripUpdateAdapter.java index 8ee723567c0..20faad7c134 100644 --- a/application/src/main/java/org/opentripplanner/updater/trip/siri/SiriRealTimeTripUpdateAdapter.java +++ b/application/src/main/java/org/opentripplanner/updater/trip/siri/SiriRealTimeTripUpdateAdapter.java @@ -47,7 +47,8 @@ public class SiriRealTimeTripUpdateAdapter { * Use an id generator to generate TripPattern ids for new TripPatterns created by RealTime * updates. */ - private final SiriTripPatternIdGenerator tripPatternIdGenerator = new SiriTripPatternIdGenerator(); + private final SiriTripPatternIdGenerator tripPatternIdGenerator = + new SiriTripPatternIdGenerator(); /** * A synchronized cache of trip patterns that are added to the graph due to GTFS-real-time * messages. @@ -68,10 +69,14 @@ public SiriRealTimeTripUpdateAdapter( TimetableSnapshotManager snapshotManager ) { this.snapshotManager = snapshotManager; - this.transitEditorService = - new DefaultTransitService(timetableRepository, snapshotManager.getTimetableSnapshotBuffer()); - this.tripPatternCache = - new SiriTripPatternCache(tripPatternIdGenerator, transitEditorService::findPattern); + this.transitEditorService = new DefaultTransitService( + timetableRepository, + snapshotManager.getTimetableSnapshotBuffer() + ); + this.tripPatternCache = new SiriTripPatternCache( + tripPatternIdGenerator, + transitEditorService::findPattern + ); } /** @@ -132,14 +137,12 @@ private Result apply( shouldAddNewTrip = shouldAddNewTrip(journey, entityResolver); Result result; if (shouldAddNewTrip) { - result = - new AddedTripBuilder( - journey, - transitService, - entityResolver, - tripPatternIdGenerator::generateUniqueTripPatternId - ) - .build(); + result = new AddedTripBuilder( + journey, + transitService, + entityResolver, + tripPatternIdGenerator::generateUniqueTripPatternId + ).build(); } else { result = handleModifiedTrip(fuzzyTripMatcher, entityResolver, journey); } @@ -253,8 +256,7 @@ private Result handleModifiedTrip( serviceDate, transitEditorService.getTimeZone(), entityResolver - ) - .build(); + ).build(); if (updateResult.isFailure()) { return updateResult.toFailureResult(); } @@ -283,8 +285,11 @@ private Result addTripToGraphAndBuffer(TripUpdate tr pattern = tripUpdate.addedTripPattern(); } else { // Get cached trip pattern or create one if it doesn't exist yet - pattern = - tripPatternCache.getOrCreateTripPattern(tripUpdate.stopPattern(), trip, serviceDate); + pattern = tripPatternCache.getOrCreateTripPattern( + tripUpdate.stopPattern(), + trip, + serviceDate + ); } // Add new trip times to buffer, making protective copies as needed. Bubble success/error up. diff --git a/application/src/main/java/org/opentripplanner/updater/trip/siri/SiriTripPatternCache.java b/application/src/main/java/org/opentripplanner/updater/trip/siri/SiriTripPatternCache.java index 4d080f11bb6..5808b6f4c0e 100644 --- a/application/src/main/java/org/opentripplanner/updater/trip/siri/SiriTripPatternCache.java +++ b/application/src/main/java/org/opentripplanner/updater/trip/siri/SiriTripPatternCache.java @@ -90,16 +90,14 @@ public synchronized TripPattern getOrCreateTripPattern( // Create TripPattern if it doesn't exist yet if (tripPattern == null) { var id = tripPatternIdGenerator.generateUniqueTripPatternId(trip); - tripPattern = - TripPattern - .of(id) - .withRoute(trip.getRoute()) - .withMode(trip.getMode()) - .withNetexSubmode(trip.getNetexSubMode()) - .withStopPattern(stopPattern) - .withCreatedByRealtimeUpdater(true) - .withOriginalTripPattern(originalTripPattern) - .build(); + tripPattern = TripPattern.of(id) + .withRoute(trip.getRoute()) + .withMode(trip.getMode()) + .withNetexSubmode(trip.getNetexSubMode()) + .withStopPattern(stopPattern) + .withCreatedByRealtimeUpdater(true) + .withOriginalTripPattern(originalTripPattern) + .build(); // TODO: Add pattern to timetableRepository index? // Add pattern to cache diff --git a/application/src/main/java/org/opentripplanner/updater/trip/siri/updater/SiriETHttpTripUpdateSource.java b/application/src/main/java/org/opentripplanner/updater/trip/siri/updater/SiriETHttpTripUpdateSource.java index d7b6ffd6ea1..3508b080441 100644 --- a/application/src/main/java/org/opentripplanner/updater/trip/siri/updater/SiriETHttpTripUpdateSource.java +++ b/application/src/main/java/org/opentripplanner/updater/trip/siri/updater/SiriETHttpTripUpdateSource.java @@ -35,10 +35,9 @@ public class SiriETHttpTripUpdateSource implements EstimatedTimetableSource { public SiriETHttpTripUpdateSource(Parameters parameters, SiriLoader siriLoader) { this.url = parameters.url(); - this.requestorRef = - parameters.requestorRef() == null || parameters.requestorRef().isEmpty() - ? "otp-" + UUID.randomUUID() - : parameters.requestorRef(); + this.requestorRef = parameters.requestorRef() == null || parameters.requestorRef().isEmpty() + ? "otp-" + UUID.randomUUID() + : parameters.requestorRef(); this.siriLoader = siriLoader; } diff --git a/application/src/main/java/org/opentripplanner/updater/trip/siri/updater/SiriETUpdater.java b/application/src/main/java/org/opentripplanner/updater/trip/siri/updater/SiriETUpdater.java index 190086343af..f9ac432b914 100644 --- a/application/src/main/java/org/opentripplanner/updater/trip/siri/updater/SiriETUpdater.java +++ b/application/src/main/java/org/opentripplanner/updater/trip/siri/updater/SiriETUpdater.java @@ -49,8 +49,11 @@ public SiriETUpdater( LOG.info("Creating SIRI-ET updater running every {}: {}", pollingPeriod(), updateSource); - estimatedTimetableHandler = - new EstimatedTimetableHandler(adapter, config.fuzzyTripMatching(), feedId); + estimatedTimetableHandler = new EstimatedTimetableHandler( + adapter, + config.fuzzyTripMatching(), + feedId + ); this.metricsConsumer = metricsConsumer; } @@ -71,7 +74,8 @@ public void runPolling() { // Mark this updater as primed after last page of updates. Copy moreData into a final // primitive, because the object moreData persists across iterations. final boolean markPrimed = !moreData; - List etds = serviceDelivery.getEstimatedTimetableDeliveries(); + List etds = + serviceDelivery.getEstimatedTimetableDeliveries(); if (etds != null) { saveResultOnGraph.execute(context -> { var result = estimatedTimetableHandler.applyUpdate(etds, incrementality, context); @@ -88,8 +92,7 @@ public void runPolling() { @Override public String toString() { - return ToStringBuilder - .of(SiriETUpdater.class) + return ToStringBuilder.of(SiriETUpdater.class) .addStr("source", updateSource.toString()) .addDuration("frequency", pollingPeriod()) .toString(); diff --git a/application/src/main/java/org/opentripplanner/updater/trip/siri/updater/google/GooglePubsubEstimatedTimetableSource.java b/application/src/main/java/org/opentripplanner/updater/trip/siri/updater/google/GooglePubsubEstimatedTimetableSource.java index e711d79d104..5b22e029837 100644 --- a/application/src/main/java/org/opentripplanner/updater/trip/siri/updater/google/GooglePubsubEstimatedTimetableSource.java +++ b/application/src/main/java/org/opentripplanner/updater/trip/siri/updater/google/GooglePubsubEstimatedTimetableSource.java @@ -122,20 +122,23 @@ public GooglePubsubEstimatedTimetableSource( this.initialGetDataTimeout = initialGetDataTimeout; String subscriptionId = buildSubscriptionId(); - subscriptionName = - ProjectSubscriptionName.of(subscriptionProjectName, subscriptionId).toString(); - subscriber = - Subscriber.newBuilder(subscriptionName, new EstimatedTimetableMessageReceiver()).build(); + subscriptionName = ProjectSubscriptionName.of( + subscriptionProjectName, + subscriptionId + ).toString(); + subscriber = Subscriber.newBuilder( + subscriptionName, + new EstimatedTimetableMessageReceiver() + ).build(); this.topic = ProjectTopicName.of(topicProjectName, topicName); this.pushConfig = PushConfig.getDefaultInstance(); - retry = - new OtpRetryBuilder() - .withName("SIRI-ET Google PubSub Updater setup") - .withMaxAttempts(RETRY_MAX_ATTEMPTS) - .withInitialRetryInterval(RETRY_INITIAL_DELAY) - .withBackoffMultiplier(RETRY_BACKOFF) - .build(); + retry = new OtpRetryBuilder() + .withName("SIRI-ET Google PubSub Updater setup") + .withMaxAttempts(RETRY_MAX_ATTEMPTS) + .withInitialRetryInterval(RETRY_INITIAL_DELAY) + .withBackoffMultiplier(RETRY_BACKOFF) + .build(); addShutdownHook(); } @@ -196,8 +199,7 @@ private static String buildSubscriptionId() { private void createSubscription() { try (SubscriptionAdminClient subscriptionAdminClient = SubscriptionAdminClient.create()) { subscriptionAdminClient.createSubscription( - Subscription - .newBuilder() + Subscription.newBuilder() .setTopic(topic.toString()) .setName(subscriptionName) .setPushConfig(pushConfig) @@ -206,8 +208,7 @@ private void createSubscription() { com.google.protobuf.Duration.newBuilder().setSeconds(600).build() ) .setExpirationPolicy( - ExpirationPolicy - .newBuilder() + ExpirationPolicy.newBuilder() // How long will the subscription exist when no longer in use - minimum 1 day .setTtl(com.google.protobuf.Duration.newBuilder().setSeconds(86400).build()) .build() @@ -315,16 +316,13 @@ private ByteString fetchInitialData() { * Shut down the PubSub subscriber at server shutdown. */ private void addShutdownHook() { - ApplicationShutdownSupport.addShutdownHook( - "siri-et-google-pubsub-shutdown", - () -> { - if (subscriber != null) { - LOG.info("Stopping SIRI-ET PubSub subscriber '{}'.", subscriptionName); - subscriber.stopAsync(); - } - deleteSubscription(); + ApplicationShutdownSupport.addShutdownHook("siri-et-google-pubsub-shutdown", () -> { + if (subscriber != null) { + LOG.info("Stopping SIRI-ET PubSub subscriber '{}'.", subscriptionName); + subscriber.stopAsync(); } - ); + deleteSubscription(); + }); } private String getTimeSinceStartupString() { @@ -352,14 +350,13 @@ public void receiveMessage(PubsubMessage message, AckReplyConsumer consumer) { private void logPubsubMessage(ServiceDelivery serviceDelivery) { int numberOfUpdatedTrips = 0; try { - numberOfUpdatedTrips = - serviceDelivery - .getEstimatedTimetableDeliveries() - .getFirst() - .getEstimatedJourneyVersionFrames() - .getFirst() - .getEstimatedVehicleJourneies() - .size(); + numberOfUpdatedTrips = serviceDelivery + .getEstimatedTimetableDeliveries() + .getFirst() + .getEstimatedJourneyVersionFrames() + .getFirst() + .getEstimatedVehicleJourneies() + .size(); } catch (Exception e) { //ignore } @@ -372,9 +369,10 @@ private void logPubsubMessage(ServiceDelivery serviceDelivery) { numberOfMessages, numberOfUpdates, FileSizeToTextConverter.fileSizeToString(SIZE_COUNTER.get()), - Duration - .between(serviceDelivery.getResponseTimestamp().toInstant(), Instant.now()) - .toMillis(), + Duration.between( + serviceDelivery.getResponseTimestamp().toInstant(), + Instant.now() + ).toMillis(), getTimeSinceStartupString() ); } diff --git a/application/src/main/java/org/opentripplanner/updater/trip/siri/updater/google/SiriETGooglePubsubUpdater.java b/application/src/main/java/org/opentripplanner/updater/trip/siri/updater/google/SiriETGooglePubsubUpdater.java index 98c8135b3ed..156d4508443 100644 --- a/application/src/main/java/org/opentripplanner/updater/trip/siri/updater/google/SiriETGooglePubsubUpdater.java +++ b/application/src/main/java/org/opentripplanner/updater/trip/siri/updater/google/SiriETGooglePubsubUpdater.java @@ -29,18 +29,20 @@ public SiriETGooglePubsubUpdater( ) { configRef = config.configRef(); - asyncEstimatedTimetableSource = - new GooglePubsubEstimatedTimetableSource( - config.dataInitializationUrl(), - config.reconnectPeriod(), - config.initialGetDataTimeout(), - config.subscriptionProjectName(), - config.topicProjectName(), - config.topicName() - ); + asyncEstimatedTimetableSource = new GooglePubsubEstimatedTimetableSource( + config.dataInitializationUrl(), + config.reconnectPeriod(), + config.initialGetDataTimeout(), + config.subscriptionProjectName(), + config.topicProjectName(), + config.topicName() + ); - estimatedTimetableHandler = - new EstimatedTimetableHandler(adapter, config.fuzzyTripMatching(), config.feedId()); + estimatedTimetableHandler = new EstimatedTimetableHandler( + adapter, + config.fuzzyTripMatching(), + config.feedId() + ); updateResultConsumer = TripUpdateMetrics.streaming(config); } @@ -52,11 +54,12 @@ public void setup(WriteToGraphCallback writeToGraphCallback) { @Override public void run() { - AsyncEstimatedTimetableProcessor asyncEstimatedTimetableProcessor = new AsyncEstimatedTimetableProcessor( - estimatedTimetableHandler, - saveResultOnGraph, - updateResultConsumer - ); + AsyncEstimatedTimetableProcessor asyncEstimatedTimetableProcessor = + new AsyncEstimatedTimetableProcessor( + estimatedTimetableHandler, + saveResultOnGraph, + updateResultConsumer + ); asyncEstimatedTimetableSource.start(asyncEstimatedTimetableProcessor::processSiriData); } diff --git a/application/src/main/java/org/opentripplanner/updater/trip/siri/updater/google/SiriETGooglePubsubUpdaterParameters.java b/application/src/main/java/org/opentripplanner/updater/trip/siri/updater/google/SiriETGooglePubsubUpdaterParameters.java index 1cc4795b085..ec217a67ff0 100644 --- a/application/src/main/java/org/opentripplanner/updater/trip/siri/updater/google/SiriETGooglePubsubUpdaterParameters.java +++ b/application/src/main/java/org/opentripplanner/updater/trip/siri/updater/google/SiriETGooglePubsubUpdaterParameters.java @@ -33,8 +33,7 @@ public record SiriETGooglePubsubUpdaterParameters( @Override public String toString() { - return ToStringBuilder - .of(SiriETGooglePubsubUpdaterParameters.class) + return ToStringBuilder.of(SiriETGooglePubsubUpdaterParameters.class) .addObj("configRef", configRef, null) .addObj("feedId", feedId, null) .addObj("subscriptionProjectName", subscriptionProjectName) diff --git a/application/src/main/java/org/opentripplanner/updater/trip/siri/updater/lite/SiriETLiteHttpTripUpdateSource.java b/application/src/main/java/org/opentripplanner/updater/trip/siri/updater/lite/SiriETLiteHttpTripUpdateSource.java index 35388262ba0..10f7a1225a9 100644 --- a/application/src/main/java/org/opentripplanner/updater/trip/siri/updater/lite/SiriETLiteHttpTripUpdateSource.java +++ b/application/src/main/java/org/opentripplanner/updater/trip/siri/updater/lite/SiriETLiteHttpTripUpdateSource.java @@ -57,8 +57,7 @@ public UpdateIncrementality incrementalityOfLastUpdates() { } public String toString() { - return ToStringBuilder - .of(this.getClass()) + return ToStringBuilder.of(this.getClass()) .addStr("feedId", parameters.feedId()) .addStr("uri", parameters.uri().toString()) .toString(); diff --git a/application/src/main/java/org/opentripplanner/updater/vehicle_parking/VehicleParkingAvailabilityUpdater.java b/application/src/main/java/org/opentripplanner/updater/vehicle_parking/VehicleParkingAvailabilityUpdater.java index 29e820ff952..049b19ed7bc 100644 --- a/application/src/main/java/org/opentripplanner/updater/vehicle_parking/VehicleParkingAvailabilityUpdater.java +++ b/application/src/main/java/org/opentripplanner/updater/vehicle_parking/VehicleParkingAvailabilityUpdater.java @@ -58,11 +58,10 @@ private class AvailabilityUpdater implements GraphWriterRunnable { private AvailabilityUpdater(List updates) { this.updates = List.copyOf(updates); - this.parkingById = - repository - .listVehicleParkings() - .stream() - .collect(Collectors.toUnmodifiableMap(VehicleParking::getId, Function.identity())); + this.parkingById = repository + .listVehicleParkings() + .stream() + .collect(Collectors.toUnmodifiableMap(VehicleParking::getId, Function.identity())); } @Override diff --git a/application/src/main/java/org/opentripplanner/updater/vehicle_parking/VehicleParkingUpdater.java b/application/src/main/java/org/opentripplanner/updater/vehicle_parking/VehicleParkingUpdater.java index 639ce664b33..a676d4673f6 100644 --- a/application/src/main/java/org/opentripplanner/updater/vehicle_parking/VehicleParkingUpdater.java +++ b/application/src/main/java/org/opentripplanner/updater/vehicle_parking/VehicleParkingUpdater.java @@ -38,8 +38,10 @@ public class VehicleParkingUpdater extends PollingGraphUpdater { private static final Logger LOG = LoggerFactory.getLogger(VehicleParkingUpdater.class); - private final Map> verticesByPark = new HashMap<>(); - private final Map> tempEdgesByPark = new HashMap<>(); + private final Map> verticesByPark = + new HashMap<>(); + private final Map> tempEdgesByPark = + new HashMap<>(); private final DataSource source; private final List oldVehicleParkings = new ArrayList<>(); private final VertexLinker linker; @@ -84,10 +86,9 @@ private class VehicleParkingGraphWriterRunnable implements GraphWriterRunnable { private final Set updatedVehicleParkings; private VehicleParkingGraphWriterRunnable(List updatedVehicleParkings) { - this.oldVehicleParkingsById = - oldVehicleParkings - .stream() - .collect(Collectors.toMap(VehicleParking::getId, Function.identity())); + this.oldVehicleParkingsById = oldVehicleParkings + .stream() + .collect(Collectors.toMap(VehicleParking::getId, Function.identity())); this.updatedVehicleParkings = new HashSet<>(updatedVehicleParkings); } diff --git a/application/src/main/java/org/opentripplanner/updater/vehicle_position/GtfsRealtimeHttpVehiclePositionSource.java b/application/src/main/java/org/opentripplanner/updater/vehicle_position/GtfsRealtimeHttpVehiclePositionSource.java index 31ae9a32faf..096d5d3cb84 100644 --- a/application/src/main/java/org/opentripplanner/updater/vehicle_position/GtfsRealtimeHttpVehiclePositionSource.java +++ b/application/src/main/java/org/opentripplanner/updater/vehicle_position/GtfsRealtimeHttpVehiclePositionSource.java @@ -51,8 +51,7 @@ public List getPositions() { @Override public String toString() { - return ToStringBuilder - .of(GtfsRealtimeHttpVehiclePositionSource.class) + return ToStringBuilder.of(GtfsRealtimeHttpVehiclePositionSource.class) .addObj("url", url) .toString(); } diff --git a/application/src/main/java/org/opentripplanner/updater/vehicle_position/PollingVehiclePositionUpdater.java b/application/src/main/java/org/opentripplanner/updater/vehicle_position/PollingVehiclePositionUpdater.java index f53d3010e59..9d4dbc898d0 100644 --- a/application/src/main/java/org/opentripplanner/updater/vehicle_position/PollingVehiclePositionUpdater.java +++ b/application/src/main/java/org/opentripplanner/updater/vehicle_position/PollingVehiclePositionUpdater.java @@ -36,8 +36,10 @@ public PollingVehiclePositionUpdater( RealtimeVehicleRepository realtimeVehicleRepository ) { super(params); - this.vehiclePositionSource = - new GtfsRealtimeHttpVehiclePositionSource(params.url(), params.headers()); + this.vehiclePositionSource = new GtfsRealtimeHttpVehiclePositionSource( + params.url(), + params.headers() + ); this.realtimeVehicleRepository = realtimeVehicleRepository; this.feedId = params.feedId(); this.fuzzyTripMatching = params.fuzzyTripMatching(); diff --git a/application/src/main/java/org/opentripplanner/updater/vehicle_position/RealtimeVehiclePatternMatcher.java b/application/src/main/java/org/opentripplanner/updater/vehicle_position/RealtimeVehiclePatternMatcher.java index ccb271c9d68..7492b110997 100644 --- a/application/src/main/java/org/opentripplanner/updater/vehicle_position/RealtimeVehiclePatternMatcher.java +++ b/application/src/main/java/org/opentripplanner/updater/vehicle_position/RealtimeVehiclePatternMatcher.java @@ -114,14 +114,8 @@ public UpdateResult applyRealtimeVehicleUpdates(List vehiclePos .entrySet() .stream() .collect( - Collectors.toMap( - Entry::getKey, - e -> - e - .getValue() - .stream() - .map(PatternAndRealtimeVehicle::vehicle) - .collect(Collectors.toList()) + Collectors.toMap(Entry::getKey, e -> + e.getValue().stream().map(PatternAndRealtimeVehicle::vehicle).collect(Collectors.toList()) ) ); @@ -179,14 +173,12 @@ protected static LocalDate inferServiceDate( // yesterday, today or tomorrow. whichever one has the lowest "distance" to now is guessed to be // the service day of the undated vehicle position // if this is concerning to you, you should put a start_date in your feed. - return Stream - .of(yesterday, today, tomorrow) + return Stream.of(yesterday, today, tomorrow) .flatMap(day -> { var startTime = ServiceDateUtils.toZonedDateTime(day, zoneId, start).toInstant(); var endTime = ServiceDateUtils.toZonedDateTime(day, zoneId, end).toInstant(); - return Stream - .of(Duration.between(startTime, now), Duration.between(endTime, now)) + return Stream.of(Duration.between(startTime, now), Duration.between(endTime, now)) .map(Duration::abs) // temporal "distances" can be positive and negative .map(duration -> new TemporalDistance(day, duration.toSeconds())); }) @@ -358,8 +350,7 @@ private Result toRealtimeVehicle( return UpdateError.result(scopedTripId, TRIP_NOT_FOUND); } - var serviceDate = Optional - .of(vehiclePositionWithTripId.getTrip().getStartDate()) + var serviceDate = Optional.of(vehiclePositionWithTripId.getTrip().getStartDate()) .map(Strings::emptyToNull) .flatMap(ServiceDateUtils::parseStringToOptional) .orElseGet(() -> inferServiceDate(trip)); diff --git a/application/src/main/java/org/opentripplanner/updater/vehicle_rental/GeofencingVertexUpdater.java b/application/src/main/java/org/opentripplanner/updater/vehicle_rental/GeofencingVertexUpdater.java index 60eaae3a8ed..c355df99563 100644 --- a/application/src/main/java/org/opentripplanner/updater/vehicle_rental/GeofencingVertexUpdater.java +++ b/application/src/main/java/org/opentripplanner/updater/vehicle_rental/GeofencingVertexUpdater.java @@ -73,8 +73,7 @@ Map applyGeofencingZones( .map(GeofencingZone::geometry) .toArray(Geometry[]::new); - var unionOfBusinessAreas = GeometryUtils - .getGeometryFactory() + var unionOfBusinessAreas = GeometryUtils.getGeometryFactory() .createGeometryCollection(polygons) .union(); diff --git a/application/src/main/java/org/opentripplanner/updater/vehicle_rental/VehicleRentalUpdater.java b/application/src/main/java/org/opentripplanner/updater/vehicle_rental/VehicleRentalUpdater.java index f1cb602060b..1a444dd43a7 100644 --- a/application/src/main/java/org/opentripplanner/updater/vehicle_rental/VehicleRentalUpdater.java +++ b/application/src/main/java/org/opentripplanner/updater/vehicle_rental/VehicleRentalUpdater.java @@ -72,11 +72,10 @@ public VehicleRentalUpdater( LOG.info("Setting up vehicle rental updater for {}.", source); this.source = source; - this.nameForLogging = - ObjectUtils.ifNotNull( - parameters.sourceParameters().network(), - parameters.sourceParameters().url() - ); + this.nameForLogging = ObjectUtils.ifNotNull( + parameters.sourceParameters().network(), + parameters.sourceParameters().url() + ); this.unlinkedPlaceThrottle = Throttle.ofOneSecond(); // Creation of network linker library will not modify the graph @@ -190,12 +189,10 @@ public void run(RealTimeUpdateContext context) { ) ); } - Set formFactors = Stream - .concat( - station.getAvailablePickupFormFactors(false).stream(), - station.getAvailableDropoffFormFactors(false).stream() - ) - .collect(Collectors.toSet()); + Set formFactors = Stream.concat( + station.getAvailablePickupFormFactors(false).stream(), + station.getAvailableDropoffFormFactors(false).stream() + ).collect(Collectors.toSet()); for (RentalFormFactor formFactor : formFactors) { tempEdges.addEdge( VehicleRentalEdge.createVehicleRentalEdge(vehicleRentalVertex, formFactor) diff --git a/application/src/main/java/org/opentripplanner/updater/vehicle_rental/datasources/GbfsFreeVehicleStatusMapper.java b/application/src/main/java/org/opentripplanner/updater/vehicle_rental/datasources/GbfsFreeVehicleStatusMapper.java index 7c242e85bbe..abf04e472e4 100644 --- a/application/src/main/java/org/opentripplanner/updater/vehicle_rental/datasources/GbfsFreeVehicleStatusMapper.java +++ b/application/src/main/java/org/opentripplanner/updater/vehicle_rental/datasources/GbfsFreeVehicleStatusMapper.java @@ -50,41 +50,30 @@ public VehicleRentalVehicle mapFreeVehicleStatus(GBFSBike vehicle) { rentalVehicle.name = new NonLocalizedString(getName(vehicle)); rentalVehicle.longitude = vehicle.getLon(); rentalVehicle.latitude = vehicle.getLat(); - rentalVehicle.vehicleType = - vehicleTypes.getOrDefault( - vehicle.getVehicleTypeId(), - RentalVehicleType.getDefaultType(system.systemId) - ); + rentalVehicle.vehicleType = vehicleTypes.getOrDefault( + vehicle.getVehicleTypeId(), + RentalVehicleType.getDefaultType(system.systemId) + ); rentalVehicle.isReserved = vehicle.getIsReserved() != null ? vehicle.getIsReserved() : false; rentalVehicle.isDisabled = vehicle.getIsDisabled() != null ? vehicle.getIsDisabled() : false; - rentalVehicle.lastReported = - vehicle.getLastReported() != null - ? Instant.ofEpochSecond((long) (double) vehicle.getLastReported()) - : null; + rentalVehicle.lastReported = vehicle.getLastReported() != null + ? Instant.ofEpochSecond((long) (double) vehicle.getLastReported()) + : null; - var fuelRatio = Ratio - .ofBoxed( - vehicle.getCurrentFuelPercent(), - validationErrorMessage -> - LOG_THROTTLE.throttle(() -> - LOG.warn("'currentFuelPercent' is not valid. Details: {}", validationErrorMessage) - ) - ) - .orElse(null); - var rangeMeters = Distance - .ofMetersBoxed( - vehicle.getCurrentRangeMeters(), - error -> { - LOG_THROTTLE.throttle(() -> - LOG.warn( - "Current range meter value not valid: {} - {}", - vehicle.getCurrentRangeMeters(), - error - ) - ); - } + var fuelRatio = Ratio.ofBoxed(vehicle.getCurrentFuelPercent(), validationErrorMessage -> + LOG_THROTTLE.throttle(() -> + LOG.warn("'currentFuelPercent' is not valid. Details: {}", validationErrorMessage) ) - .orElse(null); + ).orElse(null); + var rangeMeters = Distance.ofMetersBoxed(vehicle.getCurrentRangeMeters(), error -> { + LOG_THROTTLE.throttle(() -> + LOG.warn( + "Current range meter value not valid: {} - {}", + vehicle.getCurrentRangeMeters(), + error + ) + ); + }).orElse(null); // if the propulsion type has an engine current_range_meters is required if ( vehicle.getVehicleTypeId() != null && diff --git a/application/src/main/java/org/opentripplanner/updater/vehicle_rental/datasources/GbfsGeofencingZoneMapper.java b/application/src/main/java/org/opentripplanner/updater/vehicle_rental/datasources/GbfsGeofencingZoneMapper.java index 934243a1e76..50d766f6338 100644 --- a/application/src/main/java/org/opentripplanner/updater/vehicle_rental/datasources/GbfsGeofencingZoneMapper.java +++ b/application/src/main/java/org/opentripplanner/updater/vehicle_rental/datasources/GbfsGeofencingZoneMapper.java @@ -70,8 +70,7 @@ private GeofencingZone toInternalModel(GBFSFeature f) { * Some zones don't have a name, so we use the hash of the geometry as a fallback. */ private static String fallbackId(Geometry geom) { - return Hashing - .murmur3_32_fixed() + return Hashing.murmur3_32_fixed() .hashBytes(geom.toString().getBytes(StandardCharsets.UTF_8)) .toString(); } diff --git a/application/src/main/java/org/opentripplanner/updater/vehicle_rental/datasources/GbfsStationInformationMapper.java b/application/src/main/java/org/opentripplanner/updater/vehicle_rental/datasources/GbfsStationInformationMapper.java index 2f58476457c..dc14ab91ede 100644 --- a/application/src/main/java/org/opentripplanner/updater/vehicle_rental/datasources/GbfsStationInformationMapper.java +++ b/application/src/main/java/org/opentripplanner/updater/vehicle_rental/datasources/GbfsStationInformationMapper.java @@ -63,37 +63,36 @@ public VehicleRentalStation mapStationInformation(GBFSStation station) { rentalStation.crossStreet = station.getCrossStreet(); rentalStation.regionId = station.getRegionId(); rentalStation.postCode = station.getPostCode(); - rentalStation.isVirtualStation = - station.getIsVirtualStation() != null ? station.getIsVirtualStation() : false; - rentalStation.isValetStation = - station.getIsValetStation() != null ? station.getIsValetStation() : false; + rentalStation.isVirtualStation = station.getIsVirtualStation() != null + ? station.getIsVirtualStation() + : false; + rentalStation.isValetStation = station.getIsValetStation() != null + ? station.getIsValetStation() + : false; // TODO: Convert geometry // rentalStation.stationArea = station.getStationArea(); - rentalStation.capacity = - station.getCapacity() != null ? station.getCapacity().intValue() : null; + rentalStation.capacity = station.getCapacity() != null + ? station.getCapacity().intValue() + : null; - rentalStation.vehicleTypeAreaCapacity = - station.getVehicleCapacity() != null && vehicleTypes != null - ? station - .getVehicleCapacity() - .getAdditionalProperties() - .entrySet() - .stream() - .collect( - Collectors.toMap(e -> vehicleTypes.get(e.getKey()), e -> e.getValue().intValue()) - ) - : null; - rentalStation.vehicleTypeDockCapacity = - station.getVehicleTypeCapacity() != null && vehicleTypes != null - ? station - .getVehicleTypeCapacity() - .getAdditionalProperties() - .entrySet() - .stream() - .collect( - Collectors.toMap(e -> vehicleTypes.get(e.getKey()), e -> e.getValue().intValue()) - ) - : null; + rentalStation.vehicleTypeAreaCapacity = station.getVehicleCapacity() != null && + vehicleTypes != null + ? station + .getVehicleCapacity() + .getAdditionalProperties() + .entrySet() + .stream() + .collect(Collectors.toMap(e -> vehicleTypes.get(e.getKey()), e -> e.getValue().intValue())) + : null; + rentalStation.vehicleTypeDockCapacity = station.getVehicleTypeCapacity() != null && + vehicleTypes != null + ? station + .getVehicleTypeCapacity() + .getAdditionalProperties() + .entrySet() + .stream() + .collect(Collectors.toMap(e -> vehicleTypes.get(e.getKey()), e -> e.getValue().intValue())) + : null; rentalStation.isArrivingInRentalVehicleAtDestinationAllowed = allowKeepingRentedVehicleAtDestination; diff --git a/application/src/main/java/org/opentripplanner/updater/vehicle_rental/datasources/GbfsStationStatusMapper.java b/application/src/main/java/org/opentripplanner/updater/vehicle_rental/datasources/GbfsStationStatusMapper.java index 21ee8d000c0..c00fe43ee8a 100644 --- a/application/src/main/java/org/opentripplanner/updater/vehicle_rental/datasources/GbfsStationStatusMapper.java +++ b/application/src/main/java/org/opentripplanner/updater/vehicle_rental/datasources/GbfsStationStatusMapper.java @@ -33,49 +33,50 @@ void fillStationStatus(VehicleRentalStation station) { } GBFSStation status = statusLookup.get(station.getStationId()); - station.vehiclesAvailable = - status.getNumBikesAvailable() != null ? status.getNumBikesAvailable() : 0; - - station.vehicleTypesAvailable = - status.getVehicleTypesAvailable() != null - ? status - .getVehicleTypesAvailable() - .stream() - .filter(e -> containsVehicleType(e, status)) - .collect(Collectors.toMap(e -> vehicleTypes.get(e.getVehicleTypeId()), e -> e.getCount())) - : Map.of(RentalVehicleType.getDefaultType(station.getNetwork()), station.vehiclesAvailable); - - station.vehiclesDisabled = - status.getNumBikesDisabled() != null ? status.getNumBikesDisabled() : 0; - - station.spacesAvailable = - status.getNumDocksAvailable() != null ? status.getNumDocksAvailable() : Integer.MAX_VALUE; - - station.vehicleSpacesAvailable = - status.getVehicleDocksAvailable() != null - ? status - .getVehicleDocksAvailable() - .stream() - .flatMap(available -> - available - .getVehicleTypeIds() - .stream() - .map(t -> new VehicleTypeCount(vehicleTypes.get(t), available.getCount())) - ) - .collect(Collectors.toMap(VehicleTypeCount::type, VehicleTypeCount::count)) - : Map.of(RentalVehicleType.getDefaultType(station.getNetwork()), station.spacesAvailable); - - station.spacesDisabled = - status.getNumDocksDisabled() != null ? status.getNumDocksDisabled() : 0; + station.vehiclesAvailable = status.getNumBikesAvailable() != null + ? status.getNumBikesAvailable() + : 0; + + station.vehicleTypesAvailable = status.getVehicleTypesAvailable() != null + ? status + .getVehicleTypesAvailable() + .stream() + .filter(e -> containsVehicleType(e, status)) + .collect(Collectors.toMap(e -> vehicleTypes.get(e.getVehicleTypeId()), e -> e.getCount())) + : Map.of(RentalVehicleType.getDefaultType(station.getNetwork()), station.vehiclesAvailable); + + station.vehiclesDisabled = status.getNumBikesDisabled() != null + ? status.getNumBikesDisabled() + : 0; + + station.spacesAvailable = status.getNumDocksAvailable() != null + ? status.getNumDocksAvailable() + : Integer.MAX_VALUE; + + station.vehicleSpacesAvailable = status.getVehicleDocksAvailable() != null + ? status + .getVehicleDocksAvailable() + .stream() + .flatMap(available -> + available + .getVehicleTypeIds() + .stream() + .map(t -> new VehicleTypeCount(vehicleTypes.get(t), available.getCount())) + ) + .collect(Collectors.toMap(VehicleTypeCount::type, VehicleTypeCount::count)) + : Map.of(RentalVehicleType.getDefaultType(station.getNetwork()), station.spacesAvailable); + + station.spacesDisabled = status.getNumDocksDisabled() != null + ? status.getNumDocksDisabled() + : 0; station.isInstalled = status.getIsInstalled() != null ? status.getIsInstalled() : true; station.isRenting = status.getIsRenting() != null ? status.getIsRenting() : true; station.isReturning = status.getIsReturning() != null ? status.getIsReturning() : true; - station.lastReported = - status.getLastReported() != null - ? Instant.ofEpochSecond(status.getLastReported().longValue()) - : null; + station.lastReported = status.getLastReported() != null + ? Instant.ofEpochSecond(status.getLastReported().longValue()) + : null; } private boolean containsVehicleType( diff --git a/application/src/main/java/org/opentripplanner/updater/vehicle_rental/datasources/GbfsSystemInformationMapper.java b/application/src/main/java/org/opentripplanner/updater/vehicle_rental/datasources/GbfsSystemInformationMapper.java index 8011fd1ce63..0177b2a9523 100644 --- a/application/src/main/java/org/opentripplanner/updater/vehicle_rental/datasources/GbfsSystemInformationMapper.java +++ b/application/src/main/java/org/opentripplanner/updater/vehicle_rental/datasources/GbfsSystemInformationMapper.java @@ -12,18 +12,16 @@ public VehicleRentalSystem mapSystemInformation(GBFSData systemInformation, Stri if (systemInformation.getRentalApps() != null) { if (systemInformation.getRentalApps().getAndroid() != null) { - android = - new VehicleRentalSystemAppInformation( - systemInformation.getRentalApps().getAndroid().getStoreUri(), - systemInformation.getRentalApps().getAndroid().getDiscoveryUri() - ); + android = new VehicleRentalSystemAppInformation( + systemInformation.getRentalApps().getAndroid().getStoreUri(), + systemInformation.getRentalApps().getAndroid().getDiscoveryUri() + ); } if (systemInformation.getRentalApps().getIos() != null) { - ios = - new VehicleRentalSystemAppInformation( - systemInformation.getRentalApps().getIos().getStoreUri(), - systemInformation.getRentalApps().getIos().getDiscoveryUri() - ); + ios = new VehicleRentalSystemAppInformation( + systemInformation.getRentalApps().getIos().getStoreUri(), + systemInformation.getRentalApps().getIos().getDiscoveryUri() + ); } } diff --git a/application/src/main/java/org/opentripplanner/updater/vehicle_rental/datasources/GbfsVehicleRentalDataSource.java b/application/src/main/java/org/opentripplanner/updater/vehicle_rental/datasources/GbfsVehicleRentalDataSource.java index 331c4a15a70..2f0f995bb51 100644 --- a/application/src/main/java/org/opentripplanner/updater/vehicle_rental/datasources/GbfsVehicleRentalDataSource.java +++ b/application/src/main/java/org/opentripplanner/updater/vehicle_rental/datasources/GbfsVehicleRentalDataSource.java @@ -152,14 +152,17 @@ public List getUpdates() { @Override public void setup() { - loader = - new GbfsFeedLoader(params.url(), params.httpHeaders(), params.language(), otpHttpClient); + loader = new GbfsFeedLoader( + params.url(), + params.httpHeaders(), + params.language(), + otpHttpClient + ); } @Override public String toString() { - return ToStringBuilder - .of(GbfsVehicleRentalDataSource.class) + return ToStringBuilder.of(GbfsVehicleRentalDataSource.class) .addStr("url", params.url()) .addStr("language", params.language()) .addBoolIfTrue( diff --git a/application/src/main/java/org/opentripplanner/visualizer/ShowGraph.java b/application/src/main/java/org/opentripplanner/visualizer/ShowGraph.java index b03dc3c80cf..473c4b2df82 100644 --- a/application/src/main/java/org/opentripplanner/visualizer/ShowGraph.java +++ b/application/src/main/java/org/opentripplanner/visualizer/ShowGraph.java @@ -258,8 +258,8 @@ public void mouseDragged(MouseEvent e) { if (ctrlPressed || mouseButton == RIGHT) { zoom(dy * 0.01, startDrag); } else { - double tx = modelBounds.getWidth() * dx / getWidth(); - double ty = modelBounds.getHeight() * dy / getHeight(); + double tx = (modelBounds.getWidth() * dx) / getWidth(); + double ty = (modelBounds.getHeight() * dy) / getHeight(); modelBounds.translate(tx, ty); } dragX = c.x; @@ -757,18 +757,16 @@ private void drawCoords() { private void drawVertices() { /* turn off vertex display when zoomed out */ final double METERS_PER_DEGREE_LAT = 111111.111111; - boolean closeEnough = (modelBounds.getHeight() * METERS_PER_DEGREE_LAT / this.width < 5); + boolean closeEnough = ((modelBounds.getHeight() * METERS_PER_DEGREE_LAT) / this.width < 5); /* Draw selected visible vertices */ for (Vertex v : visibleVertices) { if ( drawTransitStopVertices && closeEnough && - ( - v instanceof TransitStopVertex || + (v instanceof TransitStopVertex || v instanceof TransitPathwayNodeVertex || v instanceof TransitEntranceVertex || - v instanceof TransitBoardingAreaVertex - ) + v instanceof TransitBoardingAreaVertex) ) { fill(60, 60, 200); // Make transit stops blue dots drawVertex(v, 7); @@ -783,17 +781,13 @@ private void drawVertices() { } if ( drawStreetVertices && - ( - (v instanceof IntersectionVertex && ((IntersectionVertex) v).hasCyclingTrafficLight()) || - ( - v instanceof ElevatorOnboardVertex || + ((v instanceof IntersectionVertex && ((IntersectionVertex) v).hasCyclingTrafficLight()) || + (v instanceof ElevatorOnboardVertex || v instanceof ElevatorOffboardVertex || v instanceof ExitVertex || v instanceof TemporaryVertex || v instanceof SplitterVertex || - v instanceof StreetLocation - ) - ) + v instanceof StreetLocation)) ) { if (v instanceof IntersectionVertex && ((IntersectionVertex) v).hasCyclingTrafficLight()) { fill(120, 60, 60); // Make traffic lights red dots @@ -922,9 +916,8 @@ private void drawPartial(int startMillis) { int drawStart = 0; int drawCount = 0; while (drawStart < DECIMATE && drawStart < visibleStreetEdges.size()) { - if (drawFast) drawEdgeFast(visibleStreetEdges.get(drawIndex)); else drawEdge( - visibleStreetEdges.get(drawIndex) - ); + if (drawFast) drawEdgeFast(visibleStreetEdges.get(drawIndex)); + else drawEdge(visibleStreetEdges.get(drawIndex)); drawIndex += DECIMATE; drawCount += 1; if (drawCount % BLOCK_SIZE == 0 && millis() - startMillis > FRAME_TIME) { @@ -1189,7 +1182,7 @@ private int colorRamp(int aa) { aa = aa % RAMPLEN; //make sure aa fits within the color ramp int hueIndex = aa / HUELEN; //establish the hue int hue = hueIndex * (HUELEN / NHUES); //convert that to a hue value - int saturation = HUELEN - aa % HUELEN; + int saturation = HUELEN - (aa % HUELEN); return color(hue, saturation, BRIGHTNESS); } diff --git a/application/src/test/java/org/opentripplanner/ConstantsForTests.java b/application/src/test/java/org/opentripplanner/ConstantsForTests.java index 2944eb5a290..78731e68617 100644 --- a/application/src/test/java/org/opentripplanner/ConstantsForTests.java +++ b/application/src/test/java/org/opentripplanner/ConstantsForTests.java @@ -141,8 +141,12 @@ public static TestOtpModel buildNewPortlandGraph(boolean withElevation) { var osmProvider = new DefaultOsmProvider(PORTLAND_CENTRAL_OSM, false); var osmInfoRepository = new DefaultOsmInfoGraphBuildRepository(); var vehicleParkingRepository = new DefaultVehicleParkingRepository(); - var osmModule = OsmModule - .of(osmProvider, graph, osmInfoRepository, vehicleParkingRepository) + var osmModule = OsmModule.of( + osmProvider, + graph, + osmInfoRepository, + vehicleParkingRepository + ) .withStaticParkAndRide(true) .withStaticBikeParkAndRide(true) .build(); @@ -180,8 +184,7 @@ public static TestOtpModel buildNewPortlandGraph(boolean withElevation) { DataImportIssueStore.NOOP, Duration.ofMinutes(30), List.of(new RouteRequest()) - ) - .buildGraph(); + ).buildGraph(); graph.index(timetableRepository.getSiteRepository()); @@ -201,9 +204,12 @@ public static TestOtpModel buildOsmGraph(File osmFile) { var osmProvider = new DefaultOsmProvider(osmFile, true); var osmInfoRepository = new DefaultOsmInfoGraphBuildRepository(); var vehicleParkingRepository = new DefaultVehicleParkingRepository(); - var osmModule = OsmModule - .of(osmProvider, graph, osmInfoRepository, vehicleParkingRepository) - .build(); + var osmModule = OsmModule.of( + osmProvider, + graph, + osmInfoRepository, + vehicleParkingRepository + ).build(); osmModule.buildGraph(); return new TestOtpModel(graph, timetableRepository); } catch (Exception e) { diff --git a/application/src/test/java/org/opentripplanner/GtfsTest.java b/application/src/test/java/org/opentripplanner/GtfsTest.java index cf7d2a8ce80..8160a679e23 100644 --- a/application/src/test/java/org/opentripplanner/GtfsTest.java +++ b/application/src/test/java/org/opentripplanner/GtfsTest.java @@ -110,8 +110,7 @@ public Itinerary plan( } routingRequest.setWheelchair(wheelchairAccessible); - RequestModesBuilder requestModesBuilder = RequestModes - .of() + RequestModesBuilder requestModesBuilder = RequestModes.of() .withDirectMode(NOT_SET) .withAccessMode(WALK) .withTransferMode(WALK) @@ -230,8 +229,11 @@ protected void setUp() throws Exception { TimetableSnapshotParameters.PUBLISH_IMMEDIATELY, LocalDate::now ); - tripUpdateAdapter = - new GtfsRealTimeTripUpdateAdapter(timetableRepository, snapshotManager, LocalDate::now); + tripUpdateAdapter = new GtfsRealTimeTripUpdateAdapter( + timetableRepository, + snapshotManager, + LocalDate::now + ); alertPatchServiceImpl = new TransitAlertServiceImpl(timetableRepository); alertsUpdateHandler.setTransitAlertService(alertPatchServiceImpl); alertsUpdateHandler.setFeedId(feedId.getId()); @@ -253,7 +255,11 @@ protected void setUp() throws Exception { ); alertsUpdateHandler.update(feedMessage, null); } catch (FileNotFoundException exception) {} - serverContext = - TestServerContext.createServerContext(graph, timetableRepository, snapshotManager, null); + serverContext = TestServerContext.createServerContext( + graph, + timetableRepository, + snapshotManager, + null + ); } } diff --git a/application/src/test/java/org/opentripplanner/OtpArchitectureModules.java b/application/src/test/java/org/opentripplanner/OtpArchitectureModules.java index 8d6fc431f50..4970f172385 100644 --- a/application/src/test/java/org/opentripplanner/OtpArchitectureModules.java +++ b/application/src/test/java/org/opentripplanner/OtpArchitectureModules.java @@ -24,8 +24,7 @@ public interface OtpArchitectureModules { Package DATASTORE = OTP_ROOT.subPackage("datastore"); Package FRAMEWORK = OTP_ROOT.subPackage("framework"); Module GEO_UTILS = Module.of(JTS_GEOM, FRAMEWORK.subPackage("geometry")); - Package RAPTOR_ADAPTER = OTP_ROOT - .subPackage("routing") + Package RAPTOR_ADAPTER = OTP_ROOT.subPackage("routing") .subPackage("algorithm") .subPackage("raptoradapter"); Package RAPTOR_ADAPTER_API = RAPTOR_ADAPTER.subPackage("api"); diff --git a/application/src/test/java/org/opentripplanner/TestServerContext.java b/application/src/test/java/org/opentripplanner/TestServerContext.java index e89dc98392b..30ad171b663 100644 --- a/application/src/test/java/org/opentripplanner/TestServerContext.java +++ b/application/src/test/java/org/opentripplanner/TestServerContext.java @@ -66,8 +66,11 @@ public static OtpServerRequestContext createServerContext( request = routerConfig.routingRequestDefaults(); } if (snapshotManager == null) { - snapshotManager = - new TimetableSnapshotManager(null, TimetableSnapshotParameters.DEFAULT, LocalDate::now); + snapshotManager = new TimetableSnapshotManager( + null, + TimetableSnapshotParameters.DEFAULT, + LocalDate::now + ); } timetableRepository.index(); @@ -114,8 +117,7 @@ public static OtpServerRequestContext createServerContext( /** Static factory method to create a service for test purposes. */ public static WorldEnvelopeService createWorldEnvelopeService() { var repository = new DefaultWorldEnvelopeRepository(); - var envelope = WorldEnvelope - .of() + var envelope = WorldEnvelope.of() .expandToIncludeStreetEntities(0, 0) .expandToIncludeStreetEntities(1, 1) .build(); diff --git a/application/src/test/java/org/opentripplanner/_support/geometry/Polygons.java b/application/src/test/java/org/opentripplanner/_support/geometry/Polygons.java index bdf59c70e82..50e7b54d94b 100644 --- a/application/src/test/java/org/opentripplanner/_support/geometry/Polygons.java +++ b/application/src/test/java/org/opentripplanner/_support/geometry/Polygons.java @@ -68,8 +68,7 @@ public class Polygons { public static org.geojson.Polygon toGeoJson(Polygon polygon) { var ret = new org.geojson.Polygon(); - var coordinates = Arrays - .stream(polygon.getCoordinates()) + var coordinates = Arrays.stream(polygon.getCoordinates()) .map(c -> new LngLatAlt(c.x, c.y)) .toList(); ret.add(coordinates); diff --git a/application/src/test/java/org/opentripplanner/_support/text/TextAssertionsTest.java b/application/src/test/java/org/opentripplanner/_support/text/TextAssertionsTest.java index 739b7b59c4b..c04871d3aea 100644 --- a/application/src/test/java/org/opentripplanner/_support/text/TextAssertionsTest.java +++ b/application/src/test/java/org/opentripplanner/_support/text/TextAssertionsTest.java @@ -15,27 +15,26 @@ void testIgnoreWhiteSpace() { // Text with white-space inserted assertLinesEquals( """ - A Test - Line 2 - DOS\r\n - line-shift - """, + A Test + Line 2 + DOS\r\n + line-shift + """, + """ + + A Test \t + \t + + \tLine 2 + DOS\rline-shift """ - - A Test \t - \t - - \tLine 2 - DOS\rline-shift - """ ); } @Test void testEndOfText() { - var ex = Assertions.assertThrows( - org.opentest4j.AssertionFailedError.class, - () -> assertLinesEquals("A\n", "A\nExtra Line") + var ex = Assertions.assertThrows(org.opentest4j.AssertionFailedError.class, () -> + assertLinesEquals("A\n", "A\nExtra Line") ); Assertions.assertTrue( ex.getMessage().contains("Expected(@end-of-text)"), diff --git a/application/src/test/java/org/opentripplanner/apis/gtfs/CoordinateValueScalarTest.java b/application/src/test/java/org/opentripplanner/apis/gtfs/CoordinateValueScalarTest.java index 99042498342..be8fa6b9516 100644 --- a/application/src/test/java/org/opentripplanner/apis/gtfs/CoordinateValueScalarTest.java +++ b/application/src/test/java/org/opentripplanner/apis/gtfs/CoordinateValueScalarTest.java @@ -26,77 +26,60 @@ class CoordinateValueScalarTest { @Test void testSerialize() { - var coordinate = (Double) GraphQLScalars.COORDINATE_VALUE_SCALAR - .getCoercing() + var coordinate = (Double) GraphQLScalars.COORDINATE_VALUE_SCALAR.getCoercing() .serialize(COORDINATE); assertEquals(COORDINATE, coordinate, DELTA); - coordinate = - (Double) GraphQLScalars.COORDINATE_VALUE_SCALAR - .getCoercing() - .serialize(COORDINATE.floatValue()); + coordinate = (Double) GraphQLScalars.COORDINATE_VALUE_SCALAR.getCoercing() + .serialize(COORDINATE.floatValue()); assertEquals(COORDINATE, coordinate, DELTA); - assertThrows( - CoercingSerializeException.class, - () -> GraphQLScalars.COORDINATE_VALUE_SCALAR.getCoercing().serialize(TEXT) + assertThrows(CoercingSerializeException.class, () -> + GraphQLScalars.COORDINATE_VALUE_SCALAR.getCoercing().serialize(TEXT) ); } @Test void testParseValue() { - var coordinate = (Double) GraphQLScalars.COORDINATE_VALUE_SCALAR - .getCoercing() + var coordinate = (Double) GraphQLScalars.COORDINATE_VALUE_SCALAR.getCoercing() .parseValue(COORDINATE); assertEquals(COORDINATE, coordinate, DELTA); - coordinate = - (Double) GraphQLScalars.COORDINATE_VALUE_SCALAR.getCoercing().parseValue(COORDINATE_MIN); + coordinate = (Double) GraphQLScalars.COORDINATE_VALUE_SCALAR.getCoercing() + .parseValue(COORDINATE_MIN); assertEquals(COORDINATE_MIN, coordinate, DELTA); - coordinate = - (Double) GraphQLScalars.COORDINATE_VALUE_SCALAR.getCoercing().parseValue(COORDINATE_MAX); + coordinate = (Double) GraphQLScalars.COORDINATE_VALUE_SCALAR.getCoercing() + .parseValue(COORDINATE_MAX); assertEquals(COORDINATE_MAX, coordinate, DELTA); - coordinate = - (Double) GraphQLScalars.COORDINATE_VALUE_SCALAR.getCoercing().parseValue(COORDINATE_INT); + coordinate = (Double) GraphQLScalars.COORDINATE_VALUE_SCALAR.getCoercing() + .parseValue(COORDINATE_INT); assertEquals(COORDINATE_INT, coordinate, DELTA); - assertThrows( - CoercingParseValueException.class, - () -> GraphQLScalars.COORDINATE_VALUE_SCALAR.getCoercing().parseValue(TEXT) + assertThrows(CoercingParseValueException.class, () -> + GraphQLScalars.COORDINATE_VALUE_SCALAR.getCoercing().parseValue(TEXT) ); - assertThrows( - CoercingParseValueException.class, - () -> GraphQLScalars.COORDINATE_VALUE_SCALAR.getCoercing().parseValue(TOO_LOW) + assertThrows(CoercingParseValueException.class, () -> + GraphQLScalars.COORDINATE_VALUE_SCALAR.getCoercing().parseValue(TOO_LOW) ); - assertThrows( - CoercingParseValueException.class, - () -> GraphQLScalars.COORDINATE_VALUE_SCALAR.getCoercing().parseValue(TOO_HIGH) + assertThrows(CoercingParseValueException.class, () -> + GraphQLScalars.COORDINATE_VALUE_SCALAR.getCoercing().parseValue(TOO_HIGH) ); } @Test void testParseLiteral() { - var coordinateDouble = (Double) GraphQLScalars.COORDINATE_VALUE_SCALAR - .getCoercing() + var coordinateDouble = (Double) GraphQLScalars.COORDINATE_VALUE_SCALAR.getCoercing() .parseLiteral(new FloatValue(BigDecimal.valueOf(COORDINATE))); assertEquals(COORDINATE, coordinateDouble, DELTA); - var coordinateInt = (Double) GraphQLScalars.COORDINATE_VALUE_SCALAR - .getCoercing() + var coordinateInt = (Double) GraphQLScalars.COORDINATE_VALUE_SCALAR.getCoercing() .parseLiteral(new IntValue(BigInteger.valueOf(COORDINATE.intValue()))); assertEquals(COORDINATE, coordinateInt, DELTA); - assertThrows( - CoercingParseLiteralException.class, - () -> GraphQLScalars.COORDINATE_VALUE_SCALAR.getCoercing().parseLiteral(new StringValue(TEXT)) + assertThrows(CoercingParseLiteralException.class, () -> + GraphQLScalars.COORDINATE_VALUE_SCALAR.getCoercing().parseLiteral(new StringValue(TEXT)) ); - assertThrows( - CoercingParseLiteralException.class, - () -> - GraphQLScalars.COORDINATE_VALUE_SCALAR - .getCoercing() - .parseLiteral(new FloatValue(BigDecimal.valueOf(TOO_HIGH))) + assertThrows(CoercingParseLiteralException.class, () -> + GraphQLScalars.COORDINATE_VALUE_SCALAR.getCoercing() + .parseLiteral(new FloatValue(BigDecimal.valueOf(TOO_HIGH))) ); - assertThrows( - CoercingParseLiteralException.class, - () -> - GraphQLScalars.COORDINATE_VALUE_SCALAR - .getCoercing() - .parseLiteral(new FloatValue(BigDecimal.valueOf(TOO_LOW))) + assertThrows(CoercingParseLiteralException.class, () -> + GraphQLScalars.COORDINATE_VALUE_SCALAR.getCoercing() + .parseLiteral(new FloatValue(BigDecimal.valueOf(TOO_LOW))) ); } } diff --git a/application/src/test/java/org/opentripplanner/apis/gtfs/CostScalarTest.java b/application/src/test/java/org/opentripplanner/apis/gtfs/CostScalarTest.java index bb8b5bfe445..f89366d86a1 100644 --- a/application/src/test/java/org/opentripplanner/apis/gtfs/CostScalarTest.java +++ b/application/src/test/java/org/opentripplanner/apis/gtfs/CostScalarTest.java @@ -26,9 +26,8 @@ void testSerialize() { assertEquals(THIRTY, cost); var costNumber = GraphQLScalars.COST_SCALAR.getCoercing().serialize(THIRTY); assertEquals(THIRTY, costNumber); - assertThrows( - CoercingSerializeException.class, - () -> GraphQLScalars.COST_SCALAR.getCoercing().serialize(TEXT) + assertThrows(CoercingSerializeException.class, () -> + GraphQLScalars.COST_SCALAR.getCoercing().serialize(TEXT) ); } @@ -36,43 +35,32 @@ void testSerialize() { void testParseValue() { var cost = GraphQLScalars.COST_SCALAR.getCoercing().parseValue(THIRTY); assertEquals(COST_THIRTY, cost); - assertThrows( - CoercingParseValueException.class, - () -> GraphQLScalars.COST_SCALAR.getCoercing().parseValue(TEXT) + assertThrows(CoercingParseValueException.class, () -> + GraphQLScalars.COST_SCALAR.getCoercing().parseValue(TEXT) ); - assertThrows( - CoercingParseValueException.class, - () -> GraphQLScalars.COST_SCALAR.getCoercing().parseValue(NEGATIVE_THIRTY) + assertThrows(CoercingParseValueException.class, () -> + GraphQLScalars.COST_SCALAR.getCoercing().parseValue(NEGATIVE_THIRTY) ); - assertThrows( - CoercingParseValueException.class, - () -> GraphQLScalars.COST_SCALAR.getCoercing().parseValue(TOO_HIGH) + assertThrows(CoercingParseValueException.class, () -> + GraphQLScalars.COST_SCALAR.getCoercing().parseValue(TOO_HIGH) ); } @Test void testParseLiteral() { - var cost = GraphQLScalars.COST_SCALAR - .getCoercing() + var cost = GraphQLScalars.COST_SCALAR.getCoercing() .parseLiteral(new IntValue(BigInteger.valueOf(THIRTY))); assertEquals(COST_THIRTY, cost); - assertThrows( - CoercingParseLiteralException.class, - () -> GraphQLScalars.COST_SCALAR.getCoercing().parseLiteral(new StringValue(TEXT)) + assertThrows(CoercingParseLiteralException.class, () -> + GraphQLScalars.COST_SCALAR.getCoercing().parseLiteral(new StringValue(TEXT)) ); - assertThrows( - CoercingParseLiteralException.class, - () -> - GraphQLScalars.COST_SCALAR - .getCoercing() - .parseLiteral(new IntValue(BigInteger.valueOf(NEGATIVE_THIRTY))) + assertThrows(CoercingParseLiteralException.class, () -> + GraphQLScalars.COST_SCALAR.getCoercing() + .parseLiteral(new IntValue(BigInteger.valueOf(NEGATIVE_THIRTY))) ); - assertThrows( - CoercingParseLiteralException.class, - () -> - GraphQLScalars.COST_SCALAR - .getCoercing() - .parseLiteral(new IntValue(BigInteger.valueOf(TOO_HIGH))) + assertThrows(CoercingParseLiteralException.class, () -> + GraphQLScalars.COST_SCALAR.getCoercing() + .parseLiteral(new IntValue(BigInteger.valueOf(TOO_HIGH))) ); } } diff --git a/application/src/test/java/org/opentripplanner/apis/gtfs/DurationScalarTest.java b/application/src/test/java/org/opentripplanner/apis/gtfs/DurationScalarTest.java index 28d1ad08376..5d3476ceaa2 100644 --- a/application/src/test/java/org/opentripplanner/apis/gtfs/DurationScalarTest.java +++ b/application/src/test/java/org/opentripplanner/apis/gtfs/DurationScalarTest.java @@ -33,9 +33,8 @@ void duration(Duration duration, String expected) { @Test void nonDuration() { - Assertions.assertThrows( - CoercingSerializeException.class, - () -> GraphQLScalars.DURATION_SCALAR.getCoercing().serialize(new Object()) + Assertions.assertThrows(CoercingSerializeException.class, () -> + GraphQLScalars.DURATION_SCALAR.getCoercing().serialize(new Object()) ); } } diff --git a/application/src/test/java/org/opentripplanner/apis/gtfs/GeoJsonScalarTest.java b/application/src/test/java/org/opentripplanner/apis/gtfs/GeoJsonScalarTest.java index 9890b2d5398..914453cb847 100644 --- a/application/src/test/java/org/opentripplanner/apis/gtfs/GeoJsonScalarTest.java +++ b/application/src/test/java/org/opentripplanner/apis/gtfs/GeoJsonScalarTest.java @@ -23,8 +23,7 @@ void geoJson() throws JsonProcessingException { ); var geoJson = GraphQLScalars.GEOJSON_SCALAR.getCoercing().serialize(polygon); - var expected = ObjectMappers - .ignoringExtraFields() + var expected = ObjectMappers.ignoringExtraFields() .readTree( "{\"type\":\"Polygon\",\"coordinates\":[[[0.0,0.0],[1.0,1.0],[2.0,2.0],[0.0,0.0]]]}" ); diff --git a/application/src/test/java/org/opentripplanner/apis/gtfs/GraphQLIntegrationTest.java b/application/src/test/java/org/opentripplanner/apis/gtfs/GraphQLIntegrationTest.java index f6416f6aadb..256d8f79302 100644 --- a/application/src/test/java/org/opentripplanner/apis/gtfs/GraphQLIntegrationTest.java +++ b/application/src/test/java/org/opentripplanner/apis/gtfs/GraphQLIntegrationTest.java @@ -128,8 +128,7 @@ class GraphQLIntegrationTest { private static final Place G = TEST_MODEL.place("G", 9.5, 11.0); private static final Place H = TEST_MODEL.place("H", 10.0, 11.5); - private static final List STOP_LOCATIONS = Stream - .of(A, B, C, D, E, F, G, H) + private static final List STOP_LOCATIONS = Stream.of(A, B, C, D, E, F, G, H) .map(p -> (RegularStop) p.stop) .toList(); private static final Route ROUTE = TimetableRepositoryForTest.route("a-route").build(); @@ -138,30 +137,31 @@ class GraphQLIntegrationTest { public static final ZoneId TIME_ZONE = ZoneIds.BERLIN; public static final String FEED_ID = TimetableRepositoryForTest.FEED_ID; - private static final VehicleRentalStation VEHICLE_RENTAL_STATION = new TestVehicleRentalStationBuilder() - .withVehicles(10) - .withSpaces(10) - .withVehicleTypeBicycle(5, 7) - .withVehicleTypeElectricBicycle(5, 3) - .withSystem("Network-1", "https://foo.bar") - .build(); - - private static final VehicleRentalVehicle RENTAL_VEHICLE_1 = new TestFreeFloatingRentalVehicleBuilder() - .withSystem("Network-1", "https://foo.bar") - .build(); - - private static final VehicleRentalVehicle RENTAL_VEHICLE_2 = new TestFreeFloatingRentalVehicleBuilder() - .withSystem("Network-2", "https://foo.bar.baz") - .withNetwork("Network-2") - .withCurrentRangeMeters(null) - .withCurrentFuelPercent(null) - .build(); + private static final VehicleRentalStation VEHICLE_RENTAL_STATION = + new TestVehicleRentalStationBuilder() + .withVehicles(10) + .withSpaces(10) + .withVehicleTypeBicycle(5, 7) + .withVehicleTypeElectricBicycle(5, 3) + .withSystem("Network-1", "https://foo.bar") + .build(); + + private static final VehicleRentalVehicle RENTAL_VEHICLE_1 = + new TestFreeFloatingRentalVehicleBuilder().withSystem("Network-1", "https://foo.bar").build(); + + private static final VehicleRentalVehicle RENTAL_VEHICLE_2 = + new TestFreeFloatingRentalVehicleBuilder() + .withSystem("Network-2", "https://foo.bar.baz") + .withNetwork("Network-2") + .withCurrentRangeMeters(null) + .withCurrentFuelPercent(null) + .build(); static final Graph GRAPH = new Graph(); - static final Instant ALERT_START_TIME = OffsetDateTime - .parse("2023-02-15T12:03:28+01:00") - .toInstant(); + static final Instant ALERT_START_TIME = OffsetDateTime.parse( + "2023-02-15T12:03:28+01:00" + ).toInstant(); static final Instant ALERT_END_TIME = ALERT_START_TIME.plus(1, ChronoUnit.DAYS); private static final int TEN_MINUTES = 10 * 60; @@ -171,14 +171,14 @@ class GraphQLIntegrationTest { private static GraphQLRequestContext context; private static final Deduplicator DEDUPLICATOR = new Deduplicator(); - private static final VehicleParkingRepository parkingRepository = new DefaultVehicleParkingRepository(); + private static final VehicleParkingRepository parkingRepository = + new DefaultVehicleParkingRepository(); @BeforeAll static void setup() { parkingRepository.updateVehicleParking( List.of( - VehicleParking - .builder() + VehicleParking.builder() .id(id("parking-1")) .coordinate(WgsCoordinate.GREENWICH) .name(NonLocalizedString.ofNullable("parking")) @@ -193,27 +193,23 @@ static void setup() { var timetableRepository = new TimetableRepository(siteRepository, DEDUPLICATOR); var cal_id = TimetableRepositoryForTest.id("CAL_1"); - var trip = TimetableRepositoryForTest - .trip("123") + var trip = TimetableRepositoryForTest.trip("123") .withHeadsign(I18NString.of("Trip Headsign")) .withServiceId(cal_id) .build(); var stopTimes = TEST_MODEL.stopTimesEvery5Minutes(3, trip, "11:00"); var tripTimes = TripTimesFactory.tripTimes(trip, stopTimes, DEDUPLICATOR); - var trip2 = TimetableRepositoryForTest - .trip("321Canceled") + var trip2 = TimetableRepositoryForTest.trip("321Canceled") .withHeadsign(I18NString.of("Trip Headsign")) .withServiceId(cal_id) .build(); var stopTimes2 = TEST_MODEL.stopTimesEvery5Minutes(3, trip2, "11:30"); var tripTimes2 = TripTimesFactory.tripTimes(trip2, stopTimes2, DEDUPLICATOR); - var tripToBeReplaced = TimetableRepositoryForTest - .trip(REPLACEMENT_TRIP_ID) + var tripToBeReplaced = TimetableRepositoryForTest.trip(REPLACEMENT_TRIP_ID) .withServiceId(cal_id) .build(); - final TripPattern pattern = TEST_MODEL - .pattern(BUS) + final TripPattern pattern = TEST_MODEL.pattern(BUS) .withScheduledTimeTableBuilder(builder -> builder .addTripTimes(tripTimes) @@ -233,8 +229,7 @@ static void setup() { var feedInfo = FeedInfo.dummyForTest(FEED_ID); timetableRepository.addFeedInfo(feedInfo); - var agency = Agency - .of(new FeedScopedId(FEED_ID, "agency-xx")) + var agency = Agency.of(new FeedScopedId(FEED_ID, "agency-xx")) .withName("speedtransit") .withUrl("www.otp-foo.bar") .withTimezone("Europe/Berlin") @@ -263,12 +258,10 @@ static void setup() { tripTimes2.cancelTrip(); timetableSnapshot.update(new RealTimeTripUpdate(pattern, tripTimes2, secondDate)); - var routes = Arrays - .stream(TransitMode.values()) + var routes = Arrays.stream(TransitMode.values()) .sorted(Comparator.comparing(Enum::name)) .map(m -> - TimetableRepositoryForTest - .route(m.name()) + TimetableRepositoryForTest.route(m.name()) .withMode(m) .withLongName(I18NString.of("Long name for %s".formatted(m))) .withGtfsSortOrder(sortOrder(m)) @@ -279,8 +272,7 @@ static void setup() { var busRoute = routes.stream().filter(r -> r.getMode().equals(BUS)).findFirst().get(); - final Trip addedTrip = Trip - .of(new FeedScopedId(FEED_ID, ADDED_TRIP_ID)) + final Trip addedTrip = Trip.of(new FeedScopedId(FEED_ID, ADDED_TRIP_ID)) .withRoute(busRoute) .build(); @@ -293,8 +285,7 @@ static void setup() { realTimeTripTimes.setServiceCode(SERVICE_CODE); timetableSnapshot.update( new RealTimeTripUpdate( - TripPattern - .of(new FeedScopedId(FEED_ID, "ADDED_TRIP_PATTERN")) + TripPattern.of(new FeedScopedId(FEED_ID, "ADDED_TRIP_PATTERN")) .withRoute(t.getRoute()) .withStopPattern( TimetableRepositoryForTest.stopPattern( @@ -346,8 +337,7 @@ public Set findRoutes(StopLocation stop) { .build(); var step2 = walkStep("elevator").withRelativeDirection(RelativeDirection.ELEVATOR).build(); FeedScopedId entranceId = new FeedScopedId("osm", "123"); - Entrance entrance = Entrance - .of(entranceId) + Entrance entrance = Entrance.of(entranceId) .withCoordinate(new WgsCoordinate(60, 80)) .withCode("A") .withWheelchairAccessibility(Accessibility.POSSIBLE) @@ -358,8 +348,7 @@ public Set findRoutes(StopLocation stop) { .build(); var entitySelector = new EntitySelector.Stop(A.stop.getId()); - var alert = TransitAlert - .of(id("an-alert")) + var alert = TransitAlert.of(id("an-alert")) .withHeaderText(I18NString.of("A header")) .withDescriptionText(I18NString.of("A description")) .withUrl(I18NString.of("https://example.com")) @@ -410,15 +399,13 @@ public Set findRoutes(StopLocation stop) { transitService.getTransitAlertService().setAlerts(alerts); var realtimeVehicleService = new DefaultRealtimeVehicleService(transitService); - var occypancyVehicle = RealtimeVehicle - .builder() + var occypancyVehicle = RealtimeVehicle.builder() .withTrip(trip) .withTime(Instant.MAX) .withVehicleId(id("vehicle-1")) .withOccupancyStatus(FEW_SEATS_AVAILABLE) .build(); - var positionVehicle = RealtimeVehicle - .builder() + var positionVehicle = RealtimeVehicle.builder() .withTrip(trip) .withTime(Instant.MIN) .withVehicleId(id("vehicle-2")) @@ -437,18 +424,17 @@ public Set findRoutes(StopLocation stop) { defaultVehicleRentalService.addVehicleRentalStation(RENTAL_VEHICLE_2); var routeRequest = new RouteRequest(); - context = - new GraphQLRequestContext( - new TestRoutingService(List.of(i1)), - transitService, - new DefaultFareService(), - defaultVehicleRentalService, - new DefaultVehicleParkingService(parkingRepository), - realtimeVehicleService, - SchemaFactory.createSchemaWithDefaultInjection(routeRequest), - finder, - routeRequest - ); + context = new GraphQLRequestContext( + new TestRoutingService(List.of(i1)), + transitService, + new DefaultFareService(), + defaultVehicleRentalService, + new DefaultVehicleParkingService(parkingRepository), + realtimeVehicleService, + SchemaFactory.createSchemaWithDefaultInjection(routeRequest), + finder, + routeRequest + ); } private static BikeAccess bikesAllowed(TransitMode m) { @@ -520,28 +506,24 @@ void graphQL(Path path) throws IOException { } private static List getTransitAlert(EntitySelector.Stop entitySelector) { - var alertWithoutDescription = TransitAlert - .of(id("no-description")) + var alertWithoutDescription = TransitAlert.of(id("no-description")) .withHeaderText(I18NStrings.TRANSLATED_STRING_1) .addEntity(entitySelector); - var alertWithoutHeader = TransitAlert - .of(id("no-header")) + var alertWithoutHeader = TransitAlert.of(id("no-header")) .withDescriptionText(I18NStrings.TRANSLATED_STRING_2) .addEntity(entitySelector); - var alertWithNothing = TransitAlert - .of(id("neither-header-nor-description")) - .addEntity(entitySelector); + var alertWithNothing = TransitAlert.of(id("neither-header-nor-description")).addEntity( + entitySelector + ); - return Stream - .of(alertWithoutDescription, alertWithoutHeader, alertWithNothing) + return Stream.of(alertWithoutDescription, alertWithoutHeader, alertWithNothing) .map(AbstractBuilder::build) .toList(); } private static WalkStepBuilder walkStep(String name) { - return WalkStep - .builder() + return WalkStep.builder() .withDirectionText(I18NString.of(name)) .withStartLocation(WgsCoordinate.GREENWICH) .withAngle(10); diff --git a/application/src/test/java/org/opentripplanner/apis/gtfs/OffsetDateTimeScalarTest.java b/application/src/test/java/org/opentripplanner/apis/gtfs/OffsetDateTimeScalarTest.java index 45c8e9de837..59c4e7309b1 100644 --- a/application/src/test/java/org/opentripplanner/apis/gtfs/OffsetDateTimeScalarTest.java +++ b/application/src/test/java/org/opentripplanner/apis/gtfs/OffsetDateTimeScalarTest.java @@ -54,8 +54,7 @@ void parseOffsetDateTime(OffsetDateTime expected, String input) { @ParameterizedTest @MethodSource("offsetDateTimeCases") void parseOffsetDateTimeLiteral(OffsetDateTime expected, String input) { - var odt = GraphQLScalars.OFFSET_DATETIME_SCALAR - .getCoercing() + var odt = GraphQLScalars.OFFSET_DATETIME_SCALAR.getCoercing() .parseLiteral(new StringValue(input)); assertEquals(expected, odt); } diff --git a/application/src/test/java/org/opentripplanner/apis/gtfs/RatioScalarTest.java b/application/src/test/java/org/opentripplanner/apis/gtfs/RatioScalarTest.java index b628ef3f5d1..af058f29192 100644 --- a/application/src/test/java/org/opentripplanner/apis/gtfs/RatioScalarTest.java +++ b/application/src/test/java/org/opentripplanner/apis/gtfs/RatioScalarTest.java @@ -29,9 +29,8 @@ void testSerialize() { assertEquals(HALF, ratio, DELTA); ratio = (Double) GraphQLScalars.RATIO_SCALAR.getCoercing().serialize(HALF.floatValue()); assertEquals(HALF, ratio, DELTA); - assertThrows( - CoercingSerializeException.class, - () -> GraphQLScalars.RATIO_SCALAR.getCoercing().serialize(TEXT) + assertThrows(CoercingSerializeException.class, () -> + GraphQLScalars.RATIO_SCALAR.getCoercing().serialize(TEXT) ); } @@ -43,47 +42,35 @@ void testParseValue() { assertEquals(ZERO, ratio, DELTA); ratio = (Double) GraphQLScalars.RATIO_SCALAR.getCoercing().parseValue(ONE); assertEquals(ONE, ratio, DELTA); - assertThrows( - CoercingParseValueException.class, - () -> GraphQLScalars.RATIO_SCALAR.getCoercing().parseValue(TEXT) + assertThrows(CoercingParseValueException.class, () -> + GraphQLScalars.RATIO_SCALAR.getCoercing().parseValue(TEXT) ); - assertThrows( - CoercingParseValueException.class, - () -> GraphQLScalars.RATIO_SCALAR.getCoercing().parseValue(TOO_LOW) + assertThrows(CoercingParseValueException.class, () -> + GraphQLScalars.RATIO_SCALAR.getCoercing().parseValue(TOO_LOW) ); - assertThrows( - CoercingParseValueException.class, - () -> GraphQLScalars.RATIO_SCALAR.getCoercing().parseValue(TOO_HIGH) + assertThrows(CoercingParseValueException.class, () -> + GraphQLScalars.RATIO_SCALAR.getCoercing().parseValue(TOO_HIGH) ); } @Test void testParseLiteral() { - var ratioDouble = (Double) GraphQLScalars.RATIO_SCALAR - .getCoercing() + var ratioDouble = (Double) GraphQLScalars.RATIO_SCALAR.getCoercing() .parseLiteral(new FloatValue(BigDecimal.valueOf(HALF))); assertEquals(HALF, ratioDouble, DELTA); - var ratioInt = (Double) GraphQLScalars.RATIO_SCALAR - .getCoercing() + var ratioInt = (Double) GraphQLScalars.RATIO_SCALAR.getCoercing() .parseLiteral(new IntValue(BigInteger.valueOf(HALF.intValue()))); assertEquals(HALF.intValue(), ratioInt, DELTA); - assertThrows( - CoercingParseLiteralException.class, - () -> GraphQLScalars.RATIO_SCALAR.getCoercing().parseLiteral(new StringValue(TEXT)) + assertThrows(CoercingParseLiteralException.class, () -> + GraphQLScalars.RATIO_SCALAR.getCoercing().parseLiteral(new StringValue(TEXT)) ); - assertThrows( - CoercingParseLiteralException.class, - () -> - GraphQLScalars.RATIO_SCALAR - .getCoercing() - .parseLiteral(new FloatValue(BigDecimal.valueOf(TOO_HIGH))) + assertThrows(CoercingParseLiteralException.class, () -> + GraphQLScalars.RATIO_SCALAR.getCoercing() + .parseLiteral(new FloatValue(BigDecimal.valueOf(TOO_HIGH))) ); - assertThrows( - CoercingParseLiteralException.class, - () -> - GraphQLScalars.RATIO_SCALAR - .getCoercing() - .parseLiteral(new FloatValue(BigDecimal.valueOf(TOO_LOW))) + assertThrows(CoercingParseLiteralException.class, () -> + GraphQLScalars.RATIO_SCALAR.getCoercing() + .parseLiteral(new FloatValue(BigDecimal.valueOf(TOO_LOW))) ); } } diff --git a/application/src/test/java/org/opentripplanner/apis/gtfs/ReluctanceScalarTest.java b/application/src/test/java/org/opentripplanner/apis/gtfs/ReluctanceScalarTest.java index 40684e85885..5b17d2aec75 100644 --- a/application/src/test/java/org/opentripplanner/apis/gtfs/ReluctanceScalarTest.java +++ b/application/src/test/java/org/opentripplanner/apis/gtfs/ReluctanceScalarTest.java @@ -26,12 +26,11 @@ class ReluctanceScalarTest { void testSerialize() { var reluctance = (Double) GraphQLScalars.RELUCTANCE_SCALAR.getCoercing().serialize(HALF); assertEquals(HALF, reluctance, DELTA); - reluctance = - (Double) GraphQLScalars.RELUCTANCE_SCALAR.getCoercing().serialize(HALF.floatValue()); + reluctance = (Double) GraphQLScalars.RELUCTANCE_SCALAR.getCoercing() + .serialize(HALF.floatValue()); assertEquals(HALF, reluctance, DELTA); - assertThrows( - CoercingSerializeException.class, - () -> GraphQLScalars.RELUCTANCE_SCALAR.getCoercing().serialize(TEXT) + assertThrows(CoercingSerializeException.class, () -> + GraphQLScalars.RELUCTANCE_SCALAR.getCoercing().serialize(TEXT) ); } @@ -41,47 +40,35 @@ void testParseValue() { assertEquals(HALF, reluctanceDouble, DELTA); var reluctanceInt = (Double) GraphQLScalars.RELUCTANCE_SCALAR.getCoercing().parseValue(ONE); assertEquals(ONE, reluctanceInt, DELTA); - assertThrows( - CoercingParseValueException.class, - () -> GraphQLScalars.RELUCTANCE_SCALAR.getCoercing().parseValue(TEXT) + assertThrows(CoercingParseValueException.class, () -> + GraphQLScalars.RELUCTANCE_SCALAR.getCoercing().parseValue(TEXT) ); - assertThrows( - CoercingParseValueException.class, - () -> GraphQLScalars.RELUCTANCE_SCALAR.getCoercing().parseValue(TOO_LOW) + assertThrows(CoercingParseValueException.class, () -> + GraphQLScalars.RELUCTANCE_SCALAR.getCoercing().parseValue(TOO_LOW) ); - assertThrows( - CoercingParseValueException.class, - () -> GraphQLScalars.RELUCTANCE_SCALAR.getCoercing().parseValue(TOO_HIGH) + assertThrows(CoercingParseValueException.class, () -> + GraphQLScalars.RELUCTANCE_SCALAR.getCoercing().parseValue(TOO_HIGH) ); } @Test void testParseLiteral() { - var reluctanceDouble = (Double) GraphQLScalars.RELUCTANCE_SCALAR - .getCoercing() + var reluctanceDouble = (Double) GraphQLScalars.RELUCTANCE_SCALAR.getCoercing() .parseLiteral(new FloatValue(BigDecimal.valueOf(HALF))); assertEquals(HALF, reluctanceDouble, DELTA); - var reluctanceInt = (Double) GraphQLScalars.RELUCTANCE_SCALAR - .getCoercing() + var reluctanceInt = (Double) GraphQLScalars.RELUCTANCE_SCALAR.getCoercing() .parseLiteral(new IntValue(BigInteger.valueOf(ONE))); assertEquals(ONE, reluctanceInt, DELTA); - assertThrows( - CoercingParseLiteralException.class, - () -> GraphQLScalars.RELUCTANCE_SCALAR.getCoercing().parseLiteral(new StringValue(TEXT)) + assertThrows(CoercingParseLiteralException.class, () -> + GraphQLScalars.RELUCTANCE_SCALAR.getCoercing().parseLiteral(new StringValue(TEXT)) ); - assertThrows( - CoercingParseLiteralException.class, - () -> - GraphQLScalars.RELUCTANCE_SCALAR - .getCoercing() - .parseLiteral(new FloatValue(BigDecimal.valueOf(TOO_HIGH))) + assertThrows(CoercingParseLiteralException.class, () -> + GraphQLScalars.RELUCTANCE_SCALAR.getCoercing() + .parseLiteral(new FloatValue(BigDecimal.valueOf(TOO_HIGH))) ); - assertThrows( - CoercingParseLiteralException.class, - () -> - GraphQLScalars.RELUCTANCE_SCALAR - .getCoercing() - .parseLiteral(new FloatValue(BigDecimal.valueOf(TOO_LOW))) + assertThrows(CoercingParseLiteralException.class, () -> + GraphQLScalars.RELUCTANCE_SCALAR.getCoercing() + .parseLiteral(new FloatValue(BigDecimal.valueOf(TOO_LOW))) ); } } diff --git a/application/src/test/java/org/opentripplanner/apis/gtfs/SchemaFactoryTest.java b/application/src/test/java/org/opentripplanner/apis/gtfs/SchemaFactoryTest.java index dac20e3af37..ba306c81a5f 100644 --- a/application/src/test/java/org/opentripplanner/apis/gtfs/SchemaFactoryTest.java +++ b/application/src/test/java/org/opentripplanner/apis/gtfs/SchemaFactoryTest.java @@ -87,8 +87,7 @@ private static DataFetcher getQueryType(String fieldName, GraphQLSchema schem .getCodeRegistry() .getDataFetcher( FieldCoordinates.coordinates("QueryType", fieldName), - GraphQLFieldDefinition - .newFieldDefinition() + GraphQLFieldDefinition.newFieldDefinition() .name(fieldName) .type(GraphQLObjectType.newObject().name(fieldName).build()) .build() diff --git a/application/src/test/java/org/opentripplanner/apis/gtfs/TestRoutingService.java b/application/src/test/java/org/opentripplanner/apis/gtfs/TestRoutingService.java index 57c965eb3f1..47f51ad55bd 100644 --- a/application/src/test/java/org/opentripplanner/apis/gtfs/TestRoutingService.java +++ b/application/src/test/java/org/opentripplanner/apis/gtfs/TestRoutingService.java @@ -19,15 +19,14 @@ public class TestRoutingService implements RoutingService { private final RoutingResponse routingResponse; public TestRoutingService(List results) { - routingResponse = - new RoutingResponse( - new TripPlan(PlanTestConstants.A, PlanTestConstants.B, instant, results), - null, - null, - null, - List.of(), - new DebugTimingAggregator() - ); + routingResponse = new RoutingResponse( + new TripPlan(PlanTestConstants.A, PlanTestConstants.B, instant, results), + null, + null, + null, + List.of(), + new DebugTimingAggregator() + ); } @Override diff --git a/application/src/test/java/org/opentripplanner/apis/gtfs/datafetchers/BookingInfoImplTest.java b/application/src/test/java/org/opentripplanner/apis/gtfs/datafetchers/BookingInfoImplTest.java index d721a73939b..8400e62290d 100644 --- a/application/src/test/java/org/opentripplanner/apis/gtfs/datafetchers/BookingInfoImplTest.java +++ b/application/src/test/java/org/opentripplanner/apis/gtfs/datafetchers/BookingInfoImplTest.java @@ -15,8 +15,7 @@ class BookingInfoImplTest { private static final BookingInfoImpl SUBJECT = new BookingInfoImpl(); private static final Duration TEN_MINUTES = Duration.ofMinutes(10); - private static final BookingInfo WITH_NOTICE_DURATIONS = BookingInfo - .of() + private static final BookingInfo WITH_NOTICE_DURATIONS = BookingInfo.of() .withMinimumBookingNotice(TEN_MINUTES) .withMaximumBookingNotice(TEN_MINUTES) .build(); @@ -53,8 +52,7 @@ private DataFetchingEnvironment dataFetchingEnvironment(BookingInfo bookingInfo) var executionContext = newExecutionContextBuilder() .executionId(ExecutionId.from(this.getClass().getName())) .build(); - return DataFetchingEnvironmentImpl - .newDataFetchingEnvironment(executionContext) + return DataFetchingEnvironmentImpl.newDataFetchingEnvironment(executionContext) .source(bookingInfo) .build(); } diff --git a/application/src/test/java/org/opentripplanner/apis/gtfs/datafetchers/QueryTypeImplTest.java b/application/src/test/java/org/opentripplanner/apis/gtfs/datafetchers/QueryTypeImplTest.java index e223b53844a..dff49304d0e 100644 --- a/application/src/test/java/org/opentripplanner/apis/gtfs/datafetchers/QueryTypeImplTest.java +++ b/application/src/test/java/org/opentripplanner/apis/gtfs/datafetchers/QueryTypeImplTest.java @@ -26,8 +26,7 @@ public class QueryTypeImplTest { @BeforeAll public static void setUp() { var entityOne = new EntitySelector.Route(ROUTE_ID); - var alertOne = TransitAlert - .of(ROUTE_ID) + var alertOne = TransitAlert.of(ROUTE_ID) .withDescriptionText(new NonLocalizedString("foo desc")) .withHeaderText(new NonLocalizedString("foo header")) .addEntity(entityOne) @@ -36,8 +35,7 @@ public static void setUp() { .withEffect(AlertEffect.REDUCED_SERVICE) .build(); var entityTwo = new EntitySelector.Stop(STOP_ID); - var alertTwo = TransitAlert - .of(STOP_ID) + var alertTwo = TransitAlert.of(STOP_ID) .withDescriptionText(new NonLocalizedString("bar desc")) .withHeaderText(new NonLocalizedString("bar header")) .addEntity(entityTwo) diff --git a/application/src/test/java/org/opentripplanner/apis/gtfs/mapping/DirectionMapperTest.java b/application/src/test/java/org/opentripplanner/apis/gtfs/mapping/DirectionMapperTest.java index 1dcd6e210a3..d1158a39675 100644 --- a/application/src/test/java/org/opentripplanner/apis/gtfs/mapping/DirectionMapperTest.java +++ b/application/src/test/java/org/opentripplanner/apis/gtfs/mapping/DirectionMapperTest.java @@ -11,18 +11,15 @@ class DirectionMapperTest { @Test void absoluteDirection() { - Arrays - .stream(AbsoluteDirection.values()) - .forEach(d -> { - var mapped = DirectionMapper.map(d); - assertEquals(d.toString(), mapped.toString()); - }); + Arrays.stream(AbsoluteDirection.values()).forEach(d -> { + var mapped = DirectionMapper.map(d); + assertEquals(d.toString(), mapped.toString()); + }); } @Test void relativeDirection() { - Arrays - .stream(RelativeDirection.values()) + Arrays.stream(RelativeDirection.values()) .filter(v -> v != RelativeDirection.ENTER_OR_EXIT_STATION) .forEach(d -> { var mapped = DirectionMapper.map(d); diff --git a/application/src/test/java/org/opentripplanner/apis/gtfs/mapping/routerequest/LegacyRouteRequestMapperTest.java b/application/src/test/java/org/opentripplanner/apis/gtfs/mapping/routerequest/LegacyRouteRequestMapperTest.java index bf019023eaa..0775b3d649e 100644 --- a/application/src/test/java/org/opentripplanner/apis/gtfs/mapping/routerequest/LegacyRouteRequestMapperTest.java +++ b/application/src/test/java/org/opentripplanner/apis/gtfs/mapping/routerequest/LegacyRouteRequestMapperTest.java @@ -59,18 +59,17 @@ class LegacyRouteRequestMapperTest implements PlanTestConstants { timetableRepository.initTimeZone(ZoneIds.BERLIN); final DefaultTransitService transitService = new DefaultTransitService(timetableRepository); var routeRequest = new RouteRequest(); - context = - new GraphQLRequestContext( - new TestRoutingService(List.of()), - transitService, - new DefaultFareService(), - new DefaultVehicleRentalService(), - new DefaultVehicleParkingService(new DefaultVehicleParkingRepository()), - new DefaultRealtimeVehicleService(transitService), - SchemaFactory.createSchemaWithDefaultInjection(routeRequest), - GraphFinder.getInstance(graph, transitService::findRegularStopsByBoundingBox), - routeRequest - ); + context = new GraphQLRequestContext( + new TestRoutingService(List.of()), + transitService, + new DefaultFareService(), + new DefaultVehicleRentalService(), + new DefaultVehicleParkingService(new DefaultVehicleParkingRepository()), + new DefaultRealtimeVehicleService(transitService), + SchemaFactory.createSchemaWithDefaultInjection(routeRequest), + GraphFinder.getInstance(graph, transitService::findRegularStopsByBoundingBox), + routeRequest + ); } @Test @@ -209,8 +208,7 @@ void bikeTriangle() { } static Stream noTriangleCases() { - return Arrays - .stream(GraphQLTypes.GraphQLOptimizeType.values()) + return Arrays.stream(GraphQLTypes.GraphQLOptimizeType.values()) .filter(value -> value != GraphQLTypes.GraphQLOptimizeType.TRIANGLE) .map(Arguments::of); } @@ -293,8 +291,7 @@ void via() { } private DataFetchingEnvironment executionContext(Map arguments) { - ExecutionInput executionInput = ExecutionInput - .newExecutionInput() + ExecutionInput executionInput = ExecutionInput.newExecutionInput() .query("") .operationName("plan") .context(context) @@ -305,8 +302,7 @@ private DataFetchingEnvironment executionContext(Map arguments) .executionInput(executionInput) .executionId(ExecutionId.from(this.getClass().getName())) .build(); - return DataFetchingEnvironmentImpl - .newDataFetchingEnvironment(executionContext) + return DataFetchingEnvironmentImpl.newDataFetchingEnvironment(executionContext) .arguments(arguments) .build(); } diff --git a/application/src/test/java/org/opentripplanner/apis/gtfs/mapping/routerequest/RouteRequestMapperBicycleTest.java b/application/src/test/java/org/opentripplanner/apis/gtfs/mapping/routerequest/RouteRequestMapperBicycleTest.java index 698390557e1..c1ba91dca66 100644 --- a/application/src/test/java/org/opentripplanner/apis/gtfs/mapping/routerequest/RouteRequestMapperBicycleTest.java +++ b/application/src/test/java/org/opentripplanner/apis/gtfs/mapping/routerequest/RouteRequestMapperBicycleTest.java @@ -227,9 +227,8 @@ void testEmptyBikeRentalPreferences() { ) ); var allowedEnv = executionContext(bikeArgs, Locale.ENGLISH, RouteRequestMapperTest.CONTEXT); - assertThrows( - IllegalArgumentException.class, - () -> RouteRequestMapper.toRouteRequest(allowedEnv, RouteRequestMapperTest.CONTEXT) + assertThrows(IllegalArgumentException.class, () -> + RouteRequestMapper.toRouteRequest(allowedEnv, RouteRequestMapperTest.CONTEXT) ); bikeArgs = createArgsCopy(RouteRequestMapperTest.ARGS); diff --git a/application/src/test/java/org/opentripplanner/apis/gtfs/mapping/routerequest/RouteRequestMapperCarTest.java b/application/src/test/java/org/opentripplanner/apis/gtfs/mapping/routerequest/RouteRequestMapperCarTest.java index f1912ee57f2..c1d7e64a653 100644 --- a/application/src/test/java/org/opentripplanner/apis/gtfs/mapping/routerequest/RouteRequestMapperCarTest.java +++ b/application/src/test/java/org/opentripplanner/apis/gtfs/mapping/routerequest/RouteRequestMapperCarTest.java @@ -96,9 +96,8 @@ void testEmptyCarRentalPreferences() { ) ); var allowedEnv = executionContext(carArgs, Locale.ENGLISH, RouteRequestMapperTest.CONTEXT); - assertThrows( - IllegalArgumentException.class, - () -> RouteRequestMapper.toRouteRequest(allowedEnv, RouteRequestMapperTest.CONTEXT) + assertThrows(IllegalArgumentException.class, () -> + RouteRequestMapper.toRouteRequest(allowedEnv, RouteRequestMapperTest.CONTEXT) ); carArgs = createArgsCopy(RouteRequestMapperTest.ARGS); diff --git a/application/src/test/java/org/opentripplanner/apis/gtfs/mapping/routerequest/RouteRequestMapperModesTest.java b/application/src/test/java/org/opentripplanner/apis/gtfs/mapping/routerequest/RouteRequestMapperModesTest.java index 910bb916a7b..158c5b57934 100644 --- a/application/src/test/java/org/opentripplanner/apis/gtfs/mapping/routerequest/RouteRequestMapperModesTest.java +++ b/application/src/test/java/org/opentripplanner/apis/gtfs/mapping/routerequest/RouteRequestMapperModesTest.java @@ -67,9 +67,8 @@ void testStreetModesWithOneInvalidMode() { var bicycleRental = List.of("BICYCLE_RENTAL"); modesArgs.put("modes", Map.ofEntries(entry("direct", bicycleRental))); var env = executionContext(modesArgs, Locale.ENGLISH, RouteRequestMapperTest.CONTEXT); - assertThrows( - IllegalArgumentException.class, - () -> RouteRequestMapper.toRouteRequest(env, RouteRequestMapperTest.CONTEXT) + assertThrows(IllegalArgumentException.class, () -> + RouteRequestMapper.toRouteRequest(env, RouteRequestMapperTest.CONTEXT) ); } @@ -107,9 +106,8 @@ void testStreetModesWithTwoInvalidModes() { ) ); var rentalEnv = executionContext(modesArgs, Locale.ENGLISH, RouteRequestMapperTest.CONTEXT); - assertThrows( - IllegalArgumentException.class, - () -> RouteRequestMapper.toRouteRequest(rentalEnv, RouteRequestMapperTest.CONTEXT) + assertThrows(IllegalArgumentException.class, () -> + RouteRequestMapper.toRouteRequest(rentalEnv, RouteRequestMapperTest.CONTEXT) ); modesArgs = createArgsCopy(RouteRequestMapperTest.ARGS); @@ -125,9 +123,8 @@ void testStreetModesWithTwoInvalidModes() { Locale.ENGLISH, RouteRequestMapperTest.CONTEXT ); - assertThrows( - IllegalArgumentException.class, - () -> RouteRequestMapper.toRouteRequest(bicycleWalkEnv, RouteRequestMapperTest.CONTEXT) + assertThrows(IllegalArgumentException.class, () -> + RouteRequestMapper.toRouteRequest(bicycleWalkEnv, RouteRequestMapperTest.CONTEXT) ); } @@ -143,9 +140,8 @@ void testStreetModesWithThreeModes() { ) ); var env = executionContext(modesArgs, Locale.ENGLISH, RouteRequestMapperTest.CONTEXT); - assertThrows( - IllegalArgumentException.class, - () -> RouteRequestMapper.toRouteRequest(env, RouteRequestMapperTest.CONTEXT) + assertThrows(IllegalArgumentException.class, () -> + RouteRequestMapper.toRouteRequest(env, RouteRequestMapperTest.CONTEXT) ); } @@ -190,25 +186,22 @@ void testStreetModesWithEmptyModes() { var empty = List.of(); modesArgs.put("modes", Map.ofEntries(entry("direct", empty))); var directEnv = executionContext(modesArgs, Locale.ENGLISH, RouteRequestMapperTest.CONTEXT); - assertThrows( - IllegalArgumentException.class, - () -> RouteRequestMapper.toRouteRequest(directEnv, RouteRequestMapperTest.CONTEXT) + assertThrows(IllegalArgumentException.class, () -> + RouteRequestMapper.toRouteRequest(directEnv, RouteRequestMapperTest.CONTEXT) ); modesArgs = createArgsCopy(RouteRequestMapperTest.ARGS); modesArgs.put("modes", Map.ofEntries(entry("transit", Map.ofEntries(entry("access", empty))))); var accessEnv = executionContext(modesArgs, Locale.ENGLISH, RouteRequestMapperTest.CONTEXT); - assertThrows( - IllegalArgumentException.class, - () -> RouteRequestMapper.toRouteRequest(accessEnv, RouteRequestMapperTest.CONTEXT) + assertThrows(IllegalArgumentException.class, () -> + RouteRequestMapper.toRouteRequest(accessEnv, RouteRequestMapperTest.CONTEXT) ); modesArgs = createArgsCopy(RouteRequestMapperTest.ARGS); modesArgs.put("modes", Map.ofEntries(entry("transit", Map.ofEntries(entry("egress", empty))))); var egressEnv = executionContext(modesArgs, Locale.ENGLISH, RouteRequestMapperTest.CONTEXT); - assertThrows( - IllegalArgumentException.class, - () -> RouteRequestMapper.toRouteRequest(egressEnv, RouteRequestMapperTest.CONTEXT) + assertThrows(IllegalArgumentException.class, () -> + RouteRequestMapper.toRouteRequest(egressEnv, RouteRequestMapperTest.CONTEXT) ); modesArgs = createArgsCopy(RouteRequestMapperTest.ARGS); @@ -217,17 +210,15 @@ void testStreetModesWithEmptyModes() { Map.ofEntries(entry("transit", Map.ofEntries(entry("transfer", empty)))) ); var transferEnv = executionContext(modesArgs, Locale.ENGLISH, RouteRequestMapperTest.CONTEXT); - assertThrows( - IllegalArgumentException.class, - () -> RouteRequestMapper.toRouteRequest(transferEnv, RouteRequestMapperTest.CONTEXT) + assertThrows(IllegalArgumentException.class, () -> + RouteRequestMapper.toRouteRequest(transferEnv, RouteRequestMapperTest.CONTEXT) ); modesArgs = createArgsCopy(RouteRequestMapperTest.ARGS); modesArgs.put("modes", Map.ofEntries(entry("transit", Map.ofEntries(entry("transit", empty))))); var transitEnv = executionContext(modesArgs, Locale.ENGLISH, RouteRequestMapperTest.CONTEXT); - assertThrows( - IllegalArgumentException.class, - () -> RouteRequestMapper.toRouteRequest(transitEnv, RouteRequestMapperTest.CONTEXT) + assertThrows(IllegalArgumentException.class, () -> + RouteRequestMapper.toRouteRequest(transitEnv, RouteRequestMapperTest.CONTEXT) ); } } diff --git a/application/src/test/java/org/opentripplanner/apis/gtfs/mapping/routerequest/RouteRequestMapperScooterTest.java b/application/src/test/java/org/opentripplanner/apis/gtfs/mapping/routerequest/RouteRequestMapperScooterTest.java index de15a45d0c9..3a05881be1e 100644 --- a/application/src/test/java/org/opentripplanner/apis/gtfs/mapping/routerequest/RouteRequestMapperScooterTest.java +++ b/application/src/test/java/org/opentripplanner/apis/gtfs/mapping/routerequest/RouteRequestMapperScooterTest.java @@ -174,9 +174,8 @@ void testEmptyScooterRentalPreferences() { ) ); var allowedEnv = executionContext(scooterArgs, Locale.ENGLISH, RouteRequestMapperTest.CONTEXT); - assertThrows( - IllegalArgumentException.class, - () -> RouteRequestMapper.toRouteRequest(allowedEnv, RouteRequestMapperTest.CONTEXT) + assertThrows(IllegalArgumentException.class, () -> + RouteRequestMapper.toRouteRequest(allowedEnv, RouteRequestMapperTest.CONTEXT) ); scooterArgs = createArgsCopy(RouteRequestMapperTest.ARGS); diff --git a/application/src/test/java/org/opentripplanner/apis/gtfs/mapping/routerequest/RouteRequestMapperTest.java b/application/src/test/java/org/opentripplanner/apis/gtfs/mapping/routerequest/RouteRequestMapperTest.java index 0aab9473371..a120d93597c 100644 --- a/application/src/test/java/org/opentripplanner/apis/gtfs/mapping/routerequest/RouteRequestMapperTest.java +++ b/application/src/test/java/org/opentripplanner/apis/gtfs/mapping/routerequest/RouteRequestMapperTest.java @@ -69,18 +69,17 @@ class RouteRequestMapperTest { timetableRepository.initTimeZone(ZoneIds.BERLIN); final DefaultTransitService transitService = new DefaultTransitService(timetableRepository); var routeRequest = new RouteRequest(); - CONTEXT = - new GraphQLRequestContext( - new TestRoutingService(List.of()), - transitService, - new DefaultFareService(), - new DefaultVehicleRentalService(), - new DefaultVehicleParkingService(new DefaultVehicleParkingRepository()), - new DefaultRealtimeVehicleService(transitService), - SchemaFactory.createSchemaWithDefaultInjection(routeRequest), - GraphFinder.getInstance(graph, transitService::findRegularStopsByBoundingBox), - routeRequest - ); + CONTEXT = new GraphQLRequestContext( + new TestRoutingService(List.of()), + transitService, + new DefaultFareService(), + new DefaultVehicleRentalService(), + new DefaultVehicleParkingService(new DefaultVehicleParkingRepository()), + new DefaultRealtimeVehicleService(transitService), + SchemaFactory.createSchemaWithDefaultInjection(routeRequest), + GraphFinder.getInstance(graph, transitService::findRegularStopsByBoundingBox), + routeRequest + ); } @Test @@ -107,9 +106,9 @@ void testMinimalArgs() { routeRequest.journey().transit().filters().toString() ); assertTrue( - Duration - .between(defaultRequest.dateTime(), routeRequest.dateTime()) - .compareTo(Duration.ofSeconds(10)) < + Duration.between(defaultRequest.dateTime(), routeRequest.dateTime()).compareTo( + Duration.ofSeconds(10) + ) < 0 ); @@ -330,8 +329,7 @@ static DataFetchingEnvironment executionContext( Locale locale, GraphQLRequestContext requestContext ) { - ExecutionInput executionInput = ExecutionInput - .newExecutionInput() + ExecutionInput executionInput = ExecutionInput.newExecutionInput() .query("") .operationName("planConnection") .context(requestContext) @@ -342,8 +340,7 @@ static DataFetchingEnvironment executionContext( .executionInput(executionInput) .executionId(ExecutionId.from("planConnectionTest")) .build(); - return DataFetchingEnvironmentImpl - .newDataFetchingEnvironment(executionContext) + return DataFetchingEnvironmentImpl.newDataFetchingEnvironment(executionContext) .arguments(arguments) .localContext(Map.of("locale", locale)) .build(); diff --git a/application/src/test/java/org/opentripplanner/apis/support/TileJsonTest.java b/application/src/test/java/org/opentripplanner/apis/support/TileJsonTest.java index 73c8cd1369e..c54f588f438 100644 --- a/application/src/test/java/org/opentripplanner/apis/support/TileJsonTest.java +++ b/application/src/test/java/org/opentripplanner/apis/support/TileJsonTest.java @@ -15,8 +15,7 @@ class TileJsonTest { private static final List LAYERS = List.of("stops", "rentalVehicles"); - private static final WorldEnvelope ENVELOPE = WorldEnvelope - .of() + private static final WorldEnvelope ENVELOPE = WorldEnvelope.of() .expandToIncludeStreetEntities(1, 1) .expandToIncludeStreetEntities(2, 2) .build(); diff --git a/application/src/test/java/org/opentripplanner/apis/support/graphql/injectdoc/InjectCustomDocumentationTest.java b/application/src/test/java/org/opentripplanner/apis/support/graphql/injectdoc/InjectCustomDocumentationTest.java index 44318d613a4..30c06e6532a 100644 --- a/application/src/test/java/org/opentripplanner/apis/support/graphql/injectdoc/InjectCustomDocumentationTest.java +++ b/application/src/test/java/org/opentripplanner/apis/support/graphql/injectdoc/InjectCustomDocumentationTest.java @@ -48,15 +48,13 @@ void setUp() throws IOException { } private static RuntimeWiring buildRuntimeWiring() { - return RuntimeWiring - .newRuntimeWiring() + return RuntimeWiring.newRuntimeWiring() .type("QueryType", b -> b.dataFetcher("listE", e -> List.of())) .type("En", b -> b.enumValues(n -> n)) .type("AB", b -> b.typeResolver(it -> null)) .type("AC", b -> b.typeResolver(it -> null)) .scalar( - GraphQLScalarType - .newScalar() + GraphQLScalarType.newScalar() .name("Duration") .coercing(new Coercing() {}) .build() @@ -69,32 +67,30 @@ private static RuntimeWiring buildRuntimeWiring() { * value is the same as the key for easy recognition. */ static Map text() { - return Stream - .of( - "AB.description", - "AC.description.append", - "AType.description", - "AType.a.description", - "AType.b.deprecated", - "BType.description", - "BType.a.description", - "BType.a.deprecated", - "CType.description.append", - "CType.a.description.append", - "CType.b.deprecated.append", - "QueryType.findAB.description", - "QueryType.getAC.deprecated", - "AEnum.description", - "AEnum.E1.description", - "AEnum.E2.deprecated", - "AEnum.E3.deprecated", - "Duration.description", - "InputType.description", - "InputType.a.description", - "InputType.b.deprecated", - "InputType.c.deprecated" - ) - .collect(Collectors.toMap(e -> e, e -> e)); + return Stream.of( + "AB.description", + "AC.description.append", + "AType.description", + "AType.a.description", + "AType.b.deprecated", + "BType.description", + "BType.a.description", + "BType.a.deprecated", + "CType.description.append", + "CType.a.description.append", + "CType.b.deprecated.append", + "QueryType.findAB.description", + "QueryType.getAC.deprecated", + "AEnum.description", + "AEnum.E1.description", + "AEnum.E2.deprecated", + "AEnum.E3.deprecated", + "Duration.description", + "InputType.description", + "InputType.a.description", + "InputType.b.deprecated", + "InputType.c.deprecated" + ).collect(Collectors.toMap(e -> e, e -> e)); } @Test diff --git a/application/src/test/java/org/opentripplanner/apis/transmodel/mapping/BookingInfoMapperTest.java b/application/src/test/java/org/opentripplanner/apis/transmodel/mapping/BookingInfoMapperTest.java index 76af5f76d37..ea5c3be493d 100644 --- a/application/src/test/java/org/opentripplanner/apis/transmodel/mapping/BookingInfoMapperTest.java +++ b/application/src/test/java/org/opentripplanner/apis/transmodel/mapping/BookingInfoMapperTest.java @@ -57,8 +57,7 @@ void dayOfTravelOnly() { @Test void latestBookingTime() { - var info = BookingInfo - .of() + var info = BookingInfo.of() .withEarliestBookingTime(BOOKING_TIME_ZERO_DAYS_PRIOR) .withLatestBookingTime(BOOKING_TIME_ZERO_DAYS_PRIOR) .build(); @@ -67,16 +66,14 @@ void latestBookingTime() { @Test void earliestBookingTimeZero() { - var info = BookingInfo - .of() + var info = BookingInfo.of() .withEarliestBookingTime(new BookingTime(LocalTime.of(10, 0), 10)) .build(); assertEquals("other", mapToBookWhen(info)); } private static BookingInfo daysPrior(int daysPrior) { - return BookingInfo - .of() + return BookingInfo.of() .withLatestBookingTime(new BookingTime(LocalTime.of(10, 0), daysPrior)) .build(); } diff --git a/application/src/test/java/org/opentripplanner/apis/transmodel/mapping/RequestModesMapperTest.java b/application/src/test/java/org/opentripplanner/apis/transmodel/mapping/RequestModesMapperTest.java index d897fc808c2..4bf89d3a6d2 100644 --- a/application/src/test/java/org/opentripplanner/apis/transmodel/mapping/RequestModesMapperTest.java +++ b/application/src/test/java/org/opentripplanner/apis/transmodel/mapping/RequestModesMapperTest.java @@ -9,8 +9,7 @@ class RequestModesMapperTest { - private static final RequestModes MODES_NOT_SET = RequestModes - .of() + private static final RequestModes MODES_NOT_SET = RequestModes.of() .withAccessMode(StreetMode.NOT_SET) .withEgressMode(StreetMode.NOT_SET) .withDirectMode(StreetMode.NOT_SET) @@ -29,8 +28,7 @@ void testMapRequestModesEmptyMapReturnsDefaults() { void testMapRequestModesScooterRentalAccessSetReturnsDefaultsForOthers() { Map inputModes = Map.of("accessMode", StreetMode.SCOOTER_RENTAL); - RequestModes wantModes = MODES_NOT_SET - .copyOf() + RequestModes wantModes = MODES_NOT_SET.copyOf() .withAccessMode(StreetMode.SCOOTER_RENTAL) .withTransferMode(StreetMode.WALK) .withDirectMode(null) @@ -45,8 +43,7 @@ void testMapRequestModesScooterRentalAccessSetReturnsDefaultsForOthers() { void testMapRequestModesBikeAccessSetReturnsDefaultsForOthers() { Map inputModes = Map.of("accessMode", StreetMode.BIKE); - RequestModes wantModes = MODES_NOT_SET - .copyOf() + RequestModes wantModes = MODES_NOT_SET.copyOf() .withAccessMode(StreetMode.BIKE) .withTransferMode(StreetMode.BIKE) .withDirectMode(null) @@ -61,8 +58,7 @@ void testMapRequestModesBikeAccessSetReturnsDefaultsForOthers() { void testMapRequestModesEgressSetReturnsDefaultsForOthers() { Map inputModes = Map.of("egressMode", StreetMode.CAR); - RequestModes wantModes = MODES_NOT_SET - .copyOf() + RequestModes wantModes = MODES_NOT_SET.copyOf() .withEgressMode(StreetMode.CAR) .withDirectMode(null) .build(); diff --git a/application/src/test/java/org/opentripplanner/apis/transmodel/mapping/TripRequestMapperTest.java b/application/src/test/java/org/opentripplanner/apis/transmodel/mapping/TripRequestMapperTest.java index dac26086a9f..088b47ef942 100644 --- a/application/src/test/java/org/opentripplanner/apis/transmodel/mapping/TripRequestMapperTest.java +++ b/application/src/test/java/org/opentripplanner/apis/transmodel/mapping/TripRequestMapperTest.java @@ -75,8 +75,7 @@ public class TripRequestMapperTest implements PlanTestConstants { .bus(route2, 2, time("11:20"), time("11:40"), Place.forStop(stop3)) .build(); var patterns = itineraryPatterns(itinerary); - var siteRepository = TEST_MODEL - .siteRepositoryBuilder() + var siteRepository = TEST_MODEL.siteRepositoryBuilder() .withRegularStop(stop1) .withRegularStop(stop2) .withRegularStop(stop3) @@ -123,12 +122,11 @@ void setup() { defaultRequest ); - context = - new TransmodelRequestContext( - otpServerRequestContext, - otpServerRequestContext.routingService(), - otpServerRequestContext.transitService() - ); + context = new TransmodelRequestContext( + otpServerRequestContext, + otpServerRequestContext.routingService(), + otpServerRequestContext.transitService() + ); } private static final List> DURATIONS = List.of( @@ -188,8 +186,7 @@ public void testMaxDirectDurationForMode() { @Test public void testMaxAccessEgressDurationValidation() { - var defaultValue = StreetPreferences.DEFAULT - .accessEgress() + var defaultValue = StreetPreferences.DEFAULT.accessEgress() .maxDuration() .valueOf(StreetMode.WALK); var duration = List.of( @@ -198,9 +195,8 @@ public void testMaxAccessEgressDurationValidation() { Map arguments = Map.of("maxAccessEgressDurationForMode", duration); - assertThrows( - IllegalArgumentException.class, - () -> TripRequestMapper.createRequest(executionContext(arguments)) + assertThrows(IllegalArgumentException.class, () -> + TripRequestMapper.createRequest(executionContext(arguments)) ); } @@ -210,9 +206,8 @@ public void testMaxAccessEgressDurationForFlexWithTooLongDuration() { "maxAccessEgressDurationForMode", List.of(Map.of("streetMode", StreetMode.FLEXIBLE, "duration", MAX_FLEXIBLE.plusSeconds(1))) ); - assertThrows( - IllegalArgumentException.class, - () -> TripRequestMapper.createRequest(executionContext(arguments)) + assertThrows(IllegalArgumentException.class, () -> + TripRequestMapper.createRequest(executionContext(arguments)) ); } @@ -225,9 +220,8 @@ public void testMaxDirectDurationValidation() { Map arguments = Map.of("maxDirectDurationForMode", duration); - assertThrows( - IllegalArgumentException.class, - () -> TripRequestMapper.createRequest(executionContext(arguments)) + assertThrows(IllegalArgumentException.class, () -> + TripRequestMapper.createRequest(executionContext(arguments)) ); } @@ -237,9 +231,8 @@ public void testMaxDirectDurationForFlexWithTooLongDuration() { "maxDirectDurationForMode", List.of(Map.of("streetMode", StreetMode.FLEXIBLE, "duration", MAX_FLEXIBLE.plusSeconds(1))) ); - assertThrows( - IllegalArgumentException.class, - () -> TripRequestMapper.createRequest(executionContext(arguments)) + assertThrows(IllegalArgumentException.class, () -> + TripRequestMapper.createRequest(executionContext(arguments)) ); } @@ -299,9 +292,9 @@ void testViaLocations() { List.of(Map.of("name", "PTP1", "placeIds", PTP1), Map.of("placeIds", PTP2, "name", "PTP2")) ); - final List viaLocations = TripRequestMapper - .createRequest(executionContext(arguments)) - .getViaLocations(); + final List viaLocations = TripRequestMapper.createRequest( + executionContext(arguments) + ).getViaLocations(); assertEquals( "PassThroughViaLocation{label: PTP1, stopLocationIds: [F:ST:stop1, F:ST:stop2, F:ST:stop3]}", viaLocations.get(0).toString() @@ -396,8 +389,7 @@ public void testExplicitModesBikeAccess() { } private DataFetchingEnvironment executionContext(Map arguments) { - ExecutionInput executionInput = ExecutionInput - .newExecutionInput() + ExecutionInput executionInput = ExecutionInput.newExecutionInput() .query("") .operationName("trip") .context(context) @@ -409,8 +401,7 @@ private DataFetchingEnvironment executionContext(Map arguments) .executionId(ExecutionId.from(this.getClass().getName())) .build(); - var env = DataFetchingEnvironmentImpl - .newDataFetchingEnvironment(executionContext) + var env = DataFetchingEnvironmentImpl.newDataFetchingEnvironment(executionContext) .context(context) .arguments(arguments) .build(); diff --git a/application/src/test/java/org/opentripplanner/apis/transmodel/mapping/TripViaLocationMapperTest.java b/application/src/test/java/org/opentripplanner/apis/transmodel/mapping/TripViaLocationMapperTest.java index 343ac5c5a0c..96501ab7cd1 100644 --- a/application/src/test/java/org/opentripplanner/apis/transmodel/mapping/TripViaLocationMapperTest.java +++ b/application/src/test/java/org/opentripplanner/apis/transmodel/mapping/TripViaLocationMapperTest.java @@ -75,9 +75,8 @@ void testMapToVisitViaLocationsWithBareMinimum() { @Test void testMapToVisitViaLocationsWithoutIdsOrCoordinates() { Map input = mapOf(FIELD_VISIT, mapOf(FIELD_STOP_LOCATION_IDS, null)); - var ex = assertThrows( - IllegalArgumentException.class, - () -> TripViaLocationMapper.mapToViaLocations(List.of(input)) + var ex = assertThrows(IllegalArgumentException.class, () -> + TripViaLocationMapper.mapToViaLocations(List.of(input)) ); assertEquals( "A via location must have at least one stop location or a coordinate.", @@ -88,9 +87,8 @@ void testMapToVisitViaLocationsWithoutIdsOrCoordinates() { @Test void testMapToVisitViaLocationsWithAnEmptyListOfIds() { Map input = mapOf(FIELD_VISIT, mapOf(FIELD_STOP_LOCATION_IDS, List.of())); - var ex = assertThrows( - IllegalArgumentException.class, - () -> TripViaLocationMapper.mapToViaLocations(List.of(input)) + var ex = assertThrows(IllegalArgumentException.class, () -> + TripViaLocationMapper.mapToViaLocations(List.of(input)) ); assertEquals( "A via location must have at least one stop location or a coordinate.", @@ -133,9 +131,8 @@ void testMapToPassThroughWithAnEmptyListOfIds() { FIELD_PASS_THROUGH, mapOf(FIELD_STOP_LOCATION_IDS, List.of()) ); - var ex = assertThrows( - IllegalArgumentException.class, - () -> TripViaLocationMapper.mapToViaLocations(List.of(input)) + var ex = assertThrows(IllegalArgumentException.class, () -> + TripViaLocationMapper.mapToViaLocations(List.of(input)) ); assertEquals( "A pass-through via-location must have at least one stop location.", @@ -149,20 +146,17 @@ void testOneOf() { entry(FIELD_VISIT, visitInput("A", D1m, List.of("F:99"), null)), entry(FIELD_PASS_THROUGH, passThroughInput(LABEL, LIST_IDS_INPUT)) ); - var ex = assertThrows( - IllegalArgumentException.class, - () -> TripViaLocationMapper.mapToViaLocations(List.of(input)) + var ex = assertThrows(IllegalArgumentException.class, () -> + TripViaLocationMapper.mapToViaLocations(List.of(input)) ); assertEquals( "Only one entry in 'via @oneOf' is allowed. Set: 'visit', 'passThrough'", ex.getMessage() ); - ex = - assertThrows( - IllegalArgumentException.class, - () -> TripViaLocationMapper.mapToViaLocations(List.of(Map.of())) - ); + ex = assertThrows(IllegalArgumentException.class, () -> + TripViaLocationMapper.mapToViaLocations(List.of(Map.of())) + ); assertEquals( "No entries in 'via @oneOf'. One of 'visit', 'passThrough' must be set.", ex.getMessage() diff --git a/application/src/test/java/org/opentripplanner/apis/transmodel/model/EnumTypesTest.java b/application/src/test/java/org/opentripplanner/apis/transmodel/model/EnumTypesTest.java index 5a83ec66bb8..bfb69264613 100644 --- a/application/src/test/java/org/opentripplanner/apis/transmodel/model/EnumTypesTest.java +++ b/application/src/test/java/org/opentripplanner/apis/transmodel/model/EnumTypesTest.java @@ -56,26 +56,23 @@ void createFromDocumentedEnum() { @Test void createFromDocumentedEnumMissingValueThrowsException() { - assertThrows( - IllegalStateException.class, - () -> EnumTypes.createFromDocumentedEnum("oof", List.of(EnumTypes.map("Rab", Foo.Bar))) + assertThrows(IllegalStateException.class, () -> + EnumTypes.createFromDocumentedEnum("oof", List.of(EnumTypes.map("Rab", Foo.Bar))) ); } @Test void createFromDocumentedEnumDuplicateThrowsException() { - assertThrows( - IllegalStateException.class, - () -> - EnumTypes.createFromDocumentedEnum( - "oof", - List.of( - EnumTypes.map("Rab", Foo.Bar), - EnumTypes.map("Hi", Foo.Hi), - // Duplicate: Bar -> throw exception - EnumTypes.map("Bar", Foo.Bar) - ) + assertThrows(IllegalStateException.class, () -> + EnumTypes.createFromDocumentedEnum( + "oof", + List.of( + EnumTypes.map("Rab", Foo.Bar), + EnumTypes.map("Hi", Foo.Hi), + // Duplicate: Bar -> throw exception + EnumTypes.map("Bar", Foo.Bar) ) + ) ); } diff --git a/application/src/test/java/org/opentripplanner/apis/transmodel/model/TransportModeSlackTest.java b/application/src/test/java/org/opentripplanner/apis/transmodel/model/TransportModeSlackTest.java index 22d998c189b..c538c9e44c3 100644 --- a/application/src/test/java/org/opentripplanner/apis/transmodel/model/TransportModeSlackTest.java +++ b/application/src/test/java/org/opentripplanner/apis/transmodel/model/TransportModeSlackTest.java @@ -23,8 +23,7 @@ public class TransportModeSlackTest { @Test public void mapToApiList() { // Given - DurationForEnum domain = DurationForEnum - .of(TransitMode.class) + DurationForEnum domain = DurationForEnum.of(TransitMode.class) .with(TransitMode.FUNICULAR, D10m) .with(TransitMode.CABLE_CAR, D10m) .with(TransitMode.RAIL, D30m) diff --git a/application/src/test/java/org/opentripplanner/apis/transmodel/model/framework/CoordinateInputTypeTest.java b/application/src/test/java/org/opentripplanner/apis/transmodel/model/framework/CoordinateInputTypeTest.java index 6defbed804f..b468b5c0e26 100644 --- a/application/src/test/java/org/opentripplanner/apis/transmodel/model/framework/CoordinateInputTypeTest.java +++ b/application/src/test/java/org/opentripplanner/apis/transmodel/model/framework/CoordinateInputTypeTest.java @@ -20,9 +20,10 @@ class CoordinateInputTypeTest { void mapToWgsCoordinate() { assertEquals( new WgsCoordinate(LATITUDE_VALUE, LONGITUDE_VALUE), - CoordinateInputType - .mapToWgsCoordinate("c", Map.of("c", CoordinateInputType.mapForTest(COORDINATE))) - .get() + CoordinateInputType.mapToWgsCoordinate( + "c", + Map.of("c", CoordinateInputType.mapForTest(COORDINATE)) + ).get() ); } diff --git a/application/src/test/java/org/opentripplanner/apis/transmodel/model/plan/RelaxCostTypeTest.java b/application/src/test/java/org/opentripplanner/apis/transmodel/model/plan/RelaxCostTypeTest.java index 6fa235cdf0b..ab53d07e51e 100644 --- a/application/src/test/java/org/opentripplanner/apis/transmodel/model/plan/RelaxCostTypeTest.java +++ b/application/src/test/java/org/opentripplanner/apis/transmodel/model/plan/RelaxCostTypeTest.java @@ -18,8 +18,7 @@ class RelaxCostTypeTest { @Test void valueOf() { assertEquals( - ObjectValue - .newObjectValue() + ObjectValue.newObjectValue() .objectField(ObjectField.newObjectField().name(RATIO).value(FloatValue.of(1.0)).build()) .objectField( ObjectField.newObjectField().name(CONSTANT).value(StringValue.of("0s")).build() @@ -29,8 +28,7 @@ void valueOf() { RelaxCostType.valueOf(CostLinearFunction.NORMAL).toString() ); assertEquals( - ObjectValue - .newObjectValue() + ObjectValue.newObjectValue() .objectField(ObjectField.newObjectField().name(RATIO).value(FloatValue.of(1.3)).build()) .objectField( ObjectField.newObjectField().name(CONSTANT).value(StringValue.of("1m7s")).build() diff --git a/application/src/test/java/org/opentripplanner/apis/transmodel/support/ExecutionResultMapperTest.java b/application/src/test/java/org/opentripplanner/apis/transmodel/support/ExecutionResultMapperTest.java index 7cc373e5145..aae7fe015b2 100644 --- a/application/src/test/java/org/opentripplanner/apis/transmodel/support/ExecutionResultMapperTest.java +++ b/application/src/test/java/org/opentripplanner/apis/transmodel/support/ExecutionResultMapperTest.java @@ -9,11 +9,11 @@ class ExecutionResultMapperTest { - private static ExecutionResult OK_RESULT_WITH_DATA_AND_ERROR = ExecutionResult - .newExecutionResult() - .data("Test") - .addError(GraphQLError.newError().message("Error").build()) - .build(); + private static ExecutionResult OK_RESULT_WITH_DATA_AND_ERROR = + ExecutionResult.newExecutionResult() + .data("Test") + .addError(GraphQLError.newError().message("Error").build()) + .build(); private static String RESULT_SERIALIZED = quoteReplace( "{" + diff --git a/application/src/test/java/org/opentripplanner/apis/transmodel/support/GqlUtilTest.java b/application/src/test/java/org/opentripplanner/apis/transmodel/support/GqlUtilTest.java index 40a95a6661a..be0293e4830 100644 --- a/application/src/test/java/org/opentripplanner/apis/transmodel/support/GqlUtilTest.java +++ b/application/src/test/java/org/opentripplanner/apis/transmodel/support/GqlUtilTest.java @@ -20,17 +20,15 @@ public class GqlUtilTest { private static final String TEST_ARGUMENT = "testArgument"; static { - ExecutionInput executionInput = ExecutionInput - .newExecutionInput() + ExecutionInput executionInput = ExecutionInput.newExecutionInput() .query("") .locale(Locale.ENGLISH) .build(); - executionContext = - newExecutionContextBuilder() - .executionInput(executionInput) - .executionId(ExecutionId.from("GqlUtilTest")) - .build(); + executionContext = newExecutionContextBuilder() + .executionInput(executionInput) + .executionId(ExecutionId.from("GqlUtilTest")) + .build(); } @Test @@ -48,43 +46,38 @@ void testGetPositiveNonNullIntegerArgumentWithZeroValue() { @Test void testGetPositiveNonNullIntegerArgumentWithNegativeValue() { var env = buildEnvWithTestValue(-1); - assertThrows( - IllegalArgumentException.class, - () -> GqlUtil.getPositiveNonNullIntegerArgument(env, TEST_ARGUMENT) + assertThrows(IllegalArgumentException.class, () -> + GqlUtil.getPositiveNonNullIntegerArgument(env, TEST_ARGUMENT) ); } @Test void testGetPositiveNonNullIntegerArgumentWithNullValue() { var env = buildEnvWithTestValue(null); - assertThrows( - IllegalArgumentException.class, - () -> GqlUtil.getPositiveNonNullIntegerArgument(env, TEST_ARGUMENT) + assertThrows(IllegalArgumentException.class, () -> + GqlUtil.getPositiveNonNullIntegerArgument(env, TEST_ARGUMENT) ); } @Test void testGetPositiveNonNullIntegerArgumentWithoutValue() { var env = DataFetchingEnvironmentImpl.newDataFetchingEnvironment(executionContext).build(); - assertThrows( - IllegalArgumentException.class, - () -> GqlUtil.getPositiveNonNullIntegerArgument(env, TEST_ARGUMENT) + assertThrows(IllegalArgumentException.class, () -> + GqlUtil.getPositiveNonNullIntegerArgument(env, TEST_ARGUMENT) ); } private static DataFetchingEnvironment buildEnvWithTestValue(Integer value) { Map argsMap = new HashMap<>(); argsMap.put(TEST_ARGUMENT, value); - return DataFetchingEnvironmentImpl - .newDataFetchingEnvironment(executionContext) + return DataFetchingEnvironmentImpl.newDataFetchingEnvironment(executionContext) .arguments(argsMap) .build(); } @Test void testGetLocaleWithLangArgument() { - var env = DataFetchingEnvironmentImpl - .newDataFetchingEnvironment(executionContext) + var env = DataFetchingEnvironmentImpl.newDataFetchingEnvironment(executionContext) .locale(Locale.ENGLISH) .arguments(Map.of("lang", "fr")) .build(); @@ -96,8 +89,7 @@ void testGetLocaleWithLangArgument() { @Test void testGetLocaleWithLanguageArgument() { - var env = DataFetchingEnvironmentImpl - .newDataFetchingEnvironment(executionContext) + var env = DataFetchingEnvironmentImpl.newDataFetchingEnvironment(executionContext) .locale(Locale.ENGLISH) .arguments(Map.of("language", "fr")) .build(); @@ -109,8 +101,7 @@ void testGetLocaleWithLanguageArgument() { @Test void testGetLocaleWithBothArguments() { - var env = DataFetchingEnvironmentImpl - .newDataFetchingEnvironment(executionContext) + var env = DataFetchingEnvironmentImpl.newDataFetchingEnvironment(executionContext) .locale(Locale.ENGLISH) .arguments(Map.of("lang", "de", "language", "fr")) .build(); @@ -122,8 +113,7 @@ void testGetLocaleWithBothArguments() { @Test void testGetLocaleWithoutArguments() { - var env = DataFetchingEnvironmentImpl - .newDataFetchingEnvironment(executionContext) + var env = DataFetchingEnvironmentImpl.newDataFetchingEnvironment(executionContext) .locale(Locale.ENGLISH) .build(); diff --git a/application/src/test/java/org/opentripplanner/apis/transmodel/support/OneOfInputValidatorTest.java b/application/src/test/java/org/opentripplanner/apis/transmodel/support/OneOfInputValidatorTest.java index e641a1cc855..54dcd6f18ad 100644 --- a/application/src/test/java/org/opentripplanner/apis/transmodel/support/OneOfInputValidatorTest.java +++ b/application/src/test/java/org/opentripplanner/apis/transmodel/support/OneOfInputValidatorTest.java @@ -19,9 +19,8 @@ void testValidateOneReturnsTheFieldName() { @Test void testValidateOneOfWithEmptySetOfArguments() { - var ex = assertThrows( - IllegalArgumentException.class, - () -> OneOfInputValidator.validateOneOf(Map.of(), "parent", "one", "two") + var ex = assertThrows(IllegalArgumentException.class, () -> + OneOfInputValidator.validateOneOf(Map.of(), "parent", "one", "two") ); assertEquals( "No entries in 'parent @oneOf'. One of 'one', 'two' must be set.", @@ -31,10 +30,8 @@ void testValidateOneOfWithEmptySetOfArguments() { @Test void testValidateOneOfWithTooManyArguments() { - var ex = assertThrows( - IllegalArgumentException.class, - () -> - OneOfInputValidator.validateOneOf(Map.of("one", "X", "two", "Y"), "parent", "one", "two") + var ex = assertThrows(IllegalArgumentException.class, () -> + OneOfInputValidator.validateOneOf(Map.of("one", "X", "two", "Y"), "parent", "one", "two") ); assertEquals( "Only one entry in 'parent @oneOf' is allowed. Set: 'one', 'two'", @@ -44,9 +41,8 @@ void testValidateOneOfWithTooManyArguments() { @Test void testValidateOneOfWithEmptyCollection() { - var ex = assertThrows( - IllegalArgumentException.class, - () -> OneOfInputValidator.validateOneOf(Map.of("one", List.of()), "parent", "one", "two") + var ex = assertThrows(IllegalArgumentException.class, () -> + OneOfInputValidator.validateOneOf(Map.of("one", List.of()), "parent", "one", "two") ); assertEquals("'one' can not be empty in 'parent @oneOf'.", ex.getMessage()); } diff --git a/application/src/test/java/org/opentripplanner/astar/AStarTest.java b/application/src/test/java/org/opentripplanner/astar/AStarTest.java index db41e68f11e..4408752efb5 100644 --- a/application/src/test/java/org/opentripplanner/astar/AStarTest.java +++ b/application/src/test/java/org/opentripplanner/astar/AStarTest.java @@ -93,8 +93,7 @@ public void testForward() { request.withPreferences(pref -> pref.withWalk(w -> w.withSpeed(1.0))); Vertex from = graph.getVertex("56th_24th"); Vertex to = graph.getVertex("leary_20th"); - ShortestPathTree tree = StreetSearchBuilder - .of() + ShortestPathTree tree = StreetSearchBuilder.of() .setHeuristic(new EuclideanRemainingWeightHeuristic()) .setRequest(request) .setFrom(from) @@ -124,8 +123,7 @@ public void testBack() { request.setArriveBy(true); Vertex from = graph.getVertex("56th_24th"); Vertex to = graph.getVertex("leary_20th"); - ShortestPathTree tree = StreetSearchBuilder - .of() + ShortestPathTree tree = StreetSearchBuilder.of() .setHeuristic(new EuclideanRemainingWeightHeuristic()) .setRequest(request) .setFrom(from) @@ -175,8 +173,7 @@ public void testForwardExtraEdges() { ); TemporaryConcreteEdge.createTemporaryConcreteEdge(graph.getVertex("56th_20th"), to); - ShortestPathTree tree = StreetSearchBuilder - .of() + ShortestPathTree tree = StreetSearchBuilder.of() .setHeuristic(new EuclideanRemainingWeightHeuristic()) .setRequest(request) .setFrom(from) @@ -219,8 +216,7 @@ public void testBackExtraEdges() { ); TemporaryConcreteEdge.createTemporaryConcreteEdge(graph.getVertex("56th_20th"), to); - ShortestPathTree tree = StreetSearchBuilder - .of() + ShortestPathTree tree = StreetSearchBuilder.of() .setHeuristic(new EuclideanRemainingWeightHeuristic()) .setRequest(request) .setFrom(from) @@ -260,8 +256,7 @@ public void testMultipleTargets() { Vertex v1 = graph.getVertex("56th_24th"); Vertex v2 = graph.getVertex("leary_20th"); - ShortestPathTree tree = StreetSearchBuilder - .of() + ShortestPathTree tree = StreetSearchBuilder.of() .setHeuristic(new EuclideanRemainingWeightHeuristic()) .setTerminationStrategy(strategy) .setRequest(request) diff --git a/application/src/test/java/org/opentripplanner/datastore/OtpDataStoreTest.java b/application/src/test/java/org/opentripplanner/datastore/OtpDataStoreTest.java index d7afc55a556..5c4469b41b3 100644 --- a/application/src/test/java/org/opentripplanner/datastore/OtpDataStoreTest.java +++ b/application/src/test/java/org/opentripplanner/datastore/OtpDataStoreTest.java @@ -46,8 +46,7 @@ public class OtpDataStoreTest { private static final String GRAPH_FILENAME = "graph.obj"; private static final String STREET_GRAPH_FILENAME = "streetGraph.obj"; private static final String REPORT_FILENAME = "report"; - private static final long D2000_01_01 = ZonedDateTime - .parse("2000-01-01T12:00+01:00") + private static final long D2000_01_01 = ZonedDateTime.parse("2000-01-01T12:00+01:00") .toInstant() .toEpochMilli(); diff --git a/application/src/test/java/org/opentripplanner/datastore/base/ByteArrayDataSourceTest.java b/application/src/test/java/org/opentripplanner/datastore/base/ByteArrayDataSourceTest.java index 987cd56a638..3a13fda801b 100644 --- a/application/src/test/java/org/opentripplanner/datastore/base/ByteArrayDataSourceTest.java +++ b/application/src/test/java/org/opentripplanner/datastore/base/ByteArrayDataSourceTest.java @@ -50,8 +50,14 @@ public void asOutputStream() throws IOException { @Test public void asInputStream() throws IOException { - DataSource subject = new ByteArrayDataSource(PATH, NAME, TYPE, SIZE, LAST_MODIFIED, false) - .withBytes(BYTES); + DataSource subject = new ByteArrayDataSource( + PATH, + NAME, + TYPE, + SIZE, + LAST_MODIFIED, + false + ).withBytes(BYTES); assertEquals(BYTES, subject.asBytes()); assertEquals(DATA, new String(subject.asInputStream().readAllBytes(), UTF_8)); @@ -59,8 +65,14 @@ public void asInputStream() throws IOException { @Test public void verifyAReadOnlyInstanceIsNotWritable() { - DataSource subject = new ByteArrayDataSource(PATH, NAME, TYPE, SIZE, LAST_MODIFIED, false) - .withBytes(BYTES); + DataSource subject = new ByteArrayDataSource( + PATH, + NAME, + TYPE, + SIZE, + LAST_MODIFIED, + false + ).withBytes(BYTES); assertFalse(subject.isWritable()); assertThrows(UnsupportedOperationException.class, subject::asOutputStream); diff --git a/application/src/test/java/org/opentripplanner/ext/restapi/resources/PlannerResourceTest.java b/application/src/test/java/org/opentripplanner/ext/restapi/resources/PlannerResourceTest.java index dc924ac765a..478c35b1a4b 100644 --- a/application/src/test/java/org/opentripplanner/ext/restapi/resources/PlannerResourceTest.java +++ b/application/src/test/java/org/opentripplanner/ext/restapi/resources/PlannerResourceTest.java @@ -47,8 +47,7 @@ void bicycleRent() { var req = resource.buildRequest(queryParams); assertFalse(req.journey().transit().enabled()); assertEquals( - RequestModes - .of() + RequestModes.of() .withDirectMode(BIKE_RENTAL) .withEgressMode(BIKE_RENTAL) .withAccessMode(BIKE_RENTAL) diff --git a/application/src/test/java/org/opentripplanner/framework/FrameworkArchitectureTest.java b/application/src/test/java/org/opentripplanner/framework/FrameworkArchitectureTest.java index 1bfc576d822..aafa23c1668 100644 --- a/application/src/test/java/org/opentripplanner/framework/FrameworkArchitectureTest.java +++ b/application/src/test/java/org/opentripplanner/framework/FrameworkArchitectureTest.java @@ -49,9 +49,15 @@ void enforceFunctionalPackageDependencies() { @Test void enforceGeometryPackageDependencies() { - GEOMETRY - .dependsOn(GEO_JSON, GEO_TOOLS, GNU_TROVE, JTS_GEOM, OPEN_GIS, GUAVA_COLLECTIONS, OTP_UTILS) - .verify(); + GEOMETRY.dependsOn( + GEO_JSON, + GEO_TOOLS, + GNU_TROVE, + JTS_GEOM, + OPEN_GIS, + GUAVA_COLLECTIONS, + OTP_UTILS + ).verify(); } @Test diff --git a/application/src/test/java/org/opentripplanner/framework/application/OTPFeatureTest.java b/application/src/test/java/org/opentripplanner/framework/application/OTPFeatureTest.java index 0f814b302d7..c86cb6f3a3e 100644 --- a/application/src/test/java/org/opentripplanner/framework/application/OTPFeatureTest.java +++ b/application/src/test/java/org/opentripplanner/framework/application/OTPFeatureTest.java @@ -52,13 +52,13 @@ public void allowOTPFeaturesToBeConfigurableFromJSON() { // Given the following config String json = """ - { - otpFeatures : { - APIBikeRental : false, - MinimumTransferTimeIsDefinitive : true - } + { + otpFeatures : { + APIBikeRental : false, + MinimumTransferTimeIsDefinitive : true } - """; + } + """; var configLoader = OtpConfigLoader.fromString(json); var config = configLoader.loadOtpConfig(); diff --git a/application/src/test/java/org/opentripplanner/framework/geometry/GeometryUtilsTest.java b/application/src/test/java/org/opentripplanner/framework/geometry/GeometryUtilsTest.java index affcd5c9545..9887b5df02b 100644 --- a/application/src/test/java/org/opentripplanner/framework/geometry/GeometryUtilsTest.java +++ b/application/src/test/java/org/opentripplanner/framework/geometry/GeometryUtilsTest.java @@ -90,7 +90,8 @@ public final void testSplitGeometryAtFraction() { referenceCoordinates[8][0] = coordinates; GeometryFactory geometryFactory = GeometryUtils.getGeometryFactory(); - CoordinateSequenceFactory coordinateSequenceFactory = geometryFactory.getCoordinateSequenceFactory(); + CoordinateSequenceFactory coordinateSequenceFactory = + geometryFactory.getCoordinateSequenceFactory(); CoordinateSequence sequence = coordinateSequenceFactory.create(coordinates); LineString geometry = new LineString(sequence, geometryFactory); @@ -246,17 +247,15 @@ void concatenateLineStringsWithDifferentFromToTest() { @Test void toEnvelopes() { - Coordinate[] coordinates = List - .of( - new Coordinate(0, 0), - new Coordinate(1, 1), - new Coordinate(2, 2), - new Coordinate(3, 3), - new Coordinate(4, 4), - new Coordinate(5, 5), - new Coordinate(6, 6) - ) - .toArray(new Coordinate[0]); + Coordinate[] coordinates = List.of( + new Coordinate(0, 0), + new Coordinate(1, 1), + new Coordinate(2, 2), + new Coordinate(3, 3), + new Coordinate(4, 4), + new Coordinate(5, 5), + new Coordinate(6, 6) + ).toArray(new Coordinate[0]); LineString line = GeometryUtils.makeLineString(coordinates); diff --git a/application/src/test/java/org/opentripplanner/framework/geometry/PolylineEncoderTest.java b/application/src/test/java/org/opentripplanner/framework/geometry/PolylineEncoderTest.java index 2fe5866fcf0..2dfca994aac 100644 --- a/application/src/test/java/org/opentripplanner/framework/geometry/PolylineEncoderTest.java +++ b/application/src/test/java/org/opentripplanner/framework/geometry/PolylineEncoderTest.java @@ -23,8 +23,7 @@ public void testCreateEncodingsOfCoordinateArray() { @Test public void testPolygon() { - var polygon = GeometryUtils - .getGeometryFactory() + var polygon = GeometryUtils.getGeometryFactory() .createPolygon( new Coordinate[] { new Coordinate(0, 0), diff --git a/application/src/test/java/org/opentripplanner/framework/geometry/SphericalDistanceLibraryTest.java b/application/src/test/java/org/opentripplanner/framework/geometry/SphericalDistanceLibraryTest.java index 1b60ceb15e5..075e2616798 100644 --- a/application/src/test/java/org/opentripplanner/framework/geometry/SphericalDistanceLibraryTest.java +++ b/application/src/test/java/org/opentripplanner/framework/geometry/SphericalDistanceLibraryTest.java @@ -22,7 +22,8 @@ void testLineStringLength() { coordinates[4] = new Coordinate(0, 0); GeometryFactory geometryFactory = GeometryUtils.getGeometryFactory(); - CoordinateSequenceFactory coordinateSequenceFactory = geometryFactory.getCoordinateSequenceFactory(); + CoordinateSequenceFactory coordinateSequenceFactory = + geometryFactory.getCoordinateSequenceFactory(); CoordinateSequence sequence = coordinateSequenceFactory.create(coordinates); LineString line = new LineString(sequence, geometryFactory); double length = SphericalDistanceLibrary.length(line); diff --git a/application/src/test/java/org/opentripplanner/framework/graphql/GraphQLUtilsTest.java b/application/src/test/java/org/opentripplanner/framework/graphql/GraphQLUtilsTest.java index b72cb6e5a0d..eb38dfac37c 100644 --- a/application/src/test/java/org/opentripplanner/framework/graphql/GraphQLUtilsTest.java +++ b/application/src/test/java/org/opentripplanner/framework/graphql/GraphQLUtilsTest.java @@ -19,23 +19,20 @@ class GraphQLUtilsTest { static final ExecutionContext executionContext; static { - ExecutionInput executionInput = ExecutionInput - .newExecutionInput() + ExecutionInput executionInput = ExecutionInput.newExecutionInput() .query("") .locale(Locale.ENGLISH) .build(); - executionContext = - newExecutionContextBuilder() - .executionInput(executionInput) - .executionId(ExecutionId.from("GraphQLUtilsTest")) - .build(); + executionContext = newExecutionContextBuilder() + .executionInput(executionInput) + .executionId(ExecutionId.from("GraphQLUtilsTest")) + .build(); } @Test void testGetTranslationWithNullString() { - var env = DataFetchingEnvironmentImpl - .newDataFetchingEnvironment(executionContext) + var env = DataFetchingEnvironmentImpl.newDataFetchingEnvironment(executionContext) .locale(Locale.ENGLISH) .build(); @@ -46,8 +43,7 @@ void testGetTranslationWithNullString() { @Test void testGetTranslationWithTranslations() { - var env = DataFetchingEnvironmentImpl - .newDataFetchingEnvironment(executionContext) + var env = DataFetchingEnvironmentImpl.newDataFetchingEnvironment(executionContext) .locale(Locale.FRENCH) .build(); @@ -65,8 +61,7 @@ void testGetTranslationWithTranslations() { @Test void testGetLocaleWithDefinedLocaleArg() { - var env = DataFetchingEnvironmentImpl - .newDataFetchingEnvironment(executionContext) + var env = DataFetchingEnvironmentImpl.newDataFetchingEnvironment(executionContext) .localContext(Map.of("locale", Locale.GERMAN)) .locale(Locale.ENGLISH) .build(); @@ -83,8 +78,7 @@ void testGetLocaleWithDefinedLocaleArg() { @Test void testGetLocaleWithEnvLocale() { var frenchLocale = Locale.FRENCH; - var env = DataFetchingEnvironmentImpl - .newDataFetchingEnvironment(executionContext) + var env = DataFetchingEnvironmentImpl.newDataFetchingEnvironment(executionContext) .localContext(Map.of("locale", Locale.GERMAN)) .locale(frenchLocale) .build(); @@ -99,8 +93,7 @@ void testGetLocaleWithLocalContextLocale() { // Should use locale from local context if env locale is not defined var frenchLocale = Locale.FRENCH; - var envWithNoLocale = DataFetchingEnvironmentImpl - .newDataFetchingEnvironment(executionContext) + var envWithNoLocale = DataFetchingEnvironmentImpl.newDataFetchingEnvironment(executionContext) .localContext(Map.of("locale", Locale.FRENCH)) .build(); @@ -112,8 +105,9 @@ void testGetLocaleWithLocalContextLocale() { var wildcardLocale = new Locale("*"); - var envWithWildcardLocale = DataFetchingEnvironmentImpl - .newDataFetchingEnvironment(executionContext) + var envWithWildcardLocale = DataFetchingEnvironmentImpl.newDataFetchingEnvironment( + executionContext + ) .locale(wildcardLocale) .localContext(Map.of("locale", Locale.FRENCH)) .build(); diff --git a/application/src/test/java/org/opentripplanner/framework/graphql/scalar/DateScalarFactoryTest.java b/application/src/test/java/org/opentripplanner/framework/graphql/scalar/DateScalarFactoryTest.java index db95f0ba8ce..b29e3005981 100644 --- a/application/src/test/java/org/opentripplanner/framework/graphql/scalar/DateScalarFactoryTest.java +++ b/application/src/test/java/org/opentripplanner/framework/graphql/scalar/DateScalarFactoryTest.java @@ -16,7 +16,8 @@ class DateScalarFactoryTest { private static final GraphQLScalarType GTFS_SCALAR = DateScalarFactory.createGtfsDateScalar(); - private static final GraphQLScalarType TRANSMODEL_SCALAR = DateScalarFactory.createTransmodelDateScalar(); + private static final GraphQLScalarType TRANSMODEL_SCALAR = + DateScalarFactory.createTransmodelDateScalar(); private static final List INVALID_DATES = List.of( "2024-05", "2024", @@ -39,8 +40,7 @@ void parse(GraphQLScalarType scalar, String input) { } static Stream invalidCases() { - return INVALID_DATES - .stream() + return INVALID_DATES.stream() .flatMap(date -> Stream.of(Arguments.of(GTFS_SCALAR, date), Arguments.of(TRANSMODEL_SCALAR, date)) ); diff --git a/application/src/test/java/org/opentripplanner/framework/i18n/LocalizedStringTest.java b/application/src/test/java/org/opentripplanner/framework/i18n/LocalizedStringTest.java index c9336bd5cde..9e5f3f68992 100644 --- a/application/src/test/java/org/opentripplanner/framework/i18n/LocalizedStringTest.java +++ b/application/src/test/java/org/opentripplanner/framework/i18n/LocalizedStringTest.java @@ -15,8 +15,7 @@ public void locale() { "corner", TranslatedString.getI18NString("First", "de", "erste"), TranslatedString.getI18NString("Second", "de", "zweite") - ) - .toString() + ).toString() ); } @@ -28,8 +27,7 @@ public void localeWithTranslation() { "corner", TranslatedString.getI18NString("First", "de", "Erste"), TranslatedString.getI18NString("Second", "de", "Zweite") - ) - .toString(Locale.GERMANY) + ).toString(Locale.GERMANY) ); } @@ -41,8 +39,7 @@ public void localeWithoutTranslation() { "corner", TranslatedString.getI18NString("First", "de", "erste"), TranslatedString.getI18NString("Second", "de", "zweite") - ) - .toString(Locale.CHINESE) + ).toString(Locale.CHINESE) ); } @@ -56,8 +53,11 @@ public void hungarianResource() { assertEquals("névtelen", new LocalizedString("unnamedStreet").toString(new Locale("hu"))); assertEquals( "A (B része)", - new LocalizedString("partOf", new NonLocalizedString("A"), new NonLocalizedString("B")) - .toString(new Locale("hu")) + new LocalizedString( + "partOf", + new NonLocalizedString("A"), + new NonLocalizedString("B") + ).toString(new Locale("hu")) ); } } diff --git a/application/src/test/java/org/opentripplanner/framework/json/JsonUtilsTest.java b/application/src/test/java/org/opentripplanner/framework/json/JsonUtilsTest.java index 4f50e9ad1a5..6dbc22c0b6f 100644 --- a/application/src/test/java/org/opentripplanner/framework/json/JsonUtilsTest.java +++ b/application/src/test/java/org/opentripplanner/framework/json/JsonUtilsTest.java @@ -22,9 +22,11 @@ void testAsText() throws JsonProcessingException { assertTrue(JsonUtils.asText(NullNode.getInstance(), "any").isEmpty()); assertTrue(JsonUtils.asText(new TextNode("foo"), "bar").isEmpty()); - JsonNode node = MAPPER.readTree(""" - { "foo" : "bar", "array" : [] } - """); + JsonNode node = MAPPER.readTree( + """ + { "foo" : "bar", "array" : [] } + """ + ); Optional result = JsonUtils.asText(node, "foo"); assertTrue(result.isPresent()); diff --git a/application/src/test/java/org/opentripplanner/framework/model/UnitsTest.java b/application/src/test/java/org/opentripplanner/framework/model/UnitsTest.java index 818b9b7df16..cc25a92c925 100644 --- a/application/src/test/java/org/opentripplanner/framework/model/UnitsTest.java +++ b/application/src/test/java/org/opentripplanner/framework/model/UnitsTest.java @@ -21,9 +21,8 @@ void reluctance() { @Test void normalizedFactor() { assertEquals(0.0, Units.normalizedFactor(0.0, 0.0, 8.0)); - var ex = assertThrows( - IllegalArgumentException.class, - () -> Units.normalizedFactor(0.999, 1.0, 8.0) + var ex = assertThrows(IllegalArgumentException.class, () -> + Units.normalizedFactor(0.999, 1.0, 8.0) ); assertEquals("The value is not in range[1.0, 8.0]: 1.0", ex.getMessage()); } diff --git a/application/src/test/java/org/opentripplanner/framework/retry/OtpRetryTest.java b/application/src/test/java/org/opentripplanner/framework/retry/OtpRetryTest.java index 21b7aea8da3..70dc98232ad 100644 --- a/application/src/test/java/org/opentripplanner/framework/retry/OtpRetryTest.java +++ b/application/src/test/java/org/opentripplanner/framework/retry/OtpRetryTest.java @@ -20,11 +20,10 @@ class OtpRetryTest { @BeforeEach void beforeEach() { hasRetried = new CompletableFuture<>(); - otpRetryBuilder = - new OtpRetryBuilder() - .withName("Test-retry") - .withInitialRetryInterval(Duration.ZERO) - .withOnRetry(() -> hasRetried.complete(true)); + otpRetryBuilder = new OtpRetryBuilder() + .withName("Test-retry") + .withInitialRetryInterval(Duration.ZERO) + .withOnRetry(() -> hasRetried.complete(true)); } @Test @@ -42,12 +41,10 @@ void testNoInitialFailureOneRetryAttempt() throws InterruptedException { @Test void testInitialFailureNoRetryAttempt() { OtpRetry retry = otpRetryBuilder.withMaxAttempts(0).build(); - assertThrows( - OtpRetryException.class, - () -> - retry.execute(() -> { - throw new RuntimeException("Failed retry"); - }) + assertThrows(OtpRetryException.class, () -> + retry.execute(() -> { + throw new RuntimeException("Failed retry"); + }) ); assertFalse(hasRetried.isDone()); } @@ -55,12 +52,10 @@ void testInitialFailureNoRetryAttempt() { @Test void testInitialFailureAndOneRetryAttempt() { OtpRetry retry = otpRetryBuilder.withMaxAttempts(1).build(); - assertThrows( - OtpRetryException.class, - () -> - retry.execute(() -> { - throw new RuntimeException("Failed retry"); - }) + assertThrows(OtpRetryException.class, () -> + retry.execute(() -> { + throw new RuntimeException("Failed retry"); + }) ); assertTrue(hasRetried.isDone()); } @@ -72,12 +67,10 @@ void testInitialFailureAndTwoRetryAttempts() { .withMaxAttempts(2) .withOnRetry(retryCounter::incrementAndGet) .build(); - assertThrows( - OtpRetryException.class, - () -> - retry.execute(() -> { - throw new RuntimeException("Failed retry"); - }) + assertThrows(OtpRetryException.class, () -> + retry.execute(() -> { + throw new RuntimeException("Failed retry"); + }) ); assertEquals(2, retryCounter.get()); } @@ -99,12 +92,10 @@ void testInitialFailureWithNonRetryableExceptionAndOneRetryAttempt() { .withMaxAttempts(1) .withRetryableException(IOException.class::isInstance) .build(); - assertThrows( - OtpRetryException.class, - () -> - retry.execute(() -> { - throw new RuntimeException("Failed retry"); - }) + assertThrows(OtpRetryException.class, () -> + retry.execute(() -> { + throw new RuntimeException("Failed retry"); + }) ); assertFalse(hasRetried.isDone()); } diff --git a/application/src/test/java/org/opentripplanner/framework/token/AdvancedTokenSchemaTest.java b/application/src/test/java/org/opentripplanner/framework/token/AdvancedTokenSchemaTest.java index 92fe6ad937e..5dd4b18efbf 100644 --- a/application/src/test/java/org/opentripplanner/framework/token/AdvancedTokenSchemaTest.java +++ b/application/src/test/java/org/opentripplanner/framework/token/AdvancedTokenSchemaTest.java @@ -42,60 +42,48 @@ class AdvancedTokenSchemaTest implements TestTokenSchemaConstants { // Version 3 - BYTE, @deprecated DURATION, INT builder = builder.newVersion().deprecate(DURATION_FIELD); TEST_CASES.add( - testCase( - builder, - "(v3, 17, 31)", - it -> - it - .encode() - .withInt(INT_FIELD, INT_VALUE) - .withByte(BYTE_FIELD, BYTE_VALUE) - .withDuration(DURATION_FIELD, DURATION_VALUE) + testCase(builder, "(v3, 17, 31)", it -> + it + .encode() + .withInt(INT_FIELD, INT_VALUE) + .withByte(BYTE_FIELD, BYTE_VALUE) + .withDuration(DURATION_FIELD, DURATION_VALUE) ) ); // Version 4 - BYTE, INT, STRING builder = builder.newVersion().addString(STRING_FIELD); TEST_CASES.add( - testCase( - builder, - "(v4, 17, 31, text)", - it -> - it - .encode() - .withInt(INT_FIELD, INT_VALUE) - .withByte(BYTE_FIELD, BYTE_VALUE) - .withString(STRING_FIELD, STRING_VALUE) + testCase(builder, "(v4, 17, 31, text)", it -> + it + .encode() + .withInt(INT_FIELD, INT_VALUE) + .withByte(BYTE_FIELD, BYTE_VALUE) + .withString(STRING_FIELD, STRING_VALUE) ) ); // Version 5 - @deprecated BYTE, INT, STRING, TIME_INSTANT builder = builder.newVersion().deprecate(BYTE_FIELD).addTimeInstant(TIME_INSTANT_FIELD); TEST_CASES.add( - testCase( - builder, - "(v5, 31, text, 2023-10-23T10:00:59Z)", - it -> - it - .encode() - .withInt(INT_FIELD, INT_VALUE) - .withByte(BYTE_FIELD, BYTE_VALUE) - .withTimeInstant(TIME_INSTANT_FIELD, TIME_INSTANT_VALUE) - .withString(STRING_FIELD, STRING_VALUE) + testCase(builder, "(v5, 31, text, 2023-10-23T10:00:59Z)", it -> + it + .encode() + .withInt(INT_FIELD, INT_VALUE) + .withByte(BYTE_FIELD, BYTE_VALUE) + .withTimeInstant(TIME_INSTANT_FIELD, TIME_INSTANT_VALUE) + .withString(STRING_FIELD, STRING_VALUE) ) ); // Version 6 - INT, STRING, TIME_INSTANT builder = builder.newVersion(); TEST_CASES.add( - testCase( - builder, - "(v6, 31, text, 2023-10-23T10:00:59Z)", - it -> - it - .encode() - .withInt(INT_FIELD, INT_VALUE) - .withTimeInstant(TIME_INSTANT_FIELD, TIME_INSTANT_VALUE) - .withString(STRING_FIELD, STRING_VALUE) + testCase(builder, "(v6, 31, text, 2023-10-23T10:00:59Z)", it -> + it + .encode() + .withInt(INT_FIELD, INT_VALUE) + .withTimeInstant(TIME_INSTANT_FIELD, TIME_INSTANT_VALUE) + .withString(STRING_FIELD, STRING_VALUE) ) ); } @@ -107,8 +95,9 @@ private static List testCases() { @ParameterizedTest @MethodSource(value = "testCases") void testDecodeBackwardsCompatibility(TestCase testCase) { - allTestCasesFrom(testCase) - .forEach(s -> assertEquals(testCase.expected(), s.decode(testCase.token()).toString())); + allTestCasesFrom(testCase).forEach(s -> + assertEquals(testCase.expected(), s.decode(testCase.token()).toString()) + ); } @ParameterizedTest @@ -123,8 +112,7 @@ void testDecodeForwardCompatibility(TestCase testCase) { @Test void testMerge() { - var merged = TokenSchema - .ofVersion(6) + var merged = TokenSchema.ofVersion(6) .addInt(INT_FIELD) .addString(STRING_FIELD) .addTimeInstant(TIME_INSTANT_FIELD) @@ -153,8 +141,7 @@ void testDefinitionToString() { * List of all test-cases including the given test-case until the end of all test-cases */ private static Stream allTestCasesFrom(TestCase testCase) { - return TEST_CASES - .subList(TEST_CASES.indexOf(testCase), TEST_CASES.size() - 1) + return TEST_CASES.subList(TEST_CASES.indexOf(testCase), TEST_CASES.size() - 1) .stream() .map(TestCase::subject); } diff --git a/application/src/test/java/org/opentripplanner/framework/token/TokenSchemaTest.java b/application/src/test/java/org/opentripplanner/framework/token/TokenSchemaTest.java index 089aac372cc..f2b250c33a0 100644 --- a/application/src/test/java/org/opentripplanner/framework/token/TokenSchemaTest.java +++ b/application/src/test/java/org/opentripplanner/framework/token/TokenSchemaTest.java @@ -15,39 +15,32 @@ class TokenSchemaTest implements TestTokenSchemaConstants { // Token field names. These are used to reference a specific field value in the // token to avoid index errors. They are not part of the serialized token. - private static final TokenSchema BOOLEAN_SCHEMA = TokenSchema - .ofVersion(1) + private static final TokenSchema BOOLEAN_SCHEMA = TokenSchema.ofVersion(1) .addBoolean(BOOLEAN_TRUE_FIELD) .addBoolean(BOOLEAN_FALSE_FIELD) .build(); - private static final TokenSchema BYTE_SCHEMA = TokenSchema - .ofVersion(1) + private static final TokenSchema BYTE_SCHEMA = TokenSchema.ofVersion(1) .addByte(BYTE_FIELD) .build(); - private static final TokenSchema DURATION_SCHEMA = TokenSchema - .ofVersion(2) + private static final TokenSchema DURATION_SCHEMA = TokenSchema.ofVersion(2) .addDuration(DURATION_FIELD) .build(); - private static final TokenSchema ENUM_SCHEMA = TokenSchema - .ofVersion(3) + private static final TokenSchema ENUM_SCHEMA = TokenSchema.ofVersion(3) .addEnum(ENUM_FIELD) .build(); private static final TokenSchema INT_SCHEMA = TokenSchema.ofVersion(3).addInt(INT_FIELD).build(); - private static final TokenSchema STRING_SCHEMA = TokenSchema - .ofVersion(7) + private static final TokenSchema STRING_SCHEMA = TokenSchema.ofVersion(7) .addString(STRING_FIELD) .build(); - private static final TokenSchema TIME_INSTANT_SCHEMA = TokenSchema - .ofVersion(13) + private static final TokenSchema TIME_INSTANT_SCHEMA = TokenSchema.ofVersion(13) .addTimeInstant(TIME_INSTANT_FIELD) .build(); @Test public void encodeBoolean() { // Add in opposite order of Schema, test naming fields work - var token = BOOLEAN_SCHEMA - .encode() + var token = BOOLEAN_SCHEMA.encode() .withBoolean(BOOLEAN_FALSE_FIELD, false) .withBoolean(BOOLEAN_TRUE_FIELD, true) .build(); @@ -96,8 +89,7 @@ public void testString() { @Test public void encodeTimeInstant() { - var token = TIME_INSTANT_SCHEMA - .encode() + var token = TIME_INSTANT_SCHEMA.encode() .withTimeInstant(TIME_INSTANT_FIELD, TIME_INSTANT_VALUE) .build(); assertEquals(TIME_INSTANT_ENCODED, token); @@ -109,32 +101,27 @@ public void encodeTimeInstant() { @Test public void encodeUndefinedFields() { - var ex = Assertions.assertThrows( - IllegalArgumentException.class, - () -> INT_SCHEMA.encode().withString("foo", "A") + var ex = Assertions.assertThrows(IllegalArgumentException.class, () -> + INT_SCHEMA.encode().withString("foo", "A") ); assertEquals("Unknown field: 'foo'", ex.getMessage()); - Assertions.assertThrows( - NullPointerException.class, - () -> BYTE_SCHEMA.encode().withString(null, "A") + Assertions.assertThrows(NullPointerException.class, () -> + BYTE_SCHEMA.encode().withString(null, "A") ); } @Test public void encodeFieldValueWithTypeMismatch() { - var ex = Assertions.assertThrows( - IllegalArgumentException.class, - () -> STRING_SCHEMA.encode().withByte(STRING_FIELD, (byte) 12) + var ex = Assertions.assertThrows(IllegalArgumentException.class, () -> + STRING_SCHEMA.encode().withByte(STRING_FIELD, (byte) 12) ); assertEquals("The defined type for 'AStr' is STRING not BYTE.", ex.getMessage()); } @Test public void decodeUndefinedToken() { - var ex = Assertions.assertThrows( - IllegalArgumentException.class, - () -> INT_SCHEMA.decode("foo") + var ex = Assertions.assertThrows(IllegalArgumentException.class, () -> INT_SCHEMA.decode("foo") ); assertEquals("Token is not valid. Unable to parse token: 'foo'.", ex.getMessage()); } diff --git a/application/src/test/java/org/opentripplanner/generate/doc/BuildConfigurationDocTest.java b/application/src/test/java/org/opentripplanner/generate/doc/BuildConfigurationDocTest.java index a44d013fd03..e83de1c8fd1 100644 --- a/application/src/test/java/org/opentripplanner/generate/doc/BuildConfigurationDocTest.java +++ b/application/src/test/java/org/opentripplanner/generate/doc/BuildConfigurationDocTest.java @@ -29,8 +29,7 @@ public class BuildConfigurationDocTest { private static final File OUT_FILE = new File(USER_DOC_PATH, "BuildConfiguration.md"); private static final String CONFIG_PATH = "standalone/config/" + CONFIG_JSON; - private static final SkipNodes SKIP_NODES = SkipNodes - .of() + private static final SkipNodes SKIP_NODES = SkipNodes.of() .skip("dataOverlay", "sandbox/DataOverlay.md") .skip("fares", "sandbox/Fares.md") .skip("transferRequests", "RouteRequest.md") diff --git a/application/src/test/java/org/opentripplanner/generate/doc/OsmMapperDocTest.java b/application/src/test/java/org/opentripplanner/generate/doc/OsmMapperDocTest.java index e2844437ca5..84a1e89b04b 100644 --- a/application/src/test/java/org/opentripplanner/generate/doc/OsmMapperDocTest.java +++ b/application/src/test/java/org/opentripplanner/generate/doc/OsmMapperDocTest.java @@ -40,8 +40,7 @@ public class OsmMapperDocTest { ); public static List mappers() { - return Arrays - .stream(OsmTagMapperSource.values()) + return Arrays.stream(OsmTagMapperSource.values()) .filter(m -> !SKIP_MAPPERS.contains(m)) .toList(); } diff --git a/application/src/test/java/org/opentripplanner/generate/doc/RideHailingDocTest.java b/application/src/test/java/org/opentripplanner/generate/doc/RideHailingDocTest.java index fe959d9138d..078b46afbaa 100644 --- a/application/src/test/java/org/opentripplanner/generate/doc/RideHailingDocTest.java +++ b/application/src/test/java/org/opentripplanner/generate/doc/RideHailingDocTest.java @@ -81,8 +81,7 @@ private String getParameterDetailsTable(NodeAdapter node) { private void addExample(DocBuilder buf, NodeAdapter node) { buf.addSection("##### Example configuration"); - var root = TemplateUtil - .jsonExampleBuilder(node.rawNode()) + var root = TemplateUtil.jsonExampleBuilder(node.rawNode()) .wrapInArray() .wrapInObject(CONFIG_PROP) .build(); diff --git a/application/src/test/java/org/opentripplanner/generate/doc/RouteRequestDocTest.java b/application/src/test/java/org/opentripplanner/generate/doc/RouteRequestDocTest.java index c51660a9a60..988fe9e3fd2 100644 --- a/application/src/test/java/org/opentripplanner/generate/doc/RouteRequestDocTest.java +++ b/application/src/test/java/org/opentripplanner/generate/doc/RouteRequestDocTest.java @@ -28,8 +28,7 @@ public class RouteRequestDocTest { private static final File TEMPLATE = new File(TEMPLATE_PATH, "RouteRequest.md"); private static final File OUT_FILE = new File(USER_DOC_PATH, "RouteRequest.md"); private static final String ROUTER_CONFIG_PATH = "standalone/config/" + ROUTER_CONFIG_FILENAME; - private static final SkipNodes SKIP_NODES = SkipNodes - .of() + private static final SkipNodes SKIP_NODES = SkipNodes.of() .skip("vectorTileLayers", "sandbox/MapboxVectorTilesApi.md") .build(); @@ -51,8 +50,7 @@ public void updateRouteRequestConfigurationDoc() { doc = replaceParametersTable(doc, getParameterSummaryTable(node)); doc = replaceParametersDetails(doc, getParameterDetailsList(node)); - var example = TemplateUtil - .jsonExampleBuilder(node.rawNode()) + var example = TemplateUtil.jsonExampleBuilder(node.rawNode()) .wrapInObject("routingDefaults") .build(); doc = replaceJsonExample(doc, example, ROUTER_CONFIG_FILENAME); diff --git a/application/src/test/java/org/opentripplanner/generate/doc/RouterConfigurationDocTest.java b/application/src/test/java/org/opentripplanner/generate/doc/RouterConfigurationDocTest.java index cdb10e28c6a..65d472f5b43 100644 --- a/application/src/test/java/org/opentripplanner/generate/doc/RouterConfigurationDocTest.java +++ b/application/src/test/java/org/opentripplanner/generate/doc/RouterConfigurationDocTest.java @@ -28,8 +28,7 @@ public class RouterConfigurationDocTest { private static final File OUT_FILE = new File(USER_DOC_PATH, "RouterConfiguration.md"); private static final String CONFIG_PATH = "standalone/config/" + ROUTER_CONFIG_FILENAME; - private static final SkipNodes SKIP_NODES = SkipNodes - .of() + private static final SkipNodes SKIP_NODES = SkipNodes.of() .skip("flex", "sandbox/Flex.md") .skip("routingDefaults", "RouteRequest.md") .skip("updaters", "UpdaterConfig.md") diff --git a/application/src/test/java/org/opentripplanner/generate/doc/RoutingModeDocTest.java b/application/src/test/java/org/opentripplanner/generate/doc/RoutingModeDocTest.java index 188101e3b5d..6db7ee852f6 100644 --- a/application/src/test/java/org/opentripplanner/generate/doc/RoutingModeDocTest.java +++ b/application/src/test/java/org/opentripplanner/generate/doc/RoutingModeDocTest.java @@ -34,8 +34,7 @@ public void updateDocs() { streetBuilder.header(2, "Street modes", "Street modes"); streetBuilder.addSection(StreetMode.CAR.typeDescription()); - Arrays - .stream(StreetMode.values()) + Arrays.stream(StreetMode.values()) .sorted(Comparator.comparing(Enum::name)) .filter(m -> m != StreetMode.NOT_SET) .forEach(m -> { @@ -51,8 +50,7 @@ public void updateDocs() { transitBuilder.addSection(TransitMode.BUS.typeDescription()); - Arrays - .stream(TransitMode.values()) + Arrays.stream(TransitMode.values()) .sorted(Comparator.comparing(Enum::name)) .forEach(m -> { transitBuilder.header(4, m.name(), m.name()); diff --git a/application/src/test/java/org/opentripplanner/generate/doc/StopConsolidationDocTest.java b/application/src/test/java/org/opentripplanner/generate/doc/StopConsolidationDocTest.java index 2861253aac7..0b0ec6b7f81 100644 --- a/application/src/test/java/org/opentripplanner/generate/doc/StopConsolidationDocTest.java +++ b/application/src/test/java/org/opentripplanner/generate/doc/StopConsolidationDocTest.java @@ -30,9 +30,10 @@ public class StopConsolidationDocTest { public void updateDoc() { NodeAdapter node = readConfig(); - var lines = ResourceLoader - .of(this) - .lines("/org/opentripplanner/ext/stopconsolidation/consolidated-stops.csv", 6); + var lines = ResourceLoader.of(this).lines( + "/org/opentripplanner/ext/stopconsolidation/consolidated-stops.csv", + 6 + ); // Read and close input file (same as output file) String template = readFile(TEMPLATE); @@ -40,7 +41,8 @@ public void updateDoc() { var joined = String.join("\n", lines); - var csvExample = """ + var csvExample = + """ ``` %s ``` diff --git a/application/src/test/java/org/opentripplanner/generate/doc/framework/DocBuilderTest.java b/application/src/test/java/org/opentripplanner/generate/doc/framework/DocBuilderTest.java index 1a9796e9aac..1fb30a7d06e 100644 --- a/application/src/test/java/org/opentripplanner/generate/doc/framework/DocBuilderTest.java +++ b/application/src/test/java/org/opentripplanner/generate/doc/framework/DocBuilderTest.java @@ -28,14 +28,14 @@ void toDoc() { assertEquals( """ Section - + **Label** `code` ∙ Text\s\s\s More text\s - +

Header

- + Paragraph - + **Enums** `a` | `bar` | `boo-boo` """, subject.toDoc() diff --git a/application/src/test/java/org/opentripplanner/generate/doc/framework/DocsTestConstants.java b/application/src/test/java/org/opentripplanner/generate/doc/framework/DocsTestConstants.java index e646625ec24..1d3ca8ae9a1 100644 --- a/application/src/test/java/org/opentripplanner/generate/doc/framework/DocsTestConstants.java +++ b/application/src/test/java/org/opentripplanner/generate/doc/framework/DocsTestConstants.java @@ -26,11 +26,11 @@ static boolean docsExistOrWarn() { LOG.warn( """ SKIP TEST - '/doc/user' or '/doc/templates' NOT FOUND - + The /doc/user and /doc/templates directories might not be available if you run the tests outside the root of the projects. This may happen if the project root is not the working directory, if you run tests using jar files or in a Maven multi-module project. - + """ ); return false; diff --git a/application/src/test/java/org/opentripplanner/generate/doc/framework/TemplateUtil.java b/application/src/test/java/org/opentripplanner/generate/doc/framework/TemplateUtil.java index f8d36f1050f..51e1e5b4564 100644 --- a/application/src/test/java/org/opentripplanner/generate/doc/framework/TemplateUtil.java +++ b/application/src/test/java/org/opentripplanner/generate/doc/framework/TemplateUtil.java @@ -41,7 +41,7 @@ public static String replaceSection(String doc, String token, String replacement """ - + %s """.trim() @@ -63,22 +63,19 @@ private static String replaceToken(String token) { */ public static String jsonExample(JsonNode json, String comment) { return """ - ```JSON - // %s - %s - ``` - """.formatted( - comment, - JsonSupport.prettyPrint(json) - ); + ```JSON + // %s + %s + ``` + """.formatted(comment, JsonSupport.prettyPrint(json)); } public static String graphQlExample(String query) { return """ - ```graphql - %s - ``` - """.formatted(query); + ```graphql + %s + ``` + """.formatted(query); } /** diff --git a/application/src/test/java/org/opentripplanner/generate/doc/framework/TemplateUtilTest.java b/application/src/test/java/org/opentripplanner/generate/doc/framework/TemplateUtilTest.java index 7b3532cd69f..1e1b76f9bc8 100644 --- a/application/src/test/java/org/opentripplanner/generate/doc/framework/TemplateUtilTest.java +++ b/application/src/test/java/org/opentripplanner/generate/doc/framework/TemplateUtilTest.java @@ -13,7 +13,8 @@ public class TemplateUtilTest { @Test public void replaceSectionTest() { - var body = """ + var body = + """ Expected line 1. Expected line 2. """; @@ -21,14 +22,14 @@ public void replaceSectionTest() { assertEquals( """ - - - - Expected line 1. - Expected line 2. - - - """.trim(), + + + + Expected line 1. + Expected line 2. + + + """.trim(), replaceSection(doc, "TEST", body) ); } diff --git a/application/src/test/java/org/opentripplanner/generate/doc/support/ConfigTypeTable.java b/application/src/test/java/org/opentripplanner/generate/doc/support/ConfigTypeTable.java index e85eee9eedb..76855255692 100644 --- a/application/src/test/java/org/opentripplanner/generate/doc/support/ConfigTypeTable.java +++ b/application/src/test/java/org/opentripplanner/generate/doc/support/ConfigTypeTable.java @@ -10,8 +10,7 @@ public class ConfigTypeTable { private static final String NEW_LINE = "\n"; public static String configTypeTable() { - var tbl = Table - .of() + var tbl = Table.of() .withHeaders("Type", "Description", "Examples") .withAlights(Table.Align.Left, Table.Align.Left, Table.Align.Left); diff --git a/application/src/test/java/org/opentripplanner/generate/doc/support/OTPFeatureTable.java b/application/src/test/java/org/opentripplanner/generate/doc/support/OTPFeatureTable.java index ccdc1337b87..41197ef14b1 100644 --- a/application/src/test/java/org/opentripplanner/generate/doc/support/OTPFeatureTable.java +++ b/application/src/test/java/org/opentripplanner/generate/doc/support/OTPFeatureTable.java @@ -14,8 +14,7 @@ public class OTPFeatureTable { private static final String NEW_LINE = "\n"; public static String otpFeaturesTable() { - var table = Table - .of() + var table = Table.of() .withHeaders("Feature", "Description", "Enabled by default", "Sandbox") .withAlights(Left, Left, Center, Center); diff --git a/application/src/test/java/org/opentripplanner/graph_builder/module/DirectTransferGeneratorTest.java b/application/src/test/java/org/opentripplanner/graph_builder/module/DirectTransferGeneratorTest.java index c18200793df..976c5de51e5 100644 --- a/application/src/test/java/org/opentripplanner/graph_builder/module/DirectTransferGeneratorTest.java +++ b/application/src/test/java/org/opentripplanner/graph_builder/module/DirectTransferGeneratorTest.java @@ -72,8 +72,7 @@ public void testDirectTransfersWithoutPatterns() { DataImportIssueStore.NOOP, MAX_TRANSFER_DURATION, transferRequests - ) - .buildGraph(); + ).buildGraph(); assertTransfers(timetableRepository.getAllPathTransfers()); } @@ -94,8 +93,7 @@ public void testDirectTransfersWithPatterns() { DataImportIssueStore.NOOP, MAX_TRANSFER_DURATION, transferRequests - ) - .buildGraph(); + ).buildGraph(); assertTransfers( timetableRepository.getAllPathTransfers(), @@ -126,8 +124,7 @@ public void testDirectTransfersWithRestrictedPatterns() { DataImportIssueStore.NOOP, MAX_TRANSFER_DURATION, transferRequests - ) - .buildGraph(); + ).buildGraph(); assertTransfers( timetableRepository.getAllPathTransfers(), @@ -162,8 +159,7 @@ public void testSingleRequestWithoutPatterns() { DataImportIssueStore.NOOP, MAX_TRANSFER_DURATION, transferRequests - ) - .buildGraph(); + ).buildGraph(); assertTransfers(timetableRepository.getAllPathTransfers()); } @@ -185,8 +181,7 @@ public void testSingleRequestWithPatterns() { DataImportIssueStore.NOOP, MAX_TRANSFER_DURATION, transferRequests - ) - .buildGraph(); + ).buildGraph(); assertTransfers( timetableRepository.getAllPathTransfers(), @@ -217,8 +212,7 @@ public void testMultipleRequestsWithoutPatterns() { DataImportIssueStore.NOOP, MAX_TRANSFER_DURATION, transferRequests - ) - .buildGraph(); + ).buildGraph(); assertTransfers(timetableRepository.getAllPathTransfers()); } @@ -244,8 +238,7 @@ public void testMultipleRequestsWithPatterns() { DataImportIssueStore.NOOP, MAX_TRANSFER_DURATION, transferRequests - ) - .buildGraph(); + ).buildGraph(); var walkTransfers = timetableRepository.findTransfers(StreetMode.WALK); var bikeTransfers = timetableRepository.findTransfers(StreetMode.BIKE); @@ -283,8 +276,7 @@ public void testTransferOnIsolatedStations() { DataImportIssueStore.NOOP, MAX_TRANSFER_DURATION, transferRequests - ) - .buildGraph(); + ).buildGraph(); assertTrue(timetableRepository.getAllPathTransfers().isEmpty()); } @@ -314,8 +306,7 @@ public void testRequestWithCarsAllowedPatterns() { MAX_TRANSFER_DURATION, transferRequests, transferParametersForMode - ) - .buildGraph(); + ).buildGraph(); assertTransfers( timetableRepository.getAllPathTransfers(), @@ -349,8 +340,7 @@ public void testRequestWithCarsAllowedPatternsWithDurationLimit() { MAX_TRANSFER_DURATION, transferRequests, transferParametersForMode - ) - .buildGraph(); + ).buildGraph(); assertTransfers(timetableRepository.getAllPathTransfers(), tr(S0, 100, List.of(V0, V11), S11)); } @@ -386,8 +376,7 @@ public void testMultipleRequestsWithPatternsAndWithCarsAllowedPatterns() { MAX_TRANSFER_DURATION, transferRequests, transferParametersForMode - ) - .buildGraph(); + ).buildGraph(); var walkTransfers = timetableRepository.findTransfers(StreetMode.WALK); var bikeTransfers = timetableRepository.findTransfers(StreetMode.BIKE); @@ -441,8 +430,7 @@ public void testBikeRequestWithPatternsAndWithCarsAllowedPatterns() { Duration.ofSeconds(30), transferRequests, transferParametersForMode - ) - .buildGraph(); + ).buildGraph(); assertTransfers( timetableRepository.getAllPathTransfers(), @@ -472,8 +460,7 @@ public void testBikeRequestWithPatternsAndWithCarsAllowedPatternsWithoutCarInTra DataImportIssueStore.NOOP, Duration.ofSeconds(30), transferRequests - ) - .buildGraph(); + ).buildGraph(); assertTransfers( timetableRepository.getAllPathTransfers(), @@ -516,8 +503,7 @@ public void testDisableDefaultTransfersForMode() { MAX_TRANSFER_DURATION, transferRequests, transferParametersForMode - ) - .buildGraph(); + ).buildGraph(); var walkTransfers = timetableRepository.findTransfers(StreetMode.WALK); var bikeTransfers = timetableRepository.findTransfers(StreetMode.BIKE); @@ -565,8 +551,7 @@ public void testMaxTransferDurationForMode() { MAX_TRANSFER_DURATION, transferRequests, transferParametersForMode - ) - .buildGraph(); + ).buildGraph(); var walkTransfers = timetableRepository.findTransfers(StreetMode.WALK); var bikeTransfers = timetableRepository.findTransfers(StreetMode.BIKE); @@ -605,9 +590,8 @@ private TestOtpModel model( new Builder() { @Override public void build() { - var station = stationEntity( - "1", - builder -> builder.withTransfersNotAllowed(withNoTransfersOnStations) + var station = stationEntity("1", builder -> + builder.withTransfersNotAllowed(withNoTransfersOnStations) ); S0 = stop("S0", 47.495, 19.001, station); @@ -650,8 +634,7 @@ public void build() { var agency = TimetableRepositoryForTest.agency("Agency"); tripPattern( - TripPattern - .of(TimetableRepositoryForTest.id("TP1")) + TripPattern.of(TimetableRepositoryForTest.id("TP1")) .withRoute(route("R1", TransitMode.BUS, agency)) .withStopPattern( new StopPattern(List.of(st(S11, !withBoardingConstraint, true), st(S12), st(S13))) @@ -660,8 +643,7 @@ public void build() { ); tripPattern( - TripPattern - .of(TimetableRepositoryForTest.id("TP2")) + TripPattern.of(TimetableRepositoryForTest.id("TP2")) .withRoute(route("R2", TransitMode.BUS, agency)) .withStopPattern(new StopPattern(List.of(st(S21), st(S22), st(S23)))) .build() @@ -672,17 +654,14 @@ public void build() { var agency = TimetableRepositoryForTest.agency("FerryAgency"); tripPattern( - TripPattern - .of(TimetableRepositoryForTest.id("TP3")) + TripPattern.of(TimetableRepositoryForTest.id("TP3")) .withRoute(route("R3", TransitMode.FERRY, agency)) .withStopPattern(new StopPattern(List.of(st(S11), st(S21)))) .withScheduledTimeTableBuilder(builder -> builder.addTripTimes( - ScheduledTripTimes - .of() + ScheduledTripTimes.of() .withTrip( - TimetableRepositoryForTest - .trip("carsAllowedTrip") + TimetableRepositoryForTest.trip("carsAllowedTrip") .withCarsAllowed(CarAccess.ALLOWED) .build() ) @@ -694,17 +673,14 @@ public void build() { ); tripPattern( - TripPattern - .of(TimetableRepositoryForTest.id("TP4")) + TripPattern.of(TimetableRepositoryForTest.id("TP4")) .withRoute(route("R4", TransitMode.FERRY, agency)) .withStopPattern(new StopPattern(List.of(st(S0), st(S13)))) .withScheduledTimeTableBuilder(builder -> builder.addTripTimes( - ScheduledTripTimes - .of() + ScheduledTripTimes.of() .withTrip( - TimetableRepositoryForTest - .trip("carsAllowedTrip") + TimetableRepositoryForTest.trip("carsAllowedTrip") .withCarsAllowed(CarAccess.ALLOWED) .build() ) @@ -716,17 +692,14 @@ public void build() { ); tripPattern( - TripPattern - .of(TimetableRepositoryForTest.id("TP5")) + TripPattern.of(TimetableRepositoryForTest.id("TP5")) .withRoute(route("R5", TransitMode.FERRY, agency)) .withStopPattern(new StopPattern(List.of(st(S12), st(S22)))) .withScheduledTimeTableBuilder(builder -> builder.addTripTimes( - ScheduledTripTimes - .of() + ScheduledTripTimes.of() .withTrip( - TimetableRepositoryForTest - .trip("carsAllowedTrip") + TimetableRepositoryForTest.trip("carsAllowedTrip") .withCarsAllowed(CarAccess.ALLOWED) .build() ) @@ -808,8 +781,7 @@ public TransferDescriptor( @Override public String toString() { - return ToStringBuilder - .of(getClass()) + return ToStringBuilder.of(getClass()) .addObj("from", from) .addObj("to", to) .addNum("distanceMeters", distanceMeters) diff --git a/application/src/test/java/org/opentripplanner/graph_builder/module/OsmBoardingLocationsModuleTest.java b/application/src/test/java/org/opentripplanner/graph_builder/module/OsmBoardingLocationsModuleTest.java index bd4f6af8e54..fc0322ae59f 100644 --- a/application/src/test/java/org/opentripplanner/graph_builder/module/OsmBoardingLocationsModuleTest.java +++ b/application/src/test/java/org/opentripplanner/graph_builder/module/OsmBoardingLocationsModuleTest.java @@ -49,8 +49,15 @@ static Stream herrenbergTestCases() { return Stream.of( Arguments.of( false, - Stream - .of(302563833L, 3223067049L, 302563836L, 3223067680L, 302563834L, 768590748L, 302563839L) + Stream.of( + 302563833L, + 3223067049L, + 302563836L, + 3223067680L, + 302563834L, + 768590748L, + 302563839L + ) .map(VertexLabel::osm) .collect(Collectors.toSet()) ), @@ -67,9 +74,9 @@ static Stream herrenbergTestCases() { ) @MethodSource("herrenbergTestCases") void addAndLinkBoardingLocations(boolean areaVisibility, Set linkedVertices) { - File file = ResourceLoader - .of(OsmBoardingLocationsModuleTest.class) - .file("herrenberg-minimal.osm.pbf"); + File file = ResourceLoader.of(OsmBoardingLocationsModuleTest.class).file( + "herrenberg-minimal.osm.pbf" + ); RegularStop platform = testModel .stop("de:08115:4512:4:101") .withCoordinate(48.59328, 8.86128) @@ -94,8 +101,7 @@ void addAndLinkBoardingLocations(boolean areaVisibility, Set linkedVerti ); var osmInfoRepository = new DefaultOsmInfoGraphBuildRepository(); var vehicleParkingRepository = new DefaultVehicleParkingRepository(); - var osmModule = OsmModule - .of(provider, graph, osmInfoRepository, vehicleParkingRepository) + var osmModule = OsmModule.of(provider, graph, osmInfoRepository, vehicleParkingRepository) .withBoardingAreaRefTags(Set.of("ref", "ref:IFOPT")) .withAreaVisibility(areaVisibility) .build(); @@ -198,16 +204,15 @@ void testLinearPlatforms() { var deduplicator = new Deduplicator(); var graph = new Graph(deduplicator); var osmInfoRepository = new DefaultOsmInfoGraphBuildRepository(); - var osmModule = OsmModule - .of( - new DefaultOsmProvider( - ResourceLoader.of(OsmBoardingLocationsModuleTest.class).file("moorgate.osm.pbf"), - false - ), - graph, - osmInfoRepository, - new DefaultVehicleParkingRepository() - ) + var osmModule = OsmModule.of( + new DefaultOsmProvider( + ResourceLoader.of(OsmBoardingLocationsModuleTest.class).file("moorgate.osm.pbf"), + false + ), + graph, + osmInfoRepository, + new DefaultVehicleParkingRepository() + ) .withBoardingAreaRefTags(Set.of("naptan:AtcoCode")) .build(); osmModule.buildGraph(); @@ -298,8 +303,7 @@ TransitStopVertex getPlatformVertex() { graph, new DefaultOsmInfoGraphBuildService(osmInfoRepository), timetableRepository - ) - .buildGraph(); + ).buildGraph(); var boardingLocations = graph.getVerticesOfType(OsmBoardingLocationVertex.class); @@ -353,10 +357,12 @@ private static void assertSplitVertex( assertConnections(splitVertex, begin, end); if (splitVertex != begin && splitVertex != end) { - var forwardEdges = getEdge(begin, splitVertex) - .flatMap(first -> getEdge(splitVertex, end).map(second -> List.of(first, second))); - var backwardEdges = getEdge(end, splitVertex) - .flatMap(first -> getEdge(splitVertex, begin).map(second -> List.of(first, second))); + var forwardEdges = getEdge(begin, splitVertex).flatMap(first -> + getEdge(splitVertex, end).map(second -> List.of(first, second)) + ); + var backwardEdges = getEdge(end, splitVertex).flatMap(first -> + getEdge(splitVertex, begin).map(second -> List.of(first, second)) + ); for (var edgeList : List.of(forwardEdges, backwardEdges)) { edgeList.ifPresent(edges -> assertEquals( @@ -388,11 +394,9 @@ private void assertConnections( OsmBoardingLocationVertex busBoardingLocation, Set> expected ) { - Stream - .of(busBoardingLocation.getIncoming(), busBoardingLocation.getOutgoing()) - .forEach(edges -> - assertEquals(expected, edges.stream().map(Edge::getClass).collect(Collectors.toSet())) - ); + Stream.of(busBoardingLocation.getIncoming(), busBoardingLocation.getOutgoing()).forEach(edges -> + assertEquals(expected, edges.stream().map(Edge::getClass).collect(Collectors.toSet())) + ); } private static Optional getEdge(Vertex from, Vertex to) { diff --git a/application/src/test/java/org/opentripplanner/graph_builder/module/StreetLinkerModuleTest.java b/application/src/test/java/org/opentripplanner/graph_builder/module/StreetLinkerModuleTest.java index 10427812ac2..5add5a4cc3e 100644 --- a/application/src/test/java/org/opentripplanner/graph_builder/module/StreetLinkerModuleTest.java +++ b/application/src/test/java/org/opentripplanner/graph_builder/module/StreetLinkerModuleTest.java @@ -150,8 +150,7 @@ void linkFlexStopWithBoardingLocation() { @Test void linkCarsAllowedStop() { var model = new TestModel(); - var carsAllowedTrip = TimetableRepositoryForTest - .of() + var carsAllowedTrip = TimetableRepositoryForTest.of() .trip("carsAllowedTrip") .withCarsAllowed(CarAccess.ALLOWED) .build(); @@ -203,11 +202,10 @@ public TestModel() { var walkableEdge = StreetModelForTest.streetEdge(from, to, PEDESTRIAN); var drivableEdge = StreetModelForTest.streetEdge(from, to, CAR); var builder = SiteRepository.of(); - stop = - builder - .regularStop(id("platform-1")) - .withCoordinate(new WgsCoordinate(KONGSBERG_PLATFORM_1)) - .build(); + stop = builder + .regularStop(id("platform-1")) + .withCoordinate(new WgsCoordinate(KONGSBERG_PLATFORM_1)) + .build(); builder.withRegularStop(stop); timetableRepository = new TimetableRepository(builder.build(), new Deduplicator()); @@ -216,14 +214,13 @@ public TestModel() { graph.addVertex(stopVertex); graph.hasStreets = true; - module = - new StreetLinkerModule( - graph, - new DefaultVehicleParkingRepository(), - timetableRepository, - DataImportIssueStore.NOOP, - false - ); + module = new StreetLinkerModule( + graph, + new DefaultVehicleParkingRepository(), + timetableRepository, + DataImportIssueStore.NOOP, + false + ); assertFalse(stopVertex.isConnectedToGraph()); assertTrue(stopVertex.getIncoming().isEmpty()); @@ -252,8 +249,7 @@ public void withFlexTrip(UnscheduledTrip flexTrip) { public void withCarsAllowedTrip(Trip trip, StopLocation... stops) { Route route = TimetableRepositoryForTest.route("carsAllowedRoute").build(); - var stopTimes = Arrays - .stream(stops) + var stopTimes = Arrays.stream(stops) .map(s -> { var stopTime = new StopTime(); stopTime.setStop(s); @@ -269,8 +265,10 @@ public void withCarsAllowedTrip(Trip trip, StopLocation... stops) { stopTimes, timetableRepository.getDeduplicator() ); - TripPattern tripPattern = TimetableRepositoryForTest - .tripPattern("carsAllowedTripPattern", route) + TripPattern tripPattern = TimetableRepositoryForTest.tripPattern( + "carsAllowedTripPattern", + route + ) .withStopPattern(stopPattern) .withScheduledTimeTableBuilder(builder -> builder.addTripTimes(tripTimes)) .build(); diff --git a/application/src/test/java/org/opentripplanner/graph_builder/module/TestStreetLinkerModule.java b/application/src/test/java/org/opentripplanner/graph_builder/module/TestStreetLinkerModule.java index 551564cbb05..2d09d99bd7f 100644 --- a/application/src/test/java/org/opentripplanner/graph_builder/module/TestStreetLinkerModule.java +++ b/application/src/test/java/org/opentripplanner/graph_builder/module/TestStreetLinkerModule.java @@ -24,7 +24,6 @@ public static void link( timetableRepository, DataImportIssueStore.NOOP, false - ) - .buildGraph(); + ).buildGraph(); } } diff --git a/application/src/test/java/org/opentripplanner/graph_builder/module/VehicleParkingLinkingTest.java b/application/src/test/java/org/opentripplanner/graph_builder/module/VehicleParkingLinkingTest.java index 4f0a20bfb7f..42a57a4c605 100644 --- a/application/src/test/java/org/opentripplanner/graph_builder/module/VehicleParkingLinkingTest.java +++ b/application/src/test/java/org/opentripplanner/graph_builder/module/VehicleParkingLinkingTest.java @@ -46,8 +46,7 @@ public void setup() { @Test public void entranceWithVertexLinkingTest() { - var parking = StreetModelForTest - .vehicleParking() + var parking = StreetModelForTest.vehicleParking() .entrance(builder -> builder.entranceId(id("1")).coordinate(new WgsCoordinate(A.getCoordinate())).vertex(A) ) @@ -65,8 +64,7 @@ public void entranceWithVertexLinkingTest() { @Test public void entranceWithoutVertexLinkingTest() { - var parking = StreetModelForTest - .vehicleParking() + var parking = StreetModelForTest.vehicleParking() .entrance(builder -> builder .entranceId(id("1")) @@ -99,8 +97,7 @@ public void carParkingEntranceToAllTraversableStreetLinkingTest() { StreetModelForTest.streetEdge(A, C, StreetTraversalPermission.NONE); - var parking = StreetModelForTest - .vehicleParking() + var parking = StreetModelForTest.vehicleParking() .entrance(builder -> builder .entranceId(id("1")) @@ -123,8 +120,7 @@ public void carParkingEntranceToAllTraversableStreetLinkingTest() { @Test public void removeEntranceWithNonExistingVertexTest() { - var vehicleParking = StreetModelForTest - .vehicleParking() + var vehicleParking = StreetModelForTest.vehicleParking() .bicyclePlaces(true) .entrance(builder -> builder @@ -158,8 +154,7 @@ public void removeEntranceWithNonExistingVertexTest() { @Test public void removeVehicleParkingWithOneEntranceAndNonExistingVertexTest() { - var vehicleParking = StreetModelForTest - .vehicleParking() + var vehicleParking = StreetModelForTest.vehicleParking() .bicyclePlaces(true) .entrance(builder -> builder diff --git a/application/src/test/java/org/opentripplanner/graph_builder/module/islandpruning/AdaptivePruningTest.java b/application/src/test/java/org/opentripplanner/graph_builder/module/islandpruning/AdaptivePruningTest.java index 90ffc33d848..7b2e138991e 100644 --- a/application/src/test/java/org/opentripplanner/graph_builder/module/islandpruning/AdaptivePruningTest.java +++ b/application/src/test/java/org/opentripplanner/graph_builder/module/islandpruning/AdaptivePruningTest.java @@ -22,14 +22,13 @@ public class AdaptivePruningTest { @BeforeAll static void setup() { - graph = - buildOsmGraph( - ResourceLoader.of(AdaptivePruningTest.class).file("isoiiluoto.pbf"), - 5, - 0, - 20, - 30 - ); + graph = buildOsmGraph( + ResourceLoader.of(AdaptivePruningTest.class).file("isoiiluoto.pbf"), + 5, + 0, + 20, + 30 + ); } @Test diff --git a/application/src/test/java/org/opentripplanner/graph_builder/module/islandpruning/IslandPruningUtils.java b/application/src/test/java/org/opentripplanner/graph_builder/module/islandpruning/IslandPruningUtils.java index 1f37eeeeb65..67e26b0da5d 100644 --- a/application/src/test/java/org/opentripplanner/graph_builder/module/islandpruning/IslandPruningUtils.java +++ b/application/src/test/java/org/opentripplanner/graph_builder/module/islandpruning/IslandPruningUtils.java @@ -28,8 +28,7 @@ static Graph buildOsmGraph( var osmProvider = new DefaultOsmProvider(osmFile, true); var osmInfoRepository = new DefaultOsmInfoGraphBuildRepository(); var vehicleParkingRepository = new DefaultVehicleParkingRepository(); - var osmModule = OsmModule - .of(osmProvider, graph, osmInfoRepository, vehicleParkingRepository) + var osmModule = OsmModule.of(osmProvider, graph, osmInfoRepository, vehicleParkingRepository) .withEdgeNamer(new TestNamer()) .build(); diff --git a/application/src/test/java/org/opentripplanner/graph_builder/module/islandpruning/PruneNoThruIslandsTest.java b/application/src/test/java/org/opentripplanner/graph_builder/module/islandpruning/PruneNoThruIslandsTest.java index 9070fb00f8f..5b1fc175e36 100644 --- a/application/src/test/java/org/opentripplanner/graph_builder/module/islandpruning/PruneNoThruIslandsTest.java +++ b/application/src/test/java/org/opentripplanner/graph_builder/module/islandpruning/PruneNoThruIslandsTest.java @@ -18,16 +18,15 @@ public class PruneNoThruIslandsTest { @BeforeAll static void setup() { - graph = - buildOsmGraph( - ResourceLoader - .of(PruneNoThruIslandsTest.class) - .file("herrenberg-island-prune-nothru.osm.pbf"), - 10, - 2, - 50, - 250 - ); + graph = buildOsmGraph( + ResourceLoader.of(PruneNoThruIslandsTest.class).file( + "herrenberg-island-prune-nothru.osm.pbf" + ), + 10, + 2, + 50, + 250 + ); } @Test diff --git a/application/src/test/java/org/opentripplanner/graph_builder/module/islandpruning/SubgraphOnlyFerryTest.java b/application/src/test/java/org/opentripplanner/graph_builder/module/islandpruning/SubgraphOnlyFerryTest.java index 2085e7a238a..ec8370316ca 100644 --- a/application/src/test/java/org/opentripplanner/graph_builder/module/islandpruning/SubgraphOnlyFerryTest.java +++ b/application/src/test/java/org/opentripplanner/graph_builder/module/islandpruning/SubgraphOnlyFerryTest.java @@ -18,8 +18,7 @@ class SubgraphOnlyFerryTest { @Test void subgraphHasOnlyFerry() { - TransitStopVertex transitStopVertex = TransitStopVertex - .of() + TransitStopVertex transitStopVertex = TransitStopVertex.of() .withStop(regularStop1) .withModes(Set.of(TransitMode.FERRY)) .build(); @@ -32,8 +31,7 @@ void subgraphHasOnlyFerry() { @Test void subgraphHasOnlyNoFerry() { - TransitStopVertex transitStopVertex1 = TransitStopVertex - .of() + TransitStopVertex transitStopVertex1 = TransitStopVertex.of() .withStop(regularStop1) .withModes(Set.of(TransitMode.BUS)) .build(); @@ -46,8 +44,7 @@ void subgraphHasOnlyNoFerry() { @Test void subgraphHasOnlyNoMode() { - TransitStopVertex transitStopVertex1 = TransitStopVertex - .of() + TransitStopVertex transitStopVertex1 = TransitStopVertex.of() .withStop(regularStop1) .withModes(Set.of()) .build(); @@ -60,13 +57,11 @@ void subgraphHasOnlyNoMode() { @Test void subgraphHasOnlyFerryMoreStops() { - TransitStopVertex transitStopVertex1 = TransitStopVertex - .of() + TransitStopVertex transitStopVertex1 = TransitStopVertex.of() .withStop(regularStop1) .withModes(Set.of(TransitMode.FERRY)) .build(); - TransitStopVertex transitStopVertex2 = TransitStopVertex - .of() + TransitStopVertex transitStopVertex2 = TransitStopVertex.of() .withStop(regularStop2) .withModes(Set.of(TransitMode.FERRY)) .build(); @@ -80,13 +75,11 @@ void subgraphHasOnlyFerryMoreStops() { @Test void subgraphHasNotOnlyFerryMoreStops() { - TransitStopVertex transitStopVertex1 = TransitStopVertex - .of() + TransitStopVertex transitStopVertex1 = TransitStopVertex.of() .withStop(regularStop1) .withModes(Set.of(TransitMode.FERRY)) .build(); - TransitStopVertex transitStopVertex2 = TransitStopVertex - .of() + TransitStopVertex transitStopVertex2 = TransitStopVertex.of() .withStop(regularStop2) .withModes(Set.of(TransitMode.BUS)) .build(); @@ -100,13 +93,11 @@ void subgraphHasNotOnlyFerryMoreStops() { @Test void subgraphHasNoModeMoreStops() { - TransitStopVertex transitStopVertex1 = TransitStopVertex - .of() + TransitStopVertex transitStopVertex1 = TransitStopVertex.of() .withStop(regularStop1) .withModes(Set.of(TransitMode.FERRY)) .build(); - TransitStopVertex transitStopVertex2 = TransitStopVertex - .of() + TransitStopVertex transitStopVertex2 = TransitStopVertex.of() .withStop(regularStop2) .withModes(Set.of()) .build(); diff --git a/application/src/test/java/org/opentripplanner/graph_builder/module/linking/LinkingTest.java b/application/src/test/java/org/opentripplanner/graph_builder/module/linking/LinkingTest.java index 6c45d97a825..a25287ed1e4 100644 --- a/application/src/test/java/org/opentripplanner/graph_builder/module/linking/LinkingTest.java +++ b/application/src/test/java/org/opentripplanner/graph_builder/module/linking/LinkingTest.java @@ -161,9 +161,12 @@ public static TestOtpModel buildGraphNoTransit() { var osmInfoRepository = new DefaultOsmInfoGraphBuildRepository(); var vehicleParkingRepository = new DefaultVehicleParkingRepository(); - var osmModule = OsmModule - .of(provider, graph, osmInfoRepository, vehicleParkingRepository) - .build(); + var osmModule = OsmModule.of( + provider, + graph, + osmInfoRepository, + vehicleParkingRepository + ).build(); osmModule.buildGraph(); return new TestOtpModel(graph, timetableRepository); diff --git a/application/src/test/java/org/opentripplanner/graph_builder/module/ned/MissingElevationHandlerTest.java b/application/src/test/java/org/opentripplanner/graph_builder/module/ned/MissingElevationHandlerTest.java index 4e403cdd837..f723e5659f5 100644 --- a/application/src/test/java/org/opentripplanner/graph_builder/module/ned/MissingElevationHandlerTest.java +++ b/application/src/test/java/org/opentripplanner/graph_builder/module/ned/MissingElevationHandlerTest.java @@ -209,8 +209,7 @@ private void assignElevation(StreetEdge edge, Map elevations) { PackedCoordinateSequence profile = new PackedCoordinateSequence.Double(coords); - StreetElevationExtensionBuilder - .of(edge) + StreetElevationExtensionBuilder.of(edge) .withElevationProfile(profile) .withComputed(true) .build() diff --git a/application/src/test/java/org/opentripplanner/graph_builder/module/osm/OsmModuleTest.java b/application/src/test/java/org/opentripplanner/graph_builder/module/osm/OsmModuleTest.java index 34881cb3ede..3a68c99e612 100644 --- a/application/src/test/java/org/opentripplanner/graph_builder/module/osm/OsmModuleTest.java +++ b/application/src/test/java/org/opentripplanner/graph_builder/module/osm/OsmModuleTest.java @@ -62,13 +62,12 @@ public void testGraphBuilder() { DefaultOsmProvider provider = new DefaultOsmProvider(file, true); - OsmModule osmModule = OsmModule - .of( - provider, - graph, - new DefaultOsmInfoGraphBuildRepository(), - new DefaultVehicleParkingRepository() - ) + OsmModule osmModule = OsmModule.of( + provider, + graph, + new DefaultOsmInfoGraphBuildRepository(), + new DefaultVehicleParkingRepository() + ) .withAreaVisibility(true) .build(); @@ -128,8 +127,7 @@ public void testBuildGraphDetailed() { var provider = new DefaultOsmProvider(file, true); var osmInfoRepository = new DefaultOsmInfoGraphBuildRepository(); var vehicleParkingRepository = new DefaultVehicleParkingRepository(); - var osmModule = OsmModule - .of(provider, gg, osmInfoRepository, vehicleParkingRepository) + var osmModule = OsmModule.of(provider, gg, osmInfoRepository, vehicleParkingRepository) .withAreaVisibility(true) .build(); @@ -325,14 +323,12 @@ void testBarrierAtEnd() { File file = RESOURCE_LOADER.file("accessno-at-end.pbf"); DefaultOsmProvider provider = new DefaultOsmProvider(file, false); - OsmModule loader = OsmModule - .of( - provider, - graph, - new DefaultOsmInfoGraphBuildRepository(), - new DefaultVehicleParkingRepository() - ) - .build(); + OsmModule loader = OsmModule.of( + provider, + graph, + new DefaultOsmInfoGraphBuildRepository(), + new DefaultVehicleParkingRepository() + ).build(); loader.buildGraph(); Vertex start = graph.getVertex(VertexLabel.osm(1)); @@ -350,13 +346,11 @@ void testBarrierAtEnd() { private BuildResult buildParkingLots() { var graph = new Graph(); var service = new DefaultVehicleParkingRepository(); - List providers = Stream - .of("B+R.osm.pbf", "P+R.osm.pbf") + List providers = Stream.of("B+R.osm.pbf", "P+R.osm.pbf") .map(RESOURCE_LOADER::file) .map(f -> (OsmProvider) new DefaultOsmProvider(f, false)) .toList(); - var module = OsmModule - .of(providers, graph, new DefaultOsmInfoGraphBuildRepository(), service) + var module = OsmModule.of(providers, graph, new DefaultOsmInfoGraphBuildRepository(), service) .withStaticParkAndRide(true) .withStaticBikeParkAndRide(true) .build(); @@ -384,8 +378,7 @@ private void testBuildingAreas(boolean skipVisibility) { var osmInfoRepository = new DefaultOsmInfoGraphBuildRepository(); var vehicleParkingRepository = new DefaultVehicleParkingRepository(); - var loader = OsmModule - .of(provider, graph, osmInfoRepository, vehicleParkingRepository) + var loader = OsmModule.of(provider, graph, osmInfoRepository, vehicleParkingRepository) .withAreaVisibility(!skipVisibility) .build(); diff --git a/application/src/test/java/org/opentripplanner/graph_builder/module/osm/ParkingProcessorTest.java b/application/src/test/java/org/opentripplanner/graph_builder/module/osm/ParkingProcessorTest.java index bfe5992399b..2dc62e74fb3 100644 --- a/application/src/test/java/org/opentripplanner/graph_builder/module/osm/ParkingProcessorTest.java +++ b/application/src/test/java/org/opentripplanner/graph_builder/module/osm/ParkingProcessorTest.java @@ -17,10 +17,8 @@ class ParkingProcessorTest { - private static final IntersectionVertex INTERSECTION_VERTEX = StreetModelForTest.intersectionVertex( - 1, - 1 - ); + private static final IntersectionVertex INTERSECTION_VERTEX = + StreetModelForTest.intersectionVertex(1, 1); private static final ParkingProcessor PROCESSOR = new ParkingProcessor( new Graph(), DataImportIssueStore.NOOP, diff --git a/application/src/test/java/org/opentripplanner/graph_builder/module/osm/PlatformLinkerTest.java b/application/src/test/java/org/opentripplanner/graph_builder/module/osm/PlatformLinkerTest.java index 76f4b25c3ef..3b54d846cad 100644 --- a/application/src/test/java/org/opentripplanner/graph_builder/module/osm/PlatformLinkerTest.java +++ b/application/src/test/java/org/opentripplanner/graph_builder/module/osm/PlatformLinkerTest.java @@ -31,13 +31,12 @@ public void testLinkEntriesToPlatforms() { DefaultOsmProvider provider = new DefaultOsmProvider(file, false); - OsmModule osmModule = OsmModule - .of( - provider, - graph, - new DefaultOsmInfoGraphBuildRepository(), - new DefaultVehicleParkingRepository() - ) + OsmModule osmModule = OsmModule.of( + provider, + graph, + new DefaultOsmInfoGraphBuildRepository(), + new DefaultVehicleParkingRepository() + ) .withPlatformEntriesLinking(true) .build(); diff --git a/application/src/test/java/org/opentripplanner/graph_builder/module/osm/TriangleInequalityTest.java b/application/src/test/java/org/opentripplanner/graph_builder/module/osm/TriangleInequalityTest.java index f43faef27c5..8b064ad87e3 100644 --- a/application/src/test/java/org/opentripplanner/graph_builder/module/osm/TriangleInequalityTest.java +++ b/application/src/test/java/org/opentripplanner/graph_builder/module/osm/TriangleInequalityTest.java @@ -39,9 +39,8 @@ public class TriangleInequalityTest { private static Graph graph; - private final IntersectionTraversalCalculator calculator = new ConstantIntersectionTraversalCalculator( - 10.0 - ); + private final IntersectionTraversalCalculator calculator = + new ConstantIntersectionTraversalCalculator(10.0); private Vertex start; private Vertex end; @@ -52,13 +51,12 @@ public static void onlyOnce() { File file = ResourceLoader.of(TriangleInequalityTest.class).file("NYC_small.osm.pbf"); DefaultOsmProvider provider = new DefaultOsmProvider(file, true); - OsmModule osmModule = OsmModule - .of( - provider, - graph, - new DefaultOsmInfoGraphBuildRepository(), - new DefaultVehicleParkingRepository() - ) + OsmModule osmModule = OsmModule.of( + provider, + graph, + new DefaultOsmInfoGraphBuildRepository(), + new DefaultVehicleParkingRepository() + ) .withAreaVisibility(true) .build(); osmModule.buildGraph(); @@ -163,8 +161,7 @@ private GraphPath getPath( Vertex u, Vertex v ) { - return StreetSearchBuilder - .of() + return StreetSearchBuilder.of() .setHeuristic(new EuclideanRemainingWeightHeuristic()) .setOriginBackEdge(startBackEdge) .setRequest(options) @@ -202,8 +199,7 @@ private void checkTriangleInequality(RequestModes modes, List fil prototypeOptions.journey().transit().setFilters(filters); } - ShortestPathTree tree = StreetSearchBuilder - .of() + ShortestPathTree tree = StreetSearchBuilder.of() .setHeuristic(new EuclideanRemainingWeightHeuristic()) .setDominanceFunction(new DominanceFunctions.EarliestArrival()) .setRequest(prototypeOptions) diff --git a/application/src/test/java/org/opentripplanner/graph_builder/module/osm/UnconnectedAreasTest.java b/application/src/test/java/org/opentripplanner/graph_builder/module/osm/UnconnectedAreasTest.java index 9c83bd1b2bb..36ba31fab4d 100644 --- a/application/src/test/java/org/opentripplanner/graph_builder/module/osm/UnconnectedAreasTest.java +++ b/application/src/test/java/org/opentripplanner/graph_builder/module/osm/UnconnectedAreasTest.java @@ -163,13 +163,12 @@ private Graph buildOsmGraph(String osmFileName, DataImportIssueStore issueStore) var graph = new Graph(deduplicator); var timetableRepository = new TimetableRepository(siteRepository, deduplicator); DefaultOsmProvider provider = new DefaultOsmProvider(RESOURCE_LOADER.file(osmFileName), false); - OsmModule loader = OsmModule - .of( - provider, - graph, - new DefaultOsmInfoGraphBuildRepository(), - new DefaultVehicleParkingRepository() - ) + OsmModule loader = OsmModule.of( + provider, + graph, + new DefaultOsmInfoGraphBuildRepository(), + new DefaultVehicleParkingRepository() + ) .withIssueStore(issueStore) .withAreaVisibility(true) .withStaticParkAndRide(true) diff --git a/application/src/test/java/org/opentripplanner/graph_builder/module/osm/UnroutableTest.java b/application/src/test/java/org/opentripplanner/graph_builder/module/osm/UnroutableTest.java index 465c5ab13df..f8c04b86834 100644 --- a/application/src/test/java/org/opentripplanner/graph_builder/module/osm/UnroutableTest.java +++ b/application/src/test/java/org/opentripplanner/graph_builder/module/osm/UnroutableTest.java @@ -39,13 +39,12 @@ public void setUp() throws Exception { var osmDataFile = ResourceLoader.of(UnroutableTest.class).file("bridge_construction.osm.pbf"); DefaultOsmProvider provider = new DefaultOsmProvider(osmDataFile, true); - OsmModule osmBuilder = OsmModule - .of( - provider, - graph, - new DefaultOsmInfoGraphBuildRepository(), - new DefaultVehicleParkingRepository() - ) + OsmModule osmBuilder = OsmModule.of( + provider, + graph, + new DefaultOsmInfoGraphBuildRepository(), + new DefaultVehicleParkingRepository() + ) .withAreaVisibility(true) .build(); osmBuilder.buildGraph(); @@ -63,8 +62,7 @@ public void testOnBoardRouting() { Vertex from = graph.getVertex(VertexLabel.osm(2003617278)); Vertex to = graph.getVertex(VertexLabel.osm(40446276)); - ShortestPathTree spt = StreetSearchBuilder - .of() + ShortestPathTree spt = StreetSearchBuilder.of() .setHeuristic(new EuclideanRemainingWeightHeuristic()) .setRequest(options) .setStreetRequest(options.journey().direct()) diff --git a/application/src/test/java/org/opentripplanner/graph_builder/module/osm/moduletests/BoardingLocationTest.java b/application/src/test/java/org/opentripplanner/graph_builder/module/osm/moduletests/BoardingLocationTest.java index 734e86d1cf8..88f7f9e1a54 100644 --- a/application/src/test/java/org/opentripplanner/graph_builder/module/osm/moduletests/BoardingLocationTest.java +++ b/application/src/test/java/org/opentripplanner/graph_builder/module/osm/moduletests/BoardingLocationTest.java @@ -31,8 +31,12 @@ void oneWayPlatform() { var graph = new Graph(new Deduplicator()); var osmInfoRepository = new DefaultOsmInfoGraphBuildRepository(); - var osmModule = OsmModule - .of(provider, graph, osmInfoRepository, new DefaultVehicleParkingRepository()) + var osmModule = OsmModule.of( + provider, + graph, + osmInfoRepository, + new DefaultVehicleParkingRepository() + ) .withBoardingAreaRefTags(Set.of("ref")) .build(); @@ -54,8 +58,12 @@ void skipPlatformsWithoutReferences() { var graph = new Graph(new Deduplicator()); var osmInfoRepository = new DefaultOsmInfoGraphBuildRepository(); - var osmModule = OsmModule - .of(provider, graph, osmInfoRepository, new DefaultVehicleParkingRepository()) + var osmModule = OsmModule.of( + provider, + graph, + osmInfoRepository, + new DefaultVehicleParkingRepository() + ) .withBoardingAreaRefTags(Set.of("ref")) .build(); @@ -76,8 +84,12 @@ void testHighwayPlatform() { var graph = new Graph(new Deduplicator()); var osmInfoRepository = new DefaultOsmInfoGraphBuildRepository(); - var osmModule = OsmModule - .of(provider, graph, osmInfoRepository, new DefaultVehicleParkingRepository()) + var osmModule = OsmModule.of( + provider, + graph, + osmInfoRepository, + new DefaultVehicleParkingRepository() + ) .withBoardingAreaRefTags(Set.of("ref")) .build(); diff --git a/application/src/test/java/org/opentripplanner/graph_builder/module/osm/moduletests/walkablearea/ConcaveHoleTest.java b/application/src/test/java/org/opentripplanner/graph_builder/module/osm/moduletests/walkablearea/ConcaveHoleTest.java index 79c0cdb01b0..4faa530971c 100644 --- a/application/src/test/java/org/opentripplanner/graph_builder/module/osm/moduletests/walkablearea/ConcaveHoleTest.java +++ b/application/src/test/java/org/opentripplanner/graph_builder/module/osm/moduletests/walkablearea/ConcaveHoleTest.java @@ -61,14 +61,12 @@ void visibilityNodes() { var outerRingId = 1000; var holeId = 1001; - var relation = RelationBuilder - .ofMultiPolygon() + var relation = RelationBuilder.ofMultiPolygon() .withWayMember(outerRingId, "outer") .withWayMember(holeId, "inner") .build(); - var provider = TestOsmProvider - .of() + var provider = TestOsmProvider.of() .addAreaFromNodes(outerRingId, outerRing) .addAreaFromNodes(holeId, hole) .addWayFromNodes(outside0, inside0) @@ -77,13 +75,12 @@ void visibilityNodes() { .build(); var graph = new Graph(new Deduplicator()); - var osmModule = OsmModule - .of( - provider, - graph, - new DefaultOsmInfoGraphBuildRepository(), - new DefaultVehicleParkingRepository() - ) + var osmModule = OsmModule.of( + provider, + graph, + new DefaultOsmInfoGraphBuildRepository(), + new DefaultVehicleParkingRepository() + ) .withAreaVisibility(true) .withMaxAreaNodes(10) .build(); diff --git a/application/src/test/java/org/opentripplanner/graph_builder/module/osm/moduletests/walkablearea/SimpleAreaTest.java b/application/src/test/java/org/opentripplanner/graph_builder/module/osm/moduletests/walkablearea/SimpleAreaTest.java index 70ecec365f9..6d8b0465824 100644 --- a/application/src/test/java/org/opentripplanner/graph_builder/module/osm/moduletests/walkablearea/SimpleAreaTest.java +++ b/application/src/test/java/org/opentripplanner/graph_builder/module/osm/moduletests/walkablearea/SimpleAreaTest.java @@ -32,21 +32,19 @@ void walkableArea() { var outside0 = node(5, new WgsCoordinate(-1, 0)); var outside1 = node(6, new WgsCoordinate(6, 5)); - var provider = TestOsmProvider - .of() + var provider = TestOsmProvider.of() .addAreaFromNodes(area) .addWayFromNodes(outside0, inside0) .addWayFromNodes(outside1, inside1) .build(); var graph = new Graph(new Deduplicator()); - var osmModule = OsmModule - .of( - provider, - graph, - new DefaultOsmInfoGraphBuildRepository(), - new DefaultVehicleParkingRepository() - ) + var osmModule = OsmModule.of( + provider, + graph, + new DefaultOsmInfoGraphBuildRepository(), + new DefaultVehicleParkingRepository() + ) .withAreaVisibility(true) .withMaxAreaNodes(10) .build(); diff --git a/application/src/test/java/org/opentripplanner/gtfs/GenerateTripPatternsOperationTest.java b/application/src/test/java/org/opentripplanner/gtfs/GenerateTripPatternsOperationTest.java index d0968adf7e9..a5975a55f43 100644 --- a/application/src/test/java/org/opentripplanner/gtfs/GenerateTripPatternsOperationTest.java +++ b/application/src/test/java/org/opentripplanner/gtfs/GenerateTripPatternsOperationTest.java @@ -54,13 +54,12 @@ static void setupClass() { stopA = timetableRepositoryForTest.stop("stopA").build(); stopB = timetableRepositoryForTest.stop("stopB").build(); stopC = timetableRepositoryForTest.stop("stopC").build(); - siteRepository = - timetableRepositoryForTest - .siteRepositoryBuilder() - .withRegularStop(stopA) - .withRegularStop(stopB) - .withRegularStop(stopC) - .build(); + siteRepository = timetableRepositoryForTest + .siteRepositoryBuilder() + .withRegularStop(stopA) + .withRegularStop(stopB) + .withRegularStop(stopC) + .build(); stopTimeA = new StopTime(); stopTimeA.setStop(stopA); @@ -70,56 +69,51 @@ static void setupClass() { stopTimeC.setStop(stopC); FeedScopedId serviceId1 = TimetableRepositoryForTest.id("SERVICE_ID_1"); - trip1 = - trip("TRIP_ID_1") - .withServiceId(serviceId1) - .withMode(TransitMode.RAIL) - .withNetexSubmode("SUBMODE_1") - .withDirection(Direction.INBOUND) - .build(); + trip1 = trip("TRIP_ID_1") + .withServiceId(serviceId1) + .withMode(TransitMode.RAIL) + .withNetexSubmode("SUBMODE_1") + .withDirection(Direction.INBOUND) + .build(); // same route, mode, submode and direction as trip1 FeedScopedId serviceId2 = TimetableRepositoryForTest.id("SERVICE_ID_2"); - trip2 = - trip("TRIP_ID_2") - .withServiceId(serviceId2) - .withRoute(trip1.getRoute()) - .withMode(trip1.getMode()) - .withNetexSubmode(trip1.getNetexSubMode().name()) - .withDirection(trip1.getDirection()) - .build(); + trip2 = trip("TRIP_ID_2") + .withServiceId(serviceId2) + .withRoute(trip1.getRoute()) + .withMode(trip1.getMode()) + .withNetexSubmode(trip1.getNetexSubMode().name()) + .withDirection(trip1.getDirection()) + .build(); // same route, direction as trip1, different mode FeedScopedId serviceId3 = TimetableRepositoryForTest.id("SERVICE_ID_3"); - trip3 = - trip("TRIP_ID_3") - .withServiceId(serviceId3) - .withRoute(trip1.getRoute()) - .withMode(TransitMode.BUS) - .withDirection(trip1.getDirection()) - .build(); + trip3 = trip("TRIP_ID_3") + .withServiceId(serviceId3) + .withRoute(trip1.getRoute()) + .withMode(TransitMode.BUS) + .withDirection(trip1.getDirection()) + .build(); // same route, mode, direction as trip1, different submode FeedScopedId serviceId4 = TimetableRepositoryForTest.id("SERVICE_ID_4"); - trip4 = - trip("TRIP_ID_4") - .withServiceId(serviceId4) - .withRoute(trip1.getRoute()) - .withMode(trip1.getMode()) - .withNetexSubmode("SUMODE_2") - .withDirection(trip1.getDirection()) - .build(); + trip4 = trip("TRIP_ID_4") + .withServiceId(serviceId4) + .withRoute(trip1.getRoute()) + .withMode(trip1.getMode()) + .withNetexSubmode("SUMODE_2") + .withDirection(trip1.getDirection()) + .build(); // same route, mode as trip1, different direction FeedScopedId serviceId5 = TimetableRepositoryForTest.id("SERVICE_ID_5"); - trip5 = - trip("TRIP_ID_5") - .withServiceId(serviceId5) - .withRoute(trip1.getRoute()) - .withMode(trip1.getMode()) - .withNetexSubmode(trip1.getNetexSubMode().name()) - .withDirection(Direction.OUTBOUND) - .build(); + trip5 = trip("TRIP_ID_5") + .withServiceId(serviceId5) + .withRoute(trip1.getRoute()) + .withMode(trip1.getMode()) + .withNetexSubmode(trip1.getNetexSubMode().name()) + .withDirection(Direction.OUTBOUND) + .build(); } @BeforeEach @@ -128,8 +122,11 @@ void setup() { issueStore = new DefaultDataImportIssueStore(); transitServiceBuilder = new OtpTransitServiceBuilder(siteRepository, issueStore); double maxStopToShapeSnapDistance = 100; - geometryProcessor = - new GeometryProcessor(transitServiceBuilder, maxStopToShapeSnapDistance, issueStore); + geometryProcessor = new GeometryProcessor( + transitServiceBuilder, + maxStopToShapeSnapDistance, + issueStore + ); } @Test diff --git a/application/src/test/java/org/opentripplanner/gtfs/GtfsContextBuilder.java b/application/src/test/java/org/opentripplanner/gtfs/GtfsContextBuilder.java index 80f66caf98e..5b9e6e11648 100644 --- a/application/src/test/java/org/opentripplanner/gtfs/GtfsContextBuilder.java +++ b/application/src/test/java/org/opentripplanner/gtfs/GtfsContextBuilder.java @@ -60,8 +60,9 @@ public static GtfsContextBuilder contextBuilder(@Nullable String defaultFeedId, ); mapper.mapStopTripAndRouteDataIntoBuilder(); mapper.mapAndAddTransfersToBuilder(); - return new GtfsContextBuilder(feedId, transitBuilder) - .withDataImportIssueStore(DataImportIssueStore.NOOP); + return new GtfsContextBuilder(feedId, transitBuilder).withDataImportIssueStore( + DataImportIssueStore.NOOP + ); } public OtpTransitServiceBuilder getTransitBuilder() { @@ -138,8 +139,7 @@ private void repairStopTimesForEachTrip() { true, true, issueStore - ) - .run(); + ).run(); } private void generateTripPatterns() { @@ -149,8 +149,7 @@ private void generateTripPatterns() { deduplicator(), calendarService().getServiceIds(), new GeometryProcessor(transitBuilder, 150, issueStore) - ) - .run(); + ).run(); } private CalendarService calendarService() { diff --git a/application/src/test/java/org/opentripplanner/gtfs/interlining/InterlineProcessorTest.java b/application/src/test/java/org/opentripplanner/gtfs/interlining/InterlineProcessorTest.java index 1fd24f17f3b..ab2ba1cbff9 100644 --- a/application/src/test/java/org/opentripplanner/gtfs/interlining/InterlineProcessorTest.java +++ b/application/src/test/java/org/opentripplanner/gtfs/interlining/InterlineProcessorTest.java @@ -150,8 +150,7 @@ void staySeatedNotAllowed() { } private static TripPattern tripPattern(String tripId, String blockId, String serviceId) { - var trip = TimetableRepositoryForTest - .trip(tripId) + var trip = TimetableRepositoryForTest.trip(tripId) .withGtfsBlockId(blockId) .withServiceId(new FeedScopedId("1", serviceId)) .build(); @@ -164,8 +163,7 @@ private static TripPattern tripPattern(String tripId, String blockId, String ser var stopPattern = new StopPattern(stopTimes); var tripTimes = TripTimesFactory.tripTimes(trip, stopTimes, new Deduplicator()); - return TripPattern - .of(TimetableRepositoryForTest.id(tripId)) + return TripPattern.of(TimetableRepositoryForTest.id(tripId)) .withRoute(trip.getRoute()) .withStopPattern(stopPattern) .withScheduledTimeTableBuilder(builder -> builder.addTripTimes(tripTimes)) diff --git a/application/src/test/java/org/opentripplanner/gtfs/mapping/EntranceMapperTest.java b/application/src/test/java/org/opentripplanner/gtfs/mapping/EntranceMapperTest.java index fbf9444ccec..a17d6e05d98 100644 --- a/application/src/test/java/org/opentripplanner/gtfs/mapping/EntranceMapperTest.java +++ b/application/src/test/java/org/opentripplanner/gtfs/mapping/EntranceMapperTest.java @@ -45,9 +45,8 @@ public class EntranceMapperTest { private static final Stop STOP = new Stop(); - private final EntranceMapper subject = new EntranceMapper( - new TranslationHelper(), - stationId -> null + private final EntranceMapper subject = new EntranceMapper(new TranslationHelper(), stationId -> + null ); static { diff --git a/application/src/test/java/org/opentripplanner/gtfs/mapping/FareAttributeMapperTest.java b/application/src/test/java/org/opentripplanner/gtfs/mapping/FareAttributeMapperTest.java index 57c0986bd8a..06f65486eba 100644 --- a/application/src/test/java/org/opentripplanner/gtfs/mapping/FareAttributeMapperTest.java +++ b/application/src/test/java/org/opentripplanner/gtfs/mapping/FareAttributeMapperTest.java @@ -18,7 +18,8 @@ public class FareAttributeMapperTest { - private static final org.onebusaway.gtfs.model.FareAttribute FARE_ATTRIBUTE = new org.onebusaway.gtfs.model.FareAttribute(); + private static final org.onebusaway.gtfs.model.FareAttribute FARE_ATTRIBUTE = + new org.onebusaway.gtfs.model.FareAttribute(); private static final AgencyAndId ID = new AgencyAndId("A", "1"); diff --git a/application/src/test/java/org/opentripplanner/gtfs/mapping/FareLegRuleMapperTest.java b/application/src/test/java/org/opentripplanner/gtfs/mapping/FareLegRuleMapperTest.java index 334d30fa94f..cf7bf1bce46 100644 --- a/application/src/test/java/org/opentripplanner/gtfs/mapping/FareLegRuleMapperTest.java +++ b/application/src/test/java/org/opentripplanner/gtfs/mapping/FareLegRuleMapperTest.java @@ -56,24 +56,21 @@ Stream mapDistance() { return testCases .stream() .map(tc -> - dynamicTest( - tc.toString(), - () -> { - var obaRule = new FareLegRule(); - obaRule.setFareProductId(fp.getFareProductId()); - obaRule.setDistanceType(tc.distanceType); - obaRule.setMinDistance(tc.minDistance); - obaRule.setMaxDistance(tc.maxDistance); - - var mappedRules = List.copyOf(ruleMapper.map(List.of(obaRule))); - assertEquals(1, mappedRules.size()); - - var otpRule = mappedRules.get(0); - assertEquals(otpRule.fareDistance(), tc.expectedDistance); - assert (otpRule.fareProducts().size() == 1); - assert (otpRule.fareProducts().contains(internalProduct)); - } - ) + dynamicTest(tc.toString(), () -> { + var obaRule = new FareLegRule(); + obaRule.setFareProductId(fp.getFareProductId()); + obaRule.setDistanceType(tc.distanceType); + obaRule.setMinDistance(tc.minDistance); + obaRule.setMaxDistance(tc.maxDistance); + + var mappedRules = List.copyOf(ruleMapper.map(List.of(obaRule))); + assertEquals(1, mappedRules.size()); + + var otpRule = mappedRules.get(0); + assertEquals(otpRule.fareDistance(), tc.expectedDistance); + assert (otpRule.fareProducts().size() == 1); + assert (otpRule.fareProducts().contains(internalProduct)); + }) ); } diff --git a/application/src/test/java/org/opentripplanner/gtfs/mapping/FareRuleMapperTest.java b/application/src/test/java/org/opentripplanner/gtfs/mapping/FareRuleMapperTest.java index 985c7d63262..7bc27b27f83 100644 --- a/application/src/test/java/org/opentripplanner/gtfs/mapping/FareRuleMapperTest.java +++ b/application/src/test/java/org/opentripplanner/gtfs/mapping/FareRuleMapperTest.java @@ -18,7 +18,8 @@ public class FareRuleMapperTest { private static final String FEED_ID = "FEED"; - private static final org.onebusaway.gtfs.model.FareRule FARE_RULE = new org.onebusaway.gtfs.model.FareRule(); + private static final org.onebusaway.gtfs.model.FareRule FARE_RULE = + new org.onebusaway.gtfs.model.FareRule(); private static final AgencyAndId AGENCY_AND_ID = new AgencyAndId("A", "1"); diff --git a/application/src/test/java/org/opentripplanner/gtfs/mapping/FeedInfoMapperTest.java b/application/src/test/java/org/opentripplanner/gtfs/mapping/FeedInfoMapperTest.java index 2ff130cd007..9930b552af1 100644 --- a/application/src/test/java/org/opentripplanner/gtfs/mapping/FeedInfoMapperTest.java +++ b/application/src/test/java/org/opentripplanner/gtfs/mapping/FeedInfoMapperTest.java @@ -14,7 +14,8 @@ public class FeedInfoMapperTest { - private static final org.onebusaway.gtfs.model.FeedInfo FEED_INFO = new org.onebusaway.gtfs.model.FeedInfo(); + private static final org.onebusaway.gtfs.model.FeedInfo FEED_INFO = + new org.onebusaway.gtfs.model.FeedInfo(); private static final String ID = "45"; diff --git a/application/src/test/java/org/opentripplanner/gtfs/mapping/FeedScopedIdMapperTest.java b/application/src/test/java/org/opentripplanner/gtfs/mapping/FeedScopedIdMapperTest.java index 94b45ff863f..70ab54bec83 100644 --- a/application/src/test/java/org/opentripplanner/gtfs/mapping/FeedScopedIdMapperTest.java +++ b/application/src/test/java/org/opentripplanner/gtfs/mapping/FeedScopedIdMapperTest.java @@ -24,9 +24,8 @@ public void testMapAgencyAndId() throws Exception { @Test public void testMapAgencyAndIdWithNulls() throws Exception { - assertThrows( - IllegalArgumentException.class, - () -> mapAgencyAndId(new org.onebusaway.gtfs.model.AgencyAndId()) + assertThrows(IllegalArgumentException.class, () -> + mapAgencyAndId(new org.onebusaway.gtfs.model.AgencyAndId()) ); } } diff --git a/application/src/test/java/org/opentripplanner/gtfs/mapping/LocationMapperTest.java b/application/src/test/java/org/opentripplanner/gtfs/mapping/LocationMapperTest.java index fb910765f1b..bd13f325f36 100644 --- a/application/src/test/java/org/opentripplanner/gtfs/mapping/LocationMapperTest.java +++ b/application/src/test/java/org/opentripplanner/gtfs/mapping/LocationMapperTest.java @@ -48,14 +48,12 @@ void invalidPolygon() { mapper.map(gtfsLocation); assertEquals( - List - .of( - Issue.issue( - "InvalidFlexAreaGeometry", - "GTFS flex location 1:zone-3 has an invalid geometry: Self-intersection at (lat: 1.0, lon: 2.0)" - ) + List.of( + Issue.issue( + "InvalidFlexAreaGeometry", + "GTFS flex location 1:zone-3 has an invalid geometry: Self-intersection at (lat: 1.0, lon: 2.0)" ) - .toString(), + ).toString(), issueStore.listIssues().toString() ); } diff --git a/application/src/test/java/org/opentripplanner/gtfs/mapping/StopTimeMapperTest.java b/application/src/test/java/org/opentripplanner/gtfs/mapping/StopTimeMapperTest.java index 2bbed14334e..2a376c40a52 100644 --- a/application/src/test/java/org/opentripplanner/gtfs/mapping/StopTimeMapperTest.java +++ b/application/src/test/java/org/opentripplanner/gtfs/mapping/StopTimeMapperTest.java @@ -63,8 +63,9 @@ public class StopTimeMapperTest { private static final Trip TRIP = new GtfsTestData().trip; public static final DataImportIssueStore ISSUE_STORE = DataImportIssueStore.NOOP; - private static final List ZONE_COORDINATES = Arrays - .stream(Polygons.BERLIN.getCoordinates()) + private static final List ZONE_COORDINATES = Arrays.stream( + Polygons.BERLIN.getCoordinates() + ) .map(c -> new LngLatAlt(c.x, c.y)) .toList(); diff --git a/application/src/test/java/org/opentripplanner/gtfs/mapping/TransferMapperTest.java b/application/src/test/java/org/opentripplanner/gtfs/mapping/TransferMapperTest.java index 0273c3055b9..c23a7cc629e 100644 --- a/application/src/test/java/org/opentripplanner/gtfs/mapping/TransferMapperTest.java +++ b/application/src/test/java/org/opentripplanner/gtfs/mapping/TransferMapperTest.java @@ -84,24 +84,26 @@ public class TransferMapperTest { void prepare() { ROUTE_MAPPER = new RouteMapper(new AgencyMapper(FEED_ID), ISSUE_STORE, new TranslationHelper()); - TRIP_MAPPER = - new TripMapper(ROUTE_MAPPER, new DirectionMapper(ISSUE_STORE), TRANSLATION_HELPER); + TRIP_MAPPER = new TripMapper( + ROUTE_MAPPER, + new DirectionMapper(ISSUE_STORE), + TRANSLATION_HELPER + ); STATION_MAPPER = new StationMapper(TRANSLATION_HELPER, StopTransferPriority.ALLOWED); - STOP_TIME_MAPPER = - new StopTimeMapper( - STOP_MAPPER, - LOCATION_MAPPER, - LOCATION_GROUP_MAPPER, - new TripMapper( - new RouteMapper(new AgencyMapper(FEED_ID), ISSUE_STORE, TRANSLATION_HELPER), - new DirectionMapper(ISSUE_STORE), - TRANSLATION_HELPER - ), - BOOKING_RULE_MAPPER, - new TranslationHelper() - ); + STOP_TIME_MAPPER = new StopTimeMapper( + STOP_MAPPER, + LOCATION_MAPPER, + LOCATION_GROUP_MAPPER, + new TripMapper( + new RouteMapper(new AgencyMapper(FEED_ID), ISSUE_STORE, TRANSLATION_HELPER), + new DirectionMapper(ISSUE_STORE), + TRANSLATION_HELPER + ), + BOOKING_RULE_MAPPER, + new TranslationHelper() + ); tripStopTimes = new TripStopTimes(); @@ -239,8 +241,7 @@ public void testFromToSameStation() { tripStopTimes, false, ISSUE_STORE - ) - .map(transfer); + ).map(transfer); assertNotNull(result); assertNotNull(result.getFrom()); diff --git a/application/src/test/java/org/opentripplanner/inspector/vector/VectorTileResponseFactoryTest.java b/application/src/test/java/org/opentripplanner/inspector/vector/VectorTileResponseFactoryTest.java index 6c874c7108f..ef51bcbee4c 100644 --- a/application/src/test/java/org/opentripplanner/inspector/vector/VectorTileResponseFactoryTest.java +++ b/application/src/test/java/org/opentripplanner/inspector/vector/VectorTileResponseFactoryTest.java @@ -15,10 +15,8 @@ class VectorTileResponseFactoryTest { - public static final OtpServerRequestContext SERVER_CONTEXT = TestServerContext.createServerContext( - new Graph(), - new TimetableRepository() - ); + public static final OtpServerRequestContext SERVER_CONTEXT = + TestServerContext.createServerContext(new Graph(), new TimetableRepository()); enum LayerType { RED, diff --git a/application/src/test/java/org/opentripplanner/model/TimetableSnapshotTest.java b/application/src/test/java/org/opentripplanner/model/TimetableSnapshotTest.java index 11506453239..ec469c5f863 100644 --- a/application/src/test/java/org/opentripplanner/model/TimetableSnapshotTest.java +++ b/application/src/test/java/org/opentripplanner/model/TimetableSnapshotTest.java @@ -114,9 +114,8 @@ void testCannotUpdateReadOnlyTimetableSnapshot() { TripPattern pattern = patternIndex.get(new FeedScopedId(feedId, "1.1")); TripTimes tripTimes = pattern.getScheduledTimetable().getTripTimes().getFirst(); RealTimeTripUpdate realTimeTripUpdate = new RealTimeTripUpdate(pattern, tripTimes, today); - assertThrows( - ConcurrentModificationException.class, - () -> committedSnapshot.update(realTimeTripUpdate) + assertThrows(ConcurrentModificationException.class, () -> + committedSnapshot.update(realTimeTripUpdate) ); } @@ -135,18 +134,16 @@ void testCannotClearReadOnlyTimetableSnapshot() { @Test void testCannotPurgeReadOnlyTimetableSnapshot() { TimetableSnapshot committedSnapshot = createCommittedSnapshot(); - assertThrows( - ConcurrentModificationException.class, - () -> committedSnapshot.purgeExpiredData(null) + assertThrows(ConcurrentModificationException.class, () -> + committedSnapshot.purgeExpiredData(null) ); } @Test void testCannotRevertReadOnlyTimetableSnapshot() { TimetableSnapshot committedSnapshot = createCommittedSnapshot(); - assertThrows( - ConcurrentModificationException.class, - () -> committedSnapshot.revertTripToScheduledTripPattern(null, null) + assertThrows(ConcurrentModificationException.class, () -> + committedSnapshot.revertTripToScheduledTripPattern(null, null) ); } diff --git a/application/src/test/java/org/opentripplanner/model/TripPatternTest.java b/application/src/test/java/org/opentripplanner/model/TripPatternTest.java index f629902f3e1..2a2dd4515a6 100644 --- a/application/src/test/java/org/opentripplanner/model/TripPatternTest.java +++ b/application/src/test/java/org/opentripplanner/model/TripPatternTest.java @@ -105,8 +105,7 @@ public TripPattern setupTripPattern( var stopPattern = builder.build(); var route = TimetableRepositoryForTest.route("R1").build(); - return TripPattern - .of(new FeedScopedId("Test", "T1")) + return TripPattern.of(new FeedScopedId("Test", "T1")) .withRoute(route) .withStopPattern(stopPattern) .withOriginalTripPattern(originalTripPattern) @@ -132,8 +131,7 @@ private List getLineStrings( coordinates.add(coordinate); coordinates.add(new Coordinate(destination.getLon(), destination.getLat())); - var l1 = GeometryUtils - .getGeometryFactory() + var l1 = GeometryUtils.getGeometryFactory() .createLineString(coordinates.toArray(Coordinate[]::new)); return List.of(l1); diff --git a/application/src/test/java/org/opentripplanner/model/calendar/ServiceDateIntervalTest.java b/application/src/test/java/org/opentripplanner/model/calendar/ServiceDateIntervalTest.java index 69f9782a093..2bbae26ca91 100644 --- a/application/src/test/java/org/opentripplanner/model/calendar/ServiceDateIntervalTest.java +++ b/application/src/test/java/org/opentripplanner/model/calendar/ServiceDateIntervalTest.java @@ -110,10 +110,8 @@ public void intersection() { @Test public void intersectionFailsIfAUnionDoNotExist() { - assertThrows( - IllegalArgumentException.class, - () -> - new ServiceDateInterval(d0, d1).intersection(new ServiceDateInterval(d1.plusDays(1), d2)) + assertThrows(IllegalArgumentException.class, () -> + new ServiceDateInterval(d0, d1).intersection(new ServiceDateInterval(d1.plusDays(1), d2)) ); } diff --git a/application/src/test/java/org/opentripplanner/model/impl/OtpTransitServiceBuilderLimitPeriodTest.java b/application/src/test/java/org/opentripplanner/model/impl/OtpTransitServiceBuilderLimitPeriodTest.java index ae44e7239f5..9e2286b0a60 100644 --- a/application/src/test/java/org/opentripplanner/model/impl/OtpTransitServiceBuilderLimitPeriodTest.java +++ b/application/src/test/java/org/opentripplanner/model/impl/OtpTransitServiceBuilderLimitPeriodTest.java @@ -199,8 +199,7 @@ private TripPattern createTripPattern(Collection trips) { FeedScopedId patternId = TimetableRepositoryForTest.id( trips.stream().map(t -> t.getId().getId()).collect(Collectors.joining(":")) ); - TripPatternBuilder tpb = TripPattern - .of(patternId) + TripPatternBuilder tpb = TripPattern.of(patternId) .withRoute(route) .withStopPattern(STOP_PATTERN); @@ -213,8 +212,7 @@ private TripPattern createTripPattern(Collection trips) { } private Trip createTrip(String id, FeedScopedId serviceId) { - return TimetableRepositoryForTest - .trip(id) + return TimetableRepositoryForTest.trip(id) .withServiceId(serviceId) .withDirection(Direction.INBOUND) .withRoute(route) diff --git a/application/src/test/java/org/opentripplanner/model/impl/OtpTransitServiceBuilderTest.java b/application/src/test/java/org/opentripplanner/model/impl/OtpTransitServiceBuilderTest.java index d1c406d4ae1..2d772e251c6 100644 --- a/application/src/test/java/org/opentripplanner/model/impl/OtpTransitServiceBuilderTest.java +++ b/application/src/test/java/org/opentripplanner/model/impl/OtpTransitServiceBuilderTest.java @@ -88,8 +88,10 @@ public void testGetAllShapePoints() { /* private methods */ private static OtpTransitServiceBuilder createBuilder() throws IOException { - OtpTransitServiceBuilder builder = contextBuilder(FEED_ID, ConstantsForTests.SIMPLE_GTFS) - .getTransitBuilder(); + OtpTransitServiceBuilder builder = contextBuilder( + FEED_ID, + ConstantsForTests.SIMPLE_GTFS + ).getTransitBuilder(); Agency agency = agency(builder); // Supplement test data with at least one entity in all collections diff --git a/application/src/test/java/org/opentripplanner/model/impl/OtpTransitServiceImplTest.java b/application/src/test/java/org/opentripplanner/model/impl/OtpTransitServiceImplTest.java index 4b7636ca07f..e9fb9fe27ef 100644 --- a/application/src/test/java/org/opentripplanner/model/impl/OtpTransitServiceImplTest.java +++ b/application/src/test/java/org/opentripplanner/model/impl/OtpTransitServiceImplTest.java @@ -81,13 +81,13 @@ public void testGetAllTransfers() { assertEquals( """ - ConstrainedTransfer{from: RouteTP{2, stop D}, to: RouteTP{5, stop I}, constraint: {guaranteed}} - ConstrainedTransfer{from: StopTP{F}, to: StopTP{E}, constraint: {minTransferTime: 20m}} - ConstrainedTransfer{from: StopTP{K}, to: StopTP{L}, constraint: {priority: RECOMMENDED}} - ConstrainedTransfer{from: StopTP{K}, to: StopTP{M}, constraint: {priority: NOT_ALLOWED}} - ConstrainedTransfer{from: StopTP{L}, to: StopTP{K}, constraint: {priority: RECOMMENDED}} - ConstrainedTransfer{from: StopTP{M}, to: StopTP{K}, constraint: {priority: NOT_ALLOWED}} - ConstrainedTransfer{from: TripTP{1.1, stopPos 1}, to: TripTP{2.2, stopPos 0}, constraint: {guaranteed}}""", + ConstrainedTransfer{from: RouteTP{2, stop D}, to: RouteTP{5, stop I}, constraint: {guaranteed}} + ConstrainedTransfer{from: StopTP{F}, to: StopTP{E}, constraint: {minTransferTime: 20m}} + ConstrainedTransfer{from: StopTP{K}, to: StopTP{L}, constraint: {priority: RECOMMENDED}} + ConstrainedTransfer{from: StopTP{K}, to: StopTP{M}, constraint: {priority: NOT_ALLOWED}} + ConstrainedTransfer{from: StopTP{L}, to: StopTP{K}, constraint: {priority: RECOMMENDED}} + ConstrainedTransfer{from: StopTP{M}, to: StopTP{K}, constraint: {priority: NOT_ALLOWED}} + ConstrainedTransfer{from: TripTP{1.1, stopPos 1}, to: TripTP{2.2, stopPos 0}, constraint: {guaranteed}}""", result ); } diff --git a/application/src/test/java/org/opentripplanner/model/plan/ElevationProfileTest.java b/application/src/test/java/org/opentripplanner/model/plan/ElevationProfileTest.java index 91915699c90..f0f85cb3527 100644 --- a/application/src/test/java/org/opentripplanner/model/plan/ElevationProfileTest.java +++ b/application/src/test/java/org/opentripplanner/model/plan/ElevationProfileTest.java @@ -63,8 +63,7 @@ void steps() { @Test void removeDuplicateSteps() { - var p = ElevationProfile - .of() + var p = ElevationProfile.of() .step(0, 0) .step(0, 0) .step(1, 1) @@ -120,8 +119,7 @@ void assertCopyOfIsSameAsOriginal() { @Test void calculateElevationChange() { - var p = ElevationProfile - .of() + var p = ElevationProfile.of() .step(1, 10.0) .step(2, 11.0) .step(3, 10.5) diff --git a/application/src/test/java/org/opentripplanner/model/plan/ItineraryTest.java b/application/src/test/java/org/opentripplanner/model/plan/ItineraryTest.java index 58bb8d84ba0..973e3f9b4ba 100644 --- a/application/src/test/java/org/opentripplanner/model/plan/ItineraryTest.java +++ b/application/src/test/java/org/opentripplanner/model/plan/ItineraryTest.java @@ -97,8 +97,7 @@ void testDerivedFieldsWithTrainAllTheWay() { @Test void testDerivedFieldsWithWalAccessAndTwoTransitLegs() { - Itinerary itinerary = TestItineraryBuilder - .newItinerary(A, T11_02) + Itinerary itinerary = TestItineraryBuilder.newItinerary(A, T11_02) .walk(D1m, B) .bus(21, T11_05, T11_10, C) .rail(110, T11_15, T11_30, D) diff --git a/application/src/test/java/org/opentripplanner/model/plan/PlaceTest.java b/application/src/test/java/org/opentripplanner/model/plan/PlaceTest.java index 4d7375b7c89..bc2bb220a4d 100644 --- a/application/src/test/java/org/opentripplanner/model/plan/PlaceTest.java +++ b/application/src/test/java/org/opentripplanner/model/plan/PlaceTest.java @@ -23,8 +23,7 @@ public class PlaceTest { - private static final Geometry GEOMETRY = GeometryUtils - .getGeometryFactory() + private static final Geometry GEOMETRY = GeometryUtils.getGeometryFactory() .createPoint(new Coordinate(11, 60)); @Test @@ -79,8 +78,7 @@ static Stream flexStopCases() { @ParameterizedTest(name = "Flex stop name of {0} should lead to a place name of {1}") @MethodSource("flexStopCases") public void flexStop(I18NString stopName, String expectedPlaceName) { - var stop = SiteRepository - .of() + var stop = SiteRepository.of() .areaStop(new FeedScopedId("1", "stop_id")) .withGeometry(GEOMETRY) .withName(stopName) diff --git a/application/src/test/java/org/opentripplanner/model/plan/ScheduledTransitLegBuilderTest.java b/application/src/test/java/org/opentripplanner/model/plan/ScheduledTransitLegBuilderTest.java index 1031810a300..ba6f9935361 100644 --- a/application/src/test/java/org/opentripplanner/model/plan/ScheduledTransitLegBuilderTest.java +++ b/application/src/test/java/org/opentripplanner/model/plan/ScheduledTransitLegBuilderTest.java @@ -21,12 +21,10 @@ class ScheduledTransitLegBuilderTest { - private static final TransitAlert ALERT = TransitAlert - .of(id("alert")) + private static final TransitAlert ALERT = TransitAlert.of(id("alert")) .withDescriptionText(I18NString.of("alert")) .build(); - private static final TripPattern PATTERN = TimetableRepositoryForTest - .of() + private static final TripPattern PATTERN = TimetableRepositoryForTest.of() .pattern(TransitMode.BUS) .build(); private static final LocalDate DATE = LocalDate.of(2023, 11, 15); diff --git a/application/src/test/java/org/opentripplanner/model/plan/ScheduledTransitLegTest.java b/application/src/test/java/org/opentripplanner/model/plan/ScheduledTransitLegTest.java index 8cb4c499f97..3d588a9ba96 100644 --- a/application/src/test/java/org/opentripplanner/model/plan/ScheduledTransitLegTest.java +++ b/application/src/test/java/org/opentripplanner/model/plan/ScheduledTransitLegTest.java @@ -21,18 +21,16 @@ class ScheduledTransitLegTest { - static final ZonedDateTime TIME = OffsetDateTime - .parse("2023-04-17T17:49:06+02:00") - .toZonedDateTime(); + static final ZonedDateTime TIME = OffsetDateTime.parse( + "2023-04-17T17:49:06+02:00" + ).toZonedDateTime(); private static final TimetableRepositoryForTest TEST_MODEL = TimetableRepositoryForTest.of(); private static final Route ROUTE = TimetableRepositoryForTest.route(id("2")).build(); - private static final TripPattern PATTERN = TimetableRepositoryForTest - .tripPattern("1", ROUTE) + private static final TripPattern PATTERN = TimetableRepositoryForTest.tripPattern("1", ROUTE) .withStopPattern(TEST_MODEL.stopPattern(3)) .build(); private static final Trip TRIP = TimetableRepositoryForTest.trip("trip1").build(); - private static final ScheduledTripTimes TRIP_TIMES = ScheduledTripTimes - .of() + private static final ScheduledTripTimes TRIP_TIMES = ScheduledTripTimes.of() .withArrivalTimes("10:00 11:00 12:00") .withDepartureTimes("10:01 11:02 12:03") .withTrip(TRIP) @@ -56,8 +54,7 @@ void legTimesWithoutRealTime() { @Test void legTimesWithRealTime() { - var tt = ScheduledTripTimes - .of() + var tt = ScheduledTripTimes.of() .withArrivalTimes("10:00 11:00 12:00") .withDepartureTimes("10:01 11:02 12:03") .withTrip(TRIP) diff --git a/application/src/test/java/org/opentripplanner/model/plan/TestItineraryBuilder.java b/application/src/test/java/org/opentripplanner/model/plan/TestItineraryBuilder.java index 7248daa1cef..571dedad1ac 100644 --- a/application/src/test/java/org/opentripplanner/model/plan/TestItineraryBuilder.java +++ b/application/src/test/java/org/opentripplanner/model/plan/TestItineraryBuilder.java @@ -210,8 +210,7 @@ public TestItineraryBuilder flex(int start, int end, Place to) { Trip trip = trip("1", route("flex").build()); - var flexTrip = UnscheduledTrip - .of(id("flex-1")) + var flexTrip = UnscheduledTrip.of(id("flex-1")) .withStopTimes(List.of(fromStopTime, toStopTime)) .withTrip(trip) .build(); @@ -246,8 +245,7 @@ public TestItineraryBuilder flex(int start, int end, Place to) { flexPath ); - FlexibleTransitLeg leg = FlexibleTransitLeg - .of() + FlexibleTransitLeg leg = FlexibleTransitLeg.of() .withFlexTripEdge(edge) .withStartTime(newTime(start)) .withEndTime(newTime(end)) @@ -446,8 +444,7 @@ public Itinerary build() { /** Create a dummy trip */ private static Trip trip(String id, Route route) { - return TimetableRepositoryForTest - .trip(id) + return TimetableRepositoryForTest.trip(id) .withRoute(route) .withHeadsign(I18NString.of("Trip headsign %s".formatted(id))) .build(); @@ -504,8 +501,7 @@ public TestItineraryBuilder transit( StopPattern stopPattern = new StopPattern(stopTimes); final TripTimes tripTimes = TripTimesFactory.tripTimes(trip, stopTimes, new Deduplicator()); - TripPattern tripPattern = TripPattern - .of(route.getId()) + TripPattern tripPattern = TripPattern.of(route.getId()) .withRoute(route) .withStopPattern(stopPattern) .withScheduledTimeTableBuilder(builder -> builder.addTripTimes(tripTimes)) @@ -516,36 +512,34 @@ public TestItineraryBuilder transit( var distance = speed(trip.getMode()) * (end - start); if (headwaySecs != null) { - leg = - new FrequencyTransitLegBuilder() - .withTripTimes(tripTimes) - .withTripPattern(tripPattern) - .withBoardStopIndexInPattern(fromStopIndex) - .withAlightStopIndexInPattern(toStopIndex) - .withStartTime(newTime(start)) - .withEndTime(newTime(end)) - .withServiceDate(serviceDate != null ? serviceDate : SERVICE_DAY) - .withZoneId(UTC) - .withTransferFromPreviousLeg(transferFromPreviousLeg) - .withGeneralizedCost(legCost) - .withDistanceMeters(distance) - .withFrequencyHeadwayInSeconds(headwaySecs) - .build(); + leg = new FrequencyTransitLegBuilder() + .withTripTimes(tripTimes) + .withTripPattern(tripPattern) + .withBoardStopIndexInPattern(fromStopIndex) + .withAlightStopIndexInPattern(toStopIndex) + .withStartTime(newTime(start)) + .withEndTime(newTime(end)) + .withServiceDate(serviceDate != null ? serviceDate : SERVICE_DAY) + .withZoneId(UTC) + .withTransferFromPreviousLeg(transferFromPreviousLeg) + .withGeneralizedCost(legCost) + .withDistanceMeters(distance) + .withFrequencyHeadwayInSeconds(headwaySecs) + .build(); } else { - leg = - new ScheduledTransitLegBuilder() - .withTripTimes(tripTimes) - .withTripPattern(tripPattern) - .withBoardStopIndexInPattern(fromStopIndex) - .withAlightStopIndexInPattern(toStopIndex) - .withStartTime(newTime(start)) - .withEndTime(newTime(end)) - .withServiceDate(serviceDate != null ? serviceDate : SERVICE_DAY) - .withZoneId(UTC) - .withTransferFromPreviousLeg(transferFromPreviousLeg) - .withGeneralizedCost(legCost) - .withDistanceMeters(distance) - .build(); + leg = new ScheduledTransitLegBuilder() + .withTripTimes(tripTimes) + .withTripPattern(tripPattern) + .withBoardStopIndexInPattern(fromStopIndex) + .withAlightStopIndexInPattern(toStopIndex) + .withStartTime(newTime(start)) + .withEndTime(newTime(end)) + .withServiceDate(serviceDate != null ? serviceDate : SERVICE_DAY) + .withZoneId(UTC) + .withTransferFromPreviousLeg(transferFromPreviousLeg) + .withGeneralizedCost(legCost) + .withDistanceMeters(distance) + .build(); } legs.add(leg); @@ -566,8 +560,7 @@ private StreetLeg streetLeg( int legCost, List walkSteps ) { - StreetLeg leg = StreetLeg - .create() + StreetLeg leg = StreetLeg.create() .withMode(mode) .withStartTime(newTime(startTime)) .withEndTime(newTime(endTime)) diff --git a/application/src/test/java/org/opentripplanner/model/plan/WalkStepTest.java b/application/src/test/java/org/opentripplanner/model/plan/WalkStepTest.java index 4556cb90de0..a311b1e2a43 100644 --- a/application/src/test/java/org/opentripplanner/model/plan/WalkStepTest.java +++ b/application/src/test/java/org/opentripplanner/model/plan/WalkStepTest.java @@ -48,6 +48,6 @@ public void testRelativeDirection() { } private double degreesToRadians(double deg) { - return deg * Math.PI / 180; + return (deg * Math.PI) / 180; } } diff --git a/application/src/test/java/org/opentripplanner/model/plan/legreference/ScheduledTransitLegReferenceTest.java b/application/src/test/java/org/opentripplanner/model/plan/legreference/ScheduledTransitLegReferenceTest.java index 43cb413955b..a9f133f0c8b 100644 --- a/application/src/test/java/org/opentripplanner/model/plan/legreference/ScheduledTransitLegReferenceTest.java +++ b/application/src/test/java/org/opentripplanner/model/plan/legreference/ScheduledTransitLegReferenceTest.java @@ -63,8 +63,10 @@ static void buildTransitService() { new Deduplicator() ); tripTimes.setServiceCode(SERVICE_CODE); - TripPattern tripPattern = TimetableRepositoryForTest - .tripPattern("1", TimetableRepositoryForTest.route(id("1")).build()) + TripPattern tripPattern = TimetableRepositoryForTest.tripPattern( + "1", + TimetableRepositoryForTest.route(id("1")).build() + ) .withStopPattern(TimetableRepositoryForTest.stopPattern(stop1, stop2, stop3)) .withScheduledTimeTableBuilder(builder -> builder.addTripTimes(tripTimes)) .build(); @@ -75,8 +77,7 @@ static void buildTransitService() { stopIdAtPosition2 = tripPattern.getStop(2).getId(); // build transit model - SiteRepository siteRepository = TEST_MODEL - .siteRepositoryBuilder() + SiteRepository siteRepository = TEST_MODEL.siteRepositoryBuilder() .withRegularStop(stop1) .withRegularStop(stop2) .withRegularStop(stop3) @@ -103,8 +104,7 @@ static void buildTransitService() { ); timetableRepository.addTripOnServiceDate( - TripOnServiceDate - .of(TRIP_ON_SERVICE_DATE_ID) + TripOnServiceDate.of(TRIP_ON_SERVICE_DATE_ID) .withTrip(trip) .withServiceDate(SERVICE_DATE) .build() @@ -225,18 +225,16 @@ void getLegFromReferenceOutOfRangeAlightingStop() { @Test void legReferenceCannotReferToBothTripAndTripOnServiceDate() { - assertThrows( - IllegalArgumentException.class, - () -> - new ScheduledTransitLegReference( - tripId, - SERVICE_DATE, - 0, - NUMBER_OF_STOPS, - stopIdAtPosition0, - stopIdAtPosition1, - TimetableRepositoryForTest.id("trip on date id") - ) + assertThrows(IllegalArgumentException.class, () -> + new ScheduledTransitLegReference( + tripId, + SERVICE_DATE, + 0, + NUMBER_OF_STOPS, + stopIdAtPosition0, + stopIdAtPosition1, + TimetableRepositoryForTest.id("trip on date id") + ) ); } diff --git a/application/src/test/java/org/opentripplanner/model/plan/paging/cursor/DeduplicationPageCutTest.java b/application/src/test/java/org/opentripplanner/model/plan/paging/cursor/DeduplicationPageCutTest.java index f2b58d6e9c5..f972c45e19b 100644 --- a/application/src/test/java/org/opentripplanner/model/plan/paging/cursor/DeduplicationPageCutTest.java +++ b/application/src/test/java/org/opentripplanner/model/plan/paging/cursor/DeduplicationPageCutTest.java @@ -23,8 +23,7 @@ void testToString() { GENERALIZED_COST, NUM_OF_TRANSFERS, ON_STREET - ) - .toString() + ).toString() ); } } diff --git a/application/src/test/java/org/opentripplanner/model/plan/paging/cursor/PageCursorFactoryTest.java b/application/src/test/java/org/opentripplanner/model/plan/paging/cursor/PageCursorFactoryTest.java index 910620872f3..46bd36e0d50 100644 --- a/application/src/test/java/org/opentripplanner/model/plan/paging/cursor/PageCursorFactoryTest.java +++ b/application/src/test/java/org/opentripplanner/model/plan/paging/cursor/PageCursorFactoryTest.java @@ -33,8 +33,12 @@ class PageCursorFactoryTest implements PlanTestConstants { @Test public void sortArrivalAscending() { - var factory = new PageCursorFactory(STREET_AND_ARRIVAL_TIME, D90M) - .withOriginalSearch(null, T12_00, null, D1H); + var factory = new PageCursorFactory(STREET_AND_ARRIVAL_TIME, D90M).withOriginalSearch( + null, + T12_00, + null, + D1H + ); var nextPage = factory.nextPageCursor(); assertPageCursor(nextPage, T13_00, null, D90M, NEXT_PAGE, false); @@ -63,8 +67,12 @@ public void sortArrivalAscendingCropSearchWindow() { @Test public void sortArrivalAscendingPreviousPage() { - var factory = new PageCursorFactory(STREET_AND_ARRIVAL_TIME, D90M) - .withOriginalSearch(PREVIOUS_PAGE, T12_00, null, D1H); + var factory = new PageCursorFactory(STREET_AND_ARRIVAL_TIME, D90M).withOriginalSearch( + PREVIOUS_PAGE, + T12_00, + null, + D1H + ); var nextPage = factory.nextPageCursor(); assertPageCursor(nextPage, T13_00, null, D90M, NEXT_PAGE, false); @@ -93,8 +101,12 @@ public void sortArrivalAscendingCropSearchWindowPreviousPage() { @Test public void sortDepartureDescending() { - var factory = new PageCursorFactory(STREET_AND_DEPARTURE_TIME, D90M) - .withOriginalSearch(null, T12_00, T13_30, D1H); + var factory = new PageCursorFactory(STREET_AND_DEPARTURE_TIME, D90M).withOriginalSearch( + null, + T12_00, + T13_30, + D1H + ); var nextPage = factory.nextPageCursor(); assertPageCursor(nextPage, T13_00, null, D90M, NEXT_PAGE, false); @@ -123,8 +135,12 @@ public void sortDepartureDescendingCropSearchWindow() { @Test public void sortDepartureDescendingNextPage() { - var factory = new PageCursorFactory(STREET_AND_DEPARTURE_TIME, D90M) - .withOriginalSearch(NEXT_PAGE, T12_00, T13_30, D1H); + var factory = new PageCursorFactory(STREET_AND_DEPARTURE_TIME, D90M).withOriginalSearch( + NEXT_PAGE, + T12_00, + T13_30, + D1H + ); var nextPage = factory.nextPageCursor(); assertPageCursor(nextPage, T13_00, null, D90M, NEXT_PAGE, false); diff --git a/application/src/test/java/org/opentripplanner/model/plan/paging/cursor/PageCursorTest.java b/application/src/test/java/org/opentripplanner/model/plan/paging/cursor/PageCursorTest.java index bd6037ef4a1..d1e7fd05978 100644 --- a/application/src/test/java/org/opentripplanner/model/plan/paging/cursor/PageCursorTest.java +++ b/application/src/test/java/org/opentripplanner/model/plan/paging/cursor/PageCursorTest.java @@ -45,8 +45,7 @@ class PageCursorTest implements PlanTestConstants { private static final Instant EDT = Instant.parse(EDT_STR); private static final Instant LAT = Instant.parse(LAT_STR); private static final Duration SEARCH_WINDOW = Duration.parse("PT2h"); - private static final Itinerary PAGE_CUT = TestItineraryBuilder - .newItinerary(A, 0) + private static final Itinerary PAGE_CUT = TestItineraryBuilder.newItinerary(A, 0) .walk(20, Place.forStop(TEST_MODEL.stop("1:stop", 1d, 1d).build())) .bus(23, 0, 50, B) .build(); @@ -60,10 +59,22 @@ public void setup() { originalTimeZone = TimeZone.getDefault(); TimeZone.setDefault(TimeZone.getTimeZone(ZONE_ID)); - subjectDepartAfter = - new PageCursor(NEXT_PAGE, STREET_AND_ARRIVAL_TIME, EDT, null, SEARCH_WINDOW, null); - subjectArriveBy = - new PageCursor(PREVIOUS_PAGE, STREET_AND_DEPARTURE_TIME, EDT, LAT, SEARCH_WINDOW, PAGE_CUT); + subjectDepartAfter = new PageCursor( + NEXT_PAGE, + STREET_AND_ARRIVAL_TIME, + EDT, + null, + SEARCH_WINDOW, + null + ); + subjectArriveBy = new PageCursor( + PREVIOUS_PAGE, + STREET_AND_DEPARTURE_TIME, + EDT, + LAT, + SEARCH_WINDOW, + PAGE_CUT + ); } @AfterEach diff --git a/application/src/test/java/org/opentripplanner/model/projectinfo/MavenProjectVersionTest.java b/application/src/test/java/org/opentripplanner/model/projectinfo/MavenProjectVersionTest.java index aaa749daa70..08f0e9eea27 100644 --- a/application/src/test/java/org/opentripplanner/model/projectinfo/MavenProjectVersionTest.java +++ b/application/src/test/java/org/opentripplanner/model/projectinfo/MavenProjectVersionTest.java @@ -10,25 +10,23 @@ public class MavenProjectVersionTest { @Test public void parse() { - List - .of( - new TC("1", 1, 0, 0, ""), - new TC("1.2", 1, 2, 0, ""), - new TC("1.2.3", 1, 2, 3, ""), - new TC("1-567", 1, 0, 0, "567"), - new TC("1.2-567", 1, 2, 0, "567"), - new TC("1.2.3-567", 1, 2, 3, "567"), - new TC("1-rc-1", 1, 0, 0, "rc-1"), - new TC("1.2.3-entur-31", 1, 2, 3, "entur-31"), - new TC("1.2.3-SNAPSHOT", 1, 2, 3, "SNAPSHOT") - ) - .forEach(tc -> { - MavenProjectVersion v = MavenProjectVersion.parse(tc.input); - assertEquals(tc.major, v.major, tc.input); - assertEquals(tc.minor, v.minor, tc.input); - assertEquals(tc.patch, v.patch, tc.input); - assertEquals(tc.qualifier, v.qualifier, tc.input); - }); + List.of( + new TC("1", 1, 0, 0, ""), + new TC("1.2", 1, 2, 0, ""), + new TC("1.2.3", 1, 2, 3, ""), + new TC("1-567", 1, 0, 0, "567"), + new TC("1.2-567", 1, 2, 0, "567"), + new TC("1.2.3-567", 1, 2, 3, "567"), + new TC("1-rc-1", 1, 0, 0, "rc-1"), + new TC("1.2.3-entur-31", 1, 2, 3, "entur-31"), + new TC("1.2.3-SNAPSHOT", 1, 2, 3, "SNAPSHOT") + ).forEach(tc -> { + MavenProjectVersion v = MavenProjectVersion.parse(tc.input); + assertEquals(tc.major, v.major, tc.input); + assertEquals(tc.minor, v.minor, tc.input); + assertEquals(tc.patch, v.patch, tc.input); + assertEquals(tc.qualifier, v.qualifier, tc.input); + }); } @Test diff --git a/application/src/test/java/org/opentripplanner/model/routing/TripSearchMetadataTest.java b/application/src/test/java/org/opentripplanner/model/routing/TripSearchMetadataTest.java index fce79cd2d4c..8fc530918c0 100644 --- a/application/src/test/java/org/opentripplanner/model/routing/TripSearchMetadataTest.java +++ b/application/src/test/java/org/opentripplanner/model/routing/TripSearchMetadataTest.java @@ -28,23 +28,21 @@ void createMetadataForArriveByWithTimeGiven() { TripSearchMetadata subject; // New arrival-time with seconds, 10:35:01, should be rounded up to 10:36:00 - subject = - TripSearchMetadata.createForArriveBy( - Instant.parse("2020-05-17T10:20:00Z"), - SEARCH_WINDOW_USED, - Instant.parse("2020-05-17T10:35:00Z") - ); + subject = TripSearchMetadata.createForArriveBy( + Instant.parse("2020-05-17T10:20:00Z"), + SEARCH_WINDOW_USED, + Instant.parse("2020-05-17T10:35:00Z") + ); assertEquals(SEARCH_WINDOW_USED, subject.searchWindowUsed); assertEquals("2020-05-17T10:04:00Z", subject.prevDateTime.toString()); assertEquals("2020-05-17T10:50:00Z", subject.nextDateTime.toString()); // New arrival-time without seconds, 10:36:00, should stay the same: 10:36:00 - subject = - TripSearchMetadata.createForArriveBy( - Instant.parse("2020-05-17T11:20:00Z"), - SEARCH_WINDOW_USED, - Instant.parse("2020-05-17T11:35:59Z") - ); + subject = TripSearchMetadata.createForArriveBy( + Instant.parse("2020-05-17T11:20:00Z"), + SEARCH_WINDOW_USED, + Instant.parse("2020-05-17T11:35:59Z") + ); assertEquals("2020-05-17T11:04:00Z", subject.prevDateTime.toString()); assertEquals("2020-05-17T11:50:00Z", subject.nextDateTime.toString()); } @@ -66,23 +64,21 @@ void createMetadataForDepartAfterWithTimeGiven() { TripSearchMetadata subject; // New departure-time, 10:35:00, should be rounded up to 10:36:00 - subject = - TripSearchMetadata.createForDepartAfter( - Instant.parse("2020-05-17T10:20:00Z"), - SEARCH_WINDOW_USED, - Instant.parse("2020-05-17T10:35:00Z") - ); + subject = TripSearchMetadata.createForDepartAfter( + Instant.parse("2020-05-17T10:20:00Z"), + SEARCH_WINDOW_USED, + Instant.parse("2020-05-17T10:35:00Z") + ); assertEquals(SEARCH_WINDOW_USED, subject.searchWindowUsed); assertEquals("2020-05-17T09:50:00Z", subject.prevDateTime.toString()); assertEquals("2020-05-17T10:36:00Z", subject.nextDateTime.toString()); // New departure-time, 11:35:59, should be rounded up to 11:36:00 - subject = - TripSearchMetadata.createForDepartAfter( - Instant.parse("2020-05-17T11:20:00Z"), - SEARCH_WINDOW_USED, - Instant.parse("2020-05-17T11:35:59Z") - ); + subject = TripSearchMetadata.createForDepartAfter( + Instant.parse("2020-05-17T11:20:00Z"), + SEARCH_WINDOW_USED, + Instant.parse("2020-05-17T11:35:59Z") + ); assertEquals("2020-05-17T10:50:00Z", subject.prevDateTime.toString()); assertEquals("2020-05-17T11:36:00Z", subject.nextDateTime.toString()); } diff --git a/application/src/test/java/org/opentripplanner/model/transfer/TransferConstraintTest.java b/application/src/test/java/org/opentripplanner/model/transfer/TransferConstraintTest.java index 47ff414790e..7b461b57e89 100644 --- a/application/src/test/java/org/opentripplanner/model/transfer/TransferConstraintTest.java +++ b/application/src/test/java/org/opentripplanner/model/transfer/TransferConstraintTest.java @@ -22,20 +22,17 @@ public class TransferConstraintTest { private final TransferConstraint STAY_SEATED = TransferConstraint.of().staySeated().build(); private final TransferConstraint GUARANTEED = TransferConstraint.of().guaranteed().build(); private final TransferConstraint NOT_ALLOWED = TransferConstraint.of().notAllowed().build(); - private final TransferConstraint MAX_WAIT_TIME = TransferConstraint - .of() + private final TransferConstraint MAX_WAIT_TIME = TransferConstraint.of() .guaranteed() .maxWaitTime(MAX_WAIT_TIME_ONE_HOUR) .build(); - private final TransferConstraint EVERYTHING = TransferConstraint - .of() + private final TransferConstraint EVERYTHING = TransferConstraint.of() .staySeated() .guaranteed() .preferred() .maxWaitTime(MAX_WAIT_TIME_ONE_HOUR) .build(); - private final TransferConstraint MIN_TX_TIME = TransferConstraint - .of() + private final TransferConstraint MIN_TX_TIME = TransferConstraint.of() .minTransferTime(D3m) .build(); diff --git a/application/src/test/java/org/opentripplanner/model/transfer/TransferPointTest.java b/application/src/test/java/org/opentripplanner/model/transfer/TransferPointTest.java index 1266ce51c83..f7559ed9eda 100644 --- a/application/src/test/java/org/opentripplanner/model/transfer/TransferPointTest.java +++ b/application/src/test/java/org/opentripplanner/model/transfer/TransferPointTest.java @@ -68,15 +68,15 @@ public void getSpecificityRanking() { @Test public void isNnnTransferPoint() { - List - .of(STATION_POINT, STOP_POINT_A, ROUTE_POINT_1A, ROUTE_POINT_1S, TRIP_POINT_11_1) - .forEach(p -> { + List.of(STATION_POINT, STOP_POINT_A, ROUTE_POINT_1A, ROUTE_POINT_1S, TRIP_POINT_11_1).forEach( + p -> { assertEquals(p == STATION_POINT, p.isStationTransferPoint()); assertEquals(p == STOP_POINT_A, p.isStopTransferPoint()); assertEquals(p == ROUTE_POINT_1A, p.isRouteStopTransferPoint()); assertEquals(p == ROUTE_POINT_1S, p.isRouteStationTransferPoint()); assertEquals(p == TRIP_POINT_11_1, p.isTripTransferPoint()); - }); + } + ); } @Test diff --git a/application/src/test/java/org/opentripplanner/model/transfer/TransferTestData.java b/application/src/test/java/org/opentripplanner/model/transfer/TransferTestData.java index 6d70936657d..cfc7e49ed92 100644 --- a/application/src/test/java/org/opentripplanner/model/transfer/TransferTestData.java +++ b/application/src/test/java/org/opentripplanner/model/transfer/TransferTestData.java @@ -17,15 +17,13 @@ public class TransferTestData { static final int POS_3 = 3; static final int ANY_POS = 999; - static final RegularStop STOP_A = TEST_MODEL - .stop("A", 60.0, 11.0) + static final RegularStop STOP_A = TEST_MODEL.stop("A", 60.0, 11.0) .build() .copy() .withParentStation(STATION) .build(); static final RegularStop STOP_B = TEST_MODEL.stop("B", 60.0, 11.0).build(); - static final RegularStop STOP_S = TEST_MODEL - .stop("S", 60.0, 11.0) + static final RegularStop STOP_S = TEST_MODEL.stop("S", 60.0, 11.0) .build() .copy() .withParentStation(STATION) diff --git a/application/src/test/java/org/opentripplanner/netex/NetexTestDataSupport.java b/application/src/test/java/org/opentripplanner/netex/NetexTestDataSupport.java index d1ff50e3437..e02d4f70a06 100644 --- a/application/src/test/java/org/opentripplanner/netex/NetexTestDataSupport.java +++ b/application/src/test/java/org/opentripplanner/netex/NetexTestDataSupport.java @@ -116,11 +116,10 @@ public static DayTypeAssignment createDayTypeAssignmentWithPeriod( String opPeriodId, Boolean isAvailable ) { - return createDayTypeAssignment(dayTypeId, isAvailable) - .withOperatingPeriodRef( - new ObjectFactory() - .createOperatingPeriodRef(new OperatingPeriodRefStructure().withRef(opPeriodId)) - ); + return createDayTypeAssignment(dayTypeId, isAvailable).withOperatingPeriodRef( + new ObjectFactory() + .createOperatingPeriodRef(new OperatingPeriodRefStructure().withRef(opPeriodId)) + ); } public static DayTypeAssignment createDayTypeAssignmentWithOpDay( @@ -128,8 +127,9 @@ public static DayTypeAssignment createDayTypeAssignmentWithOpDay( String opDayId, Boolean isAvailable ) { - return createDayTypeAssignment(dayTypeId, isAvailable) - .withOperatingDayRef(new OperatingDayRefStructure().withRef(opDayId)); + return createDayTypeAssignment(dayTypeId, isAvailable).withOperatingDayRef( + new OperatingDayRefStructure().withRef(opDayId) + ); } public static OperatingPeriod createOperatingPeriod( @@ -217,8 +217,7 @@ public static StopPlace createStopPlace( if (quay != null) { Collection> jaxbQuays = List.of(OBJECT_FACTORY.createQuay(quay)); - Quays_RelStructure quays = OBJECT_FACTORY - .createQuays_RelStructure() + Quays_RelStructure quays = OBJECT_FACTORY.createQuays_RelStructure() .withQuayRefOrQuay(jaxbQuays); stopPlace.withQuays(quays); } diff --git a/application/src/test/java/org/opentripplanner/netex/config/NetexFeedParametersTest.java b/application/src/test/java/org/opentripplanner/netex/config/NetexFeedParametersTest.java index 93624afe339..7002547770e 100644 --- a/application/src/test/java/org/opentripplanner/netex/config/NetexFeedParametersTest.java +++ b/application/src/test/java/org/opentripplanner/netex/config/NetexFeedParametersTest.java @@ -20,8 +20,7 @@ class NetexFeedParametersTest { private static final Set FERRY_IDS = Set.of("Ferry:Id"); private static final String IGNORE_FILE = "[ignoreFl]+"; - private final NetexFeedParameters subject = NetexFeedParameters - .of() + private final NetexFeedParameters subject = NetexFeedParameters.of() .withFeedId(FEED_ID) .withSource(new URI(SOURCE_URI)) .withSharedFilePattern(Pattern.compile(SHARED_FILE)) diff --git a/application/src/test/java/org/opentripplanner/netex/loader/parser/ServiceCalendarFrameParserTest.java b/application/src/test/java/org/opentripplanner/netex/loader/parser/ServiceCalendarFrameParserTest.java index 6a892469893..36c8bb319b5 100644 --- a/application/src/test/java/org/opentripplanner/netex/loader/parser/ServiceCalendarFrameParserTest.java +++ b/application/src/test/java/org/opentripplanner/netex/loader/parser/ServiceCalendarFrameParserTest.java @@ -34,10 +34,10 @@ void testParseOperatingPeriodInServiceFrame() { OBJECT_FACTORY.createOperatingPeriodsInFrame_RelStructure() ); - OperatingPeriod_VersionStructure operatingPeriod = OBJECT_FACTORY - .createOperatingPeriod_VersionStructure() - .withFromDate(FROM_DATE) - .withToDate(TO_DATE); + OperatingPeriod_VersionStructure operatingPeriod = + OBJECT_FACTORY.createOperatingPeriod_VersionStructure() + .withFromDate(FROM_DATE) + .withToDate(TO_DATE); serviceCalendarFrame .getOperatingPeriods() .getOperatingPeriodOrUicOperatingPeriod() @@ -55,8 +55,7 @@ void testParseOperatingPeriodInServiceCalendar() { .getServiceCalendar() .setOperatingPeriods(OBJECT_FACTORY.createOperatingPeriods_RelStructure()); - OperatingPeriod operatingPeriod = OBJECT_FACTORY - .createOperatingPeriod() + OperatingPeriod operatingPeriod = OBJECT_FACTORY.createOperatingPeriod() .withFromDate(FROM_DATE) .withToDate(TO_DATE); JAXBElement jaxbOperatingPeriod = OBJECT_FACTORY.createOperatingPeriod(operatingPeriod); diff --git a/application/src/test/java/org/opentripplanner/netex/mapping/FlexStopsMapperTest.java b/application/src/test/java/org/opentripplanner/netex/mapping/FlexStopsMapperTest.java index 272db6b62f0..3effbad4f6b 100644 --- a/application/src/test/java/org/opentripplanner/netex/mapping/FlexStopsMapperTest.java +++ b/application/src/test/java/org/opentripplanner/netex/mapping/FlexStopsMapperTest.java @@ -119,12 +119,13 @@ class FlexStopsMapperTest { 63.596915083462335, 10.878374152208456 ); - private static final KeyListStructure KEY_LIST_UNRESTRICTED_PUBLIC_TRANSPORT_AREAS = new KeyListStructure() - .withKeyValue( - new KeyValueStructure() - .withKey("FlexibleStopAreaType") - .withValue("UnrestrictedPublicTransportAreas") - ); + private static final KeyListStructure KEY_LIST_UNRESTRICTED_PUBLIC_TRANSPORT_AREAS = + new KeyListStructure() + .withKeyValue( + new KeyValueStructure() + .withKey("FlexibleStopAreaType") + .withValue("UnrestrictedPublicTransportAreas") + ); private final TimetableRepositoryForTest testModel = TimetableRepositoryForTest.of(); private final SiteRepositoryBuilder siteRepositoryBuilder = testModel.siteRepositoryBuilder(); diff --git a/application/src/test/java/org/opentripplanner/netex/mapping/NetexTestDataSample.java b/application/src/test/java/org/opentripplanner/netex/mapping/NetexTestDataSample.java index 56c672c7ef8..86dd14b0536 100644 --- a/application/src/test/java/org/opentripplanner/netex/mapping/NetexTestDataSample.java +++ b/application/src/test/java/org/opentripplanner/netex/mapping/NetexTestDataSample.java @@ -66,17 +66,22 @@ public class NetexTestDataSample { private final TimetableRepositoryForTest testModel = TimetableRepositoryForTest.of(); private final JourneyPattern journeyPattern; - private final HierarchicalMapById journeyPatternById = new HierarchicalMapById<>(); - private final HierarchicalMapById destinationDisplayById = new HierarchicalMapById<>(); + private final HierarchicalMapById journeyPatternById = + new HierarchicalMapById<>(); + private final HierarchicalMapById destinationDisplayById = + new HierarchicalMapById<>(); private final EntityById stopsById = new DefaultEntityById<>(); private final HierarchicalMap quayIdByStopPointRef = new HierarchicalMap<>(); private final List timetabledPassingTimes = new ArrayList<>(); - private final HierarchicalMapById serviceJourneyById = new HierarchicalMapById<>(); + private final HierarchicalMapById serviceJourneyById = + new HierarchicalMapById<>(); private final HierarchicalMapById routesById = new HierarchicalMapById<>(); private final HierarchicalMapById operatingDaysById = new HierarchicalMapById<>(); - private final ArrayListMultimap datedServiceJourneyBySjId = ArrayListMultimap.create(); + private final ArrayListMultimap datedServiceJourneyBySjId = + ArrayListMultimap.create(); - private final EntityById otpRouteByid = new DefaultEntityById<>(); + private final EntityById otpRouteByid = + new DefaultEntityById<>(); public NetexTestDataSample() { final int[] stopTimes = { 0, 4, 10, 15 }; @@ -144,16 +149,15 @@ public NetexTestDataSample() { } // Create Journey Pattern with route and points - journeyPattern = - new JourneyPattern() - .withId("RUT:JourneyPattern:1") - .withRouteRef(routeRef) - .withPointsInSequence( - new PointsInJourneyPattern_RelStructure() - .withPointInJourneyPatternOrStopPointInJourneyPatternOrTimingPointInJourneyPattern( - pointsInLink - ) - ); + journeyPattern = new JourneyPattern() + .withId("RUT:JourneyPattern:1") + .withRouteRef(routeRef) + .withPointsInSequence( + new PointsInJourneyPattern_RelStructure() + .withPointInJourneyPatternOrStopPointInJourneyPatternOrTimingPointInJourneyPattern( + pointsInLink + ) + ); journeyPatternById.add(journeyPattern); // Create a new Service Journey with line, dayType, journeyPattern and timetable from above diff --git a/application/src/test/java/org/opentripplanner/netex/mapping/NoticeAssignmentMapperTest.java b/application/src/test/java/org/opentripplanner/netex/mapping/NoticeAssignmentMapperTest.java index 09a806169ab..ca881152b97 100644 --- a/application/src/test/java/org/opentripplanner/netex/mapping/NoticeAssignmentMapperTest.java +++ b/application/src/test/java/org/opentripplanner/netex/mapping/NoticeAssignmentMapperTest.java @@ -62,9 +62,10 @@ public void mapNoticeAssignment() { new HashMap<>() ); - Multimap noticesByElement = noticeAssignmentMapper.map( - noticeAssignment - ); + Multimap< + AbstractTransitEntity, + org.opentripplanner.transit.model.basic.Notice + > noticesByElement = noticeAssignmentMapper.map(noticeAssignment); org.opentripplanner.transit.model.basic.Notice notice2 = noticesByElement .get(route) @@ -113,9 +114,10 @@ public void mapNoticeAssignmentOnStopPoint() { stopTimesById ); - Multimap noticesByElement = noticeAssignmentMapper.map( - noticeAssignment - ); + Multimap< + AbstractTransitEntity, + org.opentripplanner.transit.model.basic.Notice + > noticesByElement = noticeAssignmentMapper.map(noticeAssignment); org.opentripplanner.transit.model.basic.Notice notice2a = noticesByElement .get(stopTime1.getId()) diff --git a/application/src/test/java/org/opentripplanner/netex/mapping/NoticeMapperTest.java b/application/src/test/java/org/opentripplanner/netex/mapping/NoticeMapperTest.java index f6df29cc25a..f772315bb29 100644 --- a/application/src/test/java/org/opentripplanner/netex/mapping/NoticeMapperTest.java +++ b/application/src/test/java/org/opentripplanner/netex/mapping/NoticeMapperTest.java @@ -35,13 +35,12 @@ public void mapNotice() { // And when other instance with same id is mapped, the first one is returned // from cache - ignoring all properties except the id - otpNotice = - mapper.map( - new Notice() - .withId(NOTICE_ID) - .withPublicCode("Albatross") - .withText(new MultilingualString().withValue("Different text")) - ); + otpNotice = mapper.map( + new Notice() + .withId(NOTICE_ID) + .withPublicCode("Albatross") + .withText(new MultilingualString().withValue("Different text")) + ); // Then assertEquals(NOTICE_ID, otpNotice.getId().getId()); diff --git a/application/src/test/java/org/opentripplanner/netex/mapping/OperatorToAgencyMapperTest.java b/application/src/test/java/org/opentripplanner/netex/mapping/OperatorToAgencyMapperTest.java index d9641cfd633..5174792a16b 100644 --- a/application/src/test/java/org/opentripplanner/netex/mapping/OperatorToAgencyMapperTest.java +++ b/application/src/test/java/org/opentripplanner/netex/mapping/OperatorToAgencyMapperTest.java @@ -28,9 +28,10 @@ public void mapOperatorWithEverything() { // When mapped org.opentripplanner.transit.model.organization.Operator o; - o = - new OperatorToAgencyMapper(DataImportIssueStore.NOOP, MappingSupport.ID_FACTORY) - .mapOperator(operator); + o = new OperatorToAgencyMapper( + DataImportIssueStore.NOOP, + MappingSupport.ID_FACTORY + ).mapOperator(operator); // Then expect assertEquals(ID, o.getId().getId()); @@ -48,9 +49,10 @@ public void mapOperatorWithMinimumDataSet() { // When mapped org.opentripplanner.transit.model.organization.Operator o; - o = - new OperatorToAgencyMapper(DataImportIssueStore.NOOP, MappingSupport.ID_FACTORY) - .mapOperator(operator); + o = new OperatorToAgencyMapper( + DataImportIssueStore.NOOP, + MappingSupport.ID_FACTORY + ).mapOperator(operator); // Then expect assertEquals(ID, o.getId().getId()); diff --git a/application/src/test/java/org/opentripplanner/netex/mapping/RouteMapperTest.java b/application/src/test/java/org/opentripplanner/netex/mapping/RouteMapperTest.java index b2187af4216..18cb395dfaa 100644 --- a/application/src/test/java/org/opentripplanner/netex/mapping/RouteMapperTest.java +++ b/application/src/test/java/org/opentripplanner/netex/mapping/RouteMapperTest.java @@ -278,8 +278,7 @@ private Line createExampleFerry(String id) { } private Agency createAgency() { - return TimetableRepositoryForTest - .agency("Ruter AS") + return TimetableRepositoryForTest.agency("Ruter AS") .copy() .withId(MappingSupport.ID_FACTORY.createId(AUTHORITY_ID)) .build(); diff --git a/application/src/test/java/org/opentripplanner/netex/mapping/ServiceLinkMapperTest.java b/application/src/test/java/org/opentripplanner/netex/mapping/ServiceLinkMapperTest.java index 52c1564f025..b4010d5cfb4 100644 --- a/application/src/test/java/org/opentripplanner/netex/mapping/ServiceLinkMapperTest.java +++ b/application/src/test/java/org/opentripplanner/netex/mapping/ServiceLinkMapperTest.java @@ -114,8 +114,7 @@ void setUpTestData() { ); stopPatternBuilder = StopPattern.create(3); - Station parentStation = Station - .of(ID_FACTORY.createId("NSR:StopArea:1")) + Station parentStation = Station.of(ID_FACTORY.createId("NSR:StopArea:1")) .withName(NonLocalizedString.ofNullable("Parent Station")) .withCoordinate(59.908, 10.745) .build(); @@ -132,15 +131,14 @@ void setUpTestData() { stopsById.add(stop); } - serviceLinkMapper = - new ServiceLinkMapper( - ID_FACTORY, - serviceLinksById, - quayIdByStopPointRef, - stopsById, - issueStore, - 150 - ); + serviceLinkMapper = new ServiceLinkMapper( + ID_FACTORY, + serviceLinksById, + quayIdByStopPointRef, + stopsById, + issueStore, + 150 + ); } @Test @@ -270,9 +268,8 @@ private ServiceLink createServiceLink(String id, String from, String to, Double[ .withValue(coordinates); LinkSequenceProjection linkSequenceProjection = new LinkSequenceProjection() .withLineString(new LineStringType().withPosList(directPositionListType)); - JAXBElement linkSequenceProjection_versionStructure = MappingSupport.createJaxbElement( - linkSequenceProjection - ); + JAXBElement linkSequenceProjection_versionStructure = + MappingSupport.createJaxbElement(linkSequenceProjection); Projections_RelStructure projections_relStructure = new Projections_RelStructure() .withProjectionRefOrProjection(linkSequenceProjection_versionStructure); diff --git a/application/src/test/java/org/opentripplanner/netex/mapping/StationMapperTest.java b/application/src/test/java/org/opentripplanner/netex/mapping/StationMapperTest.java index 6f0524d92d7..b80a38fae6a 100644 --- a/application/src/test/java/org/opentripplanner/netex/mapping/StationMapperTest.java +++ b/application/src/test/java/org/opentripplanner/netex/mapping/StationMapperTest.java @@ -22,15 +22,14 @@ class StationMapperTest { @BeforeEach void setUp() { - stationMapper = - new StationMapper( - DataImportIssueStore.NOOP, - new FeedScopedIdFactory("FEED_ID"), - ZoneId.of("UTC"), - false, - Set.of(), - SiteRepository.of() - ); + stationMapper = new StationMapper( + DataImportIssueStore.NOOP, + new FeedScopedIdFactory("FEED_ID"), + ZoneId.of("UTC"), + false, + Set.of(), + SiteRepository.of() + ); } @Test diff --git a/application/src/test/java/org/opentripplanner/netex/mapping/StopAndStationMapperTest.java b/application/src/test/java/org/opentripplanner/netex/mapping/StopAndStationMapperTest.java index 2d710224661..f967f9afbd5 100644 --- a/application/src/test/java/org/opentripplanner/netex/mapping/StopAndStationMapperTest.java +++ b/application/src/test/java/org/opentripplanner/netex/mapping/StopAndStationMapperTest.java @@ -213,15 +213,14 @@ void mapStopPlaceAndQuays() { void testMapIsolatedStopPlace(boolean isolated) { Collection stopPlaces = new ArrayList<>(); StopPlace stopPlace; - stopPlace = - createStopPlace( - "NSR:StopPlace:1", - "Oslo A", - "1", - 59.909584, - 10.755165, - AllVehicleModesOfTransportEnumeration.TRAM - ); + stopPlace = createStopPlace( + "NSR:StopPlace:1", + "Oslo A", + "1", + 59.909584, + 10.755165, + AllVehicleModesOfTransportEnumeration.TRAM + ); stopPlace.withLimitedUse(LimitedUseTypeEnumeration.ISOLATED); diff --git a/application/src/test/java/org/opentripplanner/netex/mapping/TransportModeMapperTest.java b/application/src/test/java/org/opentripplanner/netex/mapping/TransportModeMapperTest.java index 11c41548a60..90120c72c4d 100644 --- a/application/src/test/java/org/opentripplanner/netex/mapping/TransportModeMapperTest.java +++ b/application/src/test/java/org/opentripplanner/netex/mapping/TransportModeMapperTest.java @@ -30,7 +30,10 @@ class TransportModeMapperTest { - private static final Map VALID_SUBMODE_STRUCTURES = Map.of( + private static final Map< + AllVehicleModesOfTransportEnumeration, + TransportSubmodeStructure + > VALID_SUBMODE_STRUCTURES = Map.of( AllVehicleModesOfTransportEnumeration.AIR, new TransportSubmodeStructure().withAirSubmode(AirSubmodeEnumeration.DOMESTIC_FLIGHT), AllVehicleModesOfTransportEnumeration.BUS, @@ -54,9 +57,8 @@ class TransportModeMapperTest { .withWaterSubmode(WaterSubmodeEnumeration.INTERNATIONAL_PASSENGER_FERRY) ); - private static final EnumSet SUPPORTED_MODES = EnumSet.copyOf( - VALID_SUBMODE_STRUCTURES.keySet() - ); + private static final EnumSet SUPPORTED_MODES = + EnumSet.copyOf(VALID_SUBMODE_STRUCTURES.keySet()); private final TransportModeMapper transportModeMapper = new TransportModeMapper(); @@ -117,18 +119,15 @@ void supportedMode() { @Test void unsupportedMode() { - EnumSet - .complementOf(SUPPORTED_MODES) - .forEach(mode -> { - assertThrows(UnsupportedModeException.class, () -> transportModeMapper.map(mode, null)); - }); + EnumSet.complementOf(SUPPORTED_MODES).forEach(mode -> { + assertThrows(UnsupportedModeException.class, () -> transportModeMapper.map(mode, null)); + }); assertThrows(UnsupportedModeException.class, () -> transportModeMapper.map(null, null)); } private static List createSubModeTestCases() { - return VALID_SUBMODE_STRUCTURES - .entrySet() + return VALID_SUBMODE_STRUCTURES.entrySet() .stream() .map(entry -> Arguments.of(entry.getKey(), entry.getValue())) .toList(); diff --git a/application/src/test/java/org/opentripplanner/netex/mapping/TripCalendarBuilderTest.java b/application/src/test/java/org/opentripplanner/netex/mapping/TripCalendarBuilderTest.java index 90251396ae4..f7d0d32f265 100644 --- a/application/src/test/java/org/opentripplanner/netex/mapping/TripCalendarBuilderTest.java +++ b/application/src/test/java/org/opentripplanner/netex/mapping/TripCalendarBuilderTest.java @@ -51,8 +51,10 @@ public class TripCalendarBuilderTest { private static final String SJ_2 = "SJ-2"; private static final String SJ_3 = "SJ-3"; - private static final HierarchicalMapById EMPTY_OPERATING_DAYS = new HierarchicalMapById<>(); - private static final HierarchicalMapById EMPTY_PERIODS = new HierarchicalMapById<>(); + private static final HierarchicalMapById EMPTY_OPERATING_DAYS = + new HierarchicalMapById<>(); + private static final HierarchicalMapById EMPTY_PERIODS = + new HierarchicalMapById<>(); public static final String OD_1 = "OD-1"; private final DataImportIssueStore issueStore = DataImportIssueStore.NOOP; diff --git a/application/src/test/java/org/opentripplanner/netex/mapping/TripMapperTest.java b/application/src/test/java/org/opentripplanner/netex/mapping/TripMapperTest.java index 6c4973329d3..e15aa83d339 100644 --- a/application/src/test/java/org/opentripplanner/netex/mapping/TripMapperTest.java +++ b/application/src/test/java/org/opentripplanner/netex/mapping/TripMapperTest.java @@ -125,7 +125,8 @@ public void mapTripWithRouteRefViaJourneyPattern() { HierarchicalMapById routeById = new HierarchicalMapById<>(); routeById.add(netexRoute); - HierarchicalMapById journeyPatternById = new HierarchicalMapById<>(); + HierarchicalMapById journeyPatternById = + new HierarchicalMapById<>(); journeyPatternById.add(journeyPattern); TripMapper tripMapper = new TripMapper( diff --git a/application/src/test/java/org/opentripplanner/netex/mapping/WgsCoordinateMapperTest.java b/application/src/test/java/org/opentripplanner/netex/mapping/WgsCoordinateMapperTest.java index d3c78f6ccb1..b3cce9fbbd6 100644 --- a/application/src/test/java/org/opentripplanner/netex/mapping/WgsCoordinateMapperTest.java +++ b/application/src/test/java/org/opentripplanner/netex/mapping/WgsCoordinateMapperTest.java @@ -48,9 +48,8 @@ public void handleCoordinatesWithMissingLocation() { @Test public void handleCoordinatesWithMissingLatitude() { SimplePoint_VersionStructure p; - p = - new SimplePoint_VersionStructure() - .withLocation(new LocationStructure().withLongitude(LONGITUDE)); + p = new SimplePoint_VersionStructure() + .withLocation(new LocationStructure().withLongitude(LONGITUDE)); assertThrows(IllegalArgumentException.class, () -> WgsCoordinateMapper.mapToDomain(p)); } @@ -58,9 +57,8 @@ public void handleCoordinatesWithMissingLatitude() { @Test public void handleCoordinatesWithMissingLongitude() { SimplePoint_VersionStructure p; - p = - new SimplePoint_VersionStructure() - .withLocation(new LocationStructure().withLatitude(LATITUDE)); + p = new SimplePoint_VersionStructure() + .withLocation(new LocationStructure().withLatitude(LATITUDE)); assertThrows(IllegalArgumentException.class, () -> WgsCoordinateMapper.mapToDomain(p)); } } diff --git a/application/src/test/java/org/opentripplanner/netex/mapping/calendar/DatedServiceJourneyMapperTest.java b/application/src/test/java/org/opentripplanner/netex/mapping/calendar/DatedServiceJourneyMapperTest.java index d8bb0d5fe20..d692db1d77d 100644 --- a/application/src/test/java/org/opentripplanner/netex/mapping/calendar/DatedServiceJourneyMapperTest.java +++ b/application/src/test/java/org/opentripplanner/netex/mapping/calendar/DatedServiceJourneyMapperTest.java @@ -42,12 +42,14 @@ public void mapToServiceDates() { // Date is filtered by ServiceAlteration dsjList.add( - createDatedServiceJourney("ID-C", OP_DAY_3, SJ_1) - .withServiceAlteration(ServiceAlterationEnumeration.CANCELLATION) + createDatedServiceJourney("ID-C", OP_DAY_3, SJ_1).withServiceAlteration( + ServiceAlterationEnumeration.CANCELLATION + ) ); dsjList.add( - createDatedServiceJourney("ID-B", OP_DAY_2, SJ_1) - .withServiceAlteration(ServiceAlterationEnumeration.EXTRA_JOURNEY) + createDatedServiceJourney("ID-B", OP_DAY_2, SJ_1).withServiceAlteration( + ServiceAlterationEnumeration.EXTRA_JOURNEY + ) ); opDaysById.add(createOperatingDay(OP_DAY_1, LD1)); diff --git a/application/src/test/java/org/opentripplanner/netex/mapping/calendar/DayTypeAssignmentMapperTest.java b/application/src/test/java/org/opentripplanner/netex/mapping/calendar/DayTypeAssignmentMapperTest.java index abff6e91f01..0d93035cd86 100644 --- a/application/src/test/java/org/opentripplanner/netex/mapping/calendar/DayTypeAssignmentMapperTest.java +++ b/application/src/test/java/org/opentripplanner/netex/mapping/calendar/DayTypeAssignmentMapperTest.java @@ -50,8 +50,10 @@ class DayTypeAssignmentMapperTest { private static final Boolean AVAILABLE = TRUE; private static final Boolean NOT_AVAILABLE = FALSE; - private static final HierarchicalMapById EMPTY_OPERATING_DAYS = new HierarchicalMapById<>(); - private static final HierarchicalMapById EMPTY_PERIODS = new HierarchicalMapById<>(); + private static final HierarchicalMapById EMPTY_OPERATING_DAYS = + new HierarchicalMapById<>(); + private static final HierarchicalMapById EMPTY_PERIODS = + new HierarchicalMapById<>(); public static final String OPERATING_DAY_1 = "OD-1"; public static final String OPERATING_DAY_2 = "OD-2"; diff --git a/application/src/test/java/org/opentripplanner/netex/validation/JourneyPatternSJMismatchTest.java b/application/src/test/java/org/opentripplanner/netex/validation/JourneyPatternSJMismatchTest.java index f1c87342800..2f598f0e41d 100644 --- a/application/src/test/java/org/opentripplanner/netex/validation/JourneyPatternSJMismatchTest.java +++ b/application/src/test/java/org/opentripplanner/netex/validation/JourneyPatternSJMismatchTest.java @@ -95,7 +95,8 @@ void passThrough() { static class ServiceJourneyPatternBuilder { private final ServiceJourneyPattern pattern = new ServiceJourneyPattern(); - private final PointsInJourneyPattern_RelStructure points = new PointsInJourneyPattern_RelStructure(); + private final PointsInJourneyPattern_RelStructure points = + new PointsInJourneyPattern_RelStructure(); ServiceJourneyPatternBuilder(String id) { pattern.setId(id); diff --git a/application/src/test/java/org/opentripplanner/netex/validation/ServiceJourneyNonIncreasingPassingTimeTest.java b/application/src/test/java/org/opentripplanner/netex/validation/ServiceJourneyNonIncreasingPassingTimeTest.java index 1672c191120..45d9d53bec4 100644 --- a/application/src/test/java/org/opentripplanner/netex/validation/ServiceJourneyNonIncreasingPassingTimeTest.java +++ b/application/src/test/java/org/opentripplanner/netex/validation/ServiceJourneyNonIncreasingPassingTimeTest.java @@ -26,7 +26,8 @@ void testValidateServiceJourneyWithRegularStop() { netexEntityIndex.journeyPatternsById.add(journeyPattern); netexEntityIndex.serviceJourneyById.add(serviceJourney); - ServiceJourneyNonIncreasingPassingTime serviceJourneyNonIncreasingPassingTime = new ServiceJourneyNonIncreasingPassingTime(); + ServiceJourneyNonIncreasingPassingTime serviceJourneyNonIncreasingPassingTime = + new ServiceJourneyNonIncreasingPassingTime(); serviceJourneyNonIncreasingPassingTime.setup(netexEntityIndex.readOnlyView()); assertEquals( @@ -49,7 +50,8 @@ void testValidateServiceJourneyWithRegularStopMissingTime() { netexEntityIndex.journeyPatternsById.add(journeyPattern); netexEntityIndex.serviceJourneyById.add(serviceJourney); - ServiceJourneyNonIncreasingPassingTime serviceJourneyNonIncreasingPassingTime = new ServiceJourneyNonIncreasingPassingTime(); + ServiceJourneyNonIncreasingPassingTime serviceJourneyNonIncreasingPassingTime = + new ServiceJourneyNonIncreasingPassingTime(); serviceJourneyNonIncreasingPassingTime.setup(netexEntityIndex.readOnlyView()); assertEquals( @@ -68,7 +70,8 @@ void testValidateServiceJourneyWithRegularStopInconsistentTime() { TimetabledPassingTime timetabledPassingTime = getFirstPassingTime(serviceJourney); timetabledPassingTime.withArrivalTime(timetabledPassingTime.getDepartureTime().plusMinutes(1)); - ServiceJourneyNonIncreasingPassingTime serviceJourneyNonIncreasingPassingTime = new ServiceJourneyNonIncreasingPassingTime(); + ServiceJourneyNonIncreasingPassingTime serviceJourneyNonIncreasingPassingTime = + new ServiceJourneyNonIncreasingPassingTime(); NetexEntityIndex netexEntityIndex = new NetexEntityIndex(); netexEntityIndex.journeyPatternsById.add(journeyPattern); netexEntityIndex.serviceJourneyById.add(serviceJourney); @@ -96,7 +99,8 @@ void testValidateServiceJourneyWithAreaStop() { .withEarliestDepartureTime(LocalTime.MIDNIGHT) .withLatestArrivalTime(LocalTime.MIDNIGHT.plusMinutes(1)); - ServiceJourneyNonIncreasingPassingTime serviceJourneyNonIncreasingPassingTime = new ServiceJourneyNonIncreasingPassingTime(); + ServiceJourneyNonIncreasingPassingTime serviceJourneyNonIncreasingPassingTime = + new ServiceJourneyNonIncreasingPassingTime(); NetexEntityIndex netexEntityIndex = new NetexEntityIndex(); netexEntityIndex.journeyPatternsById.add(journeyPattern); netexEntityIndex.serviceJourneyById.addAll(serviceJourneyById.localValues()); @@ -124,7 +128,8 @@ void testValidateServiceJourneyWithAreaStopMissingTimeWindow() { TimetabledPassingTime timetabledPassingTime = getFirstPassingTime(serviceJourney); timetabledPassingTime.withArrivalTime(null).withDepartureTime(null); - ServiceJourneyNonIncreasingPassingTime serviceJourneyNonIncreasingPassingTime = new ServiceJourneyNonIncreasingPassingTime(); + ServiceJourneyNonIncreasingPassingTime serviceJourneyNonIncreasingPassingTime = + new ServiceJourneyNonIncreasingPassingTime(); NetexEntityIndex netexEntityIndex = new NetexEntityIndex(); netexEntityIndex.journeyPatternsById.add(journeyPattern); netexEntityIndex.serviceJourneyById.addAll(serviceJourneyById.localValues()); @@ -163,7 +168,8 @@ void testValidateServiceJourneyWithAreaStopInconsistentTimeWindow() { .withEarliestDepartureTime(LocalTime.MIDNIGHT.plusMinutes(1)) .withLatestArrivalTime(LocalTime.MIDNIGHT); - ServiceJourneyNonIncreasingPassingTime serviceJourneyNonIncreasingPassingTime = new ServiceJourneyNonIncreasingPassingTime(); + ServiceJourneyNonIncreasingPassingTime serviceJourneyNonIncreasingPassingTime = + new ServiceJourneyNonIncreasingPassingTime(); NetexEntityIndex netexEntityIndex = new NetexEntityIndex(); netexEntityIndex.journeyPatternsById.add(journeyPattern); netexEntityIndex.serviceJourneyById.addAll(serviceJourneyById.localValues()); @@ -197,7 +203,8 @@ void testValidateServiceJourneyWithRegularStopFollowedByRegularStopNonIncreasing NetexEntityIndex netexEntityIndex = new NetexEntityIndex(); netexEntityIndex.journeyPatternsById.add(journeyPattern); - ServiceJourneyNonIncreasingPassingTime serviceJourneyNonIncreasingPassingTime = new ServiceJourneyNonIncreasingPassingTime(); + ServiceJourneyNonIncreasingPassingTime serviceJourneyNonIncreasingPassingTime = + new ServiceJourneyNonIncreasingPassingTime(); serviceJourneyNonIncreasingPassingTime.setup(netexEntityIndex.readOnlyView()); assertEquals( @@ -250,7 +257,8 @@ void testValidateServiceJourneyWithRegularStopFollowedByStopArea() { null ); - ServiceJourneyNonIncreasingPassingTime serviceJourneyNonIncreasingPassingTime = new ServiceJourneyNonIncreasingPassingTime(); + ServiceJourneyNonIncreasingPassingTime serviceJourneyNonIncreasingPassingTime = + new ServiceJourneyNonIncreasingPassingTime(); serviceJourneyNonIncreasingPassingTime.setup(netexEntityIndex.readOnlyView()); assertEquals( @@ -281,7 +289,8 @@ void testValidateServiceJourneyWithRegularStopFollowedByStopAreaNonIncreasingTim null ); - ServiceJourneyNonIncreasingPassingTime serviceJourneyNonIncreasingPassingTime = new ServiceJourneyNonIncreasingPassingTime(); + ServiceJourneyNonIncreasingPassingTime serviceJourneyNonIncreasingPassingTime = + new ServiceJourneyNonIncreasingPassingTime(); serviceJourneyNonIncreasingPassingTime.setup(netexEntityIndex.readOnlyView()); assertEquals( @@ -312,7 +321,8 @@ void testValidateServiceJourneyWithStopAreaFollowedByRegularStop() { null ); - ServiceJourneyNonIncreasingPassingTime serviceJourneyNonIncreasingPassingTime = new ServiceJourneyNonIncreasingPassingTime(); + ServiceJourneyNonIncreasingPassingTime serviceJourneyNonIncreasingPassingTime = + new ServiceJourneyNonIncreasingPassingTime(); serviceJourneyNonIncreasingPassingTime.setup(netexEntityIndex.readOnlyView()); assertEquals( @@ -353,7 +363,8 @@ void testValidateServiceJourneyWithStopAreaFollowedByStopArea() { getSecondScheduledStopPointRef(journeyPattern), null ); - ServiceJourneyNonIncreasingPassingTime serviceJourneyNonIncreasingPassingTime = new ServiceJourneyNonIncreasingPassingTime(); + ServiceJourneyNonIncreasingPassingTime serviceJourneyNonIncreasingPassingTime = + new ServiceJourneyNonIncreasingPassingTime(); serviceJourneyNonIncreasingPassingTime.setup(netexEntityIndex.readOnlyView()); assertEquals( @@ -395,7 +406,8 @@ void testValidateServiceJourneyWithStopAreaFollowedByStopAreaNonIncreasingTime() getSecondScheduledStopPointRef(journeyPattern), null ); - ServiceJourneyNonIncreasingPassingTime serviceJourneyNonIncreasingPassingTime = new ServiceJourneyNonIncreasingPassingTime(); + ServiceJourneyNonIncreasingPassingTime serviceJourneyNonIncreasingPassingTime = + new ServiceJourneyNonIncreasingPassingTime(); serviceJourneyNonIncreasingPassingTime.setup(netexEntityIndex.readOnlyView()); assertEquals( @@ -432,7 +444,8 @@ void testValidateServiceJourneyWithStopAreaFollowedByRegularStopNonIncreasingTim null ); - ServiceJourneyNonIncreasingPassingTime serviceJourneyNonIncreasingPassingTime = new ServiceJourneyNonIncreasingPassingTime(); + ServiceJourneyNonIncreasingPassingTime serviceJourneyNonIncreasingPassingTime = + new ServiceJourneyNonIncreasingPassingTime(); serviceJourneyNonIncreasingPassingTime.setup(netexEntityIndex.readOnlyView()); assertEquals( diff --git a/application/src/test/java/org/opentripplanner/osm/wayproperty/MapperTest.java b/application/src/test/java/org/opentripplanner/osm/wayproperty/MapperTest.java index 7aed0e9efb7..9bd9e0c9953 100644 --- a/application/src/test/java/org/opentripplanner/osm/wayproperty/MapperTest.java +++ b/application/src/test/java/org/opentripplanner/osm/wayproperty/MapperTest.java @@ -175,16 +175,14 @@ void bicycleUseSidepath() { assertEquals(ALL, useSidepathProps.getPermission()); assertEquals(4.9, useSidepathProps.bicycleSafety().forward(), epsilon); - var useSidepathForward = WayTestData - .southeastLaBonitaWay() + var useSidepathForward = WayTestData.southeastLaBonitaWay() .addTag("bicycle:forward", "use_sidepath"); var useSidepathForwardProps = wps.getDataForWay(useSidepathForward); assertEquals(ALL, useSidepathForwardProps.getPermission()); assertEquals(4.9, useSidepathForwardProps.bicycleSafety().forward(), epsilon); assertEquals(0.98, useSidepathForwardProps.bicycleSafety().back(), epsilon); - var useSidepathBackward = WayTestData - .southeastLaBonitaWay() + var useSidepathBackward = WayTestData.southeastLaBonitaWay() .addTag("bicycle:backward", "use_sidepath"); var useSidepathBackwardProps = wps.getDataForWay(useSidepathBackward); assertEquals(ALL, useSidepathBackwardProps.getPermission()); @@ -228,7 +226,7 @@ private boolean within(float val1, float val2, float epsilon) { * Convert kilometers per hour to meters per second */ private float kmhAsMs(float kmh) { - return kmh * 1000 / 3600; + return (kmh * 1000) / 3600; } /** diff --git a/application/src/test/java/org/opentripplanner/osm/wayproperty/specifier/ConditionTest.java b/application/src/test/java/org/opentripplanner/osm/wayproperty/specifier/ConditionTest.java index e53b5686263..d1d27743484 100644 --- a/application/src/test/java/org/opentripplanner/osm/wayproperty/specifier/ConditionTest.java +++ b/application/src/test/java/org/opentripplanner/osm/wayproperty/specifier/ConditionTest.java @@ -114,9 +114,7 @@ void otherTests(OsmEntity way, Condition op, MatchResult expectation) { @Test void assertThrowsOnLowerLowerThanUpperLimit() { - Assertions.assertThrows( - IllegalArgumentException.class, - () -> new InclusiveRange("lanes", 4, 6) + Assertions.assertThrows(IllegalArgumentException.class, () -> new InclusiveRange("lanes", 4, 6) ); } } diff --git a/application/src/test/java/org/opentripplanner/raptorlegacy/_data/api/TestPathBuilder.java b/application/src/test/java/org/opentripplanner/raptorlegacy/_data/api/TestPathBuilder.java index 9259358f2d2..54a0719b1f9 100644 --- a/application/src/test/java/org/opentripplanner/raptorlegacy/_data/api/TestPathBuilder.java +++ b/application/src/test/java/org/opentripplanner/raptorlegacy/_data/api/TestPathBuilder.java @@ -107,8 +107,9 @@ public TestPathBuilder bus(String patternName, int fromTime, int duration, int t int toTime = fromTime + duration; int fromStop = currentStop(); - TestTripSchedule trip = TestTripSchedule - .schedule(TestTripPattern.pattern(patternName, fromStop, toStop)) + TestTripSchedule trip = TestTripSchedule.schedule( + TestTripPattern.pattern(patternName, fromStop, toStop) + ) .arrDepOffset(BOARD_ALIGHT_OFFSET) .departures(fromTime, toTime + BOARD_ALIGHT_OFFSET) .build(); @@ -138,13 +139,12 @@ int currentStop() { private void reset(int startTime) { this.startTime = startTime; - this.builder = - PathBuilder.tailPathBuilder( - slackProvider, - startTime, - costCalculator, - RaptorStopNameResolver.nullSafe(null), - null - ); + this.builder = PathBuilder.tailPathBuilder( + slackProvider, + startTime, + costCalculator, + RaptorStopNameResolver.nullSafe(null), + null + ); } } diff --git a/application/src/test/java/org/opentripplanner/raptorlegacy/_data/transit/TestConstrainedBoardingSearch.java b/application/src/test/java/org/opentripplanner/raptorlegacy/_data/transit/TestConstrainedBoardingSearch.java index 2766f760067..7b34eac6d34 100644 --- a/application/src/test/java/org/opentripplanner/raptorlegacy/_data/transit/TestConstrainedBoardingSearch.java +++ b/application/src/test/java/org/opentripplanner/raptorlegacy/_data/transit/TestConstrainedBoardingSearch.java @@ -24,7 +24,8 @@ public class TestConstrainedBoardingSearch implements RaptorConstrainedBoardingSearch { /** Index of guaranteed transfers by fromStopPos */ - private final TIntObjectMap> transfersByFromStopPos = new TIntObjectHashMap<>(); + private final TIntObjectMap> transfersByFromStopPos = + new TIntObjectHashMap<>(); private final BitSet transfersByToStopPosExist = new BitSet(); private final BiPredicate timeAfterOrEqual; private int currentTargetStopPos; @@ -82,8 +83,7 @@ public List constrainedBoardings() { @Override public String toString() { - return ToStringBuilder - .of(TestConstrainedBoardingSearch.class) + return ToStringBuilder.of(TestConstrainedBoardingSearch.class) .addNum("currentTargetStopPos", currentTargetStopPos) .addObj("index", transfersByFromStopPos) .toString(); diff --git a/application/src/test/java/org/opentripplanner/raptorlegacy/_data/transit/TestConstrainedTransfer.java b/application/src/test/java/org/opentripplanner/raptorlegacy/_data/transit/TestConstrainedTransfer.java index 034a029787d..6f600230783 100644 --- a/application/src/test/java/org/opentripplanner/raptorlegacy/_data/transit/TestConstrainedTransfer.java +++ b/application/src/test/java/org/opentripplanner/raptorlegacy/_data/transit/TestConstrainedTransfer.java @@ -65,8 +65,7 @@ public RaptorTransferConstraint getTransferConstraint() { @Override public String toString() { - return ToStringBuilder - .of(TestConstrainedTransfer.class) + return ToStringBuilder.of(TestConstrainedTransfer.class) .addObj("sourceTrip", sourceTrip) .addNum("sourceStopPos", sourceStopPos) .addObj("targetTrip", targetTrip) diff --git a/application/src/test/java/org/opentripplanner/raptorlegacy/_data/transit/TestRoute.java b/application/src/test/java/org/opentripplanner/raptorlegacy/_data/transit/TestRoute.java index 715021521ef..a747c56c5fe 100644 --- a/application/src/test/java/org/opentripplanner/raptorlegacy/_data/transit/TestRoute.java +++ b/application/src/test/java/org/opentripplanner/raptorlegacy/_data/transit/TestRoute.java @@ -22,12 +22,10 @@ public class TestRoute implements RaptorRoute, RaptorTimeTable private final TestTripPattern pattern; private final List schedules = new ArrayList<>(); - private final TestConstrainedBoardingSearch transferConstraintsForwardSearch = new TestConstrainedBoardingSearch( - true - ); - private final TestConstrainedBoardingSearch transferConstraintsReverseSearch = new TestConstrainedBoardingSearch( - false - ); + private final TestConstrainedBoardingSearch transferConstraintsForwardSearch = + new TestConstrainedBoardingSearch(true); + private final TestConstrainedBoardingSearch transferConstraintsReverseSearch = + new TestConstrainedBoardingSearch(false); private TestRoute(TestTripPattern pattern) { this.pattern = pattern; @@ -97,8 +95,7 @@ public TestRoute withTimetable(TestTripSchedule.Builder... scheduleBuilders) { @Override public String toString() { - return ToStringBuilder - .of(TestRoute.class) + return ToStringBuilder.of(TestRoute.class) .addObj("pattern", pattern) .addObj("schedules", schedules) .toString(); diff --git a/application/src/test/java/org/opentripplanner/raptorlegacy/_data/transit/TestTransferPoint.java b/application/src/test/java/org/opentripplanner/raptorlegacy/_data/transit/TestTransferPoint.java index 9bf8c1bc17a..8d6216a0b31 100644 --- a/application/src/test/java/org/opentripplanner/raptorlegacy/_data/transit/TestTransferPoint.java +++ b/application/src/test/java/org/opentripplanner/raptorlegacy/_data/transit/TestTransferPoint.java @@ -44,8 +44,7 @@ public boolean matches(TestTripSchedule schedule, int stop, int stopPosition) { @Override public String toString() { - return ToStringBuilder - .of() + return ToStringBuilder.of() .addNum("stop", stop) .addObj("trip", schedule.pattern().debugInfo()) .toString(); diff --git a/application/src/test/java/org/opentripplanner/raptorlegacy/_data/transit/TestTransitData.java b/application/src/test/java/org/opentripplanner/raptorlegacy/_data/transit/TestTransitData.java index fdce4559b24..1ad550c7f5e 100644 --- a/application/src/test/java/org/opentripplanner/raptorlegacy/_data/transit/TestTransitData.java +++ b/application/src/test/java/org/opentripplanner/raptorlegacy/_data/transit/TestTransitData.java @@ -41,16 +41,13 @@ public class TestTransitData implements RaptorTransitDataProvider, RaptorTestConstants { - public static final TransferConstraint TX_GUARANTEED = TransferConstraint - .of() + public static final TransferConstraint TX_GUARANTEED = TransferConstraint.of() .guaranteed() .build(); - public static final TransferConstraint TX_NOT_ALLOWED = TransferConstraint - .of() + public static final TransferConstraint TX_NOT_ALLOWED = TransferConstraint.of() .notAllowed() .build(); - public static final TransferConstraint TX_LONG_MIN_TIME = TransferConstraint - .of() + public static final TransferConstraint TX_LONG_MIN_TIME = TransferConstraint.of() .minTransferTime(3600) .build(); diff --git a/application/src/test/java/org/opentripplanner/raptorlegacy/_data/transit/TestTripPattern.java b/application/src/test/java/org/opentripplanner/raptorlegacy/_data/transit/TestTripPattern.java index b8367e0225d..ce0747b916c 100644 --- a/application/src/test/java/org/opentripplanner/raptorlegacy/_data/transit/TestTripPattern.java +++ b/application/src/test/java/org/opentripplanner/raptorlegacy/_data/transit/TestTripPattern.java @@ -148,8 +148,7 @@ public String debugInfo() { @Override public String toString() { - return ToStringBuilder - .of(TestTripPattern.class) + return ToStringBuilder.of(TestTripPattern.class) .addStr("name", name) .addInts("stops", stopIndexes) .addInts("restrictions", restrictions) diff --git a/application/src/test/java/org/opentripplanner/raptorlegacy/_data/transit/TestTripSchedule.java b/application/src/test/java/org/opentripplanner/raptorlegacy/_data/transit/TestTripSchedule.java index 1b0441b64f8..d4130941273 100644 --- a/application/src/test/java/org/opentripplanner/raptorlegacy/_data/transit/TestTripSchedule.java +++ b/application/src/test/java/org/opentripplanner/raptorlegacy/_data/transit/TestTripSchedule.java @@ -101,13 +101,11 @@ public Accessibility wheelchairBoarding() { @Override public String toString() { if (Arrays.equals(arrivalTimes, departureTimes)) { - return ToStringBuilder - .of(TestTripSchedule.class) + return ToStringBuilder.of(TestTripSchedule.class) .addServiceTimeSchedule("times", arrivalTimes) .toString(); } - return ToStringBuilder - .of(TestTripSchedule.class) + return ToStringBuilder.of(TestTripSchedule.class) .addServiceTimeSchedule("arrivals", arrivalTimes) .addServiceTimeSchedule("departures", departureTimes) .toString(); diff --git a/application/src/test/java/org/opentripplanner/routing/TestHalfEdges.java b/application/src/test/java/org/opentripplanner/routing/TestHalfEdges.java index dc473276c7b..001362b7e03 100644 --- a/application/src/test/java/org/opentripplanner/routing/TestHalfEdges.java +++ b/application/src/test/java/org/opentripplanner/routing/TestHalfEdges.java @@ -76,46 +76,42 @@ public void setUp() { bl = factory.intersection("bl", -74.01, 40.0); br = factory.intersection("br", -74.00, 40.0); - top = - new StreetEdgeBuilder<>() - .withFromVertex(tl) - .withToVertex(tr) - .withGeometry(GeometryUtils.makeLineString(-74.01, 40.01, -74.0, 40.01)) - .withName("top") - .withMeterLength(1500) - .withPermission(StreetTraversalPermission.ALL) - .withBack(false) - .buildAndConnect(); - bottom = - new StreetEdgeBuilder<>() - .withFromVertex(br) - .withToVertex(bl) - .withGeometry(GeometryUtils.makeLineString(-74.01, 40.0, -74.0, 40.0)) - .withName("bottom") - .withMeterLength(1500) - .withPermission(StreetTraversalPermission.ALL) - .withBack(false) - .buildAndConnect(); - left = - new StreetEdgeBuilder<>() - .withFromVertex(bl) - .withToVertex(tl) - .withGeometry(GeometryUtils.makeLineString(-74.01, 40.0, -74.01, 40.01)) - .withName("left") - .withMeterLength(1500) - .withPermission(StreetTraversalPermission.ALL) - .withBack(false) - .buildAndConnect(); - right = - new StreetEdgeBuilder<>() - .withFromVertex(br) - .withToVertex(tr) - .withGeometry(GeometryUtils.makeLineString(-74.0, 40.0, -74.0, 40.01)) - .withName("right") - .withMeterLength(1500) - .withPermission(StreetTraversalPermission.PEDESTRIAN) - .withBack(false) - .buildAndConnect(); + top = new StreetEdgeBuilder<>() + .withFromVertex(tl) + .withToVertex(tr) + .withGeometry(GeometryUtils.makeLineString(-74.01, 40.01, -74.0, 40.01)) + .withName("top") + .withMeterLength(1500) + .withPermission(StreetTraversalPermission.ALL) + .withBack(false) + .buildAndConnect(); + bottom = new StreetEdgeBuilder<>() + .withFromVertex(br) + .withToVertex(bl) + .withGeometry(GeometryUtils.makeLineString(-74.01, 40.0, -74.0, 40.0)) + .withName("bottom") + .withMeterLength(1500) + .withPermission(StreetTraversalPermission.ALL) + .withBack(false) + .buildAndConnect(); + left = new StreetEdgeBuilder<>() + .withFromVertex(bl) + .withToVertex(tl) + .withGeometry(GeometryUtils.makeLineString(-74.01, 40.0, -74.01, 40.01)) + .withName("left") + .withMeterLength(1500) + .withPermission(StreetTraversalPermission.ALL) + .withBack(false) + .buildAndConnect(); + right = new StreetEdgeBuilder<>() + .withFromVertex(br) + .withToVertex(tr) + .withGeometry(GeometryUtils.makeLineString(-74.0, 40.0, -74.0, 40.01)) + .withName("right") + .withMeterLength(1500) + .withPermission(StreetTraversalPermission.PEDESTRIAN) + .withBack(false) + .buildAndConnect(); @SuppressWarnings("unused") StreetEdge topBack = new StreetEdgeBuilder<>() @@ -137,26 +133,24 @@ public void setUp() { .withPermission(StreetTraversalPermission.ALL) .withBack(true) .buildAndConnect(); - leftBack = - new StreetEdgeBuilder<>() - .withFromVertex(tl) - .withToVertex(bl) - .withGeometry(left.getGeometry().reverse()) - .withName("leftBack") - .withMeterLength(1500) - .withPermission(StreetTraversalPermission.ALL) - .withBack(true) - .buildAndConnect(); - rightBack = - new StreetEdgeBuilder<>() - .withFromVertex(tr) - .withToVertex(br) - .withGeometry(right.getGeometry().reverse()) - .withName("rightBack") - .withMeterLength(1500) - .withPermission(StreetTraversalPermission.ALL) - .withBack(true) - .buildAndConnect(); + leftBack = new StreetEdgeBuilder<>() + .withFromVertex(tl) + .withToVertex(bl) + .withGeometry(left.getGeometry().reverse()) + .withName("leftBack") + .withMeterLength(1500) + .withPermission(StreetTraversalPermission.ALL) + .withBack(true) + .buildAndConnect(); + rightBack = new StreetEdgeBuilder<>() + .withFromVertex(tr) + .withToVertex(br) + .withGeometry(right.getGeometry().reverse()) + .withName("rightBack") + .withMeterLength(1500) + .withPermission(StreetTraversalPermission.ALL) + .withBack(true) + .buildAndConnect(); var s1 = testModel.stop("fleem station", 40.0099999, -74.005).build(); var s2 = testModel.stop("morx station", 40.0099999, -74.002).build(); @@ -221,13 +215,11 @@ public void testHalfEdges() { assertEquals(2, edges.size()); - long startTime = LocalDateTime - .of(2009, Month.DECEMBER, 1, 12, 34, 25) + long startTime = LocalDateTime.of(2009, Month.DECEMBER, 1, 12, 34, 25) .atZone(ZoneIds.NEW_YORK) .toEpochSecond(); options.setDateTime(Instant.ofEpochSecond(startTime)); - ShortestPathTree spt1 = StreetSearchBuilder - .of() + ShortestPathTree spt1 = StreetSearchBuilder.of() .setHeuristic(new EuclideanRemainingWeightHeuristic()) .setRequest(options) .setStreetRequest(options.journey().direct()) @@ -238,8 +230,7 @@ public void testHalfEdges() { GraphPath pathBr = spt1.getPath(end); assertNotNull(pathBr, "There must be a path from br to end"); - ShortestPathTree spt2 = StreetSearchBuilder - .of() + ShortestPathTree spt2 = StreetSearchBuilder.of() .setHeuristic(new EuclideanRemainingWeightHeuristic()) .setRequest(options) .setStreetRequest(options.journey().direct()) @@ -254,8 +245,7 @@ public void testHalfEdges() { "path from bottom to end must be longer than path from top to end" ); - ShortestPathTree spt = StreetSearchBuilder - .of() + ShortestPathTree spt = StreetSearchBuilder.of() .setHeuristic(new EuclideanRemainingWeightHeuristic()) .setRequest(options) .setStreetRequest(options.journey().direct()) @@ -273,15 +263,13 @@ public void testHalfEdges() { } options.setArriveBy(true); - spt = - StreetSearchBuilder - .of() - .setHeuristic(new EuclideanRemainingWeightHeuristic()) - .setRequest(options) - .setStreetRequest(options.journey().direct()) - .setFrom(start) - .setTo(end) - .getShortestPathTree(); + spt = StreetSearchBuilder.of() + .setHeuristic(new EuclideanRemainingWeightHeuristic()) + .setRequest(options) + .setStreetRequest(options.journey().direct()) + .setFrom(start) + .setTo(end) + .getShortestPathTree(); path = spt.getPath(start); assertNotNull(path, "There must be a path from start to end (looking back)"); @@ -304,34 +292,30 @@ public void testHalfEdges() { options = new RouteRequest(); options.journey().direct().setMode(StreetMode.BIKE); - start = - StreetIndex.createTemporaryStreetLocationForTest( - "start1", - new NonLocalizedString("start1"), - filter(turns, StreetEdge.class), - new LinearLocation(0, 0.95).getCoordinate(top.getGeometry()), - false, - tempEdges - ); - end = - StreetIndex.createTemporaryStreetLocationForTest( - "end1", - new NonLocalizedString("end1"), - filter(turns, StreetEdge.class), - new LinearLocation(0, 0.95).getCoordinate(bottom.getGeometry()), - true, - tempEdges - ); + start = StreetIndex.createTemporaryStreetLocationForTest( + "start1", + new NonLocalizedString("start1"), + filter(turns, StreetEdge.class), + new LinearLocation(0, 0.95).getCoordinate(top.getGeometry()), + false, + tempEdges + ); + end = StreetIndex.createTemporaryStreetLocationForTest( + "end1", + new NonLocalizedString("end1"), + filter(turns, StreetEdge.class), + new LinearLocation(0, 0.95).getCoordinate(bottom.getGeometry()), + true, + tempEdges + ); - spt = - StreetSearchBuilder - .of() - .setHeuristic(new EuclideanRemainingWeightHeuristic()) - .setRequest(options) - .setStreetRequest(options.journey().direct()) - .setFrom(start) - .setTo(end) - .getShortestPathTree(); + spt = StreetSearchBuilder.of() + .setHeuristic(new EuclideanRemainingWeightHeuristic()) + .setRequest(options) + .setStreetRequest(options.journey().direct()) + .setFrom(start) + .setTo(end) + .getShortestPathTree(); path = spt.getPath(start); assertNotNull(path, "There must be a path from top to bottom along the right"); @@ -347,33 +331,29 @@ public void testHalfEdges() { assertEquals(nVertices, graph.getVertices().size()); assertEquals(nEdges, graph.getEdges().size()); - start = - StreetIndex.createTemporaryStreetLocationForTest( - "start2", - new NonLocalizedString("start2"), - filter(turns, StreetEdge.class), - new LinearLocation(0, 0.55).getCoordinate(top.getGeometry()), - false, - tempEdges - ); - end = - StreetIndex.createTemporaryStreetLocationForTest( - "end2", - new NonLocalizedString("end2"), - filter(turns, StreetEdge.class), - new LinearLocation(0, 0.55).getCoordinate(bottom.getGeometry()), - true, - tempEdges - ); + start = StreetIndex.createTemporaryStreetLocationForTest( + "start2", + new NonLocalizedString("start2"), + filter(turns, StreetEdge.class), + new LinearLocation(0, 0.55).getCoordinate(top.getGeometry()), + false, + tempEdges + ); + end = StreetIndex.createTemporaryStreetLocationForTest( + "end2", + new NonLocalizedString("end2"), + filter(turns, StreetEdge.class), + new LinearLocation(0, 0.55).getCoordinate(bottom.getGeometry()), + true, + tempEdges + ); - spt = - StreetSearchBuilder - .of() - .setHeuristic(new EuclideanRemainingWeightHeuristic()) - .setRequest(options) - .setFrom(start) - .setTo(end) - .getShortestPathTree(); + spt = StreetSearchBuilder.of() + .setHeuristic(new EuclideanRemainingWeightHeuristic()) + .setRequest(options) + .setFrom(start) + .setTo(end) + .getShortestPathTree(); path = spt.getPath(start); assertNotNull(path, "There must be a path from top to bottom"); @@ -426,13 +406,11 @@ public void testRouteToSameEdge() { assertEquals(3, edges.size()); - long startTime = LocalDateTime - .of(2009, Month.DECEMBER, 1, 12, 34, 25) + long startTime = LocalDateTime.of(2009, Month.DECEMBER, 1, 12, 34, 25) .atZone(ZoneIds.NEW_YORK) .toEpochSecond(); options.setDateTime(Instant.ofEpochSecond(startTime)); - ShortestPathTree spt = StreetSearchBuilder - .of() + ShortestPathTree spt = StreetSearchBuilder.of() .setHeuristic(new EuclideanRemainingWeightHeuristic()) .setRequest(options) .setStreetRequest(options.journey().direct()) @@ -482,13 +460,11 @@ public void testRouteToSameEdgeBackwards() { Collection edges = end.getIncoming(); assertEquals(1, edges.size()); - long startTime = LocalDateTime - .of(2009, Month.DECEMBER, 1, 12, 34, 25) + long startTime = LocalDateTime.of(2009, Month.DECEMBER, 1, 12, 34, 25) .atZone(ZoneIds.NEW_YORK) .toEpochSecond(); options.setDateTime(Instant.ofEpochSecond(startTime)); - ShortestPathTree spt = StreetSearchBuilder - .of() + ShortestPathTree spt = StreetSearchBuilder.of() .setHeuristic(new EuclideanRemainingWeightHeuristic()) .setRequest(options) .setStreetRequest(options.journey().direct()) @@ -567,15 +543,14 @@ public void testStreetSplittingAlerts() { req.withWheelchair(true); - start = - StreetIndex.createTemporaryStreetLocationForTest( - "start", - new NonLocalizedString("start"), - filter(turns, StreetEdge.class), - new LinearLocation(0, 0.4).getCoordinate(left.getGeometry()), - false, - tempEdges - ); + start = StreetIndex.createTemporaryStreetLocationForTest( + "start", + new NonLocalizedString("start"), + filter(turns, StreetEdge.class), + new LinearLocation(0, 0.4).getCoordinate(left.getGeometry()), + false, + tempEdges + ); traversedOne = new State(start, req.build()); for (Edge e : start.getOutgoing()) { @@ -603,21 +578,23 @@ public void testStreetLocationFinder() { assertTrue(graphFinder.findClosestStops(new Coordinate(-74.005000001, 40.01), 100).size() > 0); // test that the closest vertex finder returns the closest vertex - TemporaryStreetLocation some = (TemporaryStreetLocation) finder.createVertexForCoordinateForTest( - new Coordinate(-74.00, 40.00), - StreetMode.WALK, - true, - tempEdges - ); + TemporaryStreetLocation some = + (TemporaryStreetLocation) finder.createVertexForCoordinateForTest( + new Coordinate(-74.00, 40.00), + StreetMode.WALK, + true, + tempEdges + ); assertNotNull(some); // test that the closest vertex finder correctly splits streets - TemporaryStreetLocation start = (TemporaryStreetLocation) finder.createVertexForCoordinateForTest( - new Coordinate(-74.01, 40.004), - StreetMode.WALK, - false, - tempEdges - ); + TemporaryStreetLocation start = + (TemporaryStreetLocation) finder.createVertexForCoordinateForTest( + new Coordinate(-74.01, 40.004), + StreetMode.WALK, + false, + tempEdges + ); assertNotNull(start); assertTrue( start.isWheelchairAccessible(), @@ -658,8 +635,7 @@ public void testTemporaryVerticesContainer() { ) { assertNotNull(container.getFromVertices()); assertNotNull(container.getToVertices()); - ShortestPathTree spt = StreetSearchBuilder - .of() + ShortestPathTree spt = StreetSearchBuilder.of() .setHeuristic(new EuclideanRemainingWeightHeuristic()) .setRequest(walking) .setVerticesContainer(container) diff --git a/application/src/test/java/org/opentripplanner/routing/algorithm/FilterTest.java b/application/src/test/java/org/opentripplanner/routing/algorithm/FilterTest.java index 958bf97d41a..901d3fea8be 100644 --- a/application/src/test/java/org/opentripplanner/routing/algorithm/FilterTest.java +++ b/application/src/test/java/org/opentripplanner/routing/algorithm/FilterTest.java @@ -27,18 +27,15 @@ public class FilterTest { static final String AGENCY_ID_2 = "RUT:Agency:2"; static final String AGENCY_ID_3 = "RUT:Agency:3"; - static final Agency AGENCY_1 = TimetableRepositoryForTest - .agency("A") + static final Agency AGENCY_1 = TimetableRepositoryForTest.agency("A") .copy() .withId(id(AGENCY_ID_1)) .build(); - static final Agency AGENCY_2 = TimetableRepositoryForTest - .agency("B") + static final Agency AGENCY_2 = TimetableRepositoryForTest.agency("B") .copy() .withId(id(AGENCY_ID_2)) .build(); - static final Agency AGENCY_3 = TimetableRepositoryForTest - .agency("C") + static final Agency AGENCY_3 = TimetableRepositoryForTest.agency("C") .copy() .withId(id(AGENCY_ID_3)) .build(); @@ -61,24 +58,24 @@ public class FilterTest { final String GROUP_OF_Routes_ID_1 = "RUT:GroupOfLines:1"; final String GROUP_OF_Routes_ID_2 = "RUT:GroupOfLines:2"; - final GroupOfRoutes GROUP_OF_ROUTES_1 = TimetableRepositoryForTest - .groupOfRoutes(GROUP_OF_Routes_ID_1) - .build(); - final GroupOfRoutes GROUP_OF_ROUTES_2 = TimetableRepositoryForTest - .groupOfRoutes(GROUP_OF_Routes_ID_2) - .build(); + final GroupOfRoutes GROUP_OF_ROUTES_1 = TimetableRepositoryForTest.groupOfRoutes( + GROUP_OF_Routes_ID_1 + ).build(); + final GroupOfRoutes GROUP_OF_ROUTES_2 = TimetableRepositoryForTest.groupOfRoutes( + GROUP_OF_Routes_ID_2 + ).build(); @Test @DisplayName( """ Filter test 1 - + filters: [ { select: [ {A} ] } ] - + -> A """ ) @@ -88,22 +85,18 @@ public void testOne() { Route route3 = TimetableRepositoryForTest.route(ROUTE_ID_3).withAgency(AGENCY_3).build(); var patterns = List.of( - TimetableRepositoryForTest - .tripPattern(JOURNEY_PATTERN_ID_1, route1) + TimetableRepositoryForTest.tripPattern(JOURNEY_PATTERN_ID_1, route1) .withStopPattern(STOP_PATTERN) .build(), - TimetableRepositoryForTest - .tripPattern(JOURNEY_PATTERN_ID_2, route2) + TimetableRepositoryForTest.tripPattern(JOURNEY_PATTERN_ID_2, route2) .withStopPattern(STOP_PATTERN) .build(), - TimetableRepositoryForTest - .tripPattern(JOURNEY_PATTERN_ID_3, route3) + TimetableRepositoryForTest.tripPattern(JOURNEY_PATTERN_ID_3, route3) .withStopPattern(STOP_PATTERN) .build() ); - var filterRequest = TransitFilterRequest - .of() + var filterRequest = TransitFilterRequest.of() .addSelect(SelectRequest.of().withRoutes(List.of(id(ROUTE_ID_1))).build()) .build(); @@ -118,13 +111,13 @@ public void testOne() { @DisplayName( """ Filter test 2 - + filters: [ { not: [ {A} ] } ] - + -> S - A """ ) @@ -134,22 +127,18 @@ public void testTwo() { Route route3 = TimetableRepositoryForTest.route(ROUTE_ID_3).withAgency(AGENCY_3).build(); var patterns = List.of( - TimetableRepositoryForTest - .tripPattern(JOURNEY_PATTERN_ID_1, route1) + TimetableRepositoryForTest.tripPattern(JOURNEY_PATTERN_ID_1, route1) .withStopPattern(STOP_PATTERN) .build(), - TimetableRepositoryForTest - .tripPattern(JOURNEY_PATTERN_ID_2, route2) + TimetableRepositoryForTest.tripPattern(JOURNEY_PATTERN_ID_2, route2) .withStopPattern(STOP_PATTERN) .build(), - TimetableRepositoryForTest - .tripPattern(JOURNEY_PATTERN_ID_3, route3) + TimetableRepositoryForTest.tripPattern(JOURNEY_PATTERN_ID_3, route3) .withStopPattern(STOP_PATTERN) .build() ); - var filterRequest = TransitFilterRequest - .of() + var filterRequest = TransitFilterRequest.of() .addNot(SelectRequest.of().withAgencies(List.of(id(AGENCY_ID_1))).build()) .build(); @@ -163,61 +152,52 @@ public void testTwo() { @DisplayName( """ Filter test 3 - + filters: [ { select: [ {A}, {B} ] } ] - + -> A ∪ B """ ) public void testThree() { - Route route1 = TimetableRepositoryForTest - .route(ROUTE_ID_1) + Route route1 = TimetableRepositoryForTest.route(ROUTE_ID_1) .withAgency(AGENCY_1) .withMode(TransitMode.BUS) .withNetexSubmode("schoolBus") .build(); - Route route2 = TimetableRepositoryForTest - .route(ROUTE_ID_2) + Route route2 = TimetableRepositoryForTest.route(ROUTE_ID_2) .withAgency(AGENCY_2) .withMode(TransitMode.RAIL) .withNetexSubmode("railShuttle") .build(); - Route route3 = TimetableRepositoryForTest - .route(ROUTE_ID_3) + Route route3 = TimetableRepositoryForTest.route(ROUTE_ID_3) .withAgency(AGENCY_3) .withMode(TransitMode.TRAM) .build(); var patterns = List.of( - TimetableRepositoryForTest - .tripPattern(JOURNEY_PATTERN_ID_1, route1) + TimetableRepositoryForTest.tripPattern(JOURNEY_PATTERN_ID_1, route1) .withStopPattern(STOP_PATTERN) .build(), - TimetableRepositoryForTest - .tripPattern(JOURNEY_PATTERN_ID_2, route2) + TimetableRepositoryForTest.tripPattern(JOURNEY_PATTERN_ID_2, route2) .withStopPattern(STOP_PATTERN) .build(), - TimetableRepositoryForTest - .tripPattern(JOURNEY_PATTERN_ID_3, route3) + TimetableRepositoryForTest.tripPattern(JOURNEY_PATTERN_ID_3, route3) .withStopPattern(STOP_PATTERN) .build() ); - var filterRequest = TransitFilterRequest - .of() + var filterRequest = TransitFilterRequest.of() .addSelect( - SelectRequest - .of() + SelectRequest.of() .withTransportModes(List.of(new MainAndSubMode(TransitMode.BUS, SubMode.of("schoolBus")))) .build() ) .addSelect( - SelectRequest - .of() + SelectRequest.of() .withTransportModes( List.of(new MainAndSubMode(TransitMode.RAIL, SubMode.of("railShuttle"))) ) @@ -235,7 +215,7 @@ public void testThree() { @DisplayName( """ Filter test 4 - + filters: [ { select: [ {A} ] @@ -244,7 +224,7 @@ public void testThree() { select: [ {B} ] } ] - + -> A ∪ B """ ) @@ -254,27 +234,22 @@ public void testFour() { Route route3 = TimetableRepositoryForTest.route(ROUTE_ID_3).build(); var patterns = List.of( - TimetableRepositoryForTest - .tripPattern(JOURNEY_PATTERN_ID_1, route1) + TimetableRepositoryForTest.tripPattern(JOURNEY_PATTERN_ID_1, route1) .withStopPattern(STOP_PATTERN) .build(), - TimetableRepositoryForTest - .tripPattern(JOURNEY_PATTERN_ID_2, route2) + TimetableRepositoryForTest.tripPattern(JOURNEY_PATTERN_ID_2, route2) .withStopPattern(STOP_PATTERN) .build(), - TimetableRepositoryForTest - .tripPattern(JOURNEY_PATTERN_ID_3, route3) + TimetableRepositoryForTest.tripPattern(JOURNEY_PATTERN_ID_3, route3) .withStopPattern(STOP_PATTERN) .build() ); - var filter1 = TransitFilterRequest - .of() + var filter1 = TransitFilterRequest.of() .addSelect(SelectRequest.of().withRoutes(List.of(id(ROUTE_ID_1))).build()) .build(); - var filter2 = TransitFilterRequest - .of() + var filter2 = TransitFilterRequest.of() .addSelect(SelectRequest.of().withRoutes(List.of(id(ROUTE_ID_2))).build()) .build(); @@ -288,7 +263,7 @@ public void testFour() { @DisplayName( """ Filter test 5 - + filters: [ { select: [ {A} ] @@ -297,7 +272,7 @@ public void testFour() { not: [ {B} ] } ] - + -> A ∪ (S - B) """ ) @@ -306,23 +281,19 @@ public void testFive() { Route route2 = TimetableRepositoryForTest.route(ROUTE_ID_2).build(); var patterns = List.of( - TimetableRepositoryForTest - .tripPattern(JOURNEY_PATTERN_ID_1, route1) + TimetableRepositoryForTest.tripPattern(JOURNEY_PATTERN_ID_1, route1) .withStopPattern(STOP_PATTERN) .build(), - TimetableRepositoryForTest - .tripPattern(JOURNEY_PATTERN_ID_2, route2) + TimetableRepositoryForTest.tripPattern(JOURNEY_PATTERN_ID_2, route2) .withStopPattern(STOP_PATTERN) .build() ); - var filter1 = TransitFilterRequest - .of() + var filter1 = TransitFilterRequest.of() .addSelect(SelectRequest.of().withRoutes(List.of(id(ROUTE_ID_1))).build()) .build(); - var filter2 = TransitFilterRequest - .of() + var filter2 = TransitFilterRequest.of() .addNot(SelectRequest.of().withRoutes(List.of(id(ROUTE_ID_1))).build()) .build(); @@ -335,14 +306,14 @@ public void testFive() { @DisplayName( """ Filter test 6 - + filters: [ { select: [ {A} ] not: [ {B} ] } ] - + -> A - B """ ) @@ -352,22 +323,18 @@ public void testSix() { Route route3 = TimetableRepositoryForTest.route(ROUTE_ID_3).withAgency(AGENCY_1).build(); var patterns = List.of( - TimetableRepositoryForTest - .tripPattern(JOURNEY_PATTERN_ID_1, route1) + TimetableRepositoryForTest.tripPattern(JOURNEY_PATTERN_ID_1, route1) .withStopPattern(STOP_PATTERN) .build(), - TimetableRepositoryForTest - .tripPattern(JOURNEY_PATTERN_ID_2, route2) + TimetableRepositoryForTest.tripPattern(JOURNEY_PATTERN_ID_2, route2) .withStopPattern(STOP_PATTERN) .build(), - TimetableRepositoryForTest - .tripPattern(JOURNEY_PATTERN_ID_3, route3) + TimetableRepositoryForTest.tripPattern(JOURNEY_PATTERN_ID_3, route3) .withStopPattern(STOP_PATTERN) .build() ); - var filterRequest = TransitFilterRequest - .of() + var filterRequest = TransitFilterRequest.of() .addSelect(SelectRequest.of().withAgencies(List.of(id(AGENCY_ID_1))).build()) .addNot(SelectRequest.of().withRoutes(List.of(id(ROUTE_ID_3))).build()) .build(); @@ -382,7 +349,7 @@ public void testSix() { @DisplayName( """ Filter test 7 - + filters: [ { select: [ {A} ] @@ -392,7 +359,7 @@ public void testSix() { not: [ {C} ] } ] - + -> A ∪ (B - C) """ ) @@ -402,27 +369,22 @@ public void testSeven() { Route route3 = TimetableRepositoryForTest.route(ROUTE_ID_3).withAgency(AGENCY_2).build(); var patterns = List.of( - TimetableRepositoryForTest - .tripPattern(JOURNEY_PATTERN_ID_1, route1) + TimetableRepositoryForTest.tripPattern(JOURNEY_PATTERN_ID_1, route1) .withStopPattern(STOP_PATTERN) .build(), - TimetableRepositoryForTest - .tripPattern(JOURNEY_PATTERN_ID_2, route2) + TimetableRepositoryForTest.tripPattern(JOURNEY_PATTERN_ID_2, route2) .withStopPattern(STOP_PATTERN) .build(), - TimetableRepositoryForTest - .tripPattern(JOURNEY_PATTERN_ID_3, route3) + TimetableRepositoryForTest.tripPattern(JOURNEY_PATTERN_ID_3, route3) .withStopPattern(STOP_PATTERN) .build() ); - var filter1 = TransitFilterRequest - .of() + var filter1 = TransitFilterRequest.of() .addSelect(SelectRequest.of().withAgencies(List.of(id(AGENCY_ID_1))).build()) .build(); - var filter2 = TransitFilterRequest - .of() + var filter2 = TransitFilterRequest.of() .addSelect(SelectRequest.of().withAgencies(List.of(id(AGENCY_ID_2))).build()) .addNot(SelectRequest.of().withRoutes(List.of(id(ROUTE_ID_3))).build()) .build(); @@ -437,53 +399,45 @@ public void testSeven() { @DisplayName( """ Filter test 8 - + filters: [ { select: [ {A,B} ] } ] - + -> A ∩ B """ ) public void testEight() { - final Route route1 = TimetableRepositoryForTest - .route(ROUTE_ID_1) + final Route route1 = TimetableRepositoryForTest.route(ROUTE_ID_1) .withMode(TransitMode.BUS) .withAgency(AGENCY_1) .build(); - final Route route2 = TimetableRepositoryForTest - .route(ROUTE_ID_2) + final Route route2 = TimetableRepositoryForTest.route(ROUTE_ID_2) .withMode(TransitMode.RAIL) .withAgency(AGENCY_1) .build(); - final Route route3 = TimetableRepositoryForTest - .route(ROUTE_ID_3) + final Route route3 = TimetableRepositoryForTest.route(ROUTE_ID_3) .withMode(TransitMode.BUS) .withAgency(AGENCY_2) .build(); var patterns = List.of( - TimetableRepositoryForTest - .tripPattern(JOURNEY_PATTERN_ID_1, route1) + TimetableRepositoryForTest.tripPattern(JOURNEY_PATTERN_ID_1, route1) .withStopPattern(STOP_PATTERN) .build(), - TimetableRepositoryForTest - .tripPattern(JOURNEY_PATTERN_ID_2, route2) + TimetableRepositoryForTest.tripPattern(JOURNEY_PATTERN_ID_2, route2) .withStopPattern(STOP_PATTERN) .build(), - TimetableRepositoryForTest - .tripPattern(JOURNEY_PATTERN_ID_3, route3) + TimetableRepositoryForTest.tripPattern(JOURNEY_PATTERN_ID_3, route3) .withStopPattern(STOP_PATTERN) .build() ); - var filter = TransitFilterRequest - .of() + var filter = TransitFilterRequest.of() .addSelect( - SelectRequest - .of() + SelectRequest.of() .withAgencies(List.of(id(AGENCY_ID_1))) .withTransportModes(List.of(new MainAndSubMode(TransitMode.BUS))) .build() @@ -501,63 +455,53 @@ public void testEight() { @DisplayName( """ Filter test 9 - + filters: [ { select: [ {A,B} ] not: [ {C} ] } ] - + -> (A ∩ B) - C """ ) public void testNine() { - Route route1 = TimetableRepositoryForTest - .route(ROUTE_ID_1) + Route route1 = TimetableRepositoryForTest.route(ROUTE_ID_1) .withAgency(AGENCY_1) .withMode(TransitMode.BUS) .build(); - Route route2 = TimetableRepositoryForTest - .route(ROUTE_ID_2) + Route route2 = TimetableRepositoryForTest.route(ROUTE_ID_2) .withAgency(AGENCY_1) .withMode(TransitMode.RAIL) .build(); - Route route3 = TimetableRepositoryForTest - .route(ROUTE_ID_3) + Route route3 = TimetableRepositoryForTest.route(ROUTE_ID_3) .withAgency(AGENCY_1) .withMode(TransitMode.BUS) .build(); - Route route4 = TimetableRepositoryForTest - .route(ROUTE_ID_4) + Route route4 = TimetableRepositoryForTest.route(ROUTE_ID_4) .withAgency(AGENCY_2) .withMode(TransitMode.BUS) .build(); var patterns = List.of( - TimetableRepositoryForTest - .tripPattern(JOURNEY_PATTERN_ID_1, route1) + TimetableRepositoryForTest.tripPattern(JOURNEY_PATTERN_ID_1, route1) .withStopPattern(STOP_PATTERN) .build(), - TimetableRepositoryForTest - .tripPattern(JOURNEY_PATTERN_ID_2, route2) + TimetableRepositoryForTest.tripPattern(JOURNEY_PATTERN_ID_2, route2) .withStopPattern(STOP_PATTERN) .build(), - TimetableRepositoryForTest - .tripPattern(JOURNEY_PATTERN_ID_3, route3) + TimetableRepositoryForTest.tripPattern(JOURNEY_PATTERN_ID_3, route3) .withStopPattern(STOP_PATTERN) .build(), - TimetableRepositoryForTest - .tripPattern(JOURNEY_PATTERN_ID_4, route4) + TimetableRepositoryForTest.tripPattern(JOURNEY_PATTERN_ID_4, route4) .withStopPattern(STOP_PATTERN) .build() ); - var filter = TransitFilterRequest - .of() + var filter = TransitFilterRequest.of() .addSelect( - SelectRequest - .of() + SelectRequest.of() .withAgencies(List.of(id(AGENCY_ID_1))) .withTransportModes(List.of(new MainAndSubMode(TransitMode.BUS))) .build() @@ -577,60 +521,51 @@ public void testNine() { @DisplayName( """ Filter test 10 - + filters: [ { select: [ {A} ] not: [ {B, C} ] } ] - + -> A - (B ∩ C) """ ) public void testTen() { - final Route route1 = TimetableRepositoryForTest - .route(ROUTE_ID_1) + final Route route1 = TimetableRepositoryForTest.route(ROUTE_ID_1) .withMode(TransitMode.BUS) .withAgency(AGENCY_1) .build(); - final Route route2 = TimetableRepositoryForTest - .route(ROUTE_ID_2) + final Route route2 = TimetableRepositoryForTest.route(ROUTE_ID_2) .withMode(TransitMode.RAIL) .withAgency(AGENCY_1) .build(); - final Route route3 = TimetableRepositoryForTest - .route(ROUTE_ID_3) + final Route route3 = TimetableRepositoryForTest.route(ROUTE_ID_3) .withMode(TransitMode.BUS) .withAgency(AGENCY_1) .build(); final Route route4 = TimetableRepositoryForTest.route(ROUTE_ID_4).withAgency(AGENCY_2).build(); var patterns = List.of( - TimetableRepositoryForTest - .tripPattern(JOURNEY_PATTERN_ID_1, route1) + TimetableRepositoryForTest.tripPattern(JOURNEY_PATTERN_ID_1, route1) .withStopPattern(STOP_PATTERN) .build(), - TimetableRepositoryForTest - .tripPattern(JOURNEY_PATTERN_ID_2, route2) + TimetableRepositoryForTest.tripPattern(JOURNEY_PATTERN_ID_2, route2) .withStopPattern(STOP_PATTERN) .build(), - TimetableRepositoryForTest - .tripPattern(JOURNEY_PATTERN_ID_3, route3) + TimetableRepositoryForTest.tripPattern(JOURNEY_PATTERN_ID_3, route3) .withStopPattern(STOP_PATTERN) .build(), - TimetableRepositoryForTest - .tripPattern(JOURNEY_PATTERN_ID_4, route4) + TimetableRepositoryForTest.tripPattern(JOURNEY_PATTERN_ID_4, route4) .withStopPattern(STOP_PATTERN) .build() ); - var filter = TransitFilterRequest - .of() + var filter = TransitFilterRequest.of() .addSelect(SelectRequest.of().withAgencies(List.of(id(AGENCY_ID_1))).build()) .addNot( - SelectRequest - .of() + SelectRequest.of() .withTransportModes(List.of(new MainAndSubMode(TransitMode.BUS))) .withRoutes(List.of(id(ROUTE_ID_3))) .build() @@ -646,30 +581,25 @@ public void testTen() { @Test void testDifferentSubModesInRoute() { - final Route route1 = TimetableRepositoryForTest - .route(ROUTE_ID_1) + final Route route1 = TimetableRepositoryForTest.route(ROUTE_ID_1) .withMode(TransitMode.BUS) .withAgency(AGENCY_1) .build(); var patterns = List.of( - TimetableRepositoryForTest - .tripPattern(JOURNEY_PATTERN_ID_1, route1) + TimetableRepositoryForTest.tripPattern(JOURNEY_PATTERN_ID_1, route1) .withStopPattern(STOP_PATTERN) .withNetexSubmode(LOCAL_BUS) .build(), - TimetableRepositoryForTest - .tripPattern(JOURNEY_PATTERN_ID_2, route1) + TimetableRepositoryForTest.tripPattern(JOURNEY_PATTERN_ID_2, route1) .withStopPattern(STOP_PATTERN) .withNetexSubmode(NIGHT_BUS) .build() ); - var filter = TransitFilterRequest - .of() + var filter = TransitFilterRequest.of() .addNot( - SelectRequest - .of() + SelectRequest.of() .withTransportModes(List.of(new MainAndSubMode(TransitMode.BUS, NIGHT_BUS))) .build() ) @@ -696,31 +626,25 @@ private static Collection bannedPatterns( @Test public void testGroupOfLinesSelectFunctionality() { - var route1 = TimetableRepositoryForTest - .route(ROUTE_ID_1) + var route1 = TimetableRepositoryForTest.route(ROUTE_ID_1) .withGroupOfRoutes(List.of(GROUP_OF_ROUTES_1)) .build(); - var route2 = TimetableRepositoryForTest - .route(ROUTE_ID_2) + var route2 = TimetableRepositoryForTest.route(ROUTE_ID_2) .withGroupOfRoutes(List.of(GROUP_OF_ROUTES_2)) .build(); var patterns = List.of( - TimetableRepositoryForTest - .tripPattern(JOURNEY_PATTERN_ID_1, route1) + TimetableRepositoryForTest.tripPattern(JOURNEY_PATTERN_ID_1, route1) .withStopPattern(STOP_PATTERN) .build(), - TimetableRepositoryForTest - .tripPattern(JOURNEY_PATTERN_ID_2, route2) + TimetableRepositoryForTest.tripPattern(JOURNEY_PATTERN_ID_2, route2) .withStopPattern(STOP_PATTERN) .build() ); - var filter = TransitFilterRequest - .of() + var filter = TransitFilterRequest.of() .addSelect( - SelectRequest - .of() + SelectRequest.of() .withGroupOfRoutes(List.of(FeedScopedId.parse("F:" + GROUP_OF_Routes_ID_1))) .build() ) @@ -734,31 +658,25 @@ public void testGroupOfLinesSelectFunctionality() { @Test public void testGroupOfLinesExcludeFunctionality() { - var route1 = TimetableRepositoryForTest - .route(ROUTE_ID_1) + var route1 = TimetableRepositoryForTest.route(ROUTE_ID_1) .withGroupOfRoutes(List.of(GROUP_OF_ROUTES_1)) .build(); - var route2 = TimetableRepositoryForTest - .route(ROUTE_ID_2) + var route2 = TimetableRepositoryForTest.route(ROUTE_ID_2) .withGroupOfRoutes(List.of(GROUP_OF_ROUTES_2)) .build(); var patterns = List.of( - TimetableRepositoryForTest - .tripPattern(JOURNEY_PATTERN_ID_1, route1) + TimetableRepositoryForTest.tripPattern(JOURNEY_PATTERN_ID_1, route1) .withStopPattern(STOP_PATTERN) .build(), - TimetableRepositoryForTest - .tripPattern(JOURNEY_PATTERN_ID_2, route2) + TimetableRepositoryForTest.tripPattern(JOURNEY_PATTERN_ID_2, route2) .withStopPattern(STOP_PATTERN) .build() ); - var filter = TransitFilterRequest - .of() + var filter = TransitFilterRequest.of() .addNot( - SelectRequest - .of() + SelectRequest.of() .withGroupOfRoutes(List.of(FeedScopedId.parse("F:" + GROUP_OF_Routes_ID_1))) .build() ) diff --git a/application/src/test/java/org/opentripplanner/routing/algorithm/GraphRoutingTest.java b/application/src/test/java/org/opentripplanner/routing/algorithm/GraphRoutingTest.java index 26ab1215eab..1255b8f5726 100644 --- a/application/src/test/java/org/opentripplanner/routing/algorithm/GraphRoutingTest.java +++ b/application/src/test/java/org/opentripplanner/routing/algorithm/GraphRoutingTest.java @@ -228,8 +228,7 @@ public List elevator(StreetTraversalPermission permission, Vertex. // -- Transit network (pathways, linking) public Entrance entranceEntity(String id, double latitude, double longitude) { - return Entrance - .of(TimetableRepositoryForTest.id(id)) + return Entrance.of(TimetableRepositoryForTest.id(id)) .withName(new NonLocalizedString(id)) .withCode(id) .withCoordinate(latitude, longitude) @@ -445,8 +444,7 @@ public VehicleParking vehicleParking( List entrances, String... tags ) { - var vehicleParking = VehicleParking - .builder() + var vehicleParking = VehicleParking.builder() .id(TimetableRepositoryForTest.id(id)) .coordinate(new WgsCoordinate(y, x)) .bicyclePlaces(bicyclePlaces) diff --git a/application/src/test/java/org/opentripplanner/routing/algorithm/StreetModeLinkingTest.java b/application/src/test/java/org/opentripplanner/routing/algorithm/StreetModeLinkingTest.java index 1ee0ec9c481..5fa850052ee 100644 --- a/application/src/test/java/org/opentripplanner/routing/algorithm/StreetModeLinkingTest.java +++ b/application/src/test/java/org/opentripplanner/routing/algorithm/StreetModeLinkingTest.java @@ -95,9 +95,9 @@ public void testCarLinking() { @Test public void testCarParkLinking() { var setup = (BiFunction>) ( - Double latitude, - Double longitude - ) -> + Double latitude, + Double longitude + ) -> (RouteRequest rr) -> { rr.setFrom(new GenericLocation(latitude, longitude)); rr.setTo(new GenericLocation(latitude, longitude)); diff --git a/application/src/test/java/org/opentripplanner/routing/algorithm/TestBanning.java b/application/src/test/java/org/opentripplanner/routing/algorithm/TestBanning.java index 07d9074c350..74e491eec3f 100644 --- a/application/src/test/java/org/opentripplanner/routing/algorithm/TestBanning.java +++ b/application/src/test/java/org/opentripplanner/routing/algorithm/TestBanning.java @@ -26,8 +26,7 @@ public class TestBanning { public void testSetBannedOnRequest() { Collection patterns = getTestPatterns(); - var filterRequest = TransitFilterRequest - .of() + var filterRequest = TransitFilterRequest.of() .addNot(SelectRequest.of().withRoutes(List.of(id("RUT:Route:1"))).build()) .addNot(SelectRequest.of().withAgencies(List.of(id("RUT:Agency:2"))).build()) .build(); @@ -43,8 +42,7 @@ public void testSetBannedOnRequest() { public void testSetWhiteListedOnRequest() { Collection patterns = getTestPatterns(); - var filterRequest = TransitFilterRequest - .of() + var filterRequest = TransitFilterRequest.of() .addSelect(SelectRequest.of().withRoutes(List.of(id("RUT:Route:1"))).build()) .addSelect(SelectRequest.of().withAgencies(List.of(id("RUT:Agency:2"))).build()) .build(); @@ -56,13 +54,11 @@ public void testSetWhiteListedOnRequest() { } private List getTestPatterns() { - Agency agency1 = TimetableRepositoryForTest - .agency("A") + Agency agency1 = TimetableRepositoryForTest.agency("A") .copy() .withId(id("RUT:Agency:1")) .build(); - Agency agency2 = TimetableRepositoryForTest - .agency("B") + Agency agency2 = TimetableRepositoryForTest.agency("B") .copy() .withId(id("RUT:Agency:2")) .build(); @@ -73,16 +69,13 @@ private List getTestPatterns() { final StopPattern stopPattern = TimetableRepositoryForTest.of().stopPattern(2); return List.of( - TimetableRepositoryForTest - .tripPattern("RUT:JourneyPattern:1", route1) + TimetableRepositoryForTest.tripPattern("RUT:JourneyPattern:1", route1) .withStopPattern(stopPattern) .build(), - TimetableRepositoryForTest - .tripPattern("RUT:JourneyPattern:2", route2) + TimetableRepositoryForTest.tripPattern("RUT:JourneyPattern:2", route2) .withStopPattern(stopPattern) .build(), - TimetableRepositoryForTest - .tripPattern("RUT:JourneyPattern:3", route3) + TimetableRepositoryForTest.tripPattern("RUT:JourneyPattern:3", route3) .withStopPattern(stopPattern) .build() ); diff --git a/application/src/test/java/org/opentripplanner/routing/algorithm/TurnCostTest.java b/application/src/test/java/org/opentripplanner/routing/algorithm/TurnCostTest.java index e93c8b5b615..1c657a73cbd 100644 --- a/application/src/test/java/org/opentripplanner/routing/algorithm/TurnCostTest.java +++ b/application/src/test/java/org/opentripplanner/routing/algorithm/TurnCostTest.java @@ -201,8 +201,7 @@ private GraphPath checkForwardRouteDuration( Vertex to, int expectedDuration ) { - ShortestPathTree tree = StreetSearchBuilder - .of() + ShortestPathTree tree = StreetSearchBuilder.of() .setHeuristic(new EuclideanRemainingWeightHeuristic()) .setRequest(request) .setStreetRequest(new StreetRequest(streetMode)) diff --git a/application/src/test/java/org/opentripplanner/routing/algorithm/filterchain/ItineraryListFilterChainTest.java b/application/src/test/java/org/opentripplanner/routing/algorithm/filterchain/ItineraryListFilterChainTest.java index 4ccb7ac9793..cf259cb5fdd 100644 --- a/application/src/test/java/org/opentripplanner/routing/algorithm/filterchain/ItineraryListFilterChainTest.java +++ b/application/src/test/java/org/opentripplanner/routing/algorithm/filterchain/ItineraryListFilterChainTest.java @@ -228,12 +228,14 @@ void transitAlertsTest() { chain.filter(List.of(i1, i2, i3)); // Then transitAlertService should have been called with stop and route ids - Mockito - .verify(transitAlertService, Mockito.atLeastOnce()) - .getStopAlerts(A.stop.getId(), StopCondition.FIRST_DEPARTURE); - Mockito - .verify(transitAlertService, Mockito.atLeastOnce()) - .getStopAlerts(E.stop.getId(), StopCondition.ARRIVING); + Mockito.verify(transitAlertService, Mockito.atLeastOnce()).getStopAlerts( + A.stop.getId(), + StopCondition.FIRST_DEPARTURE + ); + Mockito.verify(transitAlertService, Mockito.atLeastOnce()).getStopAlerts( + E.stop.getId(), + StopCondition.ARRIVING + ); Mockito.verify(transitAlertService, Mockito.atLeastOnce()).getRouteAlerts(BUS_ROUTE.getId()); } diff --git a/application/src/test/java/org/opentripplanner/routing/algorithm/filterchain/filters/street/RemoveParkAndRideWithMostlyWalkingTest.java b/application/src/test/java/org/opentripplanner/routing/algorithm/filterchain/filters/street/RemoveParkAndRideWithMostlyWalkingTest.java index 88baabb1e2a..1366e34788e 100644 --- a/application/src/test/java/org/opentripplanner/routing/algorithm/filterchain/filters/street/RemoveParkAndRideWithMostlyWalkingTest.java +++ b/application/src/test/java/org/opentripplanner/routing/algorithm/filterchain/filters/street/RemoveParkAndRideWithMostlyWalkingTest.java @@ -20,9 +20,8 @@ public class RemoveParkAndRideWithMostlyWalkingTest { private static final int T10_10 = TimeUtils.hm2time(10, 10); private static final int T10_20 = TimeUtils.hm2time(10, 20); - private final RemoveParkAndRideWithMostlyWalkingFilter subject = new RemoveParkAndRideWithMostlyWalkingFilter( - 0.5 - ); + private final RemoveParkAndRideWithMostlyWalkingFilter subject = + new RemoveParkAndRideWithMostlyWalkingFilter(0.5); @Test public void name() { diff --git a/application/src/test/java/org/opentripplanner/routing/algorithm/filterchain/filters/system/FlexSearchWindowFilterTest.java b/application/src/test/java/org/opentripplanner/routing/algorithm/filterchain/filters/system/FlexSearchWindowFilterTest.java index dd51ccbcd19..0a0d7d161de 100644 --- a/application/src/test/java/org/opentripplanner/routing/algorithm/filterchain/filters/system/FlexSearchWindowFilterTest.java +++ b/application/src/test/java/org/opentripplanner/routing/algorithm/filterchain/filters/system/FlexSearchWindowFilterTest.java @@ -16,9 +16,9 @@ class FlexSearchWindowFilterTest implements PlanTestConstants { - private static final Instant LATEST_DEPARTURE_TIME = TestItineraryBuilder - .newTime(time("09:20")) - .toInstant(); + private static final Instant LATEST_DEPARTURE_TIME = TestItineraryBuilder.newTime( + time("09:20") + ).toInstant(); @ParameterizedTest @ValueSource(strings = { "09:20", "09:21", "13:20" }) diff --git a/application/src/test/java/org/opentripplanner/routing/algorithm/filterchain/filters/system/OutsideSearchWindowFilterTest.java b/application/src/test/java/org/opentripplanner/routing/algorithm/filterchain/filters/system/OutsideSearchWindowFilterTest.java index 0e61d146d17..1c80f56beb6 100644 --- a/application/src/test/java/org/opentripplanner/routing/algorithm/filterchain/filters/system/OutsideSearchWindowFilterTest.java +++ b/application/src/test/java/org/opentripplanner/routing/algorithm/filterchain/filters/system/OutsideSearchWindowFilterTest.java @@ -61,17 +61,14 @@ public void testTaggedBy() { private static Stream onStreetTestCases() { int t9_28 = time("9:28"); int t9_38 = time("9:38"); - return Stream - .of( - newItinerary(A, t9_28).walk(D2m, B), - newItinerary(A, t9_38).walk(D12m, B), - newItinerary(A, t9_28).bicycle(t9_28, t9_38, B), - newItinerary(A, t9_28).flex(t9_28, t9_38, B), - newItinerary(A, t9_28).flex(t9_38, time("9:48"), B), - newItinerary(A, time("9:20")).flex(time("9:20"), t9_28, B).walk(D12m, C) - ) - // results from the street & flex routers are not aware of the search window - .map(b -> b.withIsSearchWindowAware(false).build()); + return Stream.of( + newItinerary(A, t9_28).walk(D2m, B), + newItinerary(A, t9_38).walk(D12m, B), + newItinerary(A, t9_28).bicycle(t9_28, t9_38, B), + newItinerary(A, t9_28).flex(t9_28, t9_38, B), + newItinerary(A, t9_28).flex(t9_38, time("9:48"), B), + newItinerary(A, time("9:20")).flex(time("9:20"), t9_28, B).walk(D12m, C) + ).map(b -> b.withIsSearchWindowAware(false).build()); // results from the street & flex routers are not aware of the search window } @ParameterizedTest diff --git a/application/src/test/java/org/opentripplanner/routing/algorithm/filterchain/filters/system/SingleCriteriaComparatorTest.java b/application/src/test/java/org/opentripplanner/routing/algorithm/filterchain/filters/system/SingleCriteriaComparatorTest.java index da55d884d5c..1b0bf0709e5 100644 --- a/application/src/test/java/org/opentripplanner/routing/algorithm/filterchain/filters/system/SingleCriteriaComparatorTest.java +++ b/application/src/test/java/org/opentripplanner/routing/algorithm/filterchain/filters/system/SingleCriteriaComparatorTest.java @@ -15,7 +15,8 @@ class SingleCriteriaComparatorTest { private static final TimetableRepositoryForTest TEST_MODEL = TimetableRepositoryForTest.of(); - private static final DefaultTransitGroupPriorityCalculator GROUP_PRIORITY_CALCULATOR = new DefaultTransitGroupPriorityCalculator(); + private static final DefaultTransitGroupPriorityCalculator GROUP_PRIORITY_CALCULATOR = + new DefaultTransitGroupPriorityCalculator(); private static final Place A = TEST_MODEL.place("A", 10, 11); private static final Place B = TEST_MODEL.place("B", 10, 13); diff --git a/application/src/test/java/org/opentripplanner/routing/algorithm/filterchain/filters/system/mcmax/McMaxLimitFilterTest.java b/application/src/test/java/org/opentripplanner/routing/algorithm/filterchain/filters/system/mcmax/McMaxLimitFilterTest.java index 3a192853684..a5fdd0d2c17 100644 --- a/application/src/test/java/org/opentripplanner/routing/algorithm/filterchain/filters/system/mcmax/McMaxLimitFilterTest.java +++ b/application/src/test/java/org/opentripplanner/routing/algorithm/filterchain/filters/system/mcmax/McMaxLimitFilterTest.java @@ -17,7 +17,8 @@ class McMaxLimitFilterTest { private static final TimetableRepositoryForTest TEST_MODEL = TimetableRepositoryForTest.of(); - private static final DefaultTransitGroupPriorityCalculator GROUP_PRIORITY_CALCULATOR = new DefaultTransitGroupPriorityCalculator(); + private static final DefaultTransitGroupPriorityCalculator GROUP_PRIORITY_CALCULATOR = + new DefaultTransitGroupPriorityCalculator(); private static final Place A = TEST_MODEL.place("A", 10, 11); private static final Place B = TEST_MODEL.place("B", 10, 13); diff --git a/application/src/test/java/org/opentripplanner/routing/algorithm/filterchain/filters/transit/RemoveItinerariesWithShortStreetLegTest.java b/application/src/test/java/org/opentripplanner/routing/algorithm/filterchain/filters/transit/RemoveItinerariesWithShortStreetLegTest.java index 92a11485055..ed119f44c8e 100644 --- a/application/src/test/java/org/opentripplanner/routing/algorithm/filterchain/filters/transit/RemoveItinerariesWithShortStreetLegTest.java +++ b/application/src/test/java/org/opentripplanner/routing/algorithm/filterchain/filters/transit/RemoveItinerariesWithShortStreetLegTest.java @@ -11,10 +11,8 @@ class RemoveItinerariesWithShortStreetLegTest implements PlanTestConstants { - private final RemoveItinerariesWithShortStreetLeg subject = new RemoveItinerariesWithShortStreetLeg( - 500, - BICYCLE - ); + private final RemoveItinerariesWithShortStreetLeg subject = + new RemoveItinerariesWithShortStreetLeg(500, BICYCLE); @Test void noBikeDoesNothing() { diff --git a/application/src/test/java/org/opentripplanner/routing/algorithm/filterchain/filters/transit/RemoveTransitIfStreetOnlyIsBetterTest.java b/application/src/test/java/org/opentripplanner/routing/algorithm/filterchain/filters/transit/RemoveTransitIfStreetOnlyIsBetterTest.java index 4da3e83b460..070890526bf 100644 --- a/application/src/test/java/org/opentripplanner/routing/algorithm/filterchain/filters/transit/RemoveTransitIfStreetOnlyIsBetterTest.java +++ b/application/src/test/java/org/opentripplanner/routing/algorithm/filterchain/filters/transit/RemoveTransitIfStreetOnlyIsBetterTest.java @@ -64,9 +64,8 @@ void filterAwayLongTravelTimeWithoutWaitTime() { @Nested class AccessEgressPenalties { - private static final RemoveTransitIfStreetOnlyIsBetter FLAGGER = new RemoveTransitIfStreetOnlyIsBetter( - CostLinearFunction.of(Duration.ZERO, 1.0) - ); + private static final RemoveTransitIfStreetOnlyIsBetter FLAGGER = + new RemoveTransitIfStreetOnlyIsBetter(CostLinearFunction.of(Duration.ZERO, 1.0)); @Test void keepBusWithLowCostAndPenalty() { diff --git a/application/src/test/java/org/opentripplanner/routing/algorithm/filterchain/framework/filterchain/DeleteResultHandlerTest.java b/application/src/test/java/org/opentripplanner/routing/algorithm/filterchain/framework/filterchain/DeleteResultHandlerTest.java index b7d91f734d2..230178ab1e4 100644 --- a/application/src/test/java/org/opentripplanner/routing/algorithm/filterchain/framework/filterchain/DeleteResultHandlerTest.java +++ b/application/src/test/java/org/opentripplanner/routing/algorithm/filterchain/framework/filterchain/DeleteResultHandlerTest.java @@ -82,8 +82,9 @@ public static List filterLimitToSearchWindowTestCases() { @ParameterizedTest @MethodSource("filterLimitToSearchWindowTestCases") void filterLimitToSearchWindow(TestCase tc) { - var result = new DeleteResultHandler(LIMIT_TO_SEARCH_WINDOW, tc.numItineraries) - .filter(tc.input()); + var result = new DeleteResultHandler(LIMIT_TO_SEARCH_WINDOW, tc.numItineraries).filter( + tc.input() + ); assertEquals(Itinerary.toStr(tc.expected), Itinerary.toStr(result)); } @@ -104,8 +105,9 @@ public static List filterLimitToNumOfItinerariesTestCases() { @ParameterizedTest @MethodSource("filterLimitToNumOfItinerariesTestCases") void filterLimitToNumOfItineraries(TestCase tc) { - var result = new DeleteResultHandler(LIMIT_TO_NUM_OF_ITINERARIES, tc.numItineraries) - .filter(tc.input()); + var result = new DeleteResultHandler(LIMIT_TO_NUM_OF_ITINERARIES, tc.numItineraries).filter( + tc.input() + ); assertEquals(Itinerary.toStr(tc.expected), Itinerary.toStr(result)); } diff --git a/application/src/test/java/org/opentripplanner/routing/algorithm/filterchain/framework/groupids/GroupByDistanceTest.java b/application/src/test/java/org/opentripplanner/routing/algorithm/filterchain/framework/groupids/GroupByDistanceTest.java index cc17305af6d..4271418814d 100644 --- a/application/src/test/java/org/opentripplanner/routing/algorithm/filterchain/framework/groupids/GroupByDistanceTest.java +++ b/application/src/test/java/org/opentripplanner/routing/algorithm/filterchain/framework/groupids/GroupByDistanceTest.java @@ -204,17 +204,15 @@ public void notMatchFrequencyTripsWithDifferentStartTime() { @Test public void illegalRangeForPUpperBound() { - assertThrows( - IllegalArgumentException.class, - () -> new GroupByDistance(newItinerary(A).bus(21, T11_01, T11_02, E).build(), 0.991) + assertThrows(IllegalArgumentException.class, () -> + new GroupByDistance(newItinerary(A).bus(21, T11_01, T11_02, E).build(), 0.991) ); } @Test public void illegalRangeForPLowerBound() { - assertThrows( - IllegalArgumentException.class, - () -> new GroupByDistance(newItinerary(A).bus(21, T11_01, T11_02, E).build(), 0.499) + assertThrows(IllegalArgumentException.class, () -> + new GroupByDistance(newItinerary(A).bus(21, T11_01, T11_02, E).build(), 0.499) ); } diff --git a/application/src/test/java/org/opentripplanner/routing/algorithm/filterchain/framework/sort/SortOnGeneralizedCostTest.java b/application/src/test/java/org/opentripplanner/routing/algorithm/filterchain/framework/sort/SortOnGeneralizedCostTest.java index c0e53de3381..fbbcb88364d 100644 --- a/application/src/test/java/org/opentripplanner/routing/algorithm/filterchain/framework/sort/SortOnGeneralizedCostTest.java +++ b/application/src/test/java/org/opentripplanner/routing/algorithm/filterchain/framework/sort/SortOnGeneralizedCostTest.java @@ -29,8 +29,9 @@ public void sortOnCost() { rail.setGeneralizedCost(600 + 1); // When: sorting - result = - Stream.of(walk, bus, rail).sorted(generalizedCostComparator()).collect(Collectors.toList()); + result = Stream.of(walk, bus, rail) + .sorted(generalizedCostComparator()) + .collect(Collectors.toList()); // Then: expect rail(1/3 of walk time), bus(2/3 of walk time) and walk assertEquals(toStr(List.of(walk, rail, bus)), toStr(result)); @@ -55,8 +56,9 @@ public void sortOnCostAndNumOfTransfers() { bus2.setGeneralizedCost(300); // When: sorting - result = - Stream.of(bus2, walk, bus1).sorted(generalizedCostComparator()).collect(Collectors.toList()); + result = Stream.of(bus2, walk, bus1) + .sorted(generalizedCostComparator()) + .collect(Collectors.toList()); // Then: expect bus to be better than walking assertEquals(toStr(List.of(walk, bus1, bus2)), toStr(result)); diff --git a/application/src/test/java/org/opentripplanner/routing/algorithm/filterchain/framework/sort/SortOnNumberOfTransfersTest.java b/application/src/test/java/org/opentripplanner/routing/algorithm/filterchain/framework/sort/SortOnNumberOfTransfersTest.java index 40b7550b1a0..380bcd7e0c9 100644 --- a/application/src/test/java/org/opentripplanner/routing/algorithm/filterchain/framework/sort/SortOnNumberOfTransfersTest.java +++ b/application/src/test/java/org/opentripplanner/routing/algorithm/filterchain/framework/sort/SortOnNumberOfTransfersTest.java @@ -29,11 +29,9 @@ public void sortOnNumberOfTransfers() { .build(); // When: sorting - result = - Stream - .of(twoTransfers, oneTransfer, zeroTransfers) - .sorted(numberOfTransfersComparator()) - .collect(Collectors.toList()); + result = Stream.of(twoTransfers, oneTransfer, zeroTransfers) + .sorted(numberOfTransfersComparator()) + .collect(Collectors.toList()); // Then: expect the results to be in order according to number of transfers assertEquals(toStr(List.of(zeroTransfers, oneTransfer, twoTransfers)), toStr(result)); diff --git a/application/src/test/java/org/opentripplanner/routing/algorithm/filterchain/framework/sort/SortOrderComparatorTest.java b/application/src/test/java/org/opentripplanner/routing/algorithm/filterchain/framework/sort/SortOrderComparatorTest.java index c96ddede578..59d88ac6e33 100644 --- a/application/src/test/java/org/opentripplanner/routing/algorithm/filterchain/framework/sort/SortOrderComparatorTest.java +++ b/application/src/test/java/org/opentripplanner/routing/algorithm/filterchain/framework/sort/SortOrderComparatorTest.java @@ -31,20 +31,16 @@ public void sortStreetBeforeTransitThenTime() { rail.setGeneralizedCost(0); // Depart-after-sort - result = - Stream - .of(walk, bicycle, bus, rail) - .sorted(defaultComparatorDepartAfter()) - .collect(Collectors.toList()); + result = Stream.of(walk, bicycle, bus, rail) + .sorted(defaultComparatorDepartAfter()) + .collect(Collectors.toList()); assertEquals(toStr(walk, bicycle, bus, rail), toStr(result)); // Arrive-by-sort - result = - Stream - .of(walk, bicycle, bus, rail) - .sorted(defaultComparatorArriveBy()) - .collect(Collectors.toList()); + result = Stream.of(walk, bicycle, bus, rail) + .sorted(defaultComparatorArriveBy()) + .collect(Collectors.toList()); assertEquals(toStr(bicycle, walk, rail, bus), toStr(result)); } @@ -63,14 +59,16 @@ public void sortOnTime() { iD.setGeneralizedCost(0); // Depart-after-sort - result = - Stream.of(iD, iB, iA, iC).sorted(defaultComparatorDepartAfter()).collect(Collectors.toList()); + result = Stream.of(iD, iB, iA, iC) + .sorted(defaultComparatorDepartAfter()) + .collect(Collectors.toList()); assertEquals(toStr(iA, iB, iC, iD), toStr(result)); // Arrive-by-sort - result = - Stream.of(iB, iD, iC, iA).sorted(defaultComparatorArriveBy()).collect(Collectors.toList()); + result = Stream.of(iB, iD, iC, iA) + .sorted(defaultComparatorArriveBy()) + .collect(Collectors.toList()); assertEquals(toStr(iA, iC, iB, iD), toStr(result)); } @@ -89,8 +87,9 @@ public void sortOnGeneralizedCostVsTime() { iC.setGeneralizedCost(100); // Verify depart-after sort on arrival-time, then cost - result = - Stream.of(iB, iA, iC).sorted(defaultComparatorDepartAfter()).collect(Collectors.toList()); + result = Stream.of(iB, iA, iC) + .sorted(defaultComparatorDepartAfter()) + .collect(Collectors.toList()); assertEquals(toStr(iB, iA, iC), toStr(result)); @@ -115,8 +114,9 @@ public void sortOnGeneralizedCostVsNumberOfTransfers() { iC.setGeneralizedCost(100); // Verify depart-after sort on generalized-cost, then transfers - result = - Stream.of(iB, iA, iC).sorted(defaultComparatorDepartAfter()).collect(Collectors.toList()); + result = Stream.of(iB, iA, iC) + .sorted(defaultComparatorDepartAfter()) + .collect(Collectors.toList()); assertEquals(toStr(iA, iB, iC), toStr(result)); @@ -140,8 +140,9 @@ public void sortOnTransfersVsTime() { iC.setGeneralizedCost(100); // Verify depart-after sort on arrival-time, then cost - result = - Stream.of(iB, iA, iC).sorted(defaultComparatorDepartAfter()).collect(Collectors.toList()); + result = Stream.of(iB, iA, iC) + .sorted(defaultComparatorDepartAfter()) + .collect(Collectors.toList()); assertEquals(toStr(iB, iA, iC), toStr(result)); diff --git a/application/src/test/java/org/opentripplanner/routing/algorithm/mapping/BikeRentalSnapshotTest.java b/application/src/test/java/org/opentripplanner/routing/algorithm/mapping/BikeRentalSnapshotTest.java index 988c6c5abf4..65e9740835f 100644 --- a/application/src/test/java/org/opentripplanner/routing/algorithm/mapping/BikeRentalSnapshotTest.java +++ b/application/src/test/java/org/opentripplanner/routing/algorithm/mapping/BikeRentalSnapshotTest.java @@ -120,8 +120,7 @@ public void accessBikeRental() { request .journey() .setModes( - RequestModes - .of() + RequestModes.of() .withAccessMode(StreetMode.BIKE_RENTAL) .withEgressMode(StreetMode.WALK) .withDirectMode(StreetMode.NOT_SET) @@ -147,8 +146,7 @@ public void egressBikeRental() { request .journey() .setModes( - RequestModes - .of() + RequestModes.of() .withAccessMode(StreetMode.WALK) .withEgressMode(StreetMode.BIKE_RENTAL) .withTransferMode(StreetMode.WALK) diff --git a/application/src/test/java/org/opentripplanner/routing/algorithm/mapping/GraphPathToItineraryMapperTest.java b/application/src/test/java/org/opentripplanner/routing/algorithm/mapping/GraphPathToItineraryMapperTest.java index 2d5c1b1770b..abdc82fac19 100644 --- a/application/src/test/java/org/opentripplanner/routing/algorithm/mapping/GraphPathToItineraryMapperTest.java +++ b/application/src/test/java/org/opentripplanner/routing/algorithm/mapping/GraphPathToItineraryMapperTest.java @@ -15,19 +15,17 @@ class GraphPathToItineraryMapperTest { private static Stream cases() { - return Stream - .of( - TestStateBuilder.ofWalking(), - TestStateBuilder.ofCycling(), - TestStateBuilder.ofDriving(), - TestStateBuilder.ofScooterRental().pickUpFreeFloatingScooter(), - TestStateBuilder.ofBikeAndRide(), - TestStateBuilder.parkAndRide() - ) - .map(b -> { - var state = b.streetEdge().streetEdge().build(); - return Arguments.argumentSet(state.currentMode().toString(), state); - }); + return Stream.of( + TestStateBuilder.ofWalking(), + TestStateBuilder.ofCycling(), + TestStateBuilder.ofDriving(), + TestStateBuilder.ofScooterRental().pickUpFreeFloatingScooter(), + TestStateBuilder.ofBikeAndRide(), + TestStateBuilder.parkAndRide() + ).map(b -> { + var state = b.streetEdge().streetEdge().build(); + return Arguments.argumentSet(state.currentMode().toString(), state); + }); } @ParameterizedTest diff --git a/application/src/test/java/org/opentripplanner/routing/algorithm/mapping/RaptorPathToItineraryMapperTest.java b/application/src/test/java/org/opentripplanner/routing/algorithm/mapping/RaptorPathToItineraryMapperTest.java index 28867ffc375..a09006e0868 100644 --- a/application/src/test/java/org/opentripplanner/routing/algorithm/mapping/RaptorPathToItineraryMapperTest.java +++ b/application/src/test/java/org/opentripplanner/routing/algorithm/mapping/RaptorPathToItineraryMapperTest.java @@ -83,13 +83,14 @@ public class RaptorPathToItineraryMapperTest { private static final int TRANSIT_END = TimeUtils.time("11:00"); private static final Route ROUTE = TimetableRepositoryForTest.route("route").build(); - public static final RaptorCostCalculator COST_CALCULATOR = new DefaultCostCalculator<>( - BOARD_COST_SEC, - TRANSFER_COST_SEC, - WAIT_RELUCTANCE, - TRANSIT_RELUCTANCE, - STOP_COSTS - ); + public static final RaptorCostCalculator COST_CALCULATOR = + new DefaultCostCalculator<>( + BOARD_COST_SEC, + TRANSFER_COST_SEC, + WAIT_RELUCTANCE, + TRANSIT_RELUCTANCE, + STOP_COSTS + ); private static final RegularStop S1 = TEST_MODEL.stop("STOP1").build(); private static final RegularStop S2 = TEST_MODEL.stop("STOP2").build(); @@ -101,8 +102,9 @@ void createItineraryTestZeroDurationEgress(int lastLegCost) { // Arrange RaptorPathToItineraryMapper mapper = getRaptorPathToItineraryMapper(); - RaptorPath path = createTestTripSchedulePath(getTestTripSchedule()) - .egress(TestAccessEgress.free(2, RaptorCostConverter.toRaptorCost(lastLegCost))); + RaptorPath path = createTestTripSchedulePath(getTestTripSchedule()).egress( + TestAccessEgress.free(2, RaptorCostConverter.toRaptorCost(lastLegCost)) + ); int transitLegCost = path.accessLeg().nextLeg().c1(); int egressLegCost = path.accessLeg().nextLeg().nextLeg().c1(); @@ -257,8 +259,9 @@ private TestTripSchedule transferAtSameStopSchedule() { void isSearchWindowAware() { var mapper = getRaptorPathToItineraryMapper(); - var path = createTestTripSchedulePath(getTestTripSchedule()) - .egress(TestAccessEgress.free(2, RaptorCostConverter.toRaptorCost(100))); + var path = createTestTripSchedulePath(getTestTripSchedule()).egress( + TestAccessEgress.free(2, RaptorCostConverter.toRaptorCost(100)) + ); var itinerary = mapper.createItinerary(path); assertTrue(itinerary.isSearchWindowAware()); } @@ -279,8 +282,7 @@ private TripPattern getOriginalPattern(TestTripPattern pattern) { stopTimes.add(stopTime); } - var builder = TripPattern - .of(new FeedScopedId("TestFeed", "TestId")) + var builder = TripPattern.of(new FeedScopedId("TestFeed", "TestId")) .withRoute(pattern.route()) .withStopPattern(new StopPattern(stopTimes)); return builder.build(); @@ -292,8 +294,7 @@ private TestPathBuilder createTestTripSchedulePath(TestTripSchedule testTripSche } private RaptorPathToItineraryMapper getRaptorPathToItineraryMapper() { - Instant dateTime = LocalDateTime - .of(2022, Month.OCTOBER, 10, 12, 0, 0) + Instant dateTime = LocalDateTime.of(2022, Month.OCTOBER, 10, 12, 0, 0) .atZone(ZoneIds.STOCKHOLM) .toInstant(); TimetableRepository timetableRepository = new TimetableRepository(); @@ -312,8 +313,7 @@ private static RaptorTransitData getRaptorTransitData() { new HashMap<>(), null, null, - TEST_MODEL - .siteRepositoryBuilder() + TEST_MODEL.siteRepositoryBuilder() .withRegularStop(S1) .withRegularStop(S2) .withRegularStop(S3) diff --git a/application/src/test/java/org/opentripplanner/routing/algorithm/mapping/SnapshotTestBase.java b/application/src/test/java/org/opentripplanner/routing/algorithm/mapping/SnapshotTestBase.java index cab308c092b..91644b4cff8 100644 --- a/application/src/test/java/org/opentripplanner/routing/algorithm/mapping/SnapshotTestBase.java +++ b/application/src/test/java/org/opentripplanner/routing/algorithm/mapping/SnapshotTestBase.java @@ -85,8 +85,10 @@ public static void loadGraphBeforeClass(boolean withElevation) { protected OtpServerRequestContext serverContext() { if (serverContext == null) { TestOtpModel model = getGraph(); - serverContext = - TestServerContext.createServerContext(model.graph(), model.timetableRepository()); + serverContext = TestServerContext.createServerContext( + model.graph(), + model.timetableRepository() + ); } return serverContext; @@ -108,8 +110,7 @@ protected RouteRequest createTestRequest( RouteRequest request = serverContext.defaultRouteRequest(); request.setDateTime( - LocalDateTime - .of(year, month, day, hour, minute, second) + LocalDateTime.of(year, month, day, hour, minute, second) .atZone(ZoneId.of(serverContext.transitService().getTimeZone().getId())) .toInstant() ); @@ -183,9 +184,8 @@ protected void expectArriveByToMatchDepartAtAndSnapshot(RouteRequest request) { logDebugInformationOnFailure(request, () -> assertFalse(departByItineraries.isEmpty())); - logDebugInformationOnFailure( - departAt, - () -> expectItinerariesToMatchSnapshot(departByItineraries) + logDebugInformationOnFailure(departAt, () -> + expectItinerariesToMatchSnapshot(departByItineraries) ); RouteRequest arriveBy = request.clone(); @@ -197,13 +197,11 @@ protected void expectArriveByToMatchDepartAtAndSnapshot(RouteRequest request) { var departAtItinerary = departByItineraries.get(0); var arriveByItinerary = arriveByItineraries.get(0); - logDebugInformationOnFailure( - arriveBy, - () -> - assertEquals( - asJsonString(itineraryMapper.mapItinerary(departAtItinerary)), - asJsonString(itineraryMapper.mapItinerary(arriveByItinerary)) - ) + logDebugInformationOnFailure(arriveBy, () -> + assertEquals( + asJsonString(itineraryMapper.mapItinerary(departAtItinerary)), + asJsonString(itineraryMapper.mapItinerary(arriveByItinerary)) + ) ); } @@ -271,8 +269,7 @@ private List retrieveItineraries(RouteRequest request) { } private String createDebugUrlForRequest(RouteRequest request) { - var dateTime = Instant - .ofEpochSecond(request.dateTime().getEpochSecond()) + var dateTime = Instant.ofEpochSecond(request.dateTime().getEpochSecond()) .atZone(serverContext().transitService().getTimeZone()) .toLocalDateTime(); @@ -288,18 +285,16 @@ private String createDebugUrlForRequest(RouteRequest request) { var transitModes = mapModes(transportModes); - var modes = Stream - .concat( - Stream - .of( - asQualifiedMode(request.journey().direct().mode(), false), - asQualifiedMode(request.journey().access().mode(), false), - asQualifiedMode(request.journey().egress().mode(), true) - ) - .filter(Objects::nonNull) - .map(QualifiedMode::toString), - transitModes.stream().map(ApiRequestMode::name) + var modes = Stream.concat( + Stream.of( + asQualifiedMode(request.journey().direct().mode(), false), + asQualifiedMode(request.journey().access().mode(), false), + asQualifiedMode(request.journey().egress().mode(), true) ) + .filter(Objects::nonNull) + .map(QualifiedMode::toString), + transitModes.stream().map(ApiRequestMode::name) + ) .distinct() .collect(Collectors.joining(",")); @@ -377,21 +372,20 @@ private SnapshotItinerarySerializer() { objectMapper.addMixIn(ApiLeg.class, ApiLegMixin.class); - pp = - new DefaultPrettyPrinter("") { - @Override - public DefaultPrettyPrinter withSeparators(Separators separators) { - this._separators = separators; - this._objectFieldValueSeparatorWithSpaces = - separators.getObjectFieldValueSeparator() + " "; - return this; - } - - @Override - public DefaultPrettyPrinter createInstance() { - return this; - } - }; + pp = new DefaultPrettyPrinter("") { + @Override + public DefaultPrettyPrinter withSeparators(Separators separators) { + this._separators = separators; + this._objectFieldValueSeparatorWithSpaces = + separators.getObjectFieldValueSeparator() + " "; + return this; + } + + @Override + public DefaultPrettyPrinter createInstance() { + return this; + } + }; DefaultPrettyPrinter.Indenter lfOnlyIndenter = new DefaultIndenter(" ", "\n"); pp.indentArraysWith(lfOnlyIndenter); diff --git a/application/src/test/java/org/opentripplanner/routing/algorithm/mapping/StatesToWalkStepsMapperTest.java b/application/src/test/java/org/opentripplanner/routing/algorithm/mapping/StatesToWalkStepsMapperTest.java index a2bb428a78c..42e031f7d20 100644 --- a/application/src/test/java/org/opentripplanner/routing/algorithm/mapping/StatesToWalkStepsMapperTest.java +++ b/application/src/test/java/org/opentripplanner/routing/algorithm/mapping/StatesToWalkStepsMapperTest.java @@ -36,8 +36,7 @@ void elevator() { @Test void enterStation() { - final TestStateBuilder builder = TestStateBuilder - .ofWalking() + final TestStateBuilder builder = TestStateBuilder.ofWalking() .streetEdge() .enterStation("Lichterfelde-Ost"); var walkSteps = buildWalkSteps(builder); @@ -49,8 +48,7 @@ void enterStation() { @Test void exitStation() { - final TestStateBuilder builder = TestStateBuilder - .ofWalking() + final TestStateBuilder builder = TestStateBuilder.ofWalking() .streetEdge() .exitStation("Lichterfelde-Ost"); var walkSteps = buildWalkSteps(builder); diff --git a/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/router/FilterTransitWhenDirectModeIsEmptyTest.java b/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/router/FilterTransitWhenDirectModeIsEmptyTest.java index 5206f6f2bd8..44f6536d087 100644 --- a/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/router/FilterTransitWhenDirectModeIsEmptyTest.java +++ b/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/router/FilterTransitWhenDirectModeIsEmptyTest.java @@ -13,8 +13,7 @@ public class FilterTransitWhenDirectModeIsEmptyTest { @Test public void directModeIsExistAndIsNotWalking() { - var modes = RequestModes - .of() + var modes = RequestModes.of() .withAccessMode(null) .withEgressMode(null) .withDirectMode(StreetMode.BIKE) @@ -41,8 +40,7 @@ public void directModeIsExistAndIsWalking() { @Test public void directModeIsEmpty() { - var modes = RequestModes - .of() + var modes = RequestModes.of() .withAccessMode(null) .withEgressMode(null) .withDirectMode(null) diff --git a/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/router/street/AccessEgressRouterTest.java b/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/router/street/AccessEgressRouterTest.java index 9cd2b6b913e..2665944285d 100644 --- a/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/router/street/AccessEgressRouterTest.java +++ b/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/router/street/AccessEgressRouterTest.java @@ -47,25 +47,29 @@ public void build() { biStreet(C, D, 100); biStreet(farAway, A, 1000000); - var centroidRoutingStation = stationEntity( - "CentroidRoutingStation", - b -> b.withCoordinate(A.toWgsCoordinate()).withShouldRouteToCentroid(true) + var centroidRoutingStation = stationEntity("CentroidRoutingStation", b -> + b.withCoordinate(A.toWgsCoordinate()).withShouldRouteToCentroid(true) ); var centroidRoutingStationVertex = stationCentroid(centroidRoutingStation); - var noCentroidRoutingStation = stationEntity( - "NoCentroidRoutingStation", - b -> b.withCoordinate(D.toWgsCoordinate()) + var noCentroidRoutingStation = stationEntity("NoCentroidRoutingStation", b -> + b.withCoordinate(D.toWgsCoordinate()) ); var noCentroidRoutingStationVertex = stationCentroid(noCentroidRoutingStation); // StopForCentroidRoutingStation is a child of centroidRoutingStation - stopForCentroidRoutingStation = - stop("StopForCentroidRoutingStation", B.toWgsCoordinate(), centroidRoutingStation); + stopForCentroidRoutingStation = stop( + "StopForCentroidRoutingStation", + B.toWgsCoordinate(), + centroidRoutingStation + ); // StopForNoCentroidRoutingStation is a child of noCentroidRoutingStation - stopForNoCentroidRoutingStation = - stop("StopForNoCentroidRoutingStation", C.toWgsCoordinate(), noCentroidRoutingStation); + stopForNoCentroidRoutingStation = stop( + "StopForNoCentroidRoutingStation", + C.toWgsCoordinate(), + noCentroidRoutingStation + ); biLink(A, centroidRoutingStationVertex); biLink(B, stopForCentroidRoutingStation); @@ -237,8 +241,9 @@ private String stateDescription(State state) { } private void assertAcessEgresses(Set expected, Collection actual) { - assertThat(actual.stream().map(this::nearbyStopDescription)) - .containsExactlyElementsIn(expected); + assertThat(actual.stream().map(this::nearbyStopDescription)).containsExactlyElementsIn( + expected + ); } private Collection findAccessEgressFromTo( diff --git a/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/router/street/AccessEgressesTest.java b/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/router/street/AccessEgressesTest.java index bd498e82f65..3c02cb7b26c 100644 --- a/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/router/street/AccessEgressesTest.java +++ b/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/router/street/AccessEgressesTest.java @@ -18,13 +18,11 @@ class AccessEgressesTest { private static final RoutingAccessEgress ACCESS_A = new DefaultAccessEgress( 1, TestStateBuilder.ofWalking().build() - ) - .withPenalty(new TimeAndCost(D3m, Cost.ZERO)); + ).withPenalty(new TimeAndCost(D3m, Cost.ZERO)); private static final RoutingAccessEgress ACCESS_B = new DefaultAccessEgress( 1, TestStateBuilder.ofWalking().build() - ) - .withPenalty(new TimeAndCost(D7m, Cost.ZERO)); + ).withPenalty(new TimeAndCost(D7m, Cost.ZERO)); private static final RoutingAccessEgress ACCESS_C = new DefaultAccessEgress( 1, TestStateBuilder.ofWalking().build() diff --git a/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/RaptorTransitDataTest.java b/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/RaptorTransitDataTest.java index 194147a6984..30d1654b0db 100644 --- a/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/RaptorTransitDataTest.java +++ b/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/RaptorTransitDataTest.java @@ -31,19 +31,16 @@ class RaptorTransitDataTest { stopTime.setStop(stop); var stopPattern = new StopPattern(List.of(stopTime)); var route = TimetableRepositoryForTest.route("1").build(); - TRIP_PATTERN = - TripPattern - .of(TimetableRepositoryForTest.id("P1")) - .withRoute(route) - .withStopPattern(stopPattern) - .build() - .getRoutingTripPattern(); - TRIP_TIMES = - TripTimesFactory.tripTimes( - TimetableRepositoryForTest.trip("1").withRoute(route).build(), - List.of(new StopTime()), - new Deduplicator() - ); + TRIP_PATTERN = TripPattern.of(TimetableRepositoryForTest.id("P1")) + .withRoute(route) + .withStopPattern(stopPattern) + .build() + .getRoutingTripPattern(); + TRIP_TIMES = TripTimesFactory.tripTimes( + TimetableRepositoryForTest.trip("1").withRoute(route).build(), + List.of(new StopTime()), + new Deduplicator() + ); } @Test diff --git a/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/TripPatternForDateTest.java b/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/TripPatternForDateTest.java index c7f76fc3377..8215328a1cf 100644 --- a/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/TripPatternForDateTest.java +++ b/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/TripPatternForDateTest.java @@ -34,9 +34,9 @@ class TripPatternForDateTest { ); static Stream testCases() { - return Stream - .of(List.of(new FrequencyEntry(new Frequency(), tripTimes)), List.of()) - .map(Arguments::of); + return Stream.of(List.of(new FrequencyEntry(new Frequency(), tripTimes)), List.of()).map( + Arguments::of + ); } @ParameterizedTest(name = "trip with frequencies {0} should be correctly filtered") @@ -45,8 +45,7 @@ void shouldExcludeAndIncludeBasedOnFrequency(List freqs) { var stopTime = new StopTime(); stopTime.setStop(STOP); StopPattern stopPattern = new StopPattern(List.of(stopTime)); - RoutingTripPattern tripPattern = TripPattern - .of(TimetableRepositoryForTest.id("P1")) + RoutingTripPattern tripPattern = TripPattern.of(TimetableRepositoryForTest.id("P1")) .withRoute(ROUTE) .withStopPattern(stopPattern) .build() diff --git a/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/constrainedtransfer/ConstrainedBoardingSearchTest.java b/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/constrainedtransfer/ConstrainedBoardingSearchTest.java index 80ec5de7ed4..542ac4d65de 100644 --- a/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/constrainedtransfer/ConstrainedBoardingSearchTest.java +++ b/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/constrainedtransfer/ConstrainedBoardingSearchTest.java @@ -36,22 +36,16 @@ public class ConstrainedBoardingSearchTest { private static final FeedScopedId ID = TimetableRepositoryForTest.id("ID"); - private static final TransferConstraint GUARANTEED_CONSTRAINT = TransferConstraint - .of() + private static final TransferConstraint GUARANTEED_CONSTRAINT = TransferConstraint.of() .guaranteed() .build(); - private static final TransferConstraint NOT_ALLOWED_CONSTRAINT = TransferConstraint - .of() + private static final TransferConstraint NOT_ALLOWED_CONSTRAINT = TransferConstraint.of() .notAllowed() .build(); - private static final TransferConstraint MIN_TRANSFER_TIME_10_MIN_CONSTRAINT = TransferConstraint - .of() - .minTransferTime(600) - .build(); - private static final TransferConstraint MIN_TRANSFER_TIME_0_MIN_CONSTRAINT = TransferConstraint - .of() - .minTransferTime(0) - .build(); + private static final TransferConstraint MIN_TRANSFER_TIME_10_MIN_CONSTRAINT = + TransferConstraint.of().minTransferTime(600).build(); + private static final TransferConstraint MIN_TRANSFER_TIME_0_MIN_CONSTRAINT = + TransferConstraint.of().minTransferTime(0).build(); private static final StopTransferPoint STOP_B_TX_POINT = new StopTransferPoint(STOP_B); private static final StopTransferPoint STOP_C_TX_POINT = new StopTransferPoint(STOP_C); @@ -109,27 +103,25 @@ public class ConstrainedBoardingSearchTest { */ @BeforeEach void setup() { - route1 = - TestRouteData.of( - "R1", - TransitMode.RAIL, - List.of(STOP_A, STOP_B, STOP_C), - "10:00 10:10 10:20", - "10:05 10:15 10:25" - ); + route1 = TestRouteData.of( + "R1", + TransitMode.RAIL, + List.of(STOP_A, STOP_B, STOP_C), + "10:00 10:10 10:20", + "10:05 10:15 10:25" + ); - route2 = - TestRouteData.of( - "R2", - TransitMode.BUS, - List.of(STOP_B, STOP_C, STOP_D), - "10:15 10:30 10:40", - "10:20 10:35 10:45", - "10:25 10:40 10:50", - "10:30 10:45 10:55", - "10:35 10:50 11:00", - "10:40 10:55 11:05" - ); + route2 = TestRouteData.of( + "R2", + TransitMode.BUS, + List.of(STOP_B, STOP_C, STOP_D), + "10:15 10:30 10:40", + "10:20 10:35 10:45", + "10:25 10:40 10:50", + "10:30 10:45 10:55", + "10:35 10:50 11:00", + "10:40 10:55 11:05" + ); this.pattern1 = route1.getTripPattern(); this.pattern2 = route2.getTripPattern(); @@ -160,12 +152,11 @@ void transferExist() { assertFalse(subject.transferExistSourceStop(toStopPos)); // Reverse - - subject = - new ConstrainedBoardingSearch( - false, - constrainedTransfers.toStop(routingPattern1.patternIndex()), - constrainedTransfers.fromStop(routingPattern1.patternIndex()) - ); + subject = new ConstrainedBoardingSearch( + false, + constrainedTransfers.toStop(routingPattern1.patternIndex()), + constrainedTransfers.fromStop(routingPattern1.patternIndex()) + ); assertTrue(subject.transferExistTargetStop(fromStopPos)); assertFalse(subject.transferExistSourceStop(fromStopPos)); } diff --git a/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/cost/DefaultCostCalculatorTest.java b/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/cost/DefaultCostCalculatorTest.java index ef10296a3ef..b9f7e4ef00d 100644 --- a/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/cost/DefaultCostCalculatorTest.java +++ b/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/cost/DefaultCostCalculatorTest.java @@ -20,13 +20,11 @@ public class DefaultCostCalculatorTest { private static final int STOP_B = 1; private static final String ANY_SCHEDULE = "10:00 11:00"; - private static final TestTripSchedule TRIP_1 = TestTripSchedule - .schedule(ANY_SCHEDULE) + private static final TestTripSchedule TRIP_1 = TestTripSchedule.schedule(ANY_SCHEDULE) .transitReluctanceIndex(TRANSIT_RELUCTANCE_1) .build(); - private static final TestTripSchedule TRIP_2 = TestTripSchedule - .schedule(ANY_SCHEDULE) + private static final TestTripSchedule TRIP_2 = TestTripSchedule.schedule(ANY_SCHEDULE) .transitReluctanceIndex(TRANSIT_RELUCTANCE_2) .build(); diff --git a/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/cost/PatternCostCalculatorTest.java b/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/cost/PatternCostCalculatorTest.java index 1cf9a324de5..9e3fef29cc5 100644 --- a/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/cost/PatternCostCalculatorTest.java +++ b/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/cost/PatternCostCalculatorTest.java @@ -43,13 +43,14 @@ public class PatternCostCalculatorTest { private static final FeedScopedId UNPREFERRED_AGENCY_ID = id("contoso-travels"); private static final Agency UNPREFERRED_AGENCY = agency(UNPREFERRED_AGENCY_ID.getId()); - protected static final RaptorCostCalculator DEFAULT_COST_CALCULATOR = new DefaultCostCalculator<>( - BOARD_COST_SEC, - TRANSFER_COST_SEC, - WAIT_RELUCTANCE_FACTOR, - null, - null - ); + protected static final RaptorCostCalculator DEFAULT_COST_CALCULATOR = + new DefaultCostCalculator<>( + BOARD_COST_SEC, + TRANSFER_COST_SEC, + WAIT_RELUCTANCE_FACTOR, + null, + null + ); @Test @DisplayName("cost mapper should create penalty map") @@ -98,13 +99,13 @@ public void testMcCostParameterMapping() { private static Stream preferencesPenaltyForRouteTestCases() { return TestTableParser.of( """ - # unpreferred | expected - # agency | route | extra-cost - - | - | 0 - - | x | 230000 - x | - | 230000 - x | x | 230000 - """ + # unpreferred | expected + # agency | route | extra-cost + - | - | 0 + - | x | 230000 + x | - | 230000 + x | x | 230000 + """ ); } @@ -180,8 +181,7 @@ RaptorCostCalculator createCostCalculator(TestTripSchedule sch * @return Test schedule */ TestTripSchedule createSchedule() { - return TestTripSchedule - .schedule("12:00 12:01") + return TestTripSchedule.schedule("12:00 12:01") .pattern(pattern(unPreferredRoute, unPreferredAgency)) .build(); } diff --git a/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/cost/RaptorCostLinearFunctionTest.java b/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/cost/RaptorCostLinearFunctionTest.java index b38cefe232c..81c22b05724 100644 --- a/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/cost/RaptorCostLinearFunctionTest.java +++ b/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/cost/RaptorCostLinearFunctionTest.java @@ -33,14 +33,14 @@ class RaptorCostLinearFunctionTest { static Stream calculateRaptorCostTestCases() { return TestTableParser.of( """ - # expectedRaptorCost | timeSeconds - 1700 | 0 - 1950 | 1 - 2200 | 2 - 5450 | 15 - 5700 | 16 - 16950 | 61 - """ + # expectedRaptorCost | timeSeconds + 1700 | 0 + 1950 | 1 + 2200 | 2 + 5450 | 15 + 5700 | 16 + 16950 | 61 + """ ); } diff --git a/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/cost/WheelchairCostCalculatorTest.java b/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/cost/WheelchairCostCalculatorTest.java index 76de708c817..ee9dbdb370e 100644 --- a/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/cost/WheelchairCostCalculatorTest.java +++ b/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/cost/WheelchairCostCalculatorTest.java @@ -21,18 +21,20 @@ public class WheelchairCostCalculatorTest { private static final int TRANSFER_COST_SEC = 2; private static final double WAIT_RELUCTANCE_FACTOR = 0.5; - private final DefaultCostCalculator defaultCostCalculator = new DefaultCostCalculator<>( - BOARD_COST_SEC, - TRANSFER_COST_SEC, - WAIT_RELUCTANCE_FACTOR, - null, - null - ); + private final DefaultCostCalculator defaultCostCalculator = + new DefaultCostCalculator<>( + BOARD_COST_SEC, + TRANSFER_COST_SEC, + WAIT_RELUCTANCE_FACTOR, + null, + null + ); - private final WheelchairCostCalculator wheelchairCostCalculator = new WheelchairCostCalculator<>( - defaultCostCalculator, - AccessibilityPreferences.ofCost(UNKNOWN_ACCESSIBILITY_COST, INACCESSIBLE_TRIP_COST) - ); + private final WheelchairCostCalculator wheelchairCostCalculator = + new WheelchairCostCalculator<>( + defaultCostCalculator, + AccessibilityPreferences.ofCost(UNKNOWN_ACCESSIBILITY_COST, INACCESSIBLE_TRIP_COST) + ); private final TestTripSchedule.Builder scheduleBuilder = TestTripSchedule.schedule("12:00 12:01"); static Stream testCases() { diff --git a/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/GeneralizedCostParametersMapperTest.java b/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/GeneralizedCostParametersMapperTest.java index 2620dd506bc..dfa44fcf737 100644 --- a/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/GeneralizedCostParametersMapperTest.java +++ b/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/GeneralizedCostParametersMapperTest.java @@ -43,9 +43,10 @@ public void shouldExtractRoutesFromAgencies() { var routingRequest = new RouteRequest(); routingRequest.journey().transit().setUnpreferredAgencies(List.of(unpreferredAgency)); - BitSet unpreferredPatterns = GeneralizedCostParametersMapper - .map(routingRequest, data.getPatterns()) - .unpreferredPatterns(); + BitSet unpreferredPatterns = GeneralizedCostParametersMapper.map( + routingRequest, + data.getPatterns() + ).unpreferredPatterns(); for (var pattern : data.getPatterns()) { assertEquals( @@ -68,9 +69,9 @@ public void dealWithEmptyList() { private static TestRoute testTripPattern(FeedScopedId agencyId, FeedScopedId routeId) { return TestRoute.route( - TestTripPattern - .pattern(1, 2) - .withRoute(route(routeId).withAgency(agency(agencyId.getId())).build()) + TestTripPattern.pattern(1, 2).withRoute( + route(routeId).withAgency(agency(agencyId.getId())).build() + ) ); } } diff --git a/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/LookupStopIndexCallbackTest.java b/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/LookupStopIndexCallbackTest.java index fb39db51cd5..a20c36d600a 100644 --- a/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/LookupStopIndexCallbackTest.java +++ b/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/LookupStopIndexCallbackTest.java @@ -27,9 +27,8 @@ class LookupStopIndexCallbackTest { */ void lookupStopLocationIndexesSingleIdInput() { assertArrayEquals(new int[] { 1, 7, 13 }, subject.lookupStopLocationIndexes(ID_1).toArray()); - var ex = Assertions.assertThrows( - EntityNotFoundException.class, - () -> subject.lookupStopLocationIndexes(ID_3).toArray() + var ex = Assertions.assertThrows(EntityNotFoundException.class, () -> + subject.lookupStopLocationIndexes(ID_3).toArray() ); assertEquals("StopLocation does not exist for id F:3", ex.getMessage()); } @@ -44,9 +43,8 @@ void lookupStopLocationIndexesCollectionInput() { ); // Should throw exception? - var ex = assertThrows( - EntityNotFoundException.class, - () -> subject.lookupStopLocationIndexes(List.of(ID_1, ID_3)) + var ex = assertThrows(EntityNotFoundException.class, () -> + subject.lookupStopLocationIndexes(List.of(ID_1, ID_3)) ); assertEquals("StopLocation entity not found: F:3", ex.getMessage()); } diff --git a/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/RaptorRequestMapperTest.java b/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/RaptorRequestMapperTest.java index aecb3d50fef..c1c4b7d7df7 100644 --- a/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/RaptorRequestMapperTest.java +++ b/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/RaptorRequestMapperTest.java @@ -191,9 +191,9 @@ static List testViaAndTransitGroupPriorityCombinationsTestCases() { ), Arguments.of( """ - VIA_VISIT is not allowed together VIA_PASS_THROUGH, an error is expected. - Other features are ignored. - """, + VIA_VISIT is not allowed together VIA_PASS_THROUGH, an error is expected. + Other features are ignored. + """, List.of(VIA_VISIT, VIA_PASS_THROUGH, TRANSIT_GROUP_PRIORITY, RELAX_COST_DEST), List.of(), "A mix of via-locations and pass-through is not allowed in this version." @@ -221,9 +221,9 @@ VIA_PASS_THROUGH override VIA_VISIT (see above) ), Arguments.of( """ - TRANSIT_GROUP_PRIORITY cannot be combined with other features, override RELAX_COST_DEST - VIA_PASS_THROUGH and VIA_VISIT override VIA_VISIT (see above) - """, + TRANSIT_GROUP_PRIORITY cannot be combined with other features, override RELAX_COST_DEST + VIA_PASS_THROUGH and VIA_VISIT override VIA_VISIT (see above) + """, List.of(TRANSIT_GROUP_PRIORITY, RELAX_COST_DEST), List.of(TRANSIT_GROUP_PRIORITY), null diff --git a/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/RaptorRoutingRequestTransitDataCreatorTest.java b/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/RaptorRoutingRequestTransitDataCreatorTest.java index 7df9677082d..894eb0f6ab9 100644 --- a/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/RaptorRoutingRequestTransitDataCreatorTest.java +++ b/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/RaptorRoutingRequestTransitDataCreatorTest.java @@ -99,8 +99,7 @@ private static TripPatternForDates findTripPatternForDate( } private TripTimes createTripTimesForTest() { - return ScheduledTripTimes - .of() + return ScheduledTripTimes.of() .withTrip(TimetableRepositoryForTest.trip("Test").build()) .withDepartureTimes("00:00 02:00") .build(); @@ -118,8 +117,7 @@ private static StopTime createStopTime() { } private static RoutingTripPattern createTripPattern(FeedScopedId id) { - return TripPattern - .of(id) + return TripPattern.of(id) .withRoute(TimetableRepositoryForTest.route("1").withMode(TransitMode.BUS).build()) .withStopPattern(new StopPattern(List.of(createStopTime(), createStopTime()))) .build() diff --git a/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/RouteRequestTransitDataProviderFilterTest.java b/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/RouteRequestTransitDataProviderFilterTest.java index ea4b7174e79..b0622a82206 100644 --- a/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/RouteRequestTransitDataProviderFilterTest.java +++ b/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/RouteRequestTransitDataProviderFilterTest.java @@ -61,12 +61,9 @@ class RouteRequestTransitDataProviderFilterTest { private static final WheelchairPreferences DEFAULT_ACCESSIBILITY = WheelchairPreferences.DEFAULT; - private static final AccessibilityPreferences RELAXED_ACCESSIBILITY_PREFERENCE = AccessibilityPreferences.ofCost( - 0, - 10 - ); - private static final WheelchairPreferences RELAXED_ACCESSIBILITY = WheelchairPreferences - .of() + private static final AccessibilityPreferences RELAXED_ACCESSIBILITY_PREFERENCE = + AccessibilityPreferences.ofCost(0, 10); + private static final WheelchairPreferences RELAXED_ACCESSIBILITY = WheelchairPreferences.of() .withTrip(RELAXED_ACCESSIBILITY_PREFERENCE) .withStop(RELAXED_ACCESSIBILITY_PREFERENCE) .withElevator(RELAXED_ACCESSIBILITY_PREFERENCE) @@ -101,8 +98,7 @@ void testWheelchairAccess(Accessibility wheelchair, WheelchairPreferences access stopTimeEnd.setStop(lastStop); var stopPattern = new StopPattern(List.of(stopTimeStart, stopTimeEnd)); - var tripPattern = TripPattern - .of(TimetableRepositoryForTest.id("P1")) + var tripPattern = TripPattern.of(TimetableRepositoryForTest.id("P1")) .withRoute(TimetableRepositoryForTest.route("1").build()) .withStopPattern(stopPattern) .build() @@ -152,8 +148,7 @@ void testRealtimeCancelledStops(boolean includeRealtimeCancellations) { var stopTime3 = getStopTime("TEST:3", PickDrop.NONE); var stopTime4 = getStopTime("TEST:4", PickDrop.SCHEDULED); var stopPattern = new StopPattern(List.of(stopTime1, stopTime2, stopTime3, stopTime4)); - var tripPattern = TripPattern - .of(TimetableRepositoryForTest.id("P1")) + var tripPattern = TripPattern.of(TimetableRepositoryForTest.id("P1")) .withRoute(TimetableRepositoryForTest.route("1").build()) .withStopPattern(stopPattern) .build() @@ -234,8 +229,7 @@ void bannedRouteFilteringTest() { false, Set.of(), List.of( - TransitFilterRequest - .of() + TransitFilterRequest.of() .addNot(SelectRequest.of().withRoutes(List.of(ROUTE.getId())).build()) .build() ) @@ -365,17 +359,14 @@ void matchSelectedAgencyExcludedSubMode() { false, Set.of(), List.of( - TransitFilterRequest - .of() + TransitFilterRequest.of() .addSelect( - SelectRequest - .of() + SelectRequest.of() .withAgencies(List.of(TimetableRepositoryForTest.AGENCY.getId())) .build() ) .addNot( - SelectRequest - .of() + SelectRequest.of() .withTransportModes( List.of( new MainAndSubMode( @@ -929,8 +920,7 @@ private TripPatternForDate createTestTripPatternForDate() { var stopTime = new StopTime(); stopTime.setStop(STOP_FOR_TEST); StopPattern stopPattern = new StopPattern(List.of(stopTime)); - RoutingTripPattern tripPattern = TripPattern - .of(TimetableRepositoryForTest.id("P1")) + RoutingTripPattern tripPattern = TripPattern.of(TimetableRepositoryForTest.id("P1")) .withRoute(route) .withStopPattern(stopPattern) .build() @@ -951,8 +941,7 @@ private List filterForMode(TransitMode mode) { private List filterForModes(Collection modes) { return List.of( - TransitFilterRequest - .of() + TransitFilterRequest.of() .addSelect(SelectRequest.of().withTransportModes(List.copyOf(modes)).build()) .build() ); @@ -963,8 +952,7 @@ private List filterForModesAndFilterForBannedAgencies( List agencyIds ) { return List.of( - TransitFilterRequest - .of() + TransitFilterRequest.of() .addSelect(SelectRequest.of().withTransportModes(List.copyOf(modes)).build()) .build(), TransitFilterRequest.of().addNot(SelectRequest.of().withAgencies(agencyIds).build()).build() @@ -976,8 +964,7 @@ private List combinedFilterForModesAndBannedAgencies( List agencyIds ) { return List.of( - TransitFilterRequest - .of() + TransitFilterRequest.of() .addSelect(SelectRequest.of().withTransportModes(List.copyOf(modes)).build()) .addNot(SelectRequest.of().withAgencies(agencyIds).build()) .build() @@ -994,8 +981,7 @@ private RealTimeTripTimes createTestTripTimes( Accessibility wheelchairBoarding, TripAlteration tripAlteration ) { - Trip trip = Trip - .of(tripId) + Trip trip = Trip.of(tripId) .withRoute(route) .withMode(mode) .withNetexSubmode(submode) @@ -1033,8 +1019,7 @@ public static RegularStop stopForTest( double lat, double lon ) { - return TEST_MODEL - .stop(idAndName) + return TEST_MODEL.stop(idAndName) .withCoordinate(new WgsCoordinate(lat, lon)) .withWheelchairAccessibility(wheelchair) .build(); diff --git a/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/TestRouteData.java b/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/TestRouteData.java index 5c345e55931..702ffa6e733 100644 --- a/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/TestRouteData.java +++ b/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/TestRouteData.java @@ -44,11 +44,10 @@ public class TestRouteData { public TestRouteData(Route route, List stops, List times) { final Deduplicator deduplicator = new Deduplicator(); this.route = route; - this.trips = - times - .stream() - .map(it -> parseTripInfo(route.getName(), it, stops, deduplicator)) - .collect(Collectors.toList()); + this.trips = times + .stream() + .map(it -> parseTripInfo(route.getName(), it, stops, deduplicator)) + .collect(Collectors.toList()); List stopTimesFistTrip = firstTrip().getStopTimes(); // Get TripTimes in same order as the trips @@ -57,13 +56,11 @@ public TestRouteData(Route route, List stops, List times) { .map(tripTimesByTrip::get) .collect(Collectors.toList()); - tripPattern = - TripPattern - .of(TimetableRepositoryForTest.id("TP:" + route)) - .withRoute(this.route) - .withStopPattern(new StopPattern(stopTimesFistTrip)) - .withScheduledTimeTableBuilder(builder -> builder.addAllTripTimes(tripTimes)) - .build(); + tripPattern = TripPattern.of(TimetableRepositoryForTest.id("TP:" + route)) + .withRoute(this.route) + .withStopPattern(new StopPattern(stopTimesFistTrip)) + .withScheduledTimeTableBuilder(builder -> builder.addAllTripTimes(tripTimes)) + .build(); RoutingTripPattern routingTripPattern = tripPattern.getRoutingTripPattern(); @@ -166,8 +163,7 @@ private Trip parseTripInfo( List stops, Deduplicator deduplicator ) { - var trip = Trip - .of(TimetableRepositoryForTest.id(route + "-" + stopTimesByTrip.size() + 1)) + var trip = Trip.of(TimetableRepositoryForTest.id(route + "-" + stopTimesByTrip.size() + 1)) .withRoute(this.route) .build(); var stopTimes = stopTimes(trip, stops, tripTimes); @@ -260,8 +256,7 @@ public Builder withSubmode(String submode) { } public TestRouteData build() { - var routeBuilder = TimetableRepositoryForTest - .route(route) + var routeBuilder = TimetableRepositoryForTest.route(route) .withMode(mode) .withShortName(route); if (agency != null) { diff --git a/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/TestTransitCaseData.java b/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/TestTransitCaseData.java index 729b643667a..943c7929117 100644 --- a/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/TestTransitCaseData.java +++ b/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/TestTransitCaseData.java @@ -9,21 +9,17 @@ public final class TestTransitCaseData { private static TimetableRepositoryForTest TEST_MODEL = TimetableRepositoryForTest.of(); - public static final Station STATION_A = TEST_MODEL - .station("A") + public static final Station STATION_A = TEST_MODEL.station("A") .withCoordinate(60.0, 11.1) .build(); - public static final Station STATION_B = TEST_MODEL - .station("B") + public static final Station STATION_B = TEST_MODEL.station("B") .withCoordinate(61.0, 11.5) .build(); - public static final RegularStop STOP_A = TEST_MODEL - .stop("A", 60.0, 11.0) + public static final RegularStop STOP_A = TEST_MODEL.stop("A", 60.0, 11.0) .withParentStation(STATION_A) .build(); - public static final RegularStop STOP_B = TEST_MODEL - .stop("B", 60.0, 11.2) + public static final RegularStop STOP_B = TEST_MODEL.stop("B", 60.0, 11.2) .withParentStation(STATION_B) .build(); public static final RegularStop STOP_C = TEST_MODEL.stop("C", 61.0, 11.4).build(); diff --git a/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/TripPatternForDatesTest.java b/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/TripPatternForDatesTest.java index 9189a5b932a..1d5fb3ecfcd 100644 --- a/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/TripPatternForDatesTest.java +++ b/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/TripPatternForDatesTest.java @@ -77,8 +77,7 @@ private static TripPatternForDates getTestSubjectWithExactFrequency() { stopTime2.setDepartureTime(300); stopTime2.setStopSequence(1); StopPattern stopPattern = new StopPattern(List.of(stopTime1, stopTime2)); - RoutingTripPattern tripPattern = TripPattern - .of(TimetableRepositoryForTest.id("P1")) + RoutingTripPattern tripPattern = TripPattern.of(TimetableRepositoryForTest.id("P1")) .withRoute(ROUTE) .withStopPattern(stopPattern) .build() diff --git a/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/TripScheduleAlightSearchTest.java b/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/TripScheduleAlightSearchTest.java index 55cb99b2f82..df193b5922c 100644 --- a/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/TripScheduleAlightSearchTest.java +++ b/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/TripScheduleAlightSearchTest.java @@ -53,14 +53,12 @@ public class TripScheduleAlightSearchTest implements RaptorTestConstants { private final TestTripPattern pattern = pattern("R1", STOP_A, STOP_B); - private TestRoute route = TestRoute - .route(pattern) - .withTimetable( - // Trips in service - schedule().arrivals(TIME_A1, TIME_A2), - schedule().arrivals(TIME_B1, TIME_B2), - schedule().arrivals(TIME_C1, TIME_C2) - ); + private TestRoute route = TestRoute.route(pattern).withTimetable( + // Trips in service + schedule().arrivals(TIME_A1, TIME_A2), + schedule().arrivals(TIME_B1, TIME_B2), + schedule().arrivals(TIME_C1, TIME_C2) + ); private final TestTripSchedule tripA = route.timetable().getTripSchedule(TRIP_A); private final TestTripSchedule tripB = route.timetable().getTripSchedule(TRIP_B); diff --git a/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/TripScheduleBoardSearchTest.java b/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/TripScheduleBoardSearchTest.java index 28811fcc42c..714ec98a0f8 100644 --- a/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/TripScheduleBoardSearchTest.java +++ b/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/TripScheduleBoardSearchTest.java @@ -53,13 +53,11 @@ public class TripScheduleBoardSearchTest implements RaptorTestConstants { private static final int TRIP_C = 2; // Route with trip A, B, C. - private TestRoute route = TestRoute - .route(pattern) - .withTimetable( - schedule().departures(TIME_A1, TIME_A2), - schedule().departures(TIME_B1, TIME_B2), - schedule().departures(TIME_C1, TIME_C2) - ); + private TestRoute route = TestRoute.route(pattern).withTimetable( + schedule().departures(TIME_A1, TIME_A2), + schedule().departures(TIME_B1, TIME_B2), + schedule().departures(TIME_C1, TIME_C2) + ); // Trips in service private final TestTripSchedule tripA = route.timetable().getTripSchedule(TRIP_A); diff --git a/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/BasicPathTestCase.java b/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/BasicPathTestCase.java index 574e05c9c5e..1ea242aca41 100644 --- a/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/BasicPathTestCase.java +++ b/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/BasicPathTestCase.java @@ -173,33 +173,37 @@ public class BasicPathTestCase implements RaptorTestConstants { public static final String LINE_21 = "L21"; public static final String LINE_31 = "L31"; - public static final TestTripSchedule TRIP_1 = TestTripSchedule - .schedule(TestTripPattern.pattern(LINE_11, STOP_A, STOP_B)) + public static final TestTripSchedule TRIP_1 = TestTripSchedule.schedule( + TestTripPattern.pattern(LINE_11, STOP_A, STOP_B) + ) .times(L11_START, L11_END) .transitReluctanceIndex(TRANSIT_RELUCTANCE_INDEX) .build(); - public static final TestTripSchedule TRIP_2 = TestTripSchedule - .schedule(TestTripPattern.pattern(LINE_21, STOP_C, STOP_D)) + public static final TestTripSchedule TRIP_2 = TestTripSchedule.schedule( + TestTripPattern.pattern(LINE_21, STOP_C, STOP_D) + ) .times(L21_START, L21_END) .transitReluctanceIndex(TRANSIT_RELUCTANCE_INDEX) .build(); - public static final TestTripSchedule TRIP_3 = TestTripSchedule - .schedule(TestTripPattern.pattern(LINE_31, STOP_D, STOP_E)) + public static final TestTripSchedule TRIP_3 = TestTripSchedule.schedule( + TestTripPattern.pattern(LINE_31, STOP_D, STOP_E) + ) // The early arrival and late departure should not have any effect on tests .arrivals(VERY_EARLY, L31_END) .departures(L31_START, VERY_LATE) .transitReluctanceIndex(TRANSIT_RELUCTANCE_INDEX) .build(); - public static final RaptorCostCalculator C1_CALCULATOR = new DefaultCostCalculator<>( - BOARD_C1_SEC, - TRANSFER_C1_SEC, - WAIT_RELUCTANCE, - TRANSIT_RELUCTANCE, - STOP_C1S - ); + public static final RaptorCostCalculator C1_CALCULATOR = + new DefaultCostCalculator<>( + BOARD_C1_SEC, + TRANSFER_C1_SEC, + WAIT_RELUCTANCE, + TRANSIT_RELUCTANCE, + STOP_C1S + ); public static final int TOTAL_C1 = ACCESS_C1 + LINE_11_C1 + TX_C1 + LINE_21_C1 + LINE_31_C1 + EGRESS_C1; diff --git a/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/model/MinSafeTransferTimeCalculatorTest.java b/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/model/MinSafeTransferTimeCalculatorTest.java index 1cd9c8f139d..eabe200be50 100644 --- a/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/model/MinSafeTransferTimeCalculatorTest.java +++ b/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/model/MinSafeTransferTimeCalculatorTest.java @@ -20,16 +20,13 @@ public class MinSafeTransferTimeCalculatorTest implements RaptorTestConstants { private static final TestPathBuilder PATH_BUILDER = new TestPathBuilder(COST_CALCULATOR); - private final MinSafeTransferTimeCalculator subject = new MinSafeTransferTimeCalculator<>( - SLACK_PROVIDER - ); - RaptorPath path_1_bus_leg = PATH_BUILDER - .access(time("10:00:15"), STOP_A, D2m) + private final MinSafeTransferTimeCalculator subject = + new MinSafeTransferTimeCalculator<>(SLACK_PROVIDER); + RaptorPath path_1_bus_leg = PATH_BUILDER.access(time("10:00:15"), STOP_A, D2m) .bus("L11", time("10:03"), TRANSIT_TIME, STOP_B) .egress(D2m); - RaptorPath path_3_bus_legs = PATH_BUILDER - .access(time("10:00:15"), STOP_A, D2m) + RaptorPath path_3_bus_legs = PATH_BUILDER.access(time("10:00:15"), STOP_A, D2m) .bus("L1", time("10:03"), TRANSIT_TIME, STOP_B) .walk(D2m, STOP_C) .bus("L2", time("10:45"), TRANSIT_TIME, STOP_D) diff --git a/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/model/OptimizedPathTailTest.java b/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/model/OptimizedPathTailTest.java index f43daf1fbc9..bae5dc246e2 100644 --- a/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/model/OptimizedPathTailTest.java +++ b/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/model/OptimizedPathTailTest.java @@ -26,13 +26,21 @@ class OptimizedPathTailTest implements RaptorTestConstants { private final TransitPathLeg t3 = t2.nextTransitLeg(); @SuppressWarnings("ConstantConditions") - private final TripToTripTransfer tx23 = TestTransferBuilder - .tx(t2.trip(), STOP_D, t3.trip(), STOP_D) + private final TripToTripTransfer tx23 = TestTransferBuilder.tx( + t2.trip(), + STOP_D, + t3.trip(), + STOP_D + ) .staySeated() .build(); - private final TripToTripTransfer tx12 = TestTransferBuilder - .tx(t1.trip(), STOP_B, t2.trip(), STOP_C) + private final TripToTripTransfer tx12 = TestTransferBuilder.tx( + t1.trip(), + STOP_B, + t2.trip(), + STOP_C + ) .walk(D2m) .build(); diff --git a/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/model/TransferWaitTimeCostCalculatorTest.java b/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/model/TransferWaitTimeCostCalculatorTest.java index 3a375f7968a..a97742be930 100644 --- a/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/model/TransferWaitTimeCostCalculatorTest.java +++ b/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/model/TransferWaitTimeCostCalculatorTest.java @@ -104,13 +104,10 @@ public void calculateOptimizedWaitCost() { @Test public void calculateTxCostWithNoMinSafeTxTimeThrowsException() { - assertThrows( - IllegalStateException.class, - () -> { - var subject = new TransferWaitTimeCostCalculator(1.0, 2.0); - subject.calculateOptimizedWaitCost(d20m); - } - ); + assertThrows(IllegalStateException.class, () -> { + var subject = new TransferWaitTimeCostCalculator(1.0, 2.0); + subject.calculateOptimizedWaitCost(d20m); + }); } @Test diff --git a/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/model/TripStopTimeTest.java b/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/model/TripStopTimeTest.java index 640dd48d27d..1069e48088f 100644 --- a/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/model/TripStopTimeTest.java +++ b/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/model/TripStopTimeTest.java @@ -15,8 +15,9 @@ public class TripStopTimeTest { private static final int STOP_2 = 5; private static final int STOP_3 = 7; - TestTripSchedule trip = TestTripSchedule - .schedule(TestTripPattern.pattern("L31", STOP_1, STOP_2, STOP_3)) + TestTripSchedule trip = TestTripSchedule.schedule( + TestTripPattern.pattern("L31", STOP_1, STOP_2, STOP_3) + ) .arrivals("10:00 10:05 10:20") .departures("10:01 10:06 10:21") .build(); diff --git a/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/model/costfilter/MinCostPathTailFilterTest.java b/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/model/costfilter/MinCostPathTailFilterTest.java index d57f949a13a..1afdfe63ee8 100644 --- a/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/model/costfilter/MinCostPathTailFilterTest.java +++ b/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/model/costfilter/MinCostPathTailFilterTest.java @@ -14,10 +14,8 @@ class MinCostPathTailFilterTest implements RaptorTestConstants { - private static final TransferWaitTimeCostCalculator WAIT_TIME_CALC = new TransferWaitTimeCostCalculator( - 1.0, - 5.0 - ); + private static final TransferWaitTimeCostCalculator WAIT_TIME_CALC = + new TransferWaitTimeCostCalculator(1.0, 5.0); private final A v01 = new A("A", 0, 11); private final A v10 = new A("B", 1, 10); @@ -29,8 +27,9 @@ void filterEmptySet() { // filter empty set assertEquals( Set.of(), - new MinCostPathTailFilter(List.of(OptimizedPathTail::generalizedCost)) - .filterIntermediateResult(Set.of(), 0) + new MinCostPathTailFilter( + List.of(OptimizedPathTail::generalizedCost) + ).filterIntermediateResult(Set.of(), 0) ); } diff --git a/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/model/passthrough/PassThroughNoTransfersTest.java b/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/model/passthrough/PassThroughNoTransfersTest.java index ff1f37ef5fa..800b88768e9 100644 --- a/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/model/passthrough/PassThroughNoTransfersTest.java +++ b/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/model/passthrough/PassThroughNoTransfersTest.java @@ -33,8 +33,7 @@ public class PassThroughNoTransfersTest implements RaptorTestConstants { /** Any stop not part of trip. */ private static final int ANY_STOP = STOP_I; - private final TestTripSchedule trip1 = TestTripSchedule - .schedule() + private final TestTripSchedule trip1 = TestTripSchedule.schedule() .pattern("Line 1", STOP_A, STOP_B, STOP_C, STOP_D, STOP_E) .times("10:05 10:10 10:15 10:20 10:25") .build(); diff --git a/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/model/passthrough/PassThroughOneTransferTest.java b/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/model/passthrough/PassThroughOneTransferTest.java index d1bc95f3b68..1e97e4afdb6 100644 --- a/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/model/passthrough/PassThroughOneTransferTest.java +++ b/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/model/passthrough/PassThroughOneTransferTest.java @@ -45,14 +45,12 @@ public class PassThroughOneTransferTest implements RaptorTestConstants { */ private static final int N_STOPS = STOP_M + 1; - private final TestTripSchedule trip1 = TestTripSchedule - .schedule() + private final TestTripSchedule trip1 = TestTripSchedule.schedule() .pattern("Line 1", STOP_A, STOP_B, STOP_C, STOP_D, STOP_E) .times("10:05 10:10 10:15 10:20 10:25") .build(); - private final TestTripSchedule trip2 = TestTripSchedule - .schedule() + private final TestTripSchedule trip2 = TestTripSchedule.schedule() .pattern("Line 2", STOP_F, STOP_G, STOP_H, STOP_I, STOP_J) .times("10:30 10:35 10:40 10:45 10:50") .build(); diff --git a/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/model/passthrough/PassThroughTwoTransfersTest.java b/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/model/passthrough/PassThroughTwoTransfersTest.java index bed2bff0202..a33ead97c20 100644 --- a/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/model/passthrough/PassThroughTwoTransfersTest.java +++ b/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/model/passthrough/PassThroughTwoTransfersTest.java @@ -39,20 +39,17 @@ public class PassThroughTwoTransfersTest implements RaptorTestConstants { private static final int ITERATION_START_TIME = time("10:00"); - private final TestTripSchedule trip1 = TestTripSchedule - .schedule() + private final TestTripSchedule trip1 = TestTripSchedule.schedule() .pattern("Line 1", STOP_A, STOP_B, STOP_C, STOP_D, STOP_E) .times("10:05 10:10 10:15 10:20 10:25") .build(); - private final TestTripSchedule trip2 = TestTripSchedule - .schedule() + private final TestTripSchedule trip2 = TestTripSchedule.schedule() .pattern("Line 2", STOP_F, STOP_G, STOP_H, STOP_I, STOP_J) .times("10:30 10:35 10:40 10:45 10:50") .build(); - private final TestTripSchedule trip3 = TestTripSchedule - .schedule() + private final TestTripSchedule trip3 = TestTripSchedule.schedule() .pattern("Line 3", STOP_K, STOP_L, STOP_M) .times("10:55 11:00 11:05") .build(); diff --git a/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/model/passthrough/TestUtils.java b/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/model/passthrough/TestUtils.java index fb819c4371e..ebc875a2184 100644 --- a/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/model/passthrough/TestUtils.java +++ b/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/model/passthrough/TestUtils.java @@ -22,13 +22,8 @@ class TestUtils implements RaptorTestConstants { private static final int TRANSFER_COST_SEC = 0; private static final double WAIT_RELUCTANCE = 1.0; - private static final RaptorCostCalculator COST_CALCULATOR = new DefaultCostCalculator<>( - BOARD_COST_SEC, - TRANSFER_COST_SEC, - WAIT_RELUCTANCE, - null, - null - ); + private static final RaptorCostCalculator COST_CALCULATOR = + new DefaultCostCalculator<>(BOARD_COST_SEC, TRANSFER_COST_SEC, WAIT_RELUCTANCE, null, null); static TestPathBuilder pathBuilder() { return new TestPathBuilder(TestTransitData.SLACK_PROVIDER, COST_CALCULATOR); diff --git a/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/services/OptimizePathDomainServiceConstrainedTest.java b/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/services/OptimizePathDomainServiceConstrainedTest.java index 3cfba2330c1..36a4c0b6569 100644 --- a/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/services/OptimizePathDomainServiceConstrainedTest.java +++ b/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/services/OptimizePathDomainServiceConstrainedTest.java @@ -49,14 +49,12 @@ public class OptimizePathDomainServiceConstrainedTest implements RaptorTestConst private final int START_TIME_T1 = time("10:00:20"); // Given - TestTripSchedule trip1 = TestTripSchedule - .schedule() + TestTripSchedule trip1 = TestTripSchedule.schedule() .pattern("T1", STOP_A, STOP_B, STOP_C, STOP_D, STOP_E, STOP_F) .times("10:02 10:10 10:15 10:20 10:25 10:30") .build(); - TestTripSchedule trip2 = TestTripSchedule - .schedule() + TestTripSchedule trip2 = TestTripSchedule.schedule() .pattern("T2", STOP_C, STOP_D, STOP_E, STOP_F, STOP_G, STOP_H) .times("10:13 10:18 10:24 10:30 10:36 10:40") .build(); @@ -139,8 +137,7 @@ private void doTest( TransferPriority expPriority, String expItinerary ) { - var original = OptimizePathDomainServiceTest - .pathBuilder() + var original = OptimizePathDomainServiceTest.pathBuilder() .access(START_TIME_T1, STOP_A) .bus(trip1, STOP_B) .walk(D1m, STOP_C) diff --git a/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/services/OptimizePathDomainServiceTest.java b/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/services/OptimizePathDomainServiceTest.java index 6a023138751..74e8e2ea7c5 100644 --- a/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/services/OptimizePathDomainServiceTest.java +++ b/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/services/OptimizePathDomainServiceTest.java @@ -38,18 +38,11 @@ public class OptimizePathDomainServiceTest implements RaptorTestConstants { ALIGHT_SLACK ); - public static final RaptorCostCalculator COST_CALCULATOR = new DefaultCostCalculator<>( - BOARD_COST_SEC, - TRANSFER_COST_SEC, - WAIT_RELUCTANCE, - null, - null - ); + public static final RaptorCostCalculator COST_CALCULATOR = + new DefaultCostCalculator<>(BOARD_COST_SEC, TRANSFER_COST_SEC, WAIT_RELUCTANCE, null, null); - private static final TransferWaitTimeCostCalculator TRANS_WAIT_TIME_CALC = new TransferWaitTimeCostCalculator( - 1.0, - 2.0 - ); + private static final TransferWaitTimeCostCalculator TRANS_WAIT_TIME_CALC = + new TransferWaitTimeCostCalculator(1.0, 2.0); static { TRANS_WAIT_TIME_CALC.setMinSafeTransferTime(D5m); @@ -61,8 +54,7 @@ public class OptimizePathDomainServiceTest implements RaptorTestConstants { @Test public void testTripWithoutTransfers() { // Given a trip A-B-C-D - var trip1 = TestTripSchedule - .schedule() + var trip1 = TestTripSchedule.schedule() .pattern("T1", STOP_A, STOP_B, STOP_C, STOP_D) .times("10:02 10:10 10:20 10:30") .build(); @@ -97,15 +89,13 @@ public void testTripWithoutTransfers() { @Test public void testTripWithOneTransfer() { // Given - var trip1 = TestTripSchedule - .schedule() + var trip1 = TestTripSchedule.schedule() .arrDepOffset(D0s) .pattern("T1", STOP_A, STOP_B, STOP_C, STOP_D) .times("10:02 10:10 10:20 10:30") .build(); - var trip2 = TestTripSchedule - .schedule() + var trip2 = TestTripSchedule.schedule() .arrDepOffset(D0s) .pattern("T2", STOP_E, STOP_F, STOP_G) .times("10:12 10:22 10:50") @@ -148,20 +138,17 @@ public void testTripWithOneTransfer() { @Test public void testPathWithThreeTripsAndMultiplePlacesToTransfer() { // Given - var trip1 = TestTripSchedule - .schedule() + var trip1 = TestTripSchedule.schedule() .pattern("T1", STOP_A, STOP_B, STOP_D) .times("10:02 10:10 10:20") .build(); - var trip2 = TestTripSchedule - .schedule() + var trip2 = TestTripSchedule.schedule() .pattern("T2", STOP_B, STOP_C, STOP_D, STOP_F) .times("10:12 10:15 10:22 10:35") .build(); - var trip3 = TestTripSchedule - .schedule() + var trip3 = TestTripSchedule.schedule() .pattern("T3", STOP_E, STOP_F, STOP_G) .times("10:24 10:37 10:49") .build(); @@ -229,14 +216,12 @@ public void testPathWithThreeTripsAndMultiplePlacesToTransfer() { @Test public void testConstrainedTransferIsPreferred() { // Given - var trip1 = TestTripSchedule - .schedule() + var trip1 = TestTripSchedule.schedule() .pattern("T1", STOP_A, STOP_B, STOP_C) .times("10:02 10:10 10:15") .build(); - var trip2 = TestTripSchedule - .schedule() + var trip2 = TestTripSchedule.schedule() .pattern("T2", STOP_B, STOP_C, STOP_D) .times("10:13 10:17 10:30") .build(); @@ -289,14 +274,12 @@ public void testConstrainedTransferIsPreferred() { @Test public void testSameStopTimesInPattern() { // Given - var trip1 = TestTripSchedule - .schedule() + var trip1 = TestTripSchedule.schedule() .pattern("T1", STOP_A, STOP_B, STOP_C) .times("10:10 10:10 10:15") .build(); - var trip2 = TestTripSchedule - .schedule() + var trip2 = TestTripSchedule.schedule() .pattern("T2", STOP_B, STOP_C, STOP_D) .times("10:13 10:13 10:30") .build(); @@ -345,8 +328,7 @@ static OptimizePathDomainService subject( var filter = new MinCostPathTailFilterFactory( true, waitTimeCalculator != null - ) - .createFilter(); + ).createFilter(); return new OptimizePathDomainService<>( generator, COST_CALCULATOR, diff --git a/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/services/TestTransferBuilder.java b/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/services/TestTransferBuilder.java index 71257dd974c..3da205f2f04 100644 --- a/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/services/TestTransferBuilder.java +++ b/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/services/TestTransferBuilder.java @@ -154,9 +154,9 @@ public TripToTripTransfer build() { private static Trip createDummyTrip(T trip) { // Set an uniq id: pattern + the first stop departure time - return TimetableRepositoryForTest - .trip(trip.pattern().debugInfo() + ":" + TimeUtils.timeToStrCompact(trip.departure(0))) - .build(); + return TimetableRepositoryForTest.trip( + trip.pattern().debugInfo() + ":" + TimeUtils.timeToStrCompact(trip.departure(0)) + ).build(); } private ConstrainedTransfer buildConstrainedTransfer() { diff --git a/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/services/TransferGeneratorTest.java b/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/services/TransferGeneratorTest.java index 97efb583483..9f07dd460d4 100644 --- a/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/services/TransferGeneratorTest.java +++ b/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/services/TransferGeneratorTest.java @@ -54,8 +54,9 @@ public class TransferGeneratorTest implements RaptorTestConstants { @Test void findTransferPathWithoutTransfers() { data.withRoutes( - route(TestTripPattern.pattern("L1", STOP_A, STOP_B, STOP_C).withSlackIndex(1)) - .withTimetable(schedule("10:00 10:20 10:30")) + route(TestTripPattern.pattern("L1", STOP_A, STOP_B, STOP_C).withSlackIndex(1)).withTimetable( + schedule("10:00 10:20 10:30") + ) ); var schedule = data.getRoute(0).getTripSchedule(0); @@ -74,8 +75,10 @@ void findTransferPathWithoutTransfers() { @Test void findTransferForTheSameRoute() { data.withRoutes( - route("L1", STOP_A, STOP_B, STOP_C, STOP_D) - .withTimetable(schedule("10:02 10:10 10:20 10:30"), schedule("10:04 10:12 10:22 10:32")) + route("L1", STOP_A, STOP_B, STOP_C, STOP_D).withTimetable( + schedule("10:02 10:10 10:20 10:30"), + schedule("10:04 10:12 10:22 10:32") + ) ); // The only possible place to transfer between A and C is stop B: @@ -148,10 +151,12 @@ void findGuaranteedTransferWithNoSlack() { @Test void findTransferForDifferentRoutes() { - TestRoute l1 = route("L1", STOP_A, STOP_B, STOP_C, STOP_D) - .withTimetable(schedule("10:02 10:10 10:20 10:30")); - TestRoute l2 = route("L2", STOP_E, STOP_C, STOP_F, STOP_G) - .withTimetable(schedule("10:12 10:22 10:32 10:40")); + TestRoute l1 = route("L1", STOP_A, STOP_B, STOP_C, STOP_D).withTimetable( + schedule("10:02 10:10 10:20 10:30") + ); + TestRoute l2 = route("L2", STOP_E, STOP_C, STOP_F, STOP_G).withTimetable( + schedule("10:12 10:22 10:32 10:40") + ); // S data @@ -180,8 +185,9 @@ void findTransferForDifferentRoutes() { void findTransfersForCircularLine1() { var l1 = route("L1", STOP_A, STOP_C, STOP_D).withTimetable(schedule("10:02 10:10 10:20")); // Passing same stop two times - var l2 = route("L2", STOP_D, STOP_E, STOP_D, STOP_F) - .withTimetable(schedule("10:30 10:40 10:50 11:00")); + var l2 = route("L2", STOP_D, STOP_E, STOP_D, STOP_F).withTimetable( + schedule("10:30 10:40 10:50 11:00") + ); data.withRoutes(l1, l2); @@ -203,8 +209,9 @@ void findTransfersForCircularLine1() { void findTransfersForCircularLine2() { var l1 = route("L1", STOP_A, STOP_C, STOP_D).withTimetable(schedule("10:02 10:10 10:20")); // Passing same stop two times - var l2 = route("L2", STOP_E, STOP_F, STOP_E, STOP_G) - .withTimetable(schedule("10:30 10:40 10:50 11:00")); + var l2 = route("L2", STOP_E, STOP_F, STOP_E, STOP_G).withTimetable( + schedule("10:30 10:40 10:50 11:00") + ); data.withRoutes(l1, l2).withTransfer(STOP_D, TestTransfers.transfer(STOP_E, D1m)); @@ -238,8 +245,9 @@ void findTransfersForCircularLine2() { void findTransfersForCircularLine3() { var l1 = route("L1", STOP_A, STOP_C, STOP_D).withTimetable(schedule("10:02 10:10 10:20")); // Passing same stop two times - var l2 = route("L2", STOP_D, STOP_E, STOP_D, STOP_F) - .withTimetable(schedule("10:10 10:20 10:30 10:40")); + var l2 = route("L2", STOP_D, STOP_E, STOP_D, STOP_F).withTimetable( + schedule("10:10 10:20 10:30 10:40") + ); data.withRoutes(l1, l2); @@ -287,8 +295,9 @@ void findTransfersForCircularLine4() { void findTransfersForCircularLine5() { var l1 = route("L1", STOP_A, STOP_C, STOP_D).withTimetable(schedule("10:02 10:10 10:20")); // Passing same stop two times - var l2 = route("L2", STOP_E, STOP_F, STOP_E, STOP_G) - .withTimetable(schedule("10:30 10:40 10:50 11:00")); + var l2 = route("L2", STOP_E, STOP_F, STOP_E, STOP_G).withTimetable( + schedule("10:30 10:40 10:50 11:00") + ); data.withRoutes(l1, l2).withTransfer(STOP_D, TestTransfers.transfer(STOP_E, D1m)); @@ -325,8 +334,9 @@ void findTransfersForCircularLine5() { void findTransfersForCircularLine6() { var l1 = route("L1", STOP_A, STOP_C, STOP_D).withTimetable(schedule("10:02 10:10 10:20")); // Passing same stop two times - var l2 = route("L2", STOP_D, STOP_E, STOP_F, STOP_D) - .withTimetable(schedule("10:30 10:40 10:50 11:00")); + var l2 = route("L2", STOP_D, STOP_E, STOP_F, STOP_D).withTimetable( + schedule("10:30 10:40 10:50 11:00") + ); data.withRoutes(l1, l2); @@ -529,8 +539,7 @@ void includeTransferSlackInMinimumTransferTime( var tripA = l1.getTripSchedule(0); var tripB = l2.getTripSchedule(0); - var constraint = TransferConstraint - .of() + var constraint = TransferConstraint.of() .minTransferTime((int) minTransferTime.getSeconds()) .build(); data.withConstrainedTransfer(tripA, STOP_B, tripB, STOP_B, constraint); @@ -549,9 +558,8 @@ void includeTransferSlackInMinimumTransferTime( result.toString() ); } else { - Assertions.assertThrows( - RuntimeException.class, - () -> subject.findAllPossibleTransfers(transitLegs) + Assertions.assertThrows(RuntimeException.class, () -> + subject.findAllPossibleTransfers(transitLegs) ); } } @@ -601,11 +609,13 @@ private void testThatThereIsNoTransferAtStopB(TransferConstraint transfer) { "TripToTripTransfer{from: [3 10:20 BUS L1], to: [4 10:30 BUS L2], transfer: WALK 1m $120 ~ 4}"; var expExE = "TripToTripTransfer{from: [5 10:30 BUS L1], to: [5 10:40 BUS L2]}"; - var l1 = route("L1", STOP_A, STOP_B, STOP_C, STOP_E) - .withTimetable(schedule("10:00 10:10 10:20 10:30")); + var l1 = route("L1", STOP_A, STOP_B, STOP_C, STOP_E).withTimetable( + schedule("10:00 10:10 10:20 10:30") + ); - var l2 = route("L2", STOP_B, STOP_D, STOP_E, STOP_F) - .withTimetable(schedule("10:20 10:30 10:40 10:50")); + var l2 = route("L2", STOP_B, STOP_D, STOP_E, STOP_F).withTimetable( + schedule("10:20 10:30 10:40 10:50") + ); data.withRoutes(l1, l2).withTransfer(STOP_C, TestTransfers.transfer(STOP_D, D1m)); diff --git a/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/services/TransitPathLegSelectorTest.java b/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/services/TransitPathLegSelectorTest.java index e3b95bb07a1..ee79d0db7f0 100644 --- a/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/services/TransitPathLegSelectorTest.java +++ b/application/src/test/java/org/opentripplanner/routing/algorithm/transferoptimization/services/TransitPathLegSelectorTest.java @@ -30,17 +30,11 @@ public class TransitPathLegSelectorTest implements RaptorTestConstants { ALIGHT_SLACK ); - private static final RaptorCostCalculator COST_CALCULATOR = new DefaultCostCalculator<>( - 20, - 60, - 1.0, - null, - null - ); + private static final RaptorCostCalculator COST_CALCULATOR = + new DefaultCostCalculator<>(20, 60, 1.0, null, null); - public static final PathTailFilter FILTER_CHAIN = MinCostPathTailFilterFactory.ofCostFunction( - OptimizedPathTail::generalizedCost - ); + public static final PathTailFilter FILTER_CHAIN = + MinCostPathTailFilterFactory.ofCostFunction(OptimizedPathTail::generalizedCost); private final int STOP_TIME_ONE = TimeUtils.time("10:00"); private final int STOP_TIME_TWO = TimeUtils.time("10:20"); @@ -60,8 +54,7 @@ public class TransitPathLegSelectorTest implements RaptorTestConstants { this::stopIndexToName ); - private final TestTripSchedule TRIP = TestTripSchedule - .schedule() + private final TestTripSchedule TRIP = TestTripSchedule.schedule() .pattern("L1", STOP_A, STOP_C, STOP_E) .times(STOP_TIME_ONE, STOP_TIME_TWO, STOP_TIME_THREE) .build(); diff --git a/application/src/test/java/org/opentripplanner/routing/algorithm/via/ViaRoutingWorkerTest.java b/application/src/test/java/org/opentripplanner/routing/algorithm/via/ViaRoutingWorkerTest.java index c11b25d4ac3..5d611de7bf9 100644 --- a/application/src/test/java/org/opentripplanner/routing/algorithm/via/ViaRoutingWorkerTest.java +++ b/application/src/test/java/org/opentripplanner/routing/algorithm/via/ViaRoutingWorkerTest.java @@ -146,8 +146,7 @@ public RouteViaRequest createRouteViaRequest() { var viaJourneys = List.of(new JourneyRequest(), new JourneyRequest()); - return RouteViaRequest - .of(viaLocations, viaJourneys) + return RouteViaRequest.of(viaLocations, viaJourneys) .withDateTime(dateTime) .withFrom(location(fromA)) .withTo(location(toB)) @@ -160,21 +159,26 @@ public RouteViaRequest createRouteViaRequest() { */ void createItinieraries() { // Arrive 13 - s1i1 = - newItinerary(fromA).bus(1, TimeUtils.hm2time(12, 0), TimeUtils.hm2time(13, 0), viaC).build(); + s1i1 = newItinerary(fromA) + .bus(1, TimeUtils.hm2time(12, 0), TimeUtils.hm2time(13, 0), viaC) + .build(); // Arrive 14 - s1i2 = - newItinerary(fromA).bus(2, TimeUtils.hm2time(12, 0), TimeUtils.hm2time(14, 0), viaC).build(); + s1i2 = newItinerary(fromA) + .bus(2, TimeUtils.hm2time(12, 0), TimeUtils.hm2time(14, 0), viaC) + .build(); // departure 13:15 - s2i1 = - newItinerary(viaC).bus(3, TimeUtils.hm2time(13, 15), TimeUtils.hm2time(15, 0), toB).build(); + s2i1 = newItinerary(viaC) + .bus(3, TimeUtils.hm2time(13, 15), TimeUtils.hm2time(15, 0), toB) + .build(); // departure 13:45 - s2i2 = - newItinerary(viaC).bus(3, TimeUtils.hm2time(13, 45), TimeUtils.hm2time(15, 0), toB).build(); + s2i2 = newItinerary(viaC) + .bus(3, TimeUtils.hm2time(13, 45), TimeUtils.hm2time(15, 0), toB) + .build(); // departure 14:30 - s2i3 = - newItinerary(viaC).bus(3, TimeUtils.hm2time(14, 30), TimeUtils.hm2time(15, 0), toB).build(); + s2i3 = newItinerary(viaC) + .bus(3, TimeUtils.hm2time(14, 30), TimeUtils.hm2time(15, 0), toB) + .build(); firstSearch = List.of(s1i1, s1i2); secondSearch = List.of(s2i1, s2i2, s2i3); diff --git a/application/src/test/java/org/opentripplanner/routing/api/request/WheelchairPreferencesTest.java b/application/src/test/java/org/opentripplanner/routing/api/request/WheelchairPreferencesTest.java index 9dd533704c7..f6d740193a2 100644 --- a/application/src/test/java/org/opentripplanner/routing/api/request/WheelchairPreferencesTest.java +++ b/application/src/test/java/org/opentripplanner/routing/api/request/WheelchairPreferencesTest.java @@ -24,8 +24,7 @@ static Stream roundingTestCases() { ) @MethodSource("roundingTestCases") void testConstructorNormalization(double raw, double rounded2, double rounded3) { - var roundedRequest = WheelchairPreferences - .of() + var roundedRequest = WheelchairPreferences.of() .withTripOnlyAccessible() .withStopOnlyAccessible() .withElevatorOnlyAccessible() @@ -61,8 +60,7 @@ static Stream toStringTestCases() { "WheelchairPreferences{trip: AccessibilityPreferences{unknownCost: $99, inaccessibleCost: $100}}" ), Arguments.of( - WheelchairPreferences - .of() + WheelchairPreferences.of() .withTripCost(10, 100) .withStopCost(20, 200) .withElevatorCost(30, 300) diff --git a/application/src/test/java/org/opentripplanner/routing/api/request/framework/CostLinearFunctionTest.java b/application/src/test/java/org/opentripplanner/routing/api/request/framework/CostLinearFunctionTest.java index 8d972896878..8b6dc72c244 100644 --- a/application/src/test/java/org/opentripplanner/routing/api/request/framework/CostLinearFunctionTest.java +++ b/application/src/test/java/org/opentripplanner/routing/api/request/framework/CostLinearFunctionTest.java @@ -38,9 +38,8 @@ void parsePenaltyRandomInputNotAllowed() { @Test void negativeDurationNotAllowed() { assertThrows(IllegalArgumentException.class, () -> CostLinearFunction.of("-2m + 1.0 t")); - assertThrows( - IllegalArgumentException.class, - () -> CostLinearFunction.of(DurationUtils.duration("-2m"), 1.0) + assertThrows(IllegalArgumentException.class, () -> + CostLinearFunction.of(DurationUtils.duration("-2m"), 1.0) ); } @@ -54,9 +53,8 @@ void emptyInputNotAllowed() { @Test void parsePenaltyTimeCoefficientMustBeAtLeastZeroAndLessThanTen() { assertThrows(IllegalArgumentException.class, () -> CostLinearFunction.of(D2m, -0.01)); - var ex = assertThrows( - IllegalArgumentException.class, - () -> CostLinearFunction.of(Duration.ZERO, 100.1) + var ex = assertThrows(IllegalArgumentException.class, () -> + CostLinearFunction.of(Duration.ZERO, 100.1) ); assertEquals("The value is not in range[0.0, 100.0]: 100.1", ex.getMessage()); } diff --git a/application/src/test/java/org/opentripplanner/routing/api/request/framework/DurationForEnumTest.java b/application/src/test/java/org/opentripplanner/routing/api/request/framework/DurationForEnumTest.java index dc729bdaa22..b47a0ecc2a6 100644 --- a/application/src/test/java/org/opentripplanner/routing/api/request/framework/DurationForEnumTest.java +++ b/application/src/test/java/org/opentripplanner/routing/api/request/framework/DurationForEnumTest.java @@ -20,8 +20,7 @@ class DurationForEnumTest { private static final Duration DEFAULT = Duration.ofSeconds(7); private static final Duration WALK_VALUE = Duration.ofSeconds(3); - private final DurationForEnum subject = DurationForEnum - .of(StreetMode.class) + private final DurationForEnum subject = DurationForEnum.of(StreetMode.class) .withDefault(DEFAULT) .withValues(Map.of(StreetMode.WALK, WALK_VALUE)) .build(); @@ -33,8 +32,7 @@ void testToString() { // Assert modes are in order of the enum ordinal assertEquals( "DurationForStreetMode{default:7s, BIKE:3s, SCOOTER_RENTAL:1s, CAR:4s, FLEXIBLE:2s}", - DurationForEnum - .of(StreetMode.class) + DurationForEnum.of(StreetMode.class) .withDefault(DEFAULT) .withValues(Map.of(StreetMode.SCOOTER_RENTAL, Duration.ofSeconds(1))) .withValues(Map.of(StreetMode.CAR, Duration.ofSeconds(4))) @@ -50,9 +48,8 @@ void defaultValue() { assertEquals(DEFAULT, subject.defaultValue()); assertEquals(DEFAULT.toSeconds(), subject.defaultValueSeconds()); - assertThrows( - NullPointerException.class, - () -> DurationForEnum.of(StreetMode.class).withDefault(null).build() + assertThrows(NullPointerException.class, () -> + DurationForEnum.of(StreetMode.class).withDefault(null).build() ); } @@ -70,8 +67,7 @@ void isSet() { @Test void equalsAndHashCode() { - var sameValue = DurationForEnum - .of(StreetMode.class) + var sameValue = DurationForEnum.of(StreetMode.class) .withDefault(DEFAULT) .with(StreetMode.WALK, WALK_VALUE) .build(); @@ -113,8 +109,10 @@ void copyOf() { assertEquals(D10s, copy.valueOf(StreetMode.WALK)); // with no "real" changes -> return original - copy = - subject.copyOf().apply(b -> b.withDefault(DEFAULT).with(StreetMode.WALK, WALK_VALUE)).build(); + copy = subject + .copyOf() + .apply(b -> b.withDefault(DEFAULT).with(StreetMode.WALK, WALK_VALUE)) + .build(); assertSame(subject, copy); } } diff --git a/application/src/test/java/org/opentripplanner/routing/api/request/framework/LinearFunctionSerializationTest.java b/application/src/test/java/org/opentripplanner/routing/api/request/framework/LinearFunctionSerializationTest.java index dbb33e1f97b..0cf767a0609 100644 --- a/application/src/test/java/org/opentripplanner/routing/api/request/framework/LinearFunctionSerializationTest.java +++ b/application/src/test/java/org/opentripplanner/routing/api/request/framework/LinearFunctionSerializationTest.java @@ -24,21 +24,21 @@ class LinearFunctionSerializationTest { static Stream parseTestCases() { return TestTableParser.of( """ - # INPUT || EXPECTED - # || CONSTANT | COEFFICIENT - 0+0t || 0s | 0.0 - 1+0.0111 t || 1s | 0.01 - 120 + 0.111 t || 2m | 0.11 - 120 + 0.111 t || 2m | 0.11 - 12.0 + 0 t || 12s | 0.0 - 2h3m + 1.111 t || 2h3m | 1.11 - 2h3m + 2.111 t || 2h3m | 2.1 - 3h + 5.111 t || 3h | 5.1 - 7m + 10.1 x || 7m | 10.0 - PT7s + 10.1 x || 7s | 10.0 - 0.1 + 10.1 x || 0s | 10.0 - 0.5 + 10.1 x || 1s | 10.0 - """ + # INPUT || EXPECTED + # || CONSTANT | COEFFICIENT + 0+0t || 0s | 0.0 + 1+0.0111 t || 1s | 0.01 + 120 + 0.111 t || 2m | 0.11 + 120 + 0.111 t || 2m | 0.11 + 12.0 + 0 t || 12s | 0.0 + 2h3m + 1.111 t || 2h3m | 1.11 + 2h3m + 2.111 t || 2h3m | 2.1 + 3h + 5.111 t || 3h | 5.1 + 7m + 10.1 x || 7m | 10.0 + PT7s + 10.1 x || 7s | 10.0 + 0.1 + 10.1 x || 0s | 10.0 + 0.5 + 10.1 x || 1s | 10.0 + """ ); } @@ -72,18 +72,16 @@ void serialize() { @Test void parseIllegalArgument() { - var ex = assertThrows( - IllegalArgumentException.class, - () -> LinearFunctionSerialization.parse("foo", fail()) + var ex = assertThrows(IllegalArgumentException.class, () -> + LinearFunctionSerialization.parse("foo", fail()) ); assertEquals("Unable to parse function: 'foo'", ex.getMessage()); } @Test void parseIllegalDuration() { - var ex = assertThrows( - IllegalArgumentException.class, - () -> LinearFunctionSerialization.parse("600ss + 1.3 t", fail()) + var ex = assertThrows(IllegalArgumentException.class, () -> + LinearFunctionSerialization.parse("600ss + 1.3 t", fail()) ); assertEquals("Unable to parse duration: '600ss'", ex.getMessage()); } diff --git a/application/src/test/java/org/opentripplanner/routing/api/request/framework/TimeAndCostPenaltyForEnumTest.java b/application/src/test/java/org/opentripplanner/routing/api/request/framework/TimeAndCostPenaltyForEnumTest.java index 26279eb265b..6704a460808 100644 --- a/application/src/test/java/org/opentripplanner/routing/api/request/framework/TimeAndCostPenaltyForEnumTest.java +++ b/application/src/test/java/org/opentripplanner/routing/api/request/framework/TimeAndCostPenaltyForEnumTest.java @@ -16,8 +16,7 @@ class TimeAndCostPenaltyForEnumTest { "11s + 1.2t", COST_FACTOR ); - private final TimeAndCostPenaltyForEnum subject = TimeAndCostPenaltyForEnum - .of(Fish.class) + private final TimeAndCostPenaltyForEnum subject = TimeAndCostPenaltyForEnum.of(Fish.class) .with(Fish.PERCH, PERCH_PENALTY) .build(); @@ -60,8 +59,7 @@ void testToString() { @Test void testEqualsAndHashCode() { var same = TimeAndCostPenaltyForEnum.of(Fish.class).with(Fish.PERCH, PERCH_PENALTY).build(); - var other = TimeAndCostPenaltyForEnum - .of(Fish.class) + var other = TimeAndCostPenaltyForEnum.of(Fish.class) .with(Fish.COD, new TimeAndCostPenalty(TimePenalty.of("1s + 1.0 t"), 1.5)) .build(); @@ -76,8 +74,7 @@ void testEqualsAndHashCode() { @Test void testOf() { - var c = TimeAndCostPenaltyForEnum - .of(Fish.class) + var c = TimeAndCostPenaltyForEnum.of(Fish.class) .with(Fish.COD, TimeAndCostPenalty.of("1s + 3t", 0.2)) .build(); assertEquals( @@ -96,8 +93,7 @@ void testBuilderWithRemoveExistingValue() { @Test void testBuilderWithMap() { - var c = TimeAndCostPenaltyForEnum - .of(Fish.class) + var c = TimeAndCostPenaltyForEnum.of(Fish.class) .withValues(Map.of(Fish.PERCH, TimeAndCostPenalty.of("2s + 4t", 2.0))) .build(); @@ -109,8 +105,7 @@ void testBuilderWithMap() { @Test void testBuildApply() { - var c = TimeAndCostPenaltyForEnum - .of(Fish.class) + var c = TimeAndCostPenaltyForEnum.of(Fish.class) .apply(b -> b.with(Fish.PERCH, TimeAndCostPenalty.of("3s + 5t", 0.1))) .build(); diff --git a/application/src/test/java/org/opentripplanner/routing/api/request/framework/TimePenaltyTest.java b/application/src/test/java/org/opentripplanner/routing/api/request/framework/TimePenaltyTest.java index 7321653192e..e26dad5e33d 100644 --- a/application/src/test/java/org/opentripplanner/routing/api/request/framework/TimePenaltyTest.java +++ b/application/src/test/java/org/opentripplanner/routing/api/request/framework/TimePenaltyTest.java @@ -28,18 +28,15 @@ void parsePenaltyRandomInputNotAllowed() { @Test void negativeDurationNotAllowed() { assertThrows(IllegalArgumentException.class, () -> TimePenalty.of("-2m + 1.0 t")); - assertThrows( - IllegalArgumentException.class, - () -> TimePenalty.of(DurationUtils.duration("-2m"), 1.0) + assertThrows(IllegalArgumentException.class, () -> + TimePenalty.of(DurationUtils.duration("-2m"), 1.0) ); } @Test void parsePenaltyTimeCoefficientMustBeAtLeastZeroAndLessThanTen() { assertThrows(IllegalArgumentException.class, () -> TimePenalty.of(D2m, -0.01)); - var ex = assertThrows( - IllegalArgumentException.class, - () -> TimePenalty.of(Duration.ZERO, 100.1) + var ex = assertThrows(IllegalArgumentException.class, () -> TimePenalty.of(Duration.ZERO, 100.1) ); assertEquals("The value is not in range[0.0, 100.0]: 100.1", ex.getMessage()); } diff --git a/application/src/test/java/org/opentripplanner/routing/api/request/preference/AccessEgressPreferencesTest.java b/application/src/test/java/org/opentripplanner/routing/api/request/preference/AccessEgressPreferencesTest.java index 13fc9a60da9..3e6eb52530c 100644 --- a/application/src/test/java/org/opentripplanner/routing/api/request/preference/AccessEgressPreferencesTest.java +++ b/application/src/test/java/org/opentripplanner/routing/api/request/preference/AccessEgressPreferencesTest.java @@ -21,8 +21,7 @@ public class AccessEgressPreferencesTest { 3.5 ); - private final AccessEgressPreferences subject = AccessEgressPreferences - .of() + private final AccessEgressPreferences subject = AccessEgressPreferences.of() .withPenalty(Map.of(StreetMode.CAR_TO_PARK, CAR_TO_PARK_PENALTY)) .withMaxDuration(MAX_ACCESS_EGRESS, Map.of()) .withMaxStopCount(MAX_DEFAULT_STOP_COUNT, Map.of(StreetMode.CAR, MAX_CAR_STOP_COUNT)) diff --git a/application/src/test/java/org/opentripplanner/routing/api/request/preference/AccessibilityPreferencesTest.java b/application/src/test/java/org/opentripplanner/routing/api/request/preference/AccessibilityPreferencesTest.java index ae7562cd6ef..0be416da9a2 100644 --- a/application/src/test/java/org/opentripplanner/routing/api/request/preference/AccessibilityPreferencesTest.java +++ b/application/src/test/java/org/opentripplanner/routing/api/request/preference/AccessibilityPreferencesTest.java @@ -13,7 +13,8 @@ class AccessibilityPreferencesTest { public static final int UNKNOWN_COST = 190; public static final int INACCESSIBLE_COST = 350; - private final AccessibilityPreferences subjectOnlyAccessible = AccessibilityPreferences.ofOnlyAccessible(); + private final AccessibilityPreferences subjectOnlyAccessible = + AccessibilityPreferences.ofOnlyAccessible(); private final AccessibilityPreferences subject = AccessibilityPreferences.ofCost( UNKNOWN_COST, INACCESSIBLE_COST diff --git a/application/src/test/java/org/opentripplanner/routing/api/request/preference/BikePreferencesTest.java b/application/src/test/java/org/opentripplanner/routing/api/request/preference/BikePreferencesTest.java index 3bbaf0105e5..e7c1566604a 100644 --- a/application/src/test/java/org/opentripplanner/routing/api/request/preference/BikePreferencesTest.java +++ b/application/src/test/java/org/opentripplanner/routing/api/request/preference/BikePreferencesTest.java @@ -12,8 +12,7 @@ class BikePreferencesTest { public static final double SPEED = 2.0; public static final double RELUCTANCE = 1.2; public static final int BOARD_COST = 660; - public static final TimeSlopeSafetyTriangle TRIANGLE = TimeSlopeSafetyTriangle - .of() + public static final TimeSlopeSafetyTriangle TRIANGLE = TimeSlopeSafetyTriangle.of() .withSlope(1) .build(); public static final VehicleRoutingOptimizeType OPTIMIZE_TYPE = @@ -21,8 +20,7 @@ class BikePreferencesTest { public static final int RENTAL_PICKUP_TIME = 30; public static final int PARK_COST = 30; - private final BikePreferences subject = BikePreferences - .of() + private final BikePreferences subject = BikePreferences.of() .withSpeed(SPEED) .withReluctance(RELUCTANCE) .withBoardCost(BOARD_COST) @@ -103,21 +101,18 @@ void testToString() { @Test void testForcedTriangleOptimization() { - var trianglePreferences = BikePreferences - .of() + var trianglePreferences = BikePreferences.of() .withForcedOptimizeTriangle(it -> it.withSlope(1).build()) .build(); assertEquals(VehicleRoutingOptimizeType.TRIANGLE, trianglePreferences.optimizeType()); - var conflictingPreferences = BikePreferences - .of() + var conflictingPreferences = BikePreferences.of() .withOptimizeType(VehicleRoutingOptimizeType.SAFE_STREETS) .withForcedOptimizeTriangle(it -> it.withSlope(1).build()) .build(); assertEquals(VehicleRoutingOptimizeType.TRIANGLE, conflictingPreferences.optimizeType()); - var emptyTrianglePreferences = BikePreferences - .of() + var emptyTrianglePreferences = BikePreferences.of() .withOptimizeType(VehicleRoutingOptimizeType.SAFE_STREETS) .withForcedOptimizeTriangle(it -> it.build()) .build(); diff --git a/application/src/test/java/org/opentripplanner/routing/api/request/preference/CarPreferencesTest.java b/application/src/test/java/org/opentripplanner/routing/api/request/preference/CarPreferencesTest.java index 564baa0330d..636f7a66107 100644 --- a/application/src/test/java/org/opentripplanner/routing/api/request/preference/CarPreferencesTest.java +++ b/application/src/test/java/org/opentripplanner/routing/api/request/preference/CarPreferencesTest.java @@ -20,8 +20,7 @@ class CarPreferencesTest { public static final int RENTAL_PICKUP_TIME = 30; public static final int PARK_COST = 30; - private final CarPreferences subject = CarPreferences - .of() + private final CarPreferences subject = CarPreferences.of() .withReluctance(RELUCTANCE) .withBoardCost(BOARD_COST) .withPickupTime(Duration.ofSeconds(PICKUP_TIME)) diff --git a/application/src/test/java/org/opentripplanner/routing/api/request/preference/ElevatorPreferencesTest.java b/application/src/test/java/org/opentripplanner/routing/api/request/preference/ElevatorPreferencesTest.java index 3a5d243466d..96dfbcee299 100644 --- a/application/src/test/java/org/opentripplanner/routing/api/request/preference/ElevatorPreferencesTest.java +++ b/application/src/test/java/org/opentripplanner/routing/api/request/preference/ElevatorPreferencesTest.java @@ -12,8 +12,7 @@ class ElevatorPreferencesTest { public static final int BOARD_TIME = 60; public static final int HOP_COST = 200; public static final int HOP_TIME = 120; - private final ElevatorPreferences subject = ElevatorPreferences - .of() + private final ElevatorPreferences subject = ElevatorPreferences.of() .withBoardCost(BOARD_COST) .withBoardTime(BOARD_TIME) .withHopCost(HOP_COST) diff --git a/application/src/test/java/org/opentripplanner/routing/api/request/preference/ItineraryFilterPreferencesTest.java b/application/src/test/java/org/opentripplanner/routing/api/request/preference/ItineraryFilterPreferencesTest.java index 4c1403b0b0f..c2ba69c516b 100644 --- a/application/src/test/java/org/opentripplanner/routing/api/request/preference/ItineraryFilterPreferencesTest.java +++ b/application/src/test/java/org/opentripplanner/routing/api/request/preference/ItineraryFilterPreferencesTest.java @@ -19,22 +19,17 @@ class ItineraryFilterPreferencesTest { private static final double GROUP_SIMILARITY_KEEP_ONE = 0.8; private static final double GROUP_SIMILARITY_KEEP_THREE = 0.5; private static final double MIN_BIKE_PARKING_DISTANCE = 2000.0; - private static final CostLinearFunction NON_TRANSIT_GENERALIZED_COST_LIMIT = CostLinearFunction.of( - Duration.ofSeconds(4), - 5.0 - ); + private static final CostLinearFunction NON_TRANSIT_GENERALIZED_COST_LIMIT = + CostLinearFunction.of(Duration.ofSeconds(4), 5.0); private static final double PARK_AND_RIDE_DURATION_RATIO = 0.44; - private static final TransitGeneralizedCostFilterParams TRANSIT_GENERALIZED_COST_LIMIT = new TransitGeneralizedCostFilterParams( - CostLinearFunction.of(Duration.ofSeconds(4), 5.0), - 3.0 - ); + private static final TransitGeneralizedCostFilterParams TRANSIT_GENERALIZED_COST_LIMIT = + new TransitGeneralizedCostFilterParams(CostLinearFunction.of(Duration.ofSeconds(4), 5.0), 3.0); private static final CostLinearFunction TRANSIT_BEST_STREET_COST_LIMIT = CostLinearFunction.of( Duration.ofSeconds(30), 1.3 ); - private final ItineraryFilterPreferences subject = ItineraryFilterPreferences - .of() + private final ItineraryFilterPreferences subject = ItineraryFilterPreferences.of() .withAccessibilityScore(ACCESSIBILITY_SCORE) .withBikeRentalDistanceRatio(BIKE_RENTAL_DISTANCE_RATIO) .withDebug(DEBUG) diff --git a/application/src/test/java/org/opentripplanner/routing/api/request/preference/MaxStopCountLimitTest.java b/application/src/test/java/org/opentripplanner/routing/api/request/preference/MaxStopCountLimitTest.java index 0291b5f39dd..3be4327945a 100644 --- a/application/src/test/java/org/opentripplanner/routing/api/request/preference/MaxStopCountLimitTest.java +++ b/application/src/test/java/org/opentripplanner/routing/api/request/preference/MaxStopCountLimitTest.java @@ -13,8 +13,7 @@ public class MaxStopCountLimitTest { private static final int MAX_DEFAULT_STOP_COUNT = 245; private static final int MAX_CAR_STOP_COUNT = 0; - private final MaxStopCountLimit subject = MaxStopCountLimit - .of() + private final MaxStopCountLimit subject = MaxStopCountLimit.of() .withDefaultLimit(MAX_DEFAULT_STOP_COUNT) .withLimitsForModes(Map.of(StreetMode.CAR, MAX_CAR_STOP_COUNT)) .build(); diff --git a/application/src/test/java/org/opentripplanner/routing/api/request/preference/RaptorPreferencesTest.java b/application/src/test/java/org/opentripplanner/routing/api/request/preference/RaptorPreferencesTest.java index 2894e1a1ae0..20c01824c67 100644 --- a/application/src/test/java/org/opentripplanner/routing/api/request/preference/RaptorPreferencesTest.java +++ b/application/src/test/java/org/opentripplanner/routing/api/request/preference/RaptorPreferencesTest.java @@ -23,15 +23,13 @@ class RaptorPreferencesTest { private static final SearchDirection SEARCH_DIRECTION = SearchDirection.REVERSE; private static final RaptorProfile PROFILE = RaptorProfile.STANDARD; private static final Set OPTIMIZATIONS = Set.of(Optimization.PARALLEL); - private static final Instant TIME_LIMIT = LocalDate - .of(2020, Month.JUNE, 9) + private static final Instant TIME_LIMIT = LocalDate.of(2020, Month.JUNE, 9) .atStartOfDay(ZoneIds.UTC) .toInstant(); private static final double RELAX_GENERALIZED_COST_AT_DESTINATION = 1.2; - private final RaptorPreferences subject = RaptorPreferences - .of() + private final RaptorPreferences subject = RaptorPreferences.of() .withSearchDirection(SEARCH_DIRECTION) .withProfile(PROFILE) .withOptimizations(OPTIMIZATIONS) @@ -46,9 +44,8 @@ void optimizations() { @Test void optimizationsShouldNotBeModifiable() { - assertThrows( - UnsupportedOperationException.class, - () -> subject.optimizations().add(Optimization.PARALLEL) + assertThrows(UnsupportedOperationException.class, () -> + subject.optimizations().add(Optimization.PARALLEL) ); } @@ -94,20 +91,17 @@ void relaxGeneralizedCostAtDestination() { ); assertEquals( 1.0, - RaptorPreferences - .of() + RaptorPreferences.of() .withRelaxGeneralizedCostAtDestination(1.0) .build() .relaxGeneralizedCostAtDestination() .orElseThrow() ); - assertThrows( - IllegalArgumentException.class, - () -> RaptorPreferences.of().withRelaxGeneralizedCostAtDestination(0.99).build() + assertThrows(IllegalArgumentException.class, () -> + RaptorPreferences.of().withRelaxGeneralizedCostAtDestination(0.99).build() ); - assertThrows( - IllegalArgumentException.class, - () -> RaptorPreferences.of().withRelaxGeneralizedCostAtDestination(2.01).build() + assertThrows(IllegalArgumentException.class, () -> + RaptorPreferences.of().withRelaxGeneralizedCostAtDestination(2.01).build() ); } diff --git a/application/src/test/java/org/opentripplanner/routing/api/request/preference/ScooterPreferencesTest.java b/application/src/test/java/org/opentripplanner/routing/api/request/preference/ScooterPreferencesTest.java index 01a12ef5cbb..93300d04da6 100644 --- a/application/src/test/java/org/opentripplanner/routing/api/request/preference/ScooterPreferencesTest.java +++ b/application/src/test/java/org/opentripplanner/routing/api/request/preference/ScooterPreferencesTest.java @@ -11,16 +11,14 @@ class ScooterPreferencesTest { public static final double SPEED = 2.0; public static final double RELUCTANCE = 1.2; - public static final TimeSlopeSafetyTriangle TRIANGLE = TimeSlopeSafetyTriangle - .of() + public static final TimeSlopeSafetyTriangle TRIANGLE = TimeSlopeSafetyTriangle.of() .withSlope(1) .build(); public static final VehicleRoutingOptimizeType OPTIMIZE_TYPE = VehicleRoutingOptimizeType.TRIANGLE; public static final int RENTAL_PICKUP_TIME = 30; - private final ScooterPreferences subject = ScooterPreferences - .of() + private final ScooterPreferences subject = ScooterPreferences.of() .withSpeed(SPEED) .withReluctance(RELUCTANCE) .withOptimizeType(OPTIMIZE_TYPE) @@ -86,21 +84,18 @@ void testToString() { @Test void testForcedTriangleOptimization() { - var trianglePreferences = ScooterPreferences - .of() + var trianglePreferences = ScooterPreferences.of() .withForcedOptimizeTriangle(it -> it.withSlope(1).build()) .build(); assertEquals(VehicleRoutingOptimizeType.TRIANGLE, trianglePreferences.optimizeType()); - var conflictingPreferences = ScooterPreferences - .of() + var conflictingPreferences = ScooterPreferences.of() .withOptimizeType(VehicleRoutingOptimizeType.SAFE_STREETS) .withForcedOptimizeTriangle(it -> it.withSlope(1).build()) .build(); assertEquals(VehicleRoutingOptimizeType.TRIANGLE, conflictingPreferences.optimizeType()); - var emptyTrianglePreferences = ScooterPreferences - .of() + var emptyTrianglePreferences = ScooterPreferences.of() .withOptimizeType(VehicleRoutingOptimizeType.SAFE_STREETS) .withForcedOptimizeTriangle(it -> it.build()) .build(); diff --git a/application/src/test/java/org/opentripplanner/routing/api/request/preference/StreetPreferencesTest.java b/application/src/test/java/org/opentripplanner/routing/api/request/preference/StreetPreferencesTest.java index 52b95532a66..36c143d7720 100644 --- a/application/src/test/java/org/opentripplanner/routing/api/request/preference/StreetPreferencesTest.java +++ b/application/src/test/java/org/opentripplanner/routing/api/request/preference/StreetPreferencesTest.java @@ -21,8 +21,7 @@ class StreetPreferencesTest { private static final IntersectionTraversalModel INTERSECTION_TRAVERSAL_MODEL = IntersectionTraversalModel.CONSTANT; - private final StreetPreferences subject = StreetPreferences - .of() + private final StreetPreferences subject = StreetPreferences.of() .withDrivingDirection(DRIVING_DIRECTION) .withTurnReluctance(TURN_RELUCTANCE) .withElevator(it -> it.withBoardTime(ELEVATOR_BOARD_TIME)) diff --git a/application/src/test/java/org/opentripplanner/routing/api/request/preference/SystemPreferencesTest.java b/application/src/test/java/org/opentripplanner/routing/api/request/preference/SystemPreferencesTest.java index 6356d358094..8cedf103527 100644 --- a/application/src/test/java/org/opentripplanner/routing/api/request/preference/SystemPreferencesTest.java +++ b/application/src/test/java/org/opentripplanner/routing/api/request/preference/SystemPreferencesTest.java @@ -24,8 +24,7 @@ class SystemPreferencesTest { .add(ParameterName.LEAD, ParameterType.PENALTY, 17.3) .build(); - private final SystemPreferences subject = SystemPreferences - .of() + private final SystemPreferences subject = SystemPreferences.of() .withGeoidElevation(true) .withMaxJourneyDuration(MAX_JOURNEY_DURATION) .addTags(List.of(TAG_RENTAL)) diff --git a/application/src/test/java/org/opentripplanner/routing/api/request/preference/TimeSlopeSafetyTriangleTest.java b/application/src/test/java/org/opentripplanner/routing/api/request/preference/TimeSlopeSafetyTriangleTest.java index 2ba7f2569e4..97dd9a4b37e 100644 --- a/application/src/test/java/org/opentripplanner/routing/api/request/preference/TimeSlopeSafetyTriangleTest.java +++ b/application/src/test/java/org/opentripplanner/routing/api/request/preference/TimeSlopeSafetyTriangleTest.java @@ -38,8 +38,7 @@ public void test( double expSafety, String description ) { - var subject = TimeSlopeSafetyTriangle - .of() + var subject = TimeSlopeSafetyTriangle.of() .withTime(inTime) .withSlope(inSlope) .withSafety(inSafety) @@ -52,8 +51,7 @@ public void test( @Test public void testBuildWithDefaultValue() { // Set som arbitrary values for the default instance - var expected = TimeSlopeSafetyTriangle - .of() + var expected = TimeSlopeSafetyTriangle.of() .withTime(1.0) .withSlope(2.0) .withSafety(3.0) diff --git a/application/src/test/java/org/opentripplanner/routing/api/request/preference/TransferOptimizationPreferencesTest.java b/application/src/test/java/org/opentripplanner/routing/api/request/preference/TransferOptimizationPreferencesTest.java index 3abd4f41cc7..ec0e558e010 100644 --- a/application/src/test/java/org/opentripplanner/routing/api/request/preference/TransferOptimizationPreferencesTest.java +++ b/application/src/test/java/org/opentripplanner/routing/api/request/preference/TransferOptimizationPreferencesTest.java @@ -16,8 +16,7 @@ class TransferOptimizationPreferencesTest { private static final double BACK_TRAVEL_WAIT_TIME_FACTOR = 1.2; private static final double EXTRA_STOP_BOARD_ALIGHT_COSTS_FACTOR = 100.0; - private final TransferOptimizationPreferences subject = TransferOptimizationPreferences - .of() + private final TransferOptimizationPreferences subject = TransferOptimizationPreferences.of() .withOptimizeTransferWaitTime(false) .withMinSafeWaitTimeFactor(MIN_SAFE_WAIT_TIME_FACTOR) .withBackTravelWaitTimeFactor(BACK_TRAVEL_WAIT_TIME_FACTOR) diff --git a/application/src/test/java/org/opentripplanner/routing/api/request/preference/TransferPreferencesTest.java b/application/src/test/java/org/opentripplanner/routing/api/request/preference/TransferPreferencesTest.java index f09ce529a60..75cfec8fe0d 100644 --- a/application/src/test/java/org/opentripplanner/routing/api/request/preference/TransferPreferencesTest.java +++ b/application/src/test/java/org/opentripplanner/routing/api/request/preference/TransferPreferencesTest.java @@ -14,13 +14,10 @@ class TransferPreferencesTest { private static final double WAIT_RELUCTANCE = 0.95; private static final int MAX_TRANSFERS = 17; private static final int MAX_ADDITIONAL_TRANSFERS = 7; - private static final TransferOptimizationPreferences OPTIMIZATION = TransferOptimizationPreferences - .of() - .withBackTravelWaitTimeFactor(2.5) - .build(); + private static final TransferOptimizationPreferences OPTIMIZATION = + TransferOptimizationPreferences.of().withBackTravelWaitTimeFactor(2.5).build(); private static final int NONPREFERRED_COST = 30_000; - private final TransferPreferences subject = TransferPreferences - .of() + private final TransferPreferences subject = TransferPreferences.of() .withCost(COST) .withSlack(SLACK) .withWaitReluctance(WAIT_RELUCTANCE) diff --git a/application/src/test/java/org/opentripplanner/routing/api/request/preference/TransitPreferencesTest.java b/application/src/test/java/org/opentripplanner/routing/api/request/preference/TransitPreferencesTest.java index bcdfcfc545c..95a03c0fb47 100644 --- a/application/src/test/java/org/opentripplanner/routing/api/request/preference/TransitPreferencesTest.java +++ b/application/src/test/java/org/opentripplanner/routing/api/request/preference/TransitPreferencesTest.java @@ -35,8 +35,7 @@ class TransitPreferencesTest { private static final boolean INCLUDE_PLANNED_CANCELLATIONS = true; private static final boolean INCLUDE_REALTIME_CANCELLATIONS = true; - private final TransitPreferences subject = TransitPreferences - .of() + private final TransitPreferences subject = TransitPreferences.of() .setReluctanceForMode(RELUCTANCE_FOR_MODE) .setOtherThanPreferredRoutesPenalty(OTHER_THAN_PREFERRED_ROUTES_PENALTY) .setUnpreferredCost(UNPREFERRED_COST) diff --git a/application/src/test/java/org/opentripplanner/routing/api/request/preference/VehicleParkingPreferencesTest.java b/application/src/test/java/org/opentripplanner/routing/api/request/preference/VehicleParkingPreferencesTest.java index ff43a7ddba6..30d4811a37c 100644 --- a/application/src/test/java/org/opentripplanner/routing/api/request/preference/VehicleParkingPreferencesTest.java +++ b/application/src/test/java/org/opentripplanner/routing/api/request/preference/VehicleParkingPreferencesTest.java @@ -74,8 +74,7 @@ private static String tagsToString(Set tags) { } private VehicleParkingPreferences createPreferences() { - return VehicleParkingPreferences - .of() + return VehicleParkingPreferences.of() .withPreferredVehicleParkingTags(PREFERRED_TAGS) .withNotPreferredVehicleParkingTags(NOT_PREFERRED_TAGS) .withUnpreferredVehicleParkingTagCost(UNPREFERRED_COST) diff --git a/application/src/test/java/org/opentripplanner/routing/api/request/preference/VehicleRentalPreferencesTest.java b/application/src/test/java/org/opentripplanner/routing/api/request/preference/VehicleRentalPreferencesTest.java index 1b7068d0cd4..85fe48a0bb0 100644 --- a/application/src/test/java/org/opentripplanner/routing/api/request/preference/VehicleRentalPreferencesTest.java +++ b/application/src/test/java/org/opentripplanner/routing/api/request/preference/VehicleRentalPreferencesTest.java @@ -21,8 +21,7 @@ class VehicleRentalPreferencesTest { public static final Set ALLOWED_NETWORKS = Set.of("foo"); public static final Set BANNED_NETWORKS = Set.of("bar"); - private final VehicleRentalPreferences subject = VehicleRentalPreferences - .of() + private final VehicleRentalPreferences subject = VehicleRentalPreferences.of() .withPickupTime(PICKUP_TIME) .withPickupCost(PICKUP_COST) .withDropOffTime(DROPOFF_TIME) diff --git a/application/src/test/java/org/opentripplanner/routing/api/request/preference/VehicleWalkingPreferencesTest.java b/application/src/test/java/org/opentripplanner/routing/api/request/preference/VehicleWalkingPreferencesTest.java index fdc416d7c0f..630af695778 100644 --- a/application/src/test/java/org/opentripplanner/routing/api/request/preference/VehicleWalkingPreferencesTest.java +++ b/application/src/test/java/org/opentripplanner/routing/api/request/preference/VehicleWalkingPreferencesTest.java @@ -65,8 +65,7 @@ void testToString() { } private VehicleWalkingPreferences createPreferences() { - return VehicleWalkingPreferences - .of() + return VehicleWalkingPreferences.of() .withSpeed(SPEED) .withReluctance(RELUCTANCE) .withMountDismountTime(MOUNT_DISMOUNT_TIME) diff --git a/application/src/test/java/org/opentripplanner/routing/api/request/preference/WalkPreferencesTest.java b/application/src/test/java/org/opentripplanner/routing/api/request/preference/WalkPreferencesTest.java index 785b130ca7a..d934546bcaa 100644 --- a/application/src/test/java/org/opentripplanner/routing/api/request/preference/WalkPreferencesTest.java +++ b/application/src/test/java/org/opentripplanner/routing/api/request/preference/WalkPreferencesTest.java @@ -21,8 +21,7 @@ class WalkPreferencesTest { private static final double SAFETY_FACTOR = 0.5111; private static final double EXPECTED_SAFETY_FACTOR = 0.51; - private final WalkPreferences subject = WalkPreferences - .of() + private final WalkPreferences subject = WalkPreferences.of() .withSpeed(SPEED) .withReluctance(RELUCTANCE) .withBoardCost(BOARD_COST) @@ -82,8 +81,7 @@ void testEqualsAndHashCodeWithNewlyConstructedPreferences() { var sameSafetyFactor = 0.5; var sameEscalatorReluctance = 2.45; var sameBoardCost = 60; - var firstEqual = WalkPreferences - .of() + var firstEqual = WalkPreferences.of() .withSpeed(sameSpeed) .withReluctance(sameReluctance) .withStairsReluctance(sameStairsReluctance) @@ -91,8 +89,7 @@ void testEqualsAndHashCodeWithNewlyConstructedPreferences() { .withEscalator(escalator -> escalator.withReluctance(sameEscalatorReluctance)) .withBoardCost(sameBoardCost) .build(); - var secondEqual = WalkPreferences - .of() + var secondEqual = WalkPreferences.of() .withSpeed(sameSpeed) .withReluctance(sameReluctance) .withStairsReluctance(sameStairsReluctance) @@ -104,8 +101,7 @@ void testEqualsAndHashCodeWithNewlyConstructedPreferences() { // Test that changing speed means preferences are not equal var notSameSpeed = sameSpeed + 1; - var differentSpeedPreferences = WalkPreferences - .of() + var differentSpeedPreferences = WalkPreferences.of() .withSpeed(notSameSpeed) .withReluctance(sameReluctance) .withStairsReluctance(sameStairsReluctance) @@ -117,8 +113,7 @@ void testEqualsAndHashCodeWithNewlyConstructedPreferences() { // Test that changing reluctance means preferences are not equal var notSameReluctance = sameReluctance + 1; - var differentReluctancePreferences = WalkPreferences - .of() + var differentReluctancePreferences = WalkPreferences.of() .withSpeed(sameSpeed) .withReluctance(notSameReluctance) .withStairsReluctance(sameStairsReluctance) @@ -130,8 +125,7 @@ void testEqualsAndHashCodeWithNewlyConstructedPreferences() { // Test that changing stairs reluctance means preferences are not equal var notSameStairsReluctance = sameStairsReluctance + 1; - var differentStairsReluctancePreferences = WalkPreferences - .of() + var differentStairsReluctancePreferences = WalkPreferences.of() .withSpeed(sameSpeed) .withReluctance(sameReluctance) .withStairsReluctance(notSameStairsReluctance) @@ -143,8 +137,7 @@ void testEqualsAndHashCodeWithNewlyConstructedPreferences() { // Test that changing safety factor means preferences are not equal var notSameSafetyFactor = sameSafetyFactor + 0.1; - var differentSafetyFactorPreferences = WalkPreferences - .of() + var differentSafetyFactorPreferences = WalkPreferences.of() .withSpeed(sameSpeed) .withReluctance(sameReluctance) .withStairsReluctance(sameStairsReluctance) @@ -156,8 +149,7 @@ void testEqualsAndHashCodeWithNewlyConstructedPreferences() { // Test that changing escalator reluctance means preferences are not equal var notSameEscalatorReluctance = sameEscalatorReluctance + 1; - var differentEscalatorReluctancePreferences = WalkPreferences - .of() + var differentEscalatorReluctancePreferences = WalkPreferences.of() .withSpeed(sameSpeed) .withReluctance(sameReluctance) .withStairsReluctance(sameStairsReluctance) @@ -169,8 +161,7 @@ void testEqualsAndHashCodeWithNewlyConstructedPreferences() { // Test that changing board cost means preferences are not equal var notSameBoardCost = sameBoardCost + 1; - var differentBoardCostPreferences = WalkPreferences - .of() + var differentBoardCostPreferences = WalkPreferences.of() .withSpeed(sameSpeed) .withReluctance(sameReluctance) .withStairsReluctance(sameStairsReluctance) diff --git a/application/src/test/java/org/opentripplanner/routing/api/request/request/filter/SelectRequestTest.java b/application/src/test/java/org/opentripplanner/routing/api/request/request/filter/SelectRequestTest.java index 216606603f9..9525a731a12 100644 --- a/application/src/test/java/org/opentripplanner/routing/api/request/request/filter/SelectRequestTest.java +++ b/application/src/test/java/org/opentripplanner/routing/api/request/request/filter/SelectRequestTest.java @@ -61,8 +61,7 @@ static SelectRequest modesSelect(MainAndSubMode... modes) { } static SelectRequest notModesSelect(MainAndSubMode... modes) { - return SelectRequest - .of() + return SelectRequest.of() .withTransportModes(MainAndSubMode.notMainModes(Arrays.asList(modes))) .build(); } diff --git a/application/src/test/java/org/opentripplanner/routing/api/request/via/PassThroughViaLocationTest.java b/application/src/test/java/org/opentripplanner/routing/api/request/via/PassThroughViaLocationTest.java index 9ed431912ac..7696108aab6 100644 --- a/application/src/test/java/org/opentripplanner/routing/api/request/via/PassThroughViaLocationTest.java +++ b/application/src/test/java/org/opentripplanner/routing/api/request/via/PassThroughViaLocationTest.java @@ -53,8 +53,7 @@ void testToString() { @Test void testEqAndHashCode() { - AssertEqualsAndHashCode - .verify(subject) + AssertEqualsAndHashCode.verify(subject) .sameAs(new PassThroughViaLocation(subject.label(), subject.stopLocationIds())) .differentFrom( new PassThroughViaLocation("Other", subject.stopLocationIds()), diff --git a/application/src/test/java/org/opentripplanner/routing/api/request/via/VisitViaLocationTest.java b/application/src/test/java/org/opentripplanner/routing/api/request/via/VisitViaLocationTest.java index e36ed42551e..47d5ecfb4b7 100644 --- a/application/src/test/java/org/opentripplanner/routing/api/request/via/VisitViaLocationTest.java +++ b/application/src/test/java/org/opentripplanner/routing/api/request/via/VisitViaLocationTest.java @@ -64,8 +64,7 @@ void testEqAndHashCode() { var ids = subject.stopLocationIds(); var cs = subject.coordinates(); - AssertEqualsAndHashCode - .verify(subject) + AssertEqualsAndHashCode.verify(subject) .sameAs(new VisitViaLocation(l, mwt, ids, cs)) .differentFrom( new VisitViaLocation("other", mwt, ids, cs), diff --git a/application/src/test/java/org/opentripplanner/routing/core/DistanceTest.java b/application/src/test/java/org/opentripplanner/routing/core/DistanceTest.java index 5eb1ce8bc6a..9dce9bdcb42 100644 --- a/application/src/test/java/org/opentripplanner/routing/core/DistanceTest.java +++ b/application/src/test/java/org/opentripplanner/routing/core/DistanceTest.java @@ -8,24 +8,30 @@ public class DistanceTest { - private static final Distance ONE_THOUSAND_FIVE_HUNDRED_METERS = Distance - .ofMetersBoxed(1500d, ignore -> {}) - .orElse(null); - private static final Distance ONE_POINT_FIVE_KILOMETERS = Distance - .ofKilometersBoxed(1.5d, ignore -> {}) - .orElse(null); - private static final Distance TWO_KILOMETERS = Distance - .ofKilometersBoxed(2d, ignore -> {}) - .orElse(null); - private static final Distance ONE_HUNDRED_METERS = Distance - .ofMetersBoxed(100d, ignore -> {}) - .orElse(null); - private static final Distance POINT_ONE_KILOMETER = Distance - .ofKilometersBoxed(0.1d, ignore -> {}) - .orElse(null); - private static final Distance ONE_HUNDRED_POINT_FIVE_METERS = Distance - .ofMetersBoxed(100.5d, ignore -> {}) - .orElse(null); + private static final Distance ONE_THOUSAND_FIVE_HUNDRED_METERS = Distance.ofMetersBoxed( + 1500d, + ignore -> {} + ).orElse(null); + private static final Distance ONE_POINT_FIVE_KILOMETERS = Distance.ofKilometersBoxed( + 1.5d, + ignore -> {} + ).orElse(null); + private static final Distance TWO_KILOMETERS = Distance.ofKilometersBoxed( + 2d, + ignore -> {} + ).orElse(null); + private static final Distance ONE_HUNDRED_METERS = Distance.ofMetersBoxed( + 100d, + ignore -> {} + ).orElse(null); + private static final Distance POINT_ONE_KILOMETER = Distance.ofKilometersBoxed( + 0.1d, + ignore -> {} + ).orElse(null); + private static final Distance ONE_HUNDRED_POINT_FIVE_METERS = Distance.ofMetersBoxed( + 100.5d, + ignore -> {} + ).orElse(null); @Test void equals() { diff --git a/application/src/test/java/org/opentripplanner/routing/core/RouteRequestTest.java b/application/src/test/java/org/opentripplanner/routing/core/RouteRequestTest.java index 01498453425..57c464e448f 100644 --- a/application/src/test/java/org/opentripplanner/routing/core/RouteRequestTest.java +++ b/application/src/test/java/org/opentripplanner/routing/core/RouteRequestTest.java @@ -137,18 +137,16 @@ void testZeroSearchWindow() { void testTooLongSearchWindow() { RouteRequest request = new RouteRequest(); request.initMaxSearchWindow(DURATION_24_HOURS); - assertThrows( - IllegalArgumentException.class, - () -> request.setSearchWindow(DURATION_24_HOURS_AND_ONE_MINUTE) + assertThrows(IllegalArgumentException.class, () -> + request.setSearchWindow(DURATION_24_HOURS_AND_ONE_MINUTE) ); } @Test void testNegativeSearchWindow() { RouteRequest request = new RouteRequest(); - assertThrows( - IllegalArgumentException.class, - () -> request.setSearchWindow(DURATION_MINUS_ONE_MINUTE) + assertThrows(IllegalArgumentException.class, () -> + request.setSearchWindow(DURATION_MINUS_ONE_MINUTE) ); } diff --git a/application/src/test/java/org/opentripplanner/routing/graph/GraphSerializationTest.java b/application/src/test/java/org/opentripplanner/routing/graph/GraphSerializationTest.java index 5ac020b18b8..5a95c03b51b 100644 --- a/application/src/test/java/org/opentripplanner/routing/graph/GraphSerializationTest.java +++ b/application/src/test/java/org/opentripplanner/routing/graph/GraphSerializationTest.java @@ -46,22 +46,20 @@ */ public class GraphSerializationTest { - static Class[] IGNORED_CLASSES = Set - .of( - // Skip AtomicInteger, it does not implement equals/hashCode - AtomicInteger.class, - ThreadPoolExecutor.class, - WeakValueHashMap.class, - Method.class, - JarFile.class, - SoftReference.class, - Class.class, - org.slf4j.Logger.class, - ch.qos.logback.classic.Logger.class, - HashGridSpatialIndex.class, - Deduplicator.class - ) - .toArray(Class[]::new); + static Class[] IGNORED_CLASSES = Set.of( + // Skip AtomicInteger, it does not implement equals/hashCode + AtomicInteger.class, + ThreadPoolExecutor.class, + WeakValueHashMap.class, + Method.class, + JarFile.class, + SoftReference.class, + Class.class, + org.slf4j.Logger.class, + ch.qos.logback.classic.Logger.class, + HashGridSpatialIndex.class, + Deduplicator.class + ).toArray(Class[]::new); /** * Tests GTFS based graph serialization to file. @@ -124,8 +122,7 @@ public void testRoundTripSerializationForNetexGraph() throws Exception { */ @Test public void compareGraphToItself() { - TestOtpModel cachedPortlandGraph = ConstantsForTests - .getInstance() + TestOtpModel cachedPortlandGraph = ConstantsForTests.getInstance() .getCachedPortlandGraph() .index(); Graph originalGraph = cachedPortlandGraph.graph(); diff --git a/application/src/test/java/org/opentripplanner/routing/graph/SimpleConcreteEdge.java b/application/src/test/java/org/opentripplanner/routing/graph/SimpleConcreteEdge.java index 03d85c78923..687d89470c8 100644 --- a/application/src/test/java/org/opentripplanner/routing/graph/SimpleConcreteEdge.java +++ b/application/src/test/java/org/opentripplanner/routing/graph/SimpleConcreteEdge.java @@ -26,7 +26,7 @@ public static SimpleConcreteEdge createSimpleConcreteEdge(Vertex v1, Vertex v2) public State[] traverse(State s0) { double d = getDistanceMeters(); TraverseMode mode = s0.currentMode(); - int t = (int) (1000.0 * d / s0.getPreferences().getSpeed(mode, false)); + int t = (int) ((1000.0 * d) / s0.getPreferences().getSpeed(mode, false)); StateEditor s1 = s0.edit(this); s1.incrementTimeInMilliseconds(t); s1.incrementWeight(d); diff --git a/application/src/test/java/org/opentripplanner/routing/graph/TemporaryConcreteEdge.java b/application/src/test/java/org/opentripplanner/routing/graph/TemporaryConcreteEdge.java index d3f4c06c3f7..d499ebf7c72 100644 --- a/application/src/test/java/org/opentripplanner/routing/graph/TemporaryConcreteEdge.java +++ b/application/src/test/java/org/opentripplanner/routing/graph/TemporaryConcreteEdge.java @@ -32,7 +32,7 @@ public static TemporaryConcreteEdge createTemporaryConcreteEdge(Vertex v1, Tempo public State[] traverse(State s0) { double d = getDistanceMeters(); TraverseMode mode = s0.currentMode(); - int t = (int) (1000.0 * d / s0.getPreferences().getSpeed(mode, false)); + int t = (int) ((1000.0 * d) / s0.getPreferences().getSpeed(mode, false)); StateEditor s1 = s0.edit(this); s1.incrementTimeInMilliseconds(t); s1.incrementWeight(d); diff --git a/application/src/test/java/org/opentripplanner/routing/graphfinder/PlaceFinderTraverseVisitorTest.java b/application/src/test/java/org/opentripplanner/routing/graphfinder/PlaceFinderTraverseVisitorTest.java index 95ad1aa316e..cf3a06221d1 100644 --- a/application/src/test/java/org/opentripplanner/routing/graphfinder/PlaceFinderTraverseVisitorTest.java +++ b/application/src/test/java/org/opentripplanner/routing/graphfinder/PlaceFinderTraverseVisitorTest.java @@ -28,14 +28,12 @@ public class PlaceFinderTraverseVisitorTest { static TimetableRepositoryForTest model = TimetableRepositoryForTest.of(); - static final Station STATION1 = Station - .of(id("S1")) + static final Station STATION1 = Station.of(id("S1")) .withName(new NonLocalizedString("Station 1")) .withCoordinate(1.1, 1.1) .build(); - static final Station STATION2 = Station - .of(id("S2")) + static final Station STATION2 = Station.of(id("S2")) .withName(new NonLocalizedString("Station 2")) .withCoordinate(1.1, 1.1) .build(); @@ -329,19 +327,18 @@ void rentalStationWithNetworksFilter() { assertEquals(List.of(station), res); - visitor = - new PlaceFinderTraverseVisitor( - transitService, - null, - List.of(PlaceType.VEHICLE_RENT), - null, - null, - null, - null, - List.of("Network-2"), - 1, - 500 - ); + visitor = new PlaceFinderTraverseVisitor( + transitService, + null, + List.of(PlaceType.VEHICLE_RENT), + null, + null, + null, + null, + List.of("Network-2"), + 1, + 500 + ); assertEquals(List.of(), visitor.placesFound); state1 = TestStateBuilder.ofWalking().rentalStation(station).build(); diff --git a/application/src/test/java/org/opentripplanner/routing/graphfinder/StreetGraphFinderTest.java b/application/src/test/java/org/opentripplanner/routing/graphfinder/StreetGraphFinderTest.java index 2c787bc682c..d475c5a2212 100644 --- a/application/src/test/java/org/opentripplanner/routing/graphfinder/StreetGraphFinderTest.java +++ b/application/src/test/java/org/opentripplanner/routing/graphfinder/StreetGraphFinderTest.java @@ -56,35 +56,32 @@ public void build() { C = intersection("C", 47.520, 19.00); D = intersection("D", 47.530, 19.00); - BP1 = - vehicleParking( - "BP1", - 47.520, - 18.999, - true, - false, - List.of(vehicleParkingEntrance(C, "BP1 Entrance", false, true)) - ); - - PR1 = - vehicleParking( - "PR1", - 47.510, - 18.999, - false, - true, - List.of(vehicleParkingEntrance(B, "PR1 Entrance", true, true)) - ); - - PR2 = - vehicleParking( - "PR2", - 47.530, - 18.999, - false, - true, - List.of(vehicleParkingEntrance(D, "PR2 Entrance", true, true)) - ); + BP1 = vehicleParking( + "BP1", + 47.520, + 18.999, + true, + false, + List.of(vehicleParkingEntrance(C, "BP1 Entrance", false, true)) + ); + + PR1 = vehicleParking( + "PR1", + 47.510, + 18.999, + false, + true, + List.of(vehicleParkingEntrance(B, "PR1 Entrance", true, true)) + ); + + PR2 = vehicleParking( + "PR2", + 47.530, + 18.999, + false, + true, + List.of(vehicleParkingEntrance(D, "PR2 Entrance", true, true)) + ); biLink(A, S1); biLink(A, BR1); @@ -97,20 +94,16 @@ public void build() { street(C, D, 100, StreetTraversalPermission.ALL); tripPattern( - TP1 = - TripPattern - .of(TimetableRepositoryForTest.id("TP1")) - .withRoute(R1) - .withStopPattern(new StopPattern(List.of(st(S1), st(S2)))) - .build() + TP1 = TripPattern.of(TimetableRepositoryForTest.id("TP1")) + .withRoute(R1) + .withStopPattern(new StopPattern(List.of(st(S1), st(S2)))) + .build() ); tripPattern( - TP2 = - TripPattern - .of(TimetableRepositoryForTest.id("TP2")) - .withRoute(R2) - .withStopPattern(new StopPattern(List.of(st(S1), st(S3)))) - .build() + TP2 = TripPattern.of(TimetableRepositoryForTest.id("TP2")) + .withRoute(R2) + .withStopPattern(new StopPattern(List.of(st(S1), st(S3)))) + .build() ); } } diff --git a/application/src/test/java/org/opentripplanner/routing/stoptimes/AlternativeLegsTest.java b/application/src/test/java/org/opentripplanner/routing/stoptimes/AlternativeLegsTest.java index 65e99825a9e..b8619224efe 100644 --- a/application/src/test/java/org/opentripplanner/routing/stoptimes/AlternativeLegsTest.java +++ b/application/src/test/java/org/opentripplanner/routing/stoptimes/AlternativeLegsTest.java @@ -45,8 +45,7 @@ void testPreviousLegs() { STOP_ID_B, STOP_ID_C, null - ) - .getLeg(transitService); + ).getLeg(transitService); final List alternativeLegs = AlternativeLegs.getAlternativeLegs( originalLeg, @@ -79,8 +78,7 @@ void testNextLegs() { STOP_ID_B, STOP_ID_C, null - ) - .getLeg(transitService); + ).getLeg(transitService); final List alternativeLegs = AlternativeLegs.getAlternativeLegs( originalLeg, @@ -113,8 +111,7 @@ void testCircularRoutes() { STOP_ID_X, STOP_ID_Y, null - ) - .getLeg(transitService); + ).getLeg(transitService); final List alternativeLegs = AlternativeLegs.getAlternativeLegs( originalLeg, @@ -141,8 +138,7 @@ void testComplexCircularRoutes() { STOP_ID_X, STOP_ID_B, null - ) - .getLeg(transitService); + ).getLeg(transitService); final List alternativeLegs = AlternativeLegs.getAlternativeLegs( originalLeg, diff --git a/application/src/test/java/org/opentripplanner/routing/stoptimes/StopTimesHelperTest.java b/application/src/test/java/org/opentripplanner/routing/stoptimes/StopTimesHelperTest.java index 52ddaf86d91..919d407563e 100644 --- a/application/src/test/java/org/opentripplanner/routing/stoptimes/StopTimesHelperTest.java +++ b/application/src/test/java/org/opentripplanner/routing/stoptimes/StopTimesHelperTest.java @@ -39,11 +39,10 @@ public static void setUp() throws Exception { var tt = originalPattern.getScheduledTimetable(); var newTripTimes = tt.getTripTimes(0).copyScheduledTimes(); newTripTimes.cancelTrip(); - pattern = - originalPattern - .copy() - .withScheduledTimeTableBuilder(builder -> builder.addOrUpdateTripTimes(newTripTimes)) - .build(); + pattern = originalPattern + .copy() + .withScheduledTimeTableBuilder(builder -> builder.addOrUpdateTripTimes(newTripTimes)) + .build(); // replace the original pattern by the updated pattern in the transit model timetableRepository.addTripPattern(pattern.getId(), pattern); timetableRepository.index(); diff --git a/application/src/test/java/org/opentripplanner/routing/util/TestElevationUtils.java b/application/src/test/java/org/opentripplanner/routing/util/TestElevationUtils.java index d8950f4681b..7ab36fff396 100644 --- a/application/src/test/java/org/opentripplanner/routing/util/TestElevationUtils.java +++ b/application/src/test/java/org/opentripplanner/routing/util/TestElevationUtils.java @@ -25,10 +25,9 @@ public void testLengthMultiplier() { costs = ElevationUtils.getSlopeCosts(seq, false); assertEquals(1.00498756211208902702, costs.lengthMultiplier); - seq = - factory.create( - new Coordinate[] { new Coordinate(0, 1), new Coordinate(10, 2), new Coordinate(15, 1) } - ); + seq = factory.create( + new Coordinate[] { new Coordinate(0, 1), new Coordinate(10, 2), new Coordinate(15, 1) } + ); costs = ElevationUtils.getSlopeCosts(seq, false); assertEquals(1.00992634231424500668, costs.lengthMultiplier); } @@ -119,8 +118,11 @@ private static void assertPartialElevation( if (expectedCoordinates == null) { assertNull(partialElevationProfile); } else { - var expectedElevationProfile = new PackedCoordinateSequence.Double(expectedCoordinates, 2, 0) - .toCoordinateArray(); + var expectedElevationProfile = new PackedCoordinateSequence.Double( + expectedCoordinates, + 2, + 0 + ).toCoordinateArray(); var actualElevationProfile = partialElevationProfile != null ? partialElevationProfile.toCoordinateArray() : null; diff --git a/application/src/test/java/org/opentripplanner/routing/util/elevation/ToblersHikingFunctionTest.java b/application/src/test/java/org/opentripplanner/routing/util/elevation/ToblersHikingFunctionTest.java index 517d37645dd..5df059df453 100644 --- a/application/src/test/java/org/opentripplanner/routing/util/elevation/ToblersHikingFunctionTest.java +++ b/application/src/test/java/org/opentripplanner/routing/util/elevation/ToblersHikingFunctionTest.java @@ -50,7 +50,7 @@ static class TestCase { // Set the horizontal distance to 300 meters this.dx = 300.0; // Calculate the height: - this.dh = dx * slopeAnglePercentage / 100.0; + this.dh = (dx * slopeAnglePercentage) / 100.0; this.expected = expected; } diff --git a/application/src/test/java/org/opentripplanner/service/paging/PS3_FewItinerariesOnSearchWindowLimitTest.java b/application/src/test/java/org/opentripplanner/service/paging/PS3_FewItinerariesOnSearchWindowLimitTest.java index fffcf93e5fb..09ab0136235 100644 --- a/application/src/test/java/org/opentripplanner/service/paging/PS3_FewItinerariesOnSearchWindowLimitTest.java +++ b/application/src/test/java/org/opentripplanner/service/paging/PS3_FewItinerariesOnSearchWindowLimitTest.java @@ -98,8 +98,12 @@ void test(String edt, boolean arriveBy, String testCaseTokens) { if (arriveBy) { expectedSortOrder = SortOrder.STREET_AND_DEPARTURE_TIME; - driver = - model.arriveByDriver(currTime, LATEST_ARRIVAL_TIME, SEARCH_WINDOW, NUM_OF_ITINERARIES); + driver = model.arriveByDriver( + currTime, + LATEST_ARRIVAL_TIME, + SEARCH_WINDOW, + NUM_OF_ITINERARIES + ); } else { expectedSortOrder = SortOrder.STREET_AND_ARRIVAL_TIME; driver = model.departAfterDriver(currTime, SEARCH_WINDOW, NUM_OF_ITINERARIES); diff --git a/application/src/test/java/org/opentripplanner/service/paging/TestPagingModel.java b/application/src/test/java/org/opentripplanner/service/paging/TestPagingModel.java index 9a30b5e8a90..f9889ac88b3 100644 --- a/application/src/test/java/org/opentripplanner/service/paging/TestPagingModel.java +++ b/application/src/test/java/org/opentripplanner/service/paging/TestPagingModel.java @@ -115,13 +115,11 @@ class TestPagingModel { itinerary(T09_00_PLUS_1d, T09_30_PLUS_1d, COST_HIGH, TX_1, TRANSIT) ); - static final List ITINERARIES_CASE_B_DEPART_AFTER = ITINERARIES_CASE_B - .stream() + static final List ITINERARIES_CASE_B_DEPART_AFTER = ITINERARIES_CASE_B.stream() .sorted(SortOrderComparator.comparator(STREET_AND_ARRIVAL_TIME)) .toList(); - static final List ITINERARIES_CASE_B_ARRIVE_BY = ITINERARIES_CASE_B - .stream() + static final List ITINERARIES_CASE_B_ARRIVE_BY = ITINERARIES_CASE_B.stream() .sorted(SortOrderComparator.comparator(SortOrder.STREET_AND_DEPARTURE_TIME)) .toList(); diff --git a/application/src/test/java/org/opentripplanner/service/vehicleparking/VehicleParkingHelperTest.java b/application/src/test/java/org/opentripplanner/service/vehicleparking/VehicleParkingHelperTest.java index 34b48bfe051..12fdc51ac9d 100644 --- a/application/src/test/java/org/opentripplanner/service/vehicleparking/VehicleParkingHelperTest.java +++ b/application/src/test/java/org/opentripplanner/service/vehicleparking/VehicleParkingHelperTest.java @@ -44,19 +44,18 @@ void linkThreeVerticesTest() { @Test void linkSkippingEdgesTest() { Graph graph = new Graph(); - var vehicleParking = StreetModelForTest - .vehicleParking() + var vehicleParking = StreetModelForTest.vehicleParking() .entrances( - IntStream - .rangeClosed(1, 3) - .mapToObj(id -> - builder -> - builder - .entranceId(new FeedScopedId(TEST_FEED_ID, "Entrance " + id)) - .name(new NonLocalizedString("Entrance " + id)) - .coordinate(new WgsCoordinate(id, id)) - .carAccessible(id == 1 || id == 3) - .walkAccessible(id == 2 || id == 3) + IntStream.rangeClosed(1, 3) + .mapToObj( + id -> + builder -> + builder + .entranceId(new FeedScopedId(TEST_FEED_ID, "Entrance " + id)) + .name(new NonLocalizedString("Entrance " + id)) + .coordinate(new WgsCoordinate(id, id)) + .carAccessible(id == 1 || id == 3) + .walkAccessible(id == 2 || id == 3) ) .collect(Collectors.toList()) ) @@ -70,19 +69,18 @@ void linkSkippingEdgesTest() { } private VehicleParking createParingWithEntrances(int entranceNumber) { - return StreetModelForTest - .vehicleParking() + return StreetModelForTest.vehicleParking() .bicyclePlaces(true) .entrances( - IntStream - .rangeClosed(1, entranceNumber) - .mapToObj(id -> - builder -> - builder - .entranceId(new FeedScopedId(TEST_FEED_ID, "Entrance " + id)) - .name(new NonLocalizedString("Entrance " + id)) - .coordinate(new WgsCoordinate(id, id)) - .walkAccessible(true) + IntStream.rangeClosed(1, entranceNumber) + .mapToObj( + id -> + builder -> + builder + .entranceId(new FeedScopedId(TEST_FEED_ID, "Entrance " + id)) + .name(new NonLocalizedString("Entrance " + id)) + .coordinate(new WgsCoordinate(id, id)) + .walkAccessible(true) ) .collect(Collectors.toList()) ) diff --git a/application/src/test/java/org/opentripplanner/service/vehicleparking/VehicleParkingTestUtil.java b/application/src/test/java/org/opentripplanner/service/vehicleparking/VehicleParkingTestUtil.java index aebd422cf81..cb3b2c52b26 100644 --- a/application/src/test/java/org/opentripplanner/service/vehicleparking/VehicleParkingTestUtil.java +++ b/application/src/test/java/org/opentripplanner/service/vehicleparking/VehicleParkingTestUtil.java @@ -28,8 +28,7 @@ public static VehicleParking createParkingWithEntrances( .coordinate(new WgsCoordinate(y, x)) .walkAccessible(true); - return StreetModelForTest - .vehicleParking() + return StreetModelForTest.vehicleParking() .id(new FeedScopedId(TEST_FEED_ID, id)) .bicyclePlaces(true) .capacity(vehiclePlaces) diff --git a/application/src/test/java/org/opentripplanner/service/vehiclerental/internal/DefaultVehicleRentalServiceTest.java b/application/src/test/java/org/opentripplanner/service/vehiclerental/internal/DefaultVehicleRentalServiceTest.java index 0a7cfd568aa..3a9ed72a027 100644 --- a/application/src/test/java/org/opentripplanner/service/vehiclerental/internal/DefaultVehicleRentalServiceTest.java +++ b/application/src/test/java/org/opentripplanner/service/vehiclerental/internal/DefaultVehicleRentalServiceTest.java @@ -27,12 +27,8 @@ void getVehicleRentalStationForEnvelopeShouldExcludeVehicleRentalVehicle() { .build(); defaultVehicleRentalService.addVehicleRentalStation(vehicleRentalVehicle); - List vehicleRentalStationForEnvelope = defaultVehicleRentalService.getVehicleRentalStationForEnvelope( - 0, - 0, - 10, - 10 - ); + List vehicleRentalStationForEnvelope = + defaultVehicleRentalService.getVehicleRentalStationForEnvelope(0, 0, 10, 10); assertEquals(1, vehicleRentalStationForEnvelope.size()); assertEquals(vehicleRentalStation, vehicleRentalStationForEnvelope.get(0)); } diff --git a/application/src/test/java/org/opentripplanner/service/vehiclerental/model/TestFreeFloatingRentalVehicleBuilder.java b/application/src/test/java/org/opentripplanner/service/vehiclerental/model/TestFreeFloatingRentalVehicleBuilder.java index 2b8881715a9..ebe501b0677 100644 --- a/application/src/test/java/org/opentripplanner/service/vehiclerental/model/TestFreeFloatingRentalVehicleBuilder.java +++ b/application/src/test/java/org/opentripplanner/service/vehiclerental/model/TestFreeFloatingRentalVehicleBuilder.java @@ -60,24 +60,23 @@ public TestFreeFloatingRentalVehicleBuilder withNetwork(String network) { } public TestFreeFloatingRentalVehicleBuilder withSystem(String id, String url) { - this.system = - new VehicleRentalSystem( - id, - null, - null, - null, - null, - url, - null, - null, - null, - null, - null, - null, - null, - null, - null - ); + this.system = new VehicleRentalSystem( + id, + null, + null, + null, + null, + url, + null, + null, + null, + null, + null, + null, + null, + null, + null + ); return this; } @@ -102,23 +101,21 @@ public VehicleRentalVehicle build() { vehicle.longitude = longitude; vehicle.vehicleType = vehicleType; vehicle.system = system; - vehicle.fuel = - new RentalVehicleFuel( - currentFuelPercent, - Distance.ofMetersBoxed(currentRangeMeters, ignore -> {}).orElse(null) - ); + vehicle.fuel = new RentalVehicleFuel( + currentFuelPercent, + Distance.ofMetersBoxed(currentRangeMeters, ignore -> {}).orElse(null) + ); return vehicle; } private TestFreeFloatingRentalVehicleBuilder buildVehicleType(RentalFormFactor rentalFormFactor) { - this.vehicleType = - new RentalVehicleType( - new FeedScopedId(TestFreeFloatingRentalVehicleBuilder.NETWORK_1, rentalFormFactor.name()), - rentalFormFactor.name(), - rentalFormFactor, - RentalVehicleType.PropulsionType.ELECTRIC, - 100000d - ); + this.vehicleType = new RentalVehicleType( + new FeedScopedId(TestFreeFloatingRentalVehicleBuilder.NETWORK_1, rentalFormFactor.name()), + rentalFormFactor.name(), + rentalFormFactor, + RentalVehicleType.PropulsionType.ELECTRIC, + 100000d + ); return this; } } diff --git a/application/src/test/java/org/opentripplanner/service/vehiclerental/model/TestVehicleRentalStationBuilder.java b/application/src/test/java/org/opentripplanner/service/vehiclerental/model/TestVehicleRentalStationBuilder.java index ea8af5ade6f..cb3d2e6f1f7 100644 --- a/application/src/test/java/org/opentripplanner/service/vehiclerental/model/TestVehicleRentalStationBuilder.java +++ b/application/src/test/java/org/opentripplanner/service/vehiclerental/model/TestVehicleRentalStationBuilder.java @@ -53,24 +53,23 @@ public TestVehicleRentalStationBuilder withStationOn(boolean stationOn) { } public TestVehicleRentalStationBuilder withSystem(String id, String url) { - this.system = - new VehicleRentalSystem( - id, - null, - null, - null, - null, - url, - null, - null, - null, - null, - null, - null, - null, - null, - null - ); + this.system = new VehicleRentalSystem( + id, + null, + null, + null, + null, + url, + null, + null, + null, + null, + null, + null, + null, + null, + null + ); return this; } diff --git a/application/src/test/java/org/opentripplanner/service/worldenvelope/internal/WorldEnvelopeRepositoryTest.java b/application/src/test/java/org/opentripplanner/service/worldenvelope/internal/WorldEnvelopeRepositoryTest.java index db0aa46754c..694b48d705a 100644 --- a/application/src/test/java/org/opentripplanner/service/worldenvelope/internal/WorldEnvelopeRepositoryTest.java +++ b/application/src/test/java/org/opentripplanner/service/worldenvelope/internal/WorldEnvelopeRepositoryTest.java @@ -8,8 +8,7 @@ class WorldEnvelopeRepositoryTest { - private final WorldEnvelope envelope = WorldEnvelope - .of() + private final WorldEnvelope envelope = WorldEnvelope.of() .expandToIncludeStreetEntities(60d, 10d) .expandToIncludeStreetEntities(65d, 14d) .build(); diff --git a/application/src/test/java/org/opentripplanner/service/worldenvelope/internal/WorldEnvelopeServiceTest.java b/application/src/test/java/org/opentripplanner/service/worldenvelope/internal/WorldEnvelopeServiceTest.java index 0f18f67899b..53387aaa874 100644 --- a/application/src/test/java/org/opentripplanner/service/worldenvelope/internal/WorldEnvelopeServiceTest.java +++ b/application/src/test/java/org/opentripplanner/service/worldenvelope/internal/WorldEnvelopeServiceTest.java @@ -8,8 +8,7 @@ class WorldEnvelopeServiceTest { - private final WorldEnvelope envelope = WorldEnvelope - .of() + private final WorldEnvelope envelope = WorldEnvelope.of() .expandToIncludeStreetEntities(60d, 10d) .expandToIncludeStreetEntities(65d, 14d) .build(); diff --git a/application/src/test/java/org/opentripplanner/service/worldenvelope/model/WorldEnvelopeTest.java b/application/src/test/java/org/opentripplanner/service/worldenvelope/model/WorldEnvelopeTest.java index 136caf31a5b..304235e993c 100644 --- a/application/src/test/java/org/opentripplanner/service/worldenvelope/model/WorldEnvelopeTest.java +++ b/application/src/test/java/org/opentripplanner/service/worldenvelope/model/WorldEnvelopeTest.java @@ -68,15 +68,13 @@ void testWorldEnvelope( // WorldEnvelope should normalize to lower-left and upper-right // Add lower-right & upper-left the world-envelope - var subjectWithoutMedian = WorldEnvelope - .of() + var subjectWithoutMedian = WorldEnvelope.of() .expandToIncludeStreetEntities(lowerLat, rightLon) .expandToIncludeStreetEntities(upperLat, leftLon) .build(); // Add the ~middle point between each corner of the envelope + median point // We offset the one center value to the "other" side of the median by adding 2.0 - var subjectWithMedian = WorldEnvelope - .of() + var subjectWithMedian = WorldEnvelope.of() .expandToIncludeTransitEntities( List.of( new WgsCoordinate(upperLat, centerLon), @@ -111,8 +109,7 @@ void testWorldEnvelope( void testWorldEnvelopeToString() { assertEquals( "WorldEnvelope{lowerLeft: (-10.0, -60.0), upperRight: (40.0, 50.0), meanCenter: (15.0, -5.0)}", - WorldEnvelope - .of() + WorldEnvelope.of() .expandToIncludeStreetEntities(S10, E50) .expandToIncludeStreetEntities(N40, W60) .build() diff --git a/application/src/test/java/org/opentripplanner/standalone/config/ExampleConfigTest.java b/application/src/test/java/org/opentripplanner/standalone/config/ExampleConfigTest.java index 934da6f923d..9ea42e813e1 100644 --- a/application/src/test/java/org/opentripplanner/standalone/config/ExampleConfigTest.java +++ b/application/src/test/java/org/opentripplanner/standalone/config/ExampleConfigTest.java @@ -77,19 +77,15 @@ void debugUiConfig(Path filename) { ) @ParameterizedTest(name = "Fail when parsing an invalid config from {0}") void failInvalidConfig(Path filename) { - Assertions.assertThrows( - AssertionFailedError.class, - () -> testConfig(filename, a -> new BuildConfig(a, true)) + Assertions.assertThrows(AssertionFailedError.class, () -> + testConfig(filename, a -> new BuildConfig(a, true)) ); } private void testConfig(Path path, Consumer buildConfig) { try { var json = Files.readString(path); - var replaced = EnvironmentVariableReplacer.insertVariables( - json, - json, - ignored -> "some-value" + var replaced = EnvironmentVariableReplacer.insertVariables(json, json, ignored -> "some-value" ); var node = JsonSupport.jsonNodeFromString(replaced); var a = new NodeAdapter(node, path.toString()); diff --git a/application/src/test/java/org/opentripplanner/standalone/config/OtpConfigLoaderTest.java b/application/src/test/java/org/opentripplanner/standalone/config/OtpConfigLoaderTest.java index 8dae448e2c6..37b34ab6bb5 100644 --- a/application/src/test/java/org/opentripplanner/standalone/config/OtpConfigLoaderTest.java +++ b/application/src/test/java/org/opentripplanner/standalone/config/OtpConfigLoaderTest.java @@ -84,8 +84,7 @@ public void testReplacementOfEnvironmentVariables() { // and a value with less than 30 characters (avoid long values like paths for // readability). We will use this to insert it in the JSON and later see if the // ConfigLoader is able to replace the placeholder with the expected value. - Map.Entry envVar = System - .getenv() + Map.Entry envVar = System.getenv() .entrySet() .stream() .filter(e -> e.getKey().matches("\\w+") && e.getValue().length() < 30) diff --git a/application/src/test/java/org/opentripplanner/standalone/config/buildconfig/DemConfigTest.java b/application/src/test/java/org/opentripplanner/standalone/config/buildconfig/DemConfigTest.java index 26f80869dfc..5c8df29703e 100644 --- a/application/src/test/java/org/opentripplanner/standalone/config/buildconfig/DemConfigTest.java +++ b/application/src/test/java/org/opentripplanner/standalone/config/buildconfig/DemConfigTest.java @@ -30,10 +30,12 @@ void mapDemDefaultParameters() { @Test void mapMissingDemDefaultParameters() { - NodeAdapter nodeAdapter = newNodeAdapterForTest(""" + NodeAdapter nodeAdapter = newNodeAdapterForTest( + """ { } - """); + """ + ); var subject = DemConfig.mapDemDefaultsConfig(nodeAdapter, "demDefaults"); @@ -122,10 +124,12 @@ void mapDemExtractsWithConflictingDefaults() { @Test void mapDemExtractWithNoDefaults() { - NodeAdapter noDefaultsAdapter = newNodeAdapterForTest(""" + NodeAdapter noDefaultsAdapter = newNodeAdapterForTest( + """ { } - """); + """ + ); var defaults = DemConfig.mapDemDefaultsConfig(noDefaultsAdapter, "demDefaults"); diff --git a/application/src/test/java/org/opentripplanner/standalone/config/buildconfig/GtfsConfigTest.java b/application/src/test/java/org/opentripplanner/standalone/config/buildconfig/GtfsConfigTest.java index 5bca5fbc0cc..3a6c87ba8da 100644 --- a/application/src/test/java/org/opentripplanner/standalone/config/buildconfig/GtfsConfigTest.java +++ b/application/src/test/java/org/opentripplanner/standalone/config/buildconfig/GtfsConfigTest.java @@ -42,10 +42,12 @@ void mapGtfsDefaultParameters() { @Test void mapMissingGtfsDefaultParameters() { - NodeAdapter nodeAdapter = newNodeAdapterForTest(""" + NodeAdapter nodeAdapter = newNodeAdapterForTest( + """ { } - """); + """ + ); var subject = GtfsConfig.mapGtfsDefaultParameters(nodeAdapter, "gtfsDefaults"); @@ -141,10 +143,12 @@ void mapGtfsFeedWithConflictingDefaults() { @Test void mapGtfsFeedWithNoDefaults() { - NodeAdapter noDefaultsAdapter = newNodeAdapterForTest(""" + NodeAdapter noDefaultsAdapter = newNodeAdapterForTest( + """ { } - """); + """ + ); var defaults = GtfsConfig.mapGtfsDefaultParameters(noDefaultsAdapter, "gtfsDefaults"); diff --git a/application/src/test/java/org/opentripplanner/standalone/config/buildconfig/OsmConfigTest.java b/application/src/test/java/org/opentripplanner/standalone/config/buildconfig/OsmConfigTest.java index c771655bdbb..f8c6dbeae96 100644 --- a/application/src/test/java/org/opentripplanner/standalone/config/buildconfig/OsmConfigTest.java +++ b/application/src/test/java/org/opentripplanner/standalone/config/buildconfig/OsmConfigTest.java @@ -34,10 +34,12 @@ void mapOsmDefaultParameters() { @Test void mapMissingOsmDefaultParameters() { - NodeAdapter nodeAdapter = newNodeAdapterForTest(""" + NodeAdapter nodeAdapter = newNodeAdapterForTest( + """ { } - """); + """ + ); var subject = OsmConfig.mapOsmDefaults(nodeAdapter, "osmDefaults"); @@ -134,10 +136,12 @@ void mapOsmExtractsWithConflictingDefaults() { @Test void mapOsmExtractWithNoDefaults() { - NodeAdapter noDefaultsAdapter = newNodeAdapterForTest(""" + NodeAdapter noDefaultsAdapter = newNodeAdapterForTest( + """ { } - """); + """ + ); var defaults = OsmConfig.mapOsmDefaults(noDefaultsAdapter, "osmDefaults"); diff --git a/application/src/test/java/org/opentripplanner/standalone/config/framework/file/ConfigFileLoaderTest.java b/application/src/test/java/org/opentripplanner/standalone/config/framework/file/ConfigFileLoaderTest.java index 2e698efb64d..9eb4142ea80 100644 --- a/application/src/test/java/org/opentripplanner/standalone/config/framework/file/ConfigFileLoaderTest.java +++ b/application/src/test/java/org/opentripplanner/standalone/config/framework/file/ConfigFileLoaderTest.java @@ -58,8 +58,7 @@ public void testReplacementOfEnvironmentVariables() { // and a value with less than 30 characters (avoid long values like paths for // readability). We will use this to insert it in the JSON and later see if the // ConfigLoader is able to replace the placeholder with the expected value. - Map.Entry envVar = System - .getenv() + Map.Entry envVar = System.getenv() .entrySet() .stream() .filter(e -> e.getKey().matches("\\w+") && e.getValue().length() < 30) @@ -90,10 +89,8 @@ public void testReplacementOfEnvironmentVariables() { */ @Test public void testMissingEnvironmentVariable() { - assertThrows( - OtpAppException.class, - () -> - ConfigFileLoader.nodeFromString(json("{ key: '${none_existing_env_variable}' }"), "test") + assertThrows(OtpAppException.class, () -> + ConfigFileLoader.nodeFromString(json("{ key: '${none_existing_env_variable}' }"), "test") ); } diff --git a/application/src/test/java/org/opentripplanner/standalone/config/framework/json/EnumMapperTest.java b/application/src/test/java/org/opentripplanner/standalone/config/framework/json/EnumMapperTest.java index 7df9570f153..2548a37bfc1 100644 --- a/application/src/test/java/org/opentripplanner/standalone/config/framework/json/EnumMapperTest.java +++ b/application/src/test/java/org/opentripplanner/standalone/config/framework/json/EnumMapperTest.java @@ -38,19 +38,21 @@ void testToString() { void docEnumValueList() { assertEquals( """ - - `bar` This is Bar - - `boo-boo` This is Boo - Boo - """, + - `bar` This is Bar + - `boo-boo` This is Boo + Boo + """, EnumMapper.docEnumValueList(Foo.values()) ); } enum Foo implements DocumentedEnum { Bar("This is Bar"), - BOO_BOO(""" + BOO_BOO( + """ This is Boo - Boo"""); + Boo""" + ); private final String doc; diff --git a/application/src/test/java/org/opentripplanner/standalone/config/framework/json/NodeAdapterTest.java b/application/src/test/java/org/opentripplanner/standalone/config/framework/json/NodeAdapterTest.java index 9d3719c2285..308ce6b3bd4 100644 --- a/application/src/test/java/org/opentripplanner/standalone/config/framework/json/NodeAdapterTest.java +++ b/application/src/test/java/org/opentripplanner/standalone/config/framework/json/NodeAdapterTest.java @@ -173,13 +173,13 @@ void asEnumWithIllegalPropertySet() { // Given NodeAdapter subject = newNodeAdapterForTest( """ - { - key : 'NONE_EXISTING_ENUM_VALUE', - skim : { - albin : 'NONE_EXISTING_ENUM_VALUE' + { + key : 'NONE_EXISTING_ENUM_VALUE', + skim : { + albin : 'NONE_EXISTING_ENUM_VALUE' + } } - } - """ + """ ); NodeAdapter child = subject.of("skim").asObject(); @@ -194,9 +194,9 @@ void asEnumWithIllegalPropertySet() { subject.logAllWarnings(m -> log.append(m).append('\n')); assertEquals( """ - {error-message} Parameter: skim.albin. Source: Test. - {error-message} Parameter: key. Source: Test. - """.replace( + {error-message} Parameter: skim.albin. Source: Test. + {error-message} Parameter: key. Source: Test. + """.replace( "{error-message}", "The enum value 'NONE_EXISTING_ENUM_VALUE' is not legal. Expected one of [A, B, A_B_C]." ), @@ -270,9 +270,8 @@ void asEnumMapAllKeysRequired() { assertNull(subject.of("missing-key").asEnumMapAllKeysRequired(AnEnum.class, Boolean.class)); var subjectMissingB = newNodeAdapterForTest("{ key : { A: true, a_B_c: true } }"); - assertThrows( - OtpAppException.class, - () -> subjectMissingB.of("key").asEnumMapAllKeysRequired(AnEnum.class, Boolean.class) + assertThrows(OtpAppException.class, () -> + subjectMissingB.of("key").asEnumMapAllKeysRequired(AnEnum.class, Boolean.class) ); // Any extra keys should be ignored for forward/backward compatibility @@ -284,9 +283,8 @@ void asEnumMapWithRequiredMissingValue() { // A value for C is missing in map NodeAdapter subject = newNodeAdapterForTest("{ key : { A: true, B: false } }"); - assertThrows( - OtpAppException.class, - () -> subject.of("key").asEnumMapAllKeysRequired(AnEnum.class, Boolean.class) + assertThrows(OtpAppException.class, () -> + subject.of("key").asEnumMapAllKeysRequired(AnEnum.class, Boolean.class) ); } @@ -367,9 +365,8 @@ void testParsePeriodDateThrowsException() { NodeAdapter subject = newNodeAdapterForTest("{ 'foo' : 'bar' }"); // Then - assertThrows( - OtpAppException.class, - () -> subject.of("foo").asDateOrRelativePeriod(null, ZoneId.systemDefault()) + assertThrows(OtpAppException.class, () -> + subject.of("foo").asDateOrRelativePeriod(null, ZoneId.systemDefault()) ); } diff --git a/application/src/test/java/org/opentripplanner/standalone/config/framework/json/NodeInfoTest.java b/application/src/test/java/org/opentripplanner/standalone/config/framework/json/NodeInfoTest.java index 3227e43b23d..55a051ade61 100644 --- a/application/src/test/java/org/opentripplanner/standalone/config/framework/json/NodeInfoTest.java +++ b/application/src/test/java/org/opentripplanner/standalone/config/framework/json/NodeInfoTest.java @@ -14,8 +14,7 @@ class NodeInfoTest { private static final OtpVersion SINCE = OtpVersion.V2_2; private static final String SUMMARY = "Summary"; private static final String DESCRIPTION = "Description"; - private final NodeInfo subject = NodeInfo - .of() + private final NodeInfo subject = NodeInfo.of() .withName(NAME) .withType(TYPE) .withOptional(DEFAULT_VALUE) @@ -88,8 +87,7 @@ void experimentalFeature() { } private NodeInfoBuilder createBuilder() { - return NodeInfo - .of() + return NodeInfo.of() .withType(ConfigType.STRING) .withName(NAME) .withSummary(SUMMARY) diff --git a/application/src/test/java/org/opentripplanner/standalone/config/framework/project/EnvironmentVariableReplacerTest.java b/application/src/test/java/org/opentripplanner/standalone/config/framework/project/EnvironmentVariableReplacerTest.java index a9cf8cf63b5..2163f704797 100644 --- a/application/src/test/java/org/opentripplanner/standalone/config/framework/project/EnvironmentVariableReplacerTest.java +++ b/application/src/test/java/org/opentripplanner/standalone/config/framework/project/EnvironmentVariableReplacerTest.java @@ -29,8 +29,7 @@ public class EnvironmentVariableReplacerTest { */ @BeforeEach public void setup() { - Map.Entry envVar = System - .getenv() + Map.Entry envVar = System.getenv() .entrySet() .stream() .filter(e -> e.getKey().matches("\\w+") && e.getValue().length() < 30) @@ -121,13 +120,11 @@ public void verifyProjectInfo() { */ @Test public void testMissingEnvironmentVariable() { - assertThrows( - OtpAppException.class, - () -> - ConfigFileLoader.nodeFromString( - "None existing env.var: '${none_existing_env_variable}'.", - "test" - ) + assertThrows(OtpAppException.class, () -> + ConfigFileLoader.nodeFromString( + "None existing env.var: '${none_existing_env_variable}'.", + "test" + ) ); } } diff --git a/application/src/test/java/org/opentripplanner/standalone/config/routerconfig/ServerConfigTest.java b/application/src/test/java/org/opentripplanner/standalone/config/routerconfig/ServerConfigTest.java index 7dcb823593c..4bcf02e5707 100644 --- a/application/src/test/java/org/opentripplanner/standalone/config/routerconfig/ServerConfigTest.java +++ b/application/src/test/java/org/opentripplanner/standalone/config/routerconfig/ServerConfigTest.java @@ -78,10 +78,7 @@ void parseIncompleteServerConfig(String traceParameterJson) { ] } } - """.replace( - "OBJECT", - traceParameterJson - ) + """.replace("OBJECT", traceParameterJson) ); assertThrows(IllegalArgumentException.class, () -> new ServerConfig("server", root)); } diff --git a/application/src/test/java/org/opentripplanner/standalone/config/routerequest/RouteRequestConfigTest.java b/application/src/test/java/org/opentripplanner/standalone/config/routerequest/RouteRequestConfigTest.java index fca70eaa388..6c41f6ec0ca 100644 --- a/application/src/test/java/org/opentripplanner/standalone/config/routerequest/RouteRequestConfigTest.java +++ b/application/src/test/java/org/opentripplanner/standalone/config/routerequest/RouteRequestConfigTest.java @@ -75,15 +75,15 @@ public void testWheelchairAccessibility() { public void testAccessEgressPenalty() { var nodeAdapter = newNodeAdapterForTest( """ - { - "accessEgress": { - "penalty": { - "FLEXIBLE" : { "timePenalty": "2m + 1.1t", "costFactor": 1.7 }, - "CAR" : { "timePenalty": "0s + 4t" } - } - } + { + "accessEgress": { + "penalty": { + "FLEXIBLE" : { "timePenalty": "2m + 1.1t", "costFactor": 1.7 }, + "CAR" : { "timePenalty": "0s + 4t" } + } } - """ + } + """ ); var subject = RouteRequestConfig.mapRouteRequest(nodeAdapter); diff --git a/application/src/test/java/org/opentripplanner/standalone/config/routerequest/TimeAndCostPenaltyMapperTest.java b/application/src/test/java/org/opentripplanner/standalone/config/routerequest/TimeAndCostPenaltyMapperTest.java index 2cbb4d115f9..56ab5dc946b 100644 --- a/application/src/test/java/org/opentripplanner/standalone/config/routerequest/TimeAndCostPenaltyMapperTest.java +++ b/application/src/test/java/org/opentripplanner/standalone/config/routerequest/TimeAndCostPenaltyMapperTest.java @@ -23,9 +23,11 @@ void mapNormal() { @Test void mapMissingTimePenalty() { - var node = newNodeAdapterForTest(""" + var node = newNodeAdapterForTest( + """ { "costFactor": 3.4 } - """); + """ + ); var ex = assertThrows(IllegalArgumentException.class, () -> TimeAndCostPenaltyMapper.map(node)); assertEquals( "When time-penalty is zero, the costFactor have no effect and should be zero as well.", diff --git a/application/src/test/java/org/opentripplanner/standalone/config/routerequest/WheelchairConfigTest.java b/application/src/test/java/org/opentripplanner/standalone/config/routerequest/WheelchairConfigTest.java index 64216e5d83f..4d8409505a9 100644 --- a/application/src/test/java/org/opentripplanner/standalone/config/routerequest/WheelchairConfigTest.java +++ b/application/src/test/java/org/opentripplanner/standalone/config/routerequest/WheelchairConfigTest.java @@ -87,12 +87,9 @@ void testMapAccessibilityWithIncompatibleValues() { "{\"unknownCost\": 200, \"inaccessibleCost\": 100, \"onlyConsiderAccessible\": true}" ); - assertThrows( - IllegalStateException.class, - () -> { - var builder = ofOnlyAccessible().copyOfWithDefaultCosts(DEFAULT_COSTS); - WheelchairConfig.mapAccessibilityPreferences(nodeAdapter, builder); - } - ); + assertThrows(IllegalStateException.class, () -> { + var builder = ofOnlyAccessible().copyOfWithDefaultCosts(DEFAULT_COSTS); + WheelchairConfig.mapAccessibilityPreferences(nodeAdapter, builder); + }); } } diff --git a/application/src/test/java/org/opentripplanner/standalone/server/RequestTraceFilterTest.java b/application/src/test/java/org/opentripplanner/standalone/server/RequestTraceFilterTest.java index 8198444f6be..3d2392d4eb3 100644 --- a/application/src/test/java/org/opentripplanner/standalone/server/RequestTraceFilterTest.java +++ b/application/src/test/java/org/opentripplanner/standalone/server/RequestTraceFilterTest.java @@ -12,8 +12,7 @@ class RequestTraceFilterTest { /** The longest string accepted the check - 512 characters long*/ - private static final String A_VERY_LONG_STRING = IntStream - .range(200, 712) + private static final String A_VERY_LONG_STRING = IntStream.range(200, 712) .mapToObj(Character::toString) .collect(Collectors.joining()); private static final String A_TOO_LONG_STRING = A_VERY_LONG_STRING + "1"; diff --git a/application/src/test/java/org/opentripplanner/street/integration/BarrierRoutingTest.java b/application/src/test/java/org/opentripplanner/street/integration/BarrierRoutingTest.java index 8092ab62bc3..9e1e93d3c58 100644 --- a/application/src/test/java/org/opentripplanner/street/integration/BarrierRoutingTest.java +++ b/application/src/test/java/org/opentripplanner/street/integration/BarrierRoutingTest.java @@ -143,13 +143,14 @@ private static String computePolyline( itineraries .stream() .flatMap(i -> i.getLegs().stream()) - .map(l -> - () -> - assertEquals( - mapMode(streetMode), - (l instanceof StreetLeg s) ? s.getMode() : null, - "Allow only " + streetMode + " legs" - ) + .map( + l -> + () -> + assertEquals( + mapMode(streetMode), + (l instanceof StreetLeg s) ? s.getMode() : null, + "Allow only " + streetMode + " legs" + ) ) ); } diff --git a/application/src/test/java/org/opentripplanner/street/integration/BikeRentalTest.java b/application/src/test/java/org/opentripplanner/street/integration/BikeRentalTest.java index 5ec83c2db92..83821f1f348 100644 --- a/application/src/test/java/org/opentripplanner/street/integration/BikeRentalTest.java +++ b/application/src/test/java/org/opentripplanner/street/integration/BikeRentalTest.java @@ -587,22 +587,17 @@ private List runStreetSearchAndCreateDescriptor( boolean useAvailabilityInformation, int keepRentedBicycleCost ) { - return runStreetSearchAndCreateDescriptor( - fromVertex, - toVertex, - arriveBy, - options -> { - options.withPreferences(preferences -> - preferences.withBike(bike -> - bike.withRental(rental -> { - rental.withUseAvailabilityInformation(useAvailabilityInformation); - rental.withArrivingInRentalVehicleAtDestinationCost(keepRentedBicycleCost); - rental.withAllowArrivingInRentedVehicleAtDestination(keepRentedBicycleCost > 0); - }) - ) - ); - } - ); + return runStreetSearchAndCreateDescriptor(fromVertex, toVertex, arriveBy, options -> { + options.withPreferences(preferences -> + preferences.withBike(bike -> + bike.withRental(rental -> { + rental.withUseAvailabilityInformation(useAvailabilityInformation); + rental.withArrivingInRentalVehicleAtDestinationCost(keepRentedBicycleCost); + rental.withAllowArrivingInRentedVehicleAtDestination(keepRentedBicycleCost > 0); + }) + ) + ); + }); } private List runStreetSearchAndCreateDescriptor( @@ -641,8 +636,7 @@ private List runStreetSearchAndCreateDescriptor( RouteRequest options, StreetMode streetMode ) { - var tree = StreetSearchBuilder - .of() + var tree = StreetSearchBuilder.of() .setHeuristic(new EuclideanRemainingWeightHeuristic()) .setRequest(options) .setStreetRequest(new StreetRequest(streetMode)) diff --git a/application/src/test/java/org/opentripplanner/street/integration/BikeWalkingTest.java b/application/src/test/java/org/opentripplanner/street/integration/BikeWalkingTest.java index 41ec677b3bb..892f841e7ed 100644 --- a/application/src/test/java/org/opentripplanner/street/integration/BikeWalkingTest.java +++ b/application/src/test/java/org/opentripplanner/street/integration/BikeWalkingTest.java @@ -383,8 +383,7 @@ private List runStreetSearchAndCreateDescriptor( ); request.setArriveBy(arriveBy); - var tree = StreetSearchBuilder - .of() + var tree = StreetSearchBuilder.of() .setHeuristic(new EuclideanRemainingWeightHeuristic()) .setRequest(request) .setStreetRequest(new StreetRequest(streetMode)) diff --git a/application/src/test/java/org/opentripplanner/street/integration/CarPickupTest.java b/application/src/test/java/org/opentripplanner/street/integration/CarPickupTest.java index 43718bb8b92..8d91422b0c2 100644 --- a/application/src/test/java/org/opentripplanner/street/integration/CarPickupTest.java +++ b/application/src/test/java/org/opentripplanner/street/integration/CarPickupTest.java @@ -175,8 +175,7 @@ private String runStreetSearchAndCreateDescriptor( var options = new RouteRequest(); options.setArriveBy(arriveBy); - var tree = StreetSearchBuilder - .of() + var tree = StreetSearchBuilder.of() .setHeuristic(new EuclideanRemainingWeightHeuristic()) .setRequest(options) .setRequest(options) diff --git a/application/src/test/java/org/opentripplanner/street/integration/ParkAndRideTest.java b/application/src/test/java/org/opentripplanner/street/integration/ParkAndRideTest.java index c4f7f52f4ec..02f5bae3581 100644 --- a/application/src/test/java/org/opentripplanner/street/integration/ParkAndRideTest.java +++ b/application/src/test/java/org/opentripplanner/street/integration/ParkAndRideTest.java @@ -158,8 +158,7 @@ protected List runStreetSearchAndCreateDescriptor( request.setWheelchair(requireWheelChairAccessible); request.setArriveBy(arriveBy); - var tree = StreetSearchBuilder - .of() + var tree = StreetSearchBuilder.of() .setHeuristic(new EuclideanRemainingWeightHeuristic()) .setRequest(request) .setStreetRequest(new StreetRequest(streetMode)) diff --git a/application/src/test/java/org/opentripplanner/street/integration/SplitEdgeTurnRestrictionsTest.java b/application/src/test/java/org/opentripplanner/street/integration/SplitEdgeTurnRestrictionsTest.java index e664b3fe2b7..47d907fe389 100644 --- a/application/src/test/java/org/opentripplanner/street/integration/SplitEdgeTurnRestrictionsTest.java +++ b/application/src/test/java/org/opentripplanner/street/integration/SplitEdgeTurnRestrictionsTest.java @@ -32,8 +32,7 @@ */ public class SplitEdgeTurnRestrictionsTest { - static final Instant dateTime = LocalDateTime - .of(2020, 3, 3, 7, 0) + static final Instant dateTime = LocalDateTime.of(2020, 3, 3, 7, 0) .atZone(ZoneIds.BERLIN) .toInstant(); // Deufringen diff --git a/application/src/test/java/org/opentripplanner/street/model/TurnRestrictionTest.java b/application/src/test/java/org/opentripplanner/street/model/TurnRestrictionTest.java index f5d660e5d88..5026417fb65 100644 --- a/application/src/test/java/org/opentripplanner/street/model/TurnRestrictionTest.java +++ b/application/src/test/java/org/opentripplanner/street/model/TurnRestrictionTest.java @@ -96,8 +96,7 @@ public void testForwardDefault() { request.withPreferences(preferences -> preferences.withWalk(w -> w.withSpeed(1.0))); - ShortestPathTree tree = StreetSearchBuilder - .of() + ShortestPathTree tree = StreetSearchBuilder.of() .setHeuristic(new EuclideanRemainingWeightHeuristic()) .setRequest(request) .setFrom(topRight) @@ -126,8 +125,7 @@ public void testForwardAsPedestrian() { var request = new RouteRequest(); request.withPreferences(pref -> pref.withWalk(w -> w.withSpeed(1.0))); - ShortestPathTree tree = StreetSearchBuilder - .of() + ShortestPathTree tree = StreetSearchBuilder.of() .setHeuristic(new EuclideanRemainingWeightHeuristic()) .setRequest(request) .setFrom(topRight) @@ -155,8 +153,7 @@ public void testForwardAsPedestrian() { public void testForwardAsCar() { var request = new RouteRequest(); - ShortestPathTree tree = StreetSearchBuilder - .of() + ShortestPathTree tree = StreetSearchBuilder.of() .setHeuristic(new EuclideanRemainingWeightHeuristic()) .setRequest(request) .setStreetRequest(new StreetRequest(StreetMode.CAR)) diff --git a/application/src/test/java/org/opentripplanner/street/model/_data/StreetModelForTest.java b/application/src/test/java/org/opentripplanner/street/model/_data/StreetModelForTest.java index 08710fe0599..08c4698c1ed 100644 --- a/application/src/test/java/org/opentripplanner/street/model/_data/StreetModelForTest.java +++ b/application/src/test/java/org/opentripplanner/street/model/_data/StreetModelForTest.java @@ -42,8 +42,7 @@ public static IntersectionVertex intersectionVertex(String label, double lat, do } public static TransitEntranceVertex transitEntranceVertex(String id, double lat, double lon) { - var entrance = Entrance - .of(id(id)) + var entrance = Entrance.of(id(id)) .withCoordinate(new WgsCoordinate(lat, lon)) .withName(I18NString.of(id)) .build(); @@ -97,8 +96,7 @@ public static StreetEdge streetEdge( } public static VehicleRentalPlaceVertex rentalVertex(RentalFormFactor formFactor) { - var rentalVehicleBuilder = TestFreeFloatingRentalVehicleBuilder - .of() + var rentalVehicleBuilder = TestFreeFloatingRentalVehicleBuilder.of() .withLatitude(-122.575133) .withLongitude(45.456773); if (formFactor == RentalFormFactor.SCOOTER) { diff --git a/application/src/test/java/org/opentripplanner/street/model/edge/AreaEdgeBuilderTest.java b/application/src/test/java/org/opentripplanner/street/model/edge/AreaEdgeBuilderTest.java index c5d7fc2afbb..04c0f0f6f0e 100644 --- a/application/src/test/java/org/opentripplanner/street/model/edge/AreaEdgeBuilderTest.java +++ b/application/src/test/java/org/opentripplanner/street/model/edge/AreaEdgeBuilderTest.java @@ -19,8 +19,7 @@ class AreaEdgeBuilderTest { StreetTraversalPermission.ALL; private static final I18NString NAME = I18NString.of("area-edge-name"); - private static final LineString GEOMETRY = GeometryUtils - .getGeometryFactory() + private static final LineString GEOMETRY = GeometryUtils.getGeometryFactory() .createLineString(new Coordinate[] { FROM_VERTEX.getCoordinate(), TO_VERTEX.getCoordinate() }); private static final AreaGroup AREA = new AreaGroup(null); diff --git a/application/src/test/java/org/opentripplanner/street/model/edge/ElevatorHopEdgeTest.java b/application/src/test/java/org/opentripplanner/street/model/edge/ElevatorHopEdgeTest.java index 8efa6940d20..d8894c26df3 100644 --- a/application/src/test/java/org/opentripplanner/street/model/edge/ElevatorHopEdgeTest.java +++ b/application/src/test/java/org/opentripplanner/street/model/edge/ElevatorHopEdgeTest.java @@ -35,8 +35,7 @@ void shouldNotTraverse(Accessibility wheelchair) { .withWheelchair(true) .withPreferences(preferences -> preferences.withWheelchair( - WheelchairPreferences - .of() + WheelchairPreferences.of() .withTrip(feature) .withStop(feature) .withElevator(feature) diff --git a/application/src/test/java/org/opentripplanner/street/model/edge/EscalatorEdgeTest.java b/application/src/test/java/org/opentripplanner/street/model/edge/EscalatorEdgeTest.java index efd984acc3d..c4e48f6cda5 100644 --- a/application/src/test/java/org/opentripplanner/street/model/edge/EscalatorEdgeTest.java +++ b/application/src/test/java/org/opentripplanner/street/model/edge/EscalatorEdgeTest.java @@ -29,8 +29,7 @@ static Stream args() { @MethodSource("args") void testWalking(double escalatorReluctance, double expectedWeight) { var edge = EscalatorEdge.createEscalatorEdge(from, to, 45, null); - var req = StreetSearchRequest - .of() + var req = StreetSearchRequest.of() .withPreferences(p -> p.withWalk(w -> w.withEscalator(escalator -> escalator.withReluctance(escalatorReluctance))) ) diff --git a/application/src/test/java/org/opentripplanner/street/model/edge/PathwayEdgeTest.java b/application/src/test/java/org/opentripplanner/street/model/edge/PathwayEdgeTest.java index 6d5574b8027..31cc46fcf06 100644 --- a/application/src/test/java/org/opentripplanner/street/model/edge/PathwayEdgeTest.java +++ b/application/src/test/java/org/opentripplanner/street/model/edge/PathwayEdgeTest.java @@ -195,8 +195,7 @@ private State assertThatEdgeIsTraversable(PathwayEdge edge, boolean wheelchair) preferences .withWalk(builder -> builder.withSpeed(10)) .withWheelchair( - WheelchairPreferences - .of() + WheelchairPreferences.of() .withTripOnlyAccessible() .withStopOnlyAccessible() .withElevatorOnlyAccessible() diff --git a/application/src/test/java/org/opentripplanner/street/model/edge/StreetEdgeBuilderTest.java b/application/src/test/java/org/opentripplanner/street/model/edge/StreetEdgeBuilderTest.java index aeddb9221c9..d3245c4bf85 100644 --- a/application/src/test/java/org/opentripplanner/street/model/edge/StreetEdgeBuilderTest.java +++ b/application/src/test/java/org/opentripplanner/street/model/edge/StreetEdgeBuilderTest.java @@ -21,8 +21,7 @@ class StreetEdgeBuilderTest { private static final I18NString NAME = I18NString.of("street-edge-name"); private static final double LENGTH = 10.5; - private static final LineString GEOMETRY = GeometryUtils - .getGeometryFactory() + private static final LineString GEOMETRY = GeometryUtils.getGeometryFactory() .createLineString(new Coordinate[] { FROM_VERTEX.getCoordinate(), TO_VERTEX.getCoordinate() }); private static final boolean WHEELCHAIR_ACCESSIBLE = false; diff --git a/application/src/test/java/org/opentripplanner/street/model/edge/StreetEdgeGeofencingTest.java b/application/src/test/java/org/opentripplanner/street/model/edge/StreetEdgeGeofencingTest.java index 0a9dfa44440..7d5bc6ed04d 100644 --- a/application/src/test/java/org/opentripplanner/street/model/edge/StreetEdgeGeofencingTest.java +++ b/application/src/test/java/org/opentripplanner/street/model/edge/StreetEdgeGeofencingTest.java @@ -289,16 +289,14 @@ public void pickupFloatingVehiclesWhenStartedInNoDropOffZoneAllNetworksAllowedBy assertEquals(BICYCLE, unknownNetworkState.currentMode()); assertNull(unknownNetworkState.getVehicleRentalNetwork()); - final State tierState = Arrays - .stream(states) + final State tierState = Arrays.stream(states) .filter(s -> NETWORK_TIER.equals(s.getVehicleRentalNetwork())) .findFirst() .get(); assertEquals(RENTING_FLOATING, tierState.getVehicleRentalState()); assertEquals(BICYCLE, tierState.currentMode()); - final State birdState = Arrays - .stream(states) + final State birdState = Arrays.stream(states) .filter(s -> NETWORK_BIRD.equals(s.getVehicleRentalNetwork())) .findFirst() .get(); @@ -321,16 +319,14 @@ public void pickupFloatingVehiclesWhenStartedInNoDropOffZoneAllNetworksAllowed() assertEquals(BICYCLE, unknownNetworkState.currentMode()); assertNull(unknownNetworkState.getVehicleRentalNetwork()); - final State tierState = Arrays - .stream(states) + final State tierState = Arrays.stream(states) .filter(s -> NETWORK_TIER.equals(s.getVehicleRentalNetwork())) .findFirst() .get(); assertEquals(RENTING_FLOATING, tierState.getVehicleRentalState()); assertEquals(BICYCLE, tierState.currentMode()); - final State birdState = Arrays - .stream(states) + final State birdState = Arrays.stream(states) .filter(s -> NETWORK_BIRD.equals(s.getVehicleRentalNetwork())) .findFirst() .get(); @@ -410,8 +406,7 @@ private static State makeHaveRentedState(Vertex vertex, StreetSearchRequest req) // this is the state that starts inside a restricted zone // (no drop off, no traversal or outside business area) // and is walking towards finding a rental vehicle - return State - .getInitialStates(Set.of(vertex), req) + return State.getInitialStates(Set.of(vertex), req) .stream() .filter(s -> s.getVehicleRentalState() == HAVE_RENTED) .findAny() @@ -419,8 +414,7 @@ private static State makeHaveRentedState(Vertex vertex, StreetSearchRequest req) } private static StreetSearchRequest defaultArriveByRequest() { - return StreetSearchRequest - .of() + return StreetSearchRequest.of() .withPreferences(p -> p.withBike(b -> b.withRental(r -> r.withAllowedNetworks(Set.of(NETWORK_TIER)))) ) @@ -433,8 +427,7 @@ private static StreetSearchRequest makeArriveByRequest( Set allowedNetworks, Set bannedNetworks ) { - return StreetSearchRequest - .of() + return StreetSearchRequest.of() .withPreferences(p -> p.withBike(b -> b.withRental(r -> @@ -464,8 +457,7 @@ private State forwardState(String network) { } private State initialState(Vertex startVertex, String network, boolean arriveBy) { - var req = StreetSearchRequest - .of() + var req = StreetSearchRequest.of() .withMode(StreetMode.SCOOTER_RENTAL) .withArriveBy(arriveBy) .build(); diff --git a/application/src/test/java/org/opentripplanner/street/model/edge/StreetEdgeRentalTraversalTest.java b/application/src/test/java/org/opentripplanner/street/model/edge/StreetEdgeRentalTraversalTest.java index e2187acad18..6e2680b49c3 100644 --- a/application/src/test/java/org/opentripplanner/street/model/edge/StreetEdgeRentalTraversalTest.java +++ b/application/src/test/java/org/opentripplanner/street/model/edge/StreetEdgeRentalTraversalTest.java @@ -41,13 +41,11 @@ private static Stream baseCases(StreetTraversalPermission p) { } static Stream allowedToTraverse() { - return Stream - .of( - StreetTraversalPermission.ALL, - StreetTraversalPermission.PEDESTRIAN_AND_BICYCLE, - StreetTraversalPermission.BICYCLE - ) - .flatMap(StreetEdgeRentalTraversalTest::baseCases); + return Stream.of( + StreetTraversalPermission.ALL, + StreetTraversalPermission.PEDESTRIAN_AND_BICYCLE, + StreetTraversalPermission.BICYCLE + ).flatMap(StreetEdgeRentalTraversalTest::baseCases); } @ParameterizedTest( @@ -75,9 +73,9 @@ void scooterBicycleTraversal( } static Stream noTraversal() { - return Stream - .of(StreetTraversalPermission.CAR, StreetTraversalPermission.NONE) - .flatMap(StreetEdgeRentalTraversalTest::baseCases); + return Stream.of(StreetTraversalPermission.CAR, StreetTraversalPermission.NONE).flatMap( + StreetEdgeRentalTraversalTest::baseCases + ); } @ParameterizedTest( diff --git a/application/src/test/java/org/opentripplanner/street/model/edge/StreetEdgeScooterTraversalTest.java b/application/src/test/java/org/opentripplanner/street/model/edge/StreetEdgeScooterTraversalTest.java index 734b1efa2b9..631ddb8b701 100644 --- a/application/src/test/java/org/opentripplanner/street/model/edge/StreetEdgeScooterTraversalTest.java +++ b/application/src/test/java/org/opentripplanner/street/model/edge/StreetEdgeScooterTraversalTest.java @@ -111,18 +111,16 @@ public void testTraverseFloatingScooter() { @Test public void testWalkingBeforeScooter() { - StreetEdge e1 = StreetModelForTest - .streetEdgeBuilder( - StreetModelForTest.V1, - StreetModelForTest.V2, - 100.0, - StreetTraversalPermission.ALL - ) + StreetEdge e1 = StreetModelForTest.streetEdgeBuilder( + StreetModelForTest.V1, + StreetModelForTest.V2, + 100.0, + StreetTraversalPermission.ALL + ) .withCarSpeed(10.0f) .buildAndConnect(); - var request = StreetSearchRequest - .of() + var request = StreetSearchRequest.of() .withPreferences(pref -> pref.withWalk(walk -> walk.withReluctance(1))) .withMode(StreetMode.SCOOTER_RENTAL); @@ -180,8 +178,7 @@ public void testScooterOptimizeTriangle() { new Coordinate(length, 0), // slope = -0.1 }; PackedCoordinateSequence elev = new PackedCoordinateSequence.Double(profile); - StreetElevationExtensionBuilder - .of(testStreet) + StreetElevationExtensionBuilder.of(testStreet) .withElevationProfile(elev) .withComputed(false) .build() @@ -225,8 +222,8 @@ public void testScooterOptimizeTriangle() { double slopeWeight = result.getWeight(); double expectedSlopeWeight = slopeWorkLength / SPEED; assertEquals(expectedSlopeWeight, slopeWeight - startState.getWeight(), DELTA); - assertTrue(length * 1.5 / SPEED < slopeWeight); - assertTrue(length * 1.5 * 10 / SPEED > slopeWeight); + assertTrue((length * 1.5) / SPEED < slopeWeight); + assertTrue((length * 1.5 * 10) / SPEED > slopeWeight); request.withPreferences(p -> p.withScooter(scooter -> scooter.withOptimizeTriangle(it -> it.withSafety(1))) diff --git a/application/src/test/java/org/opentripplanner/street/model/edge/StreetEdgeTest.java b/application/src/test/java/org/opentripplanner/street/model/edge/StreetEdgeTest.java index aa95bfd9f47..04923aced8b 100644 --- a/application/src/test/java/org/opentripplanner/street/model/edge/StreetEdgeTest.java +++ b/application/src/test/java/org/opentripplanner/street/model/edge/StreetEdgeTest.java @@ -51,19 +51,15 @@ void before() { v1 = intersectionVertex("maple_1st", 2.0, 2.0); v2 = intersectionVertex("maple_2nd", 2.0, 1.0); - this.proto = - StreetSearchRequest - .of() - .withPreferences(references -> - references - .withStreet(s -> s.withTurnReluctance(1.0)) - .withWalk(it -> it.withSpeed(1.0).withReluctance(1.0).withStairsReluctance(1.0)) - .withBike(it -> - it.withSpeed(5.0f).withReluctance(1.0).withWalking(w -> w.withSpeed(0.8)) - ) - .withCar(c -> c.withReluctance(1.0)) - ) - .build(); + this.proto = StreetSearchRequest.of() + .withPreferences(references -> + references + .withStreet(s -> s.withTurnReluctance(1.0)) + .withWalk(it -> it.withSpeed(1.0).withReluctance(1.0).withStairsReluctance(1.0)) + .withBike(it -> it.withSpeed(5.0f).withReluctance(1.0).withWalking(w -> w.withSpeed(0.8))) + .withCar(c -> c.withReluctance(1.0)) + ) + .build(); } @Test @@ -91,8 +87,7 @@ void testInAndOutAngles() { void testTraverseAsPedestrian() { StreetEdge e1 = streetEdgeBuilder(v1, v2, 100.0, ALL).withCarSpeed(10.0f).buildAndConnect(); - StreetSearchRequest options = StreetSearchRequest - .copyOf(proto) + StreetSearchRequest options = StreetSearchRequest.copyOf(proto) .withMode(StreetMode.WALK) .build(); @@ -291,8 +286,7 @@ void testElevationProfile() { 0 ); var edge = streetEdge(v0, v1, 50.0, ALL); - StreetElevationExtensionBuilder - .of(edge) + StreetElevationExtensionBuilder.of(edge) .withElevationProfile(elevationProfile) .withComputed(false) .build() @@ -337,8 +331,7 @@ void testBikeOptimizeTriangle() { new Coordinate(length, 0), // slope = -0.1 }; PackedCoordinateSequence elev = new PackedCoordinateSequence.Double(profile); - StreetElevationExtensionBuilder - .of(testStreet) + StreetElevationExtensionBuilder.of(testStreet) .withElevationProfile(elev) .withComputed(false) .build() @@ -378,8 +371,8 @@ void testBikeOptimizeTriangle() { double slopeWeight = result.getWeight(); double expectedSlopeWeight = slopeWorkLength / SPEED; assertEquals(expectedSlopeWeight, slopeWeight, DELTA); - assertTrue(length * 1.5 / SPEED < slopeWeight); - assertTrue(length * 1.5 * 10 / SPEED > slopeWeight); + assertTrue((length * 1.5) / SPEED < slopeWeight); + assertTrue((length * 1.5 * 10) / SPEED > slopeWeight); request.withPreferences(p -> p.withBike(bike -> bike.withOptimizeTriangle(it -> it.withSafety(1))) diff --git a/application/src/test/java/org/opentripplanner/street/model/edge/StreetEdgeWheelchairCostTest.java b/application/src/test/java/org/opentripplanner/street/model/edge/StreetEdgeWheelchairCostTest.java index 7c2767a6935..f23b306b5a8 100644 --- a/application/src/test/java/org/opentripplanner/street/model/edge/StreetEdgeWheelchairCostTest.java +++ b/application/src/test/java/org/opentripplanner/street/model/edge/StreetEdgeWheelchairCostTest.java @@ -77,8 +77,7 @@ public void shouldScaleCostWithMaxSlope(double slope, double reluctance, long ex }; PackedCoordinateSequence elev = new PackedCoordinateSequence.Double(profile); - StreetElevationExtensionBuilder - .of(edge) + StreetElevationExtensionBuilder.of(edge) .withElevationProfile(elev) .withComputed(true) .build() @@ -89,8 +88,7 @@ public void shouldScaleCostWithMaxSlope(double slope, double reluctance, long ex req.withWheelchair(true); req.withPreferences(preferences -> preferences.withWheelchair( - WheelchairPreferences - .of() + WheelchairPreferences.of() .withTripOnlyAccessible() .withStopOnlyAccessible() .withElevatorOnlyAccessible() @@ -130,8 +128,7 @@ public void wheelchairStairsReluctance(double stairsReluctance, long expectedCos req.withWheelchair(true); req.withPreferences(preferences -> preferences.withWheelchair( - WheelchairPreferences - .of() + WheelchairPreferences.of() .withTripOnlyAccessible() .withStopOnlyAccessible() .withElevatorOnlyAccessible() @@ -177,8 +174,7 @@ public void inaccessibleStreet(float inaccessibleStreetReluctance, long expected req.withWheelchair(true); req.withPreferences(preferences -> preferences.withWheelchair( - WheelchairPreferences - .of() + WheelchairPreferences.of() .withTripOnlyAccessible() .withStopOnlyAccessible() .withElevatorOnlyAccessible() diff --git a/application/src/test/java/org/opentripplanner/street/model/edge/StreetElevationExtensionBuilderTest.java b/application/src/test/java/org/opentripplanner/street/model/edge/StreetElevationExtensionBuilderTest.java index 080f646a919..60f1dd9b591 100644 --- a/application/src/test/java/org/opentripplanner/street/model/edge/StreetElevationExtensionBuilderTest.java +++ b/application/src/test/java/org/opentripplanner/street/model/edge/StreetElevationExtensionBuilderTest.java @@ -19,22 +19,17 @@ class StreetElevationExtensionBuilderTest { private static final Coordinate[] COORDINATES_ONE_POINT = new Coordinate[] { new Coordinate(0, 0), }; - private static final PackedCoordinateSequence ELEVATION_PROFILE_ONE_POINT = new PackedCoordinateSequence.Double( - COORDINATES_ONE_POINT, - 2 - ); + private static final PackedCoordinateSequence ELEVATION_PROFILE_ONE_POINT = + new PackedCoordinateSequence.Double(COORDINATES_ONE_POINT, 2); private static final Coordinate[] COORDINATES_TWO_POINTS = new Coordinate[] { new Coordinate(0, 0), new Coordinate(1, 1), }; - private static final PackedCoordinateSequence ELEVATION_PROFILE_TWO_POINTS = new PackedCoordinateSequence.Double( - COORDINATES_TWO_POINTS, - 2 - ); + private static final PackedCoordinateSequence ELEVATION_PROFILE_TWO_POINTS = + new PackedCoordinateSequence.Double(COORDINATES_TWO_POINTS, 2); - private static final LineString GEOMETRY = GeometryUtils - .getGeometryFactory() + private static final LineString GEOMETRY = GeometryUtils.getGeometryFactory() .createLineString( new Coordinate[] { StreetModelForTest.V1.getCoordinate(), @@ -45,12 +40,11 @@ class StreetElevationExtensionBuilderTest { @BeforeEach void setup() { - streetEdgeBuilder = - new StreetEdgeBuilder<>() - .withPermission(StreetTraversalPermission.ALL) - .withFromVertex(StreetModelForTest.V1) - .withToVertex(StreetModelForTest.V2) - .withGeometry(GEOMETRY); + streetEdgeBuilder = new StreetEdgeBuilder<>() + .withPermission(StreetTraversalPermission.ALL) + .withFromVertex(StreetModelForTest.V1) + .withToVertex(StreetModelForTest.V2) + .withGeometry(GEOMETRY); } @Test @@ -75,27 +69,31 @@ void testValidElevationProfile() { @Test void testBuildFromStreetEdge() { StreetEdge se = streetEdgeBuilder.buildAndConnect(); - StreetElevationExtensionBuilder seeb = StreetElevationExtensionBuilder - .of(se) - .withElevationProfile(ELEVATION_PROFILE_TWO_POINTS); + StreetElevationExtensionBuilder seeb = StreetElevationExtensionBuilder.of( + se + ).withElevationProfile(ELEVATION_PROFILE_TWO_POINTS); Optional streetElevationExtension = seeb.build(); assertFalse(streetElevationExtension.isEmpty()); } @Test void testBuildFromStreetEdgeBuilder() { - StreetElevationExtensionBuilder seebFromStreetEdgeBuilder = StreetElevationExtensionBuilder - .of(streetEdgeBuilder) + StreetElevationExtensionBuilder seebFromStreetEdgeBuilder = StreetElevationExtensionBuilder.of( + streetEdgeBuilder + ) .withElevationProfile(ELEVATION_PROFILE_TWO_POINTS) .withDistanceInMeters(1); - Optional streetElevationExtensionFromStreetEdgeBuilder = seebFromStreetEdgeBuilder.build(); + Optional streetElevationExtensionFromStreetEdgeBuilder = + seebFromStreetEdgeBuilder.build(); assertFalse(streetElevationExtensionFromStreetEdgeBuilder.isEmpty()); - StreetElevationExtensionBuilder seebFromStreetEdge = StreetElevationExtensionBuilder - .of(streetEdgeBuilder.buildAndConnect()) + StreetElevationExtensionBuilder seebFromStreetEdge = StreetElevationExtensionBuilder.of( + streetEdgeBuilder.buildAndConnect() + ) .withElevationProfile(ELEVATION_PROFILE_TWO_POINTS) .withDistanceInMeters(1); - Optional streetElevationExtensionFromStreetEdge = seebFromStreetEdge.build(); + Optional streetElevationExtensionFromStreetEdge = + seebFromStreetEdge.build(); assertEquals( streetElevationExtensionFromStreetEdge.orElseThrow().toString(), diff --git a/application/src/test/java/org/opentripplanner/street/model/edge/StreetTransitEntityLinkTest.java b/application/src/test/java/org/opentripplanner/street/model/edge/StreetTransitEntityLinkTest.java index 748e3b608fe..b9bc0c0aeb2 100644 --- a/application/src/test/java/org/opentripplanner/street/model/edge/StreetTransitEntityLinkTest.java +++ b/application/src/test/java/org/opentripplanner/street/model/edge/StreetTransitEntityLinkTest.java @@ -101,8 +101,7 @@ private State[] traverse(RegularStop stop, boolean onlyAccessible) { req.withWheelchair(true); req.withPreferences(p -> p.withWheelchair( - WheelchairPreferences - .of() + WheelchairPreferences.of() .withTrip(feature) .withStop(feature) .withElevator(feature) @@ -123,16 +122,15 @@ private State[] traverse(RegularStop stop, boolean onlyAccessible) { class Rental { static List allowedStates() { - return Stream - .of( - TestStateBuilder.ofScooterRental().pickUpFreeFloatingScooter(), - TestStateBuilder.ofBikeRental().pickUpFreeFloatingBike(), - // allowing cars into stations is a bit questionable but the alternatives would be quite - // computationally expensive - TestStateBuilder.ofCarRental().pickUpFreeFloatingCar(), - TestStateBuilder.ofWalking(), - TestStateBuilder.ofCycling() - ) + return Stream.of( + TestStateBuilder.ofScooterRental().pickUpFreeFloatingScooter(), + TestStateBuilder.ofBikeRental().pickUpFreeFloatingBike(), + // allowing cars into stations is a bit questionable but the alternatives would be quite + // computationally expensive + TestStateBuilder.ofCarRental().pickUpFreeFloatingCar(), + TestStateBuilder.ofWalking(), + TestStateBuilder.ofCycling() + ) .map(TestStateBuilder::build) .toList(); } @@ -144,14 +142,13 @@ void freeFloatingVehiclesAreAllowedIntoStops(State state) { } static List notAllowedStates() { - return Stream - .of( - TestStateBuilder.ofBikeRental().pickUpBikeFromStation(), - TestStateBuilder.ofCarRental().pickUpCarFromStation(), - // for bike and ride you need to drop the bike at a parking facility first - TestStateBuilder.ofBikeAndRide().streetEdge(), - TestStateBuilder.parkAndRide().streetEdge() - ) + return Stream.of( + TestStateBuilder.ofBikeRental().pickUpBikeFromStation(), + TestStateBuilder.ofCarRental().pickUpCarFromStation(), + // for bike and ride you need to drop the bike at a parking facility first + TestStateBuilder.ofBikeAndRide().streetEdge(), + TestStateBuilder.parkAndRide().streetEdge() + ) .map(TestStateBuilder::build) .toList(); } @@ -181,8 +178,7 @@ private static RegularStop stopForTest( Station parent, Accessibility wheelchair ) { - return TEST_MODEL - .stop(idAndName) + return TEST_MODEL.stop(idAndName) .withDescription(NonLocalizedString.ofNullable(desc)) .withCoordinate(new WgsCoordinate(lat, lon)) .withWheelchairAccessibility(wheelchair) diff --git a/application/src/test/java/org/opentripplanner/street/model/edge/StreetVehicleParkingLinkTest.java b/application/src/test/java/org/opentripplanner/street/model/edge/StreetVehicleParkingLinkTest.java index a44bed87bdf..a6d654b45f1 100644 --- a/application/src/test/java/org/opentripplanner/street/model/edge/StreetVehicleParkingLinkTest.java +++ b/application/src/test/java/org/opentripplanner/street/model/edge/StreetVehicleParkingLinkTest.java @@ -101,15 +101,13 @@ void linkedToGraphWithOutgoing() { } private static VehicleParkingEntranceVertex buildVertex(Set parkingTags) { - var parking = VehicleParking - .builder() + var parking = VehicleParking.builder() .id(id("parking")) .coordinate(new WgsCoordinate(1, 1)) .tags(parkingTags) .build(); - var entrance = VehicleParkingEntrance - .builder() + var entrance = VehicleParkingEntrance.builder() .vehicleParking(parking) .entranceId(id("entrance")) .coordinate(new WgsCoordinate(1, 1)) diff --git a/application/src/test/java/org/opentripplanner/street/model/edge/TemporaryPartialStreetEdgeBuilderTest.java b/application/src/test/java/org/opentripplanner/street/model/edge/TemporaryPartialStreetEdgeBuilderTest.java index 7040a78ce04..99d02dac823 100644 --- a/application/src/test/java/org/opentripplanner/street/model/edge/TemporaryPartialStreetEdgeBuilderTest.java +++ b/application/src/test/java/org/opentripplanner/street/model/edge/TemporaryPartialStreetEdgeBuilderTest.java @@ -23,8 +23,7 @@ class TemporaryPartialStreetEdgeBuilderTest { StreetTraversalPermission.ALL; private static final I18NString NAME = I18NString.of("temporary-partial-street-edge-name"); - private static final LineString GEOMETRY = GeometryUtils - .getGeometryFactory() + private static final LineString GEOMETRY = GeometryUtils.getGeometryFactory() .createLineString(new Coordinate[] { FROM_VERTEX.getCoordinate(), TO_VERTEX.getCoordinate() }); @Test diff --git a/application/src/test/java/org/opentripplanner/street/model/edge/TemporaryPartialStreetEdgeTest.java b/application/src/test/java/org/opentripplanner/street/model/edge/TemporaryPartialStreetEdgeTest.java index 0cd63555a21..eb50164f37b 100644 --- a/application/src/test/java/org/opentripplanner/street/model/edge/TemporaryPartialStreetEdgeTest.java +++ b/application/src/test/java/org/opentripplanner/street/model/edge/TemporaryPartialStreetEdgeTest.java @@ -133,8 +133,7 @@ public void testTraversalOfSubdividedEdge() { tempEdges ); - StreetSearchRequest request = StreetSearchRequest - .of() + StreetSearchRequest request = StreetSearchRequest.of() .withMode(StreetMode.CAR) .withPreferences(p -> p.withStreet(s -> s.withTurnReluctance(1.0))) .build(); diff --git a/application/src/test/java/org/opentripplanner/street/model/edge/VehicleParkingEdgeTest.java b/application/src/test/java/org/opentripplanner/street/model/edge/VehicleParkingEdgeTest.java index 4fa7f682dfb..efbfab78296 100644 --- a/application/src/test/java/org/opentripplanner/street/model/edge/VehicleParkingEdgeTest.java +++ b/application/src/test/java/org/opentripplanner/street/model/edge/VehicleParkingEdgeTest.java @@ -131,8 +131,7 @@ private VehicleParking createVehicleParking( boolean carPlaces, VehicleParkingSpaces availability ) { - return StreetModelForTest - .vehicleParking() + return StreetModelForTest.vehicleParking() .id(TimetableRepositoryForTest.id("VehicleParking")) .bicyclePlaces(bicyclePlaces) .carPlaces(carPlaces) diff --git a/application/src/test/java/org/opentripplanner/street/model/edge/VehicleParkingPreferredTagsTest.java b/application/src/test/java/org/opentripplanner/street/model/edge/VehicleParkingPreferredTagsTest.java index 2f18f02b89b..78244507f31 100644 --- a/application/src/test/java/org/opentripplanner/street/model/edge/VehicleParkingPreferredTagsTest.java +++ b/application/src/test/java/org/opentripplanner/street/model/edge/VehicleParkingPreferredTagsTest.java @@ -62,14 +62,12 @@ private void runTest( double expectedCost, boolean arriveBy ) { - var parking = StreetModelForTest - .vehicleParking() + var parking = StreetModelForTest.vehicleParking() .tags(parkingTags) .availability(VehicleParkingSpaces.builder().bicycleSpaces(100).build()) .bicyclePlaces(true) .build(); - var entrance = VehicleParkingEntrance - .builder() + var entrance = VehicleParkingEntrance.builder() .name(new NonLocalizedString("bike parking")) .vehicleParking(parking) .walkAccessible(true) diff --git a/application/src/test/java/org/opentripplanner/street/model/edge/VehicleRentalEdgeTest.java b/application/src/test/java/org/opentripplanner/street/model/edge/VehicleRentalEdgeTest.java index e8a1282327c..409c8fd279c 100644 --- a/application/src/test/java/org/opentripplanner/street/model/edge/VehicleRentalEdgeTest.java +++ b/application/src/test/java/org/opentripplanner/street/model/edge/VehicleRentalEdgeTest.java @@ -196,8 +196,7 @@ private void initEdgeAndRequest(StreetMode mode, int vehicles, int spaces) { class StartedReverseSearchInNoGeofencingZone { private static final String NETWORK = "tier"; - private static final StreetSearchRequest SEARCH_REQUEST = StreetSearchRequest - .of() + private static final StreetSearchRequest SEARCH_REQUEST = StreetSearchRequest.of() .withMode(StreetMode.SCOOTER_RENTAL) .withArriveBy(true) .build(); @@ -208,14 +207,13 @@ class StartedReverseSearchInNoGeofencingZone { RENTAL_PLACE.latitude = 1; RENTAL_PLACE.longitude = 1; RENTAL_PLACE.id = new FeedScopedId(NETWORK, "123"); - RENTAL_PLACE.vehicleType = - new RentalVehicleType( - new FeedScopedId(NETWORK, "scooter"), - "scooter", - RentalFormFactor.SCOOTER, - RentalVehicleType.PropulsionType.ELECTRIC, - 100000d - ); + RENTAL_PLACE.vehicleType = new RentalVehicleType( + new FeedScopedId(NETWORK, "scooter"), + "scooter", + RentalFormFactor.SCOOTER, + RentalVehicleType.PropulsionType.ELECTRIC, + 100000d + ); } @Test @@ -269,8 +267,7 @@ private void initEdgeAndRequest( boolean useRealtime, boolean banNetwork ) { - var station = TestVehicleRentalStationBuilder - .of() + var station = TestVehicleRentalStationBuilder.of() .withVehicles(vehicles) .withSpaces(spaces) .withOverloadingAllowed(overloadingAllowed) @@ -283,22 +280,18 @@ private void initEdgeAndRequest( Set bannedNetworks = banNetwork ? Set.of(station.getNetwork()) : Set.of(); - this.request = - StreetSearchRequest - .of() - .withMode(mode) - .withPreferences(preferences -> - preferences - .withBike(bike -> - bike.withRental(rental -> - rental - .withUseAvailabilityInformation(useRealtime) - .withBannedNetworks(bannedNetworks) - ) + this.request = StreetSearchRequest.of() + .withMode(mode) + .withPreferences(preferences -> + preferences + .withBike(bike -> + bike.withRental(rental -> + rental.withUseAvailabilityInformation(useRealtime).withBannedNetworks(bannedNetworks) ) - .build() - ) - .build(); + ) + .build() + ) + .build(); } private void initFreeFloatingEdgeAndRequest( @@ -314,20 +307,18 @@ private void initFreeFloatingEdgeAndRequest( ? Set.of(this.vertex.getStation().getNetwork()) : Set.of(); - this.request = - StreetSearchRequest - .of() - .withMode(mode) - .withPreferences(preferences -> - preferences - .withCar(car -> car.withRental(rental -> rental.withBannedNetworks(bannedNetworks))) - .withBike(bike -> bike.withRental(rental -> rental.withBannedNetworks(bannedNetworks))) - .withScooter(scooter -> - scooter.withRental(rental -> rental.withBannedNetworks(bannedNetworks)) - ) - .build() - ) - .build(); + this.request = StreetSearchRequest.of() + .withMode(mode) + .withPreferences(preferences -> + preferences + .withCar(car -> car.withRental(rental -> rental.withBannedNetworks(bannedNetworks))) + .withBike(bike -> bike.withRental(rental -> rental.withBannedNetworks(bannedNetworks))) + .withScooter(scooter -> + scooter.withRental(rental -> rental.withBannedNetworks(bannedNetworks)) + ) + .build() + ) + .build(); } private State[] rent() { diff --git a/application/src/test/java/org/opentripplanner/street/search/state/StateDataTest.java b/application/src/test/java/org/opentripplanner/street/search/state/StateDataTest.java index 83cec24cd77..da642d6dd5c 100644 --- a/application/src/test/java/org/opentripplanner/street/search/state/StateDataTest.java +++ b/application/src/test/java/org/opentripplanner/street/search/state/StateDataTest.java @@ -13,9 +13,9 @@ class StateDataTest { static Stream cases() { - return Arrays - .stream(StreetMode.values()) - .flatMap(mode -> Stream.of(Arguments.of(true, mode), Arguments.of(false, mode))); + return Arrays.stream(StreetMode.values()).flatMap(mode -> + Stream.of(Arguments.of(true, mode), Arguments.of(false, mode)) + ); } @ParameterizedTest(name = "arriveBy={0}, streetMode={1}") diff --git a/application/src/test/java/org/opentripplanner/street/search/state/TestStateBuilder.java b/application/src/test/java/org/opentripplanner/street/search/state/TestStateBuilder.java index 9605d950ae0..2d07f49f3e4 100644 --- a/application/src/test/java/org/opentripplanner/street/search/state/TestStateBuilder.java +++ b/application/src/test/java/org/opentripplanner/street/search/state/TestStateBuilder.java @@ -46,9 +46,9 @@ public class TestStateBuilder { private final TimetableRepositoryForTest testModel = TimetableRepositoryForTest.of(); - private static final Instant DEFAULT_START_TIME = OffsetDateTime - .parse("2023-04-18T12:00:00+02:00") - .toInstant(); + private static final Instant DEFAULT_START_TIME = OffsetDateTime.parse( + "2023-04-18T12:00:00+02:00" + ).toInstant(); private int count = 1; private State currentState; @@ -58,16 +58,14 @@ private TestStateBuilder(StreetMode mode) { } private TestStateBuilder(StreetMode mode, AccessEgressType type) { - currentState = - new State( - StreetModelForTest.intersectionVertex(count, count), - StreetSearchRequest - .of() - .withArriveBy(type.isEgress()) - .withMode(mode) - .withStartTime(DEFAULT_START_TIME) - .build() - ); + currentState = new State( + StreetModelForTest.intersectionVertex(count, count), + StreetSearchRequest.of() + .withArriveBy(type.isEgress()) + .withMode(mode) + .withStartTime(DEFAULT_START_TIME) + .build() + ); } /** @@ -200,10 +198,10 @@ public TestStateBuilder elevator() { new NonLocalizedString("1") ); - currentState = - EdgeTraverser - .traverseEdges(currentState, List.of(link, boardEdge, hopEdge, alightEdge)) - .orElseThrow(); + currentState = EdgeTraverser.traverseEdges( + currentState, + List.of(link, boardEdge, hopEdge, alightEdge) + ).orElseThrow(); return this; } @@ -325,8 +323,10 @@ private TestStateBuilder pickUpRentalVehicle( var edge = VehicleRentalEdge.createVehicleRentalEdge(vertex, rentalFormFactor); State[] traverse = edge.traverse(currentState); - currentState = - Arrays.stream(traverse).filter(it -> it.currentMode() != TraverseMode.WALK).findFirst().get(); + currentState = Arrays.stream(traverse) + .filter(it -> it.currentMode() != TraverseMode.WALK) + .findFirst() + .get(); assertTrue(currentState.isRentingVehicle()); diff --git a/application/src/test/java/org/opentripplanner/test/support/JsonAssertions.java b/application/src/test/java/org/opentripplanner/test/support/JsonAssertions.java index 9c1254ae298..0c85928c24e 100644 --- a/application/src/test/java/org/opentripplanner/test/support/JsonAssertions.java +++ b/application/src/test/java/org/opentripplanner/test/support/JsonAssertions.java @@ -29,14 +29,11 @@ public static void assertEqualJson(String expected, JsonNode actual) { try { var actualNode = MAPPER.readTree(actual.toString()); var exp = MAPPER.readTree(expected); - assertEquals( - exp, - actualNode, - () -> - "Expected '%s' but actual was '%s'".formatted( - JsonSupport.prettyPrint(exp), - JsonSupport.prettyPrint(actualNode) - ) + assertEquals(exp, actualNode, () -> + "Expected '%s' but actual was '%s'".formatted( + JsonSupport.prettyPrint(exp), + JsonSupport.prettyPrint(actualNode) + ) ); } catch (JsonProcessingException e) { throw new RuntimeException(e); diff --git a/application/src/test/java/org/opentripplanner/test/support/TestTableParser.java b/application/src/test/java/org/opentripplanner/test/support/TestTableParser.java index f48ff1517f2..71cde3fe03b 100644 --- a/application/src/test/java/org/opentripplanner/test/support/TestTableParser.java +++ b/application/src/test/java/org/opentripplanner/test/support/TestTableParser.java @@ -82,20 +82,22 @@ void testParser() { assertEquals(List.of(List.of(1, 1.2)), toLists("1 | 1.2")); assertEquals( List.of(List.of(1, 7)), - toLists(""" - # input | output - 1 | 7 - """) + toLists( + """ + # input | output + 1 | 7 + """ + ) ); assertEquals( List.of(List.of(1, 2, 3, 6, 6), List.of(1, 2, 4, 7, 8)), toLists( """ - # input || result - # a | b | c || a+b+c | a*b*c - 1 | 2 | 3 || 6 | 6 # Expect sum and product to be the same - 1 | 2 | 4 || 7 | 8 # Product is larger - """ + # input || result + # a | b | c || a+b+c | a*b*c + 1 | 2 | 3 || 6 | 6 # Expect sum and product to be the same + 1 | 2 | 4 || 7 | 8 # Product is larger + """ ) ); } diff --git a/application/src/test/java/org/opentripplanner/transit/api/model/RequiredFilterValuesTest.java b/application/src/test/java/org/opentripplanner/transit/api/model/RequiredFilterValuesTest.java index 7c06128c7bf..f6aa00a696f 100644 --- a/application/src/test/java/org/opentripplanner/transit/api/model/RequiredFilterValuesTest.java +++ b/application/src/test/java/org/opentripplanner/transit/api/model/RequiredFilterValuesTest.java @@ -9,24 +9,18 @@ class RequiredFilterValuesTest { @Test void testEmptyIsInvalid() { - IllegalArgumentException e = assertThrows( - IllegalArgumentException.class, - () -> { - FilterValues.ofRequired("empty", List.of()); - } - ); + IllegalArgumentException e = assertThrows(IllegalArgumentException.class, () -> { + FilterValues.ofRequired("empty", List.of()); + }); assertEquals("Filter empty values must not be empty.", e.getMessage()); } @Test void testNullIsInvalid() { List nullList = null; - IllegalArgumentException e = assertThrows( - IllegalArgumentException.class, - () -> { - FilterValues.ofRequired("null", nullList); - } - ); + IllegalArgumentException e = assertThrows(IllegalArgumentException.class, () -> { + FilterValues.ofRequired("null", nullList); + }); assertEquals("Filter null values must not be empty.", e.getMessage()); } } diff --git a/application/src/test/java/org/opentripplanner/transit/model/TimetableRepositoryArchitectureTest.java b/application/src/test/java/org/opentripplanner/transit/model/TimetableRepositoryArchitectureTest.java index d2ae7e2e47d..dd47ec72548 100644 --- a/application/src/test/java/org/opentripplanner/transit/model/TimetableRepositoryArchitectureTest.java +++ b/application/src/test/java/org/opentripplanner/transit/model/TimetableRepositoryArchitectureTest.java @@ -44,51 +44,45 @@ void enforceOrganizationPackageDependencies() { @Test void enforceSitePackageDependencies() { - SITE - .dependsOn( - FRAMEWORK_UTILS, - JACKSON_ANNOTATIONS, - GEO_UTILS, - TRANSIT_FRAMEWORK, - BASIC, - ORGANIZATION - ) - .verify(); + SITE.dependsOn( + FRAMEWORK_UTILS, + JACKSON_ANNOTATIONS, + GEO_UTILS, + TRANSIT_FRAMEWORK, + BASIC, + ORGANIZATION + ).verify(); } @Test void enforceNetworkPackageDependencies() { // TODO OTP2 temporarily allow circular dependency between network and timetable - NETWORK - .dependsOn( - FRAMEWORK_UTILS, - GEO_UTILS, - TRANSIT_FRAMEWORK, - BASIC, - ORGANIZATION, - SITE, - TIMETABLE, - LEGACY_MODEL, - RAPTOR_API, - RAPTOR_ADAPTER_API - ) - .verify(); + NETWORK.dependsOn( + FRAMEWORK_UTILS, + GEO_UTILS, + TRANSIT_FRAMEWORK, + BASIC, + ORGANIZATION, + SITE, + TIMETABLE, + LEGACY_MODEL, + RAPTOR_API, + RAPTOR_ADAPTER_API + ).verify(); } @Test void enforceTimetablePackageDependencies() { - TIMETABLE - .dependsOn( - FRAMEWORK_UTILS, - TRANSIT_FRAMEWORK, - BASIC, - ORGANIZATION, - NETWORK, - SITE, - TIMETABLE_BOOKING, - LEGACY_MODEL - ) - .verify(); + TIMETABLE.dependsOn( + FRAMEWORK_UTILS, + TRANSIT_FRAMEWORK, + BASIC, + ORGANIZATION, + NETWORK, + SITE, + TIMETABLE_BOOKING, + LEGACY_MODEL + ).verify(); } @Test diff --git a/application/src/test/java/org/opentripplanner/transit/model/_data/PatternTestModel.java b/application/src/test/java/org/opentripplanner/transit/model/_data/PatternTestModel.java index e046ea42247..06c6c8123ea 100644 --- a/application/src/test/java/org/opentripplanner/transit/model/_data/PatternTestModel.java +++ b/application/src/test/java/org/opentripplanner/transit/model/_data/PatternTestModel.java @@ -16,8 +16,7 @@ public class PatternTestModel { public static final Route ROUTE_1 = TimetableRepositoryForTest.route("1").build(); private static final FeedScopedId SERVICE_ID = id("service"); - private static final Trip TRIP = TimetableRepositoryForTest - .trip("t1") + private static final Trip TRIP = TimetableRepositoryForTest.trip("t1") .withRoute(ROUTE_1) .withServiceId(SERVICE_ID) .build(); @@ -34,15 +33,13 @@ public class PatternTestModel { * Creates a trip pattern that has a stop pattern, trip times and a trip with a service id. */ public static TripPattern pattern() { - var tt = ScheduledTripTimes - .of() + var tt = ScheduledTripTimes.of() .withTrip(TRIP) .withArrivalTimes("10:00 10:05") .withDepartureTimes("10:00 10:05") .build(); - return TimetableRepositoryForTest - .tripPattern("1", ROUTE_1) + return TimetableRepositoryForTest.tripPattern("1", ROUTE_1) .withStopPattern(STOP_PATTERN) .withScheduledTimeTableBuilder(builder -> builder.addTripTimes(tt)) .build(); diff --git a/application/src/test/java/org/opentripplanner/transit/model/_data/TimetableRepositoryForTest.java b/application/src/test/java/org/opentripplanner/transit/model/_data/TimetableRepositoryForTest.java index f8dbf97efb9..5f7c24732ed 100644 --- a/application/src/test/java/org/opentripplanner/transit/model/_data/TimetableRepositoryForTest.java +++ b/application/src/test/java/org/opentripplanner/transit/model/_data/TimetableRepositoryForTest.java @@ -59,8 +59,7 @@ public class TimetableRepositoryForTest { public static final WgsCoordinate ANY_COORDINATE = new WgsCoordinate(60.0, 10.0); // This is used to create valid objects - do not use it for verification - private static final Polygon ANY_POLYGON = GeometryUtils - .getGeometryFactory() + private static final Polygon ANY_POLYGON = GeometryUtils.getGeometryFactory() .createPolygon( new Coordinate[] { Coordinates.of(61.0, 10.0), @@ -70,21 +69,20 @@ public class TimetableRepositoryForTest { } ); - public static final Agency AGENCY = Agency - .of(id("A1")) + public static final Agency AGENCY = Agency.of(id("A1")) .withName("Agency Test") .withTimezone(TIME_ZONE_ID) .withUrl("https://www.agency.com") .build(); - public static final Agency OTHER_AGENCY = Agency - .of(id("AX")) + public static final Agency OTHER_AGENCY = Agency.of(id("AX")) .withName("Other Agency Test") .withTimezone(TIME_ZONE_ID) .withUrl("https://www.otheragency.com") .build(); - public static final Agency OTHER_FEED_AGENCY = Agency - .of(FeedScopedId.ofNullable("F2", "other.feed-agency")) + public static final Agency OTHER_FEED_AGENCY = Agency.of( + FeedScopedId.ofNullable("F2", "other.feed-agency") + ) .withName("Other feed agency") .withTimezone(TIME_ZONE_ID) .withUrl("https:/www.otherfeedagency.com") @@ -158,8 +156,7 @@ public RegularStopBuilder stop(String idAndName, double lat, double lon) { } public StationBuilder station(String idAndName) { - return Station - .of(new FeedScopedId(FEED_ID, idAndName)) + return Station.of(new FeedScopedId(FEED_ID, idAndName)) .withName(new NonLocalizedString(idAndName)) .withCode(idAndName) .withCoordinate(60.0, 10.0) @@ -230,8 +227,7 @@ public Place place(String name, double lat, double lon) { */ public List stopTimesEvery5Minutes(int count, Trip trip, String time) { var startTime = TimeUtils.time(time); - return IntStream - .range(0, count) + return IntStream.range(0, count) .mapToObj(seq -> stopTime(trip, (seq + 1) * 10, startTime + (seq * 60 * 5))) .toList(); } @@ -264,13 +260,13 @@ public static StopPattern stopPattern(List stops) { * Create {@link TripPatternBuilder} fully set up with the given mode. */ public TripPatternBuilder pattern(TransitMode mode) { - return tripPattern(mode.name(), route(mode.name()).withMode(mode).build()) - .withStopPattern(stopPattern(3)); + return tripPattern(mode.name(), route(mode.name()).withMode(mode).build()).withStopPattern( + stopPattern(3) + ); } public UnscheduledTrip unscheduledTrip(String id, StopLocation... stops) { - var stopTimes = Arrays - .stream(stops) + var stopTimes = Arrays.stream(stops) .map(s -> { var st = new StopTime(); st.setStop(s); @@ -284,16 +280,14 @@ public UnscheduledTrip unscheduledTrip(String id, StopLocation... stops) { } public UnscheduledTrip unscheduledTrip(String id, List stopTimes) { - return UnscheduledTrip - .of(id(id)) + return UnscheduledTrip.of(id(id)) .withTrip(trip("flex-trip").build()) .withStopTimes(stopTimes) .build(); } public ScheduledDeviatedTrip scheduledDeviatedTrip(String id, StopTime... stopTimes) { - return ScheduledDeviatedTrip - .of(id(id)) + return ScheduledDeviatedTrip.of(id(id)) .withTrip(trip("flex-trip").build()) .withStopTimes(Arrays.asList(stopTimes)) .build(); diff --git a/application/src/test/java/org/opentripplanner/transit/model/basic/NoticeTest.java b/application/src/test/java/org/opentripplanner/transit/model/basic/NoticeTest.java index 5306d31077a..1e0ee3d7b6f 100644 --- a/application/src/test/java/org/opentripplanner/transit/model/basic/NoticeTest.java +++ b/application/src/test/java/org/opentripplanner/transit/model/basic/NoticeTest.java @@ -15,8 +15,7 @@ class NoticeTest { private static final String TEXT = "text"; private static final String PUBLIC_CODE = "public code"; - private static final Notice subject = Notice - .of(TimetableRepositoryForTest.id(ID)) + private static final Notice subject = Notice.of(TimetableRepositoryForTest.id(ID)) .withPublicCode(PUBLIC_CODE) .withText(TEXT) .build(); diff --git a/application/src/test/java/org/opentripplanner/transit/model/filter/expr/NullSafeWrapperMatcherTest.java b/application/src/test/java/org/opentripplanner/transit/model/filter/expr/NullSafeWrapperMatcherTest.java index 0b2f008a2fc..8c59c99d48b 100644 --- a/application/src/test/java/org/opentripplanner/transit/model/filter/expr/NullSafeWrapperMatcherTest.java +++ b/application/src/test/java/org/opentripplanner/transit/model/filter/expr/NullSafeWrapperMatcherTest.java @@ -20,10 +20,8 @@ void testMatches() { @Test void testFailsWithoutNullSafeWrapperMatcher() { - var matcher = new CaseInsensitiveStringPrefixMatcher<>( - "string", - "here's a string", - s -> s.toString() + var matcher = new CaseInsensitiveStringPrefixMatcher<>("string", "here's a string", s -> + s.toString() ); assertThrows(NullPointerException.class, () -> matcher.match(null)); } diff --git a/application/src/test/java/org/opentripplanner/transit/model/filter/transit/RegularStopMatcherFactoryTest.java b/application/src/test/java/org/opentripplanner/transit/model/filter/transit/RegularStopMatcherFactoryTest.java index 5cfeaf2780f..400a574a886 100644 --- a/application/src/test/java/org/opentripplanner/transit/model/filter/transit/RegularStopMatcherFactoryTest.java +++ b/application/src/test/java/org/opentripplanner/transit/model/filter/transit/RegularStopMatcherFactoryTest.java @@ -15,15 +15,15 @@ class RegularStopMatcherFactoryTest { @BeforeAll static void setup() { - stop1 = - RegularStop - .of(new FeedScopedId("agency", "stopId"), new AtomicInteger()::getAndIncrement) - .build(); - - stop2 = - RegularStop - .of(new FeedScopedId("otherAgency", "otherStopId"), new AtomicInteger()::getAndIncrement) - .build(); + stop1 = RegularStop.of( + new FeedScopedId("agency", "stopId"), + new AtomicInteger()::getAndIncrement + ).build(); + + stop2 = RegularStop.of( + new FeedScopedId("otherAgency", "otherStopId"), + new AtomicInteger()::getAndIncrement + ).build(); } @Test diff --git a/application/src/test/java/org/opentripplanner/transit/model/filter/transit/RouteMatcherFactoryTest.java b/application/src/test/java/org/opentripplanner/transit/model/filter/transit/RouteMatcherFactoryTest.java index 9b70bf93f43..5f3d2faae6c 100644 --- a/application/src/test/java/org/opentripplanner/transit/model/filter/transit/RouteMatcherFactoryTest.java +++ b/application/src/test/java/org/opentripplanner/transit/model/filter/transit/RouteMatcherFactoryTest.java @@ -22,28 +22,23 @@ class RouteMatcherFactoryTest { @BeforeEach void setup() { - route1 = - Route - .of(new FeedScopedId("feedId", "routeId")) - .withAgency(TimetableRepositoryForTest.agency("AGENCY")) - .withMode(TransitMode.BUS) - .withShortName("ROUTE1") - .withLongName(I18NString.of("ROUTE1LONG")) - .build(); - route2 = - Route - .of(new FeedScopedId("otherFeedId", "otherRouteId")) - .withAgency(TimetableRepositoryForTest.agency("OTHER_AGENCY")) - .withMode(TransitMode.RAIL) - .withShortName("ROUTE2") - .withLongName(I18NString.of("ROUTE2LONG")) - .build(); + route1 = Route.of(new FeedScopedId("feedId", "routeId")) + .withAgency(TimetableRepositoryForTest.agency("AGENCY")) + .withMode(TransitMode.BUS) + .withShortName("ROUTE1") + .withLongName(I18NString.of("ROUTE1LONG")) + .build(); + route2 = Route.of(new FeedScopedId("otherFeedId", "otherRouteId")) + .withAgency(TimetableRepositoryForTest.agency("OTHER_AGENCY")) + .withMode(TransitMode.RAIL) + .withShortName("ROUTE2") + .withLongName(I18NString.of("ROUTE2LONG")) + .build(); } @Test void testAgencies() { - FindRoutesRequest request = FindRoutesRequest - .of() + FindRoutesRequest request = FindRoutesRequest.of() .withAgencies(FilterValues.ofEmptyIsEverything("agencies", List.of("AGENCY"))) .build(); @@ -54,8 +49,7 @@ void testAgencies() { @Test void testTransitModes() { - FindRoutesRequest request = FindRoutesRequest - .of() + FindRoutesRequest request = FindRoutesRequest.of() .withTransitModes(FilterValues.ofEmptyIsEverything("transitModes", List.of(TransitMode.BUS))) .build(); @@ -75,8 +69,7 @@ void testShortLongName() { @Test void testShortNames() { - FindRoutesRequest request = FindRoutesRequest - .of() + FindRoutesRequest request = FindRoutesRequest.of() .withShortNames(FilterValues.ofEmptyIsEverything("publicCodes", List.of("ROUTE1", "ROUTE3"))) .build(); @@ -125,8 +118,7 @@ void testLongNameCaseInsensitivePrefixMatch() { @Test void testAll() { - FindRoutesRequest request = FindRoutesRequest - .of() + FindRoutesRequest request = FindRoutesRequest.of() .withAgencies(FilterValues.ofEmptyIsEverything("agencies", List.of("AGENCY"))) .withTransitModes(FilterValues.ofEmptyIsEverything("transitModes", List.of(TransitMode.BUS))) .withShortName("ROUTE1") diff --git a/application/src/test/java/org/opentripplanner/transit/model/filter/transit/StopLocationMatcherFactoryTest.java b/application/src/test/java/org/opentripplanner/transit/model/filter/transit/StopLocationMatcherFactoryTest.java index 1e0817824eb..2d100b68919 100644 --- a/application/src/test/java/org/opentripplanner/transit/model/filter/transit/StopLocationMatcherFactoryTest.java +++ b/application/src/test/java/org/opentripplanner/transit/model/filter/transit/StopLocationMatcherFactoryTest.java @@ -19,17 +19,19 @@ public class StopLocationMatcherFactoryTest { @BeforeEach void setup() { - stop1 = - RegularStop - .of(new FeedScopedId("agency", "stopId"), new AtomicInteger()::getAndIncrement) - .withName(I18NString.of("name")) - .build(); - - stop2 = - RegularStop - .of(new FeedScopedId("otherAgency", "otherStopId"), new AtomicInteger()::getAndIncrement) - .withName(I18NString.of("otherName")) - .build(); + stop1 = RegularStop.of( + new FeedScopedId("agency", "stopId"), + new AtomicInteger()::getAndIncrement + ) + .withName(I18NString.of("name")) + .build(); + + stop2 = RegularStop.of( + new FeedScopedId("otherAgency", "otherStopId"), + new AtomicInteger()::getAndIncrement + ) + .withName(I18NString.of("otherName")) + .build(); } @Test diff --git a/application/src/test/java/org/opentripplanner/transit/model/filter/transit/TripMatcherFactoryTest.java b/application/src/test/java/org/opentripplanner/transit/model/filter/transit/TripMatcherFactoryTest.java index ec4b3241dd5..bb3f6f4b9f5 100644 --- a/application/src/test/java/org/opentripplanner/transit/model/filter/transit/TripMatcherFactoryTest.java +++ b/application/src/test/java/org/opentripplanner/transit/model/filter/transit/TripMatcherFactoryTest.java @@ -25,69 +25,56 @@ public class TripMatcherFactoryTest { @BeforeEach void setup() { - tripRut = - Trip - .of(new FeedScopedId("F", "RUT:route:trip:1")) - .withRoute( - Route - .of(new FeedScopedId("F", "RUT:route:1")) - .withAgency( - Agency - .of(new FeedScopedId("F", "RUT:1")) - .withName("RUT") - .withTimezone("Europe/Oslo") - .build() - ) - .withMode(TransitMode.BUS) - .withShortName("BUS") - .build() - ) - .withServiceId(new FeedScopedId("F", "RUT:route:trip:1")) - .build(); - tripRut2 = - Trip - .of(new FeedScopedId("F", "RUT:route:trip:2")) - .withRoute( - Route - .of(new FeedScopedId("F", "RUT:route:2")) - .withAgency( - Agency - .of(new FeedScopedId("F", "RUT:2")) - .withName("RUT") - .withTimezone("Europe/Oslo") - .build() - ) - .withMode(TransitMode.BUS) - .withShortName("BUS") - .build() - ) - .withServiceId(new FeedScopedId("F", "RUT:route:trip:2")) - .build(); - tripAkt = - Trip - .of(new FeedScopedId("F", "AKT:route:trip:1")) - .withRoute( - Route - .of(new FeedScopedId("F", "AKT:route:1")) - .withAgency( - Agency - .of(new FeedScopedId("F", "AKT")) - .withName("AKT") - .withTimezone("Europe/Oslo") - .build() - ) - .withMode(TransitMode.BUS) - .withShortName("BUS") - .build() - ) - .withServiceId(new FeedScopedId("F", "AKT:route:trip:1")) - .build(); + tripRut = Trip.of(new FeedScopedId("F", "RUT:route:trip:1")) + .withRoute( + Route.of(new FeedScopedId("F", "RUT:route:1")) + .withAgency( + Agency.of(new FeedScopedId("F", "RUT:1")) + .withName("RUT") + .withTimezone("Europe/Oslo") + .build() + ) + .withMode(TransitMode.BUS) + .withShortName("BUS") + .build() + ) + .withServiceId(new FeedScopedId("F", "RUT:route:trip:1")) + .build(); + tripRut2 = Trip.of(new FeedScopedId("F", "RUT:route:trip:2")) + .withRoute( + Route.of(new FeedScopedId("F", "RUT:route:2")) + .withAgency( + Agency.of(new FeedScopedId("F", "RUT:2")) + .withName("RUT") + .withTimezone("Europe/Oslo") + .build() + ) + .withMode(TransitMode.BUS) + .withShortName("BUS") + .build() + ) + .withServiceId(new FeedScopedId("F", "RUT:route:trip:2")) + .build(); + tripAkt = Trip.of(new FeedScopedId("F", "AKT:route:trip:1")) + .withRoute( + Route.of(new FeedScopedId("F", "AKT:route:1")) + .withAgency( + Agency.of(new FeedScopedId("F", "AKT")) + .withName("AKT") + .withTimezone("Europe/Oslo") + .build() + ) + .withMode(TransitMode.BUS) + .withShortName("BUS") + .build() + ) + .withServiceId(new FeedScopedId("F", "AKT:route:trip:1")) + .build(); } @Test void testMatchRouteId() { - TripRequest request = TripRequest - .of() + TripRequest request = TripRequest.of() .withRoutes( FilterValues.ofEmptyIsEverything("routes", List.of(new FeedScopedId("F", "RUT:route:1"))) ) @@ -113,8 +100,7 @@ void testMatchDefaultAll() { @Test void testMatchAgencyId() { - TripRequest request = TripRequest - .of() + TripRequest request = TripRequest.of() .withAgencies( FilterValues.ofEmptyIsEverything("agencies", List.of(new FeedScopedId("F", "RUT:1"))) ) @@ -129,8 +115,7 @@ void testMatchAgencyId() { @Test void testMatchServiceDates() { - TripRequest request = TripRequest - .of() + TripRequest request = TripRequest.of() .withServiceDates( FilterValues.ofEmptyIsEverything( "operatingDays", diff --git a/application/src/test/java/org/opentripplanner/transit/model/filter/transit/TripOnServiceDateMatcherFactoryTest.java b/application/src/test/java/org/opentripplanner/transit/model/filter/transit/TripOnServiceDateMatcherFactoryTest.java index dcfb10b5947..f5041f53d4b 100644 --- a/application/src/test/java/org/opentripplanner/transit/model/filter/transit/TripOnServiceDateMatcherFactoryTest.java +++ b/application/src/test/java/org/opentripplanner/transit/model/filter/transit/TripOnServiceDateMatcherFactoryTest.java @@ -24,87 +24,72 @@ class TripOnServiceDateMatcherFactoryTest { @BeforeEach void setup() { - tripOnServiceDateRut = - TripOnServiceDate - .of(new FeedScopedId("F", "RUT:route:trip:date:1")) - .withTrip( - Trip - .of(new FeedScopedId("F", "RUT:route:trip:1")) - .withRoute( - Route - .of(new FeedScopedId("F", "RUT:route:1")) - .withAgency( - Agency - .of(new FeedScopedId("F", "RUT:1")) - .withName("RUT") - .withTimezone("Europe/Oslo") - .build() - ) - .withMode(TransitMode.BUS) - .withShortName("BUS") - .build() - ) - .build() - ) - .withServiceDate(LocalDate.of(2024, 2, 22)) - .build(); - - tripOnServiceDateRut2 = - TripOnServiceDate - .of(new FeedScopedId("F", "RUT:route:trip:date:2")) - .withTrip( - Trip - .of(new FeedScopedId("F", "RUT:route:trip:2")) - .withRoute( - Route - .of(new FeedScopedId("F", "RUT:route:2")) - .withAgency( - Agency - .of(new FeedScopedId("F", "RUT:2")) - .withName("RUT") - .withTimezone("Europe/Oslo") - .build() - ) - .withMode(TransitMode.BUS) - .withShortName("BUS") - .build() - ) - .build() - ) - .withServiceDate(LocalDate.of(2024, 2, 22)) - .build(); - - tripOnServiceDateAkt = - TripOnServiceDate - .of(new FeedScopedId("F", "AKT:route:trip:date:1")) - .withTrip( - Trip - .of(new FeedScopedId("F", "AKT:route:trip:1")) - .withRoute( - Route - .of(new FeedScopedId("F", "AKT:route:1")) - .withAgency( - Agency - .of(new FeedScopedId("F", "AKT:1")) - .withName("AKT") - .withTimezone("Europe/Oslo") - .build() - ) - .withMode(TransitMode.BUS) - .withShortName("BUS") - .build() - ) - .build() - ) - .withServiceDate(LocalDate.of(2024, 2, 22)) - .build(); + tripOnServiceDateRut = TripOnServiceDate.of(new FeedScopedId("F", "RUT:route:trip:date:1")) + .withTrip( + Trip.of(new FeedScopedId("F", "RUT:route:trip:1")) + .withRoute( + Route.of(new FeedScopedId("F", "RUT:route:1")) + .withAgency( + Agency.of(new FeedScopedId("F", "RUT:1")) + .withName("RUT") + .withTimezone("Europe/Oslo") + .build() + ) + .withMode(TransitMode.BUS) + .withShortName("BUS") + .build() + ) + .build() + ) + .withServiceDate(LocalDate.of(2024, 2, 22)) + .build(); + + tripOnServiceDateRut2 = TripOnServiceDate.of(new FeedScopedId("F", "RUT:route:trip:date:2")) + .withTrip( + Trip.of(new FeedScopedId("F", "RUT:route:trip:2")) + .withRoute( + Route.of(new FeedScopedId("F", "RUT:route:2")) + .withAgency( + Agency.of(new FeedScopedId("F", "RUT:2")) + .withName("RUT") + .withTimezone("Europe/Oslo") + .build() + ) + .withMode(TransitMode.BUS) + .withShortName("BUS") + .build() + ) + .build() + ) + .withServiceDate(LocalDate.of(2024, 2, 22)) + .build(); + + tripOnServiceDateAkt = TripOnServiceDate.of(new FeedScopedId("F", "AKT:route:trip:date:1")) + .withTrip( + Trip.of(new FeedScopedId("F", "AKT:route:trip:1")) + .withRoute( + Route.of(new FeedScopedId("F", "AKT:route:1")) + .withAgency( + Agency.of(new FeedScopedId("F", "AKT:1")) + .withName("AKT") + .withTimezone("Europe/Oslo") + .build() + ) + .withMode(TransitMode.BUS) + .withShortName("BUS") + .build() + ) + .build() + ) + .withServiceDate(LocalDate.of(2024, 2, 22)) + .build(); } @Test void testMatchOperatingDays() { - TripOnServiceDateRequest request = TripOnServiceDateRequest - .of(FilterValues.ofRequired("serviceDates", List.of(LocalDate.of(2024, 2, 22)))) - .build(); + TripOnServiceDateRequest request = TripOnServiceDateRequest.of( + FilterValues.ofRequired("serviceDates", List.of(LocalDate.of(2024, 2, 22))) + ).build(); Matcher matcher = TripOnServiceDateMatcherFactory.of(request); @@ -115,8 +100,9 @@ void testMatchOperatingDays() { @Test void testMatchMultiple() { - TripOnServiceDateRequest request = TripOnServiceDateRequest - .of(FilterValues.ofRequired("serviceDates", List.of(LocalDate.of(2024, 2, 22)))) + TripOnServiceDateRequest request = TripOnServiceDateRequest.of( + FilterValues.ofRequired("serviceDates", List.of(LocalDate.of(2024, 2, 22))) + ) .withAgencies( FilterValues.ofEmptyIsEverything("agencies", List.of(new FeedScopedId("F", "RUT:1"))) ) @@ -140,8 +126,9 @@ void testMatchMultiple() { @Test void testMatchMultipleServiceJourneyMatchers() { - TripOnServiceDateRequest request = TripOnServiceDateRequest - .of(FilterValues.ofRequired("serviceDates", List.of(LocalDate.of(2024, 2, 22)))) + TripOnServiceDateRequest request = TripOnServiceDateRequest.of( + FilterValues.ofRequired("serviceDates", List.of(LocalDate.of(2024, 2, 22))) + ) .withAgencies( FilterValues.ofEmptyIsEverything( "agencies", diff --git a/application/src/test/java/org/opentripplanner/transit/model/framework/FeedScopedIdTest.java b/application/src/test/java/org/opentripplanner/transit/model/framework/FeedScopedIdTest.java index a7c7c5ff058..e419152b8a4 100644 --- a/application/src/test/java/org/opentripplanner/transit/model/framework/FeedScopedIdTest.java +++ b/application/src/test/java/org/opentripplanner/transit/model/framework/FeedScopedIdTest.java @@ -38,11 +38,8 @@ void parseList(String input) { } ) void throwExceptionForInvisibleChar(String input) { - Assertions.assertThrows( - IllegalArgumentException.class, - () -> { - FeedScopedId.parseList(input); - } - ); + Assertions.assertThrows(IllegalArgumentException.class, () -> { + FeedScopedId.parseList(input); + }); } } diff --git a/application/src/test/java/org/opentripplanner/transit/model/network/GroupOfRoutesTest.java b/application/src/test/java/org/opentripplanner/transit/model/network/GroupOfRoutesTest.java index 2788b62bae9..0779163b165 100644 --- a/application/src/test/java/org/opentripplanner/transit/model/network/GroupOfRoutesTest.java +++ b/application/src/test/java/org/opentripplanner/transit/model/network/GroupOfRoutesTest.java @@ -17,8 +17,7 @@ public class GroupOfRoutesTest { private static final String NAME = "test_name"; private static final String DESCRIPTION = "description"; - private static final GroupOfRoutes subject = GroupOfRoutes - .of(TimetableRepositoryForTest.id(ID)) + private static final GroupOfRoutes subject = GroupOfRoutes.of(TimetableRepositoryForTest.id(ID)) .withPrivateCode(PRIVATE_CODE) .withShortName(SHORT_NAME) .withName(NAME) diff --git a/application/src/test/java/org/opentripplanner/transit/model/network/RouteTest.java b/application/src/test/java/org/opentripplanner/transit/model/network/RouteTest.java index 65bc3bb53a9..ce913954752 100644 --- a/application/src/test/java/org/opentripplanner/transit/model/network/RouteTest.java +++ b/application/src/test/java/org/opentripplanner/transit/model/network/RouteTest.java @@ -27,8 +27,7 @@ class RouteTest { private static final TransitMode TRANSIT_MODE = TransitMode.BUS; private static final String NETEX_SUBMODE_NAME = "submode"; private static final SubMode NETEX_SUBMODE = SubMode.of(NETEX_SUBMODE_NAME); - private static final Operator OPERATOR = Operator - .of(FeedScopedId.parse("x:operatorId")) + private static final Operator OPERATOR = Operator.of(FeedScopedId.parse("x:operatorId")) .withName("operator name") .build(); @@ -40,8 +39,7 @@ class RouteTest { private static final Integer GTFS_SORT_ORDER = 0; private static final String URL = "url"; public static final Agency AGENCY = TimetableRepositoryForTest.AGENCY; - private static final Route subject = Route - .of(TimetableRepositoryForTest.id(ID)) + private static final Route subject = Route.of(TimetableRepositoryForTest.id(ID)) .withShortName(SHORT_NAME) .withLongName(LONG_NAME) .withDescription(DESCRIPTION) @@ -108,8 +106,7 @@ void sameAs() { subject .copy() .withOperator( - Operator - .of(FeedScopedId.parse("x:otherOperatorId")) + Operator.of(FeedScopedId.parse("x:otherOperatorId")) .withName("other operator name") .build() ) diff --git a/application/src/test/java/org/opentripplanner/transit/model/network/TripPatternTest.java b/application/src/test/java/org/opentripplanner/transit/model/network/TripPatternTest.java index 32563545694..2baba7183a6 100644 --- a/application/src/test/java/org/opentripplanner/transit/model/network/TripPatternTest.java +++ b/application/src/test/java/org/opentripplanner/transit/model/network/TripPatternTest.java @@ -39,8 +39,7 @@ class TripPatternTest { makeLineString(STOP_B.getCoordinate(), STOP_Y.getCoordinate(), STOP_C.getCoordinate()) ); - private static final TripPattern subject = TripPattern - .of(id(ID)) + private static final TripPattern subject = TripPattern.of(id(ID)) .withName(NAME) .withRoute(ROUTE) .withStopPattern(STOP_PATTERN) @@ -74,8 +73,7 @@ void copy() { @Test void hopGeometryForReplacementPattern() { - var pattern = TripPattern - .of(id("replacement")) + var pattern = TripPattern.of(id("replacement")) .withName("replacement") .withRoute(ROUTE) .withStopPattern(TimetableRepositoryForTest.stopPattern(STOP_A, STOP_B, STOP_X, STOP_Y)) @@ -124,8 +122,7 @@ void shouldAddName() { @Test void shouldResolveMode() { - var patternWithoutExplicitMode = TripPattern - .of(id(ID)) + var patternWithoutExplicitMode = TripPattern.of(id(ID)) .withRoute(ROUTE) .withStopPattern(STOP_PATTERN) .build(); diff --git a/application/src/test/java/org/opentripplanner/transit/model/network/grouppriority/DefaultTransitGroupPriorityCalculatorTest.java b/application/src/test/java/org/opentripplanner/transit/model/network/grouppriority/DefaultTransitGroupPriorityCalculatorTest.java index 34a7d3ef698..438385c095b 100644 --- a/application/src/test/java/org/opentripplanner/transit/model/network/grouppriority/DefaultTransitGroupPriorityCalculatorTest.java +++ b/application/src/test/java/org/opentripplanner/transit/model/network/grouppriority/DefaultTransitGroupPriorityCalculatorTest.java @@ -8,7 +8,8 @@ class DefaultTransitGroupPriorityCalculatorTest { - private final DefaultTransitGroupPriorityCalculator subject = new DefaultTransitGroupPriorityCalculator(); + private final DefaultTransitGroupPriorityCalculator subject = + new DefaultTransitGroupPriorityCalculator(); @Test void mergeGroupIds() { diff --git a/application/src/test/java/org/opentripplanner/transit/model/network/grouppriority/MatchersTest.java b/application/src/test/java/org/opentripplanner/transit/model/network/grouppriority/MatchersTest.java index cdda3755d37..386f0ec0aa1 100644 --- a/application/src/test/java/org/opentripplanner/transit/model/network/grouppriority/MatchersTest.java +++ b/application/src/test/java/org/opentripplanner/transit/model/network/grouppriority/MatchersTest.java @@ -13,14 +13,12 @@ class MatchersTest { - private final TestRouteData r1 = TestRouteData - .rail("R1") + private final TestRouteData r1 = TestRouteData.rail("R1") .withSubmode("express") .withAgency("A1") .build(); private final TestRouteData b1 = TestRouteData.bus("B2").withAgency("A2").build(); - private final TestRouteData f1 = TestRouteData - .ferry("F1") + private final TestRouteData f1 = TestRouteData.ferry("F1") .withAgency("A1") .withSubmode("localFerry") .build(); @@ -103,8 +101,7 @@ void testSubMode() { @Test void testAnd() { var subject = Matchers.of( - TransitGroupSelect - .of() + TransitGroupSelect.of() .addSubModeRegexp(List.of("express")) .addRouteIds(List.of(r1routeId)) .addModes(List.of(TransitMode.RAIL, TransitMode.TRAM)) @@ -125,8 +122,7 @@ void testAnd() { @Test void testToString() { var subject = Matchers.of( - TransitGroupSelect - .of() + TransitGroupSelect.of() .addModes(List.of(TransitMode.BUS, TransitMode.TRAM)) .addAgencyIds(List.of(anyId, r1agencyId)) .addRouteIds(List.of(r1routeId)) diff --git a/application/src/test/java/org/opentripplanner/transit/model/network/grouppriority/TransitGroupPriorityServiceTest.java b/application/src/test/java/org/opentripplanner/transit/model/network/grouppriority/TransitGroupPriorityServiceTest.java index fe2cb361f07..2ee728be9de 100644 --- a/application/src/test/java/org/opentripplanner/transit/model/network/grouppriority/TransitGroupPriorityServiceTest.java +++ b/application/src/test/java/org/opentripplanner/transit/model/network/grouppriority/TransitGroupPriorityServiceTest.java @@ -80,8 +80,7 @@ void emptyConfigurationShouldReturnGroupZero() { @Test void lookupTransitGroupIdByAgency() { - var select = TransitGroupSelect - .of() + var select = TransitGroupSelect.of() .addModes(List.of(TransitMode.BUS, TransitMode.RAIL)) .build(); diff --git a/application/src/test/java/org/opentripplanner/transit/model/organization/AgencyTest.java b/application/src/test/java/org/opentripplanner/transit/model/organization/AgencyTest.java index 2eff9b5d112..15c1db22dec 100644 --- a/application/src/test/java/org/opentripplanner/transit/model/organization/AgencyTest.java +++ b/application/src/test/java/org/opentripplanner/transit/model/organization/AgencyTest.java @@ -19,8 +19,7 @@ class AgencyTest { private static final String FARE_URL = "http://fare.aaa.com"; private static final String LANG = "image"; - private static final Agency subject = Agency - .of(TimetableRepositoryForTest.id(ID)) + private static final Agency subject = Agency.of(TimetableRepositoryForTest.id(ID)) .withName(NAME) .withUrl(URL) .withTimezone(TIMEZONE) diff --git a/application/src/test/java/org/opentripplanner/transit/model/organization/BrandingTest.java b/application/src/test/java/org/opentripplanner/transit/model/organization/BrandingTest.java index 37e6217cd15..c609195e55b 100644 --- a/application/src/test/java/org/opentripplanner/transit/model/organization/BrandingTest.java +++ b/application/src/test/java/org/opentripplanner/transit/model/organization/BrandingTest.java @@ -18,8 +18,7 @@ public class BrandingTest { private static final String DESCRIPTION = "test_description"; private static final String IMAGE = "test_image"; - Branding subject = Branding - .of(TimetableRepositoryForTest.id(ID)) + Branding subject = Branding.of(TimetableRepositoryForTest.id(ID)) .withShortName(SHORT_NAME) .withName(NAME) .withUrl(URL) diff --git a/application/src/test/java/org/opentripplanner/transit/model/organization/ContactInfoTest.java b/application/src/test/java/org/opentripplanner/transit/model/organization/ContactInfoTest.java index e8184ded215..09a3b677f37 100644 --- a/application/src/test/java/org/opentripplanner/transit/model/organization/ContactInfoTest.java +++ b/application/src/test/java/org/opentripplanner/transit/model/organization/ContactInfoTest.java @@ -16,8 +16,7 @@ class ContactInfoTest { private static final String EMAIL = "email@aaa.com"; private static final String INFO_URL = "http://info.aaa.com"; - private static final ContactInfo subject = ContactInfo - .of() + private static final ContactInfo subject = ContactInfo.of() .withContactPerson(CONTACT_PERSON) .withPhoneNumber(PHONE) .withEMail(EMAIL) diff --git a/application/src/test/java/org/opentripplanner/transit/model/organization/OperatorTest.java b/application/src/test/java/org/opentripplanner/transit/model/organization/OperatorTest.java index 12decb1fc82..a7df910ced0 100644 --- a/application/src/test/java/org/opentripplanner/transit/model/organization/OperatorTest.java +++ b/application/src/test/java/org/opentripplanner/transit/model/organization/OperatorTest.java @@ -16,8 +16,7 @@ class OperatorTest { private static final String URL = "http://info.aaa.com"; private static final String PHONE = "+47 95566333"; - private static final Operator subject = Operator - .of(TimetableRepositoryForTest.id(ID)) + private static final Operator subject = Operator.of(TimetableRepositoryForTest.id(ID)) .withName(NAME) .withUrl(URL) .withPhone(PHONE) diff --git a/application/src/test/java/org/opentripplanner/transit/model/site/AreaStopTest.java b/application/src/test/java/org/opentripplanner/transit/model/site/AreaStopTest.java index cf68a51ae5a..f7bdbb0a1d2 100644 --- a/application/src/test/java/org/opentripplanner/transit/model/site/AreaStopTest.java +++ b/application/src/test/java/org/opentripplanner/transit/model/site/AreaStopTest.java @@ -33,8 +33,7 @@ class AreaStopTest { private static final AreaStop subject = areaStopBuilder().withGeometry(GEOMETRY).build(); private static AreaStopBuilder areaStopBuilder() { - return SiteRepository - .of() + return SiteRepository.of() .areaStop(TimetableRepositoryForTest.id(ID)) .withName(NAME) .withDescription(DESCRIPTION) diff --git a/application/src/test/java/org/opentripplanner/transit/model/site/BoardingAreaTest.java b/application/src/test/java/org/opentripplanner/transit/model/site/BoardingAreaTest.java index 235f4c089ff..d781b7858dd 100644 --- a/application/src/test/java/org/opentripplanner/transit/model/site/BoardingAreaTest.java +++ b/application/src/test/java/org/opentripplanner/transit/model/site/BoardingAreaTest.java @@ -17,13 +17,11 @@ class BoardingAreaTest { private static final String ID = "1"; private static final I18NString NAME = new NonLocalizedString("name"); private static final I18NString DESCRIPTION = new NonLocalizedString("description"); - private static final RegularStop PARENT_STOP = TimetableRepositoryForTest - .of() + private static final RegularStop PARENT_STOP = TimetableRepositoryForTest.of() .stop("stopId") .build(); - private static final BoardingArea subject = BoardingArea - .of(TimetableRepositoryForTest.id(ID)) + private static final BoardingArea subject = BoardingArea.of(TimetableRepositoryForTest.id(ID)) .withName(NAME) .withDescription(DESCRIPTION) .withParentStop(PARENT_STOP) diff --git a/application/src/test/java/org/opentripplanner/transit/model/site/EntranceTest.java b/application/src/test/java/org/opentripplanner/transit/model/site/EntranceTest.java index 0a9bb5cb5a4..de48e349394 100644 --- a/application/src/test/java/org/opentripplanner/transit/model/site/EntranceTest.java +++ b/application/src/test/java/org/opentripplanner/transit/model/site/EntranceTest.java @@ -26,8 +26,7 @@ class EntranceTest { private static final TimetableRepositoryForTest TEST_MODEL = TimetableRepositoryForTest.of(); private static final Station PARENT_STATION = TEST_MODEL.station("stationId").build(); - private static final Entrance subject = Entrance - .of(TimetableRepositoryForTest.id(ID)) + private static final Entrance subject = Entrance.of(TimetableRepositoryForTest.id(ID)) .withName(NAME) .withDescription(DESCRIPTION) .withCode(CODE) diff --git a/application/src/test/java/org/opentripplanner/transit/model/site/FareZoneTest.java b/application/src/test/java/org/opentripplanner/transit/model/site/FareZoneTest.java index c98f18d7aec..84bc310f0b8 100644 --- a/application/src/test/java/org/opentripplanner/transit/model/site/FareZoneTest.java +++ b/application/src/test/java/org/opentripplanner/transit/model/site/FareZoneTest.java @@ -13,8 +13,7 @@ class FareZoneTest { private static final String ID = "1"; private static final String NAME = "name"; - private static final FareZone subject = FareZone - .of(TimetableRepositoryForTest.id(ID)) + private static final FareZone subject = FareZone.of(TimetableRepositoryForTest.id(ID)) .withName(NAME) .build(); diff --git a/application/src/test/java/org/opentripplanner/transit/model/site/GroupOfStationsTest.java b/application/src/test/java/org/opentripplanner/transit/model/site/GroupOfStationsTest.java index f1816e5a4b7..e03541bf3ea 100644 --- a/application/src/test/java/org/opentripplanner/transit/model/site/GroupOfStationsTest.java +++ b/application/src/test/java/org/opentripplanner/transit/model/site/GroupOfStationsTest.java @@ -20,13 +20,13 @@ class GroupOfStationsTest { private static final Station STATION = TEST_MODEL.station("1:station").build(); - private static final StopLocation STOP_LOCATION = TEST_MODEL - .stop("1:stop", 1d, 1d) + private static final StopLocation STOP_LOCATION = TEST_MODEL.stop("1:stop", 1d, 1d) .withParentStation(STATION) .build(); - private static final GroupOfStations subject = GroupOfStations - .of(TimetableRepositoryForTest.id(ID)) + private static final GroupOfStations subject = GroupOfStations.of( + TimetableRepositoryForTest.id(ID) + ) .withName(NAME) .addChildStation(STATION) .build(); diff --git a/application/src/test/java/org/opentripplanner/transit/model/site/GroupStopTest.java b/application/src/test/java/org/opentripplanner/transit/model/site/GroupStopTest.java index 06c7a7dff1c..da04d0d79d9 100644 --- a/application/src/test/java/org/opentripplanner/transit/model/site/GroupStopTest.java +++ b/application/src/test/java/org/opentripplanner/transit/model/site/GroupStopTest.java @@ -24,11 +24,12 @@ class GroupStopTest { private static final String ID = "1"; private static final I18NString NAME = new NonLocalizedString("name"); - private static final StopLocation STOP_LOCATION = TEST_MODEL - .stop("1:stop", Coordinates.BERLIN.getX(), Coordinates.BERLIN.getY()) - .build(); - private static final GroupStop subject = SiteRepository - .of() + private static final StopLocation STOP_LOCATION = TEST_MODEL.stop( + "1:stop", + Coordinates.BERLIN.getX(), + Coordinates.BERLIN.getY() + ).build(); + private static final GroupStop subject = SiteRepository.of() .groupStop(TimetableRepositoryForTest.id(ID)) .withName(NAME) .addLocation(STOP_LOCATION) @@ -36,15 +37,18 @@ class GroupStopTest { @Test void testGroupStopGeometry() { - StopLocation stopLocation1 = TEST_MODEL - .stop("1:stop", Coordinates.BERLIN.getX(), Coordinates.BERLIN.getY()) - .build(); - StopLocation stopLocation2 = TEST_MODEL - .stop("2:stop", Coordinates.HAMBURG.getX(), Coordinates.HAMBURG.getY()) - .build(); - - GroupStop groupStop = SiteRepository - .of() + StopLocation stopLocation1 = TEST_MODEL.stop( + "1:stop", + Coordinates.BERLIN.getX(), + Coordinates.BERLIN.getY() + ).build(); + StopLocation stopLocation2 = TEST_MODEL.stop( + "2:stop", + Coordinates.HAMBURG.getX(), + Coordinates.HAMBURG.getY() + ).build(); + + GroupStop groupStop = SiteRepository.of() .groupStop(TimetableRepositoryForTest.id(ID)) .withName(NAME) .addLocation(stopLocation1) @@ -60,12 +64,13 @@ void testGroupStopGeometry() { @Test void testGroupStopEncompassingAreaGeometry() { - StopLocation stopLocation = TEST_MODEL - .stop("1:stop", Coordinates.BERLIN.getX(), Coordinates.BERLIN.getY()) - .build(); + StopLocation stopLocation = TEST_MODEL.stop( + "1:stop", + Coordinates.BERLIN.getX(), + Coordinates.BERLIN.getY() + ).build(); - GroupStop groupStop = SiteRepository - .of() + GroupStop groupStop = SiteRepository.of() .groupStop(TimetableRepositoryForTest.id(ID)) .withName(NAME) .addLocation(stopLocation) diff --git a/application/src/test/java/org/opentripplanner/transit/model/site/MultiModalStationTest.java b/application/src/test/java/org/opentripplanner/transit/model/site/MultiModalStationTest.java index 93be75e5c13..75b4a6c9345 100644 --- a/application/src/test/java/org/opentripplanner/transit/model/site/MultiModalStationTest.java +++ b/application/src/test/java/org/opentripplanner/transit/model/site/MultiModalStationTest.java @@ -23,8 +23,9 @@ class MultiModalStationTest { private static final Station STATION_2 = TEST_MODEL.station("1:2").build(); public static final Set CHILD_STATIONS = Set.of(STATION_1, STATION_2); - private static final MultiModalStation subject = MultiModalStation - .of(TimetableRepositoryForTest.id(ID)) + private static final MultiModalStation subject = MultiModalStation.of( + TimetableRepositoryForTest.id(ID) + ) .withName(NAME) .withChildStations(CHILD_STATIONS) .withCoordinate(new WgsCoordinate(1, 1)) diff --git a/application/src/test/java/org/opentripplanner/transit/model/site/PathwayNodeTest.java b/application/src/test/java/org/opentripplanner/transit/model/site/PathwayNodeTest.java index 77de36ceb71..41740fab659 100644 --- a/application/src/test/java/org/opentripplanner/transit/model/site/PathwayNodeTest.java +++ b/application/src/test/java/org/opentripplanner/transit/model/site/PathwayNodeTest.java @@ -25,8 +25,7 @@ class PathwayNodeTest { public static final WgsCoordinate COORDINATE = new WgsCoordinate(0, 0); private static final StopLevel LEVEL = new StopLevel("level", 0); private static final Accessibility WHEELCHAIR_ACCESSIBILITY = Accessibility.POSSIBLE; - private static final PathwayNode subject = PathwayNode - .of(TimetableRepositoryForTest.id(ID)) + private static final PathwayNode subject = PathwayNode.of(TimetableRepositoryForTest.id(ID)) .withName(NAME) .withDescription(DESCRIPTION) .withCode(CODE) diff --git a/application/src/test/java/org/opentripplanner/transit/model/site/PathwayTest.java b/application/src/test/java/org/opentripplanner/transit/model/site/PathwayTest.java index 09bf034e6ba..90456abccf0 100644 --- a/application/src/test/java/org/opentripplanner/transit/model/site/PathwayTest.java +++ b/application/src/test/java/org/opentripplanner/transit/model/site/PathwayTest.java @@ -16,15 +16,13 @@ class PathwayTest { private static final String ID = "1:pathway"; private static final String NAME = "name"; private static final PathwayMode MODE = PathwayMode.ESCALATOR; - private static final PathwayNode FROM = PathwayNode - .of(TimetableRepositoryForTest.id("1:node")) + private static final PathwayNode FROM = PathwayNode.of(TimetableRepositoryForTest.id("1:node")) .withCoordinate(new WgsCoordinate(20, 30)) .build(); private static final RegularStop TO = TimetableRepositoryForTest.of().stop("1:stop").build(); public static final int TRAVERSAL_TIME = 120; - private final Pathway subject = Pathway - .of(TimetableRepositoryForTest.id(ID)) + private final Pathway subject = Pathway.of(TimetableRepositoryForTest.id(ID)) .withPathwayMode(MODE) .withSignpostedAs(NAME) .withFromStop(FROM) diff --git a/application/src/test/java/org/opentripplanner/transit/model/site/RegularStopTest.java b/application/src/test/java/org/opentripplanner/transit/model/site/RegularStopTest.java index cfcab8a0b13..e51facec0bb 100644 --- a/application/src/test/java/org/opentripplanner/transit/model/site/RegularStopTest.java +++ b/application/src/test/java/org/opentripplanner/transit/model/site/RegularStopTest.java @@ -35,8 +35,7 @@ class RegularStopTest { public static final ZoneId TIME_ZONE = ZoneId.of(TimetableRepositoryForTest.TIME_ZONE_ID); private static final String PLATFORM_CODE = "platformCode"; - private static final RegularStop subject = SiteRepository - .of() + private static final RegularStop subject = SiteRepository.of() .regularStop(TimetableRepositoryForTest.id(ID)) .withName(NAME) .withDescription(DESCRIPTION) diff --git a/application/src/test/java/org/opentripplanner/transit/model/site/StationTest.java b/application/src/test/java/org/opentripplanner/transit/model/site/StationTest.java index 958816bc74d..a834908ea56 100644 --- a/application/src/test/java/org/opentripplanner/transit/model/site/StationTest.java +++ b/application/src/test/java/org/opentripplanner/transit/model/site/StationTest.java @@ -27,8 +27,7 @@ class StationTest { private static final TimetableRepositoryForTest TEST_MODEL = TimetableRepositoryForTest.of(); private static final Station PARENT_STATION = TEST_MODEL.station("stationId").build(); - private static final Station subject = Station - .of(TimetableRepositoryForTest.id(ID)) + private static final Station subject = Station.of(TimetableRepositoryForTest.id(ID)) .withName(NAME) .withDescription(DESCRIPTION) .withCode(CODE) diff --git a/application/src/test/java/org/opentripplanner/transit/model/timetable/RealTimeTripTimesTest.java b/application/src/test/java/org/opentripplanner/transit/model/timetable/RealTimeTripTimesTest.java index 93e4c107b00..5176bedf36e 100644 --- a/application/src/test/java/org/opentripplanner/transit/model/timetable/RealTimeTripTimesTest.java +++ b/application/src/test/java/org/opentripplanner/transit/model/timetable/RealTimeTripTimesTest.java @@ -271,8 +271,10 @@ public void testPositiveHopTimeWithTerminalCancellation() { ); assertFalse(updatedTripTimes.interpolateMissingTimes()); - error = - assertThrows(DataValidationException.class, updatedTripTimes::validateNonIncreasingTimes); + error = assertThrows( + DataValidationException.class, + updatedTripTimes::validateNonIncreasingTimes + ); assertEquals( "NEGATIVE_HOP_TIME for stop position 2 in trip Trip{F:testTripId RRtestTripId}.", error.error().message() diff --git a/application/src/test/java/org/opentripplanner/transit/model/timetable/ScheduledTripTimesTest.java b/application/src/test/java/org/opentripplanner/transit/model/timetable/ScheduledTripTimesTest.java index 06469a34b2a..600e8e5aa3b 100644 --- a/application/src/test/java/org/opentripplanner/transit/model/timetable/ScheduledTripTimesTest.java +++ b/application/src/test/java/org/opentripplanner/transit/model/timetable/ScheduledTripTimesTest.java @@ -37,8 +37,7 @@ class ScheduledTripTimesTest { TIMEPOINTS.set(1); } - private final ScheduledTripTimes subject = ScheduledTripTimes - .of() + private final ScheduledTripTimes subject = ScheduledTripTimes.of() .withArrivalTimes("10:00 11:00 12:00") .withDepartureTimes("10:01 11:02 12:03") .withServiceCode(SERVICE_CODE) @@ -102,15 +101,12 @@ void isTimepoint() { @Test void validateLastArrivalTimeIsNotMoreThan20DaysAfterFirstDepartureTime() { - var ex = assertThrows( - DataValidationException.class, - () -> - ScheduledTripTimes - .of() - .withDepartureTimes("10:00 12:00 10:00:01+20d") - .withServiceCode(SERVICE_CODE) - .withTrip(TRIP) - .build() + var ex = assertThrows(DataValidationException.class, () -> + ScheduledTripTimes.of() + .withDepartureTimes("10:00 12:00 10:00:01+20d") + .withServiceCode(SERVICE_CODE) + .withTrip(TRIP) + .build() ); assertEquals( "The arrivalTime is not in range[-12h, 20d]. Time: 10:00:01+20d, stop-pos: 2, trip: F:Trip-1.", diff --git a/application/src/test/java/org/opentripplanner/transit/model/timetable/StopTimeKeyTest.java b/application/src/test/java/org/opentripplanner/transit/model/timetable/StopTimeKeyTest.java index e86b4133256..45eb42ab9f0 100644 --- a/application/src/test/java/org/opentripplanner/transit/model/timetable/StopTimeKeyTest.java +++ b/application/src/test/java/org/opentripplanner/transit/model/timetable/StopTimeKeyTest.java @@ -12,9 +12,10 @@ class StopTimeKeyTest { private static final String ID = "1"; private static final int STOP_SEQUENCE_NUMBER = 1; - private static final StopTimeKey subject = StopTimeKey - .of(TimetableRepositoryForTest.id(ID), STOP_SEQUENCE_NUMBER) - .build(); + private static final StopTimeKey subject = StopTimeKey.of( + TimetableRepositoryForTest.id(ID), + STOP_SEQUENCE_NUMBER + ).build(); @Test void copy() { diff --git a/application/src/test/java/org/opentripplanner/transit/model/timetable/TripOnServiceDateTest.java b/application/src/test/java/org/opentripplanner/transit/model/timetable/TripOnServiceDateTest.java index d84af565fab..ea2f2375952 100644 --- a/application/src/test/java/org/opentripplanner/transit/model/timetable/TripOnServiceDateTest.java +++ b/application/src/test/java/org/opentripplanner/transit/model/timetable/TripOnServiceDateTest.java @@ -18,8 +18,9 @@ class TripOnServiceDateTest { ); public static final LocalDate SERVICE_DATE = LocalDate.now(); public static final String TRIP_ID = "tripId"; - private static final TripOnServiceDate subject = TripOnServiceDate - .of(TimetableRepositoryForTest.id(ID)) + private static final TripOnServiceDate subject = TripOnServiceDate.of( + TimetableRepositoryForTest.id(ID) + ) .withTrip(TimetableRepositoryForTest.trip(TRIP_ID).build()) .withServiceDate(SERVICE_DATE) .withTripAlteration(TRIP_ALTERATION) diff --git a/application/src/test/java/org/opentripplanner/transit/model/timetable/TripTest.java b/application/src/test/java/org/opentripplanner/transit/model/timetable/TripTest.java index 441ce74927a..7fdb09ce0c6 100644 --- a/application/src/test/java/org/opentripplanner/transit/model/timetable/TripTest.java +++ b/application/src/test/java/org/opentripplanner/transit/model/timetable/TripTest.java @@ -32,14 +32,12 @@ class TripTest { private static final String NETEX_SUBMODE_NAME = "submode"; private static final SubMode NETEX_SUBMODE = SubMode.of(NETEX_SUBMODE_NAME); private static final String NETEX_INTERNAL_PLANNING_CODE = "internalPlanningCode"; - private static final Operator OPERATOR = Operator - .of(FeedScopedId.parse("x:operatorId")) + private static final Operator OPERATOR = Operator.of(FeedScopedId.parse("x:operatorId")) .withName("operator name") .build(); private static final FeedScopedId SERVICE_ID = FeedScopedId.parse("x:serviceId"); private static final FeedScopedId SHAPE_ID = FeedScopedId.parse("x:shapeId"); - private static final Trip subject = Trip - .of(TimetableRepositoryForTest.id(ID)) + private static final Trip subject = Trip.of(TimetableRepositoryForTest.id(ID)) .withShortName(SHORT_NAME) .withRoute(ROUTE) .withDirection(DIRECTION) @@ -59,8 +57,7 @@ class TripTest { @Test void shouldCopyFieldsFromRoute() { - var routeWithModes = ROUTE - .copy() + var routeWithModes = ROUTE.copy() .withMode(TRANSIT_MODE) .withNetexSubmode(NETEX_SUBMODE_NAME) .withBikesAllowed(BIKE_ACCESS) @@ -127,8 +124,7 @@ void sameAs() { subject .copy() .withOperator( - Operator - .of(FeedScopedId.parse("x:otherOperatorId")) + Operator.of(FeedScopedId.parse("x:otherOperatorId")) .withName("other operator name") .build() ) diff --git a/application/src/test/java/org/opentripplanner/transit/model/timetable/booking/BookingInfoTest.java b/application/src/test/java/org/opentripplanner/transit/model/timetable/booking/BookingInfoTest.java index 36587e1f696..7498a8dc0a0 100644 --- a/application/src/test/java/org/opentripplanner/transit/model/timetable/booking/BookingInfoTest.java +++ b/application/src/test/java/org/opentripplanner/transit/model/timetable/booking/BookingInfoTest.java @@ -12,8 +12,7 @@ class BookingInfoTest { public static final String URL = "http://booking.otp.org"; - public static final ContactInfo CONTACT = ContactInfo - .of() + public static final ContactInfo CONTACT = ContactInfo.of() .withBookingUrl(URL) .withContactPerson("Jo Contact") .build(); @@ -24,8 +23,7 @@ class BookingInfoTest { @Test void testBookingInfoWithLatestBookingTime() { - var subject = BookingInfo - .of() + var subject = BookingInfo.of() .withContactInfo(CONTACT) .withBookingMethods(BOOKING_METHODS) .withLatestBookingTime(BOOKING_TIME_NOON) @@ -51,8 +49,7 @@ void testBookingInfoWithLatestBookingTime() { @Test void testBookingInfoWithMinBookingNotice() { Duration minimumBookingNotice = Duration.ofMinutes(45); - var subject = BookingInfo - .of() + var subject = BookingInfo.of() .withBookingMethods(BOOKING_METHODS) .withMinimumBookingNotice(minimumBookingNotice) .build(); diff --git a/application/src/test/java/org/opentripplanner/transit/model/timetable/booking/RoutingBookingInfoTest.java b/application/src/test/java/org/opentripplanner/transit/model/timetable/booking/RoutingBookingInfoTest.java index 2b9dfaface8..ae72fb5c595 100644 --- a/application/src/test/java/org/opentripplanner/transit/model/timetable/booking/RoutingBookingInfoTest.java +++ b/application/src/test/java/org/opentripplanner/transit/model/timetable/booking/RoutingBookingInfoTest.java @@ -49,8 +49,7 @@ void isThereEnoughTimeToBookWithMinBookingTimeBeforeDeparture( ) { int searchTimeSec = searchTime.toSecondOfDay(); - var subject = RoutingBookingInfo - .of(requestedBookingTime.toSecondOfDay()) + var subject = RoutingBookingInfo.of(requestedBookingTime.toSecondOfDay()) .withMinimumBookingNotice(MINIMUM_BOOKING_NOTICE_20m) .withLatestBookingTime(new BookingTime(LATEST_BOOKING_TIME_13_00, 0)) .build(); @@ -65,8 +64,7 @@ void earliestDepartureTime() { int t11_35 = TimeUtils.time("11:35"); int t11_55 = TimeUtils.time("11:35") + (int) MINIMUM_BOOKING_NOTICE_20m.toSeconds(); - var subject = RoutingBookingInfo - .of(t11_35) + var subject = RoutingBookingInfo.of(t11_35) .withMinimumBookingNotice(MINIMUM_BOOKING_NOTICE_20m) .build(); @@ -87,8 +85,7 @@ void unrestricted() { assertSame( RoutingBookingInfo.unrestricted(), - RoutingBookingInfo - .of(RoutingBookingInfo.NOT_SET) + RoutingBookingInfo.of(RoutingBookingInfo.NOT_SET) .withMinimumBookingNotice(MINIMUM_BOOKING_NOTICE_20m) .build() ); @@ -100,8 +97,7 @@ void unrestricted() { @Test void testToString() { - var subject = RoutingBookingInfo - .of(TimeUtils.time("11:35")) + var subject = RoutingBookingInfo.of(TimeUtils.time("11:35")) .withMinimumBookingNotice(MINIMUM_BOOKING_NOTICE_20m) .withLatestBookingTime(new BookingTime(LATEST_BOOKING_TIME_13_00, 0)) .build(); @@ -118,8 +114,7 @@ void testEqAndHashCode() { TimeUtils.time("11:35"), BookingInfo.of().withMinimumBookingNotice(MINIMUM_BOOKING_NOTICE_20m).build() ); - var same = RoutingBookingInfo - .of(TimeUtils.time("11:35")) + var same = RoutingBookingInfo.of(TimeUtils.time("11:35")) .withMinimumBookingNotice(MINIMUM_BOOKING_NOTICE_20m) .build(); diff --git a/application/src/test/java/org/opentripplanner/transit/service/DefaultTransitServiceTest.java b/application/src/test/java/org/opentripplanner/transit/service/DefaultTransitServiceTest.java index 78d138600e0..7d96bc3ce1e 100644 --- a/application/src/test/java/org/opentripplanner/transit/service/DefaultTransitServiceTest.java +++ b/application/src/test/java/org/opentripplanner/transit/service/DefaultTransitServiceTest.java @@ -41,8 +41,7 @@ class DefaultTransitServiceTest { private static TransitService service; private static final Station STATION = TEST_MODEL.station("C").build(); - private static final RegularStop STOP_A = TEST_MODEL - .stop("A") + private static final RegularStop STOP_A = TEST_MODEL.stop("A") .withVehicleType(TRAM) .withParentStation(STATION) .build(); @@ -57,40 +56,35 @@ class DefaultTransitServiceTest { STOP_A, STOP_B ); - private static final TripPattern REAL_TIME_PATTERN = TEST_MODEL - .pattern(BUS) + private static final TripPattern REAL_TIME_PATTERN = TEST_MODEL.pattern(BUS) .withStopPattern(REAL_TIME_STOP_PATTERN) .withCreatedByRealtimeUpdater(true) .build(); static FeedScopedId CALENDAR_ID = TimetableRepositoryForTest.id("CAL_1"); - static Trip TRIP = TimetableRepositoryForTest - .trip("123") + static Trip TRIP = TimetableRepositoryForTest.trip("123") .withHeadsign(I18NString.of("Trip Headsign")) .withServiceId(CALENDAR_ID) .build(); - private static final Trip ADDED_TRIP = TimetableRepositoryForTest - .trip("REAL_TIME_ADDED_TRIP") + private static final Trip ADDED_TRIP = TimetableRepositoryForTest.trip("REAL_TIME_ADDED_TRIP") .withServiceId(CALENDAR_ID) .build(); - private static final ScheduledTripTimes SCHEDULED_TRIP_TIMES = ScheduledTripTimes - .of() + private static final ScheduledTripTimes SCHEDULED_TRIP_TIMES = ScheduledTripTimes.of() .withTrip(TRIP) .withArrivalTimes(new int[] { 0, 1 }) .withDepartureTimes(new int[] { 0, 1 }) .withServiceCode(SERVICE_CODE) .build(); - private static final TripPattern RAIL_PATTERN = TEST_MODEL - .pattern(RAIL) + private static final TripPattern RAIL_PATTERN = TEST_MODEL.pattern(RAIL) .withScheduledTimeTableBuilder(builder -> builder.addTripTimes(SCHEDULED_TRIP_TIMES)) .build(); private static final int DELAY = 120; - private static final RealTimeTripTimes REALTIME_TRIP_TIMES = SCHEDULED_TRIP_TIMES.copyScheduledTimes(); + private static final RealTimeTripTimes REALTIME_TRIP_TIMES = + SCHEDULED_TRIP_TIMES.copyScheduledTimes(); private static final RealTimeTripTimes ADDED_TRIP_TIMES = RealTimeTripTimes.of( - ScheduledTripTimes - .of() + ScheduledTripTimes.of() .withTrip(ADDED_TRIP) .withArrivalTimes(new int[] { 10, 11 }) .withDepartureTimes(new int[] { 10, 11 }) @@ -110,8 +104,7 @@ class DefaultTransitServiceTest { @BeforeAll static void setup() { - var siteRepository = TEST_MODEL - .siteRepositoryBuilder() + var siteRepository = TEST_MODEL.siteRepositoryBuilder() .withRegularStop(STOP_A) .withRegularStop(STOP_B) .withStation(STATION) @@ -147,8 +140,7 @@ static void setup() { TimetableSnapshot timetableSnapshot = new TimetableSnapshot(); RealTimeTripTimes tripTimes = RealTimeTripTimes.of( - ScheduledTripTimes - .of() + ScheduledTripTimes.of() .withTrip(TimetableRepositoryForTest.trip("123").build()) .withDepartureTimes(new int[] { 0, 1 }) .build() @@ -165,17 +157,16 @@ static void setup() { var snapshot = timetableSnapshot.commit(); - service = - new DefaultTransitService(timetableRepository, snapshot) { - @Override - public Collection findPatterns(StopLocation stop) { - if (stop.equals(STOP_B)) { - return List.of(FERRY_PATTERN, FERRY_PATTERN, RAIL_PATTERN, RAIL_PATTERN, RAIL_PATTERN); - } else { - return List.of(BUS_PATTERN); - } + service = new DefaultTransitService(timetableRepository, snapshot) { + @Override + public Collection findPatterns(StopLocation stop) { + if (stop.equals(STOP_B)) { + return List.of(FERRY_PATTERN, FERRY_PATTERN, RAIL_PATTERN, RAIL_PATTERN, RAIL_PATTERN); + } else { + return List.of(BUS_PATTERN); } - }; + } + }; } @Test @@ -234,9 +225,10 @@ void getScheduledTripTimes() { @Test void getRealtimeTripTimes() { - Instant midnight = ServiceDateUtils - .asStartOfService(SERVICE_DATE, service.getTimeZone()) - .toInstant(); + Instant midnight = ServiceDateUtils.asStartOfService( + SERVICE_DATE, + service.getTimeZone() + ).toInstant(); assertEquals( Optional.of( @@ -261,9 +253,10 @@ void getScheduledTripTimesForAddedTrip() { @Test void getRealtimeTripTimesForAddedTrip() { - Instant midnight = ServiceDateUtils - .asStartOfService(SERVICE_DATE, service.getTimeZone()) - .toInstant(); + Instant midnight = ServiceDateUtils.asStartOfService( + SERVICE_DATE, + service.getTimeZone() + ).toInstant(); assertEquals( Optional.of( diff --git a/application/src/test/java/org/opentripplanner/transit/service/PatternByServiceDatesFilterTest.java b/application/src/test/java/org/opentripplanner/transit/service/PatternByServiceDatesFilterTest.java index 93f50ce5b1e..7b4e68b65ba 100644 --- a/application/src/test/java/org/opentripplanner/transit/service/PatternByServiceDatesFilterTest.java +++ b/application/src/test/java/org/opentripplanner/transit/service/PatternByServiceDatesFilterTest.java @@ -37,14 +37,12 @@ static List invalidRangeCases() { @ParameterizedTest @MethodSource("invalidRangeCases") void invalidRange(LocalDate start, LocalDate end) { - assertThrows( - IllegalArgumentException.class, - () -> - new PatternByServiceDatesFilter( - new LocalDateRange(start, end), - r -> List.of(), - d -> List.of() - ) + assertThrows(IllegalArgumentException.class, () -> + new PatternByServiceDatesFilter( + new LocalDateRange(start, end), + r -> List.of(), + d -> List.of() + ) ); } diff --git a/application/src/test/java/org/opentripplanner/transit/service/SiteRepositoryTest.java b/application/src/test/java/org/opentripplanner/transit/service/SiteRepositoryTest.java index 8e7b4e6f78f..28198d315f9 100644 --- a/application/src/test/java/org/opentripplanner/transit/service/SiteRepositoryTest.java +++ b/application/src/test/java/org/opentripplanner/transit/service/SiteRepositoryTest.java @@ -24,13 +24,11 @@ class SiteRepositoryTest { private static final WgsCoordinate COOR_A = new WgsCoordinate(60.0, 11.0); private static final WgsCoordinate COOR_B = new WgsCoordinate(62.0, 12.0); - private static final Geometry GEOMETRY = GeometryUtils - .getGeometryFactory() + private static final Geometry GEOMETRY = GeometryUtils.getGeometryFactory() .createPoint(COOR_A.asJtsCoordinate()); public static final NonLocalizedString NAME = NonLocalizedString.ofNullable("Name"); private static final FeedScopedId ID = TimetableRepositoryForTest.id("A"); - private static final Station STATION = Station - .of(ID) + private static final Station STATION = Station.of(ID) .withName(NAME) .withCoordinate(COOR_B) .build(); @@ -50,15 +48,13 @@ class SiteRepositoryTest { .withGeometry(GEOMETRY) .build(); private final GroupStop stopGroup = siteRepositoryBuilder.groupStop(ID).addLocation(stop).build(); - private final MultiModalStation mmStation = MultiModalStation - .of(ID) + private final MultiModalStation mmStation = MultiModalStation.of(ID) .withName(NAME) .withChildStations(List.of(STATION)) .withCoordinate(COOR_B) .build(); private final String expMmStations = List.of(mmStation).toString(); - private final GroupOfStations groupOfStations = GroupOfStations - .of(ID) + private final GroupOfStations groupOfStations = GroupOfStations.of(ID) .withName(NAME) .withCoordinate(COOR_B) .addChildStation(STATION) diff --git a/application/src/test/java/org/opentripplanner/transit/service/TimetableRepositoryTest.java b/application/src/test/java/org/opentripplanner/transit/service/TimetableRepositoryTest.java index f205cca467c..1638ed41c2f 100644 --- a/application/src/test/java/org/opentripplanner/transit/service/TimetableRepositoryTest.java +++ b/application/src/test/java/org/opentripplanner/transit/service/TimetableRepositoryTest.java @@ -47,7 +47,8 @@ void validateTimeZones() { assertEquals("America/New_York", timetableRepository.getTimeZone().getId()); // Then trip times should be same as in input data - TimetableRepositoryIndex timetableRepositoryIndex = timetableRepository.getTimetableRepositoryIndex(); + TimetableRepositoryIndex timetableRepositoryIndex = + timetableRepository.getTimetableRepositoryIndex(); Trip trip = timetableRepositoryIndex.getTripForId(SAMPLE_TRIP_ID); Timetable timetable = timetableRepositoryIndex.getPatternForTrip(trip).getScheduledTimetable(); assertEquals(20 * 60, timetable.getTripTimes(trip).getDepartureTime(0)); @@ -63,11 +64,9 @@ void validateTimeZones() { new DefaultFareServiceFactory(), null ), - ( - "The graph contains agencies with different time zones. " + + ("The graph contains agencies with different time zones. " + "Please configure the one to be used in the " + - BUILD_CONFIG_FILENAME - ) + BUILD_CONFIG_FILENAME) ); } @@ -101,7 +100,8 @@ void validateTimeZonesWithExplicitTimeZone() { new TimeZoneAdjusterModule(timetableRepository).buildGraph(); - TimetableRepositoryIndex timetableRepositoryIndex = timetableRepository.getTimetableRepositoryIndex(); + TimetableRepositoryIndex timetableRepositoryIndex = + timetableRepository.getTimetableRepositoryIndex(); // Then time zone should match the one provided in the feed assertEquals("America/Chicago", timetableRepository.getTimeZone().getId()); diff --git a/application/src/test/java/org/opentripplanner/transit/speed_test/ResultPrinter.java b/application/src/test/java/org/opentripplanner/transit/speed_test/ResultPrinter.java index 1d34c88f08e..05502b8c15f 100644 --- a/application/src/test/java/org/opentripplanner/transit/speed_test/ResultPrinter.java +++ b/application/src/test/java/org/opentripplanner/transit/speed_test/ResultPrinter.java @@ -70,8 +70,7 @@ static void logSingleTestResult( int nTestCasesSuccess = testCases.numberOfTestCasesWithSuccess(); String totalTimeSec = msToSecondsStr(testCases.stream().mapToInt(TestCase::totalTimeMs).sum()); - var summary = Table - .of() + var summary = Table.of() .withHeaders(testCases.stream().map(TestCase::id).toList()) .addRow(testCases.stream().map(TestCase::numberOfResults).toList()) .addRow(testCases.stream().map(TestCase::transitTimeMs).toList()) diff --git a/application/src/test/java/org/opentripplanner/transit/speed_test/SpeedTest.java b/application/src/test/java/org/opentripplanner/transit/speed_test/SpeedTest.java index 758c3a2cb2f..c57ee1a99fc 100644 --- a/application/src/test/java/org/opentripplanner/transit/speed_test/SpeedTest.java +++ b/application/src/test/java/org/opentripplanner/transit/speed_test/SpeedTest.java @@ -79,13 +79,12 @@ public SpeedTest( this.config = config; this.timetableRepository = timetableRepository; - this.tcIO = - new CsvFileSupport( - opts.rootDir(), - TRAVEL_SEARCH_FILENAME, - config.feedId, - opts.replaceExpectedResultsFiles() - ); + this.tcIO = new CsvFileSupport( + opts.rootDir(), + TRAVEL_SEARCH_FILENAME, + config.feedId, + opts.replaceExpectedResultsFiles() + ); // Read Test-case definitions and expected results from file this.testCaseDefinitions = tcIO.readTestCaseDefinitions(); @@ -111,31 +110,30 @@ public SpeedTest( RaptorEnvironmentFactory.create(config.transitRoutingParams.searchThreadPoolSize()) ); - this.serverContext = - new DefaultServerRequestContext( - DebugUiConfig.DEFAULT, - config.flexConfig, - graph, - timer.getRegistry(), - raptorConfig, - TestServerContext.createRealtimeVehicleService(transitService), - List.of(), - config.request, - TestServerContext.createStreetLimitationParametersService(), - config.transitRoutingParams, - new DefaultTransitService(timetableRepository), - VectorTileConfig.DEFAULT, - TestServerContext.createVehicleParkingService(), - TestServerContext.createVehicleRentalService(), - TestServerContext.createViaTransferResolver(graph, transitService), - TestServerContext.createWorldEnvelopeService(), - TestServerContext.createEmissionsService(), - null, - null, - null, - null, - null - ); + this.serverContext = new DefaultServerRequestContext( + DebugUiConfig.DEFAULT, + config.flexConfig, + graph, + timer.getRegistry(), + raptorConfig, + TestServerContext.createRealtimeVehicleService(transitService), + List.of(), + config.request, + TestServerContext.createStreetLimitationParametersService(), + config.transitRoutingParams, + new DefaultTransitService(timetableRepository), + VectorTileConfig.DEFAULT, + TestServerContext.createVehicleParkingService(), + TestServerContext.createVehicleRentalService(), + TestServerContext.createViaTransferResolver(graph, transitService), + TestServerContext.createWorldEnvelopeService(), + TestServerContext.createEmissionsService(), + null, + null, + null, + null, + null + ); // Creating raptor transit data should be integrated into the TimetableRepository, but for now // we do it manually here createRaptorTransitData(timetableRepository, config.transitRoutingParams); @@ -280,8 +278,7 @@ private void initProfileStatistics() { } private TestCases createTestCases() { - return TestCases - .of() + return TestCases.of() .withSkipCost(opts.skipCost()) .withIncludeIds(opts.testCaseIds()) .withIncludeCategories(opts.includeCategories()) diff --git a/application/src/test/java/org/opentripplanner/transit/speed_test/SpeedTestRequest.java b/application/src/test/java/org/opentripplanner/transit/speed_test/SpeedTestRequest.java index 2dfaad077c6..dc7a730a454 100644 --- a/application/src/test/java/org/opentripplanner/transit/speed_test/SpeedTestRequest.java +++ b/application/src/test/java/org/opentripplanner/transit/speed_test/SpeedTestRequest.java @@ -73,8 +73,7 @@ RouteRequest toRouteRequest() { if (tModes.isEmpty()) { request.journey().transit().disable(); } else { - var builder = TransitFilterRequest - .of() + var builder = TransitFilterRequest.of() .addSelect(SelectRequest.of().withTransportModes(tModes).build()); request.journey().transit().setFilters(List.of(builder.build())); } diff --git a/application/src/test/java/org/opentripplanner/transit/speed_test/TransferCacheTest.java b/application/src/test/java/org/opentripplanner/transit/speed_test/TransferCacheTest.java index b468848e07c..550a706a119 100644 --- a/application/src/test/java/org/opentripplanner/transit/speed_test/TransferCacheTest.java +++ b/application/src/test/java/org/opentripplanner/transit/speed_test/TransferCacheTest.java @@ -53,15 +53,12 @@ private static void measureTransferCacheComputation( SpeedTestTimer timer, TimetableRepository timetableRepository ) { - IntStream - .range(1, 7) - .forEach(reluctance -> { - RouteRequest routeRequest = new RouteRequest(); - routeRequest.withPreferences(b -> b.withWalk(c -> c.withReluctance(reluctance))); - timer.recordTimer( - "transfer_cache_computation", - () -> timetableRepository.getRaptorTransitData().initTransferCacheForRequest(routeRequest) - ); - }); + IntStream.range(1, 7).forEach(reluctance -> { + RouteRequest routeRequest = new RouteRequest(); + routeRequest.withPreferences(b -> b.withWalk(c -> c.withReluctance(reluctance))); + timer.recordTimer("transfer_cache_computation", () -> + timetableRepository.getRaptorTransitData().initTransferCacheForRequest(routeRequest) + ); + }); } } diff --git a/application/src/test/java/org/opentripplanner/transit/speed_test/model/SpeedTestProfile.java b/application/src/test/java/org/opentripplanner/transit/speed_test/model/SpeedTestProfile.java index 2220c34b11b..add7a56d240 100644 --- a/application/src/test/java/org/opentripplanner/transit/speed_test/model/SpeedTestProfile.java +++ b/application/src/test/java/org/opentripplanner/transit/speed_test/model/SpeedTestProfile.java @@ -79,8 +79,7 @@ public enum SpeedTestProfile { } public static SpeedTestProfile[] parse(String profiles) { - return Arrays - .stream(profiles.split(",")) + return Arrays.stream(profiles.split(",")) .map(SpeedTestProfile::parseOne) .toArray(SpeedTestProfile[]::new); } @@ -120,8 +119,7 @@ private static SpeedTestProfile parseOne(String value) { "Profile is not valid: '" + value + "'\nProfiles:\n\t" + - Arrays - .stream(values()) + Arrays.stream(values()) .map(SpeedTestProfile::description) .collect(Collectors.joining("\n\t")) .replace('.', ' ') diff --git a/application/src/test/java/org/opentripplanner/transit/speed_test/model/testcase/CsvFileSupport.java b/application/src/test/java/org/opentripplanner/transit/speed_test/model/testcase/CsvFileSupport.java index 3cd892763a9..7b37cdba279 100644 --- a/application/src/test/java/org/opentripplanner/transit/speed_test/model/testcase/CsvFileSupport.java +++ b/application/src/test/java/org/opentripplanner/transit/speed_test/model/testcase/CsvFileSupport.java @@ -60,10 +60,8 @@ public Map readExpectedResults() { addFileToResultsMap(resultsById, expectedResultsFile, ExpectedResults::addDefault); for (var profile : SpeedTestProfile.values()) { - addFileToResultsMap( - resultsById, - expectedResultsFileByProfile.get(profile), - (results, r) -> results.add(profile, r) + addFileToResultsMap(resultsById, expectedResultsFileByProfile.get(profile), (results, r) -> + results.add(profile, r) ); } return resultsById; @@ -85,8 +83,9 @@ public void writeResultsToFile(SpeedTestProfile profile, TestCases testCases) { return; } - new ResultCsvFile(resultsFileByProfile.get(profile)) - .write(testCases.stream().flatMap(it -> it.actualResults().stream()).toList()); + new ResultCsvFile(resultsFileByProfile.get(profile)).write( + testCases.stream().flatMap(it -> it.actualResults().stream()).toList() + ); } /* private methods */ diff --git a/application/src/test/java/org/opentripplanner/transit/speed_test/model/testcase/TableTestReport.java b/application/src/test/java/org/opentripplanner/transit/speed_test/model/testcase/TableTestReport.java index a746e744a96..d1e847bb9b4 100644 --- a/application/src/test/java/org/opentripplanner/transit/speed_test/model/testcase/TableTestReport.java +++ b/application/src/test/java/org/opentripplanner/transit/speed_test/model/testcase/TableTestReport.java @@ -34,8 +34,7 @@ public static String report(List> results) { /* private methods */ private static TableBuilder newTable() { - return Table - .of() + return Table.of() .withAlights(Center, Right, Right, Right, Right, Right, Center, Center, Left, Left, Left) .withHeaders( "STATUS", diff --git a/application/src/test/java/org/opentripplanner/transit/speed_test/model/timer/SpeedTestTimer.java b/application/src/test/java/org/opentripplanner/transit/speed_test/model/timer/SpeedTestTimer.java index 80970eaad0a..877380e4068 100644 --- a/application/src/test/java/org/opentripplanner/transit/speed_test/model/timer/SpeedTestTimer.java +++ b/application/src/test/java/org/opentripplanner/transit/speed_test/model/timer/SpeedTestTimer.java @@ -180,8 +180,7 @@ private static NamingConvention createNamingConvention() { @SuppressWarnings("NullableProblems") @Override public String name(String name, Meter.Type type, String unit) { - return Arrays - .stream(name.split("\\.")) + return Arrays.stream(name.split("\\.")) .filter(Objects::nonNull) .map(this::capitalize) .collect(Collectors.joining(" ")); diff --git a/application/src/test/java/org/opentripplanner/transit/speed_test/support/AssertSpeedTestSetup.java b/application/src/test/java/org/opentripplanner/transit/speed_test/support/AssertSpeedTestSetup.java index 46094bd5377..2bdf16162be 100644 --- a/application/src/test/java/org/opentripplanner/transit/speed_test/support/AssertSpeedTestSetup.java +++ b/application/src/test/java/org/opentripplanner/transit/speed_test/support/AssertSpeedTestSetup.java @@ -29,7 +29,7 @@ public static void assertTestDateHasData( "testDate": %s (speed-test-config.json) "transitServiceStart": %s (%s) "transitServiceEnd": %s (%s) - + """.formatted( numberOfPatternForTestDate, config.testDate, diff --git a/application/src/test/java/org/opentripplanner/updater/GtfsRealtimeFuzzyTripMatcherTest.java b/application/src/test/java/org/opentripplanner/updater/GtfsRealtimeFuzzyTripMatcherTest.java index d0d8ef1a6ad..04a3620a0e0 100644 --- a/application/src/test/java/org/opentripplanner/updater/GtfsRealtimeFuzzyTripMatcherTest.java +++ b/application/src/test/java/org/opentripplanner/updater/GtfsRealtimeFuzzyTripMatcherTest.java @@ -55,8 +55,10 @@ public class GtfsRealtimeFuzzyTripMatcherTest { TEST_MODEL.stopTimesEvery5Minutes(5, TRIP, START_TIME), new Deduplicator() ); - private static final TripPattern TRIP_PATTERN = TimetableRepositoryForTest - .tripPattern("tp1", ROUTE) + private static final TripPattern TRIP_PATTERN = TimetableRepositoryForTest.tripPattern( + "tp1", + ROUTE + ) .withStopPattern(TimetableRepositoryForTest.stopPattern(STOP_1, STOP_2)) .withScheduledTimeTableBuilder(builder -> builder.addTripTimes(TRIP_TIMES)) .build(); @@ -121,8 +123,7 @@ void incorrectDirection() { @Test void noMatch() { // Test matching with "real time", when schedule uses time greater than 24:00 - var trip = TripDescriptor - .newBuilder() + var trip = TripDescriptor.newBuilder() .setRouteId("4") .setDirectionId(0) .setStartTime("12:00:00") @@ -130,13 +131,11 @@ void noMatch() { .build(); // No departure at this time assertFalse(trip.hasTripId()); - trip = - TripDescriptor - .newBuilder() - .setRouteId("1") - .setStartTime("06:47:00") - .setStartDate("20090915") - .build(); + trip = TripDescriptor.newBuilder() + .setRouteId("1") + .setStartTime("06:47:00") + .setStartDate("20090915") + .build(); // Missing direction id assertFalse(trip.hasTripId()); } @@ -174,8 +173,7 @@ private static GtfsRealtimeFuzzyTripMatcher matcher() { } private static TripDescriptor.Builder matchingTripUpdate() { - return TripDescriptor - .newBuilder() + return TripDescriptor.newBuilder() .setRouteId(ROUTE_ID) .setDirectionId(2) .setStartTime(START_TIME) diff --git a/application/src/test/java/org/opentripplanner/updater/alert/gtfs/AlertsUpdateHandlerTest.java b/application/src/test/java/org/opentripplanner/updater/alert/gtfs/AlertsUpdateHandlerTest.java index 5c7de5b4f71..591418b5ab0 100644 --- a/application/src/test/java/org/opentripplanner/updater/alert/gtfs/AlertsUpdateHandlerTest.java +++ b/application/src/test/java/org/opentripplanner/updater/alert/gtfs/AlertsUpdateHandlerTest.java @@ -45,8 +45,7 @@ public void setUp() { @Test public void testAlertWithTimePeriodConsideringEarlyStart() { - GtfsRealtime.Alert alert = GtfsRealtime.Alert - .newBuilder() + GtfsRealtime.Alert alert = GtfsRealtime.Alert.newBuilder() .addActivePeriod(GtfsRealtime.TimeRange.newBuilder().setStart(10).setEnd(20).build()) .addInformedEntity(GtfsRealtime.EntitySelector.newBuilder().setAgencyId("1")) .build(); @@ -57,8 +56,7 @@ public void testAlertWithTimePeriodConsideringEarlyStart() { @Test public void testAlertStartConsideringEarlyStart() { - GtfsRealtime.Alert alert = GtfsRealtime.Alert - .newBuilder() + GtfsRealtime.Alert alert = GtfsRealtime.Alert.newBuilder() .addActivePeriod(GtfsRealtime.TimeRange.newBuilder().setStart(10).build()) .addInformedEntity(GtfsRealtime.EntitySelector.newBuilder().setAgencyId("1")) .build(); @@ -69,8 +67,7 @@ public void testAlertStartConsideringEarlyStart() { @Test public void testAlertEnd() { - GtfsRealtime.Alert alert = GtfsRealtime.Alert - .newBuilder() + GtfsRealtime.Alert alert = GtfsRealtime.Alert.newBuilder() .addActivePeriod(GtfsRealtime.TimeRange.newBuilder().setEnd(20).build()) .addInformedEntity(GtfsRealtime.EntitySelector.newBuilder().setAgencyId("1")) .build(); @@ -81,8 +78,7 @@ public void testAlertEnd() { @Test public void testWithoutUrl() { - GtfsRealtime.Alert alert = GtfsRealtime.Alert - .newBuilder() + GtfsRealtime.Alert alert = GtfsRealtime.Alert.newBuilder() .addInformedEntity(GtfsRealtime.EntitySelector.newBuilder().setAgencyId("1")) .build(); TransitAlert transitAlert = processOneAlert(alert); @@ -91,12 +87,10 @@ public void testWithoutUrl() { @Test public void testWithoutUrlTranslations() { - GtfsRealtime.Alert alert = Alert - .newBuilder() + GtfsRealtime.Alert alert = Alert.newBuilder() .addInformedEntity(GtfsRealtime.EntitySelector.newBuilder().setAgencyId("1")) .setUrl( - GtfsRealtime.TranslatedString - .newBuilder() + GtfsRealtime.TranslatedString.newBuilder() .addTranslation( 0, Translation.newBuilder().setText("https://www.opentripplanner.org/").build() @@ -110,24 +104,20 @@ public void testWithoutUrlTranslations() { @Test public void testWithUrlTranslations() { - GtfsRealtime.Alert alert = Alert - .newBuilder() + GtfsRealtime.Alert alert = Alert.newBuilder() .addInformedEntity(GtfsRealtime.EntitySelector.newBuilder().setAgencyId("1")) .setUrl( - GtfsRealtime.TranslatedString - .newBuilder() + GtfsRealtime.TranslatedString.newBuilder() .addTranslation( 0, - Translation - .newBuilder() + Translation.newBuilder() .setText("https://www.opentripplanner.org/") .setLanguage("en") .build() ) .addTranslation( 0, - Translation - .newBuilder() + Translation.newBuilder() .setText("https://www.opentripplanner.org/fr") .setLanguage("fr") .build() @@ -148,12 +138,10 @@ public void testWithUrlTranslations() { @Test public void testWithoutHeaderTranslations() { - GtfsRealtime.Alert alert = Alert - .newBuilder() + GtfsRealtime.Alert alert = Alert.newBuilder() .addInformedEntity(GtfsRealtime.EntitySelector.newBuilder().setAgencyId("1")) .setHeaderText( - GtfsRealtime.TranslatedString - .newBuilder() + GtfsRealtime.TranslatedString.newBuilder() .addTranslation(0, Translation.newBuilder().setText("Title").build()) .build() ) @@ -164,12 +152,10 @@ public void testWithoutHeaderTranslations() { @Test public void testWithHeaderTranslations() { - GtfsRealtime.Alert alert = Alert - .newBuilder() + GtfsRealtime.Alert alert = Alert.newBuilder() .addInformedEntity(GtfsRealtime.EntitySelector.newBuilder().setAgencyId("1")) .setHeaderText( - GtfsRealtime.TranslatedString - .newBuilder() + GtfsRealtime.TranslatedString.newBuilder() .addTranslation(0, Translation.newBuilder().setText("Title").setLanguage("en").build()) .addTranslation(0, Translation.newBuilder().setText("Titre").setLanguage("fr").build()) .build() @@ -188,12 +174,10 @@ public void testWithHeaderTranslations() { @Test public void testWithoutDescriptionTranslations() { - GtfsRealtime.Alert alert = Alert - .newBuilder() + GtfsRealtime.Alert alert = Alert.newBuilder() .addInformedEntity(GtfsRealtime.EntitySelector.newBuilder().setAgencyId("1")) .setDescriptionText( - GtfsRealtime.TranslatedString - .newBuilder() + GtfsRealtime.TranslatedString.newBuilder() .addTranslation(0, Translation.newBuilder().setText("Description").build()) .build() ) @@ -204,12 +188,10 @@ public void testWithoutDescriptionTranslations() { @Test public void testWithDescriptionTranslations() { - GtfsRealtime.Alert alert = Alert - .newBuilder() + GtfsRealtime.Alert alert = Alert.newBuilder() .addInformedEntity(GtfsRealtime.EntitySelector.newBuilder().setAgencyId("1")) .setDescriptionText( - GtfsRealtime.TranslatedString - .newBuilder() + GtfsRealtime.TranslatedString.newBuilder() .addTranslation( 0, Translation.newBuilder().setText("Description").setLanguage("en").build() @@ -234,8 +216,7 @@ public void testWithDescriptionTranslations() { @Test public void testMissingAlertSeverity() { - GtfsRealtime.Alert alert = GtfsRealtime.Alert - .newBuilder() + GtfsRealtime.Alert alert = GtfsRealtime.Alert.newBuilder() .addInformedEntity(GtfsRealtime.EntitySelector.newBuilder().setAgencyId("1")) .build(); TransitAlert transitAlert = processOneAlert(alert); @@ -244,8 +225,7 @@ public void testMissingAlertSeverity() { @Test public void testSetAlertSeverity() { - GtfsRealtime.Alert alert = GtfsRealtime.Alert - .newBuilder() + GtfsRealtime.Alert alert = GtfsRealtime.Alert.newBuilder() .addInformedEntity(GtfsRealtime.EntitySelector.newBuilder().setAgencyId("1")) .setSeverityLevel(SeverityLevel.SEVERE) .build(); @@ -255,8 +235,7 @@ public void testSetAlertSeverity() { @Test public void testMissingAlertCause() { - GtfsRealtime.Alert alert = GtfsRealtime.Alert - .newBuilder() + GtfsRealtime.Alert alert = GtfsRealtime.Alert.newBuilder() .addInformedEntity(GtfsRealtime.EntitySelector.newBuilder().setAgencyId("1")) .build(); TransitAlert transitAlert = processOneAlert(alert); @@ -265,8 +244,7 @@ public void testMissingAlertCause() { @Test public void testSetAlertCause() { - GtfsRealtime.Alert alert = GtfsRealtime.Alert - .newBuilder() + GtfsRealtime.Alert alert = GtfsRealtime.Alert.newBuilder() .addInformedEntity(GtfsRealtime.EntitySelector.newBuilder().setAgencyId("1")) .setCause(Cause.MAINTENANCE) .build(); @@ -276,8 +254,7 @@ public void testSetAlertCause() { @Test public void testMissingAlertEffect() { - GtfsRealtime.Alert alert = GtfsRealtime.Alert - .newBuilder() + GtfsRealtime.Alert alert = GtfsRealtime.Alert.newBuilder() .addInformedEntity(GtfsRealtime.EntitySelector.newBuilder().setAgencyId("1")) .build(); TransitAlert transitAlert = processOneAlert(alert); @@ -286,8 +263,7 @@ public void testMissingAlertEffect() { @Test public void testSetAlertEffect() { - GtfsRealtime.Alert alert = GtfsRealtime.Alert - .newBuilder() + GtfsRealtime.Alert alert = GtfsRealtime.Alert.newBuilder() .addInformedEntity(GtfsRealtime.EntitySelector.newBuilder().setAgencyId("1")) .setEffect(Effect.MODIFIED_SERVICE) .build(); @@ -297,8 +273,7 @@ public void testSetAlertEffect() { @Test public void testAgencySelector() { - GtfsRealtime.Alert alert = GtfsRealtime.Alert - .newBuilder() + GtfsRealtime.Alert alert = GtfsRealtime.Alert.newBuilder() .addInformedEntity(GtfsRealtime.EntitySelector.newBuilder().setAgencyId("1")) .build(); TransitAlert transitAlert = processOneAlert(alert); @@ -314,8 +289,7 @@ public void testAgencySelector() { @Test public void testRouteSelector() { - GtfsRealtime.Alert alert = GtfsRealtime.Alert - .newBuilder() + GtfsRealtime.Alert alert = GtfsRealtime.Alert.newBuilder() .addInformedEntity(GtfsRealtime.EntitySelector.newBuilder().setRouteId("1")) .build(); TransitAlert transitAlert = processOneAlert(alert); @@ -331,11 +305,9 @@ public void testRouteSelector() { @Test public void testTripSelectorWithTripId() { - GtfsRealtime.Alert alert = Alert - .newBuilder() + GtfsRealtime.Alert alert = Alert.newBuilder() .addInformedEntity( - GtfsRealtime.EntitySelector - .newBuilder() + GtfsRealtime.EntitySelector.newBuilder() .setTrip(TripDescriptor.newBuilder().setTripId("1").build()) ) .build(); @@ -352,8 +324,7 @@ public void testTripSelectorWithTripId() { @Test public void testStopSelector() { - GtfsRealtime.Alert alert = Alert - .newBuilder() + GtfsRealtime.Alert alert = Alert.newBuilder() .addInformedEntity(GtfsRealtime.EntitySelector.newBuilder().setStopId("1")) .build(); TransitAlert transitAlert = processOneAlert(alert); @@ -369,8 +340,7 @@ public void testStopSelector() { @Test public void testStopAndRouteSelector() { - GtfsRealtime.Alert alert = Alert - .newBuilder() + GtfsRealtime.Alert alert = Alert.newBuilder() .addInformedEntity(0, GtfsRealtime.EntitySelector.newBuilder().setStopId("1").setRouteId("1")) .build(); TransitAlert transitAlert = processOneAlert(alert); @@ -386,12 +356,10 @@ public void testStopAndRouteSelector() { @Test public void testStopAndTripSelector() { - GtfsRealtime.Alert alert = Alert - .newBuilder() + GtfsRealtime.Alert alert = Alert.newBuilder() .addInformedEntity( 0, - GtfsRealtime.EntitySelector - .newBuilder() + GtfsRealtime.EntitySelector.newBuilder() .setStopId("1") .setTrip(TripDescriptor.newBuilder().setTripId("1").build()) ) @@ -409,8 +377,7 @@ public void testStopAndTripSelector() { @Test public void testMultipleSelectors() { - GtfsRealtime.Alert alert = Alert - .newBuilder() + GtfsRealtime.Alert alert = Alert.newBuilder() .addInformedEntity(GtfsRealtime.EntitySelector.newBuilder().setAgencyId("1")) .addInformedEntity(GtfsRealtime.EntitySelector.newBuilder().setAgencyId("2")) .addInformedEntity(GtfsRealtime.EntitySelector.newBuilder().setRouteId("1")) @@ -453,8 +420,7 @@ public void testMissingSelector() { @Test public void testUnknownSelector() { // Setting just direction is not supported and should result in entity not being handled - GtfsRealtime.Alert alert = Alert - .newBuilder() + GtfsRealtime.Alert alert = Alert.newBuilder() .addInformedEntity(GtfsRealtime.EntitySelector.newBuilder().setDirectionId(1).build()) .build(); TransitAlert transitAlert = processOneAlert(alert); @@ -474,8 +440,7 @@ public void testUnknownSelector() { @Test public void testDirectionAndRouteSelector() { - GtfsRealtime.Alert alert = Alert - .newBuilder() + GtfsRealtime.Alert alert = Alert.newBuilder() .addInformedEntity( GtfsRealtime.EntitySelector.newBuilder().setDirectionId(1).setRouteId("1").build() ) @@ -493,8 +458,7 @@ public void testDirectionAndRouteSelector() { @Test public void testRouteTypeSelector() { - GtfsRealtime.Alert alert = Alert - .newBuilder() + GtfsRealtime.Alert alert = Alert.newBuilder() .addInformedEntity(GtfsRealtime.EntitySelector.newBuilder().setRouteType(1).build()) .build(); TransitAlert transitAlert = processOneAlert(alert); @@ -510,8 +474,7 @@ public void testRouteTypeSelector() { @Test public void testRouteTypeAndAgencySelector() { - GtfsRealtime.Alert alert = Alert - .newBuilder() + GtfsRealtime.Alert alert = Alert.newBuilder() .addInformedEntity( GtfsRealtime.EntitySelector.newBuilder().setRouteType(1).setAgencyId("1").build() ) @@ -528,8 +491,7 @@ public void testRouteTypeAndAgencySelector() { } private TransitAlert processOneAlert(GtfsRealtime.Alert alert) { - GtfsRealtime.FeedMessage message = GtfsRealtime.FeedMessage - .newBuilder() + GtfsRealtime.FeedMessage message = GtfsRealtime.FeedMessage.newBuilder() .setHeader(GtfsRealtime.FeedHeader.newBuilder().setGtfsRealtimeVersion("2.0")) .addEntity(GtfsRealtime.FeedEntity.newBuilder().setAlert(alert).setId("1")) .build(); diff --git a/application/src/test/java/org/opentripplanner/updater/alert/siri/SiriAlertsUpdateHandlerTest.java b/application/src/test/java/org/opentripplanner/updater/alert/siri/SiriAlertsUpdateHandlerTest.java index 6184e24c61c..00891b2928d 100644 --- a/application/src/test/java/org/opentripplanner/updater/alert/siri/SiriAlertsUpdateHandlerTest.java +++ b/application/src/test/java/org/opentripplanner/updater/alert/siri/SiriAlertsUpdateHandlerTest.java @@ -91,8 +91,11 @@ public void setUp() throws Exception { } if (alertsUpdateHandler == null) { transitAlertService = new TransitAlertServiceImpl(timetableRepository); - alertsUpdateHandler = - new SiriAlertsUpdateHandler(FEED_ID, transitAlertService, Duration.ZERO); + alertsUpdateHandler = new SiriAlertsUpdateHandler( + FEED_ID, + transitAlertService, + Duration.ZERO + ); } } @@ -650,13 +653,12 @@ public void testSiriSxUpdateForLineThenExpiry() { assertTrue(matchesEntity(transitAlert, lineRef)); assertEquals(situationNumber, transitAlert.getId().getId()); - ptSituation = - createPtSituationElement( - situationNumber, - startTime, - endTime, - createAffectsLine(lineRef.getId(), null) - ); + ptSituation = createPtSituationElement( + situationNumber, + startTime, + endTime, + createAffectsLine(lineRef.getId(), null) + ); ptSituation.setProgress(WorkflowStatusEnumeration.CLOSED); @@ -876,7 +878,7 @@ private PtSituationElement createPtSituationElement( PtSituationElement element = new PtSituationElement(); element.setCreationTime(ZonedDateTime.now()); element.setProgress(WorkflowStatusEnumeration.OPEN); - if (startTime != null | endTime != null) { + if ((startTime != null) | (endTime != null)) { HalfOpenTimestampOutputRangeStructure period = new HalfOpenTimestampOutputRangeStructure(); if (startTime != null) { @@ -960,7 +962,8 @@ private boolean matchesEntity(TransitAlert transitAlert, FeedScopedId feedScoped private ServiceDelivery createServiceDelivery(List situationElement) { ServiceDelivery delivery = new ServiceDelivery(); SituationExchangeDeliveryStructure sxDeliveries = new SituationExchangeDeliveryStructure(); - SituationExchangeDeliveryStructure.Situations situations = new SituationExchangeDeliveryStructure.Situations(); + SituationExchangeDeliveryStructure.Situations situations = + new SituationExchangeDeliveryStructure.Situations(); situations.getPtSituationElements().addAll(situationElement); sxDeliveries.setSituations(situations); delivery.getSituationExchangeDeliveries().add(sxDeliveries); @@ -1026,9 +1029,11 @@ private AffectsScopeStructure createAffectsFramedVehicleJourney( String... stopIds ) { AffectsScopeStructure affects = new AffectsScopeStructure(); - AffectsScopeStructure.VehicleJourneys vehicleJourneys = new AffectsScopeStructure.VehicleJourneys(); + AffectsScopeStructure.VehicleJourneys vehicleJourneys = + new AffectsScopeStructure.VehicleJourneys(); AffectedVehicleJourneyStructure affectedVehicleJourney = new AffectedVehicleJourneyStructure(); - FramedVehicleJourneyRefStructure framedVehicleJourneyRef = new FramedVehicleJourneyRefStructure(); + FramedVehicleJourneyRefStructure framedVehicleJourneyRef = + new FramedVehicleJourneyRefStructure(); framedVehicleJourneyRef.setDatedVehicleJourneyRef(datedVehicleJourney); if (dataFrameValue != null) { DataFrameRefStructure dataFrameRef = new DataFrameRefStructure(); @@ -1068,7 +1073,8 @@ private AffectsScopeStructure createAffectsVehicleJourney( String... stopIds ) { AffectsScopeStructure affects = new AffectsScopeStructure(); - AffectsScopeStructure.VehicleJourneys vehicleJourneys = new AffectsScopeStructure.VehicleJourneys(); + AffectsScopeStructure.VehicleJourneys vehicleJourneys = + new AffectsScopeStructure.VehicleJourneys(); AffectedVehicleJourneyStructure affectedVehicleJourney = new AffectedVehicleJourneyStructure(); VehicleJourneyRef vehicleJourney = new VehicleJourneyRef(); @@ -1094,7 +1100,8 @@ private AffectsScopeStructure createAffectsDatedVehicleJourney( String... stopIds ) { AffectsScopeStructure affects = new AffectsScopeStructure(); - AffectsScopeStructure.VehicleJourneys vehicleJourneys = new AffectsScopeStructure.VehicleJourneys(); + AffectsScopeStructure.VehicleJourneys vehicleJourneys = + new AffectsScopeStructure.VehicleJourneys(); AffectedVehicleJourneyStructure affectedVehicleJourney = new AffectedVehicleJourneyStructure(); DatedVehicleJourneyRef datedVehicleJourney = new DatedVehicleJourneyRef(); @@ -1147,7 +1154,8 @@ private AffectsScopeStructure createAffectsLine(String line, String... stopIds) AffectsScopeStructure affects = new AffectsScopeStructure(); AffectsScopeStructure.Networks networks = new AffectsScopeStructure.Networks(); - AffectsScopeStructure.Networks.AffectedNetwork affectedNetwork = new AffectsScopeStructure.Networks.AffectedNetwork(); + AffectsScopeStructure.Networks.AffectedNetwork affectedNetwork = + new AffectsScopeStructure.Networks.AffectedNetwork(); AffectedLineStructure affectedLine = new AffectedLineStructure(); LineRef lineRef = new LineRef(); lineRef.setValue(line); @@ -1217,7 +1225,8 @@ private AffectsScopeStructure createAffectsLineWithExternallyDefinedStopPoints( AffectsScopeStructure affects = new AffectsScopeStructure(); AffectsScopeStructure.Networks networks = new AffectsScopeStructure.Networks(); - AffectsScopeStructure.Networks.AffectedNetwork affectedNetwork = new AffectsScopeStructure.Networks.AffectedNetwork(); + AffectsScopeStructure.Networks.AffectedNetwork affectedNetwork = + new AffectsScopeStructure.Networks.AffectedNetwork(); AffectedLineStructure affectedLine = new AffectedLineStructure(); LineRef lineRef = new LineRef(); lineRef.setValue(line); @@ -1286,7 +1295,8 @@ private AffectsScopeStructure createAffectsLineWithExternallyDefinedStopPlaces( AffectsScopeStructure affects = new AffectsScopeStructure(); AffectsScopeStructure.Networks networks = new AffectsScopeStructure.Networks(); - AffectsScopeStructure.Networks.AffectedNetwork affectedNetwork = new AffectsScopeStructure.Networks.AffectedNetwork(); + AffectsScopeStructure.Networks.AffectedNetwork affectedNetwork = + new AffectsScopeStructure.Networks.AffectedNetwork(); AffectedLineStructure affectedLine = new AffectedLineStructure(); LineRef lineRef = new LineRef(); lineRef.setValue(line); diff --git a/application/src/test/java/org/opentripplanner/updater/trip/RealtimeTestConstants.java b/application/src/test/java/org/opentripplanner/updater/trip/RealtimeTestConstants.java index 87a9da83911..7d2fcb1f2ac 100644 --- a/application/src/test/java/org/opentripplanner/updater/trip/RealtimeTestConstants.java +++ b/application/src/test/java/org/opentripplanner/updater/trip/RealtimeTestConstants.java @@ -35,8 +35,7 @@ public interface RealtimeTestConstants { RegularStop STOP_B2 = TEST_MODEL.stop("B2").withParentStation(STATION_B).build(); RegularStop STOP_C1 = TEST_MODEL.stop(STOP_C1_ID).withParentStation(STATION_C).build(); RegularStop STOP_D1 = TEST_MODEL.stop("D1").withParentStation(STATION_D).build(); - SiteRepository SITE_REPOSITORY = TEST_MODEL - .siteRepositoryBuilder() + SiteRepository SITE_REPOSITORY = TEST_MODEL.siteRepositoryBuilder() .withRegularStop(STOP_A1) .withRegularStop(STOP_B1) .withRegularStop(STOP_B2) diff --git a/application/src/test/java/org/opentripplanner/updater/trip/RealtimeTestEnvironment.java b/application/src/test/java/org/opentripplanner/updater/trip/RealtimeTestEnvironment.java index f780d0fc570..553efb862ca 100644 --- a/application/src/test/java/org/opentripplanner/updater/trip/RealtimeTestEnvironment.java +++ b/application/src/test/java/org/opentripplanner/updater/trip/RealtimeTestEnvironment.java @@ -46,15 +46,15 @@ public static RealtimeTestEnvironmentBuilder of() { this.timetableRepository = timetableRepository; this.timetableRepository.index(); - this.snapshotManager = - new TimetableSnapshotManager( - null, - TimetableSnapshotParameters.PUBLISH_IMMEDIATELY, - () -> SERVICE_DATE - ); + this.snapshotManager = new TimetableSnapshotManager( + null, + TimetableSnapshotParameters.PUBLISH_IMMEDIATELY, + () -> SERVICE_DATE + ); siriAdapter = new SiriRealTimeTripUpdateAdapter(timetableRepository, snapshotManager); - gtfsAdapter = - new GtfsRealTimeTripUpdateAdapter(timetableRepository, snapshotManager, () -> SERVICE_DATE); + gtfsAdapter = new GtfsRealTimeTripUpdateAdapter(timetableRepository, snapshotManager, () -> + SERVICE_DATE + ); dateTimeHelper = new DateTimeHelper(TIME_ZONE, SERVICE_DATE); } @@ -181,16 +181,15 @@ private UpdateResult applyEstimatedTimetable( List updates, boolean fuzzyMatching ) { - UpdateResult updateResult = getEstimatedTimetableHandler(fuzzyMatching) - .applyUpdate( - updates, - DIFFERENTIAL, - new DefaultRealTimeUpdateContext( - new Graph(), - timetableRepository, - snapshotManager.getTimetableSnapshotBuffer() - ) - ); + UpdateResult updateResult = getEstimatedTimetableHandler(fuzzyMatching).applyUpdate( + updates, + DIFFERENTIAL, + new DefaultRealTimeUpdateContext( + new Graph(), + timetableRepository, + snapshotManager.getTimetableSnapshotBuffer() + ) + ); commitTimetableSnapshot(); return updateResult; } diff --git a/application/src/test/java/org/opentripplanner/updater/trip/RealtimeTestEnvironmentBuilder.java b/application/src/test/java/org/opentripplanner/updater/trip/RealtimeTestEnvironmentBuilder.java index 09eac9bbb4b..b7e2ca18e27 100644 --- a/application/src/test/java/org/opentripplanner/updater/trip/RealtimeTestEnvironmentBuilder.java +++ b/application/src/test/java/org/opentripplanner/updater/trip/RealtimeTestEnvironmentBuilder.java @@ -52,15 +52,13 @@ public RealtimeTestEnvironment build() { } private Trip createTrip(TripInput tripInput) { - var trip = Trip - .of(id(tripInput.id())) + var trip = Trip.of(id(tripInput.id())) .withRoute(tripInput.route()) .withHeadsign(I18NString.of("Headsign of %s".formatted(tripInput.id()))) .withServiceId(SERVICE_ID) .build(); - var tripOnServiceDate = TripOnServiceDate - .of(trip.getId()) + var tripOnServiceDate = TripOnServiceDate.of(trip.getId()) .withTrip(trip) .withServiceDate(SERVICE_DATE) .build(); @@ -71,8 +69,7 @@ private Trip createTrip(TripInput tripInput) { timetableRepository.addOperators(List.of(tripInput.route().getOperator())); } - var stopTimes = IntStream - .range(0, tripInput.stops().size()) + var stopTimes = IntStream.range(0, tripInput.stops().size()) .mapToObj(i -> { var stop = tripInput.stops().get(i); return createStopTime(trip, i, stop.stop(), stop.arrivalTime(), stop.departureTime()); @@ -81,8 +78,10 @@ private Trip createTrip(TripInput tripInput) { TripTimes tripTimes = TripTimesFactory.tripTimes(trip, stopTimes, null); - final TripPattern pattern = TimetableRepositoryForTest - .tripPattern(tripInput.id() + "Pattern", tripInput.route()) + final TripPattern pattern = TimetableRepositoryForTest.tripPattern( + tripInput.id() + "Pattern", + tripInput.route() + ) .withStopPattern( TimetableRepositoryForTest.stopPattern( tripInput.stops().stream().map(TripInput.StopCall::stop).toList() diff --git a/application/src/test/java/org/opentripplanner/updater/trip/TimetableSnapshotManagerTest.java b/application/src/test/java/org/opentripplanner/updater/trip/TimetableSnapshotManagerTest.java index c0a8095c1f8..97636807fad 100644 --- a/application/src/test/java/org/opentripplanner/updater/trip/TimetableSnapshotManagerTest.java +++ b/application/src/test/java/org/opentripplanner/updater/trip/TimetableSnapshotManagerTest.java @@ -28,8 +28,10 @@ class TimetableSnapshotManagerTest { private static final LocalDate YESTERDAY = TODAY.minusDays(1); private static final TimetableRepositoryForTest TEST_MODEL = TimetableRepositoryForTest.of(); - private static final TripPattern PATTERN = TimetableRepositoryForTest - .tripPattern("pattern", TimetableRepositoryForTest.route("r1").build()) + private static final TripPattern PATTERN = TimetableRepositoryForTest.tripPattern( + "pattern", + TimetableRepositoryForTest.route("r1").build() + ) .withStopPattern( TimetableRepositoryForTest.stopPattern( TEST_MODEL.stop("1").build(), @@ -38,8 +40,7 @@ class TimetableSnapshotManagerTest { ) .build(); private static final RealTimeTripTimes TRIP_TIMES = RealTimeTripTimes.of( - ScheduledTripTimes - .of() + ScheduledTripTimes.of() .withArrivalTimes("00:00 00:01") .withTrip(TimetableRepositoryForTest.trip("trip").build()) .build() diff --git a/application/src/test/java/org/opentripplanner/updater/trip/TripUpdateBuilder.java b/application/src/test/java/org/opentripplanner/updater/trip/TripUpdateBuilder.java index e8218edfc1f..79cbd655da3 100644 --- a/application/src/test/java/org/opentripplanner/updater/trip/TripUpdateBuilder.java +++ b/application/src/test/java/org/opentripplanner/updater/trip/TripUpdateBuilder.java @@ -129,7 +129,8 @@ private TripUpdateBuilder addStopTime( StopTimeUpdate.ScheduleRelationship scheduleRelationShip, DropOffPickupType pickDrop ) { - final StopTimeUpdate.Builder stopTimeUpdateBuilder = tripUpdateBuilder.addStopTimeUpdateBuilder(); + final StopTimeUpdate.Builder stopTimeUpdateBuilder = + tripUpdateBuilder.addStopTimeUpdateBuilder(); stopTimeUpdateBuilder.setScheduleRelationship(scheduleRelationShip); if (stopId != null) { @@ -150,8 +151,10 @@ private TripUpdateBuilder addStopTime( stopTimePropsBuilder.setExtension(MfdzRealtimeExtensions.stopTimeProperties, ext); } - final GtfsRealtime.TripUpdate.StopTimeEvent.Builder arrivalBuilder = stopTimeUpdateBuilder.getArrivalBuilder(); - final GtfsRealtime.TripUpdate.StopTimeEvent.Builder departureBuilder = stopTimeUpdateBuilder.getDepartureBuilder(); + final GtfsRealtime.TripUpdate.StopTimeEvent.Builder arrivalBuilder = + stopTimeUpdateBuilder.getArrivalBuilder(); + final GtfsRealtime.TripUpdate.StopTimeEvent.Builder departureBuilder = + stopTimeUpdateBuilder.getDepartureBuilder(); if (minutes > NO_VALUE) { var epochSeconds = midnight.plusHours(8).plusMinutes(minutes).toEpochSecond(); diff --git a/application/src/test/java/org/opentripplanner/updater/trip/gtfs/GtfsRealTimeTripUpdateAdapterTest.java b/application/src/test/java/org/opentripplanner/updater/trip/gtfs/GtfsRealTimeTripUpdateAdapterTest.java index 6ea28beb28d..f9dfb24c636 100644 --- a/application/src/test/java/org/opentripplanner/updater/trip/gtfs/GtfsRealTimeTripUpdateAdapterTest.java +++ b/application/src/test/java/org/opentripplanner/updater/trip/gtfs/GtfsRealTimeTripUpdateAdapterTest.java @@ -52,8 +52,9 @@ public void setUp() { transitService = new DefaultTransitService(timetableRepository); feedId = transitService.listFeedIds().stream().findFirst().get(); - snapshotManager = - new TimetableSnapshotManager(null, TimetableSnapshotParameters.DEFAULT, () -> SERVICE_DATE); + snapshotManager = new TimetableSnapshotManager(null, TimetableSnapshotParameters.DEFAULT, () -> + SERVICE_DATE + ); } @Test @@ -70,16 +71,18 @@ public void testHandleModifiedTrip() { tripDescriptorBuilder.setScheduleRelationship(ScheduleRelationship.REPLACEMENT); tripDescriptorBuilder.setStartDate(ServiceDateUtils.asCompactString(SERVICE_DATE)); - final long midnightSecondsSinceEpoch = ServiceDateUtils - .asStartOfService(SERVICE_DATE, transitService.getTimeZone()) - .toEpochSecond(); + final long midnightSecondsSinceEpoch = ServiceDateUtils.asStartOfService( + SERVICE_DATE, + transitService.getTimeZone() + ).toEpochSecond(); final TripUpdate.Builder tripUpdateBuilder = TripUpdate.newBuilder(); tripUpdateBuilder.setTrip(tripDescriptorBuilder); { // Stop O - final StopTimeUpdate.Builder stopTimeUpdateBuilder = tripUpdateBuilder.addStopTimeUpdateBuilder(); + final StopTimeUpdate.Builder stopTimeUpdateBuilder = + tripUpdateBuilder.addStopTimeUpdateBuilder(); stopTimeUpdateBuilder.setScheduleRelationship( StopTimeUpdate.ScheduleRelationship.SCHEDULED ); @@ -93,14 +96,16 @@ public void testHandleModifiedTrip() { } { // Departure - final StopTimeEvent.Builder departureBuilder = stopTimeUpdateBuilder.getDepartureBuilder(); + final StopTimeEvent.Builder departureBuilder = + stopTimeUpdateBuilder.getDepartureBuilder(); departureBuilder.setTime(midnightSecondsSinceEpoch + (12 * 3600) + (30 * 60)); departureBuilder.setDelay(0); } } { // Stop C - final StopTimeUpdate.Builder stopTimeUpdateBuilder = tripUpdateBuilder.addStopTimeUpdateBuilder(); + final StopTimeUpdate.Builder stopTimeUpdateBuilder = + tripUpdateBuilder.addStopTimeUpdateBuilder(); stopTimeUpdateBuilder.setScheduleRelationship( StopTimeUpdate.ScheduleRelationship.SCHEDULED ); @@ -114,14 +119,16 @@ public void testHandleModifiedTrip() { } { // Departure - final StopTimeEvent.Builder departureBuilder = stopTimeUpdateBuilder.getDepartureBuilder(); + final StopTimeEvent.Builder departureBuilder = + stopTimeUpdateBuilder.getDepartureBuilder(); departureBuilder.setTime(midnightSecondsSinceEpoch + (12 * 3600) + (45 * 60)); departureBuilder.setDelay(0); } } { // Stop D - final StopTimeUpdate.Builder stopTimeUpdateBuilder = tripUpdateBuilder.addStopTimeUpdateBuilder(); + final StopTimeUpdate.Builder stopTimeUpdateBuilder = + tripUpdateBuilder.addStopTimeUpdateBuilder(); stopTimeUpdateBuilder.setScheduleRelationship(SKIPPED); stopTimeUpdateBuilder.setStopId("D"); stopTimeUpdateBuilder.setStopSequence(40); @@ -133,14 +140,16 @@ public void testHandleModifiedTrip() { } { // Departure - final StopTimeEvent.Builder departureBuilder = stopTimeUpdateBuilder.getDepartureBuilder(); + final StopTimeEvent.Builder departureBuilder = + stopTimeUpdateBuilder.getDepartureBuilder(); departureBuilder.setTime(midnightSecondsSinceEpoch + (12 * 3600) + (51 * 60)); departureBuilder.setDelay(0); } } { // Stop P - final StopTimeUpdate.Builder stopTimeUpdateBuilder = tripUpdateBuilder.addStopTimeUpdateBuilder(); + final StopTimeUpdate.Builder stopTimeUpdateBuilder = + tripUpdateBuilder.addStopTimeUpdateBuilder(); stopTimeUpdateBuilder.setScheduleRelationship( StopTimeUpdate.ScheduleRelationship.SCHEDULED ); @@ -154,7 +163,8 @@ public void testHandleModifiedTrip() { } { // Departure - final StopTimeEvent.Builder departureBuilder = stopTimeUpdateBuilder.getDepartureBuilder(); + final StopTimeEvent.Builder departureBuilder = + stopTimeUpdateBuilder.getDepartureBuilder(); departureBuilder.setTime(midnightSecondsSinceEpoch + (12 * 3600) + (55 * 60)); departureBuilder.setDelay(0); } @@ -257,10 +267,8 @@ public void testHandleModifiedTrip() { } private GtfsRealTimeTripUpdateAdapter defaultUpdater() { - return new GtfsRealTimeTripUpdateAdapter( - timetableRepository, - snapshotManager, - () -> SERVICE_DATE + return new GtfsRealTimeTripUpdateAdapter(timetableRepository, snapshotManager, () -> + SERVICE_DATE ); } } diff --git a/application/src/test/java/org/opentripplanner/updater/trip/gtfs/LegacyTimetableSnapshotIntegrationTest.java b/application/src/test/java/org/opentripplanner/updater/trip/gtfs/LegacyTimetableSnapshotIntegrationTest.java index c0933e1d69d..9f40636a8b8 100644 --- a/application/src/test/java/org/opentripplanner/updater/trip/gtfs/LegacyTimetableSnapshotIntegrationTest.java +++ b/application/src/test/java/org/opentripplanner/updater/trip/gtfs/LegacyTimetableSnapshotIntegrationTest.java @@ -148,73 +148,67 @@ public void testUpdate() { // exception if we try to modify a snapshot TimetableSnapshot snapshot = resolver.commit(); - assertThrows( - ConcurrentModificationException.class, - () -> { - updateSnapshot(snapshot, pattern, tripUpdate, yesterday); - } - ); + assertThrows(ConcurrentModificationException.class, () -> { + updateSnapshot(snapshot, pattern, tripUpdate, yesterday); + }); } @Test public void testCommit() { - assertThrows( - ConcurrentModificationException.class, - () -> { - LocalDate today = LocalDate.now(timeZone); - LocalDate yesterday = today.minusDays(1); - TripPattern pattern = patternIndex.get(new FeedScopedId(feedId, "1.1")); - - TimetableSnapshot resolver = new TimetableSnapshot(); - - // only return a new snapshot if there are changes - TimetableSnapshot snapshot = resolver.commit(); - assertNull(snapshot); - - TripDescriptor.Builder tripDescriptorBuilder = TripDescriptor.newBuilder(); - - tripDescriptorBuilder.setTripId("1.1"); - tripDescriptorBuilder.setScheduleRelationship(ScheduleRelationship.SCHEDULED); - - TripUpdate.Builder tripUpdateBuilder = TripUpdate.newBuilder(); - - tripUpdateBuilder.setTrip(tripDescriptorBuilder); - - var stopTimeUpdateBuilder = tripUpdateBuilder.addStopTimeUpdateBuilder(0); - stopTimeUpdateBuilder.setStopSequence(2); - stopTimeUpdateBuilder.setScheduleRelationship( - TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED - ); - stopTimeUpdateBuilder.setDeparture( - TripUpdate.StopTimeEvent.newBuilder().setDelay(10).build() - ); - - TripUpdate tripUpdate = tripUpdateBuilder.build(); - - // add a new timetable for today, commit, and everything should match - assertTrue(updateSnapshot(resolver, pattern, tripUpdate, today).isSuccess()); - snapshot = resolver.commit(); - assertEquals(snapshot.resolve(pattern, today), resolver.resolve(pattern, today)); - assertEquals(snapshot.resolve(pattern, yesterday), resolver.resolve(pattern, yesterday)); - - // add a new timetable for today, don't commit, and everything should not match - assertTrue(updateSnapshot(resolver, pattern, tripUpdate, today).isSuccess()); - assertNotSame(snapshot.resolve(pattern, today), resolver.resolve(pattern, today)); - assertEquals(snapshot.resolve(pattern, yesterday), resolver.resolve(pattern, yesterday)); - - // add a new timetable for today, on another day, and things should still not match - assertTrue(updateSnapshot(resolver, pattern, tripUpdate, yesterday).isSuccess()); - assertNotSame(snapshot.resolve(pattern, yesterday), resolver.resolve(pattern, yesterday)); - - // commit, and things should match - snapshot = resolver.commit(); - assertEquals(snapshot.resolve(pattern, today), resolver.resolve(pattern, today)); - assertEquals(snapshot.resolve(pattern, yesterday), resolver.resolve(pattern, yesterday)); - - // exception if we try to commit to a snapshot - snapshot.commit(); - } - ); + assertThrows(ConcurrentModificationException.class, () -> { + LocalDate today = LocalDate.now(timeZone); + LocalDate yesterday = today.minusDays(1); + TripPattern pattern = patternIndex.get(new FeedScopedId(feedId, "1.1")); + + TimetableSnapshot resolver = new TimetableSnapshot(); + + // only return a new snapshot if there are changes + TimetableSnapshot snapshot = resolver.commit(); + assertNull(snapshot); + + TripDescriptor.Builder tripDescriptorBuilder = TripDescriptor.newBuilder(); + + tripDescriptorBuilder.setTripId("1.1"); + tripDescriptorBuilder.setScheduleRelationship(ScheduleRelationship.SCHEDULED); + + TripUpdate.Builder tripUpdateBuilder = TripUpdate.newBuilder(); + + tripUpdateBuilder.setTrip(tripDescriptorBuilder); + + var stopTimeUpdateBuilder = tripUpdateBuilder.addStopTimeUpdateBuilder(0); + stopTimeUpdateBuilder.setStopSequence(2); + stopTimeUpdateBuilder.setScheduleRelationship( + TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED + ); + stopTimeUpdateBuilder.setDeparture( + TripUpdate.StopTimeEvent.newBuilder().setDelay(10).build() + ); + + TripUpdate tripUpdate = tripUpdateBuilder.build(); + + // add a new timetable for today, commit, and everything should match + assertTrue(updateSnapshot(resolver, pattern, tripUpdate, today).isSuccess()); + snapshot = resolver.commit(); + assertEquals(snapshot.resolve(pattern, today), resolver.resolve(pattern, today)); + assertEquals(snapshot.resolve(pattern, yesterday), resolver.resolve(pattern, yesterday)); + + // add a new timetable for today, don't commit, and everything should not match + assertTrue(updateSnapshot(resolver, pattern, tripUpdate, today).isSuccess()); + assertNotSame(snapshot.resolve(pattern, today), resolver.resolve(pattern, today)); + assertEquals(snapshot.resolve(pattern, yesterday), resolver.resolve(pattern, yesterday)); + + // add a new timetable for today, on another day, and things should still not match + assertTrue(updateSnapshot(resolver, pattern, tripUpdate, yesterday).isSuccess()); + assertNotSame(snapshot.resolve(pattern, yesterday), resolver.resolve(pattern, yesterday)); + + // commit, and things should match + snapshot = resolver.commit(); + assertEquals(snapshot.resolve(pattern, today), resolver.resolve(pattern, today)); + assertEquals(snapshot.resolve(pattern, yesterday), resolver.resolve(pattern, yesterday)); + + // exception if we try to commit to a snapshot + snapshot.commit(); + }); } @Test diff --git a/application/src/test/java/org/opentripplanner/updater/trip/gtfs/TripTimesUpdaterTest.java b/application/src/test/java/org/opentripplanner/updater/trip/gtfs/TripTimesUpdaterTest.java index 5e26c485a0e..8528487a662 100644 --- a/application/src/test/java/org/opentripplanner/updater/trip/gtfs/TripTimesUpdaterTest.java +++ b/application/src/test/java/org/opentripplanner/updater/trip/gtfs/TripTimesUpdaterTest.java @@ -168,8 +168,7 @@ public void update() { ); stopTimeEventBuilder = stopTimeUpdateBuilder.getDepartureBuilder(); stopTimeEventBuilder.setTime( - LocalDateTime - .of(2009, Month.AUGUST.getValue() - 1 + 1, 7, 0, 2, 0, 0) + LocalDateTime.of(2009, Month.AUGUST.getValue() - 1 + 1, 7, 0, 2, 0, 0) .atZone(ZoneId.of("America/New_York")) .toEpochSecond() ); @@ -202,14 +201,13 @@ public void update() { stopTimeEventBuilder = stopTimeUpdateBuilder.getArrivalBuilder(); stopTimeEventBuilder.setDelay(0); tripUpdate = tripUpdateBuilder.build(); - result = - TripTimesUpdater.createUpdatedTripTimesFromGTFSRT( - timetable, - tripUpdate, - TIME_ZONE, - SERVICE_DATE, - BackwardsDelayPropagationType.REQUIRED_NO_DATA - ); + result = TripTimesUpdater.createUpdatedTripTimesFromGTFSRT( + timetable, + tripUpdate, + TIME_ZONE, + SERVICE_DATE, + BackwardsDelayPropagationType.REQUIRED_NO_DATA + ); assertTrue(result.isSuccess()); @@ -232,14 +230,13 @@ public void update() { stopTimeEventBuilder.setDelay(1); tripUpdate = tripUpdateBuilder.build(); - result = - TripTimesUpdater.createUpdatedTripTimesFromGTFSRT( - timetable, - tripUpdate, - TIME_ZONE, - SERVICE_DATE, - BackwardsDelayPropagationType.REQUIRED_NO_DATA - ); + result = TripTimesUpdater.createUpdatedTripTimesFromGTFSRT( + timetable, + tripUpdate, + TIME_ZONE, + SERVICE_DATE, + BackwardsDelayPropagationType.REQUIRED_NO_DATA + ); assertTrue(result.isSuccess()); @@ -260,14 +257,13 @@ public void update() { stopTimeEventBuilder = stopTimeUpdateBuilder.getDepartureBuilder(); stopTimeEventBuilder.setDelay(120); tripUpdate = tripUpdateBuilder.build(); - result = - TripTimesUpdater.createUpdatedTripTimesFromGTFSRT( - timetable, - tripUpdate, - TIME_ZONE, - SERVICE_DATE, - BackwardsDelayPropagationType.REQUIRED_NO_DATA - ); + result = TripTimesUpdater.createUpdatedTripTimesFromGTFSRT( + timetable, + tripUpdate, + TIME_ZONE, + SERVICE_DATE, + BackwardsDelayPropagationType.REQUIRED_NO_DATA + ); assertTrue(result.isSuccess()); @@ -287,14 +283,13 @@ public void update() { stopTimeEventBuilder = stopTimeUpdateBuilder.getDepartureBuilder(); stopTimeEventBuilder.setDelay(120); tripUpdate = tripUpdateBuilder.build(); - result = - TripTimesUpdater.createUpdatedTripTimesFromGTFSRT( - timetable, - tripUpdate, - TIME_ZONE, - SERVICE_DATE, - BackwardsDelayPropagationType.REQUIRED_NO_DATA - ); + result = TripTimesUpdater.createUpdatedTripTimesFromGTFSRT( + timetable, + tripUpdate, + TIME_ZONE, + SERVICE_DATE, + BackwardsDelayPropagationType.REQUIRED_NO_DATA + ); assertTrue(result.isSuccess()); diff --git a/application/src/test/java/org/opentripplanner/updater/trip/gtfs/moduletests/cancellation/CanceledTripTest.java b/application/src/test/java/org/opentripplanner/updater/trip/gtfs/moduletests/cancellation/CanceledTripTest.java index a06b3d85f6e..332bea4b35d 100644 --- a/application/src/test/java/org/opentripplanner/updater/trip/gtfs/moduletests/cancellation/CanceledTripTest.java +++ b/application/src/test/java/org/opentripplanner/updater/trip/gtfs/moduletests/cancellation/CanceledTripTest.java @@ -16,11 +16,9 @@ public class CanceledTripTest implements RealtimeTestConstants { @Test void listCanceledTrips() { - var env = RealtimeTestEnvironment - .of() + var env = RealtimeTestEnvironment.of() .addTrip( - TripInput - .of(TRIP_1_ID) + TripInput.of(TRIP_1_ID) .addStop(STOP_A1, "0:00:10", "0:00:11") .addStop(STOP_B1, "0:00:20", "0:00:21") .build() diff --git a/application/src/test/java/org/opentripplanner/updater/trip/gtfs/moduletests/cancellation/CancellationDeletionTest.java b/application/src/test/java/org/opentripplanner/updater/trip/gtfs/moduletests/cancellation/CancellationDeletionTest.java index 77677c2976e..f29c1a0bd2c 100644 --- a/application/src/test/java/org/opentripplanner/updater/trip/gtfs/moduletests/cancellation/CancellationDeletionTest.java +++ b/application/src/test/java/org/opentripplanner/updater/trip/gtfs/moduletests/cancellation/CancellationDeletionTest.java @@ -35,11 +35,9 @@ static List cases() { @ParameterizedTest @MethodSource("cases") void cancelledTrip(ScheduleRelationship relationship, RealTimeState state) { - var env = RealtimeTestEnvironment - .of() + var env = RealtimeTestEnvironment.of() .addTrip( - TripInput - .of(TRIP_1_ID) + TripInput.of(TRIP_1_ID) .addStop(STOP_A1, "0:00:10", "0:00:11") .addStop(STOP_B1, "0:00:20", "0:00:21") .build() diff --git a/application/src/test/java/org/opentripplanner/updater/trip/gtfs/moduletests/delay/DelayedTest.java b/application/src/test/java/org/opentripplanner/updater/trip/gtfs/moduletests/delay/DelayedTest.java index a9738ac7d65..06ce474f4ec 100644 --- a/application/src/test/java/org/opentripplanner/updater/trip/gtfs/moduletests/delay/DelayedTest.java +++ b/application/src/test/java/org/opentripplanner/updater/trip/gtfs/moduletests/delay/DelayedTest.java @@ -25,8 +25,7 @@ class DelayedTest implements RealtimeTestConstants { @Test void singleStopDelay() { - var TRIP_INPUT = TripInput - .of(TRIP_1_ID) + var TRIP_INPUT = TripInput.of(TRIP_1_ID) .addStop(STOP_A1, "0:00:10", "0:00:11") .addStop(STOP_B1, "0:00:20", "0:00:21") .build(); @@ -72,8 +71,7 @@ void singleStopDelay() { */ @Test void complexDelay() { - var tripInput = TripInput - .of(TRIP_2_ID) + var tripInput = TripInput.of(TRIP_2_ID) .addStop(STOP_A1, "0:01:00", "0:01:01") .addStop(STOP_B1, "0:01:10", "0:01:11") .addStop(STOP_C1, "0:01:20", "0:01:21") diff --git a/application/src/test/java/org/opentripplanner/updater/trip/gtfs/moduletests/delay/SkippedTest.java b/application/src/test/java/org/opentripplanner/updater/trip/gtfs/moduletests/delay/SkippedTest.java index e39e43e61b7..0cfabfcd4c6 100644 --- a/application/src/test/java/org/opentripplanner/updater/trip/gtfs/moduletests/delay/SkippedTest.java +++ b/application/src/test/java/org/opentripplanner/updater/trip/gtfs/moduletests/delay/SkippedTest.java @@ -23,8 +23,7 @@ */ class SkippedTest implements RealtimeTestConstants { - private static final TripInput TRIP_INPUT = TripInput - .of(TRIP_2_ID) + private static final TripInput TRIP_INPUT = TripInput.of(TRIP_2_ID) .addStop(STOP_A1, "0:01:00", "0:01:01") .addStop(STOP_B1, "0:01:10", "0:01:11") .addStop(STOP_C1, "0:01:20", "0:01:21") diff --git a/application/src/test/java/org/opentripplanner/updater/trip/gtfs/moduletests/rejection/InvalidInputTest.java b/application/src/test/java/org/opentripplanner/updater/trip/gtfs/moduletests/rejection/InvalidInputTest.java index bc1dfb06495..1be424eae0e 100644 --- a/application/src/test/java/org/opentripplanner/updater/trip/gtfs/moduletests/rejection/InvalidInputTest.java +++ b/application/src/test/java/org/opentripplanner/updater/trip/gtfs/moduletests/rejection/InvalidInputTest.java @@ -27,8 +27,7 @@ public static List cases() { @ParameterizedTest @MethodSource("cases") void invalidTripDate(LocalDate date) { - var tripInput = TripInput - .of(TRIP_1_ID) + var tripInput = TripInput.of(TRIP_1_ID) .addStop(STOP_A1, "0:00:10", "0:00:11") .addStop(STOP_B1, "0:00:20", "0:00:21") .build(); diff --git a/application/src/test/java/org/opentripplanner/updater/trip/siri/AddedTripBuilderTest.java b/application/src/test/java/org/opentripplanner/updater/trip/siri/AddedTripBuilderTest.java index 6b57b306e45..98b66f2fdfd 100644 --- a/application/src/test/java/org/opentripplanner/updater/trip/siri/AddedTripBuilderTest.java +++ b/application/src/test/java/org/opentripplanner/updater/trip/siri/AddedTripBuilderTest.java @@ -44,12 +44,10 @@ class AddedTripBuilderTest { private static final Agency AGENCY = TimetableRepositoryForTest.AGENCY; private static final ZoneId TIME_ZONE = AGENCY.getTimezone(); - private static final Operator OPERATOR = Operator - .of(TimetableRepositoryForTest.id("OPERATOR_ID")) + private static final Operator OPERATOR = Operator.of(TimetableRepositoryForTest.id("OPERATOR_ID")) .withName("OPERATOR_NAME") .build(); - private static final Route REPLACED_ROUTE = TimetableRepositoryForTest - .route("REPLACED_ROUTE") + private static final Route REPLACED_ROUTE = TimetableRepositoryForTest.route("REPLACED_ROUTE") .withAgency(AGENCY) .withOperator(OPERATOR) .build(); @@ -68,8 +66,7 @@ class AddedTripBuilderTest { private static final RegularStop STOP_B = MODEL_TEST.stop("B").build(); private static final RegularStop STOP_C = MODEL_TEST.stop("C").build(); private static final RegularStop STOP_D = MODEL_TEST.stop("D").build(); - private final SiteRepository SITE_REPOSITORY = MODEL_TEST - .siteRepositoryBuilder() + private final SiteRepository SITE_REPOSITORY = MODEL_TEST.siteRepositoryBuilder() .withRegularStop(STOP_A) .withRegularStop(STOP_B) .withRegularStop(STOP_C) @@ -88,8 +85,10 @@ class AddedTripBuilderTest { void setUp() { // Add entities to transit model for the entity resolver TRANSIT_MODEL.addAgency(AGENCY); - final TripPattern pattern = TimetableRepositoryForTest - .tripPattern("REPLACED_ROUTE_PATTERN_ID", REPLACED_ROUTE) + final TripPattern pattern = TimetableRepositoryForTest.tripPattern( + "REPLACED_ROUTE_PATTERN_ID", + REPLACED_ROUTE + ) .withStopPattern(TimetableRepositoryForTest.stopPattern(STOP_A, STOP_B)) .build(); TRANSIT_MODEL.addTripPattern(pattern.getId(), pattern); @@ -109,11 +108,10 @@ void setUp() { transitService = new DefaultTransitService(TRANSIT_MODEL); // Create the entity resolver only after the model has been indexed - ENTITY_RESOLVER = - new EntityResolver( - new DefaultTransitService(TRANSIT_MODEL), - TimetableRepositoryForTest.FEED_ID - ); + ENTITY_RESOLVER = new EntityResolver( + new DefaultTransitService(TRANSIT_MODEL), + TimetableRepositoryForTest.FEED_ID + ); } @Test @@ -137,8 +135,7 @@ void testAddedTrip() { HEADSIGN, List.of(), "DATASOURCE" - ) - .build(); + ).build(); assertTrue(addedTrip.isSuccess(), "Trip creation should succeed"); @@ -250,8 +247,7 @@ void testAddedTripOnAddedRoute() { HEADSIGN, List.of(), "DATASOURCE" - ) - .build(); + ).build(); assertTrue(firstAddedTrip.isSuccess(), "Trip creation should succeed"); assertTrue(firstAddedTrip.successValue().routeCreation()); @@ -279,8 +275,7 @@ void testAddedTripOnAddedRoute() { HEADSIGN, List.of(), "DATASOURCE" - ) - .build(); + ).build(); assertTrue(secondAddedTrip.isSuccess(), "Trip creation should succeed"); @@ -322,8 +317,7 @@ void testAddedTripOnExistingRoute() { HEADSIGN, List.of(), "DATASOURCE" - ) - .build(); + ).build(); assertTrue(addedTrip.isSuccess(), "Trip creation should succeed"); @@ -357,8 +351,7 @@ void testAddedTripWithoutReplacedRoute() { HEADSIGN, List.of(), "DATASOURCE" - ) - .build(); + ).build(); assertTrue(addedTrip.isSuccess(), "Trip creation should succeed"); @@ -402,8 +395,7 @@ void testAddedTripFailOnMissingServiceId() { HEADSIGN, List.of(), "DATASOURCE" - ) - .build(); + ).build(); assertTrue(addedTrip.isFailure(), "Trip creation should fail"); assertEquals( @@ -416,14 +408,12 @@ void testAddedTripFailOnMissingServiceId() { @Test void testAddedTripFailOnNonIncreasingDwellTime() { List calls = List.of( - TestCall - .of() + TestCall.of() .withStopPointRef(STOP_A.getId().getId()) .withAimedDepartureTime(zonedDateTime(10, 20)) .withExpectedDepartureTime(zonedDateTime(10, 20)) .build(), - TestCall - .of() + TestCall.of() .withStopPointRef(STOP_B.getId().getId()) .withAimedArrivalTime(zonedDateTime(10, 30)) .withExpectedArrivalTime(zonedDateTime(10, 31)) @@ -431,8 +421,7 @@ void testAddedTripFailOnNonIncreasingDwellTime() { .withExpectedDepartureTime(zonedDateTime(10, 29)) .build(), // Expected to arrive one minute prior to irrelevant aimed departure time - TestCall - .of() + TestCall.of() .withStopPointRef(STOP_C.getId().getId()) .withAimedArrivalTime(zonedDateTime(10, 40)) .withExpectedArrivalTime(zonedDateTime(10, 40)) @@ -458,8 +447,7 @@ void testAddedTripFailOnNonIncreasingDwellTime() { HEADSIGN, List.of(), "DATASOURCE" - ) - .build(); + ).build(); assertTrue(addedTrip.isFailure(), "Trip creation should fail"); assertEquals( @@ -472,8 +460,7 @@ void testAddedTripFailOnNonIncreasingDwellTime() { @Test void testAddedTripFailOnTooFewCalls() { List calls = List.of( - TestCall - .of() + TestCall.of() .withStopPointRef(STOP_A.getId().getId()) .withAimedDepartureTime(zonedDateTime(10, 20)) .withExpectedDepartureTime(zonedDateTime(10, 20)) @@ -498,8 +485,7 @@ void testAddedTripFailOnTooFewCalls() { HEADSIGN, List.of(), "DATASOURCE" - ) - .build(); + ).build(); assertTrue(addedTrip.isFailure(), "Trip creation should fail"); assertEquals( @@ -512,14 +498,12 @@ void testAddedTripFailOnTooFewCalls() { @Test void testAddedTripFailOnUnknownStop() { List calls = List.of( - TestCall - .of() + TestCall.of() .withStopPointRef("UNKNOWN_STOP_REF") .withAimedDepartureTime(zonedDateTime(10, 20)) .withExpectedDepartureTime(zonedDateTime(10, 20)) .build(), - TestCall - .of() + TestCall.of() .withStopPointRef(STOP_B.getId().getId()) .withAimedArrivalTime(zonedDateTime(10, 30)) .withExpectedArrivalTime(zonedDateTime(10, 31)) @@ -546,8 +530,7 @@ void testAddedTripFailOnUnknownStop() { HEADSIGN, List.of(), "DATASOURCE" - ) - .build(); + ).build(); assertTrue(addedTrip.isFailure(), "Trip creation should fail"); assertEquals( @@ -573,8 +556,7 @@ void testGetTransportMode( String subMode ) { // Arrange - var route = Route - .of(TimetableRepositoryForTest.id(LINE_REF)) + var route = Route.of(TimetableRepositoryForTest.id(LINE_REF)) .withShortName(SHORT_NAME) .withAgency(AGENCY) .withMode(TransitMode.valueOf(replacedRouteMode)) @@ -594,15 +576,13 @@ void testGetTransportMode( private static List getCalls(int hour) { return List.of( // Departed one minute early, prior to irrelevant aimed arrival time - TestCall - .of() + TestCall.of() .withStopPointRef(STOP_A.getId().getId()) .withAimedDepartureTime(zonedDateTime(hour, 20)) .withExpectedDepartureTime(zonedDateTime(hour, 20)) .withActualDepartureTime(zonedDateTime(hour, 19)) .build(), - TestCall - .of() + TestCall.of() .withStopPointRef(STOP_B.getId().getId()) .withAimedArrivalTime(zonedDateTime(hour, 30)) .withExpectedArrivalTime(zonedDateTime(hour, 29)) @@ -610,8 +590,7 @@ private static List getCalls(int hour) { .withExpectedDepartureTime(zonedDateTime(hour, 31)) .build(), // Expected to arrive one minute prior to irrelevant aimed departure time - TestCall - .of() + TestCall.of() .withStopPointRef(STOP_C.getId().getId()) .withAimedArrivalTime(zonedDateTime(hour, 40)) .withExpectedArrivalTime(zonedDateTime(hour, 41)) diff --git a/application/src/test/java/org/opentripplanner/updater/trip/siri/EntityResolverTest.java b/application/src/test/java/org/opentripplanner/updater/trip/siri/EntityResolverTest.java index f1bc1c721f3..203f71e123e 100644 --- a/application/src/test/java/org/opentripplanner/updater/trip/siri/EntityResolverTest.java +++ b/application/src/test/java/org/opentripplanner/updater/trip/siri/EntityResolverTest.java @@ -19,8 +19,7 @@ class EntityResolverTest { private static final TimetableRepositoryForTest TEST_MODEL = TimetableRepositoryForTest.of(); private static final RegularStop STOP_1 = TEST_MODEL.stop("stop-1").build(); private static final RegularStop STOP_2 = TEST_MODEL.stop("stop-2").build(); - private static final SiteRepository SITE_REPOSITORY = TEST_MODEL - .siteRepositoryBuilder() + private static final SiteRepository SITE_REPOSITORY = TEST_MODEL.siteRepositoryBuilder() .withRegularStops(List.of(STOP_1, STOP_2)) .build(); private static final String FEED_ID = STOP_1.getId().getFeedId(); diff --git a/application/src/test/java/org/opentripplanner/updater/trip/siri/ModifiedTripBuilderTest.java b/application/src/test/java/org/opentripplanner/updater/trip/siri/ModifiedTripBuilderTest.java index bca6b39b9a8..841886e89c0 100644 --- a/application/src/test/java/org/opentripplanner/updater/trip/siri/ModifiedTripBuilderTest.java +++ b/application/src/test/java/org/opentripplanner/updater/trip/siri/ModifiedTripBuilderTest.java @@ -47,38 +47,34 @@ class ModifiedTripBuilderTest { private static final Station STATION_B = TEST_MODEL.station("B").build(); private static final Station STATION_C = TEST_MODEL.station("C").build(); - private static final RegularStop STOP_A_1 = TEST_MODEL - .stop("A_1") + private static final RegularStop STOP_A_1 = TEST_MODEL.stop("A_1") .withParentStation(STATION_A) .build(); - private static final RegularStop STOP_A_2 = TEST_MODEL - .stop("A_2") + private static final RegularStop STOP_A_2 = TEST_MODEL.stop("A_2") .withParentStation(STATION_A) .build(); - private static final RegularStop STOP_B_1 = TEST_MODEL - .stop("B_1") + private static final RegularStop STOP_B_1 = TEST_MODEL.stop("B_1") .withParentStation(STATION_B) .build(); - private static final RegularStop STOP_C_1 = TEST_MODEL - .stop("C_1") + private static final RegularStop STOP_C_1 = TEST_MODEL.stop("C_1") .withParentStation(STATION_C) .build(); private static final RegularStop STOP_D = TEST_MODEL.stop("D").build(); - private static final Route ROUTE = TimetableRepositoryForTest - .route("ROUTE_ID") + private static final Route ROUTE = TimetableRepositoryForTest.route("ROUTE_ID") .withAgency(AGENCY) .build(); - private static final TripPattern PATTERN = TimetableRepositoryForTest - .tripPattern("PATTERN_ID", ROUTE) + private static final TripPattern PATTERN = TimetableRepositoryForTest.tripPattern( + "PATTERN_ID", + ROUTE + ) .withStopPattern(TimetableRepositoryForTest.stopPattern(STOP_A_1, STOP_B_1, STOP_C_1)) .build(); private static final FeedScopedId SERVICE_ID = TimetableRepositoryForTest.id("CAL_1"); - private static final Trip TRIP = TimetableRepositoryForTest - .trip("TRIP") + private static final Trip TRIP = TimetableRepositoryForTest.trip("TRIP") .withRoute(ROUTE) .withServiceId(SERVICE_ID) .build(); @@ -119,8 +115,7 @@ class ModifiedTripBuilderTest { ); private static final LocalDate SERVICE_DATE = LocalDate.of(2023, 2, 17); - private final SiteRepository siteRepository = TEST_MODEL - .siteRepositoryBuilder() + private final SiteRepository siteRepository = TEST_MODEL.siteRepositoryBuilder() .withRegularStop(STOP_A_1) .withRegularStop(STOP_A_2) .withRegularStop(STOP_B_1) @@ -156,11 +151,10 @@ void setUp() { timetableRepository.index(); // Create the entity resolver only after the model has been indexed - entityResolver = - new EntityResolver( - new DefaultTransitService(timetableRepository), - TimetableRepositoryForTest.FEED_ID - ); + entityResolver = new EntityResolver( + new DefaultTransitService(timetableRepository), + TimetableRepositoryForTest.FEED_ID + ); } @Test @@ -176,8 +170,7 @@ void testUpdateNoCalls() { null, false, "DATASOURCE" - ) - .build(); + ).build(); assertTrue(result.isSuccess(), "Update should succeed"); @@ -206,8 +199,7 @@ void testUpdateCancellation() { null, false, "DATASOURCE" - ) - .build(); + ).build(); assertTrue(result.isSuccess(), "Update should succeed"); @@ -226,22 +218,19 @@ void testUpdateSameStops() { timetableRepository.getTimeZone(), entityResolver, List.of( - TestCall - .of() + TestCall.of() .withStopPointRef(STOP_A_1.getId().getId()) .withAimedDepartureTime(zonedDateTime(10, 0)) .withExpectedDepartureTime(zonedDateTime(10, 1)) .build(), - TestCall - .of() + TestCall.of() .withStopPointRef(STOP_B_1.getId().getId()) .withAimedArrivalTime(zonedDateTime(10, 10)) .withExpectedArrivalTime(zonedDateTime(10, 11)) .withAimedDepartureTime(zonedDateTime(10, 12)) .withExpectedDepartureTime(zonedDateTime(10, 13)) .build(), - TestCall - .of() + TestCall.of() .withStopPointRef(STOP_C_1.getId().getId()) .withAimedArrivalTime(zonedDateTime(10, 20)) .withExpectedArrivalTime(zonedDateTime(10, 22)) @@ -251,8 +240,7 @@ void testUpdateSameStops() { null, false, "DATASOURCE" - ) - .build(); + ).build(); assertTrue(result.isSuccess(), "Update should succeed"); @@ -277,22 +265,19 @@ void testUpdateValidationFailure() { timetableRepository.getTimeZone(), entityResolver, List.of( - TestCall - .of() + TestCall.of() .withStopPointRef(STOP_A_1.getId().getId()) .withAimedDepartureTime(zonedDateTime(10, 0)) .withExpectedDepartureTime(zonedDateTime(10, 1)) .build(), - TestCall - .of() + TestCall.of() .withStopPointRef(STOP_B_1.getId().getId()) .withAimedArrivalTime(zonedDateTime(10, 10)) .withExpectedArrivalTime(zonedDateTime(10, 12)) .withAimedDepartureTime(zonedDateTime(10, 12)) .withExpectedDepartureTime(zonedDateTime(10, 10)) .build(), - TestCall - .of() + TestCall.of() .withStopPointRef(STOP_C_1.getId().getId()) .withAimedArrivalTime(zonedDateTime(10, 20)) .withExpectedArrivalTime(zonedDateTime(10, 22)) @@ -302,8 +287,7 @@ void testUpdateValidationFailure() { null, false, "DATASOURCE" - ) - .build(); + ).build(); assertFalse(result.isSuccess(), "Update should fail"); UpdateError updateError = result.failureValue(); @@ -326,22 +310,19 @@ void testUpdateSameStopsDepartEarly() { timetableRepository.getTimeZone(), entityResolver, List.of( - TestCall - .of() + TestCall.of() .withStopPointRef(STOP_A_1.getId().getId()) .withAimedDepartureTime(zonedDateTime(10, 0)) .withExpectedDepartureTime(zonedDateTime(9, 58)) .build(), - TestCall - .of() + TestCall.of() .withStopPointRef(STOP_B_1.getId().getId()) .withAimedArrivalTime(zonedDateTime(10, 10)) .withExpectedArrivalTime(zonedDateTime(10, 11)) .withAimedDepartureTime(zonedDateTime(10, 12)) .withExpectedDepartureTime(zonedDateTime(10, 13)) .build(), - TestCall - .of() + TestCall.of() .withStopPointRef(STOP_C_1.getId().getId()) .withAimedArrivalTime(zonedDateTime(10, 20)) .withExpectedArrivalTime(zonedDateTime(10, 22)) @@ -351,8 +332,7 @@ void testUpdateSameStopsDepartEarly() { null, false, "DATASOURCE" - ) - .build(); + ).build(); assertTrue(result.isSuccess(), "Update should succeed"); @@ -377,22 +357,19 @@ void testUpdateUpdatedStop() { timetableRepository.getTimeZone(), entityResolver, List.of( - TestCall - .of() + TestCall.of() .withStopPointRef(STOP_A_2.getId().getId()) .withAimedDepartureTime(zonedDateTime(10, 0)) .withExpectedDepartureTime(zonedDateTime(10, 1)) .build(), - TestCall - .of() + TestCall.of() .withStopPointRef(STOP_B_1.getId().getId()) .withAimedArrivalTime(zonedDateTime(10, 10)) .withExpectedArrivalTime(zonedDateTime(10, 11)) .withAimedDepartureTime(zonedDateTime(10, 12)) .withExpectedDepartureTime(zonedDateTime(10, 13)) .build(), - TestCall - .of() + TestCall.of() .withStopPointRef(STOP_C_1.getId().getId()) .withAimedArrivalTime(zonedDateTime(10, 20)) .withExpectedArrivalTime(zonedDateTime(10, 22)) @@ -402,8 +379,7 @@ void testUpdateUpdatedStop() { null, false, "DATASOURCE" - ) - .build(); + ).build(); assertTrue(result.isSuccess(), "Update should succeed"); @@ -433,23 +409,20 @@ void testUpdateCascading() { timetableRepository.getTimeZone(), entityResolver, List.of( - TestCall - .of() + TestCall.of() .withStopPointRef(STOP_A_1.getId().getId()) .withAimedDepartureTime(zonedDateTime(10, 0)) .withExpectedDepartureTime(zonedDateTime(10, 1)) .withActualDepartureTime(zonedDateTime(10, 2)) .build(), - TestCall - .of() + TestCall.of() .withStopPointRef(STOP_B_1.getId().getId()) .withAimedArrivalTime(zonedDateTime(10, 10)) .withExpectedArrivalTime(zonedDateTime(10, 11)) .withAimedDepartureTime(zonedDateTime(10, 12)) .withExpectedDepartureTime(zonedDateTime(10, 13)) .build(), - TestCall - .of() + TestCall.of() .withStopPointRef(STOP_C_1.getId().getId()) .withAimedArrivalTime(zonedDateTime(10, 20)) .withExpectedArrivalTime(zonedDateTime(10, 22)) @@ -459,8 +432,7 @@ void testUpdateCascading() { null, false, "DATASOURCE" - ) - .build(); + ).build(); assertTrue(firstResult.isSuccess(), "Update should succeed"); @@ -484,8 +456,7 @@ void testUpdateCascading() { timetableRepository.getTimeZone(), entityResolver, List.of( - TestCall - .of() + TestCall.of() .withStopPointRef(STOP_B_1.getId().getId()) .withAimedArrivalTime(zonedDateTime(10, 10)) .withExpectedArrivalTime(zonedDateTime(10, 11)) @@ -494,8 +465,7 @@ void testUpdateCascading() { .withExpectedDepartureTime(zonedDateTime(10, 13)) .withActualDepartureTime(zonedDateTime(10, 14)) .build(), - TestCall - .of() + TestCall.of() .withStopPointRef(STOP_C_1.getId().getId()) .withAimedArrivalTime(zonedDateTime(10, 20)) .withExpectedArrivalTime(zonedDateTime(10, 25)) @@ -505,8 +475,7 @@ void testUpdateCascading() { null, false, "DATASOURCE" - ) - .build(); + ).build(); TripUpdate tripUpdate = secondResult.successValue(); StopPattern stopPattern = tripUpdate.stopPattern(); @@ -653,8 +622,7 @@ void testCreateStopPatternNoBoardingCall() { PATTERN, List.of( TestCall.of().withStopPointRef(STOP_A_1.getId().getId()).build(), - TestCall - .of() + TestCall.of() .withStopPointRef(STOP_B_1.getId().getId()) .withDepartureBoardingActivity(DepartureBoardingActivityEnumeration.NO_BOARDING) .build(), diff --git a/application/src/test/java/org/opentripplanner/updater/trip/siri/SiriEtBuilder.java b/application/src/test/java/org/opentripplanner/updater/trip/siri/SiriEtBuilder.java index 99aa3b31e8c..57082723244 100644 --- a/application/src/test/java/org/opentripplanner/updater/trip/siri/SiriEtBuilder.java +++ b/application/src/test/java/org/opentripplanner/updater/trip/siri/SiriEtBuilder.java @@ -167,7 +167,8 @@ public FramedVehicleJourneyRefStructure build() { if (serviceDate != null) { dataFrameRefStructure.setValue(DateTimeFormatter.ISO_LOCAL_DATE.format(serviceDate)); } - FramedVehicleJourneyRefStructure framedVehicleJourneyRefStructure = new FramedVehicleJourneyRefStructure(); + FramedVehicleJourneyRefStructure framedVehicleJourneyRefStructure = + new FramedVehicleJourneyRefStructure(); framedVehicleJourneyRefStructure.setDataFrameRef(dataFrameRefStructure); framedVehicleJourneyRefStructure.setDatedVehicleJourneyRef(vehicleJourneyRef); return framedVehicleJourneyRefStructure; diff --git a/application/src/test/java/org/opentripplanner/updater/trip/siri/SiriFuzzyTripMatcherTest.java b/application/src/test/java/org/opentripplanner/updater/trip/siri/SiriFuzzyTripMatcherTest.java index fc2906ceb63..dac05e5d878 100644 --- a/application/src/test/java/org/opentripplanner/updater/trip/siri/SiriFuzzyTripMatcherTest.java +++ b/application/src/test/java/org/opentripplanner/updater/trip/siri/SiriFuzzyTripMatcherTest.java @@ -116,8 +116,7 @@ private static EstimatedVehicleJourney estimatedVehicleJourney(RealtimeTestEnvir } private static TripInput tripInput(String trip1Id) { - return TripInput - .of(trip1Id) + return TripInput.of(trip1Id) .addStop(STOP_A1, "0:10:00", "0:10:00") .addStop(STOP_B1, "0:20:00", "0:20:00") .build(); diff --git a/application/src/test/java/org/opentripplanner/updater/trip/siri/TimetableHelperTest.java b/application/src/test/java/org/opentripplanner/updater/trip/siri/TimetableHelperTest.java index 0d1204430b6..b672dc11e85 100644 --- a/application/src/test/java/org/opentripplanner/updater/trip/siri/TimetableHelperTest.java +++ b/application/src/test/java/org/opentripplanner/updater/trip/siri/TimetableHelperTest.java @@ -50,15 +50,13 @@ public class TimetableHelperTest { @BeforeEach public void setUp() { - Station station = Station - .of(SCOPED_STATION_ID) + Station station = Station.of(SCOPED_STATION_ID) .withName(new NonLocalizedString(STATION_NAME)) .withCoordinate(0.0, 0.0) .build(); var stopTime = new StopTime(); - RegularStop stop = SiteRepository - .of() + RegularStop stop = SiteRepository.of() .regularStop(SCOPED_STOP_ID) .withCoordinate(0.0, 0.0) .withParentStation(station) @@ -67,8 +65,7 @@ public void setUp() { Agency agency = Agency.of(SCOPED_AGENCY_ID).withName(AGENCY_NAME).withTimezone("CET").build(); - Route route = Route - .of(SCOPED_LINE_ID) + Route route = Route.of(SCOPED_LINE_ID) .withShortName(LINE_SHORT_NAME) .withAgency(agency) .withMode(TransitMode.FUNICULAR) @@ -82,8 +79,7 @@ public void setUp() { public void testApplyUpdates_MapPredictionInaccurate_EstimatedCall() { // Arrange - CallWrapper estimatedCall = TestCall - .of() + CallWrapper estimatedCall = TestCall.of() .withStopPointRef(STOP_ID) .withCancellation(false) .withOccupancy(OccupancyEnumeration.SEATS_AVAILABLE) @@ -101,8 +97,7 @@ public void testApplyUpdates_MapPredictionInaccurate_EstimatedCall() { public void testApplyUpdates_CancellationPriorityOverPredictionInaccurate_EstimatedCall() { // Arrange - CallWrapper estimatedCall = TestCall - .of() + CallWrapper estimatedCall = TestCall.of() .withStopPointRef(STOP_ID) .withCancellation(true) .withOccupancy(OccupancyEnumeration.FULL) @@ -122,8 +117,7 @@ public void testApplyUpdates_CancellationPriorityOverPredictionInaccurate_Record // Arrange ZonedDateTime actualTime = START_OF_SERVICE.plus(Duration.ofHours(1)); - CallWrapper recordedCall = TestCall - .of() + CallWrapper recordedCall = TestCall.of() .withStopPointRef(STOP_ID) .withPredictionInaccurate(true) .withOccupancy(OccupancyEnumeration.FULL) @@ -143,8 +137,7 @@ public void testApplyUpdates_CancellationPriorityOverPredictionInaccurate_Record public void testApplyUpdates_PredictionInaccuratePriorityOverRecorded() { // Arrange - CallWrapper recordedCall = TestCall - .of() + CallWrapper recordedCall = TestCall.of() .withStopPointRef(STOP_ID) .withPredictionInaccurate(true) .withOccupancy(OccupancyEnumeration.FULL) @@ -163,8 +156,7 @@ public void testApplyUpdates_PredictionInaccuratePriorityOverRecorded() { public void testApplyUpdates_ActualTimeResultsInRecorded() { // Arrange - CallWrapper recordedCall = TestCall - .of() + CallWrapper recordedCall = TestCall.of() .withStopPointRef(STOP_ID) .withPredictionInaccurate(false) .withOccupancy(OccupancyEnumeration.STANDING_AVAILABLE) diff --git a/application/src/test/java/org/opentripplanner/updater/trip/siri/moduletests/InterpolationTest.java b/application/src/test/java/org/opentripplanner/updater/trip/siri/moduletests/InterpolationTest.java index 455abcf820b..7c48e8fa331 100644 --- a/application/src/test/java/org/opentripplanner/updater/trip/siri/moduletests/InterpolationTest.java +++ b/application/src/test/java/org/opentripplanner/updater/trip/siri/moduletests/InterpolationTest.java @@ -10,8 +10,7 @@ class InterpolationTest implements RealtimeTestConstants { - private static final TripInput TRIP_INPUT = TripInput - .of(TRIP_1_ID) + private static final TripInput TRIP_INPUT = TripInput.of(TRIP_1_ID) .addStop(STOP_A1, "0:00:10", "0:00:11") .addStop(STOP_B1, "0:00:20", "0:00:21") .addStop(STOP_C1, "0:00:40", "0:00:41") diff --git a/application/src/test/java/org/opentripplanner/updater/trip/siri/moduletests/cancellation/CancellationTest.java b/application/src/test/java/org/opentripplanner/updater/trip/siri/moduletests/cancellation/CancellationTest.java index 6f97e68fcb8..be7ac2605bb 100644 --- a/application/src/test/java/org/opentripplanner/updater/trip/siri/moduletests/cancellation/CancellationTest.java +++ b/application/src/test/java/org/opentripplanner/updater/trip/siri/moduletests/cancellation/CancellationTest.java @@ -11,8 +11,7 @@ class CancellationTest implements RealtimeTestConstants { - private static final TripInput TRIP_INPUT = TripInput - .of(TRIP_1_ID) + private static final TripInput TRIP_INPUT = TripInput.of(TRIP_1_ID) .addStop(STOP_A1, "0:00:10", "0:00:11") .addStop(STOP_B1, "0:00:20", "0:00:21") .build(); diff --git a/application/src/test/java/org/opentripplanner/updater/trip/siri/moduletests/cancellation/CancelledStopTest.java b/application/src/test/java/org/opentripplanner/updater/trip/siri/moduletests/cancellation/CancelledStopTest.java index 8a92820bea8..fcaedd57a73 100644 --- a/application/src/test/java/org/opentripplanner/updater/trip/siri/moduletests/cancellation/CancelledStopTest.java +++ b/application/src/test/java/org/opentripplanner/updater/trip/siri/moduletests/cancellation/CancelledStopTest.java @@ -10,8 +10,7 @@ class CancelledStopTest implements RealtimeTestConstants { - private static final TripInput TRIP_INPUT = TripInput - .of(TRIP_2_ID) + private static final TripInput TRIP_INPUT = TripInput.of(TRIP_2_ID) .addStop(STOP_A1, "0:01:00", "0:01:01") .addStop(STOP_B1, "0:01:10", "0:01:11") .addStop(STOP_C1, "0:01:20", "0:01:21") diff --git a/application/src/test/java/org/opentripplanner/updater/trip/siri/moduletests/extrajourney/ExtraJourneyTest.java b/application/src/test/java/org/opentripplanner/updater/trip/siri/moduletests/extrajourney/ExtraJourneyTest.java index d444ef55609..028fb94c4ea 100644 --- a/application/src/test/java/org/opentripplanner/updater/trip/siri/moduletests/extrajourney/ExtraJourneyTest.java +++ b/application/src/test/java/org/opentripplanner/updater/trip/siri/moduletests/extrajourney/ExtraJourneyTest.java @@ -20,8 +20,7 @@ class ExtraJourneyTest implements RealtimeTestConstants { - private static final TripInput TRIP_1_INPUT = TripInput - .of(TRIP_1_ID) + private static final TripInput TRIP_1_INPUT = TripInput.of(TRIP_1_ID) .withRoute(ROUTE_1.copy().withOperator(OPERATOR1).build()) .addStop(STOP_A1, "0:00:10", "0:00:11") .addStop(STOP_B1, "0:00:20", "0:00:21") diff --git a/application/src/test/java/org/opentripplanner/updater/trip/siri/moduletests/fuzzymatching/FuzzyTripMatchingTest.java b/application/src/test/java/org/opentripplanner/updater/trip/siri/moduletests/fuzzymatching/FuzzyTripMatchingTest.java index 574f757369d..42135d660ab 100644 --- a/application/src/test/java/org/opentripplanner/updater/trip/siri/moduletests/fuzzymatching/FuzzyTripMatchingTest.java +++ b/application/src/test/java/org/opentripplanner/updater/trip/siri/moduletests/fuzzymatching/FuzzyTripMatchingTest.java @@ -13,8 +13,7 @@ class FuzzyTripMatchingTest implements RealtimeTestConstants { - private static final TripInput TRIP_INPUT = TripInput - .of(TRIP_1_ID) + private static final TripInput TRIP_INPUT = TripInput.of(TRIP_1_ID) .addStop(STOP_A1, "0:00:10", "0:00:11") .addStop(STOP_B1, "0:00:20", "0:00:21") .build(); @@ -59,14 +58,13 @@ void testUpdateJourneyWithFuzzyMatchingAndMissingAimedDepartureTime() { } private static SiriEtBuilder updatedJourneyBuilder(RealtimeTestEnvironment env) { - return new SiriEtBuilder(env.getDateTimeHelper()) - .withEstimatedCalls(builder -> - builder - .call(STOP_A1) - .departAimedExpected("00:00:11", "00:00:15") - .call(STOP_B1) - .arriveAimedExpected("00:00:20", "00:00:25") - ); + return new SiriEtBuilder(env.getDateTimeHelper()).withEstimatedCalls(builder -> + builder + .call(STOP_A1) + .departAimedExpected("00:00:11", "00:00:15") + .call(STOP_B1) + .arriveAimedExpected("00:00:20", "00:00:25") + ); } private static void assertTripUpdated(RealtimeTestEnvironment env) { diff --git a/application/src/test/java/org/opentripplanner/updater/trip/siri/moduletests/rejection/InvalidStopPointRefTest.java b/application/src/test/java/org/opentripplanner/updater/trip/siri/moduletests/rejection/InvalidStopPointRefTest.java index 5871cd49fc8..22d6206f609 100644 --- a/application/src/test/java/org/opentripplanner/updater/trip/siri/moduletests/rejection/InvalidStopPointRefTest.java +++ b/application/src/test/java/org/opentripplanner/updater/trip/siri/moduletests/rejection/InvalidStopPointRefTest.java @@ -15,9 +15,9 @@ class InvalidStopPointRefTest implements RealtimeTestConstants { private static Stream cases() { - return Stream - .of("", " ", " ", "\n", "null", "\t", null) - .flatMap(id -> Stream.of(Arguments.of(id, true), Arguments.of(id, false))); + return Stream.of("", " ", " ", "\n", "null", "\t", null).flatMap(id -> + Stream.of(Arguments.of(id, true), Arguments.of(id, false)) + ); } @ParameterizedTest(name = "invalid id of ''{0}'', extraJourney={1}") diff --git a/application/src/test/java/org/opentripplanner/updater/trip/siri/moduletests/rejection/NegativeTimesTest.java b/application/src/test/java/org/opentripplanner/updater/trip/siri/moduletests/rejection/NegativeTimesTest.java index 6f687e6d906..bad9799943d 100644 --- a/application/src/test/java/org/opentripplanner/updater/trip/siri/moduletests/rejection/NegativeTimesTest.java +++ b/application/src/test/java/org/opentripplanner/updater/trip/siri/moduletests/rejection/NegativeTimesTest.java @@ -11,14 +11,12 @@ class NegativeTimesTest implements RealtimeTestConstants { - private static final TripInput TRIP_1_INPUT = TripInput - .of(TRIP_1_ID) + private static final TripInput TRIP_1_INPUT = TripInput.of(TRIP_1_ID) .addStop(STOP_A1, "0:00:10", "0:00:11") .addStop(STOP_B1, "0:00:20", "0:00:21") .build(); - private static final TripInput TRIP_2_INPUT = TripInput - .of(TRIP_2_ID) + private static final TripInput TRIP_2_INPUT = TripInput.of(TRIP_2_ID) .addStop(STOP_A1, "0:01:00", "0:01:01") .addStop(STOP_B1, "0:01:10", "0:01:11") .addStop(STOP_C1, "0:01:20", "0:01:21") diff --git a/application/src/test/java/org/opentripplanner/updater/trip/siri/moduletests/rejection/NotMonitoredTest.java b/application/src/test/java/org/opentripplanner/updater/trip/siri/moduletests/rejection/NotMonitoredTest.java index ef0de17f343..b461f5c85d7 100644 --- a/application/src/test/java/org/opentripplanner/updater/trip/siri/moduletests/rejection/NotMonitoredTest.java +++ b/application/src/test/java/org/opentripplanner/updater/trip/siri/moduletests/rejection/NotMonitoredTest.java @@ -11,8 +11,7 @@ class NotMonitoredTest implements RealtimeTestConstants { - private static final TripInput TRIP_1_INPUT = TripInput - .of(TRIP_1_ID) + private static final TripInput TRIP_1_INPUT = TripInput.of(TRIP_1_ID) .addStop(STOP_A1, "0:00:10", "0:00:11") .addStop(STOP_B1, "0:00:20", "0:00:21") .build(); diff --git a/application/src/test/java/org/opentripplanner/updater/trip/siri/moduletests/unsupported/UnsupportedTest.java b/application/src/test/java/org/opentripplanner/updater/trip/siri/moduletests/unsupported/UnsupportedTest.java index be3aaae798f..9ac5d44cb19 100644 --- a/application/src/test/java/org/opentripplanner/updater/trip/siri/moduletests/unsupported/UnsupportedTest.java +++ b/application/src/test/java/org/opentripplanner/updater/trip/siri/moduletests/unsupported/UnsupportedTest.java @@ -16,8 +16,7 @@ */ class UnsupportedTest implements RealtimeTestConstants { - private static final TripInput TRIP_1_INPUT = TripInput - .of(TRIP_1_ID) + private static final TripInput TRIP_1_INPUT = TripInput.of(TRIP_1_ID) .addStop(STOP_A1, "0:00:10", "0:00:11") .addStop(STOP_B1, "0:00:20", "0:00:21") .build(); diff --git a/application/src/test/java/org/opentripplanner/updater/trip/siri/moduletests/update/QuayChangeTest.java b/application/src/test/java/org/opentripplanner/updater/trip/siri/moduletests/update/QuayChangeTest.java index 04fcecea4b6..ab1bdc09515 100644 --- a/application/src/test/java/org/opentripplanner/updater/trip/siri/moduletests/update/QuayChangeTest.java +++ b/application/src/test/java/org/opentripplanner/updater/trip/siri/moduletests/update/QuayChangeTest.java @@ -10,8 +10,7 @@ class QuayChangeTest implements RealtimeTestConstants { - private static final TripInput TRIP_INPUT = TripInput - .of(TRIP_1_ID) + private static final TripInput TRIP_INPUT = TripInput.of(TRIP_1_ID) .addStop(STOP_A1, "0:00:10", "0:00:11") .addStop(STOP_B1, "0:00:20", "0:00:21") .build(); diff --git a/application/src/test/java/org/opentripplanner/updater/trip/siri/moduletests/update/UpdatedTimesTest.java b/application/src/test/java/org/opentripplanner/updater/trip/siri/moduletests/update/UpdatedTimesTest.java index b49dd8aee97..21b834e4ff1 100644 --- a/application/src/test/java/org/opentripplanner/updater/trip/siri/moduletests/update/UpdatedTimesTest.java +++ b/application/src/test/java/org/opentripplanner/updater/trip/siri/moduletests/update/UpdatedTimesTest.java @@ -12,8 +12,7 @@ class UpdatedTimesTest implements RealtimeTestConstants { - private static final TripInput TRIP_INPUT = TripInput - .of(TRIP_1_ID) + private static final TripInput TRIP_INPUT = TripInput.of(TRIP_1_ID) .addStop(STOP_A1, "0:00:10", "0:00:11") .addStop(STOP_B1, "0:00:20", "0:00:21") .build(); @@ -68,14 +67,13 @@ void testUpdateJourneyWithoutJourneyRef() { } private static SiriEtBuilder updatedJourneyBuilder(RealtimeTestEnvironment env) { - return new SiriEtBuilder(env.getDateTimeHelper()) - .withEstimatedCalls(builder -> - builder - .call(STOP_A1) - .departAimedExpected("00:00:11", "00:00:15") - .call(STOP_B1) - .arriveAimedExpected("00:00:20", "00:00:25") - ); + return new SiriEtBuilder(env.getDateTimeHelper()).withEstimatedCalls(builder -> + builder + .call(STOP_A1) + .departAimedExpected("00:00:11", "00:00:15") + .call(STOP_B1) + .arriveAimedExpected("00:00:20", "00:00:25") + ); } private static void assertTripUpdated(RealtimeTestEnvironment env) { diff --git a/application/src/test/java/org/opentripplanner/updater/vehicle_parking/VehicleParkingAvailabilityUpdaterTest.java b/application/src/test/java/org/opentripplanner/updater/vehicle_parking/VehicleParkingAvailabilityUpdaterTest.java index ecf7904de4a..4ef0d44b359 100644 --- a/application/src/test/java/org/opentripplanner/updater/vehicle_parking/VehicleParkingAvailabilityUpdaterTest.java +++ b/application/src/test/java/org/opentripplanner/updater/vehicle_parking/VehicleParkingAvailabilityUpdaterTest.java @@ -27,20 +27,21 @@ class VehicleParkingAvailabilityUpdaterTest { - private static final VehicleParkingUpdaterParameters PARAMETERS = VehicleParkingUpdaterConfig.create( - "ref", - newNodeAdapterForTest( - """ - { - "type" : "vehicle-parking", - "feedId" : "parking", - "sourceType" : "siri-fm", - "frequency": "0s", - "url" : "https://transmodel.api.opendatahub.com/siri-lite/fm/parking" - } - """ - ) - ); + private static final VehicleParkingUpdaterParameters PARAMETERS = + VehicleParkingUpdaterConfig.create( + "ref", + newNodeAdapterForTest( + """ + { + "type" : "vehicle-parking", + "feedId" : "parking", + "sourceType" : "siri-fm", + "frequency": "0s", + "url" : "https://transmodel.api.opendatahub.com/siri-lite/fm/parking" + } + """ + ) + ); private static final FeedScopedId ID = id("parking1"); private static final AvailabiltyUpdate DEFAULT_UPDATE = new AvailabiltyUpdate(ID, 8); @@ -108,8 +109,7 @@ private static VehicleParkingRepository buildParkingRepository(VehicleParkingSpa } private static VehicleParking.VehicleParkingBuilder parkingBuilder() { - return VehicleParking - .builder() + return VehicleParking.builder() .id(ID) .name(I18NString.of("parking")) .coordinate(WgsCoordinate.GREENWICH); @@ -120,10 +120,8 @@ class GraphUpdaterMock extends GraphUpdaterManager { private static final Graph GRAPH = new Graph(); private static final TimetableRepository TRANSIT_MODEL = new TimetableRepository(); - public static final DefaultRealTimeUpdateContext REAL_TIME_UPDATE_CONTEXT = new DefaultRealTimeUpdateContext( - GRAPH, - TRANSIT_MODEL - ); + public static final DefaultRealTimeUpdateContext REAL_TIME_UPDATE_CONTEXT = + new DefaultRealTimeUpdateContext(GRAPH, TRANSIT_MODEL); public GraphUpdaterMock(List updaters) { super(REAL_TIME_UPDATE_CONTEXT, updaters); diff --git a/application/src/test/java/org/opentripplanner/updater/vehicle_parking/VehicleParkingUpdaterTest.java b/application/src/test/java/org/opentripplanner/updater/vehicle_parking/VehicleParkingUpdaterTest.java index 261cd55011d..e4da61f6cfa 100644 --- a/application/src/test/java/org/opentripplanner/updater/vehicle_parking/VehicleParkingUpdaterTest.java +++ b/application/src/test/java/org/opentripplanner/updater/vehicle_parking/VehicleParkingUpdaterTest.java @@ -75,8 +75,12 @@ public String configRef() { return null; } }; - vehicleParkingUpdater = - new VehicleParkingUpdater(parameters, dataSource, graph.getLinker(), parkingRepository); + vehicleParkingUpdater = new VehicleParkingUpdater( + parameters, + dataSource, + graph.getLinker(), + parkingRepository + ); } @Test @@ -113,16 +117,20 @@ void updateVehicleParkingTest() { assertEquals(vehiclePlaces, vehicleParkingInGraph.getCapacity()); vehiclePlaces = VehicleParkingSpaces.builder().bicycleSpaces(2).build(); - vehicleParkings = - List.of(VehicleParkingTestUtil.createParkingWithEntrances("1", 0.0001, 0, vehiclePlaces)); + vehicleParkings = List.of( + VehicleParkingTestUtil.createParkingWithEntrances("1", 0.0001, 0, vehiclePlaces) + ); when(dataSource.getUpdates()).thenReturn(vehicleParkings); runUpdaterOnce(); assertVehicleParkingsInGraph(1); - vehicleParkingInGraph = - parkingRepository.listVehicleParkings().stream().findFirst().orElseThrow(); + vehicleParkingInGraph = parkingRepository + .listVehicleParkings() + .stream() + .findFirst() + .orElseThrow(); assertEquals(vehiclePlaces, vehicleParkingInGraph.getAvailability()); assertEquals(vehiclePlaces, vehicleParkingInGraph.getCapacity()); } @@ -149,8 +157,7 @@ void deleteVehicleParkingTest() { @Test void addNotOperatingVehicleParkingTest() { - var vehicleParking = StreetModelForTest - .vehicleParking() + var vehicleParking = StreetModelForTest.vehicleParking() .state(VehicleParkingState.CLOSED) .build(); @@ -165,8 +172,7 @@ void addNotOperatingVehicleParkingTest() { void updateNotOperatingVehicleParkingTest() { var vehiclePlaces = VehicleParkingSpaces.builder().bicycleSpaces(1).build(); - var vehicleParking = StreetModelForTest - .vehicleParking() + var vehicleParking = StreetModelForTest.vehicleParking() .availability(vehiclePlaces) .state(VehicleParkingState.CLOSED) .build(); @@ -183,12 +189,10 @@ void updateNotOperatingVehicleParkingTest() { vehiclePlaces = VehicleParkingSpaces.builder().bicycleSpaces(2).build(); - vehicleParking = - StreetModelForTest - .vehicleParking() - .availability(vehiclePlaces) - .state(VehicleParkingState.CLOSED) - .build(); + vehicleParking = StreetModelForTest.vehicleParking() + .availability(vehiclePlaces) + .state(VehicleParkingState.CLOSED) + .build(); when(dataSource.getUpdates()).thenReturn(List.of(vehicleParking)); runUpdaterOnce(); @@ -203,8 +207,7 @@ void updateNotOperatingVehicleParkingTest() { @Test void deleteNotOperatingVehicleParkingTest() { - var vehicleParking = StreetModelForTest - .vehicleParking() + var vehicleParking = StreetModelForTest.vehicleParking() .state(VehicleParkingState.CLOSED) .build(); diff --git a/application/src/test/java/org/opentripplanner/updater/vehicle_position/RealtimeVehicleMatcherTest.java b/application/src/test/java/org/opentripplanner/updater/vehicle_position/RealtimeVehicleMatcherTest.java index 9cdeba6ec3d..0b21cc0a9e3 100644 --- a/application/src/test/java/org/opentripplanner/updater/vehicle_position/RealtimeVehicleMatcherTest.java +++ b/application/src/test/java/org/opentripplanner/updater/vehicle_position/RealtimeVehicleMatcherTest.java @@ -71,8 +71,7 @@ public void testOccupancy() { @Test @DisplayName("If the vehicle position has no start_date we need to guess the service day") public void inferStartDate() { - var posWithoutServiceDate = VehiclePosition - .newBuilder() + var posWithoutServiceDate = VehiclePosition.newBuilder() .setTrip(TripDescriptor.newBuilder().setTripId(tripId).build()) .setStopId("stop-1") .setPosition( @@ -143,8 +142,7 @@ public void sequenceId() { FEATURES ); - var pos = VehiclePosition - .newBuilder() + var pos = VehiclePosition.newBuilder() .setTrip(TripDescriptor.newBuilder().setTripId(tripId).build()) .setCurrentStopSequence(20) .build(); @@ -162,8 +160,7 @@ public void sequenceId() { @Test void invalidStopSequence() { - var posWithInvalidSequence = VehiclePosition - .newBuilder() + var posWithInvalidSequence = VehiclePosition.newBuilder() .setTrip(TripDescriptor.newBuilder().setTripId(tripId).build()) .setCurrentStopSequence(99) .setPosition( @@ -378,8 +375,7 @@ void inferServiceDateCloseToMidnight() { private static TripPattern tripPattern(Trip trip, List stopTimes) { var stopPattern = new StopPattern(stopTimes); - var pattern = TripPattern - .of(trip.getId()) + var pattern = TripPattern.of(trip.getId()) .withStopPattern(stopPattern) .withRoute(ROUTE) .withScheduledTimeTableBuilder(builder -> @@ -390,8 +386,7 @@ private static TripPattern tripPattern(Trip trip, List stopTimes) { } private static VehiclePosition vehiclePosition(String tripId1) { - return VehiclePosition - .newBuilder() + return VehiclePosition.newBuilder() .setTrip(TripDescriptor.newBuilder().setTripId(tripId1).setStartDate("20220314").build()) .setStopId("stop-1") .setPosition( diff --git a/application/src/test/java/org/opentripplanner/updater/vehicle_rental/datasources/GbfsFeedLoaderTest.java b/application/src/test/java/org/opentripplanner/updater/vehicle_rental/datasources/GbfsFeedLoaderTest.java index 836d1ef3124..f16573a6274 100644 --- a/application/src/test/java/org/opentripplanner/updater/vehicle_rental/datasources/GbfsFeedLoaderTest.java +++ b/application/src/test/java/org/opentripplanner/updater/vehicle_rental/datasources/GbfsFeedLoaderTest.java @@ -66,14 +66,12 @@ void getV22FeedWithNoLanguage() { @Test void getV22FeedWithWrongLanguage() { - assertThrows( - RuntimeException.class, - () -> - new GbfsFeedLoader( - "file:src/test/resources/gbfs/lillestrombysykkel/gbfs.json", - HttpHeaders.empty(), - LANGUAGE_EN - ) + assertThrows(RuntimeException.class, () -> + new GbfsFeedLoader( + "file:src/test/resources/gbfs/lillestrombysykkel/gbfs.json", + HttpHeaders.empty(), + LANGUAGE_EN + ) ); } @@ -129,8 +127,7 @@ void testSpin() { "https://gbfs.spin.pm/api/gbfs/v2_2/edmonton/gbfs", HttpHeaders.empty(), null - ) - .update(); + ).update(); } @Test diff --git a/raptor/src/main/java/org/opentripplanner/raptor/RaptorService.java b/raptor/src/main/java/org/opentripplanner/raptor/RaptorService.java index 599a4104414..ffc8582f4ea 100644 --- a/raptor/src/main/java/org/opentripplanner/raptor/RaptorService.java +++ b/raptor/src/main/java/org/opentripplanner/raptor/RaptorService.java @@ -45,8 +45,12 @@ public RaptorResponse route( RaptorResponse response; if (request.isDynamicSearch()) { - response = - new RangeRaptorDynamicSearch<>(config, transitData, extraMcSearch, request).route(); + response = new RangeRaptorDynamicSearch<>( + config, + transitData, + extraMcSearch, + request + ).route(); } else { response = routeUsingStdWorker(transitData, request); } diff --git a/raptor/src/main/java/org/opentripplanner/raptor/api/debug/DebugEvent.java b/raptor/src/main/java/org/opentripplanner/raptor/api/debug/DebugEvent.java index a69e977efe3..bb003f8881d 100644 --- a/raptor/src/main/java/org/opentripplanner/raptor/api/debug/DebugEvent.java +++ b/raptor/src/main/java/org/opentripplanner/raptor/api/debug/DebugEvent.java @@ -109,8 +109,7 @@ public String reason() { @Override public String toString() { - return ToStringBuilder - .of(DebugEvent.class) + return ToStringBuilder.of(DebugEvent.class) .addEnum("action", action) .addServiceTime("iterationStartTime", iterationStartTime) .addObj("element", element) diff --git a/raptor/src/main/java/org/opentripplanner/raptor/api/request/DebugRequest.java b/raptor/src/main/java/org/opentripplanner/raptor/api/request/DebugRequest.java index 91144d86917..b57c0a9daef 100644 --- a/raptor/src/main/java/org/opentripplanner/raptor/api/request/DebugRequest.java +++ b/raptor/src/main/java/org/opentripplanner/raptor/api/request/DebugRequest.java @@ -84,8 +84,7 @@ public int hashCode() { @Override public String toString() { - return ToStringBuilder - .of(DebugRequest.class) + return ToStringBuilder.of(DebugRequest.class) .addCol("stops", stops) .addCol("path", path) .addNum("startAtStopIndex", debugPathFromStopIndex, 0) diff --git a/raptor/src/main/java/org/opentripplanner/raptor/api/request/MultiCriteriaRequest.java b/raptor/src/main/java/org/opentripplanner/raptor/api/request/MultiCriteriaRequest.java index d0776cd1b00..2716a770de8 100644 --- a/raptor/src/main/java/org/opentripplanner/raptor/api/request/MultiCriteriaRequest.java +++ b/raptor/src/main/java/org/opentripplanner/raptor/api/request/MultiCriteriaRequest.java @@ -104,8 +104,7 @@ public int hashCode() { @Override public String toString() { - return ToStringBuilder - .of(MultiCriteriaRequest.class) + return ToStringBuilder.of(MultiCriteriaRequest.class) .addObj("relaxC1", relaxC1, RelaxFunction.NORMAL) .addObj("transitPriorityCalculator", transitPriorityCalculator) .addNum("relaxCostAtDestination", relaxCostAtDestination) @@ -165,8 +164,7 @@ public MultiCriteriaRequest build() { @Override public String toString() { - return ToStringBuilder - .of(MultiCriteriaRequest.Builder.class) + return ToStringBuilder.of(MultiCriteriaRequest.Builder.class) .addObj("relaxC1", relaxC1) .addObj("transitPriorityCalculator", transitPriorityCalculator) .addNum("relaxCostAtDestination", relaxCostAtDestination) diff --git a/raptor/src/main/java/org/opentripplanner/raptor/api/request/RaptorRequest.java b/raptor/src/main/java/org/opentripplanner/raptor/api/request/RaptorRequest.java index 3c27f5478c8..0da778d7add 100644 --- a/raptor/src/main/java/org/opentripplanner/raptor/api/request/RaptorRequest.java +++ b/raptor/src/main/java/org/opentripplanner/raptor/api/request/RaptorRequest.java @@ -179,8 +179,7 @@ public boolean equals(Object o) { @Override public String toString() { var defaults = RaptorRequest.defaults(); - return ToStringBuilder - .of(RaptorRequest.class) + return ToStringBuilder.of(RaptorRequest.class) .addEnum("profile", profile) .addBoolIfTrue("reverse", searchDirection.isInReverse()) .addCol("optimizations", optimizations, defaults.optimizations()) diff --git a/raptor/src/main/java/org/opentripplanner/raptor/api/request/RaptorViaLocation.java b/raptor/src/main/java/org/opentripplanner/raptor/api/request/RaptorViaLocation.java index 9338d7ee2ae..399c2086458 100644 --- a/raptor/src/main/java/org/opentripplanner/raptor/api/request/RaptorViaLocation.java +++ b/raptor/src/main/java/org/opentripplanner/raptor/api/request/RaptorViaLocation.java @@ -36,13 +36,12 @@ private RaptorViaLocation( ) { this.label = label; this.passThroughSearch = passThroughSearch; - this.minimumWaitTime = - IntUtils.requireInRange( - (int) minimumWaitTime.toSeconds(), - (int) MIN_WAIT_TIME.toSeconds(), - (int) MAX_WAIT_TIME.toSeconds(), - "minimumWaitTime" - ); + this.minimumWaitTime = IntUtils.requireInRange( + (int) minimumWaitTime.toSeconds(), + (int) MIN_WAIT_TIME.toSeconds(), + (int) MAX_WAIT_TIME.toSeconds(), + "minimumWaitTime" + ); this.connections = validateConnections(connections); } diff --git a/raptor/src/main/java/org/opentripplanner/raptor/api/request/SearchParams.java b/raptor/src/main/java/org/opentripplanner/raptor/api/request/SearchParams.java index 9a2dd6104fe..38989ba4a70 100644 --- a/raptor/src/main/java/org/opentripplanner/raptor/api/request/SearchParams.java +++ b/raptor/src/main/java/org/opentripplanner/raptor/api/request/SearchParams.java @@ -259,8 +259,7 @@ public boolean equals(Object o) { @Override public String toString() { var dft = defaults(); - return ToStringBuilder - .of(SearchParams.class) + return ToStringBuilder.of(SearchParams.class) .addServiceTime("earliestDepartureTime", earliestDepartureTime, dft.earliestDepartureTime) .addServiceTime("latestArrivalTime", latestArrivalTime, dft.latestArrivalTime) .addDurationSec("searchWindow", searchWindowInSeconds, dft.searchWindowInSeconds) diff --git a/raptor/src/main/java/org/opentripplanner/raptor/api/request/SearchParamsBuilder.java b/raptor/src/main/java/org/opentripplanner/raptor/api/request/SearchParamsBuilder.java index cdb7146e814..642153e316d 100644 --- a/raptor/src/main/java/org/opentripplanner/raptor/api/request/SearchParamsBuilder.java +++ b/raptor/src/main/java/org/opentripplanner/raptor/api/request/SearchParamsBuilder.java @@ -188,8 +188,7 @@ public SearchParams buildSearchParam() { @Override public String toString() { - return ToStringBuilder - .of(SearchParams.class) + return ToStringBuilder.of(SearchParams.class) .addServiceTime("earliestDepartureTime", earliestDepartureTime, RaptorConstants.TIME_NOT_SET) .addServiceTime("latestArrivalTime", latestArrivalTime, RaptorConstants.TIME_NOT_SET) .addDurationSec("searchWindow", searchWindowInSeconds) diff --git a/raptor/src/main/java/org/opentripplanner/raptor/api/response/RaptorResponse.java b/raptor/src/main/java/org/opentripplanner/raptor/api/response/RaptorResponse.java index 5b0f1885a85..742bfacd965 100644 --- a/raptor/src/main/java/org/opentripplanner/raptor/api/response/RaptorResponse.java +++ b/raptor/src/main/java/org/opentripplanner/raptor/api/response/RaptorResponse.java @@ -73,8 +73,7 @@ public boolean noConnectionFound() { @Override public String toString() { - return ToStringBuilder - .of(RaptorResponse.class) + return ToStringBuilder.of(RaptorResponse.class) .addObj("paths", paths) .addObj("requestUsed", requestUsed) .toString(); diff --git a/raptor/src/main/java/org/opentripplanner/raptor/configure/RaptorConfig.java b/raptor/src/main/java/org/opentripplanner/raptor/configure/RaptorConfig.java index 282e1b43015..16fcf7ae171 100644 --- a/raptor/src/main/java/org/opentripplanner/raptor/configure/RaptorConfig.java +++ b/raptor/src/main/java/org/opentripplanner/raptor/configure/RaptorConfig.java @@ -106,8 +106,10 @@ private RaptorRouter createRangeRaptorWithMcWorker( if (request.searchParams().isVisitViaSearch()) { for (SearchContextViaLeg cxLeg : context.legs().reversed()) { - var c = new McRangeRaptorConfig<>(cxLeg, passThroughPointsService) - .connectWithNextLegArrivals(nextStopArrivals); + var c = new McRangeRaptorConfig<>( + cxLeg, + passThroughPointsService + ).connectWithNextLegArrivals(nextStopArrivals); var w = createWorker(cxLeg, c.state(), c.strategy()); worker = RangeRaptorWorkerComposite.of(w, worker); nextStopArrivals = c.stopArrivals(); diff --git a/raptor/src/main/java/org/opentripplanner/raptor/path/Path.java b/raptor/src/main/java/org/opentripplanner/raptor/path/Path.java index 99f226df0ef..68475285de8 100644 --- a/raptor/src/main/java/org/opentripplanner/raptor/path/Path.java +++ b/raptor/src/main/java/org/opentripplanner/raptor/path/Path.java @@ -68,16 +68,18 @@ public Path(int iterationDepartureTime, AccessPathLeg accessLeg, int c1, int this.iterationDepartureTime = iterationDepartureTime; this.startTime = accessLeg.fromTime(); var access = accessLeg.access(); - this.startTimeInclusivePenalty = - access.hasTimePenalty() ? startTime - access.timePenalty() : startTime; + this.startTimeInclusivePenalty = access.hasTimePenalty() + ? startTime - access.timePenalty() + : startTime; this.c1 = c1; this.accessLeg = accessLeg; this.egressLeg = findEgressLeg(accessLeg); this.numberOfTransfers = countNumberOfTransfers(accessLeg, egressLeg); this.endTime = egressLeg.toTime(); var egress = egressLeg.egress(); - this.endTimeInclusivePenalty = - egress.hasTimePenalty() ? endTime + egress.timePenalty() : endTime; + this.endTimeInclusivePenalty = egress.hasTimePenalty() + ? endTime + egress.timePenalty() + : endTime; this.c2 = c2; } @@ -267,8 +269,9 @@ protected String buildString( buf.c1(leg.c1()); } if (transitLeg.getConstrainedTransferAfterLeg() != null) { - constraintPrevLeg = - transitLeg.getConstrainedTransferAfterLeg().getTransferConstraint(); + constraintPrevLeg = transitLeg + .getConstrainedTransferAfterLeg() + .getTransferConstraint(); } } else if (leg.isTransferLeg()) { buf.walk(leg.duration()); diff --git a/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/CompositeResult.java b/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/CompositeResult.java index e72c4731cc5..f3396aa5ce5 100644 --- a/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/CompositeResult.java +++ b/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/CompositeResult.java @@ -24,7 +24,11 @@ class CompositeResult implements RaptorRouterResul CompositeResult( RaptorRouterResult mainResult, RaptorRouterResult alternativeResult, - BiFunction>, Collection>, Collection>> merger + BiFunction< + Collection>, + Collection>, + Collection> + > merger ) { this.result = merger.apply(mainResult.extractPaths(), alternativeResult.extractPaths()); } diff --git a/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/ConcurrentCompositeRaptorRouter.java b/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/ConcurrentCompositeRaptorRouter.java index 1a16c6f0527..bbb709c7d2d 100644 --- a/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/ConcurrentCompositeRaptorRouter.java +++ b/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/ConcurrentCompositeRaptorRouter.java @@ -21,7 +21,11 @@ public class ConcurrentCompositeRaptorRouter private final RaptorRouter mainWorker; private final RaptorRouter alternativeWorker; - private final BiFunction>, Collection>, Collection>> merger; + private final BiFunction< + Collection>, + Collection>, + Collection> + > merger; @Nullable private final ExecutorService executorService; @@ -32,7 +36,11 @@ public class ConcurrentCompositeRaptorRouter public ConcurrentCompositeRaptorRouter( RaptorRouter mainWorker, RaptorRouter alternativeWorker, - BiFunction>, Collection>, Collection>> merger, + BiFunction< + Collection>, + Collection>, + Collection> + > merger, @Nullable ExecutorService executorService, @Nullable Function mapInterruptedException ) { diff --git a/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/SystemErrDebugLogger.java b/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/SystemErrDebugLogger.java index c80d226afc7..a72e8826d13 100644 --- a/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/SystemErrDebugLogger.java +++ b/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/SystemErrDebugLogger.java @@ -40,14 +40,12 @@ public class SystemErrDebugLogger implements DebugLogger { private final boolean enableDebugLogging; private final boolean eventLoggingDryRun; private final NumberFormat numFormat = NumberFormat.getInstance(Locale.FRANCE); - private final Table arrivalTable = Table - .of() + private final Table arrivalTable = Table.of() .withAlights(Center, Center, Right, Right, Right, Right, Left, Left) .withHeaders("ARRIVAL", "LEG", "RND", "STOP", "ARRIVE", "C₁", "TRIP", "DETAILS") .withMinWidths(9, 7, 3, 5, 8, 9, 24, 0) .build(); - private final Table pathTable = Table - .of() + private final Table pathTable = Table.of() .withAlights(Center, Center, Right, Right, Right, Right, Right, Right, Left) .withHeaders(">>> PATH", "TR", "FROM", "TO", "START", "END", "DURATION", "C₁", "DETAILS") .withMinWidths(9, 2, 5, 5, 8, 8, 8, 9, 0) diff --git a/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/context/SearchContext.java b/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/context/SearchContext.java index e197bad8461..359e2785faf 100644 --- a/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/context/SearchContext.java +++ b/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/context/SearchContext.java @@ -89,12 +89,11 @@ public class SearchContext { this.transitData = transitData; this.calculator = createCalculator(request, tuningParameters); - this.roundTracker = - new RoundTracker( - nRounds(), - request.searchParams().numberOfAdditionalTransfers(), - lifeCycle() - ); + this.roundTracker = new RoundTracker( + nRounds(), + request.searchParams().numberOfAdditionalTransfers(), + lifeCycle() + ); this.debugFactory = new DebugHandlerFactory<>(debugRequest(request), lifeCycle()); this.acceptC2AtDestination = acceptC2AtDestination; this.legs = initLegs(accessPaths, viaConnections, egressPaths); diff --git a/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/debug/DebugHandlerFactory.java b/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/debug/DebugHandlerFactory.java index b44519252a9..15148e59f3e 100644 --- a/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/debug/DebugHandlerFactory.java +++ b/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/debug/DebugHandlerFactory.java @@ -29,20 +29,17 @@ public class DebugHandlerFactory { private final DebugLogger logger; public DebugHandlerFactory(DebugRequest request, WorkerLifeCycle lifeCycle) { - this.stopHandler = - isDebug(request.stopArrivalListener()) - ? new DebugHandlerStopArrivalAdapter(request, lifeCycle) - : null; - - this.pathHandler = - isDebug(request.pathFilteringListener()) - ? new DebugHandlerPathAdapter(request, lifeCycle) - : null; - - this.patternRideHandler = - isDebug(request.patternRideDebugListener()) - ? new DebugHandlerPatternRideAdapter(request, lifeCycle) - : null; + this.stopHandler = isDebug(request.stopArrivalListener()) + ? new DebugHandlerStopArrivalAdapter(request, lifeCycle) + : null; + + this.pathHandler = isDebug(request.pathFilteringListener()) + ? new DebugHandlerPathAdapter(request, lifeCycle) + : null; + + this.patternRideHandler = isDebug(request.patternRideDebugListener()) + ? new DebugHandlerPatternRideAdapter(request, lifeCycle) + : null; this.logger = request.logger(); lifeCycle.onRouteSearch(logger::setSearchDirection); diff --git a/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/internalapi/HeuristicAtStop.java b/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/internalapi/HeuristicAtStop.java index da07c643fb6..b1058345dd5 100644 --- a/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/internalapi/HeuristicAtStop.java +++ b/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/internalapi/HeuristicAtStop.java @@ -21,12 +21,10 @@ public record HeuristicAtStop(int minTravelDuration, int minNumTransfers, int mi public String toString() { return this == UNREACHED ? "[]" - : ( - "[" + + : ("[" + (DurationUtils.durationToStr(minTravelDuration) + " ") + (minNumTransfers + "tx ") + OtpNumberFormat.formatCostCenti(minCost) + - "]" - ); + "]"); } } diff --git a/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/lifecycle/LifeCycleEventPublisher.java b/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/lifecycle/LifeCycleEventPublisher.java index 4c5c77a5288..5a7c8afa2ff 100644 --- a/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/lifecycle/LifeCycleEventPublisher.java +++ b/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/lifecycle/LifeCycleEventPublisher.java @@ -20,17 +20,20 @@ public class LifeCycleEventPublisher { @SuppressWarnings("unchecked") public LifeCycleEventPublisher(LifeCycleSubscriptions subscriptions) { this.onRouteSearchListeners = subscriptions.onRouteSearchListeners.toArray(Consumer[]::new); - this.setupIterationListeners = - subscriptions.setupIterationListeners.toArray(IntConsumer[]::new); - this.prepareForNextRoundListeners = - subscriptions.prepareForNextRoundListeners.toArray(IntConsumer[]::new); + this.setupIterationListeners = subscriptions.setupIterationListeners.toArray( + IntConsumer[]::new + ); + this.prepareForNextRoundListeners = subscriptions.prepareForNextRoundListeners.toArray( + IntConsumer[]::new + ); this.transitsForRoundCompleteListeners = subscriptions.transitsForRoundCompleteListeners.toArray(Runnable[]::new); this.transfersForRoundCompleteListeners = subscriptions.transfersForRoundCompleteListeners.toArray(Runnable[]::new); this.roundCompleteListeners = subscriptions.roundCompleteListeners.toArray(Consumer[]::new); - this.iterationCompleteListeners = - subscriptions.iterationCompleteListeners.toArray(Runnable[]::new); + this.iterationCompleteListeners = subscriptions.iterationCompleteListeners.toArray( + Runnable[]::new + ); subscriptions.close(); } diff --git a/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/multicriteria/McStopArrivals.java b/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/multicriteria/McStopArrivals.java index 4728f96e03b..72c598e007a 100644 --- a/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/multicriteria/McStopArrivals.java +++ b/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/multicriteria/McStopArrivals.java @@ -140,11 +140,9 @@ void clearTouchedStopsAndSetStopMarkers() { private StopArrivalParetoSet findOrCreateSet(final int stop) { if (arrivals[stop] == null) { - arrivals[stop] = - StopArrivalParetoSet - .of(comparator) - .withDebugListener(debugHandlerFactory.paretoSetStopArrivalListener(stop)) - .build(); + arrivals[stop] = StopArrivalParetoSet.of(comparator) + .withDebugListener(debugHandlerFactory.paretoSetStopArrivalListener(stop)) + .build(); } return arrivals[stop]; } @@ -154,12 +152,10 @@ private void initViaConnections( ) { for (ViaConnectionStopArrivalEventListener it : viaConnectionListeners) { int stop = it.fromStop(); - this.arrivals[stop] = - StopArrivalParetoSet - .of(comparator) - .withDebugListener(debugHandlerFactory.paretoSetStopArrivalListener(stop)) - .withNextLegListener(it) - .build(); + this.arrivals[stop] = StopArrivalParetoSet.of(comparator) + .withDebugListener(debugHandlerFactory.paretoSetStopArrivalListener(stop)) + .withNextLegListener(it) + .build(); } } @@ -179,12 +175,10 @@ private void initEgressStopAndGlueItToDestinationArrivals( .byStop() .forEachEntry((stop, list) -> { // The factory is creating the actual "glue" - this.arrivals[stop] = - StopArrivalParetoSet - .of(comparator) - .withDebugListener(debugHandlerFactory.paretoSetStopArrivalListener(stop)) - .withEgressListener(list, paths) - .build(); + this.arrivals[stop] = StopArrivalParetoSet.of(comparator) + .withDebugListener(debugHandlerFactory.paretoSetStopArrivalListener(stop)) + .withEgressListener(list, paths) + .build(); return true; }); } diff --git a/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/multicriteria/MultiCriteriaRoutingStrategy.java b/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/multicriteria/MultiCriteriaRoutingStrategy.java index b17b3078fc9..c5abc59f3f1 100644 --- a/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/multicriteria/MultiCriteriaRoutingStrategy.java +++ b/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/multicriteria/MultiCriteriaRoutingStrategy.java @@ -74,9 +74,8 @@ public void prepareForNextStop(int stopIndex, int stopPos) { // the stop is a pass-through point and the path has visited the pass-through points in the // correct order. //noinspection unchecked - passThroughPointsService.updateC2Value( - ride.c2(), - newC2 -> patternRides.add((R) ride.updateC2(newC2)) + passThroughPointsService.updateC2Value(ride.c2(), newC2 -> + patternRides.add((R) ride.updateC2(newC2)) ); } } diff --git a/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/multicriteria/ViaConnectionStopArrivalEventListener.java b/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/multicriteria/ViaConnectionStopArrivalEventListener.java index f0b7e708923..03a371bb720 100644 --- a/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/multicriteria/ViaConnectionStopArrivalEventListener.java +++ b/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/multicriteria/ViaConnectionStopArrivalEventListener.java @@ -56,9 +56,9 @@ private ViaConnectionStopArrivalEventListener( * Factory method for creating a {@link org.opentripplanner.raptor.util.paretoset.ParetoSet} * listener used to copy the state when arriving at a "via point" into the next Raptor "leg". */ - public static < - T extends RaptorTripSchedule - > List> createEventListeners( + public static List< + ViaConnectionStopArrivalEventListener + > createEventListeners( @Nullable ViaConnections viaConnections, McStopArrivalFactory stopArrivalFactory, McStopArrivals nextLegStopArrivals, diff --git a/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/multicriteria/arrivals/ArrivalParetoSetComparatorFactory.java b/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/multicriteria/arrivals/ArrivalParetoSetComparatorFactory.java index 68e103b18db..8d415f7b929 100644 --- a/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/multicriteria/arrivals/ArrivalParetoSetComparatorFactory.java +++ b/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/multicriteria/arrivals/ArrivalParetoSetComparatorFactory.java @@ -37,9 +37,9 @@ static > ArrivalParetoSetComparatorFactory factory : createFactoryRelaxC2(relaxC1, c2DominanceFunction); } - private static < - T extends McStopArrival - > ArrivalParetoSetComparatorFactory createFactoryC1() { + private static > ArrivalParetoSetComparatorFactory< + T + > createFactoryC1() { return new ArrivalParetoSetComparatorFactory() { @Override public ParetoComparator compareArrivalTimeRoundAndCost() { @@ -54,11 +54,9 @@ public ParetoComparator compareArrivalTimeRoundCostAndOnBoardArrival() { }; } - private static < - T extends McStopArrival - > ArrivalParetoSetComparatorFactory createFactoryC1AndC2( - DominanceFunction c2DominanceFunction - ) { + private static > ArrivalParetoSetComparatorFactory< + T + > createFactoryC1AndC2(DominanceFunction c2DominanceFunction) { return new ArrivalParetoSetComparatorFactory() { @Override public ParetoComparator compareArrivalTimeRoundAndCost() { @@ -78,9 +76,9 @@ public ParetoComparator compareArrivalTimeRoundCostAndOnBoardArrival() { }; } - private static < - T extends McStopArrival - > ArrivalParetoSetComparatorFactory createFactoryRelaxC1(RelaxFunction rc1) { + private static > ArrivalParetoSetComparatorFactory< + T + > createFactoryRelaxC1(RelaxFunction rc1) { return new ArrivalParetoSetComparatorFactory<>() { @Override public ParetoComparator compareArrivalTimeRoundAndCost() { @@ -95,12 +93,9 @@ public ParetoComparator compareArrivalTimeRoundCostAndOnBoardArrival() { }; } - private static < - T extends McStopArrival - > ArrivalParetoSetComparatorFactory createFactoryRelaxC2( - RelaxFunction relaxC1, - DominanceFunction c2DominanceFunction - ) { + private static > ArrivalParetoSetComparatorFactory< + T + > createFactoryRelaxC2(RelaxFunction relaxC1, DominanceFunction c2DominanceFunction) { return new ArrivalParetoSetComparatorFactory<>() { @Override public ParetoComparator compareArrivalTimeRoundAndCost() { @@ -114,11 +109,9 @@ public ParetoComparator compareArrivalTimeRoundAndCost() { @Override public ParetoComparator compareArrivalTimeRoundCostAndOnBoardArrival() { return (l, r) -> - ( - c2DominanceFunction.leftDominateRight(l.c2(), r.c2()) + (c2DominanceFunction.leftDominateRight(l.c2(), r.c2()) ? McStopArrival.relaxedCompareBase(relaxC1, l, r) - : McStopArrival.compareBase(l, r) - ) || + : McStopArrival.compareBase(l, r)) || McStopArrival.compareArrivedOnBoard(l, r); } }; diff --git a/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/multicriteria/configure/McRangeRaptorConfig.java b/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/multicriteria/configure/McRangeRaptorConfig.java index 522fc56a632..a1ec287c6ae 100644 --- a/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/multicriteria/configure/McRangeRaptorConfig.java +++ b/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/multicriteria/configure/McRangeRaptorConfig.java @@ -113,15 +113,14 @@ public RaptorWorkerState state() { */ public McStopArrivals stopArrivals() { if (arrivals == null) { - this.arrivals = - new McStopArrivals<>( - context().nStops(), - contextLeg.egressPaths(), - createViaConnectionListeners(), - createDestinationArrivalPaths(), - createFactoryParetoComparator(), - context().debugFactory() - ); + this.arrivals = new McStopArrivals<>( + context().nStops(), + contextLeg.egressPaths(), + createViaConnectionListeners(), + createDestinationArrivalPaths(), + createFactoryParetoComparator(), + context().debugFactory() + ); } return arrivals; } @@ -160,24 +159,24 @@ private > RoutingStrategy createTransitWorkerStrateg private McRangeRaptorWorkerState createState(Heuristics heuristics) { if (state == null) { - state = - new McRangeRaptorWorkerState<>( - stopArrivals(), - createDestinationArrivalPaths(), - createHeuristicsProvider(heuristics), - createStopArrivalFactory(), - context().costCalculator(), - context().calculator(), - context().lifeCycle() - ); + state = new McRangeRaptorWorkerState<>( + stopArrivals(), + createDestinationArrivalPaths(), + createHeuristicsProvider(heuristics), + createStopArrivalFactory(), + context().costCalculator(), + context().calculator(), + context().lifeCycle() + ); } return state; } private McStopArrivalFactory createStopArrivalFactory() { if (stopArrivalFactory == null) { - this.stopArrivalFactory = - includeC2() ? new StopArrivalFactoryC2<>() : new StopArrivalFactoryC1<>(); + this.stopArrivalFactory = includeC2() + ? new StopArrivalFactoryC2<>() + : new StopArrivalFactoryC1<>(); } return stopArrivalFactory; } diff --git a/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/multicriteria/ride/c1/PatternRideC1.java b/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/multicriteria/ride/c1/PatternRideC1.java index fd669e40ffc..3d7ae8cd768 100644 --- a/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/multicriteria/ride/c1/PatternRideC1.java +++ b/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/multicriteria/ride/c1/PatternRideC1.java @@ -74,9 +74,9 @@ public PatternRideC1 createPatternRide( * *

*/ - public static < - T extends RaptorTripSchedule - > ParetoComparator> paretoComparatorRelativeCost() { + public static ParetoComparator< + PatternRideC1 + > paretoComparatorRelativeCost() { return (l, r) -> l.tripSortIndex != r.tripSortIndex || l.relativeC1 < r.relativeC1; } @@ -87,8 +87,7 @@ public int c2() { @Override public String toString() { - return ToStringBuilder - .of(PatternRideC1.class) + return ToStringBuilder.of(PatternRideC1.class) .addNum("prevArrival", prevArrival.stop()) .addNum("boardStop", boardStopIndex) .addNum("boardPos", boardPos) diff --git a/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/multicriteria/ride/c2/PatternRideC2.java b/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/multicriteria/ride/c2/PatternRideC2.java index a23999f1813..d616703f8c5 100644 --- a/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/multicriteria/ride/c2/PatternRideC2.java +++ b/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/multicriteria/ride/c2/PatternRideC2.java @@ -46,11 +46,9 @@ public record PatternRideC2( * *

*/ - public static < - T extends RaptorTripSchedule - > ParetoComparator> paretoComparatorRelativeCost( - DominanceFunction dominanceFunctionC2 - ) { + public static ParetoComparator< + PatternRideC2 + > paretoComparatorRelativeCost(DominanceFunction dominanceFunctionC2) { return (l, r) -> l.tripSortIndex != r.tripSortIndex || l.relativeC1 < r.relativeC1 || @@ -59,8 +57,7 @@ > ParetoComparator> paretoComparatorRelativeCost( @Override public String toString() { - return ToStringBuilder - .of(PatternRideC2.class) + return ToStringBuilder.of(PatternRideC2.class) .addNum("prevArrival", prevArrival.stop()) .addNum("boardStop", boardStopIndex) .addNum("boardPos", boardPos) diff --git a/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/path/DestinationArrivalPaths.java b/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/path/DestinationArrivalPaths.java index 2f257e52645..e1db52abe54 100644 --- a/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/path/DestinationArrivalPaths.java +++ b/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/path/DestinationArrivalPaths.java @@ -71,8 +71,10 @@ public DestinationArrivalPaths( RaptorStopNameResolver stopNameResolver, WorkerLifeCycle lifeCycle ) { - this.paths = - new ParetoSet<>(paretoComparator, debugHandlerFactory.paretoSetDebugPathListener()); + this.paths = new ParetoSet<>( + paretoComparator, + debugHandlerFactory.paretoSetDebugPathListener() + ); this.transitCalculator = transitCalculator; this.costCalculator = costCalculator; this.slackProvider = slackProvider; diff --git a/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/path/PathParetoSetComparators.java b/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/path/PathParetoSetComparators.java index 22212517ce1..cfeb72516ae 100644 --- a/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/path/PathParetoSetComparators.java +++ b/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/path/PathParetoSetComparators.java @@ -93,30 +93,30 @@ public static ParetoComparator> par }; } - private static < - T extends RaptorTripSchedule - > ParetoComparator> comparatorStandardArrivalTime() { + private static ParetoComparator< + RaptorPath + > comparatorStandardArrivalTime() { return (l, r) -> compareArrivalTime(l, r) || compareNumberOfTransfers(l, r); } - private static < - T extends RaptorTripSchedule - > ParetoComparator> comparatorStandardDepartureTime() { + private static ParetoComparator< + RaptorPath + > comparatorStandardDepartureTime() { return (l, r) -> compareDepartureTime(l, r) || compareNumberOfTransfers(l, r); } - private static < - T extends RaptorTripSchedule - > ParetoComparator> comparatorTimetable() { + private static ParetoComparator< + RaptorPath + > comparatorTimetable() { return (l, r) -> compareIterationDepartureTime(l, r) || compareArrivalTime(l, r) || compareNumberOfTransfers(l, r); } - private static < - T extends RaptorTripSchedule - > ParetoComparator> comparatorTimetableAndC1() { + private static ParetoComparator< + RaptorPath + > comparatorTimetableAndC1() { return (l, r) -> compareIterationDepartureTime(l, r) || compareArrivalTime(l, r) || @@ -125,9 +125,9 @@ > ParetoComparator> comparatorTimetableAndC1() { compareC1(l, r); } - private static < - T extends RaptorTripSchedule - > ParetoComparator> comparatorTimetableAndRelaxedC1(final RelaxFunction relaxCost) { + private static ParetoComparator< + RaptorPath + > comparatorTimetableAndRelaxedC1(final RelaxFunction relaxCost) { return (l, r) -> compareIterationDepartureTime(l, r) || compareArrivalTime(l, r) || @@ -136,9 +136,9 @@ > ParetoComparator> comparatorTimetableAndRelaxedC1(final RelaxFun compareC1(relaxCost, l, r); } - private static < - T extends RaptorTripSchedule - > ParetoComparator> comparatorArrivalTimeAndC1() { + private static ParetoComparator< + RaptorPath + > comparatorArrivalTimeAndC1() { return (l, r) -> compareArrivalTime(l, r) || compareNumberOfTransfers(l, r) || @@ -146,9 +146,9 @@ > ParetoComparator> comparatorArrivalTimeAndC1() { compareC1(l, r); } - private static < - T extends RaptorTripSchedule - > ParetoComparator> comparatorDepartureTimeAndC1() { + private static ParetoComparator< + RaptorPath + > comparatorDepartureTimeAndC1() { return (l, r) -> compareDepartureTime(l, r) || compareNumberOfTransfers(l, r) || @@ -156,9 +156,9 @@ > ParetoComparator> comparatorDepartureTimeAndC1() { compareC1(l, r); } - private static < - T extends RaptorTripSchedule - > ParetoComparator> comparatorArrivalTimeAndRelaxedC1(RelaxFunction relaxCost) { + private static ParetoComparator< + RaptorPath + > comparatorArrivalTimeAndRelaxedC1(RelaxFunction relaxCost) { return (l, r) -> compareArrivalTime(l, r) || compareNumberOfTransfers(l, r) || @@ -166,9 +166,9 @@ > ParetoComparator> comparatorArrivalTimeAndRelaxedC1(RelaxFunctio compareC1(relaxCost, l, r); } - private static < - T extends RaptorTripSchedule - > ParetoComparator> comparatorDepartureTimeAndRelaxedC1(RelaxFunction relaxCost) { + private static ParetoComparator< + RaptorPath + > comparatorDepartureTimeAndRelaxedC1(RelaxFunction relaxCost) { return (l, r) -> compareDepartureTime(l, r) || compareNumberOfTransfers(l, r) || @@ -176,9 +176,9 @@ > ParetoComparator> comparatorDepartureTimeAndRelaxedC1(RelaxFunct compareC1(relaxCost, l, r); } - private static < - T extends RaptorTripSchedule - > ParetoComparator> comparatorTimetableAndC1AndC2(DominanceFunction c2Comp) { + private static ParetoComparator< + RaptorPath + > comparatorTimetableAndC1AndC2(DominanceFunction c2Comp) { return (l, r) -> compareIterationDepartureTime(l, r) || compareArrivalTime(l, r) || @@ -188,9 +188,9 @@ > ParetoComparator> comparatorTimetableAndC1AndC2(DominanceFunctio c2Comp.leftDominateRight(l.c2(), r.c2()); } - private static < - T extends RaptorTripSchedule - > ParetoComparator> comparatorTimetableAndRelaxedC1IfC2IsOptimal( + private static ParetoComparator< + RaptorPath + > comparatorTimetableAndRelaxedC1IfC2IsOptimal( RelaxFunction relaxCost, DominanceFunction c2Comp ) { @@ -202,9 +202,9 @@ > ParetoComparator> comparatorTimetableAndRelaxedC1IfC2IsOptimal( compareC1RelaxedIfC2IsOptimal(l, r, relaxCost, c2Comp); } - private static < - T extends RaptorTripSchedule - > ParetoComparator> comparatorWithC1AndC2(DominanceFunction c2Comp) { + private static ParetoComparator< + RaptorPath + > comparatorWithC1AndC2(DominanceFunction c2Comp) { return (l, r) -> compareArrivalTime(l, r) || compareNumberOfTransfers(l, r) || @@ -213,9 +213,9 @@ > ParetoComparator> comparatorWithC1AndC2(DominanceFunction c2Comp c2Comp.leftDominateRight(l.c2(), r.c2()); } - private static < - T extends RaptorTripSchedule - > ParetoComparator> comparatorDepartureTimeAndC1AndC2(DominanceFunction c2Comp) { + private static ParetoComparator< + RaptorPath + > comparatorDepartureTimeAndC1AndC2(DominanceFunction c2Comp) { return (l, r) -> compareDepartureTime(l, r) || compareNumberOfTransfers(l, r) || @@ -224,9 +224,9 @@ > ParetoComparator> comparatorDepartureTimeAndC1AndC2(DominanceFun c2Comp.leftDominateRight(l.c2(), r.c2()); } - private static < - T extends RaptorTripSchedule - > ParetoComparator> comparatorArrivalTimeAndRelaxedC1IfC2IsOptimal( + private static ParetoComparator< + RaptorPath + > comparatorArrivalTimeAndRelaxedC1IfC2IsOptimal( RelaxFunction relaxCost, DominanceFunction c2Comp ) { @@ -237,9 +237,9 @@ > ParetoComparator> comparatorArrivalTimeAndRelaxedC1IfC2IsOptimal compareC1RelaxedIfC2IsOptimal(l, r, relaxCost, c2Comp); } - private static < - T extends RaptorTripSchedule - > ParetoComparator> comparatorDepartureTimeAndRelaxedC1IfC2IsOptimal( + private static ParetoComparator< + RaptorPath + > comparatorDepartureTimeAndRelaxedC1IfC2IsOptimal( RelaxFunction relaxCost, DominanceFunction c2Comp ) { diff --git a/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/standard/besttimes/BestTimes.java b/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/standard/besttimes/BestTimes.java index 296325e9022..7dea3b025dc 100644 --- a/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/standard/besttimes/BestTimes.java +++ b/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/standard/besttimes/BestTimes.java @@ -143,8 +143,7 @@ public SingleCriteriaStopArrivals extractBestTransitArrivals() { @Override public String toString() { final int unreachedTime = calculator.unreachedTime(); - return ToStringBuilder - .of(BestTimes.class) + return ToStringBuilder.of(BestTimes.class) .addIntArraySize("times", times, unreachedTime) .addIntArraySize("transitArrivalTimes", transitArrivalTimes, unreachedTime) .addBitSetSize("reachedCurrentRound", reachedCurrentRound) diff --git a/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/standard/configure/StdRangeRaptorConfig.java b/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/standard/configure/StdRangeRaptorConfig.java index f5f689c68c4..ceede999bc5 100644 --- a/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/standard/configure/StdRangeRaptorConfig.java +++ b/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/standard/configure/StdRangeRaptorConfig.java @@ -106,17 +106,16 @@ private RoutingStrategy createWorkerStrategy() { private StdRangeRaptorWorkerState resolveState() { if (state == null) { - this.state = - oneOf( - new StdRangeRaptorWorkerState<>( - ctx.calculator(), - resolveBestTimes(), - createStopArrivals(), - resolveBestNumberOfTransfers(), - resolveArrivedAtDestinationCheck() - ), - StdWorkerState.class - ); + this.state = oneOf( + new StdRangeRaptorWorkerState<>( + ctx.calculator(), + resolveBestTimes(), + createStopArrivals(), + resolveBestNumberOfTransfers(), + resolveArrivedAtDestinationCheck() + ), + StdWorkerState.class + ); } return (StdRangeRaptorWorkerState) state; } @@ -218,13 +217,12 @@ private StopsCursor stopsCursor() { private StdStopArrivals resolveStopArrivals() { if (stopArrivals == null) { - this.stopArrivals = - withBestNumberOfTransfers( - oneOf( - new StdStopArrivals(ctx.nRounds(), ctx.nStops(), ctx.lifeCycle()), - StdStopArrivals.class - ) - ); + this.stopArrivals = withBestNumberOfTransfers( + oneOf( + new StdStopArrivals(ctx.nRounds(), ctx.nStops(), ctx.lifeCycle()), + StdStopArrivals.class + ) + ); } return stopArrivals; } diff --git a/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/standard/debug/DebugStopArrivalsState.java b/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/standard/debug/DebugStopArrivalsState.java index 2e0f3277a2a..ed75218d7c5 100644 --- a/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/standard/debug/DebugStopArrivalsState.java +++ b/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/standard/debug/DebugStopArrivalsState.java @@ -63,11 +63,8 @@ public void setNewBestTransitTime( int boardTime, boolean newBestOverall ) { - debug.dropOldStateAndAcceptNewOnBoardArrival( - stop, - newBestOverall, - () -> - delegate.setNewBestTransitTime(stop, alightTime, trip, boardStop, boardTime, newBestOverall) + debug.dropOldStateAndAcceptNewOnBoardArrival(stop, newBestOverall, () -> + delegate.setNewBestTransitTime(stop, alightTime, trip, boardStop, boardTime, newBestOverall) ); } @@ -85,9 +82,8 @@ public void rejectNewBestTransitTime( @Override public void setNewBestTransferTime(int fromStop, int arrivalTime, RaptorTransfer transfer) { - debug.dropOldStateAndAcceptNewOnStreetArrival( - transfer.stop(), - () -> delegate.setNewBestTransferTime(fromStop, arrivalTime, transfer) + debug.dropOldStateAndAcceptNewOnStreetArrival(transfer.stop(), () -> + delegate.setNewBestTransferTime(fromStop, arrivalTime, transfer) ); } diff --git a/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/standard/heuristics/HeuristicsAdapter.java b/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/standard/heuristics/HeuristicsAdapter.java index 00cce39622d..8dd706dc683 100644 --- a/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/standard/heuristics/HeuristicsAdapter.java +++ b/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/standard/heuristics/HeuristicsAdapter.java @@ -48,15 +48,14 @@ public HeuristicsAdapter( this.bestOverallTimes = bestOverallTimes; this.bestNumOfTransfers = bestNTransfers; this.originDepartureTime = calculator.minIterationDepartureTime(); - this.aggregatedResults = - AggregatedResults.create( - calculator, - originDepartureTime, - bestOverallTimes, - bestTransitTimes, - bestNTransfers, - this.egressPaths - ); + this.aggregatedResults = AggregatedResults.create( + calculator, + originDepartureTime, + bestOverallTimes, + bestTransitTimes, + bestNTransfers, + this.egressPaths + ); } @Override @@ -110,16 +109,15 @@ public int minWaitTimeForJourneysReachingDestination() { @Override public String toString() { - return ToStringBuilder - .of(Heuristics.class) + return ToStringBuilder.of(Heuristics.class) .addServiceTime("originDepartureTime(last iteration)", originDepartureTime) .addObj("aggregatedResults", aggregatedResults) .addCol( "egress stops reached", - Arrays - .stream(egressPaths.keys()) + Arrays.stream(egressPaths.keys()) .filter(bestOverallTimes::isReached) - .mapToObj(s -> "[" + s + " " + TimeUtils.timeToStrCompact(bestOverallTimes.value(s)) + "]" + .mapToObj( + s -> "[" + s + " " + TimeUtils.timeToStrCompact(bestOverallTimes.value(s)) + "]" ) .limit(20) .toList() diff --git a/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/standard/stoparrivals/EgressStopArrivalState.java b/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/standard/stoparrivals/EgressStopArrivalState.java index c002f57dcba..c7556267582 100644 --- a/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/standard/stoparrivals/EgressStopArrivalState.java +++ b/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/standard/stoparrivals/EgressStopArrivalState.java @@ -73,8 +73,7 @@ void setAccessTime(int time, boolean isBestTimeOverall, boolean onBoard) { @Override public String toString() { - var builder = ToStringBuilder - .of(EgressStopArrivalState.class) + var builder = ToStringBuilder.of(EgressStopArrivalState.class) .addNum("stop", stop) .addNum("round", round); // Add super type fields diff --git a/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/standard/stoparrivals/StdStopArrivals.java b/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/standard/stoparrivals/StdStopArrivals.java index a6dee126211..295b28382bd 100644 --- a/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/standard/stoparrivals/StdStopArrivals.java +++ b/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/standard/stoparrivals/StdStopArrivals.java @@ -39,8 +39,12 @@ public void setupEgressStopStates( egressPaths .byStop() .forEachEntry((stop, list) -> { - arrivals[round][stop] = - new EgressStopArrivalState<>(stop, round, list, destinationArrivalListener); + arrivals[round][stop] = new EgressStopArrivalState<>( + stop, + round, + list, + destinationArrivalListener + ); return true; }); } @@ -76,13 +80,12 @@ void setAccessTime(int time, RaptorAccessEgress access, boolean bestTime) { if (existingArrival instanceof AccessStopArrivalState) { ((AccessStopArrivalState) existingArrival).setAccessTime(time, access, bestTime); } else { - arrivals[round][stop] = - new AccessStopArrivalState<>( - time, - access, - bestTime, - (DefaultStopArrivalState) existingArrival - ); + arrivals[round][stop] = new AccessStopArrivalState<>( + time, + access, + bestTime, + (DefaultStopArrivalState) existingArrival + ); } } diff --git a/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/standard/stoparrivals/path/EgressArrivalToPathAdapter.java b/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/standard/stoparrivals/path/EgressArrivalToPathAdapter.java index a5d39d2eca9..652aaa0930e 100644 --- a/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/standard/stoparrivals/path/EgressArrivalToPathAdapter.java +++ b/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/standard/stoparrivals/path/EgressArrivalToPathAdapter.java @@ -157,8 +157,7 @@ private DestinationArrivalEvent( @Override public String toString() { - return ToStringBuilder - .of(DestinationArrivalEvent.class) + return ToStringBuilder.of(DestinationArrivalEvent.class) .addNum("round", round) .addBool("stopReachedOnBoard", stopReachedOnBoard) .addObj("egressPath", egressPath) diff --git a/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/transit/AccessEgressFunctions.java b/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/transit/AccessEgressFunctions.java index 1ab737ae907..d5650a2033c 100644 --- a/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/transit/AccessEgressFunctions.java +++ b/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/transit/AccessEgressFunctions.java @@ -52,12 +52,10 @@ public final class AccessEgressFunctions { * */ private static final ParetoComparator STANDARD_COMPARATOR = (l, r) -> - ( - (l.stopReachedOnBoard() && !r.stopReachedOnBoard()) || + ((l.stopReachedOnBoard() && !r.stopReachedOnBoard()) || r.hasOpeningHours() || l.numberOfRides() < r.numberOfRides() || - l.durationInSeconds() < r.durationInSeconds() - ); + l.durationInSeconds() < r.durationInSeconds()); /** * Filter Multi-criteria Raptor access and egress paths. This can be used to wash diff --git a/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/transit/ForwardRaptorTransitCalculator.java b/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/transit/ForwardRaptorTransitCalculator.java index 20dda7a3b37..2253bdfddf4 100644 --- a/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/transit/ForwardRaptorTransitCalculator.java +++ b/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/transit/ForwardRaptorTransitCalculator.java @@ -41,10 +41,9 @@ public ForwardRaptorTransitCalculator( ) { this.earliestDepartureTime = earliestDepartureTime; this.searchWindowInSeconds = searchWindowInSeconds; - this.latestAcceptableArrivalTime = - latestAcceptableArrivalTime == RaptorConstants.TIME_NOT_SET - ? unreachedTime() - : latestAcceptableArrivalTime; + this.latestAcceptableArrivalTime = latestAcceptableArrivalTime == RaptorConstants.TIME_NOT_SET + ? unreachedTime() + : latestAcceptableArrivalTime; this.iterationStep = iterationStep; } diff --git a/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/transit/RaptorSearchWindowCalculator.java b/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/transit/RaptorSearchWindowCalculator.java index bbb5a25c11e..2bbca0d6505 100644 --- a/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/transit/RaptorSearchWindowCalculator.java +++ b/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/transit/RaptorSearchWindowCalculator.java @@ -123,10 +123,8 @@ private int calculateSearchWindow() { // Set the search window using the min-travel-time. int v = roundStep( minSearchWindow.toSeconds() + - minTransitTimeCoefficient * - heuristicMinTransitTime + - minWaitTimeCoefficient * - heuristicMinWaitTime + minTransitTimeCoefficient * heuristicMinTransitTime + + minWaitTimeCoefficient * heuristicMinWaitTime ); // Set an upper bound to the search window diff --git a/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/transit/ReverseRaptorTransitCalculator.java b/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/transit/ReverseRaptorTransitCalculator.java index 1229c8d85ff..ea5f48a4339 100644 --- a/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/transit/ReverseRaptorTransitCalculator.java +++ b/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/transit/ReverseRaptorTransitCalculator.java @@ -43,10 +43,10 @@ public ReverseRaptorTransitCalculator(SearchParams s, RaptorTuningParameters t) ) { this.latestArrivalTime = latestArrivalTime; this.searchWindowInSeconds = searchWindowInSeconds; - this.earliestAcceptableDepartureTime = - earliestAcceptableDepartureTime == RaptorConstants.TIME_NOT_SET - ? unreachedTime() - : earliestAcceptableDepartureTime; + this.earliestAcceptableDepartureTime = earliestAcceptableDepartureTime == + RaptorConstants.TIME_NOT_SET + ? unreachedTime() + : earliestAcceptableDepartureTime; this.iterationStep = iterationStep; } diff --git a/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/transit/TripScheduleExactMatchSearch.java b/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/transit/TripScheduleExactMatchSearch.java index 1db6b2de055..e0b3c1a324b 100644 --- a/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/transit/TripScheduleExactMatchSearch.java +++ b/raptor/src/main/java/org/opentripplanner/raptor/rangeraptor/transit/TripScheduleExactMatchSearch.java @@ -56,8 +56,7 @@ public RaptorBoardOrAlightEvent search( @Override public String toString() { - return ToStringBuilder - .of(TripScheduleExactMatchSearch.class) + return ToStringBuilder.of(TripScheduleExactMatchSearch.class) .addNum("slack", slack) .addObj("delegate", delegate) .toString(); diff --git a/raptor/src/main/java/org/opentripplanner/raptor/service/RangeRaptorDynamicSearch.java b/raptor/src/main/java/org/opentripplanner/raptor/service/RangeRaptorDynamicSearch.java index 50b485ab4cf..9c4e2bbbc03 100644 --- a/raptor/src/main/java/org/opentripplanner/raptor/service/RangeRaptorDynamicSearch.java +++ b/raptor/src/main/java/org/opentripplanner/raptor/service/RangeRaptorDynamicSearch.java @@ -60,8 +60,9 @@ public RangeRaptorDynamicSearch( this.config = config; this.transitData = transitData; this.originalRequest = originalRequest; - this.dynamicSearchWindowCalculator = - config.searchWindowCalculator().withSearchParams(originalRequest.searchParams()); + this.dynamicSearchWindowCalculator = config + .searchWindowCalculator() + .withSearchParams(originalRequest.searchParams()); this.extraMcSearch = extraMcSearch; this.fwdHeuristics = new HeuristicSearchTask<>(FORWARD, "Forward", config, transitData); @@ -138,13 +139,12 @@ private RaptorResponse createAndRunDynamicRRWorker(RaptorRequest request) // Create worker if (request.profile().is(MULTI_CRITERIA)) { - raptorRouter = - config.createRangeRaptorWithMcWorker( - transitData, - request, - getDestinationHeuristics(), - extraMcSearch - ); + raptorRouter = config.createRangeRaptorWithMcWorker( + transitData, + request, + getDestinationHeuristics(), + extraMcSearch + ); } else { raptorRouter = config.createRangeRaptorWithStdWorker(transitData, request); } diff --git a/raptor/src/main/java/org/opentripplanner/raptor/spi/ExtraMcRouterSearch.java b/raptor/src/main/java/org/opentripplanner/raptor/spi/ExtraMcRouterSearch.java index e6fdc4fd0d0..12735c99cb9 100644 --- a/raptor/src/main/java/org/opentripplanner/raptor/spi/ExtraMcRouterSearch.java +++ b/raptor/src/main/java/org/opentripplanner/raptor/spi/ExtraMcRouterSearch.java @@ -35,5 +35,9 @@ RaptorTransitDataProvider createTransitDataAlternativeSearch( * You must provide a merge strategy to merge the main result (first argument) with the * alternative result(second argument). Make sure the end result does not have any duplicates. */ - BiFunction>, Collection>, Collection>> merger(); + BiFunction< + Collection>, + Collection>, + Collection> + > merger(); } diff --git a/raptor/src/main/java/org/opentripplanner/raptor/util/CompareIntArrays.java b/raptor/src/main/java/org/opentripplanner/raptor/util/CompareIntArrays.java index 1f446fe036c..8b68b937880 100644 --- a/raptor/src/main/java/org/opentripplanner/raptor/util/CompareIntArrays.java +++ b/raptor/src/main/java/org/opentripplanner/raptor/util/CompareIntArrays.java @@ -136,9 +136,12 @@ private void compareAll(int[] a, int[] b) { } private void countDiff(int a, int b) { - if (a == unreached) aNotReached++; else if (b == unreached) bNotReached++; else { + if (a == unreached) aNotReached++; + else if (b == unreached) bNotReached++; + else { int c = comparator.compare(a, b); - if (c < 0) aLess++; else if (c > 0) bLess++; + if (c < 0) aLess++; + else if (c > 0) bLess++; } } @@ -160,18 +163,17 @@ private String result(int size) { result += String.format(f, aName, aValues); result += String.format(f, bName, bValues); if (diffTot() != 0) { - result += - String.format( - "Number of diffs: %d of %d, %s better: %d and not reached: %d, %s better: %d and not reached: %d.%n", - diffTot(), - size, - aName, - aLess, - aNotReached, - bName, - bLess, - bNotReached - ); + result += String.format( + "Number of diffs: %d of %d, %s better: %d and not reached: %d, %s better: %d and not reached: %d.%n", + diffTot(), + size, + aName, + aLess, + aNotReached, + bName, + bLess, + bNotReached + ); } return result; } diff --git a/raptor/src/main/java/org/opentripplanner/raptor/util/composite/CompositeUtil.java b/raptor/src/main/java/org/opentripplanner/raptor/util/composite/CompositeUtil.java index 057e30cf7e7..8a08e320c8c 100644 --- a/raptor/src/main/java/org/opentripplanner/raptor/util/composite/CompositeUtil.java +++ b/raptor/src/main/java/org/opentripplanner/raptor/util/composite/CompositeUtil.java @@ -36,8 +36,7 @@ public static T of( ) { Objects.requireNonNull(children); - var list = Arrays - .stream(children) + var list = Arrays.stream(children) .filter(Objects::nonNull) .flatMap(it -> isComposite.test(it) ? listCompositeChildren.apply(it).stream() : Stream.of(it) ) diff --git a/raptor/src/test/java/org/opentripplanner/raptor/RaptorArchitectureTest.java b/raptor/src/test/java/org/opentripplanner/raptor/RaptorArchitectureTest.java index 3ada07c090b..ee81211ca81 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/RaptorArchitectureTest.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/RaptorArchitectureTest.java @@ -69,8 +69,7 @@ void enforcePackageDependenciesRaptorAPI() { API_PATH.dependsOn(OTP_UTILS, API_MODEL).verify(); var debug = API.subPackage("debug").dependsOn(OTP_UTILS).verify(); var view = API.subPackage("view").dependsOn(OTP_UTILS, API_MODEL).verify(); - var request = API - .subPackage("request") + var request = API.subPackage("request") .dependsOn(OTP_UTILS, debug, API_MODEL, API_PATH, view) .verify(); API.subPackage("response").dependsOn(OTP_UTILS, API_MODEL, API_PATH, request).verify(); @@ -99,9 +98,13 @@ void enforcePackageDependenciesInRangeRaptorSharedPackages() { RR_DEBUG.dependsOn(RR_SHARED_PACKAGES).verify(); RR_LIFECYCLE.dependsOn(RR_SHARED_PACKAGES).verify(); RR_TRANSIT.dependsOn(RR_SHARED_PACKAGES, RR_DEBUG, RR_LIFECYCLE).verify(); - RR_CONTEXT - .dependsOn(RR_SHARED_PACKAGES, RR_DEBUG, RR_LIFECYCLE, RR_SUPPORT, RR_TRANSIT) - .verify(); + RR_CONTEXT.dependsOn( + RR_SHARED_PACKAGES, + RR_DEBUG, + RR_LIFECYCLE, + RR_SUPPORT, + RR_TRANSIT + ).verify(); RR_PATH.dependsOn(RR_SHARED_PACKAGES, RR_DEBUG, RR_TRANSIT, RAPTOR_PATH).verify(); RR_PATH_CONFIGURE.dependsOn(RR_SHARED_PACKAGES, RR_CONTEXT, RR_PATH).verify(); RANGE_RAPTOR.dependsOn(RR_SHARED_PACKAGES, RR_INTERNAL_API, RR_LIFECYCLE, RR_TRANSIT).verify(); @@ -109,16 +112,13 @@ void enforcePackageDependenciesInRangeRaptorSharedPackages() { @Test void enforcePackageDependenciesInStandardRangeRaptorImplementation() { - var stdInternalApi = RR_STANDARD - .subPackage("internalapi") + var stdInternalApi = RR_STANDARD.subPackage("internalapi") .dependsOn(RAPTOR_API, RAPTOR_SPI, RR_INTERNAL_API) .verify(); - var stdBestTimes = RR_STANDARD - .subPackage("besttimes") + var stdBestTimes = RR_STANDARD.subPackage("besttimes") .dependsOn(RR_SHARED_PACKAGES, stdInternalApi) .verify(); - var stdStopArrivals = RR_STANDARD - .subPackage("stoparrivals") + var stdStopArrivals = RR_STANDARD.subPackage("stoparrivals") .dependsOn(RR_SHARED_PACKAGES, stdInternalApi) .verify(); var stdStopArrivalsView = stdStopArrivals @@ -129,105 +129,92 @@ void enforcePackageDependenciesInStandardRangeRaptorImplementation() { .subPackage("path") .dependsOn(RR_SHARED_PACKAGES, stdInternalApi, stdStopArrivalsView) .verify(); - var stdDebug = RR_STANDARD - .subPackage("debug") + var stdDebug = RR_STANDARD.subPackage("debug") .dependsOn(RR_SHARED_PACKAGES, stdInternalApi, stdStopArrivalsView) .verify(); - var RR_STANDARD_HEURISTIC = RR_STANDARD - .subPackage("heuristics") + var RR_STANDARD_HEURISTIC = RR_STANDARD.subPackage("heuristics") .dependsOn(RR_SHARED_PACKAGES, stdInternalApi, stdBestTimes) .verify(); RR_STANDARD.dependsOn(RR_SHARED_PACKAGES, stdInternalApi, stdBestTimes).verify(); - RR_STD_CONFIGURE - .dependsOn( - RR_SHARED_PACKAGES, - RR_CONTEXT, - RR_PATH_CONFIGURE, - stdInternalApi, - stdBestTimes, - stdStopArrivals, - stdStopArrivalsView, - stdStopArrivalsPath, - stdDebug, - RR_STANDARD_HEURISTIC, - RR_STANDARD - ) - .verify(); + RR_STD_CONFIGURE.dependsOn( + RR_SHARED_PACKAGES, + RR_CONTEXT, + RR_PATH_CONFIGURE, + stdInternalApi, + stdBestTimes, + stdStopArrivals, + stdStopArrivalsView, + stdStopArrivalsPath, + stdDebug, + RR_STANDARD_HEURISTIC, + RR_STANDARD + ).verify(); } @Test @Disabled void enforcePackageDependenciesInMultiCriteriaImplementation() { - var mcArrivals = RR_MULTI_CRITERIA - .subPackage("arrivals") + var mcArrivals = RR_MULTI_CRITERIA.subPackage("arrivals") .dependsOn(RR_SHARED_PACKAGES) .verify(); var mcArrivalsC1 = mcArrivals .subPackage("c1") .dependsOn(mcArrivals, RR_SHARED_PACKAGES) .verify(); - var mcRide = RR_MULTI_CRITERIA - .subPackage("ride") + var mcRide = RR_MULTI_CRITERIA.subPackage("ride") .dependsOn(mcArrivals, RR_SHARED_PACKAGES) .verify(); var mcRideC1 = mcRide .subPackage("c1") .dependsOn(mcArrivals, mcRide, RR_SHARED_PACKAGES) .verify(); - var mcHeuristics = RR_MULTI_CRITERIA - .subPackage("heuristic") + var mcHeuristics = RR_MULTI_CRITERIA.subPackage("heuristic") .dependsOn(RR_SHARED_PACKAGES, mcArrivals) .verify(); RR_MULTI_CRITERIA.dependsOn(RR_SHARED_PACKAGES, mcArrivals, mcRide, mcHeuristics).verify(); - RR_MC_CONFIGURE - .dependsOn( - RR_SHARED_PACKAGES, - RR_CONTEXT, - RR_PATH_CONFIGURE, - mcHeuristics, - mcArrivals, - mcArrivalsC1, - mcRideC1, - RR_MULTI_CRITERIA - ) - .verify(); + RR_MC_CONFIGURE.dependsOn( + RR_SHARED_PACKAGES, + RR_CONTEXT, + RR_PATH_CONFIGURE, + mcHeuristics, + mcArrivals, + mcArrivalsC1, + mcRideC1, + RR_MULTI_CRITERIA + ).verify(); } @Test void enforcePackageDependenciesInRaptorService() { - SERVICE - .dependsOn( - OTP_UTILS, - RAPTOR_API, - RAPTOR_SPI, - RAPTOR_UTIL, - CONFIGURE, - RR_INTERNAL_API, - RR_TRANSIT, - RANGE_RAPTOR - ) - .verify(); + SERVICE.dependsOn( + OTP_UTILS, + RAPTOR_API, + RAPTOR_SPI, + RAPTOR_UTIL, + CONFIGURE, + RR_INTERNAL_API, + RR_TRANSIT, + RANGE_RAPTOR + ).verify(); } @Test void enforcePackageDependenciesInConfigure() { - CONFIGURE - .dependsOn( - OTP_UTILS, - RAPTOR_API, - RAPTOR_SPI, - RANGE_RAPTOR, - RR_INTERNAL_API, - RR_TRANSIT, - RR_CONTEXT, - RR_STD_CONFIGURE, - RR_MC_CONFIGURE - ) - .verify(); + CONFIGURE.dependsOn( + OTP_UTILS, + RAPTOR_API, + RAPTOR_SPI, + RANGE_RAPTOR, + RR_INTERNAL_API, + RR_TRANSIT, + RR_CONTEXT, + RR_STD_CONFIGURE, + RR_MC_CONFIGURE + ).verify(); } @Test diff --git a/raptor/src/test/java/org/opentripplanner/raptor/_data/api/TestPathBuilder.java b/raptor/src/test/java/org/opentripplanner/raptor/_data/api/TestPathBuilder.java index 3c59c8543dd..7f060068bcd 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/_data/api/TestPathBuilder.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/_data/api/TestPathBuilder.java @@ -105,8 +105,9 @@ public TestPathBuilder bus(String patternName, int fromTime, int duration, int t int toTime = fromTime + duration; int fromStop = currentStop(); - TestTripSchedule trip = TestTripSchedule - .schedule(TestTripPattern.pattern(patternName, fromStop, toStop)) + TestTripSchedule trip = TestTripSchedule.schedule( + TestTripPattern.pattern(patternName, fromStop, toStop) + ) .arrDepOffset(BOARD_ALIGHT_OFFSET) .departures(fromTime, toTime + BOARD_ALIGHT_OFFSET) .build(); @@ -141,13 +142,12 @@ int currentStop() { private void reset(int startTime) { this.startTime = startTime; - this.builder = - PathBuilder.tailPathBuilder( - slackProvider, - startTime, - costCalculator, - RaptorStopNameResolver.nullSafe(null), - null - ); + this.builder = PathBuilder.tailPathBuilder( + slackProvider, + startTime, + costCalculator, + RaptorStopNameResolver.nullSafe(null), + null + ); } } diff --git a/raptor/src/test/java/org/opentripplanner/raptor/_data/multicriteria/ride/TestPatterRideBuilder.java b/raptor/src/test/java/org/opentripplanner/raptor/_data/multicriteria/ride/TestPatterRideBuilder.java index 4ed9fcaafa4..8c049dc8d47 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/_data/multicriteria/ride/TestPatterRideBuilder.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/_data/multicriteria/ride/TestPatterRideBuilder.java @@ -62,11 +62,10 @@ public PatternRide build() { } if (prevArrival == null) { int departureTime = boardTime - 180; - prevArrival = - stopArrivalFactory.createAccessStopArrival( - departureTime, - TestAccessEgress.walk(boardStopIndex, 30) - ); + prevArrival = stopArrivalFactory.createAccessStopArrival( + departureTime, + TestAccessEgress.walk(boardStopIndex, 30) + ); } if (boardC1 == NOT_SET) { boardC1 = prevArrival.c1() + 150; diff --git a/raptor/src/test/java/org/opentripplanner/raptor/_data/stoparrival/AccessAndEgressWithOpeningHoursPathTestCase.java b/raptor/src/test/java/org/opentripplanner/raptor/_data/stoparrival/AccessAndEgressWithOpeningHoursPathTestCase.java index 89e13aa58ec..d2ee92f2786 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/_data/stoparrival/AccessAndEgressWithOpeningHoursPathTestCase.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/_data/stoparrival/AccessAndEgressWithOpeningHoursPathTestCase.java @@ -139,13 +139,15 @@ public class AccessAndEgressWithOpeningHoursPathTestCase implements RaptorTestCo public static final String LINE_A = "A"; public static final String LINE_B = "B"; - public static final TestTripSchedule TRIP_A = TestTripSchedule - .schedule(TestTripPattern.pattern(LINE_A, STOP_A, STOP_D)) + public static final TestTripSchedule TRIP_A = TestTripSchedule.schedule( + TestTripPattern.pattern(LINE_A, STOP_A, STOP_D) + ) .times(L1_START, L1_END) .build(); - public static final TestTripSchedule TRIP_B = TestTripSchedule - .schedule(TestTripPattern.pattern(LINE_B, STOP_B, STOP_C)) + public static final TestTripSchedule TRIP_B = TestTripSchedule.schedule( + TestTripPattern.pattern(LINE_B, STOP_B, STOP_C) + ) .times(L1_START, L1_END) .build(); diff --git a/raptor/src/test/java/org/opentripplanner/raptor/_data/stoparrival/BasicPathTestCase.java b/raptor/src/test/java/org/opentripplanner/raptor/_data/stoparrival/BasicPathTestCase.java index b1e7c0f4ec6..1676a7e29f3 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/_data/stoparrival/BasicPathTestCase.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/_data/stoparrival/BasicPathTestCase.java @@ -192,18 +192,21 @@ public class BasicPathTestCase implements RaptorTestConstants { public static final String LINE_21 = "L21"; public static final String LINE_31 = "L31"; - public static final TestTripSchedule TRIP_1 = TestTripSchedule - .schedule(pattern(LINE_11, STOP_A, STOP_B)) + public static final TestTripSchedule TRIP_1 = TestTripSchedule.schedule( + pattern(LINE_11, STOP_A, STOP_B) + ) .times(L11_START, L11_END) .build(); - public static final TestTripSchedule TRIP_2 = TestTripSchedule - .schedule(pattern(LINE_21, STOP_C, STOP_D)) + public static final TestTripSchedule TRIP_2 = TestTripSchedule.schedule( + pattern(LINE_21, STOP_C, STOP_D) + ) .times(L21_START, L21_END) .build(); - public static final TestTripSchedule TRIP_3 = TestTripSchedule - .schedule(pattern(LINE_31, STOP_D, STOP_E)) + public static final TestTripSchedule TRIP_3 = TestTripSchedule.schedule( + pattern(LINE_31, STOP_D, STOP_E) + ) // The early arrival and late departure should not have any effect on tests .arrivals(VERY_EARLY, L31_END) .departures(L31_START, VERY_LATE) diff --git a/raptor/src/test/java/org/opentripplanner/raptor/_data/transit/TestConstrainedBoardingSearch.java b/raptor/src/test/java/org/opentripplanner/raptor/_data/transit/TestConstrainedBoardingSearch.java index 2b0e09bd397..b388125bcd1 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/_data/transit/TestConstrainedBoardingSearch.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/_data/transit/TestConstrainedBoardingSearch.java @@ -18,7 +18,8 @@ public class TestConstrainedBoardingSearch implements RaptorConstrainedBoardingSearch { /** Index of guaranteed transfers by fromStopPos */ - private final TIntObjectMap> transfersByFromStopPos = new TIntObjectHashMap<>(); + private final TIntObjectMap> transfersByFromStopPos = + new TIntObjectHashMap<>(); private final BitSet transfersByToStopPosExist = new BitSet(); private final BiPredicate timeAfterOrEqual; private int currentTargetStopPos; @@ -76,8 +77,7 @@ public List constrainedBoardings() { @Override public String toString() { - return ToStringBuilder - .of(TestConstrainedBoardingSearch.class) + return ToStringBuilder.of(TestConstrainedBoardingSearch.class) .addNum("currentTargetStopPos", currentTargetStopPos) .addObj("index", transfersByFromStopPos) .toString(); diff --git a/raptor/src/test/java/org/opentripplanner/raptor/_data/transit/TestConstrainedTransfer.java b/raptor/src/test/java/org/opentripplanner/raptor/_data/transit/TestConstrainedTransfer.java index 132d20465ac..aac7d109c9a 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/_data/transit/TestConstrainedTransfer.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/_data/transit/TestConstrainedTransfer.java @@ -126,8 +126,7 @@ public boolean match( @Override public String toString() { - return ToStringBuilder - .of(TestConstrainedTransfer.class) + return ToStringBuilder.of(TestConstrainedTransfer.class) .addObj("sourceTrip", sourceTrip) .addNum("sourceStopPos", sourceStopPos) .addObj("targetTrip", targetTrip) diff --git a/raptor/src/test/java/org/opentripplanner/raptor/_data/transit/TestRoute.java b/raptor/src/test/java/org/opentripplanner/raptor/_data/transit/TestRoute.java index 6176a72fc37..1fe051fd4b8 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/_data/transit/TestRoute.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/_data/transit/TestRoute.java @@ -17,12 +17,10 @@ public class TestRoute implements RaptorRoute, RaptorTimeTable private final TestTripPattern pattern; private final List schedules = new ArrayList<>(); - private final TestConstrainedBoardingSearch transferConstraintsForwardSearch = new TestConstrainedBoardingSearch( - true - ); - private final TestConstrainedBoardingSearch transferConstraintsReverseSearch = new TestConstrainedBoardingSearch( - false - ); + private final TestConstrainedBoardingSearch transferConstraintsForwardSearch = + new TestConstrainedBoardingSearch(true); + private final TestConstrainedBoardingSearch transferConstraintsReverseSearch = + new TestConstrainedBoardingSearch(false); private TestRoute(TestTripPattern pattern) { this.pattern = pattern; @@ -95,8 +93,7 @@ public TestRoute withTimetable(TestTripSchedule.Builder... scheduleBuilders) { } public TestRoute withTimetable(String timetable) { - Arrays - .stream(timetable.split("\\n")) + Arrays.stream(timetable.split("\\n")) .filter(StringUtils::hasValue) .map(s -> TestTripSchedule.schedule(s).pattern(pattern).build()) .forEach(schedules::add); @@ -105,8 +102,7 @@ public TestRoute withTimetable(String timetable) { @Override public String toString() { - return ToStringBuilder - .of(TestRoute.class) + return ToStringBuilder.of(TestRoute.class) .addObj("pattern", pattern) .addObj("schedules", schedules) .toString(); @@ -183,8 +179,7 @@ public Builder(String name) { public TestRoute timetable(String timetable) { timetable = timetable.trim(); int end = timetable.indexOf('\n'); - var stopIndexes = Arrays - .stream(timetable.substring(0, end).split("\\s+")) + var stopIndexes = Arrays.stream(timetable.substring(0, end).split("\\s+")) .mapToInt(RaptorTestConstants::stopNameToIndex) .toArray(); return route(name, stopIndexes).withTimetable(timetable.substring(end + 1)); diff --git a/raptor/src/test/java/org/opentripplanner/raptor/_data/transit/TestTripPattern.java b/raptor/src/test/java/org/opentripplanner/raptor/_data/transit/TestTripPattern.java index e9b6613500b..bbfc2d1e951 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/_data/transit/TestTripPattern.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/_data/transit/TestTripPattern.java @@ -84,8 +84,7 @@ public String debugInfo() { @Override public String toString() { - return ToStringBuilder - .of(TestTripPattern.class) + return ToStringBuilder.of(TestTripPattern.class) .addStr("name", name) .addInts("stops", stopIndexes) .addObj("restrictions", restrictions) diff --git a/raptor/src/test/java/org/opentripplanner/raptor/_data/transit/TestTripSchedule.java b/raptor/src/test/java/org/opentripplanner/raptor/_data/transit/TestTripSchedule.java index cbce4a642e0..43122ae3dcb 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/_data/transit/TestTripSchedule.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/_data/transit/TestTripSchedule.java @@ -64,13 +64,11 @@ public int size() { @Override public String toString() { if (Arrays.equals(arrivalTimes, departureTimes)) { - return ToStringBuilder - .of(TestTripSchedule.class) + return ToStringBuilder.of(TestTripSchedule.class) .addServiceTimeSchedule("times", arrivalTimes) .toString(); } - return ToStringBuilder - .of(TestTripSchedule.class) + return ToStringBuilder.of(TestTripSchedule.class) .addServiceTimeSchedule("arrivals", arrivalTimes) .addServiceTimeSchedule("departures", departureTimes) .toString(); @@ -168,8 +166,7 @@ public TestTripSchedule.Builder shiftTimes(int offset) { } public TestTripSchedule.Builder[] repeat(int nTimes, int everySeconds) { - return IntStream - .range(0, nTimes) + return IntStream.range(0, nTimes) .mapToObj(i -> copy().shiftTimes(i * everySeconds)) .toArray(Builder[]::new); } diff --git a/raptor/src/test/java/org/opentripplanner/raptor/_data/transit/TestTripScheduleSearch.java b/raptor/src/test/java/org/opentripplanner/raptor/_data/transit/TestTripScheduleSearch.java index 7e9a73e162e..5459a02bea0 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/_data/transit/TestTripScheduleSearch.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/_data/transit/TestTripScheduleSearch.java @@ -110,8 +110,7 @@ public boolean empty() { @Override public String toString() { - return ToStringBuilder - .of(TestTripScheduleSearch.class) + return ToStringBuilder.of(TestTripScheduleSearch.class) .addBoolIfTrue("REVERSE", direction.isInReverse()) .addNum("tripIndex", tripIndex, NOT_FOUND) .addNum("stopPos", stopPositionInPattern) diff --git a/raptor/src/test/java/org/opentripplanner/raptor/api/model/AbstractAccessEgressDecoratorTest.java b/raptor/src/test/java/org/opentripplanner/raptor/api/model/AbstractAccessEgressDecoratorTest.java index b5de21a1364..a5ac32e81ad 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/api/model/AbstractAccessEgressDecoratorTest.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/api/model/AbstractAccessEgressDecoratorTest.java @@ -20,14 +20,10 @@ class AbstractAccessEgressDecoratorTest { "10:35" ); - private final RaptorAccessEgress subject = AbstractAccessEgressDecorator.accessEgressWithExtraSlack( - DELEGATE, - SLACK - ); - private final RaptorAccessEgress subjectWOpeningHours = AbstractAccessEgressDecorator.accessEgressWithExtraSlack( - DELEGATE_W_OPENING_HOURS, - SLACK - ); + private final RaptorAccessEgress subject = + AbstractAccessEgressDecorator.accessEgressWithExtraSlack(DELEGATE, SLACK); + private final RaptorAccessEgress subjectWOpeningHours = + AbstractAccessEgressDecorator.accessEgressWithExtraSlack(DELEGATE_W_OPENING_HOURS, SLACK); private AbstractAccessEgressDecorator subjectCast() { return (AbstractAccessEgressDecorator) subject; diff --git a/raptor/src/test/java/org/opentripplanner/raptor/api/model/GeneralizedCostRelaxFunctionTest.java b/raptor/src/test/java/org/opentripplanner/raptor/api/model/GeneralizedCostRelaxFunctionTest.java index 6655dac62a9..5bd8e62579e 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/api/model/GeneralizedCostRelaxFunctionTest.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/api/model/GeneralizedCostRelaxFunctionTest.java @@ -29,21 +29,17 @@ void relaxCost() { assertEquals(10585, GeneralizedCostRelaxFunction.of(1.06, 0).relax(10_000)); assertEquals(10703, GeneralizedCostRelaxFunction.of(1.07, 0).relax(10_000)); - assertThrows( - IllegalArgumentException.class, - () -> GeneralizedCostRelaxFunction.of(MIN_RATIO - 0.1) + assertThrows(IllegalArgumentException.class, () -> + GeneralizedCostRelaxFunction.of(MIN_RATIO - 0.1) ); - assertThrows( - IllegalArgumentException.class, - () -> GeneralizedCostRelaxFunction.of(MAX_RATIO + 0.01) + assertThrows(IllegalArgumentException.class, () -> + GeneralizedCostRelaxFunction.of(MAX_RATIO + 0.01) ); - assertThrows( - IllegalArgumentException.class, - () -> GeneralizedCostRelaxFunction.of(1, MIN_SLACK - 1) + assertThrows(IllegalArgumentException.class, () -> + GeneralizedCostRelaxFunction.of(1, MIN_SLACK - 1) ); - assertThrows( - IllegalArgumentException.class, - () -> GeneralizedCostRelaxFunction.of(1, MAX_SLACK + 1) + assertThrows(IllegalArgumentException.class, () -> + GeneralizedCostRelaxFunction.of(1, MAX_SLACK + 1) ); } diff --git a/raptor/src/test/java/org/opentripplanner/raptor/api/path/PathTest.java b/raptor/src/test/java/org/opentripplanner/raptor/api/path/PathTest.java index ec5951bce7d..2ba7ac01677 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/api/path/PathTest.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/api/path/PathTest.java @@ -159,8 +159,7 @@ public void testCountTransfersWithStaySeated() { egress.c1() ); - var trip3 = TestTripSchedule - .schedule(pattern("L1", STOP_B, STOP_C)) + var trip3 = TestTripSchedule.schedule(pattern("L1", STOP_B, STOP_C)) .times(time("09:20"), egressStart) .build(); TransitPathLeg leg3 = new TransitPathLeg<>( @@ -174,8 +173,7 @@ public void testCountTransfersWithStaySeated() { leg4 ); - var trip2 = TestTripSchedule - .schedule(pattern("L1", STOP_A, STOP_B)) + var trip2 = TestTripSchedule.schedule(pattern("L1", STOP_A, STOP_B)) .times(time("09:10"), time("09:20")) .build(); @@ -217,8 +215,7 @@ public void testCountTransfersWithTransfer() { egress.c1() ); - var trip3 = TestTripSchedule - .schedule(pattern("L1", STOP_B, STOP_C)) + var trip3 = TestTripSchedule.schedule(pattern("L1", STOP_B, STOP_C)) .times(time("09:20"), egressStart) .build(); TransitPathLeg leg3 = new TransitPathLeg<>( @@ -232,8 +229,7 @@ public void testCountTransfersWithTransfer() { leg4 ); - var trip2 = TestTripSchedule - .schedule(pattern("L1", STOP_A, STOP_B)) + var trip2 = TestTripSchedule.schedule(pattern("L1", STOP_A, STOP_B)) .times(time("09:10"), time("09:20")) .build(); diff --git a/raptor/src/test/java/org/opentripplanner/raptor/api/request/MultiCriteriaRequestTest.java b/raptor/src/test/java/org/opentripplanner/raptor/api/request/MultiCriteriaRequestTest.java index 396f7567f08..008c0f07a12 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/api/request/MultiCriteriaRequestTest.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/api/request/MultiCriteriaRequestTest.java @@ -13,8 +13,7 @@ class MultiCriteriaRequestTest { private static final RelaxFunction RELAX_C1 = GeneralizedCostRelaxFunction.of(2.0, 600); - private final MultiCriteriaRequest subject = MultiCriteriaRequest - .of() + private final MultiCriteriaRequest subject = MultiCriteriaRequest.of() .withRelaxC1(RELAX_C1) .build(); diff --git a/raptor/src/test/java/org/opentripplanner/raptor/api/request/RaptorRequestTest.java b/raptor/src/test/java/org/opentripplanner/raptor/api/request/RaptorRequestTest.java index 4fbf1a89742..ae1b561051e 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/api/request/RaptorRequestTest.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/api/request/RaptorRequestTest.java @@ -19,8 +19,7 @@ class RaptorRequestTest { public static final int STOP_A = 1; public static final int STOP_B = 5; - private final RaptorRequest subject = RaptorRequest - .defaults() + private final RaptorRequest subject = RaptorRequest.defaults() .mutate() .profile(STANDARD) .searchDirection(REVERSE) diff --git a/raptor/src/test/java/org/opentripplanner/raptor/api/request/RaptorViaLocationTest.java b/raptor/src/test/java/org/opentripplanner/raptor/api/request/RaptorViaLocationTest.java index 4e7daea2430..3b48ab3c65b 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/api/request/RaptorViaLocationTest.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/api/request/RaptorViaLocationTest.java @@ -25,14 +25,14 @@ class RaptorViaLocationTest implements RaptorTestConstants { private static final int TX_DURATION = D30s; private static final TestTransfer TRANSFER = TestTransfer.transfer(STOP_C, TX_DURATION, TX_C1); - private final RaptorViaLocation subject = RaptorViaLocation - .via(VIA_LABEL, MINIMUM_WAIT_TIME) + private final RaptorViaLocation subject = RaptorViaLocation.via(VIA_LABEL, MINIMUM_WAIT_TIME) .addViaTransfer(STOP_B, TRANSFER) .addViaStop(STOP_A) .build(); - private final RaptorViaLocation subjectPassThrough = RaptorViaLocation - .passThrough(PASS_THROUGH_LABEL) + private final RaptorViaLocation subjectPassThrough = RaptorViaLocation.passThrough( + PASS_THROUGH_LABEL + ) .addPassThroughStop(STOP_D) .build(); @@ -169,15 +169,13 @@ void isBetterThan( boolean expected, String description ) { - var subject = RaptorViaLocation - .via("Subject") + var subject = RaptorViaLocation.via("Subject") .addViaTransfer(STOP_A, new TestTransfer(STOP_B, TX_DURATION, TX_C1)) .build() .connections() .getFirst(); - var candidate = RaptorViaLocation - .via("Candidate") + var candidate = RaptorViaLocation.via("Candidate") .addViaTransfer(fromStop, new TestTransfer(toStop, minWaitTime, c1)) .build() .connections() @@ -188,8 +186,7 @@ void isBetterThan( @Test void asBitSet() { - var subject = RaptorViaLocation - .passThrough(VIA_LABEL) + var subject = RaptorViaLocation.passThrough(VIA_LABEL) .addPassThroughStop(2) .addPassThroughStop(7) .addPassThroughStop(13) @@ -209,12 +206,10 @@ void asBitSet() { @Test void testEqualsAndHAshCode() { - var viaTxConnection = RaptorViaLocation - .via("SameAsVia", MINIMUM_WAIT_TIME) + var viaTxConnection = RaptorViaLocation.via("SameAsVia", MINIMUM_WAIT_TIME) .addViaTransfer(STOP_B, TRANSFER) .build(); - var viaStopConnections = RaptorViaLocation - .via("SameAsVia", MINIMUM_WAIT_TIME) + var viaStopConnections = RaptorViaLocation.via("SameAsVia", MINIMUM_WAIT_TIME) .addViaStop(STOP_A) .build(); diff --git a/raptor/src/test/java/org/opentripplanner/raptor/api/request/SearchParamsTest.java b/raptor/src/test/java/org/opentripplanner/raptor/api/request/SearchParamsTest.java index da69623a32d..3f24058f8f1 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/api/request/SearchParamsTest.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/api/request/SearchParamsTest.java @@ -104,22 +104,20 @@ void viaAndPassThrough() { @Test void addBothViaAndPassThroughIsNotSupported() { - var ex = assertThrows( - IllegalArgumentException.class, - () -> - new RaptorRequestBuilder() - .searchParams() - .earliestDepartureTime(1) - .latestArrivalTime(1200) - .addAccessPaths(TestAccessEgress.walk(1, 30)) - .addEgressPaths(TestAccessEgress.walk(7, 30)) - .addViaLocations( - List.of( - RaptorViaLocation.via("Via").addViaStop(5).build(), - RaptorViaLocation.passThrough("PassThrough").addPassThroughStop(5).build() - ) + var ex = assertThrows(IllegalArgumentException.class, () -> + new RaptorRequestBuilder() + .searchParams() + .earliestDepartureTime(1) + .latestArrivalTime(1200) + .addAccessPaths(TestAccessEgress.walk(1, 30)) + .addEgressPaths(TestAccessEgress.walk(7, 30)) + .addViaLocations( + List.of( + RaptorViaLocation.via("Via").addViaStop(5).build(), + RaptorViaLocation.passThrough("PassThrough").addPassThroughStop(5).build() ) - .build() + ) + .build() ); assertEquals( "Combining pass-through and regular via-vist it is not allowed: [" + diff --git a/raptor/src/test/java/org/opentripplanner/raptor/api/view/BoardAndAlightTimeTest.java b/raptor/src/test/java/org/opentripplanner/raptor/api/view/BoardAndAlightTimeTest.java index 517e59d121a..dc77e626337 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/api/view/BoardAndAlightTimeTest.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/api/view/BoardAndAlightTimeTest.java @@ -11,8 +11,7 @@ public class BoardAndAlightTimeTest { @Test public void testToString() { - RaptorTripSchedule trip = TestTripSchedule - .schedule("11:30 11:40 11:50") + RaptorTripSchedule trip = TestTripSchedule.schedule("11:30 11:40 11:50") .pattern("L1", 2, 5, 3) .build(); diff --git a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/A01_SingleRouteTest.java b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/A01_SingleRouteTest.java index a28687bdd2b..7f29550c6c5 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/A01_SingleRouteTest.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/A01_SingleRouteTest.java @@ -31,7 +31,8 @@ public class A01_SingleRouteTest implements RaptorTestConstants { private final TestTransitData data = new TestTransitData(); - private final RaptorRequestBuilder requestBuilder = new RaptorRequestBuilder<>(); + private final RaptorRequestBuilder requestBuilder = + new RaptorRequestBuilder<>(); private final RaptorService raptorService = new RaptorService<>( RaptorConfig.defaultConfigForTest() ); @@ -69,8 +70,7 @@ void setup() { static List testCases() { var path = "Walk 30s ~ B ~ BUS R1 0:01 0:05 ~ D ~ Walk 20s [0:00:30 0:05:20 4m50s Tₓ0 C₁940]"; - return RaptorModuleTestCase - .of() + return RaptorModuleTestCase.of() .addMinDuration("4m50s", TX_0, T00_00, T00_10) .add(standard(), PathUtils.withoutCost(path)) .add(multiCriteria(), path) diff --git a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/A04_BoardingTest.java b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/A04_BoardingTest.java index ff9b81030aa..e3e0b723949 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/A04_BoardingTest.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/A04_BoardingTest.java @@ -47,7 +47,8 @@ public class A04_BoardingTest implements RaptorTestConstants { private final TestTransitData data = new TestTransitData(); - private final RaptorRequestBuilder requestBuilder = new RaptorRequestBuilder<>(); + private final RaptorRequestBuilder requestBuilder = + new RaptorRequestBuilder<>(); private final RaptorService raptorService = new RaptorService<>( RaptorConfig.defaultConfigForTest() ); @@ -60,8 +61,9 @@ void setup() { data.withRoute(route("L1_3", STOP_A, STOP_D).withTimetable(schedule("0:12 0:18"))); data.withRoute( - route("L2", STOP_B, STOP_C, STOP_D, STOP_E, STOP_F, STOP_G) - .withTimetable(schedule("0:20 0:21 0:22 0:30 0:31 0:32")) + route("L2", STOP_B, STOP_C, STOP_D, STOP_E, STOP_F, STOP_G).withTimetable( + schedule("0:20 0:21 0:22 0:30 0:31 0:32") + ) ); // There is three possible paths from trip L2 to the destination. These paths are used to test @@ -81,8 +83,7 @@ void setup() { } static List testCases() { - return RaptorModuleTestCase - .of() + return RaptorModuleTestCase.of() .addMinDuration("23m", TX_2, T00_00, T01_00) // A test on the standard profile is included to demonstrate that the // min-travel-duration and the standard give different results. The L2 diff --git a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/B01_AccessTest.java b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/B01_AccessTest.java index 76583a38649..d86b6dd7e78 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/B01_AccessTest.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/B01_AccessTest.java @@ -32,7 +32,8 @@ public class B01_AccessTest implements RaptorTestConstants { private final TestTransitData data = new TestTransitData(); - private final RaptorRequestBuilder requestBuilder = new RaptorRequestBuilder<>(); + private final RaptorRequestBuilder requestBuilder = + new RaptorRequestBuilder<>(); private final RaptorService raptorService = new RaptorService<>( RaptorConfig.defaultConfigForTest() ); @@ -40,8 +41,9 @@ public class B01_AccessTest implements RaptorTestConstants { @BeforeEach void setup() { data.withRoute( - route("R1", STOP_B, STOP_C, STOP_D, STOP_E, STOP_F) - .withTimetable(schedule("0:10 0:14 0:18 0:22 0:25")) + route("R1", STOP_B, STOP_C, STOP_D, STOP_E, STOP_F).withTimetable( + schedule("0:10 0:14 0:18 0:22 0:25") + ) ); requestBuilder @@ -68,8 +70,7 @@ static List testCases() { var expStdOne = "Walk 1s 0:09:59 0:10 ~ B 0s ~ BUS R1 0:10 0:25 15m ~ F 0s ~ Walk 1s 0:25 0:25:01 [0:09:59 0:25:01 15m2s Tₓ0]"; - return RaptorModuleTestCase - .of() + return RaptorModuleTestCase.of() .addMinDuration("14m1s", TX_0, T00_00, T00_30) .add(standard().not(TC_STANDARD_ONE), expStd) // When we run one iteration the first access boarding is used as long as it diff --git a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/B02_EgressTest.java b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/B02_EgressTest.java index b32784c0c99..5f55423d599 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/B02_EgressTest.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/B02_EgressTest.java @@ -30,7 +30,8 @@ public class B02_EgressTest implements RaptorTestConstants { private final TestTransitData data = new TestTransitData(); - private final RaptorRequestBuilder requestBuilder = new RaptorRequestBuilder<>(); + private final RaptorRequestBuilder requestBuilder = + new RaptorRequestBuilder<>(); private final RaptorService raptorService = new RaptorService<>( RaptorConfig.defaultConfigForTest() ); @@ -38,8 +39,9 @@ public class B02_EgressTest implements RaptorTestConstants { @BeforeEach void setup() { data.withRoute( - route("R1", STOP_B, STOP_C, STOP_D, STOP_E, STOP_F, STOP_G) - .withTimetable(schedule("0:10, 0:14, 0:18, 0:20, 0:24, 0:28")) + route("R1", STOP_B, STOP_C, STOP_D, STOP_E, STOP_F, STOP_G).withTimetable( + schedule("0:10, 0:14, 0:18, 0:20, 0:24, 0:28") + ) ); requestBuilder @@ -61,8 +63,7 @@ static List testCases() { String expStd = "Walk 20s ~ B ~ BUS R1 0:10 0:20 ~ E ~ Walk 7m [0:09:40 0:27 17m20s Tₓ0]"; String expStdRevOne = "Walk 20s ~ B ~ BUS R1 0:10 0:28 ~ G ~ Walk 1s [0:09:40 0:28:01 18m21s Tₓ0]"; - return RaptorModuleTestCase - .of() + return RaptorModuleTestCase.of() .addMinDuration("17m20s", TX_0, T00_00, T00_30) .add(standard().not(TC_STANDARD_REV_ONE), expStd) // When we run one iteration the egress "alighting" last is used as long as it diff --git a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/B03_AccessEgressTest.java b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/B03_AccessEgressTest.java index 8cff8320f37..f3fffd64052 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/B03_AccessEgressTest.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/B03_AccessEgressTest.java @@ -33,7 +33,8 @@ public class B03_AccessEgressTest implements RaptorTestConstants { private final TestTransitData data = new TestTransitData(); - private final RaptorRequestBuilder requestBuilder = new RaptorRequestBuilder<>(); + private final RaptorRequestBuilder requestBuilder = + new RaptorRequestBuilder<>(); private final RaptorService raptorService = new RaptorService<>( RaptorConfig.defaultConfigForTest() ); @@ -41,8 +42,9 @@ public class B03_AccessEgressTest implements RaptorTestConstants { @BeforeEach public void setup() { data.withRoute( - route("R1", STOP_A, STOP_B, STOP_C, STOP_D, STOP_E, STOP_F, STOP_G, STOP_H) - .withTimetable(schedule("0:10, 0:14, 0:18, 0:22, 0:28, 0:32, 0:36, 0:40")) + route("R1", STOP_A, STOP_B, STOP_C, STOP_D, STOP_E, STOP_F, STOP_G, STOP_H).withTimetable( + schedule("0:10, 0:14, 0:18, 0:22, 0:28, 0:32, 0:36, 0:40") + ) ); requestBuilder @@ -70,8 +72,7 @@ private static RaptorModuleTestCaseFactory standardTestCases() { String expStd = "Walk 7m ~ C ~ BUS R1 0:18 0:32 ~ F ~ Walk 7m [0:11 0:39 28m Tₓ0]"; String expStdOne = "Walk 1s ~ A ~ BUS R1 0:10 0:32 ~ F ~ Walk 7m [0:09:59 0:39 29m1s Tₓ0]"; String expStdRevOne = "Walk 7m ~ C ~ BUS R1 0:18 0:40 ~ H ~ Walk 1s [0:11 0:40:01 29m1s Tₓ0]"; - return RaptorModuleTestCase - .of() + return RaptorModuleTestCase.of() .withRequest(r -> r.searchParams().timetable(true)) .addMinDuration("28m", TX_0, T00_00, T01_00) .add(standard().manyIterations(), expStd) diff --git a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/B04_AccessEgressBoardingTest.java b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/B04_AccessEgressBoardingTest.java index 6ac5ff4b028..f121d228482 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/B04_AccessEgressBoardingTest.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/B04_AccessEgressBoardingTest.java @@ -48,7 +48,8 @@ public class B04_AccessEgressBoardingTest implements RaptorTestConstants { "Walk 10s ~ B ~ BUS R1 0:14 0:38 ~ F ~ Walk 1s [0:13:50 0:38:01 24m11s Tₓ0]"; private final TestTransitData data = new TestTransitData(); - private final RaptorRequestBuilder requestBuilder = new RaptorRequestBuilder<>(); + private final RaptorRequestBuilder requestBuilder = + new RaptorRequestBuilder<>(); private final RaptorService raptorService = new RaptorService<>( RaptorConfig.defaultConfigForTest() ); @@ -56,8 +57,9 @@ public class B04_AccessEgressBoardingTest implements RaptorTestConstants { @BeforeEach void setup() { data.withRoute( - route("R1", STOP_A, STOP_B, STOP_C, STOP_D, STOP_E, STOP_F) - .withTimetable(schedule("0:10 0:14 0:18 0:30 0:34 0:38")) + route("R1", STOP_A, STOP_B, STOP_C, STOP_D, STOP_E, STOP_F).withTimetable( + schedule("0:10 0:14 0:18 0:30 0:34 0:38") + ) ); requestBuilder @@ -82,8 +84,7 @@ static List testCases() { var expected = "Walk 10s ~ B ~ BUS R1 0:14 0:34 ~ E ~ Walk 10s [0:13:50 0:34:10 20m20s Tₓ0 C₁1_840]"; - return RaptorModuleTestCase - .of() + return RaptorModuleTestCase.of() .addMinDuration("20m20s", TX_0, T00_00, T01_00) // A test on the standard profile is included to demonstrate that the min-travel-duration // and the standard give different results. The boarding stop is different. diff --git a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/B05_EgressStopBoardAlightTransferCostTest.java b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/B05_EgressStopBoardAlightTransferCostTest.java index 7f2dd2f0072..fd9d860e89a 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/B05_EgressStopBoardAlightTransferCostTest.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/B05_EgressStopBoardAlightTransferCostTest.java @@ -28,7 +28,8 @@ public class B05_EgressStopBoardAlightTransferCostTest implements RaptorTestConstants { private final TestTransitData data = new TestTransitData(); - private final RaptorRequestBuilder requestBuilder = new RaptorRequestBuilder<>(); + private final RaptorRequestBuilder requestBuilder = + new RaptorRequestBuilder<>(); private final RaptorService raptorService = new RaptorService<>( RaptorConfig.defaultConfigForTest() ); @@ -56,8 +57,7 @@ void setup() { } static List testCases() { - return RaptorModuleTestCase - .of() + return RaptorModuleTestCase.of() .add( multiCriteria(), // We should get both the fastest and the c1-cheapest results diff --git a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/C01_TransferBoardAndAlightSlackTest.java b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/C01_TransferBoardAndAlightSlackTest.java index 18d4d7d5024..15e80129e9c 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/C01_TransferBoardAndAlightSlackTest.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/C01_TransferBoardAndAlightSlackTest.java @@ -38,7 +38,8 @@ public class C01_TransferBoardAndAlightSlackTest implements RaptorTestConstants { private final TestTransitData data = new TestTransitData(); - private final RaptorRequestBuilder requestBuilder = new RaptorRequestBuilder<>(); + private final RaptorRequestBuilder requestBuilder = + new RaptorRequestBuilder<>(); private final RaptorService raptorService = new RaptorService<>( RaptorConfig.defaultConfigForTest() ); @@ -50,16 +51,16 @@ void setup() { data.withRoute( // Pattern arrive at stop 2 at 0:03:00 - route(pattern("R1", STOP_B, STOP_C)) - .withTimetable(schedule().departures("00:02:11 00:03:11").arrDepOffset(D10s)) + route(pattern("R1", STOP_B, STOP_C)).withTimetable( + schedule().departures("00:02:11 00:03:11").arrDepOffset(D10s) + ) ); data.withRoute( // earliest-departure-time: 0:03:00 + 10s + 1m + 30s = 0:04:40 - route(pattern("R2", STOP_C, STOP_D)) - .withTimetable( - schedule().departures("00:04:40 00:05:10").arrDepOffset(D10s), // Missed by 1 second - schedule().departures("00:04:41 00:05:11").arrDepOffset(D10s) // Exact match - ) + route(pattern("R2", STOP_C, STOP_D)).withTimetable( + schedule().departures("00:04:40 00:05:10").arrDepOffset(D10s), // Missed by 1 second + schedule().departures("00:04:41 00:05:11").arrDepOffset(D10s) // Exact match + ) ); requestBuilder .searchParams() @@ -80,8 +81,7 @@ static List testCases() { "~ Walk 20s " + "[0:01:11 0:05:31 4m20s Tₓ1 C₁1_510]"; - return RaptorModuleTestCase - .of() + return RaptorModuleTestCase.of() .addMinDuration("4m20s", TX_1, T00_00, T00_30) .add(standard(), PathUtils.withoutCost(expected)) .add(multiCriteria(), expected) diff --git a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/C02_OnStreetTransfersTest.java b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/C02_OnStreetTransfersTest.java index a482a75c1e9..9341ea4d753 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/C02_OnStreetTransfersTest.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/C02_OnStreetTransfersTest.java @@ -35,7 +35,8 @@ public class C02_OnStreetTransfersTest implements RaptorTestConstants { private final TestTransitData data = new TestTransitData(); - private final RaptorRequestBuilder requestBuilder = new RaptorRequestBuilder<>(); + private final RaptorRequestBuilder requestBuilder = + new RaptorRequestBuilder<>(); private final RaptorService raptorService = new RaptorService<>( RaptorConfig.defaultConfigForTest() ); @@ -46,19 +47,19 @@ public void setup() { data.withSlackProvider(new DefaultSlackProvider(D30s, D0s, D0s)); data.withRoute( - route(pattern("R1", STOP_B, STOP_C)) - .withTimetable(schedule().departures("00:02:00, 00:03:10").arrDepOffset(D10s)) + route(pattern("R1", STOP_B, STOP_C)).withTimetable( + schedule().departures("00:02:00, 00:03:10").arrDepOffset(D10s) + ) ); // It is not possible to transfer from D -> C data.withTransfer(STOP_C, TestTransfer.transfer(STOP_D, D30s)); data.withRoute( - route(pattern("R2", STOP_D, STOP_E)) - .withTimetable( - schedule().departures("00:03:59, 00:05:09").arrDepOffset(D10s), // Missed by 1 second - schedule().departures("00:04:00, 00:05:10").arrDepOffset(D10s) // Exact match - ) + route(pattern("R2", STOP_D, STOP_E)).withTimetable( + schedule().departures("00:03:59, 00:05:09").arrDepOffset(D10s), // Missed by 1 second + schedule().departures("00:04:00, 00:05:10").arrDepOffset(D10s) // Exact match + ) ); requestBuilder @@ -80,8 +81,7 @@ static List testCases() { "BUS R2 0:04 0:05 ~ E ~ " + "Walk 20s " + "[0:01:30 0:05:20 3m50s Tₓ1 C₁1_510]"; - return RaptorModuleTestCase - .of() + return RaptorModuleTestCase.of() .addMinDuration("3m50s", TX_1, T00_00, T00_30) .add(standard(), PathUtils.withoutCost(expected)) .add(multiCriteria(), expected) diff --git a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/C03_OnBoardArrivalDominateTransfersTest.java b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/C03_OnBoardArrivalDominateTransfersTest.java index 2bfc2979f6e..e22a33f220f 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/C03_OnBoardArrivalDominateTransfersTest.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/C03_OnBoardArrivalDominateTransfersTest.java @@ -38,7 +38,8 @@ public class C03_OnBoardArrivalDominateTransfersTest implements RaptorTestConsta private final RaptorService raptorService = new RaptorService<>( RaptorConfig.defaultConfigForTest() ); - private final RaptorRequestBuilder requestBuilder = new RaptorRequestBuilder<>(); + private final RaptorRequestBuilder requestBuilder = + new RaptorRequestBuilder<>(); @BeforeEach public void setup() { @@ -70,8 +71,7 @@ static List testCases() { "Walk 1m " + "[0:04 0:16 12m Tₓ1 C₁2_040]"; - return RaptorModuleTestCase - .of() + return RaptorModuleTestCase.of() // Zero transfers is wrong, it is caused by the egress stop(C) being reached by transfer // with 0tx(before boarding), so 0 transfers is stored in BestNumberOfTransfers for stop C. // Then since the path is computed after, not during, the Raptor search this fails combine diff --git a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/D01_SingeRouteBoardAlightRestrictionsTest.java b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/D01_SingeRouteBoardAlightRestrictionsTest.java index cde91ab61f8..72a0325d7ad 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/D01_SingeRouteBoardAlightRestrictionsTest.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/D01_SingeRouteBoardAlightRestrictionsTest.java @@ -31,7 +31,8 @@ public class D01_SingeRouteBoardAlightRestrictionsTest implements RaptorTestConstants { private final TestTransitData data = new TestTransitData(); - private final RaptorRequestBuilder requestBuilder = new RaptorRequestBuilder<>(); + private final RaptorRequestBuilder requestBuilder = + new RaptorRequestBuilder<>(); private final RaptorService raptorService = new RaptorService<>( RaptorConfig.defaultConfigForTest() ); @@ -56,8 +57,7 @@ public class D01_SingeRouteBoardAlightRestrictionsTest implements RaptorTestCons */ @BeforeEach void setup() { - TestTripPattern pattern = TestTripPattern - .of("R1", STOP_B, STOP_C, STOP_D) + TestTripPattern pattern = TestTripPattern.of("R1", STOP_B, STOP_C, STOP_D) .restrictions("B BA A") .build(); data.withRoute(route(pattern).withTimetable(schedule("00:01, 00:03, 00:05"))); @@ -74,8 +74,7 @@ void setup() { static List testCases() { var path = "Walk 30s ~ B ~ BUS R1 0:01 0:05 ~ D ~ Walk 20s [0:00:30 0:05:20 4m50s Tₓ0 C₁940]"; - return RaptorModuleTestCase - .of() + return RaptorModuleTestCase.of() .addMinDuration("4m50s", TX_0, T00_00, T00_10) .add(standard(), PathUtils.withoutCost(path)) .add(multiCriteria(), path) diff --git a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/E01_StaySeatedTransferTest.java b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/E01_StaySeatedTransferTest.java index 16d0ea745fe..8ac30034846 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/E01_StaySeatedTransferTest.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/E01_StaySeatedTransferTest.java @@ -34,7 +34,8 @@ public class E01_StaySeatedTransferTest implements RaptorTestConstants { private final TestTransitData data = new TestTransitData(); - private final RaptorRequestBuilder requestBuilder = new RaptorRequestBuilder<>(); + private final RaptorRequestBuilder requestBuilder = + new RaptorRequestBuilder<>(); private final RaptorService raptorService = new RaptorService<>( RaptorConfig.defaultConfigForTest() ); @@ -82,8 +83,7 @@ static List testCases() { var path = "Walk 30s ~ A ~ BUS R1 0:02 0:05 ~ B ~ BUS R2 0:05 0:10 ~ C ~ Walk 30s " + "[0:01:10 0:10:40 9m30s Tₓ0 C₁1_230]"; - return RaptorModuleTestCase - .of() + return RaptorModuleTestCase.of() .addMinDuration("9m30s", TX_1, T00_00, T00_30) .add(standard(), PathUtils.withoutCost(path)) .add(multiCriteria(), path) diff --git a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/E02_GuaranteedWalkTransferTest.java b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/E02_GuaranteedWalkTransferTest.java index cd2b1f3c25e..5a9200a4719 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/E02_GuaranteedWalkTransferTest.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/E02_GuaranteedWalkTransferTest.java @@ -34,7 +34,8 @@ public class E02_GuaranteedWalkTransferTest implements RaptorTestConstants { private final TestTransitData data = new TestTransitData(); - private final RaptorRequestBuilder requestBuilder = new RaptorRequestBuilder<>(); + private final RaptorRequestBuilder requestBuilder = + new RaptorRequestBuilder<>(); private final RaptorService raptorService = new RaptorService<>( RaptorConfig.defaultConfigForTest() ); @@ -84,8 +85,7 @@ static List testCases() { var path = "Walk 30s ~ A ~ BUS R1 0:02 0:05 ~ B ~ Walk 30s ~ C ~ BUS R2 0:05 0:10 ~ D ~ Walk 30s " + "[0:01:10 0:10:40 9m30s Tₓ1 C₁1_260]"; - return RaptorModuleTestCase - .of() + return RaptorModuleTestCase.of() // BUG! 10 minutes is wrong, it should be 9m30s - Raptor may drop optimal paths, // because of this! .addMinDuration("10m", TX_1, T00_00, T00_30) diff --git a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/E03_NotAllowedConstrainedTransferTest.java b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/E03_NotAllowedConstrainedTransferTest.java index 1a324796784..2d2237cff6d 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/E03_NotAllowedConstrainedTransferTest.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/E03_NotAllowedConstrainedTransferTest.java @@ -31,7 +31,8 @@ public class E03_NotAllowedConstrainedTransferTest implements RaptorTestConstants { private final TestTransitData data = new TestTransitData(); - private final RaptorRequestBuilder requestBuilder = new RaptorRequestBuilder<>(); + private final RaptorRequestBuilder requestBuilder = + new RaptorRequestBuilder<>(); private final RaptorService raptorService = new RaptorService<>( RaptorConfig.defaultConfigForTest() ); @@ -44,14 +45,13 @@ public class E03_NotAllowedConstrainedTransferTest implements RaptorTestConstant @BeforeEach public void setup() { var r1 = route("R1", STOP_A, STOP_B).withTimetable(schedule("0:02 0:05")); - var r2 = route("R2", STOP_B, STOP_C) - .withTimetable( - schedule("0:10 0:15"), - // Add another schedule - should not be used even if the not-allowed is - // attached to the first one - not-allowed in Raptor apply to the Route. - // The trip/timetable search should handle not-allowed on trip level. - schedule("0:12 0:17") - ); + var r2 = route("R2", STOP_B, STOP_C).withTimetable( + schedule("0:10 0:15"), + // Add another schedule - should not be used even if the not-allowed is + // attached to the first one - not-allowed in Raptor apply to the Route. + // The trip/timetable search should handle not-allowed on trip level. + schedule("0:12 0:17") + ); var r3 = route("R3", STOP_B, STOP_C).withTimetable(schedule("0:15 0:20")); var tripR1a = r1.timetable().getTripSchedule(0); @@ -83,8 +83,7 @@ static List testCases() { var path = "Walk 30s ~ A ~ BUS R1 0:02 0:05 ~ B ~ BUS R3 0:15 0:20 ~ C ~ Walk 30s " + "[0:01:30 0:20:30 19m Tₓ1 C₁2_500]"; - return RaptorModuleTestCase - .of() + return RaptorModuleTestCase.of() .addMinDuration("9m", TX_1, T00_00, T00_30) .add(standard().not(TC_STANDARD_REV), PathUtils.withoutCost(path)) .add(multiCriteria(), path) diff --git a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/F01_AccessWithRidesTest.java b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/F01_AccessWithRidesTest.java index 96a5a04d7fd..770f488ea2a 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/F01_AccessWithRidesTest.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/F01_AccessWithRidesTest.java @@ -42,7 +42,8 @@ public class F01_AccessWithRidesTest implements RaptorTestConstants { private static final int C1_ONE_SEC = RaptorCostConverter.toRaptorCost(1); private final TestTransitData data = new TestTransitData(); - private final RaptorRequestBuilder requestBuilder = new RaptorRequestBuilder<>(); + private final RaptorRequestBuilder requestBuilder = + new RaptorRequestBuilder<>(); private final RaptorService raptorService = new RaptorService<>( RaptorConfig.defaultConfigForTest() ); @@ -50,8 +51,9 @@ public class F01_AccessWithRidesTest implements RaptorTestConstants { @BeforeEach void setup() { data.withRoute( - route("R1", STOP_B, STOP_C, STOP_D, STOP_E, STOP_F) - .withTimetable(schedule("0:10, 0:12, 0:14, 0:16, 0:20")) + route("R1", STOP_B, STOP_C, STOP_D, STOP_E, STOP_F).withTimetable( + schedule("0:10, 0:12, 0:14, 0:16, 0:20") + ) ); // We will test board- and alight-slack in a separate test data.withSlackProvider(new DefaultSlackProvider(TRANSFER_SLACK, 0, 0)); @@ -79,8 +81,7 @@ void setup() { static List testCases() { String expFlexAccess = "Flex 3m 2x ~ D ~ BUS R1 0:14 0:20 ~ F ~ Walk 1m [0:10 0:21 11m Tₓ2]"; String expWalkAccess = "Walk 10m ~ B ~ BUS R1 0:10 0:20 ~ F ~ Walk 1m [0:00 0:21 21m Tₓ0]"; - return RaptorModuleTestCase - .of() + return RaptorModuleTestCase.of() // TODO - Why do we get only one result here - when there is 3 different pareto-optimal // - paths .add(TC_MIN_DURATION, "[0:00 0:11 11m Tₓ0]") diff --git a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/F02_EgressWithRidesTest.java b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/F02_EgressWithRidesTest.java index 1b5164c79a4..f3d1842f4ab 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/F02_EgressWithRidesTest.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/F02_EgressWithRidesTest.java @@ -40,7 +40,8 @@ public class F02_EgressWithRidesTest implements RaptorTestConstants { private static final int D1m59s = DurationUtils.durationInSeconds("1m59s"); private final TestTransitData data = new TestTransitData(); - private final RaptorRequestBuilder requestBuilder = new RaptorRequestBuilder<>(); + private final RaptorRequestBuilder requestBuilder = + new RaptorRequestBuilder<>(); private final RaptorService raptorService = new RaptorService<>( RaptorConfig.defaultConfigForTest() ); @@ -48,8 +49,9 @@ public class F02_EgressWithRidesTest implements RaptorTestConstants { @BeforeEach void setup() { data.withRoute( - route("R1", STOP_B, STOP_C, STOP_D, STOP_E, STOP_F) - .withTimetable(schedule("0:10, 0:12, 0:14, 0:16, 0:18")) + route("R1", STOP_B, STOP_C, STOP_D, STOP_E, STOP_F).withTimetable( + schedule("0:10, 0:12, 0:14, 0:16, 0:18") + ) ); // We will test board- and alight-slack in a separate test data.withSlackProvider(new DefaultSlackProvider(60, 0, 0)); @@ -76,8 +78,7 @@ static List testCases() { var bestCost = prefix + "0:16 ~ E ~ Flex+Walk 1m59s 2x [0:09 0:18:59 9m59s Tₓ2 C₁1_378]"; var bestTxAndTime = prefix + "0:12 ~ C ~ Flex+Walk 7m 1x [0:09 0:20 11m Tₓ1 C₁1_740]"; - return RaptorModuleTestCase - .of() + return RaptorModuleTestCase.of() .add(TC_MIN_DURATION, "[0:00 0:09 9m Tₓ2]", "[0:00 0:11 11m Tₓ1]", "[0:00 0:19 19m Tₓ0]") .add(TC_MIN_DURATION_REV, "[0:21 0:30 9m Tₓ0]") .add(standard().not(TC_STANDARD_REV_ONE), withoutCost(bestArrivalTime)) diff --git a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/F03_AccessEgressWithRidesBoardAndAlightSlackTest.java b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/F03_AccessEgressWithRidesBoardAndAlightSlackTest.java index 0c6895e7e68..fea1ec0de29 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/F03_AccessEgressWithRidesBoardAndAlightSlackTest.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/F03_AccessEgressWithRidesBoardAndAlightSlackTest.java @@ -33,7 +33,8 @@ public class F03_AccessEgressWithRidesBoardAndAlightSlackTest implements RaptorTestConstants { private final TestTransitData data = new TestTransitData(); - private final RaptorRequestBuilder requestBuilder = new RaptorRequestBuilder<>(); + private final RaptorRequestBuilder requestBuilder = + new RaptorRequestBuilder<>(); private final RaptorService raptorService = new RaptorService<>( RaptorConfig.defaultConfigForTest() ); @@ -45,18 +46,17 @@ public void setup() { data.withRoute( // Pattern arrive at stop 2 at 0:03:00 - route(pattern("R1", STOP_B, STOP_C)) - .withTimetable( - // First trip is too early: It takes 2m to get to the point of boarding: - // --> 00:00:00 + flex 30s + slack(1m + 30s) = 00:02:00 - schedule().departures("0:03:29, 0:05:29"), - // This is the trip we expect to board - schedule().departures("0:04:00, 0:10:00").arrivals("0, 00:06:00"), - // REVERSE SEARCH: The last trip arrives too late: It takes 1m40s to get to the - // point of "boarding" in the reverse search: - // --> 00:10:00 - (flex 20s + slack(1m + 10s)) = 00:08:30 (arrival time) - schedule().arrivals("0:04:51, 0:06:51") - ) + route(pattern("R1", STOP_B, STOP_C)).withTimetable( + // First trip is too early: It takes 2m to get to the point of boarding: + // --> 00:00:00 + flex 30s + slack(1m + 30s) = 00:02:00 + schedule().departures("0:03:29, 0:05:29"), + // This is the trip we expect to board + schedule().departures("0:04:00, 0:10:00").arrivals("0, 00:06:00"), + // REVERSE SEARCH: The last trip arrives too late: It takes 1m40s to get to the + // point of "boarding" in the reverse search: + // --> 00:10:00 - (flex 20s + slack(1m + 10s)) = 00:08:30 (arrival time) + schedule().arrivals("0:04:51, 0:06:51") + ) ); requestBuilder .searchParams() @@ -76,8 +76,7 @@ static List testCases() { var path = "Flex+Walk 2m 1x ~ B ~ BUS R1 0:04 0:06 ~ C ~ Flex 2m 1x " + "[0:00:30 0:09:10 8m40s Tₓ2 C₁1_360]"; - return RaptorModuleTestCase - .of() + return RaptorModuleTestCase.of() // TODO - Alight slack is missing //.add(TC_MIN_DURATION, "[0:00 0:08:30 8m30s 2tx]") // TODO - Board slack is missing diff --git a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/F04_AccessEgressWithRidesNoTransitTest.java b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/F04_AccessEgressWithRidesNoTransitTest.java index 0057b8a1d20..8318936f063 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/F04_AccessEgressWithRidesNoTransitTest.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/F04_AccessEgressWithRidesNoTransitTest.java @@ -46,7 +46,8 @@ public class F04_AccessEgressWithRidesNoTransitTest implements RaptorTestConstan private final RaptorService raptorService = new RaptorService<>( RaptorConfig.defaultConfigForTest() ); - private final RaptorRequestBuilder requestBuilder = new RaptorRequestBuilder<>(); + private final RaptorRequestBuilder requestBuilder = + new RaptorRequestBuilder<>(); @BeforeEach public void setup() { @@ -68,8 +69,7 @@ public void setup() { static List flexTransferFlexTestCases() { var path = "Flex 2m 1x ~ B ~ Walk 5m ~ C ~ Flex 2m 1x [0:10 0:20 10m Tₓ1 C₁1_140]"; var stdPathRev = "Flex 2m 1x ~ B ~ Walk 5m ~ C ~ Flex 2m 1x [0:20 0:30 10m Tₓ1]"; - return RaptorModuleTestCase - .of() + return RaptorModuleTestCase.of() .withRequest(requestBuilder -> requestBuilder .searchParams() @@ -96,8 +96,7 @@ static List flexOpeningHoursTransferFlexTestCases() { "Flex 2m 1x Open(0:12 0:16) ~ B ~ Walk 5m ~ C ~ Flex 2m 1x [0:12 0:22 10m Tₓ1 C₁1_140]"; var stdPathRev = "Flex 2m 1x Open(0:12 0:16) ~ B ~ Walk 5m ~ C ~ Flex 2m 1x [0:16 0:26 10m Tₓ1]"; - return RaptorModuleTestCase - .of() + return RaptorModuleTestCase.of() .withRequest(requestBuilder -> requestBuilder .searchParams() @@ -121,8 +120,7 @@ void flexOpeningHoursTransferFlexTest(RaptorModuleTestCase testCase) { static List flexTransferFlexOpeningHoursTestCases() { var path = "Flex 2m 1x ~ B ~ Walk 5m ~ C ~ Flex 2m 1x Open(0:22 0:26) "; - return RaptorModuleTestCase - .of() + return RaptorModuleTestCase.of() .withRequest(requestBuilder -> requestBuilder .searchParams() @@ -148,8 +146,7 @@ void flexTransferFlexOpeningHoursTest(RaptorModuleTestCase testCase) { static List flexAndWalkToFlexTestCases() { var path = "Flex+Walk 7m 1x ~ C ~ Flex 2m 1x [0:10 0:20 10m Tₓ1 C₁1_140]"; var stdPathRev = "Flex+Walk 7m 1x ~ C ~ Flex 2m 1x [0:20 0:30 10m Tₓ1]"; - return RaptorModuleTestCase - .of() + return RaptorModuleTestCase.of() .withRequest(requestBuilder -> requestBuilder .searchParams() @@ -174,8 +171,7 @@ void flexAndWalkToFlexTest(RaptorModuleTestCase testCase) { static List flexToFlexAndWalkTestCases() { var path = "Flex 2m 1x ~ C ~ Flex+Walk 7m 1x [0:10 0:20 10m Tₓ1 C₁1_140]"; var stdPathRev = "Flex 2m 1x ~ C ~ Flex+Walk 7m 1x [0:20 0:30 10m Tₓ1]"; - return RaptorModuleTestCase - .of() + return RaptorModuleTestCase.of() .withRequest(requestBuilder -> requestBuilder .searchParams() diff --git a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/F05_OnBoardAccessEgressAndTransfersTest.java b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/F05_OnBoardAccessEgressAndTransfersTest.java index 139185c33fc..8c74e24a0ff 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/F05_OnBoardAccessEgressAndTransfersTest.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/F05_OnBoardAccessEgressAndTransfersTest.java @@ -34,7 +34,8 @@ public class F05_OnBoardAccessEgressAndTransfersTest implements RaptorTestConsta private final RaptorService raptorService = new RaptorService<>( RaptorConfig.defaultConfigForTest() ); - private final RaptorRequestBuilder requestBuilder = new RaptorRequestBuilder<>(); + private final RaptorRequestBuilder requestBuilder = + new RaptorRequestBuilder<>(); @BeforeEach public void setup() { @@ -59,8 +60,7 @@ static List testCases() { var path = "Flex 5m 1x ~ A ~ Walk 10s ~ B ~ BUS R1 0:10 0:20 ~ C ~ Walk 10s ~ D ~ Flex 5m 1x [0:03:50 0:26:10 22m20s Tₓ2 C₁2_560]"; - return RaptorModuleTestCase - .of() + return RaptorModuleTestCase.of() .addMinDuration("22m20s", 2, T00_00, T00_30) .add(standard(), PathUtils.withoutCost(path)) .add(multiCriteria(), path) diff --git a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/F11_AccessWithRidesMultipleOptimalPathsTest.java b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/F11_AccessWithRidesMultipleOptimalPathsTest.java index fdc7c1dadd2..348ed8d36d4 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/F11_AccessWithRidesMultipleOptimalPathsTest.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/F11_AccessWithRidesMultipleOptimalPathsTest.java @@ -56,7 +56,8 @@ public class F11_AccessWithRidesMultipleOptimalPathsTest implements RaptorTestCo RaptorConfig.defaultConfigForTest() ); private final TestTransitData data = new TestTransitData(); - private final RaptorRequestBuilder requestBuilder = new RaptorRequestBuilder<>(); + private final RaptorRequestBuilder requestBuilder = + new RaptorRequestBuilder<>(); @BeforeEach public void setup() { @@ -98,8 +99,7 @@ static List testCase3mWalkAccess() { // Min-Duration 19m var flexAndTransit = startFlexAccess + endL2AndWalk + "[0:03 0:23 20m Tₓ1 C₁2_640]"; - return RaptorModuleTestCase - .of() + return RaptorModuleTestCase.of() .withRequest(r -> r.searchParams().addEgressPaths(free(STOP_F), walk(STOP_E, D3m))) .addMinDuration("19m", TX_1, T00_02, T00_30) .add(standard().manyIterations(), withoutCost(flexTransferTransit, flexAndTransit)) @@ -131,8 +131,7 @@ static List testCase1mWalkAccess() { // Min-Duration 17m var flexAndTransit = startFlexAccess + endL2AndWalk + "[0:03 0:21 18m Tₓ1 C₁2_400]"; - return RaptorModuleTestCase - .of() + return RaptorModuleTestCase.of() .withRequest(r -> r.searchParams().addEgressPaths(free(STOP_F), walk(STOP_E, D1m))) .addMinDuration("17m", TX_1, T00_02, T00_30) .add(standard().manyIterations(), withoutCost(flexAndTransit)) diff --git a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/F12_EgressWithRidesMultipleOptimalPathsTest.java b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/F12_EgressWithRidesMultipleOptimalPathsTest.java index 40e4ffd567d..2c15facf618 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/F12_EgressWithRidesMultipleOptimalPathsTest.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/F12_EgressWithRidesMultipleOptimalPathsTest.java @@ -71,7 +71,8 @@ public class F12_EgressWithRidesMultipleOptimalPathsTest implements RaptorTestCo RaptorConfig.defaultConfigForTest() ); private final TestTransitData data = new TestTransitData(); - private final RaptorRequestBuilder requestBuilder = new RaptorRequestBuilder<>(); + private final RaptorRequestBuilder requestBuilder = + new RaptorRequestBuilder<>(); @BeforeEach public void setup() { @@ -98,8 +99,7 @@ public void setup() { } static List withFlexAsBestOptionTestCases() { - return RaptorModuleTestCase - .of() + return RaptorModuleTestCase.of() // with Flex egress as the best destination arrival-time .withRequest(r -> r.searchParams().addEgressPaths(flex(STOP_C, D7m, 1, C1_10m), walk(STOP_C, D7m)) @@ -121,8 +121,7 @@ void withFlexAsBestOptionTest(RaptorModuleTestCase testCase) { } static List withWalkingAsBestOptionTestCase() { - return RaptorModuleTestCase - .of() + return RaptorModuleTestCase.of() // with walk egress as the best destination arrival-time .withRequest(r -> r.searchParams().addEgressPaths(flex(STOP_C, D7m, 1, C1_10m), walk(STOP_C, D5m)) diff --git a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/G01_AccessWithOpeningHoursTest.java b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/G01_AccessWithOpeningHoursTest.java index bf3bf359001..bbc3e386bd8 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/G01_AccessWithOpeningHoursTest.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/G01_AccessWithOpeningHoursTest.java @@ -57,7 +57,8 @@ public class G01_AccessWithOpeningHoursTest implements RaptorTestConstants { private static final String EXP_24_25 = " ~ B ~ BUS R1 0:25+1d 0:40+1d ~ E ~ Walk 1m "; private final TestTransitData data = new TestTransitData(); - private final RaptorRequestBuilder requestBuilder = new RaptorRequestBuilder<>(); + private final RaptorRequestBuilder requestBuilder = + new RaptorRequestBuilder<>(); private final RaptorService raptorService = new RaptorService<>( RaptorConfig.defaultConfigForTest() ); @@ -65,17 +66,16 @@ public class G01_AccessWithOpeningHoursTest implements RaptorTestConstants { @BeforeEach public void setup() { data.withRoute( - route("R1", STOP_B, STOP_E) - .withTimetable( - schedule("00:15 00:30"), - schedule("00:20 00:35"), - schedule("00:25 00:40"), - schedule("00:30 00:45"), - schedule("24:15 24:30"), - schedule("24:20 24:35"), - // Not within time-limit 24:42 (need 2 min for egress) - schedule("24:25 24:40") - ) + route("R1", STOP_B, STOP_E).withTimetable( + schedule("00:15 00:30"), + schedule("00:20 00:35"), + schedule("00:25 00:40"), + schedule("00:30 00:45"), + schedule("24:15 24:30"), + schedule("24:20 24:35"), + // Not within time-limit 24:42 (need 2 min for egress) + schedule("24:25 24:40") + ) ); requestBuilder.searchParams().addEgressPaths(walk(STOP_E, D1m)); @@ -263,8 +263,7 @@ public void partiallyOpenIntervalTestNextDayTest(RaptorModuleTestCase testCase) } private static List closedTestCase() { - return RaptorModuleTestCase - .of() + return RaptorModuleTestCase.of() .withRequest(r -> r .searchParams() @@ -291,8 +290,7 @@ private static RaptorModuleTestCaseFactory tcBuilderWithMinDuration( int earliestDepartureTime, int latestArrivalTime ) { - return RaptorModuleTestCase - .of() + return RaptorModuleTestCase.of() .addMinDuration("18m", TX_0, earliestDepartureTime, latestArrivalTime); } } diff --git a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/G02_EgressWithOpeningHoursTest.java b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/G02_EgressWithOpeningHoursTest.java index 994305cb0d5..bf4b6c3c88a 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/G02_EgressWithOpeningHoursTest.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/G02_EgressWithOpeningHoursTest.java @@ -46,7 +46,8 @@ public class G02_EgressWithOpeningHoursTest implements RaptorTestConstants { private static final Duration D25h = Duration.ofHours(25); private final TestTransitData data = new TestTransitData(); - private final RaptorRequestBuilder requestBuilder = new RaptorRequestBuilder<>(); + private final RaptorRequestBuilder requestBuilder = + new RaptorRequestBuilder<>(); private final RaptorService raptorService = new RaptorService<>( RaptorConfig.defaultConfigForTest() ); @@ -54,13 +55,12 @@ public class G02_EgressWithOpeningHoursTest implements RaptorTestConstants { @BeforeEach public void setup() { data.withRoute( - route("R1", STOP_A, STOP_B) - .withTimetable( - schedule("00:10 00:20"), - schedule("00:20 00:30"), - schedule("00:30 00:40"), - schedule("24:20 24:30") - ) + route("R1", STOP_A, STOP_B).withTimetable( + schedule("00:10 00:20"), + schedule("00:20 00:30"), + schedule("00:30 00:40"), + schedule("24:20 24:30") + ) ); requestBuilder.searchParams().addAccessPaths(TestAccessEgress.free(STOP_A)); @@ -82,8 +82,7 @@ private static List openNoTimeRestrictionTestCase() { "A ~ BUS R1 0:20+1d 0:30+1d ~ B ~ Walk 2m [0:20+1d 0:32+1d 12m Tₓ0]" ); - return RaptorModuleTestCase - .of() + return RaptorModuleTestCase.of() .withRequest(r -> r.searchParams().addEgressPaths(walk(STOP_B, D2m))) .addMinDuration("12m", TX_0, T00_10, T25_00) .add(TC_STANDARD, withoutCost(expected.first(3))) @@ -111,8 +110,7 @@ private static List openOneHourTestCase() { "A ~ BUS R1 0:20+1d 0:30+1d ~ B ~ Walk 2m Open(0:00 1:00) [0:20+1d 0:32+1d 12m Tₓ0 C₁1_440]" ); - return RaptorModuleTestCase - .of() + return RaptorModuleTestCase.of() .withRequest(r -> r.searchParams().addEgressPaths(walk(STOP_B, D2m).openingHours(T00_00, T01_00)) ) @@ -135,8 +133,7 @@ private static List openInWholeSearchIntervalTestNextDayTe var expected = "A ~ BUS R1 0:20+1d 0:30+1d ~ B ~ Walk 2m Open(0:00 1:00) [0:20+1d 0:32+1d 12m Tₓ0 C₁1_440]"; - return RaptorModuleTestCase - .of() + return RaptorModuleTestCase.of() .withRequest(r -> r .searchParams() @@ -161,8 +158,7 @@ private static List openInFirstHalfIntervalTestCase() { "A ~ BUS R1 0:30 0:40 ~ B ~ Walk 2m Open(0:00 0:25) [0:30 0:02+1d 23h32m Tₓ0 C₁85_440]" ); - return RaptorModuleTestCase - .of() + return RaptorModuleTestCase.of() .withRequest(r -> r.searchParams().addEgressPaths(walk(STOP_B, D2m).openingHours(T00_00, T00_25)) ) @@ -185,8 +181,7 @@ private static List openInFirstHalfIntervalTestNextDayTest var expected = "A ~ BUS R1 0:20+1d 0:30+1d ~ B ~ Walk 2m Open(0:25 0:40) [0:20+1d 0:32+1d 12m Tₓ0 C₁1_440]"; - return RaptorModuleTestCase - .of() + return RaptorModuleTestCase.of() .withRequest(r -> r .searchParams() @@ -215,8 +210,7 @@ private static List partiallyOpenIntervalTestCase() { "A ~ BUS R1 0:20+1d 0:30+1d ~ B ~ Walk 2m Open(0:25 0:35) [0:20+1d 0:32+1d 12m Tₓ0]" ); - return RaptorModuleTestCase - .of() + return RaptorModuleTestCase.of() .withRequest(r -> r.searchParams().addEgressPaths(walk(STOP_B, D2m).openingHours(T00_25, T00_35)) ) @@ -240,8 +234,7 @@ void partiallyOpenIntervalTest(RaptorModuleTestCase testCase) { } private static List closedTestCase() { - return RaptorModuleTestCase - .of() + return RaptorModuleTestCase.of() .withRequest(r -> r.searchParams().addEgressPaths(walk(STOP_B, D2m).openingHoursClosed())) .add(minDuration()) .add(standard()) diff --git a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/G03_AccessWithOpeningHoursMultipleOptionsTest.java b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/G03_AccessWithOpeningHoursMultipleOptionsTest.java index 3d36b813764..a32d09fc05a 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/G03_AccessWithOpeningHoursMultipleOptionsTest.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/G03_AccessWithOpeningHoursMultipleOptionsTest.java @@ -35,7 +35,8 @@ public class G03_AccessWithOpeningHoursMultipleOptionsTest implements RaptorTestConstants { private final TestTransitData data = new TestTransitData(); - private final RaptorRequestBuilder requestBuilder = new RaptorRequestBuilder<>(); + private final RaptorRequestBuilder requestBuilder = + new RaptorRequestBuilder<>(); private final RaptorService raptorService = new RaptorService<>( RaptorConfig.defaultConfigForTest() ); @@ -76,8 +77,7 @@ static List openInWholeSearchIntervalTestCases() { "~ Walk 2m 0:25 0:27 C₁240 " + "[0:13 0:27 14m Tₓ0 C₁1_620]"; - return RaptorModuleTestCase - .of() + return RaptorModuleTestCase.of() .addMinDuration("13m", TX_0, T00_00, T00_30) .add(TC_STANDARD, PathUtils.withoutCost(expA, expB)) .add(TC_STANDARD_ONE, PathUtils.withoutCost(expA)) diff --git a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/G04_EgressWithOpeningHoursMultipleOptionsTest.java b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/G04_EgressWithOpeningHoursMultipleOptionsTest.java index 682fff0d16c..191f18cb9ea 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/G04_EgressWithOpeningHoursMultipleOptionsTest.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/G04_EgressWithOpeningHoursMultipleOptionsTest.java @@ -32,7 +32,8 @@ public class G04_EgressWithOpeningHoursMultipleOptionsTest implements RaptorTestConstants { private final TestTransitData data = new TestTransitData(); - private final RaptorRequestBuilder requestBuilder = new RaptorRequestBuilder<>(); + private final RaptorRequestBuilder requestBuilder = + new RaptorRequestBuilder<>(); private final RaptorService raptorService = new RaptorService<>( RaptorConfig.defaultConfigForTest() ); @@ -72,8 +73,7 @@ static List openInWholeSearchIntervalTestCases() { "~ Walk 1m Open(0:22 0:24) 0:22 0:23 C₁240 " + "[0:08 0:23 15m Tₓ0 C₁1_680]"; - return RaptorModuleTestCase - .of() + return RaptorModuleTestCase.of() .add(TC_STANDARD, withoutCost(expA, expB)) //.add(TC_STANDARD_ONE, withoutCost(expA)) // TODO - Find out why the reverse Standard profiles does not return anything diff --git a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/G05_ClosedAccessOpeningHoursTest.java b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/G05_ClosedAccessOpeningHoursTest.java index 332f49c1f8f..4ba126d2fdd 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/G05_ClosedAccessOpeningHoursTest.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/G05_ClosedAccessOpeningHoursTest.java @@ -31,7 +31,8 @@ public class G05_ClosedAccessOpeningHoursTest implements RaptorTestConstants { private final TestTransitData data = new TestTransitData(); - private final RaptorRequestBuilder requestBuilder = new RaptorRequestBuilder<>(); + private final RaptorRequestBuilder requestBuilder = + new RaptorRequestBuilder<>(); private final RaptorService raptorService = new RaptorService<>( RaptorConfig.defaultConfigForTest() ); @@ -54,8 +55,7 @@ public void setup() { static List testCases() { var expected = "Walk 7m ~ A ~ BUS R1 0:10 0:20 ~ E [0:03 0:20 17m Tₓ0 C₁2_040]"; - return RaptorModuleTestCase - .of() + return RaptorModuleTestCase.of() .withRequest(r -> r.searchParams().addAccessPaths(walk(STOP_B, D2m))) .addMinDuration("17m", TX_0, T00_00, T00_30) .add(standard(), PathUtils.withoutCost(expected)) diff --git a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/G06_ClosedEgressOpeningHoursTest.java b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/G06_ClosedEgressOpeningHoursTest.java index 9b828d03de3..536c66af7d3 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/G06_ClosedEgressOpeningHoursTest.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/G06_ClosedEgressOpeningHoursTest.java @@ -31,7 +31,8 @@ public class G06_ClosedEgressOpeningHoursTest implements RaptorTestConstants { private final TestTransitData data = new TestTransitData(); - private final RaptorRequestBuilder requestBuilder = new RaptorRequestBuilder<>(); + private final RaptorRequestBuilder requestBuilder = + new RaptorRequestBuilder<>(); private final RaptorService raptorService = new RaptorService<>( RaptorConfig.defaultConfigForTest() ); @@ -55,8 +56,7 @@ public void setup() { static List testCases() { var expected = "A ~ BUS R1 0:05 0:10 ~ E ~ Walk 5m [0:05 0:15 10m Tₓ0 C₁1_500]"; - return RaptorModuleTestCase - .of() + return RaptorModuleTestCase.of() .withRequest(r -> r.searchParams().addAccessPaths(walk(STOP_B, D2m))) .addMinDuration("10m", TX_0, T00_00, T00_30) .add(standard(), PathUtils.withoutCost(expected)) diff --git a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/H11_GuaranteedTransferWithFlexAccessTest.java b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/H11_GuaranteedTransferWithFlexAccessTest.java index 64e4f728d09..795718ab9c5 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/H11_GuaranteedTransferWithFlexAccessTest.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/H11_GuaranteedTransferWithFlexAccessTest.java @@ -38,7 +38,8 @@ public class H11_GuaranteedTransferWithFlexAccessTest implements RaptorTestConst private static final int C1_ONE_STOP = RaptorCostConverter.toRaptorCost(2 * 60); private final TestTransitData data = new TestTransitData(); - private final RaptorRequestBuilder requestBuilder = new RaptorRequestBuilder<>(); + private final RaptorRequestBuilder requestBuilder = + new RaptorRequestBuilder<>(); private final RaptorService raptorService = new RaptorService<>( RaptorConfig.defaultConfigForTest() ); @@ -79,8 +80,7 @@ static List testCases() { "~ Walk 1m " + "[0:16 0:56 40m Tₓ2 C₁3_820]"; - return RaptorModuleTestCase - .of() + return RaptorModuleTestCase.of() .add(TC_MIN_DURATION, "[0:00 0:40 40m Tₓ2]") .add(TC_MIN_DURATION_REV, "[0:20 1:00 40m Tₓ2]") .add(standard(), withoutCost(expected)) diff --git a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/I01_HeuristicTest.java b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/I01_HeuristicTest.java index 1e2f79cce44..a697e458df2 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/I01_HeuristicTest.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/I01_HeuristicTest.java @@ -41,7 +41,8 @@ public class I01_HeuristicTest implements RaptorTestConstants { }; private final TestTransitData data = new TestTransitData(); - private final RaptorRequestBuilder requestBuilder = new RaptorRequestBuilder<>(); + private final RaptorRequestBuilder requestBuilder = + new RaptorRequestBuilder<>(); private final RaptorConfig config = RaptorConfig.defaultConfigForTest(); /** diff --git a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/J01_PassThroughTest.java b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/J01_PassThroughTest.java index ddfd42ff9eb..afffe46bf50 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/J01_PassThroughTest.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/J01_PassThroughTest.java @@ -193,10 +193,12 @@ void multiplePassThroughPoints() { // First one includes one pass-through stop point. // Second one include the second pass-through point. // Both arrive at the desired destination so normally there should not be any transfers. - var r1 = route("R1", STOP_A, STOP_B, STOP_C, STOP_F) - .withTimetable(schedule("0:02 0:05 0:10 0:20")); - var r2 = route("R2", STOP_C, STOP_D, STOP_E, STOP_F) - .withTimetable(schedule("0:15 0:20 0:30 0:50")); + var r1 = route("R1", STOP_A, STOP_B, STOP_C, STOP_F).withTimetable( + schedule("0:02 0:05 0:10 0:20") + ); + var r2 = route("R2", STOP_C, STOP_D, STOP_E, STOP_F).withTimetable( + schedule("0:15 0:20 0:30 0:50") + ); data.withRoutes(r1, r2); data.withTransferCost(100); @@ -224,10 +226,12 @@ void passThroughOrder() { // Create two routes. // Both include all the desired pass-through stop points but only one of them have correct order. - var r1 = route("R1", STOP_A, STOP_B, STOP_C, STOP_D) - .withTimetable(schedule("0:05 0:10 0:15 0:20")); - var r2 = route("R2", STOP_A, STOP_C, STOP_B, STOP_D) - .withTimetable(schedule("0:05 0:10 0:15 0:17")); + var r1 = route("R1", STOP_A, STOP_B, STOP_C, STOP_D).withTimetable( + schedule("0:05 0:10 0:15 0:20") + ); + var r2 = route("R2", STOP_A, STOP_C, STOP_B, STOP_D).withTimetable( + schedule("0:05 0:10 0:15 0:17") + ); data.withRoutes(r1, r2); diff --git a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/J02_ViaStopSearchTest.java b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/J02_ViaStopSearchTest.java index 2185213993b..f08cb0ffe84 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/J02_ViaStopSearchTest.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/J02_ViaStopSearchTest.java @@ -97,8 +97,10 @@ void viaSearchAlightingAtViaStop() { var data = new TestTransitData(); data.withRoutes( - route("R1", STOP_A, STOP_B, STOP_C, STOP_D) - .withTimetable(schedule("0:02 0:10 0:20 0:30"), schedule("0:12 0:20 0:30 0:40")) + route("R1", STOP_A, STOP_B, STOP_C, STOP_D).withTimetable( + schedule("0:02 0:10 0:20 0:30"), + schedule("0:12 0:20 0:30 0:40") + ) ); var requestBuilder = prepareRequest(); @@ -163,13 +165,12 @@ void accessWalkToViaStopWithoutTransit() { var data = new TestTransitData(); data.withRoutes( - route("R1", STOP_A, STOP_B, STOP_C, STOP_D) - .withTimetable( - schedule("0:02 0:05 0:10 0:15"), - // We add another trip to allow riding trip one - via B - then ride trip two, this - // is not a pareto-optimal solution and should only appear if there is something wrong. - schedule("0:12 0:15 0:20 0:25") - ) + route("R1", STOP_A, STOP_B, STOP_C, STOP_D).withTimetable( + schedule("0:02 0:05 0:10 0:15"), + // We add another trip to allow riding trip one - via B - then ride trip two, this + // is not a pareto-optimal solution and should only appear if there is something wrong. + schedule("0:12 0:15 0:20 0:25") + ) ); var requestBuilder = prepareRequest(); @@ -208,12 +209,11 @@ void transitToViaStopThenTakeEgressWalkToDestination() { var data = new TestTransitData(); data.withRoutes( - route("R1", STOP_A, STOP_B, STOP_C, STOP_D) - .withTimetable( - schedule("0:02 0:05 0:10 0:20"), - // We add another trip to check that we do not transfer to the other trip at some point. - schedule("0:12 0:15 0:20 0:25") - ) + route("R1", STOP_A, STOP_B, STOP_C, STOP_D).withTimetable( + schedule("0:02 0:05 0:10 0:20"), + // We add another trip to check that we do not transfer to the other trip at some point. + schedule("0:12 0:15 0:20 0:25") + ) ); var requestBuilder = prepareRequest(); @@ -250,15 +250,14 @@ void multipleViaPoints() { // The second one includes the second via point. // Both arrive at the desired destination, so normally there should not be any transfers. data.withRoutes( - route("R2") - .timetable( - """ + route("R2").timetable( + """ A B C D E F 0:02 0:05 0:10 0:15 0:20 0:25 0:12 0:15 0:20 0:25 0:30 0:35 0:22 0:25 0:30 0:35 0:40 0:45 """ - ) + ) ); data.withTransferCost(100); @@ -289,8 +288,18 @@ void viaSearchWithCircularLine() { var data = new TestTransitData(); data.withRoute( - route("R1", STOP_A, STOP_B, STOP_C, STOP_B, STOP_C, STOP_B, STOP_C, STOP_B, STOP_D) - .withTimetable(schedule("0:05 0:10 0:15 0:20 0:25 0:30 0:35 0:40 0:45")) + route( + "R1", + STOP_A, + STOP_B, + STOP_C, + STOP_B, + STOP_C, + STOP_B, + STOP_C, + STOP_B, + STOP_D + ).withTimetable(schedule("0:05 0:10 0:15 0:20 0:25 0:30 0:35 0:40 0:45")) ); var requestBuilder = prepareRequest(); @@ -349,8 +358,11 @@ void testMinWaitTime() { var data = new TestTransitData(); data.withRoutes( route("R1", STOP_A, STOP_B).withTimetable(schedule("0:02:00 0:04:00")), - route("R2", STOP_B, STOP_C) - .withTimetable(schedule("0:05:44 0:10"), schedule("0:05:45 0:11"), schedule("0:05:46 0:12")) + route("R2", STOP_B, STOP_C).withTimetable( + schedule("0:05:44 0:10"), + schedule("0:05:45 0:11"), + schedule("0:05:46 0:12") + ) ); var requestBuilder = prepareRequest(); diff --git a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/J03_ViaTransferSearchTest.java b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/J03_ViaTransferSearchTest.java index 7c7b4ed80e8..a84dcee3f61 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/J03_ViaTransferSearchTest.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/J03_ViaTransferSearchTest.java @@ -81,14 +81,13 @@ void viaSearchAlightingAtViaStop() { var data = new TestTransitData(); data.withRoutes( - route("R1") - .timetable( - """ - A B C D - 0:02 0:10 0:20 0:30 - 0:12 0:20 0:30 0:40 - """ - ) + route("R1").timetable( + """ + A B C D + 0:02 0:10 0:20 0:30 + 0:12 0:20 0:30 0:40 + """ + ) ); var requestBuilder = prepareRequest(); @@ -97,8 +96,7 @@ void viaSearchAlightingAtViaStop() { .searchParams() .addAccessPaths(walk(STOP_A, D30s)) .addViaLocation( - RaptorViaLocation - .via("B") + RaptorViaLocation.via("B") .addViaTransfer(STOP_B, TestTransfer.transfer(STOP_B, D1m)) .build() ) @@ -122,14 +120,17 @@ void viaSearchArrivingByTransferAtViaStop() { var data = new TestTransitData(); data.withRoutes( - route("R1", STOP_A, STOP_B, STOP_D).withTimetable(""" + route("R1", STOP_A, STOP_B, STOP_D).withTimetable( + """ 0:02 0:10 0:12 - """), - route("R2", STOP_C, STOP_D, STOP_E) - .withTimetable(""" + """ + ), + route("R2", STOP_C, STOP_D, STOP_E).withTimetable( + """ 0:10 0:13 0:15 0:12 0:15 0:17 - """) + """ + ) ); var requestBuilder = prepareRequest(); @@ -162,10 +163,12 @@ void viaTransferSearchNotFollowedByRegularTransfer() { .withRoutes( route("R1", STOP_A, STOP_B).withTimetable("0:02 0:10"), route("R2", STOP_C, STOP_D).withTimetable("0:12 0:15"), - route("R2", STOP_E, STOP_F).withTimetable(""" - 0:15 0:17 - 0:17 0:15 - """) + route("R2", STOP_E, STOP_F).withTimetable( + """ + 0:15 0:17 + 0:17 0:15 + """ + ) ) .withTransfer(STOP_C, transfer(STOP_E, D1m)) .withTransfer(STOP_D, transfer(STOP_E, D1m)); @@ -196,15 +199,14 @@ void testMinWaitTime() { var data = new TestTransitData(); data.withRoutes( route("R1", STOP_A, STOP_B).withTimetable("0:02:00 0:04:00"), - route("R2") - .timetable( - """ + route("R2").timetable( + """ B C 0:05:44 0:10 0:05:45 0:11 0:05:46 0:12 """ - ) + ) ); var requestBuilder = prepareRequest(); @@ -215,8 +217,7 @@ void testMinWaitTime() { .addAccessPaths(walk(STOP_A, D30s)) .addViaLocations( List.of( - RaptorViaLocation - .via("B", minWaitTime) + RaptorViaLocation.via("B", minWaitTime) .addViaTransfer(STOP_B, transfer(STOP_B, D20s)) .build() ) diff --git a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/K01_TransitPriorityTest.java b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/K01_TransitPriorityTest.java index 4a08634db93..1737dff6d9b 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/K01_TransitPriorityTest.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/K01_TransitPriorityTest.java @@ -39,7 +39,8 @@ public class K01_TransitPriorityTest { private static final int C1_SLACK_90s = RaptorCostConverter.toRaptorCost(90); private final TestTransitData data = new TestTransitData(); - private final RaptorRequestBuilder requestBuilder = new RaptorRequestBuilder<>(); + private final RaptorRequestBuilder requestBuilder = + new RaptorRequestBuilder<>(); private final RaptorService raptorService = new RaptorService<>( RaptorConfig.defaultConfigForTest() ); @@ -54,14 +55,18 @@ public class K01_TransitPriorityTest { @BeforeEach private void prepareRequest() { data.withRoutes( - route(TestTripPattern.of("L1", STOP_B, STOP_C).priorityGroup(GROUP_A).build()) - .withTimetable(schedule("00:02 00:12")), - route(TestTripPattern.of("U1", STOP_B, STOP_C).priorityGroup(GROUP_A).build()) - .withTimetable(schedule("00:02 00:12:01")), - route(TestTripPattern.of("L2", STOP_B, STOP_C).priorityGroup(GROUP_B).build()) - .withTimetable(schedule("00:02 00:13")), - route(TestTripPattern.of("L3", STOP_B, STOP_C).priorityGroup(GROUP_C).build()) - .withTimetable(schedule("00:02 00:14")) + route(TestTripPattern.of("L1", STOP_B, STOP_C).priorityGroup(GROUP_A).build()).withTimetable( + schedule("00:02 00:12") + ), + route(TestTripPattern.of("U1", STOP_B, STOP_C).priorityGroup(GROUP_A).build()).withTimetable( + schedule("00:02 00:12:01") + ), + route(TestTripPattern.of("L2", STOP_B, STOP_C).priorityGroup(GROUP_B).build()).withTimetable( + schedule("00:02 00:13") + ), + route(TestTripPattern.of("L3", STOP_B, STOP_C).priorityGroup(GROUP_C).build()).withTimetable( + schedule("00:02 00:14") + ) ); requestBuilder diff --git a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/K02_TransitPriorityDestinationTest.java b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/K02_TransitPriorityDestinationTest.java index e6d1fc38d12..8277139d86a 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/K02_TransitPriorityDestinationTest.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/K02_TransitPriorityDestinationTest.java @@ -42,7 +42,8 @@ public class K02_TransitPriorityDestinationTest { private static final int C1_SLACK_90s = RaptorCostConverter.toRaptorCost(90); private final TestTransitData data = new TestTransitData(); - private final RaptorRequestBuilder requestBuilder = new RaptorRequestBuilder<>(); + private final RaptorRequestBuilder requestBuilder = + new RaptorRequestBuilder<>(); private final RaptorService raptorService = new RaptorService<>( RaptorConfig.defaultConfigForTest() ); @@ -56,14 +57,18 @@ private void prepareRequest() { // they are in different groups), but not L3 (which certainly is in its own group but // its cost is outside the range allowed by the slack). data.withRoutes( - route(TestTripPattern.of("L1", STOP_B, STOP_C).priorityGroup(GROUP_A).build()) - .withTimetable(schedule("00:02 00:12")), - route(TestTripPattern.of("U1", STOP_B, STOP_D).priorityGroup(GROUP_A).build()) - .withTimetable(schedule("00:02 00:12:01")), - route(TestTripPattern.of("L2", STOP_B, STOP_E).priorityGroup(GROUP_B).build()) - .withTimetable(schedule("00:02 00:13")), - route(TestTripPattern.of("L3", STOP_B, STOP_F).priorityGroup(GROUP_C).build()) - .withTimetable(schedule("00:02 00:14")) + route(TestTripPattern.of("L1", STOP_B, STOP_C).priorityGroup(GROUP_A).build()).withTimetable( + schedule("00:02 00:12") + ), + route(TestTripPattern.of("U1", STOP_B, STOP_D).priorityGroup(GROUP_A).build()).withTimetable( + schedule("00:02 00:12:01") + ), + route(TestTripPattern.of("L2", STOP_B, STOP_E).priorityGroup(GROUP_B).build()).withTimetable( + schedule("00:02 00:13") + ), + route(TestTripPattern.of("L3", STOP_B, STOP_F).priorityGroup(GROUP_C).build()).withTimetable( + schedule("00:02 00:14") + ) ); requestBuilder diff --git a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/L01_TimePenaltyAccessTest.java b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/L01_TimePenaltyAccessTest.java index a4753cc2c17..7c27f49f1c2 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/L01_TimePenaltyAccessTest.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/L01_TimePenaltyAccessTest.java @@ -46,7 +46,8 @@ public class L01_TimePenaltyAccessTest implements RaptorTestConstants { // There are 5 possible trips private final TestTransitData data = new TestTransitData(); - private final RaptorRequestBuilder requestBuilder = new RaptorRequestBuilder<>(); + private final RaptorRequestBuilder requestBuilder = + new RaptorRequestBuilder<>(); private final RaptorService raptorService = new RaptorService<>( RaptorConfig.defaultConfigForTest() ); @@ -73,8 +74,7 @@ private static List tripsAtTheEndOfTheSearchWindowTestCase "Walk 2m 0:09 0:11 C₁240 ~ A 0s ~ BUS R1 0:11 .. [0:09 0:42 33m Tₓ0 C₁2_760]" ); - return RaptorModuleTestCase - .of() + return RaptorModuleTestCase.of() .withRequest(r -> r.searchParams().earliestDepartureTime(edt).latestArrivalTime(lat).searchWindow(D8m) ) @@ -109,8 +109,7 @@ private static List tripsAtTheBeginningOfTheSearchWindowTe "Walk 2m 0:17 0:19 C₁240 ~ A 0s ~ BUS R1 0:19 .. [0:17 0:50 33m Tₓ0 C₁2_760]" ); - return RaptorModuleTestCase - .of() + return RaptorModuleTestCase.of() .withRequest(r -> r.searchParams().earliestDepartureTime(edt).latestArrivalTime(lat).searchWindow(D8m) ) @@ -142,8 +141,7 @@ public static String focusOnAccess(String path) { var p = Pattern.compile("(.+BUS R1 \\d+:\\d+).+(\\[.+)"); String[] lines = path.split("\n"); - return Stream - .of(lines) + return Stream.of(lines) .map(s -> { var m = p.matcher(s); return m.find() ? m.group(1) + " .. " + m.group(2) : s; diff --git a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/L01_TimePenaltyEgressTest.java b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/L01_TimePenaltyEgressTest.java index d75b91c7aee..07d32a1cf24 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/L01_TimePenaltyEgressTest.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/L01_TimePenaltyEgressTest.java @@ -49,7 +49,8 @@ public class L01_TimePenaltyEgressTest implements RaptorTestConstants { // There are 5 possible trips private final TestTransitData data = new TestTransitData(); - private final RaptorRequestBuilder requestBuilder = new RaptorRequestBuilder<>(); + private final RaptorRequestBuilder requestBuilder = + new RaptorRequestBuilder<>(); private final RaptorService raptorService = new RaptorService<>( RaptorConfig.defaultConfigForTest() ); @@ -78,8 +79,7 @@ private static List firstTwoPathsArriveBeforeLAT() { "BUS R1 0:11 0:41 30m ~ B 0s ~ Walk 2m 0:41 0:43 [0:10 0:43 33m Tₓ0]" ); - return RaptorModuleTestCase - .of() + return RaptorModuleTestCase.of() .withRequest(r -> r.searchParams().earliestDepartureTime(edt).latestArrivalTime(lat).searchWindow(D8m) ) @@ -112,8 +112,7 @@ private static List lastTwoPathsDepartsAfterEDT() { "BUS R1 0:19 0:49 30m ~ B 0s ~ Walk 2m 0:49 0:51 [0:18 0:51 33m Tₓ0]" ); - return RaptorModuleTestCase - .of() + return RaptorModuleTestCase.of() .withRequest(r -> r.searchParams().earliestDepartureTime(edt).latestArrivalTime(lat).searchWindow(D8m) ) @@ -146,8 +145,7 @@ public static String focusOnEgress(String path) { // BUS R1 0:18 0:48 30m ~ B 0s ~ Walk 1m 0:48 0:49 .. [0:16 0:49 33m Tₓ0] String[] lines = path.split("\n"); - return Stream - .of(lines) + return Stream.of(lines) .map(s -> { int pos = s.indexOf("BUS"); return pos > 0 ? s.substring(pos) : s; diff --git a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/support/RaptorModuleTestCaseFactory.java b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/support/RaptorModuleTestCaseFactory.java index 937acd7fcc4..395d7d01813 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/support/RaptorModuleTestCaseFactory.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/support/RaptorModuleTestCaseFactory.java @@ -58,8 +58,7 @@ public RaptorModuleTestCaseFactory addMinDuration( earliestDepartureTime, earliestDepartureTime + durationSec, nTransfers - ) - .toString() + ).toString() ); add( TC_MIN_DURATION_REV, @@ -67,8 +66,7 @@ public RaptorModuleTestCaseFactory addMinDuration( latestArrivalTime, latestArrivalTime - durationSec, nTransfers - ) - .toString() + ).toString() ); return this; } diff --git a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/support/TestGroupPriorityCalculator.java b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/support/TestGroupPriorityCalculator.java index 3debd487345..6ea74b5ecd2 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/moduletests/support/TestGroupPriorityCalculator.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/moduletests/support/TestGroupPriorityCalculator.java @@ -9,7 +9,8 @@ public class TestGroupPriorityCalculator implements RaptorTransitGroupPriorityCalculator { - public static final RaptorTransitGroupPriorityCalculator PRIORITY_CALCULATOR = new TestGroupPriorityCalculator(); + public static final RaptorTransitGroupPriorityCalculator PRIORITY_CALCULATOR = + new TestGroupPriorityCalculator(); public static final int GROUP_A = 0x01; public static final int GROUP_B = 0x02; diff --git a/raptor/src/test/java/org/opentripplanner/raptor/rangeraptor/context/SearchContextTest.java b/raptor/src/test/java/org/opentripplanner/raptor/rangeraptor/context/SearchContextTest.java index 4ffa4ed1cd9..d94721315d2 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/rangeraptor/context/SearchContextTest.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/rangeraptor/context/SearchContextTest.java @@ -37,7 +37,8 @@ class SearchContextTest implements RaptorTestConstants { private final RaptorAccessEgress PATH_B = TestAccessEgress.walk(STOP_B, D1m); private final RaptorAccessEgress PATH_C_30s = TestAccessEgress.walk(STOP_C, D30s); private final RaptorAccessEgress PATH_C_40s = TestAccessEgress.walk(STOP_C, D40s); - private final RaptorRequestBuilder requestBuilder = new RaptorRequestBuilder<>(); + private final RaptorRequestBuilder requestBuilder = + new RaptorRequestBuilder<>(); @BeforeEach void setup() { diff --git a/raptor/src/test/java/org/opentripplanner/raptor/rangeraptor/internalapi/NoopPassThroughPointsServiceTest.java b/raptor/src/test/java/org/opentripplanner/raptor/rangeraptor/internalapi/NoopPassThroughPointsServiceTest.java index 1ed50477166..00d5ebc2e47 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/rangeraptor/internalapi/NoopPassThroughPointsServiceTest.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/rangeraptor/internalapi/NoopPassThroughPointsServiceTest.java @@ -21,9 +21,8 @@ void isPassThroughPoint() { @Test void updateC2Value() { - assertThrows( - UnsupportedOperationException.class, - () -> PassThroughPointsService.NOOP.updateC2Value(1000, i -> fail()) + assertThrows(UnsupportedOperationException.class, () -> + PassThroughPointsService.NOOP.updateC2Value(1000, i -> fail()) ); } diff --git a/raptor/src/test/java/org/opentripplanner/raptor/rangeraptor/multicriteria/StopArrivalStateParetoSetTest.java b/raptor/src/test/java/org/opentripplanner/raptor/rangeraptor/multicriteria/StopArrivalStateParetoSetTest.java index 60fa14e9385..fa0a14ea46a 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/rangeraptor/multicriteria/StopArrivalStateParetoSetTest.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/rangeraptor/multicriteria/StopArrivalStateParetoSetTest.java @@ -28,9 +28,9 @@ public class StopArrivalStateParetoSetTest { private static final int ROUND_1 = 1; private static final int ROUND_2 = 2; private static final int ROUND_3 = 3; - private static final RaptorTripSchedule ANY_TRIP = TestTripSchedule - .schedule("10:00 10:30") - .build(); + private static final RaptorTripSchedule ANY_TRIP = TestTripSchedule.schedule( + "10:00 10:30" + ).build(); // In this test, each stop is used to identify the pareto vector - it is just one // ParetoSet "subject" with multiple "stops" in it. The stop has no effect on @@ -45,7 +45,8 @@ public class StopArrivalStateParetoSetTest { // Make sure all "base" arrivals have the same cost private static final int BASE_C1 = 1; - private static final StopArrivalFactoryC1 STOP_ARRIVAL_FACTORY = new StopArrivalFactoryC1<>(); + private static final StopArrivalFactoryC1 STOP_ARRIVAL_FACTORY = + new StopArrivalFactoryC1<>(); private static final McStopArrival ACCESS_ARRIVAL = newAccessStopState( 999, 5, @@ -65,13 +66,13 @@ public class StopArrivalStateParetoSetTest { 20, BASE_C1 ); - public static final ArrivalParetoSetComparatorFactory> COMPARATOR_FACTORY = ArrivalParetoSetComparatorFactory.factory( - RelaxFunction.NORMAL, - null - ); + public static final ArrivalParetoSetComparatorFactory< + McStopArrival + > COMPARATOR_FACTORY = ArrivalParetoSetComparatorFactory.factory(RelaxFunction.NORMAL, null); private static Stream testCases() { - ParetoComparator> comparator = COMPARATOR_FACTORY.compareArrivalTimeRoundAndCost(); + ParetoComparator> comparator = + COMPARATOR_FACTORY.compareArrivalTimeRoundAndCost(); return Stream.of( Arguments.of("Stop Arrival - regular", StopArrivalParetoSet.of(comparator).build()), Arguments.of( @@ -161,7 +162,8 @@ public void testRoundAndTimeDominance( */ @Test public void testTransitAndTransferDoesNotAffectDominance() { - ParetoComparator> comparator = COMPARATOR_FACTORY.compareArrivalTimeRoundAndCost(); + ParetoComparator> comparator = + COMPARATOR_FACTORY.compareArrivalTimeRoundAndCost(); var subject = StopArrivalParetoSet.of(comparator).build(); subject.add(newAccessStopState(STOP_1, 20, ANY)); subject.add(newTransitStopState(ROUND_1, STOP_2, 10, ANY)); @@ -177,8 +179,9 @@ public void testTransitAndTransferDoesNotAffectDominance() { */ @Test public void testTransitAndTransferDoesAffectDominanceForStopArrivalsWithEgress() { - var subject = StopArrivalParetoSet - .of(COMPARATOR_FACTORY.compareArrivalTimeRoundCostAndOnBoardArrival()) + var subject = StopArrivalParetoSet.of( + COMPARATOR_FACTORY.compareArrivalTimeRoundCostAndOnBoardArrival() + ) .withEgressListener(List.of(), null) .build(); subject.add(newAccessStopState(STOP_1, 20, ANY)); diff --git a/raptor/src/test/java/org/opentripplanner/raptor/rangeraptor/multicriteria/arrivals/ArrivalParetoSetComparatorFactoryTest.java b/raptor/src/test/java/org/opentripplanner/raptor/rangeraptor/multicriteria/arrivals/ArrivalParetoSetComparatorFactoryTest.java index 5fd19fc07f5..36e8c1f904c 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/rangeraptor/multicriteria/arrivals/ArrivalParetoSetComparatorFactoryTest.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/rangeraptor/multicriteria/arrivals/ArrivalParetoSetComparatorFactoryTest.java @@ -21,15 +21,11 @@ class ArrivalParetoSetComparatorFactoryTest { private static final int ARRIVAL_TIME_EARLY = 12; private static final int ARRIVAL_TIME_LATE = 13; - private static final ArrivalParetoSetComparatorFactory comparatorC1 = ArrivalParetoSetComparatorFactory.factory( - RelaxFunction.NORMAL, - null - ); + private static final ArrivalParetoSetComparatorFactory comparatorC1 = + ArrivalParetoSetComparatorFactory.factory(RelaxFunction.NORMAL, null); - private static final ArrivalParetoSetComparatorFactory comparatorC1AndC2 = ArrivalParetoSetComparatorFactory.factory( - RelaxFunction.NORMAL, - (left, right) -> left > right - ); + private static final ArrivalParetoSetComparatorFactory comparatorC1AndC2 = + ArrivalParetoSetComparatorFactory.factory(RelaxFunction.NORMAL, (left, right) -> left > right); @Test void compareArrivalTimeRoundAndCost() { diff --git a/raptor/src/test/java/org/opentripplanner/raptor/rangeraptor/multicriteria/arrivals/c1/AccessStopArrivalTest.java b/raptor/src/test/java/org/opentripplanner/raptor/rangeraptor/multicriteria/arrivals/c1/AccessStopArrivalTest.java index 7abb1910ed9..13964383689 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/rangeraptor/multicriteria/arrivals/c1/AccessStopArrivalTest.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/rangeraptor/multicriteria/arrivals/c1/AccessStopArrivalTest.java @@ -112,9 +112,10 @@ public void timeShiftPartiallyAllowed() { McStopArrival original, result; // Allow time-shift, but only by dTime (a free edge has zero duration) - RaptorAccessEgress access = TestAccessEgress - .free(ALIGHT_STOP) - .openingHours(0, ALIGHT_TIME + dTime); + RaptorAccessEgress access = TestAccessEgress.free(ALIGHT_STOP).openingHours( + 0, + ALIGHT_TIME + dTime + ); original = new AccessStopArrival<>(DEPARTURE_TIME, access); diff --git a/raptor/src/test/java/org/opentripplanner/raptor/rangeraptor/multicriteria/arrivals/c1/StopArrivalFactoryC1Test.java b/raptor/src/test/java/org/opentripplanner/raptor/rangeraptor/multicriteria/arrivals/c1/StopArrivalFactoryC1Test.java index 4d18cde5232..9e085d85e53 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/rangeraptor/multicriteria/arrivals/c1/StopArrivalFactoryC1Test.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/rangeraptor/multicriteria/arrivals/c1/StopArrivalFactoryC1Test.java @@ -29,8 +29,7 @@ public class StopArrivalFactoryC1Test { private static final int STOP_ARRIVAL_TRANSIT_C1 = 63000; private static final TestAccessEgress ACCESS = TestAccessEgress.walk(STOP_A, ACCESS_DURATION); - private static final TestTripSchedule TRIP = TestTripSchedule - .schedule("10:03 10:10") + private static final TestTripSchedule TRIP = TestTripSchedule.schedule("10:03 10:10") .pattern(TestTripPattern.pattern("Line A", STOP_A, STOP_B)) .build(); diff --git a/raptor/src/test/java/org/opentripplanner/raptor/rangeraptor/multicriteria/arrivals/c1/TransferStopArrivalTest.java b/raptor/src/test/java/org/opentripplanner/raptor/rangeraptor/multicriteria/arrivals/c1/TransferStopArrivalTest.java index e3baf5e797b..1a4d4f6b190 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/rangeraptor/multicriteria/arrivals/c1/TransferStopArrivalTest.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/rangeraptor/multicriteria/arrivals/c1/TransferStopArrivalTest.java @@ -45,18 +45,17 @@ class TransferStopArrivalTest { private static final int EXPECTED_C1 = ACCESS_C1 + TRANSIT_C1 + TRANSFER_C1; - private static final AccessStopArrival ACCESS_ARRIVAL = new AccessStopArrival<>( - ACCESS_DEPARTURE_TIME, - ACCESS_WALK - ); - - private static final TransitStopArrival TRANSIT_ARRIVAL = new TransitStopArrival<>( - ACCESS_ARRIVAL.timeShiftNewArrivalTime(TRANSIT_BOARD_TIME - BOARD_SLACK), - TRANSIT_TO_STOP, - TRANSIT_ALIGHT_TIME, - ACCESS_ARRIVAL.c1() + TRANSIT_C1, - TRANSIT_TRIP - ); + private static final AccessStopArrival ACCESS_ARRIVAL = + new AccessStopArrival<>(ACCESS_DEPARTURE_TIME, ACCESS_WALK); + + private static final TransitStopArrival TRANSIT_ARRIVAL = + new TransitStopArrival<>( + ACCESS_ARRIVAL.timeShiftNewArrivalTime(TRANSIT_BOARD_TIME - BOARD_SLACK), + TRANSIT_TO_STOP, + TRANSIT_ALIGHT_TIME, + ACCESS_ARRIVAL.c1() + TRANSIT_C1, + TRANSIT_TRIP + ); private final TransferStopArrival subject = new TransferStopArrival<>( TRANSIT_ARRIVAL, diff --git a/raptor/src/test/java/org/opentripplanner/raptor/rangeraptor/multicriteria/arrivals/c1/TransitStopArrivalTest.java b/raptor/src/test/java/org/opentripplanner/raptor/rangeraptor/multicriteria/arrivals/c1/TransitStopArrivalTest.java index 1bebfc1e798..0fe7f3f5c98 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/rangeraptor/multicriteria/arrivals/c1/TransitStopArrivalTest.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/rangeraptor/multicriteria/arrivals/c1/TransitStopArrivalTest.java @@ -24,16 +24,13 @@ class TransitStopArrivalTest { ACCESS_DURATION ); private static final int ACCESS_C1 = ACCESS_WALK.c1(); - private static final AccessStopArrival ACCESS_ARRIVAL = new AccessStopArrival<>( - ACCESS_DEPARTURE_TIME, - ACCESS_WALK - ); + private static final AccessStopArrival ACCESS_ARRIVAL = + new AccessStopArrival<>(ACCESS_DEPARTURE_TIME, ACCESS_WALK); private static final int TRANSIT_TO_STOP = 101; private static final int TRANSIT_BOARD_TIME = 9 * 60 * 60; private static final int TRANSIT_LEG_DURATION = 1200; private static final int TRANSIT_ALIGHT_TIME = TRANSIT_BOARD_TIME + TRANSIT_LEG_DURATION; - private static final RaptorTripSchedule TRANSIT_TRIP = TestTripSchedule - .schedule(pattern("T1", 0)) + private static final RaptorTripSchedule TRANSIT_TRIP = TestTripSchedule.schedule(pattern("T1", 0)) .arrivals(TRANSIT_ALIGHT_TIME) .build(); private static final int TRANSIT_TRAVEL_DURATION = diff --git a/raptor/src/test/java/org/opentripplanner/raptor/rangeraptor/multicriteria/arrivals/c2/AccessStopArrivalC2Test.java b/raptor/src/test/java/org/opentripplanner/raptor/rangeraptor/multicriteria/arrivals/c2/AccessStopArrivalC2Test.java index 371eb2921bc..14401dc0040 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/rangeraptor/multicriteria/arrivals/c2/AccessStopArrivalC2Test.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/rangeraptor/multicriteria/arrivals/c2/AccessStopArrivalC2Test.java @@ -111,9 +111,10 @@ public void timeShiftPartiallyAllowed() { McStopArrival original, result; // Allow time-shift, but only by dTime (a free edge has zero duration) - RaptorAccessEgress access = TestAccessEgress - .free(ALIGHT_STOP) - .openingHours(0, ALIGHT_TIME + dTime); + RaptorAccessEgress access = TestAccessEgress.free(ALIGHT_STOP).openingHours( + 0, + ALIGHT_TIME + dTime + ); original = new AccessStopArrivalC2<>(DEPARTURE_TIME, access); diff --git a/raptor/src/test/java/org/opentripplanner/raptor/rangeraptor/multicriteria/arrivals/c2/StopArrivalFactoryC2Test.java b/raptor/src/test/java/org/opentripplanner/raptor/rangeraptor/multicriteria/arrivals/c2/StopArrivalFactoryC2Test.java index c71ca7fee11..b206b47522c 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/rangeraptor/multicriteria/arrivals/c2/StopArrivalFactoryC2Test.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/rangeraptor/multicriteria/arrivals/c2/StopArrivalFactoryC2Test.java @@ -30,8 +30,7 @@ public class StopArrivalFactoryC2Test { private static final int RIDE_C2 = 5; private static final TestAccessEgress ACCESS = TestAccessEgress.walk(STOP_A, ACCESS_DURATION); - private static final TestTripSchedule TRIP = TestTripSchedule - .schedule("10:03 10:10") + private static final TestTripSchedule TRIP = TestTripSchedule.schedule("10:03 10:10") .pattern(TestTripPattern.pattern("Line A", STOP_A, STOP_B)) .build(); diff --git a/raptor/src/test/java/org/opentripplanner/raptor/rangeraptor/multicriteria/arrivals/c2/TransferStopArrivalC2Test.java b/raptor/src/test/java/org/opentripplanner/raptor/rangeraptor/multicriteria/arrivals/c2/TransferStopArrivalC2Test.java index a8abe5bdddb..4ea1b316ff9 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/rangeraptor/multicriteria/arrivals/c2/TransferStopArrivalC2Test.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/rangeraptor/multicriteria/arrivals/c2/TransferStopArrivalC2Test.java @@ -44,19 +44,18 @@ class TransferStopArrivalC2Test { private static final int TRANSIT_C2 = 6; - private static final AccessStopArrivalC2 ACCESS_ARRIVAL = new AccessStopArrivalC2<>( - ACCESS_DEPARTURE_TIME, - ACCESS_WALK - ); - - private static final TransitStopArrivalC2 TRANSIT_ARRIVAL = new TransitStopArrivalC2<>( - ACCESS_ARRIVAL.timeShiftNewArrivalTime(TRANSIT_BOARD_TIME - BOARD_SLACK), - TRANSIT_TO_STOP, - TRANSIT_ALIGHT_TIME, - ACCESS_ARRIVAL.c1() + TRANSIT_C1, - TRANSIT_C2, - TRANSIT_TRIP - ); + private static final AccessStopArrivalC2 ACCESS_ARRIVAL = + new AccessStopArrivalC2<>(ACCESS_DEPARTURE_TIME, ACCESS_WALK); + + private static final TransitStopArrivalC2 TRANSIT_ARRIVAL = + new TransitStopArrivalC2<>( + ACCESS_ARRIVAL.timeShiftNewArrivalTime(TRANSIT_BOARD_TIME - BOARD_SLACK), + TRANSIT_TO_STOP, + TRANSIT_ALIGHT_TIME, + ACCESS_ARRIVAL.c1() + TRANSIT_C1, + TRANSIT_C2, + TRANSIT_TRIP + ); private final TransferStopArrivalC2 subject = new TransferStopArrivalC2<>( TRANSIT_ARRIVAL, diff --git a/raptor/src/test/java/org/opentripplanner/raptor/rangeraptor/multicriteria/arrivals/c2/TransitStopArrivalC2Test.java b/raptor/src/test/java/org/opentripplanner/raptor/rangeraptor/multicriteria/arrivals/c2/TransitStopArrivalC2Test.java index 8ddf4530c56..58c1022ab6d 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/rangeraptor/multicriteria/arrivals/c2/TransitStopArrivalC2Test.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/rangeraptor/multicriteria/arrivals/c2/TransitStopArrivalC2Test.java @@ -23,16 +23,13 @@ class TransitStopArrivalC2Test { ACCESS_DURATION ); private static final int ACCESS_C1 = ACCESS_WALK.c1(); - private static final AccessStopArrivalC2 ACCESS_ARRIVAL = new AccessStopArrivalC2<>( - ACCESS_DEPARTURE_TIME, - ACCESS_WALK - ); + private static final AccessStopArrivalC2 ACCESS_ARRIVAL = + new AccessStopArrivalC2<>(ACCESS_DEPARTURE_TIME, ACCESS_WALK); private static final int TRANSIT_TO_STOP = 101; private static final int TRANSIT_BOARD_TIME = 9 * 60 * 60; private static final int TRANSIT_LEG_DURATION = 1200; private static final int TRANSIT_ALIGHT_TIME = TRANSIT_BOARD_TIME + TRANSIT_LEG_DURATION; - private static final RaptorTripSchedule TRANSIT_TRIP = TestTripSchedule - .schedule(pattern("T1", 0)) + private static final RaptorTripSchedule TRANSIT_TRIP = TestTripSchedule.schedule(pattern("T1", 0)) .arrivals(TRANSIT_ALIGHT_TIME) .build(); private static final int TRANSIT_TRAVEL_DURATION = diff --git a/raptor/src/test/java/org/opentripplanner/raptor/rangeraptor/multicriteria/passthrough/BitSetPassThroughPointsServiceTest.java b/raptor/src/test/java/org/opentripplanner/raptor/rangeraptor/multicriteria/passthrough/BitSetPassThroughPointsServiceTest.java index 53e76668037..e781c6142ba 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/rangeraptor/multicriteria/passthrough/BitSetPassThroughPointsServiceTest.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/rangeraptor/multicriteria/passthrough/BitSetPassThroughPointsServiceTest.java @@ -58,25 +58,19 @@ static Stream passThroughPointTestCases() { void passThroughPointTest(int expectedSeqNr, boolean isPassThroughPoint, int stopIndex) { assertEquals(isPassThroughPoint, SUBJECT.isPassThroughPoint(stopIndex)); AtomicBoolean c2Updated = new AtomicBoolean(false); - SUBJECT.updateC2Value( - expectedSeqNr - 1, - newC2 -> { - assertEquals(expectedSeqNr, newC2); - c2Updated.set(true); - } - ); + SUBJECT.updateC2Value(expectedSeqNr - 1, newC2 -> { + assertEquals(expectedSeqNr, newC2); + c2Updated.set(true); + }); assertTrue(c2Updated.get(), "The c2 update is not performed"); - SUBJECT.updateC2Value( - expectedSeqNr - 2, - newC2 -> fail("A visited pass-through-point should not increase the c2. New C2: " + newC2) + SUBJECT.updateC2Value(expectedSeqNr - 2, newC2 -> + fail("A visited pass-through-point should not increase the c2. New C2: " + newC2) ); - SUBJECT.updateC2Value( - expectedSeqNr, - newC2 -> - fail( - "A pass-through-point where the previous point is not visited should not increase the C2. New C2: " + - newC2 - ) + SUBJECT.updateC2Value(expectedSeqNr, newC2 -> + fail( + "A pass-through-point where the previous point is not visited should not increase the C2. New C2: " + + newC2 + ) ); assertTrue(SUBJECT.acceptC2AtDestination().test(EXPECTED_C2_AT_DESTINATION)); assertFalse(SUBJECT.acceptC2AtDestination().test(EXPECTED_C2_AT_DESTINATION - 1)); diff --git a/raptor/src/test/java/org/opentripplanner/raptor/rangeraptor/path/DestinationArrivalTest.java b/raptor/src/test/java/org/opentripplanner/raptor/rangeraptor/path/DestinationArrivalTest.java index af2aa88fb5c..5b57e678d38 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/rangeraptor/path/DestinationArrivalTest.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/rangeraptor/path/DestinationArrivalTest.java @@ -36,22 +36,22 @@ public class DestinationArrivalTest { private static final int EXPECTED_ARRIVAL_TIME = TRANSIT_ALIGHT_TIME + DESTINATION_DURATION_TIME; private static final int EXPECTED_TOTAL_COST = ACCESS_COST + TRANSIT_COST + DESTINATION_C1; - private static final StopArrivalFactoryC1 STOP_ARRIVAL_FACTORY = new StopArrivalFactoryC1(); + private static final StopArrivalFactoryC1 STOP_ARRIVAL_FACTORY = + new StopArrivalFactoryC1(); /** * Setup a simple journey with an access leg, one transit and a egress leg. */ - private static final McStopArrival ACCESS_ARRIVAL = STOP_ARRIVAL_FACTORY.createAccessStopArrival( - ACCESS_DEPARTURE_TIME, - ACCESS_WALK - ); - - private static final ArrivalView TRANSIT_ARRIVAL = STOP_ARRIVAL_FACTORY.createTransitStopArrival( - new PatternRideC1<>(ACCESS_ARRIVAL, ANY, ANY, ANY, ANY, ANY, ANY, A_TRIP), - TRANSIT_STOP, - TRANSIT_ALIGHT_TIME, - ACCESS_ARRIVAL.c1() + TRANSIT_COST - ); + private static final McStopArrival ACCESS_ARRIVAL = + STOP_ARRIVAL_FACTORY.createAccessStopArrival(ACCESS_DEPARTURE_TIME, ACCESS_WALK); + + private static final ArrivalView TRANSIT_ARRIVAL = + STOP_ARRIVAL_FACTORY.createTransitStopArrival( + new PatternRideC1<>(ACCESS_ARRIVAL, ANY, ANY, ANY, ANY, ANY, ANY, A_TRIP), + TRANSIT_STOP, + TRANSIT_ALIGHT_TIME, + ACCESS_ARRIVAL.c1() + TRANSIT_COST + ); private final DestinationArrival subject = new DestinationArrival<>( TestAccessEgress.walk(TRANSIT_STOP, DESTINATION_DURATION_TIME), diff --git a/raptor/src/test/java/org/opentripplanner/raptor/rangeraptor/transit/AccessEgressFunctionsTest.java b/raptor/src/test/java/org/opentripplanner/raptor/rangeraptor/transit/AccessEgressFunctionsTest.java index 1d4f90557b0..bd025c2155c 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/rangeraptor/transit/AccessEgressFunctionsTest.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/rangeraptor/transit/AccessEgressFunctionsTest.java @@ -39,13 +39,17 @@ class AccessEgressFunctionsTest implements RaptorTestConstants { private static final RaptorAccessEgress FLEX_1x_8m = flex(STOP, D8m, 1, C1); private static final RaptorAccessEgress FLEX_2x_8m = flex(STOP, D8m, 2, C1); private static final RaptorAccessEgress FLEX_AND_WALK_1x_8m = flexAndWalk(STOP, D8m, 1, C1); - private static final RaptorAccessEgress WALK_W_OPENING_HOURS_8m = TestAccessEgress - .walk(STOP, D8m, C1) - .openingHours(T00_00, T01_00); + private static final RaptorAccessEgress WALK_W_OPENING_HOURS_8m = TestAccessEgress.walk( + STOP, + D8m, + C1 + ).openingHours(T00_00, T01_00); - private static final RaptorAccessEgress WALK_W_OPENING_HOURS_8m_OTHER = TestAccessEgress - .walk(STOP, D8m, C1) - .openingHours(T00_10, T01_00); + private static final RaptorAccessEgress WALK_W_OPENING_HOURS_8m_OTHER = TestAccessEgress.walk( + STOP, + D8m, + C1 + ).openingHours(T00_10, T01_00); @Test void removeNonOptimalPathsForStandardRaptorTest() { diff --git a/raptor/src/test/java/org/opentripplanner/raptor/rangeraptor/transit/AccessPathsTest.java b/raptor/src/test/java/org/opentripplanner/raptor/rangeraptor/transit/AccessPathsTest.java index 8611a046a5b..67aa7820af7 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/rangeraptor/transit/AccessPathsTest.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/rangeraptor/transit/AccessPathsTest.java @@ -257,13 +257,12 @@ void hasTimeDependentAccess() { ); assertTrue(accessPaths.hasTimeDependentAccess(), "Time dependent access is better."); - accessPaths = - AccessPaths.create( - 60, - List.of(WALK_FAST, walk(STOP_A, 50).openingHours(1200, 2400)), - STANDARD, - REVERSE - ); + accessPaths = AccessPaths.create( + 60, + List.of(WALK_FAST, walk(STOP_A, 50).openingHours(1200, 2400)), + STANDARD, + REVERSE + ); assertFalse(accessPaths.hasTimeDependentAccess(), "Time dependent access is worse."); } diff --git a/raptor/src/test/java/org/opentripplanner/raptor/rangeraptor/transit/RaptorSearchWindowCalculatorTest.java b/raptor/src/test/java/org/opentripplanner/raptor/rangeraptor/transit/RaptorSearchWindowCalculatorTest.java index 4898c5e2ae9..34c0409245f 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/rangeraptor/transit/RaptorSearchWindowCalculatorTest.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/rangeraptor/transit/RaptorSearchWindowCalculatorTest.java @@ -211,9 +211,7 @@ void roundUpToNearestMinute(V2 v2) { @Test void roundUpToNearestMinuteNotDefinedForNegativeNumbers() { - var ex = assertThrows( - IllegalArgumentException.class, - () -> subject.roundDownToNearestMinute(-1) + var ex = assertThrows(IllegalArgumentException.class, () -> subject.roundDownToNearestMinute(-1) ); assertEquals("This operation is not defined for negative numbers: -1", ex.getMessage()); } diff --git a/raptor/src/test/java/org/opentripplanner/raptor/rangeraptor/transit/TripScheduleExactMatchSearchTest.java b/raptor/src/test/java/org/opentripplanner/raptor/rangeraptor/transit/TripScheduleExactMatchSearchTest.java index 0949694cf0b..cd59508fcd3 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/rangeraptor/transit/TripScheduleExactMatchSearchTest.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/rangeraptor/transit/TripScheduleExactMatchSearchTest.java @@ -18,13 +18,12 @@ public class TripScheduleExactMatchSearchTest implements RaptorTestConstants { private static final int TRIP_TIME = 500; private static final boolean FORWARD = true; private static final boolean REVERSE = false; - private static final TestTripSchedule TRIP_SCHEDULE = TestTripSchedule - .schedule() + private static final TestTripSchedule TRIP_SCHEDULE = TestTripSchedule.schedule() .times(TRIP_TIME) .build(); - private static final TestRoute TIME_TABLE = TestRoute - .route("R1", STOP_A) - .withTimetable(TRIP_SCHEDULE); + private static final TestRoute TIME_TABLE = TestRoute.route("R1", STOP_A).withTimetable( + TRIP_SCHEDULE + ); private RaptorTripScheduleSearch subject; diff --git a/raptor/src/test/java/org/opentripplanner/raptor/rangeraptor/transit/TripTimesSearchTest.java b/raptor/src/test/java/org/opentripplanner/raptor/rangeraptor/transit/TripTimesSearchTest.java index d70f58fd1c5..660ff1cd0a0 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/rangeraptor/transit/TripTimesSearchTest.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/rangeraptor/transit/TripTimesSearchTest.java @@ -27,8 +27,9 @@ public class TripTimesSearchTest implements RaptorTestConstants { private static final int C_ALIGHT_LATE = C_ALIGHT_TIME + 10; // Given a trip-schedule with board-times [110, 210, -] and alight-times [-, 200, 300]. - private TestTripSchedule schedule = TestTripSchedule - .schedule(pattern("P1", STOP_A, STOP_B, STOP_C)) + private TestTripSchedule schedule = TestTripSchedule.schedule( + pattern("P1", STOP_A, STOP_B, STOP_C) + ) .departures(A_BOARD_TIME, 210, 310) .arrivals(100, 200, C_ALIGHT_TIME) .build(); @@ -81,8 +82,9 @@ public void findTripWithoutSlack() { @Test public void findInLoop() { // Stops A - (B - C){2 times} - D - var schedule = TestTripSchedule - .schedule(pattern("P1", STOP_A, STOP_B, STOP_C, STOP_B, STOP_C, STOP_D)) + var schedule = TestTripSchedule.schedule( + pattern("P1", STOP_A, STOP_B, STOP_C, STOP_B, STOP_C, STOP_D) + ) .times("10:01 10:02 10:03 10:04 10:05 10:06") .build(); // Time at stop @@ -178,12 +180,12 @@ public void findTripWhenScheduleLoops() { // stops: Start at 1, loop twice: 111, 122, 133, 144, 155, and end at 1155 // alight times: [ -, 100, 200, 300, 400, .., 1100] and // departure times: [ 10, 110, 210, 310, 410, .., 1110]. - schedule = - TestTripSchedule - .schedule(pattern(1, 111, 122, 133, 144, 155, 111, 122, 133, 144, 155, 1155)) - .departures(10, 110, 210, 310, 410, 510, 610, 710, 810, 910, 1010, 1110) - .arrivals(0, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100) - .build(); + schedule = TestTripSchedule.schedule( + pattern(1, 111, 122, 133, 144, 155, 111, 122, 133, 144, 155, 1155) + ) + .departures(10, 110, 210, 310, 410, 510, 610, 710, 810, 910, 1010, 1110) + .arrivals(0, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100) + .build(); BoardAndAlightTime r; diff --git a/raptor/src/test/java/org/opentripplanner/raptor/spi/RaptorTripScheduleTest.java b/raptor/src/test/java/org/opentripplanner/raptor/spi/RaptorTripScheduleTest.java index 9188617016a..3fd9fad8ba4 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/spi/RaptorTripScheduleTest.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/spi/RaptorTripScheduleTest.java @@ -9,8 +9,9 @@ public class RaptorTripScheduleTest { - private final TestTripSchedule subject = TestTripSchedule - .schedule(TestTripPattern.pattern("L23", 1, 1, 2, 3, 5, 8, 1)) + private final TestTripSchedule subject = TestTripSchedule.schedule( + TestTripPattern.pattern("L23", 1, 1, 2, 3, 5, 8, 1) + ) .arrivals("10:00 10:05 10:15 10:25 10:35 10:45 10:55") .departures("10:01 10:06 10:16 10:26 10:36 10:46 10:56") .build(); diff --git a/raptor/src/test/java/org/opentripplanner/raptor/util/paretoset/ParetoSetEventListenerTest.java b/raptor/src/test/java/org/opentripplanner/raptor/util/paretoset/ParetoSetEventListenerTest.java index 0f23144efc6..e0567856900 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/util/paretoset/ParetoSetEventListenerTest.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/util/paretoset/ParetoSetEventListenerTest.java @@ -11,7 +11,9 @@ public class ParetoSetEventListenerTest { // Given a set and function - private final TestParetoSetEventListener listener = new TestParetoSetEventListener(); + private final TestParetoSetEventListener listener = new TestParetoSetEventListener< + TestVector + >(); @SuppressWarnings("MismatchedQueryAndUpdateOfCollection") private final ParetoSet subject = new ParetoSet<>( diff --git a/raptor/src/test/java/org/opentripplanner/raptor/util/paretoset/ParetoSetTest.java b/raptor/src/test/java/org/opentripplanner/raptor/util/paretoset/ParetoSetTest.java index 5f2d56cfcdd..66d6497f462 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/util/paretoset/ParetoSetTest.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/util/paretoset/ParetoSetTest.java @@ -54,10 +54,11 @@ public void initiallyEmpty() { @Test public void addVector() { - ParetoSet set = new ParetoSet<>((l, r) -> - l.v1 < r.v1 || // less than - l.v2 != r.v2 || // different dominates - l.v3 + 2 < r.v3 // at least 2 less than + ParetoSet set = new ParetoSet<>( + (l, r) -> + l.v1 < r.v1 || // less than + l.v2 != r.v2 || // different dominates + l.v3 + 2 < r.v3 // at least 2 less than ); // When one element is added @@ -242,8 +243,8 @@ public void testRelaxedCriteriaAcceptingTheTwoSmallestValues() { @Test public void testRelaxedCriteriaAcceptingTenPercentExtra() { // Given a set and function - ParetoSet set = new ParetoSet<>((l, r) -> - l.v1 < r.v1 || l.v2 <= IntUtils.round(r.v2 * 1.1) + ParetoSet set = new ParetoSet<>( + (l, r) -> l.v1 < r.v1 || l.v2 <= IntUtils.round(r.v2 * 1.1) ); // Add some values @@ -260,8 +261,8 @@ public void testRelaxedCriteriaAcceptingTenPercentExtra() { public void testFourCriteria() { // Given a set with one element with 2 criteria: [5, 5] // and the pareto function is: <, !=, >, <+2 - ParetoSet set = new ParetoSet<>((l, r) -> - l.v1 < r.v1 || l.v2 != r.v2 || l.v3 > r.v3 || l.v4 < r.v4 + 2 + ParetoSet set = new ParetoSet<>( + (l, r) -> l.v1 < r.v1 || l.v2 != r.v2 || l.v3 > r.v3 || l.v4 < r.v4 + 2 ); TestVector v0 = new TestVector("V0", 5, 5, 5, 5); @@ -426,8 +427,7 @@ private static void addRejected(ParetoSet set, TestVector v) { } private static String names(Iterable set) { - return StreamSupport - .stream(set.spliterator(), false) + return StreamSupport.stream(set.spliterator(), false) .map(it -> it == null ? "null" : it.name) .collect(Collectors.joining(" ")); } diff --git a/raptor/src/test/java/org/opentripplanner/raptor/util/paretoset/ParetoSetWithMarkerTest.java b/raptor/src/test/java/org/opentripplanner/raptor/util/paretoset/ParetoSetWithMarkerTest.java index 48669f67d99..2e42f3cc648 100644 --- a/raptor/src/test/java/org/opentripplanner/raptor/util/paretoset/ParetoSetWithMarkerTest.java +++ b/raptor/src/test/java/org/opentripplanner/raptor/util/paretoset/ParetoSetWithMarkerTest.java @@ -10,8 +10,8 @@ public class ParetoSetWithMarkerTest { - private final ParetoSetWithMarker subject = new ParetoSetWithMarker<>((l, r) -> - l.u < r.u || l.v < r.v + private final ParetoSetWithMarker subject = new ParetoSetWithMarker<>( + (l, r) -> l.u < r.u || l.v < r.v ); @Test @@ -145,8 +145,7 @@ private String toString(ParetoSetWithMarker set) { } private String toString(Iterable elements) { - return StreamSupport - .stream(elements.spliterator(), false) + return StreamSupport.stream(elements.spliterator(), false) .map(Objects::toString) .reduce((a, b) -> a + ", " + b) .orElse("{}"); diff --git a/utils/src/main/java/org/opentripplanner/utils/lang/StringUtils.java b/utils/src/main/java/org/opentripplanner/utils/lang/StringUtils.java index c1a2219da72..4453deb1bc7 100644 --- a/utils/src/main/java/org/opentripplanner/utils/lang/StringUtils.java +++ b/utils/src/main/java/org/opentripplanner/utils/lang/StringUtils.java @@ -88,8 +88,7 @@ public static String padLeft(String value, char ch, int width) { if (value.length() >= width) { return value; } - return StringUtils - .append(new StringBuilder(), ch, width - value.length()) + return StringUtils.append(new StringBuilder(), ch, width - value.length()) .append(value) .toString(); } diff --git a/utils/src/main/java/org/opentripplanner/utils/logging/ProgressTracker.java b/utils/src/main/java/org/opentripplanner/utils/logging/ProgressTracker.java index 4922186bfc6..470ca016ab7 100644 --- a/utils/src/main/java/org/opentripplanner/utils/logging/ProgressTracker.java +++ b/utils/src/main/java/org/opentripplanner/utils/logging/ProgressTracker.java @@ -227,7 +227,7 @@ public String completeMessage() { long ii = stepCounter.get(); Duration totalTime = Duration.between(startTime, Instant.now()); // Add 1 millisecond to prevent / by zero. - String stepsPerSecond = toStr(Math.round(1000d * ii / (totalTime.toMillis() + 1))); + String stepsPerSecond = toStr(Math.round((1000d * ii) / (totalTime.toMillis() + 1))); return String.format( "%s progress tracking complete. %s done in %s (%s per second). ", actionName, diff --git a/utils/src/main/java/org/opentripplanner/utils/time/DurationUtils.java b/utils/src/main/java/org/opentripplanner/utils/time/DurationUtils.java index d73faecee03..892445aadef 100644 --- a/utils/src/main/java/org/opentripplanner/utils/time/DurationUtils.java +++ b/utils/src/main/java/org/opentripplanner/utils/time/DurationUtils.java @@ -152,8 +152,7 @@ public static List durations(String durations) { if (durations == null || durations.isBlank()) { return List.of(); } - return Arrays - .stream(durations.split("[,;\\s]+")) + return Arrays.stream(durations.split("[,;\\s]+")) .map(DurationUtils::duration) .collect(Collectors.toList()); } diff --git a/utils/src/main/java/org/opentripplanner/utils/time/RelativeTime.java b/utils/src/main/java/org/opentripplanner/utils/time/RelativeTime.java index b4b13a7c68b..e203dd61f0a 100644 --- a/utils/src/main/java/org/opentripplanner/utils/time/RelativeTime.java +++ b/utils/src/main/java/org/opentripplanner/utils/time/RelativeTime.java @@ -41,8 +41,7 @@ private RelativeTime(int days, int hours, int minutes, int seconds) { * for most days are midnight, but in when time is adjusted for day-light-saving it is not. */ public ZonedDateTime toZonedDateTime(LocalDate date, ZoneId zoneId) { - return ServiceDateUtils - .asStartOfService(date, zoneId) + return ServiceDateUtils.asStartOfService(date, zoneId) .plusDays(days) .plusSeconds(time.toSecondOfDay()); } diff --git a/utils/src/main/java/org/opentripplanner/utils/tostring/ToStringBuilder.java b/utils/src/main/java/org/opentripplanner/utils/tostring/ToStringBuilder.java index de40951ff75..498aeae5782 100644 --- a/utils/src/main/java/org/opentripplanner/utils/tostring/ToStringBuilder.java +++ b/utils/src/main/java/org/opentripplanner/utils/tostring/ToStringBuilder.java @@ -286,14 +286,10 @@ public ToStringBuilder addServiceTime(String name, int timeSecondsPastMidnight) * Add times in seconds since midnight. Format: hh:mm. {@code null} value is ignored. */ public ToStringBuilder addServiceTimeSchedule(String name, int[] value) { - return addIfNotNull( - name, - value, - a -> - Arrays - .stream(a) - .mapToObj(TimeUtils::timeToStrCompact) - .collect(Collectors.joining(" ", "[", "]")) + return addIfNotNull(name, value, a -> + Arrays.stream(a) + .mapToObj(TimeUtils::timeToStrCompact) + .collect(Collectors.joining(" ", "[", "]")) ); } diff --git a/utils/src/test/java/org/opentripplanner/utils/lang/IntUtilsTest.java b/utils/src/test/java/org/opentripplanner/utils/lang/IntUtilsTest.java index 99b32f47f0a..58aeeb0c2bf 100644 --- a/utils/src/test/java/org/opentripplanner/utils/lang/IntUtilsTest.java +++ b/utils/src/test/java/org/opentripplanner/utils/lang/IntUtilsTest.java @@ -42,20 +42,16 @@ void testAssertInRange() { IntUtils.requireInRange(1, 1, 1, "single-element-range"); IntUtils.requireInRange(-2, -2, 1, "negative-start"); IntUtils.requireInRange(-1, -2, -1, "negative-end"); - assertThrows( - IllegalArgumentException.class, - () -> IntUtils.requireInRange(1, 2, 1, "invalid-range") + assertThrows(IllegalArgumentException.class, () -> + IntUtils.requireInRange(1, 2, 1, "invalid-range") ); - var ex = assertThrows( - IllegalArgumentException.class, - () -> IntUtils.requireInRange(1, 2, 3, "value-too-small") + var ex = assertThrows(IllegalArgumentException.class, () -> + IntUtils.requireInRange(1, 2, 3, "value-too-small") ); assertEquals("The 'value-too-small' is not in range[2, 3]: 1", ex.getMessage()); - ex = - assertThrows( - IllegalArgumentException.class, - () -> IntUtils.requireInRange(4, 0, 3, "value-too-big") - ); + ex = assertThrows(IllegalArgumentException.class, () -> + IntUtils.requireInRange(4, 0, 3, "value-too-big") + ); assertEquals("The 'value-too-big' is not in range[0, 3]: 4", ex.getMessage()); } @@ -94,9 +90,7 @@ void testRequireNotNegative() { assertEquals(7, requireNotNegative(7, "ok")); assertEquals(0, requireNotNegative(0, "ok")); - var ex = assertThrows( - IllegalArgumentException.class, - () -> requireNotNegative(-1, "too-small") + var ex = assertThrows(IllegalArgumentException.class, () -> requireNotNegative(-1, "too-small") ); assertEquals("Negative value not expected for 'too-small': -1", ex.getMessage()); diff --git a/utils/src/test/java/org/opentripplanner/utils/lang/MemEfficientArrayBuilderTest.java b/utils/src/test/java/org/opentripplanner/utils/lang/MemEfficientArrayBuilderTest.java index 99297b29f1d..8697fe3c303 100644 --- a/utils/src/test/java/org/opentripplanner/utils/lang/MemEfficientArrayBuilderTest.java +++ b/utils/src/test/java/org/opentripplanner/utils/lang/MemEfficientArrayBuilderTest.java @@ -25,8 +25,7 @@ void size() { @Test void with() { - var smallWeekend = MemEfficientArrayBuilder - .of(WEEKEND) + var smallWeekend = MemEfficientArrayBuilder.of(WEEKEND) .with(0, DayOfWeek.THURSDAY) .with(1, DayOfWeek.FRIDAY) .build(); diff --git a/utils/src/test/java/org/opentripplanner/utils/lang/ObjectUtilsTest.java b/utils/src/test/java/org/opentripplanner/utils/lang/ObjectUtilsTest.java index 3f6283543fc..7ad39d1a3d3 100644 --- a/utils/src/test/java/org/opentripplanner/utils/lang/ObjectUtilsTest.java +++ b/utils/src/test/java/org/opentripplanner/utils/lang/ObjectUtilsTest.java @@ -35,17 +35,14 @@ void ifNotNullFunctional() { @Test void requireNotInitialized() { assertEquals("new", ObjectUtils.requireNotInitialized(null, "new")); - var ex = assertThrows( - IllegalStateException.class, - () -> ObjectUtils.requireNotInitialized("foo", "old", "new") + var ex = assertThrows(IllegalStateException.class, () -> + ObjectUtils.requireNotInitialized("foo", "old", "new") ); assertEquals("Field foo is already set! Old value: old, new value: new.", ex.getMessage()); - ex = - assertThrows( - IllegalStateException.class, - () -> ObjectUtils.requireNotInitialized("old", "new") - ); + ex = assertThrows(IllegalStateException.class, () -> + ObjectUtils.requireNotInitialized("old", "new") + ); assertEquals("Field is already set! Old value: old, new value: new.", ex.getMessage()); } diff --git a/utils/src/test/java/org/opentripplanner/utils/lang/StringUtilsTest.java b/utils/src/test/java/org/opentripplanner/utils/lang/StringUtilsTest.java index dda9248468e..a8a8fc8e786 100644 --- a/utils/src/test/java/org/opentripplanner/utils/lang/StringUtilsTest.java +++ b/utils/src/test/java/org/opentripplanner/utils/lang/StringUtilsTest.java @@ -50,9 +50,8 @@ public void assertValueExist() { for (var it : illegalValues) { assertThrows(IllegalArgumentException.class, () -> StringUtils.assertHasValue(it)); - Throwable thrown = assertThrows( - IllegalArgumentException.class, - () -> StringUtils.assertHasValue(it, "Illegal value %s", it) + Throwable thrown = assertThrows(IllegalArgumentException.class, () -> + StringUtils.assertHasValue(it, "Illegal value %s", it) ); assertTrue(thrown.getMessage().startsWith("Illegal value " + it)); } diff --git a/utils/src/test/java/org/opentripplanner/utils/text/TableTest.java b/utils/src/test/java/org/opentripplanner/utils/text/TableTest.java index 98915faebb1..1dce6f45d52 100644 --- a/utils/src/test/java/org/opentripplanner/utils/text/TableTest.java +++ b/utils/src/test/java/org/opentripplanner/utils/text/TableTest.java @@ -13,8 +13,7 @@ public class TableTest { @Test public void buildAndPrintTable() { // Test various normalization cases - var builder = Table - .of() + var builder = Table.of() .withAlights(Left, Center, Right) .withHeaders("LEFT", "CENTER", "RIGHT") .addRow(" SPACE ", " Long-value\t", 2) @@ -23,11 +22,11 @@ public void buildAndPrintTable() { var expected = """ - LEFT | CENTER | RIGHT - SPACE | Long-value | 2 - NL Before | NL in middle | NL after - | Short | 123 - """; + LEFT | CENTER | RIGHT + SPACE | Long-value | 2 + NL Before | NL in middle | NL after + | Short | 123 + """; // Both the builder and the Table returns the same table as toString() assertEquals(expected, builder.toString()); @@ -36,8 +35,7 @@ public void buildAndPrintTable() { @Test public void printTableWhileGoing() { - Table table = Table - .of() + Table table = Table.of() .withAlights(Left, Center, Right) .withHeaders("LEFT", "CENTER", "RIGHT") .withMinWidths(5, 8, 0) @@ -52,8 +50,7 @@ public void printTableWhileGoing() { @Test public void tableAsMarkdown() { - var table = Table - .of() + var table = Table.of() .withHeaders("A", "B", "Total") .withAlights(Center, Center, Center) .addRow(100, 2, 102) @@ -65,29 +62,27 @@ public void tableAsMarkdown() { assertEquals( """ - | A | B | Total | - |:-----:|:-:|:-----:| - | 100 | 2 | 102 | - | One | | | - | (A¦B) | ¦ | | - """, + | A | B | Total | + |:-----:|:-:|:-----:| + | 100 | 2 | 102 | + | One | | | + | (A¦B) | ¦ | | + """, result ); } @Test public void tableWithTooFewAlignsFails() { - assertThrows( - IllegalStateException.class, - () -> Table.of().withHeaders("A", "B").withAlights(Center).build() + assertThrows(IllegalStateException.class, () -> + Table.of().withHeaders("A", "B").withAlights(Center).build() ); } @Test public void tableWithTooFewMinWidths() { - assertThrows( - IllegalStateException.class, - () -> Table.of().withHeaders("A", "B").withMinWidths(20).build() + assertThrows(IllegalStateException.class, () -> + Table.of().withHeaders("A", "B").withMinWidths(20).build() ); } } diff --git a/utils/src/test/java/org/opentripplanner/utils/text/TextVariablesSubstitutionTest.java b/utils/src/test/java/org/opentripplanner/utils/text/TextVariablesSubstitutionTest.java index 5c1c2014cc2..2b37ad8104d 100644 --- a/utils/src/test/java/org/opentripplanner/utils/text/TextVariablesSubstitutionTest.java +++ b/utils/src/test/java/org/opentripplanner/utils/text/TextVariablesSubstitutionTest.java @@ -43,9 +43,8 @@ void testInsertVariablesInValue() { assertEquals("A B", insertVariables("${a} ${b}", map::get, this::errorHandler)); assertEquals("AB", insertVariables("${ab}", map::get, this::errorHandler)); assertEquals("AB - A - B", insertVariables("${ab2}", map::get, this::errorHandler)); - var ex = assertThrows( - IllegalArgumentException.class, - () -> insertVariables("${c}", map::get, this::errorHandler) + var ex = assertThrows(IllegalArgumentException.class, () -> + insertVariables("${c}", map::get, this::errorHandler) ); assertEquals("c", ex.getMessage()); } diff --git a/utils/src/test/java/org/opentripplanner/utils/time/DurationUtilsTest.java b/utils/src/test/java/org/opentripplanner/utils/time/DurationUtilsTest.java index ef2e0f50901..a4a9998cbb3 100644 --- a/utils/src/test/java/org/opentripplanner/utils/time/DurationUtilsTest.java +++ b/utils/src/test/java/org/opentripplanner/utils/time/DurationUtilsTest.java @@ -109,9 +109,8 @@ public void parseSecondsOrDuration() { DurationUtils.parseSecondsOrDuration(Integer.toString(3 * 24 * 60 * 60)).orElseThrow() ); - assertThrows( - DateTimeParseException.class, - () -> DurationUtils.parseSecondsOrDuration("not-a-duration").orElseThrow() + assertThrows(DateTimeParseException.class, () -> + DurationUtils.parseSecondsOrDuration("not-a-duration").orElseThrow() ); } @@ -139,54 +138,46 @@ public void testRequireNonNegativeAndMaxLimit() { assertThrows(NullPointerException.class, () -> requireNonNegative(null, D2h, "test")); // Test max limit - var ex = assertThrows( - IllegalArgumentException.class, - () -> requireNonNegative(D2h, D2h, "test") + var ex = assertThrows(IllegalArgumentException.class, () -> requireNonNegative(D2h, D2h, "test") ); assertEquals("Duration test can't be longer or equals too 2h: PT2H", ex.getMessage()); // Test non-negative - ex = - assertThrows(IllegalArgumentException.class, () -> requireNonNegative(NEG_1s, D2h, "test")); + ex = assertThrows(IllegalArgumentException.class, () -> requireNonNegative(NEG_1s, D2h, "test") + ); assertEquals("Duration test can't be negative: PT-1S", ex.getMessage()); } @Test public void testRequireNonNegativeLong() { assertThrows(NullPointerException.class, () -> requireNonNegativeMax2days(null, "test")); - assertThrows( - IllegalArgumentException.class, - () -> requireNonNegativeMax2days(Duration.ofSeconds(-1), "test") + assertThrows(IllegalArgumentException.class, () -> + requireNonNegativeMax2days(Duration.ofSeconds(-1), "test") ); - assertThrows( - IllegalArgumentException.class, - () -> requireNonNegativeMax2days(Duration.ofDays(3), "test") + assertThrows(IllegalArgumentException.class, () -> + requireNonNegativeMax2days(Duration.ofDays(3), "test") ); } @Test public void testRequireNonNegativeMedium() { assertThrows(NullPointerException.class, () -> requireNonNegativeMax2hours(null, "test")); - assertThrows( - IllegalArgumentException.class, - () -> requireNonNegativeMax2hours(Duration.ofSeconds(-1), "test") + assertThrows(IllegalArgumentException.class, () -> + requireNonNegativeMax2hours(Duration.ofSeconds(-1), "test") ); - assertThrows( - IllegalArgumentException.class, - () -> requireNonNegativeMax2hours(Duration.ofHours(3), "test") + assertThrows(IllegalArgumentException.class, () -> + requireNonNegativeMax2hours(Duration.ofHours(3), "test") ); } @Test public void testRequireNonNegativeShort() { assertThrows(NullPointerException.class, () -> requireNonNegativeMax30minutes(null, "test")); - assertThrows( - IllegalArgumentException.class, - () -> requireNonNegativeMax30minutes(Duration.ofSeconds(-1), "test") + assertThrows(IllegalArgumentException.class, () -> + requireNonNegativeMax30minutes(Duration.ofSeconds(-1), "test") ); - assertThrows( - IllegalArgumentException.class, - () -> requireNonNegativeMax30minutes(Duration.ofMinutes(31), "test") + assertThrows(IllegalArgumentException.class, () -> + requireNonNegativeMax30minutes(Duration.ofMinutes(31), "test") ); } diff --git a/utils/src/test/java/org/opentripplanner/utils/time/OffsetDateTimeParserTest.java b/utils/src/test/java/org/opentripplanner/utils/time/OffsetDateTimeParserTest.java index a114cc96788..a5677950430 100644 --- a/utils/src/test/java/org/opentripplanner/utils/time/OffsetDateTimeParserTest.java +++ b/utils/src/test/java/org/opentripplanner/utils/time/OffsetDateTimeParserTest.java @@ -41,11 +41,8 @@ static List failedCases() { @ParameterizedTest @MethodSource("failedCases") void failed(String input) { - Assertions.assertThrows( - ParseException.class, - () -> { - OffsetDateTimeParser.parseLeniently(input); - } - ); + Assertions.assertThrows(ParseException.class, () -> { + OffsetDateTimeParser.parseLeniently(input); + }); } } diff --git a/utils/src/test/java/org/opentripplanner/utils/tostring/MultiLineToStringBuilderTest.java b/utils/src/test/java/org/opentripplanner/utils/tostring/MultiLineToStringBuilderTest.java index 55b43517e18..1a4f820ca09 100644 --- a/utils/src/test/java/org/opentripplanner/utils/tostring/MultiLineToStringBuilderTest.java +++ b/utils/src/test/java/org/opentripplanner/utils/tostring/MultiLineToStringBuilderTest.java @@ -17,8 +17,7 @@ void testAdd() { number : 500 } """.trim(), - MultiLineToStringBuilder - .of("Test") + MultiLineToStringBuilder.of("Test") .add("foo", "bar") .add("number", 500) .add("null", null) @@ -42,16 +41,15 @@ void testAddDuration() { void testAddColNl() { assertEquals( """ - Test { - foo : [ - A new line - for each entry - in list! - ] - } - """.trim(), - MultiLineToStringBuilder - .of("Test") + Test { + foo : [ + A new line + for each entry + in list! + ] + } + """.trim(), + MultiLineToStringBuilder.of("Test") .addColNl("foo", List.of("A new line", "for each entry", "in list!")) // These are not added: .addColNl("null", null) diff --git a/utils/src/test/java/org/opentripplanner/utils/tostring/ToStringBuilderTest.java b/utils/src/test/java/org/opentripplanner/utils/tostring/ToStringBuilderTest.java index 477f48e7c63..d4d20edeed2 100644 --- a/utils/src/test/java/org/opentripplanner/utils/tostring/ToStringBuilderTest.java +++ b/utils/src/test/java/org/opentripplanner/utils/tostring/ToStringBuilderTest.java @@ -121,12 +121,9 @@ public void addObjOpSafe() { assertEquals( "ToStringBuilderTest{}", subject() - .addObjOpSafe( - "obj", - () -> { - throw new IllegalStateException("Ignore"); - } - ) + .addObjOpSafe("obj", () -> { + throw new IllegalStateException("Ignore"); + }) .toString() ); } @@ -260,9 +257,10 @@ public void addBitSetSize() { @Test public void addDateTime() { - var time = ZonedDateTime - .of(LocalDateTime.of(2012, 1, 28, 23, 45, 12), TIME_ZONE_ID_PARIS) - .toInstant(); + var time = ZonedDateTime.of( + LocalDateTime.of(2012, 1, 28, 23, 45, 12), + TIME_ZONE_ID_PARIS + ).toInstant(); assertEquals( "ToStringBuilderTest{t: 2012-01-28T22:45:12Z}", subject().addDateTime("t", time).toString() From bf513fe2a5434b6b0ccf7ebb20dfc722c6fb6c13 Mon Sep 17 00:00:00 2001 From: Joel Lappalainen Date: Tue, 4 Mar 2025 15:03:25 +0200 Subject: [PATCH 69/69] Add formatting commit to .git-blame-ignore-revs --- .git-blame-ignore-revs | 1 + 1 file changed, 1 insertion(+) diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index dbaccd6e799..bdfd7f6a52d 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -3,6 +3,7 @@ # project-wide reformatting with prettier 9c9dd613489a348d2381acdcbeab8f86589154d7 +e8e9a7716955b68b5b37997a0267148f1dcbcf9e # graphql test and documentation reformatting with prettier 12c51f44f204db31d34a1eeb0d59204226e0fa5d