From 11bbfb69360937c361b701065cdbc2e90699693e Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Wed, 24 May 2023 15:17:38 -0700 Subject: Remove duplicated list --- src/main/java/org/traccar/reports/common/ReportUtils.java | 11 +++++------ src/test/java/org/traccar/reports/ReportUtilsTest.java | 10 +++++----- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/main/java/org/traccar/reports/common/ReportUtils.java b/src/main/java/org/traccar/reports/common/ReportUtils.java index f5aa6d040..cd52b5de4 100644 --- a/src/main/java/org/traccar/reports/common/ReportUtils.java +++ b/src/main/java/org/traccar/reports/common/ReportUtils.java @@ -162,7 +162,7 @@ public class ReportUtils { } private TripReportItem calculateTrip( - Device device, ArrayList positions, int startIndex, int endIndex, + Device device, List positions, int startIndex, int endIndex, boolean ignoreOdometer) throws StorageException { Position startTrip = positions.get(startIndex); @@ -228,7 +228,7 @@ public class ReportUtils { } private StopReportItem calculateStop( - Device device, ArrayList positions, int startIndex, int endIndex, boolean ignoreOdometer) { + Device device, List positions, int startIndex, int endIndex, boolean ignoreOdometer) { Position startStop = positions.get(startIndex); Position endStop = positions.get(endIndex); @@ -275,7 +275,7 @@ public class ReportUtils { @SuppressWarnings("unchecked") private T calculateTripOrStop( - Device device, ArrayList positions, int startIndex, int endIndex, + Device device, List positions, int startIndex, int endIndex, boolean ignoreOdometer, Class reportClass) throws StorageException { if (reportClass.equals(TripReportItem.class)) { @@ -285,7 +285,7 @@ public class ReportUtils { } } - private boolean isMoving(ArrayList positions, int index, TripsConfig tripsConfig) { + private boolean isMoving(List positions, int index, TripsConfig tripsConfig) { if (tripsConfig.getMinimalNoDataDuration() > 0) { boolean beforeGap = index < positions.size() - 1 && positions.get(index + 1).getFixTime().getTime() - positions.get(index).getFixTime().getTime() @@ -301,14 +301,13 @@ public class ReportUtils { } public Collection detectTripsAndStops( - Device device, Collection positionCollection, boolean ignoreOdometer, + Device device, List positions, boolean ignoreOdometer, Class reportClass) throws StorageException { Collection result = new ArrayList<>(); TripsConfig tripsConfig = new TripsConfig( new AttributeUtil.StorageProvider(config, storage, permissionsService, device)); - ArrayList positions = new ArrayList<>(positionCollection); if (!positions.isEmpty()) { boolean trips = reportClass.equals(TripReportItem.class); diff --git a/src/test/java/org/traccar/reports/ReportUtilsTest.java b/src/test/java/org/traccar/reports/ReportUtilsTest.java index 22d70c93a..afb0a516f 100644 --- a/src/test/java/org/traccar/reports/ReportUtilsTest.java +++ b/src/test/java/org/traccar/reports/ReportUtilsTest.java @@ -281,7 +281,7 @@ public class ReportUtilsTest extends BaseTest { @Test public void testDetectStopsOnly() throws Exception { - Collection data = Arrays.asList( + var data = Arrays.asList( position("2016-01-01 00:00:00.000", 0, 0), position("2016-01-01 00:01:00.000", 0, 0), position("2016-01-01 00:02:00.000", 1, 0), @@ -309,7 +309,7 @@ public class ReportUtilsTest extends BaseTest { @Test public void testDetectStopsWithTripCut() throws Exception { - Collection data = Arrays.asList( + var data = Arrays.asList( position("2016-01-01 00:00:00.000", 0, 0), position("2016-01-01 00:01:00.000", 0, 0), position("2016-01-01 00:02:00.000", 0, 0), @@ -337,7 +337,7 @@ public class ReportUtilsTest extends BaseTest { @Test public void testDetectStopsStartedFromTrip() throws Exception { - Collection data = Arrays.asList( + var data = Arrays.asList( position("2016-01-01 00:00:00.000", 2, 0), position("2016-01-01 00:01:00.000", 1, 0), position("2016-01-01 00:02:00.000", 0, 0), @@ -365,7 +365,7 @@ public class ReportUtilsTest extends BaseTest { @Test public void testDetectStopsMoving() throws Exception { - Collection data = Arrays.asList( + var data = Arrays.asList( position("2016-01-01 00:00:00.000", 5, 0), position("2016-01-01 00:01:00.000", 5, 0), position("2016-01-01 00:02:00.000", 3, 0), @@ -387,7 +387,7 @@ public class ReportUtilsTest extends BaseTest { @Test public void testDetectTripAndStopByGap() throws Exception { - Collection data = Arrays.asList( + var data = Arrays.asList( position("2016-01-01 00:00:00.000", 7, 100), position("2016-01-01 00:01:00.000", 7, 300), position("2016-01-01 00:02:00.000", 5, 500), -- cgit v1.2.3