diff --git a/src/ext/java/org/opentripplanner/ext/siri/SiriTripPatternCache.java b/src/ext/java/org/opentripplanner/ext/siri/SiriTripPatternCache.java index 83b7d04c34f..8b33d71ab96 100644 --- a/src/ext/java/org/opentripplanner/ext/siri/SiriTripPatternCache.java +++ b/src/ext/java/org/opentripplanner/ext/siri/SiriTripPatternCache.java @@ -190,7 +190,7 @@ public boolean equals(Object thatObject) { return false; } StopPatternServiceDateKey that = (StopPatternServiceDateKey) thatObject; - return (this.stopPattern.equals(that.stopPattern) & this.serviceDate.equals(that.serviceDate)); + return (this.stopPattern.equals(that.stopPattern) && this.serviceDate.equals(that.serviceDate)); } } @@ -215,6 +215,6 @@ public boolean equals(Object thatObject) { return false; } TripServiceDateKey that = (TripServiceDateKey) thatObject; - return (this.trip.equals(that.trip) & this.serviceDate.equals(that.serviceDate)); + return (this.trip.equals(that.trip) && this.serviceDate.equals(that.serviceDate)); } } diff --git a/src/ext/java/org/opentripplanner/ext/vehicleparking/hslpark/HslFacilitiesDownloader.java b/src/ext/java/org/opentripplanner/ext/vehicleparking/hslpark/HslFacilitiesDownloader.java index 55a325d7431..31664170a04 100644 --- a/src/ext/java/org/opentripplanner/ext/vehicleparking/hslpark/HslFacilitiesDownloader.java +++ b/src/ext/java/org/opentripplanner/ext/vehicleparking/hslpark/HslFacilitiesDownloader.java @@ -86,7 +86,7 @@ private List parseJSON( JsonNode rootNode = mapper.readTree(facilitiesString); - if (!jsonParsePath.equals("")) { + if (!jsonParsePath.isEmpty()) { String delimiter = "/"; String[] parseElement = jsonParsePath.split(delimiter); for (String s : parseElement) { diff --git a/src/ext/java/org/opentripplanner/ext/vehicleparking/hslpark/HslHubToVehicleParkingGroupMapper.java b/src/ext/java/org/opentripplanner/ext/vehicleparking/hslpark/HslHubToVehicleParkingGroupMapper.java index 959523247e4..1ef0ef3597b 100644 --- a/src/ext/java/org/opentripplanner/ext/vehicleparking/hslpark/HslHubToVehicleParkingGroupMapper.java +++ b/src/ext/java/org/opentripplanner/ext/vehicleparking/hslpark/HslHubToVehicleParkingGroupMapper.java @@ -46,7 +46,7 @@ public Map parseHub(JsonNode jsonNode) { .fieldNames() .forEachRemaining(lang -> { String name = nameNode.path(lang).asText(); - if (!name.equals("")) { + if (!name.isEmpty()) { translations.put(lang, nameNode.path(lang).asText()); } }); diff --git a/src/ext/java/org/opentripplanner/ext/vehicleparking/hslpark/HslHubsDownloader.java b/src/ext/java/org/opentripplanner/ext/vehicleparking/hslpark/HslHubsDownloader.java index 06a275de9ae..c5712e2067e 100644 --- a/src/ext/java/org/opentripplanner/ext/vehicleparking/hslpark/HslHubsDownloader.java +++ b/src/ext/java/org/opentripplanner/ext/vehicleparking/hslpark/HslHubsDownloader.java @@ -79,7 +79,7 @@ private Map parseJSON(InputStream dataStream) JsonNode rootNode = mapper.readTree(hubsString); - if (!jsonParsePath.equals("")) { + if (!jsonParsePath.isEmpty()) { String delimiter = "/"; String[] parseElement = jsonParsePath.split(delimiter); for (String s : parseElement) { diff --git a/src/ext/java/org/opentripplanner/ext/vehicleparking/hslpark/HslParkToVehicleParkingMapper.java b/src/ext/java/org/opentripplanner/ext/vehicleparking/hslpark/HslParkToVehicleParkingMapper.java index 0e41f0ed09d..1f69458dd1f 100644 --- a/src/ext/java/org/opentripplanner/ext/vehicleparking/hslpark/HslParkToVehicleParkingMapper.java +++ b/src/ext/java/org/opentripplanner/ext/vehicleparking/hslpark/HslParkToVehicleParkingMapper.java @@ -84,7 +84,7 @@ public VehicleParking parsePark( .fieldNames() .forEachRemaining(lang -> { String name = nameNode.path(lang).asText(); - if (!name.equals("")) { + if (!name.isEmpty()) { translations.put(lang, nameNode.path(lang).asText()); } }); diff --git a/src/main/java/org/opentripplanner/framework/geometry/GeometryUtils.java b/src/main/java/org/opentripplanner/framework/geometry/GeometryUtils.java index b440ac32979..27725f5ddf4 100644 --- a/src/main/java/org/opentripplanner/framework/geometry/GeometryUtils.java +++ b/src/main/java/org/opentripplanner/framework/geometry/GeometryUtils.java @@ -249,7 +249,7 @@ public static Geometry convertGeoJsonToJtsGeometry(GeoJsonObject geoJsonGeom) int i = 0; for (List geoJsonPath : geoJsonMultiLineString.getCoordinates()) { org.geojson.LineString geoJsonLineString = new org.geojson.LineString( - geoJsonPath.toArray(new LngLatAlt[geoJsonPath.size()]) + geoJsonPath.toArray(new LngLatAlt[0]) ); jtsLineStrings[i++] = (LineString) convertGeoJsonToJtsGeometry(geoJsonLineString); } diff --git a/src/main/java/org/opentripplanner/framework/io/JsonDataListDownloader.java b/src/main/java/org/opentripplanner/framework/io/JsonDataListDownloader.java index aa8bd3d5f69..bb602adb472 100644 --- a/src/main/java/org/opentripplanner/framework/io/JsonDataListDownloader.java +++ b/src/main/java/org/opentripplanner/framework/io/JsonDataListDownloader.java @@ -89,7 +89,7 @@ private List parseJSON(InputStream dataStream) throws IllegalArgumentExceptio ObjectMapper mapper = new ObjectMapper(); JsonNode rootNode = mapper.readTree(rentalString); - if (!jsonParsePath.equals("")) { + if (!jsonParsePath.isEmpty()) { String delimiter = "/"; String[] parseElement = jsonParsePath.split(delimiter); for (String s : parseElement) { diff --git a/src/main/java/org/opentripplanner/graph_builder/module/geometry/GeometryProcessor.java b/src/main/java/org/opentripplanner/graph_builder/module/geometry/GeometryProcessor.java index 360ad9f5865..17b0f9d5367 100644 --- a/src/main/java/org/opentripplanner/graph_builder/module/geometry/GeometryProcessor.java +++ b/src/main/java/org/opentripplanner/graph_builder/module/geometry/GeometryProcessor.java @@ -80,7 +80,7 @@ public List createHopGeometries(Trip trip) { if ( trip.getShapeId() == null || trip.getShapeId().getId() == null || - trip.getShapeId().getId().equals("") + trip.getShapeId().getId().isEmpty() ) { return null; } diff --git a/src/main/java/org/opentripplanner/graph_builder/module/islandpruning/PruneIslands.java b/src/main/java/org/opentripplanner/graph_builder/module/islandpruning/PruneIslands.java index 6f35bc59ab6..d3024a144f5 100644 --- a/src/main/java/org/opentripplanner/graph_builder/module/islandpruning/PruneIslands.java +++ b/src/main/java/org/opentripplanner/graph_builder/module/islandpruning/PruneIslands.java @@ -119,9 +119,7 @@ public void buildGraph() { areas.add(ae.getArea()); } for (AreaEdgeList a : areas) { - for (Vertex v : a.visibilityVertices()) { - visibilityVertices.add(v); - } + visibilityVertices.addAll(a.visibilityVertices()); } int removed = 0; diff --git a/src/main/java/org/opentripplanner/graph_builder/module/osm/AreaGroup.java b/src/main/java/org/opentripplanner/graph_builder/module/osm/AreaGroup.java index fd3f697a8e1..a7bcc9ccb94 100644 --- a/src/main/java/org/opentripplanner/graph_builder/module/osm/AreaGroup.java +++ b/src/main/java/org/opentripplanner/graph_builder/module/osm/AreaGroup.java @@ -66,9 +66,7 @@ public AreaGroup(Collection areas) { } } GeometryFactory geometryFactory = GeometryUtils.getGeometryFactory(); - Geometry allPolygons = geometryFactory.createMultiPolygon( - allRings.toArray(new Polygon[allRings.size()]) - ); + Geometry allPolygons = geometryFactory.createMultiPolygon(allRings.toArray(new Polygon[0])); this.union = allPolygons.union(); if (this.union instanceof GeometryCollection coll) { diff --git a/src/main/java/org/opentripplanner/graph_builder/module/osm/Ring.java b/src/main/java/org/opentripplanner/graph_builder/module/osm/Ring.java index 1c126809501..9804c2d646f 100644 --- a/src/main/java/org/opentripplanner/graph_builder/module/osm/Ring.java +++ b/src/main/java/org/opentripplanner/graph_builder/module/osm/Ring.java @@ -115,7 +115,7 @@ private Polygon calculateJtsPolygon() { lrholelist.add(ring); } } - LinearRing[] lrholes = lrholelist.toArray(new LinearRing[lrholelist.size()]); + LinearRing[] lrholes = lrholelist.toArray(new LinearRing[0]); return factory.createPolygon(shell, lrholes); } diff --git a/src/main/java/org/opentripplanner/inspector/raster/NoThruTrafficEdgeRenderer.java b/src/main/java/org/opentripplanner/inspector/raster/NoThruTrafficEdgeRenderer.java index 206cfbd3f13..6d5e635d59c 100644 --- a/src/main/java/org/opentripplanner/inspector/raster/NoThruTrafficEdgeRenderer.java +++ b/src/main/java/org/opentripplanner/inspector/raster/NoThruTrafficEdgeRenderer.java @@ -47,7 +47,7 @@ public Optional renderEdge(Edge e) { label += " car"; colorIndex += 4; } - if (!label.equals("")) { + if (!label.isEmpty()) { label = "No" + label + " thru traffic"; } diff --git a/src/main/java/org/opentripplanner/openstreetmap/model/OSMLevel.java b/src/main/java/org/opentripplanner/openstreetmap/model/OSMLevel.java index c8c87f383d0..9aef9e4bd01 100644 --- a/src/main/java/org/opentripplanner/openstreetmap/model/OSMLevel.java +++ b/src/main/java/org/opentripplanner/openstreetmap/model/OSMLevel.java @@ -69,7 +69,7 @@ public static OSMLevel fromString( /* get short and long level names by splitting on = character */ String shortName = ""; String longName = ""; - Integer indexEquals = spec.indexOf('='); + int indexEquals = spec.indexOf('='); if (indexEquals >= 1) { shortName = spec.substring(0, indexEquals); longName = spec.substring(indexEquals + 1); diff --git a/src/main/java/org/opentripplanner/openstreetmap/wayproperty/WayPropertySet.java b/src/main/java/org/opentripplanner/openstreetmap/wayproperty/WayPropertySet.java index 06d5f895777..376614b1093 100644 --- a/src/main/java/org/opentripplanner/openstreetmap/wayproperty/WayPropertySet.java +++ b/src/main/java/org/opentripplanner/openstreetmap/wayproperty/WayPropertySet.java @@ -336,7 +336,7 @@ public Float getMetersSecondFromSpeed(String speed) { } String units = m.group(2); - if (units == null || units.equals("")) units = "kmh"; + if (units == null || units.isEmpty()) units = "kmh"; // we'll be doing quite a few string comparisons here units = units.intern(); diff --git a/src/main/java/org/opentripplanner/standalone/config/CommandLineParameters.java b/src/main/java/org/opentripplanner/standalone/config/CommandLineParameters.java index 6f85f9d8598..cf02d127c52 100644 --- a/src/main/java/org/opentripplanner/standalone/config/CommandLineParameters.java +++ b/src/main/java/org/opentripplanner/standalone/config/CommandLineParameters.java @@ -327,7 +327,7 @@ public static class PositiveInteger implements IParameterValidator { @Override public void validate(String name, String value) throws ParameterException { - Integer i = Integer.parseInt(value); + int i = Integer.parseInt(value); if (i <= 0) { String msg = String.format("%s must be a positive integer.", name); throw new ParameterException(msg); diff --git a/src/test/java/org/opentripplanner/astar/model/BinHeapTest.java b/src/test/java/org/opentripplanner/astar/model/BinHeapTest.java index f050928ba92..1205179d28b 100644 --- a/src/test/java/org/opentripplanner/astar/model/BinHeapTest.java +++ b/src/test/java/org/opentripplanner/astar/model/BinHeapTest.java @@ -73,9 +73,7 @@ public void testCompareHeaps() throws InterruptedException { // First determine the expected results using a plain old PriorityQueue expected = new ArrayList<>(N); PriorityQueue q = new PriorityQueue<>(N); - for (Integer j : input) { - q.add(j); - } + q.addAll(input); while (!q.isEmpty()) { expected.add(q.remove()); }