]> git.basschouten.com Git - openhab-addons.git/commitdiff
[enturno] Remove org.apache.commons (#14406)
authorlsiepel <leosiepel@gmail.com>
Fri, 27 Oct 2023 18:52:54 +0000 (20:52 +0200)
committerGitHub <noreply@github.com>
Fri, 27 Oct 2023 18:52:54 +0000 (20:52 +0200)
* Remove org.apache.commons
* Fix warnings

Also-by: Jacob Laursen <jacob-github@vindvejr.dk>
Signed-off-by: Leo Siepel <leosiepel@gmail.com>
26 files changed:
bundles/org.openhab.binding.enturno/src/main/java/org/openhab/binding/enturno/internal/EnturNoHandler.java
bundles/org.openhab.binding.enturno/src/main/java/org/openhab/binding/enturno/internal/connection/EnturNoConnection.java
bundles/org.openhab.binding.enturno/src/main/java/org/openhab/binding/enturno/internal/dto/Data.java [new file with mode: 0644]
bundles/org.openhab.binding.enturno/src/main/java/org/openhab/binding/enturno/internal/dto/EnturData.java [new file with mode: 0644]
bundles/org.openhab.binding.enturno/src/main/java/org/openhab/binding/enturno/internal/dto/EnturJsonData.java [new file with mode: 0644]
bundles/org.openhab.binding.enturno/src/main/java/org/openhab/binding/enturno/internal/dto/estimated/DestinationDisplay.java [new file with mode: 0644]
bundles/org.openhab.binding.enturno/src/main/java/org/openhab/binding/enturno/internal/dto/estimated/EstimatedCalls.java [new file with mode: 0644]
bundles/org.openhab.binding.enturno/src/main/java/org/openhab/binding/enturno/internal/dto/estimated/JourneyPattern.java [new file with mode: 0644]
bundles/org.openhab.binding.enturno/src/main/java/org/openhab/binding/enturno/internal/dto/estimated/Line.java [new file with mode: 0644]
bundles/org.openhab.binding.enturno/src/main/java/org/openhab/binding/enturno/internal/dto/estimated/Quay.java [new file with mode: 0644]
bundles/org.openhab.binding.enturno/src/main/java/org/openhab/binding/enturno/internal/dto/estimated/ServiceJourney.java [new file with mode: 0644]
bundles/org.openhab.binding.enturno/src/main/java/org/openhab/binding/enturno/internal/dto/simplified/DisplayData.java [new file with mode: 0644]
bundles/org.openhab.binding.enturno/src/main/java/org/openhab/binding/enturno/internal/dto/stopplace/StopPlace.java [new file with mode: 0644]
bundles/org.openhab.binding.enturno/src/main/java/org/openhab/binding/enturno/internal/model/Data.java [deleted file]
bundles/org.openhab.binding.enturno/src/main/java/org/openhab/binding/enturno/internal/model/EnturData.java [deleted file]
bundles/org.openhab.binding.enturno/src/main/java/org/openhab/binding/enturno/internal/model/EnturJsonData.java [deleted file]
bundles/org.openhab.binding.enturno/src/main/java/org/openhab/binding/enturno/internal/model/estimated/DestinationDisplay.java [deleted file]
bundles/org.openhab.binding.enturno/src/main/java/org/openhab/binding/enturno/internal/model/estimated/EstimatedCalls.java [deleted file]
bundles/org.openhab.binding.enturno/src/main/java/org/openhab/binding/enturno/internal/model/estimated/JourneyPattern.java [deleted file]
bundles/org.openhab.binding.enturno/src/main/java/org/openhab/binding/enturno/internal/model/estimated/Line.java [deleted file]
bundles/org.openhab.binding.enturno/src/main/java/org/openhab/binding/enturno/internal/model/estimated/Quay.java [deleted file]
bundles/org.openhab.binding.enturno/src/main/java/org/openhab/binding/enturno/internal/model/estimated/ServiceJourney.java [deleted file]
bundles/org.openhab.binding.enturno/src/main/java/org/openhab/binding/enturno/internal/model/simplified/DisplayData.java [deleted file]
bundles/org.openhab.binding.enturno/src/main/java/org/openhab/binding/enturno/internal/model/stopplace/StopPlace.java [deleted file]
bundles/org.openhab.binding.enturno/src/main/java/org/openhab/binding/enturno/internal/util/DateUtil.java [new file with mode: 0644]
bundles/org.openhab.binding.enturno/src/test/java/org/openhab/binding/enturno/internal/util/DateUtilTest.java [new file with mode: 0644]

index a89e5bcefa9787190480bd1dbb140f83ddc9e021..853f25fa8b2ba98d76e1a964dce6a59322312f83 100644 (file)
@@ -26,7 +26,7 @@ import org.eclipse.jetty.client.HttpClient;
 import org.openhab.binding.enturno.internal.connection.EnturCommunicationException;
 import org.openhab.binding.enturno.internal.connection.EnturConfigurationException;
 import org.openhab.binding.enturno.internal.connection.EnturNoConnection;
-import org.openhab.binding.enturno.internal.model.simplified.DisplayData;
+import org.openhab.binding.enturno.internal.dto.simplified.DisplayData;
 import org.openhab.core.library.types.DateTimeType;
 import org.openhab.core.library.types.StringType;
 import org.openhab.core.thing.Channel;
index 8d9b01fe5e46376756f0a24272ff9d4f2d8b1a31..6ed517a6070c3e5cd1c1c71ca42381550c6e1393 100644 (file)
@@ -32,7 +32,6 @@ import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
 import java.util.stream.Collectors;
 
-import org.apache.commons.lang3.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.jetty.client.HttpClient;
@@ -42,10 +41,11 @@ import org.eclipse.jetty.client.util.StringContentProvider;
 import org.eclipse.jetty.http.HttpHeader;
 import org.openhab.binding.enturno.internal.EnturNoConfiguration;
 import org.openhab.binding.enturno.internal.EnturNoHandler;
-import org.openhab.binding.enturno.internal.model.EnturJsonData;
-import org.openhab.binding.enturno.internal.model.estimated.EstimatedCalls;
-import org.openhab.binding.enturno.internal.model.simplified.DisplayData;
-import org.openhab.binding.enturno.internal.model.stopplace.StopPlace;
+import org.openhab.binding.enturno.internal.dto.EnturJsonData;
+import org.openhab.binding.enturno.internal.dto.estimated.EstimatedCalls;
+import org.openhab.binding.enturno.internal.dto.simplified.DisplayData;
+import org.openhab.binding.enturno.internal.dto.stopplace.StopPlace;
+import org.openhab.binding.enturno.internal.util.DateUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -189,10 +189,8 @@ public class EnturNoConnection {
     }
 
     private List<DisplayData> processData(StopPlace stopPlace, String lineCode) {
-        Map<String, List<EstimatedCalls>> departures = stopPlace.estimatedCalls.stream()
-                .filter(call -> StringUtils.equalsIgnoreCase(
-                        StringUtils.trimToEmpty(call.serviceJourney.journeyPattern.line.publicCode),
-                        StringUtils.trimToEmpty(lineCode)))
+        Map<String, List<EstimatedCalls>> departures = stopPlace.estimatedCalls.stream().filter(
+                call -> call.serviceJourney.journeyPattern.line.publicCode.strip().equalsIgnoreCase(lineCode.strip()))
                 .collect(groupingBy(call -> call.quay.id));
 
         List<DisplayData> processedData = new ArrayList<>();
@@ -214,8 +212,8 @@ public class EnturNoConnection {
         List<String> keys = new ArrayList<>(departures.keySet());
         DisplayData processedData = new DisplayData();
         List<EstimatedCalls> quayCalls = departures.get(keys.get(quayIndex));
-        List<String> departureTimes = quayCalls.stream().map(eq -> eq.expectedDepartureTime).map(this::getIsoDateTime)
-                .collect(Collectors.toList());
+        List<String> departureTimes = quayCalls.stream().map(eq -> eq.expectedDepartureTime)
+                .map(DateUtil::getIsoDateTime).collect(Collectors.toList());
 
         List<String> estimatedFlags = quayCalls.stream().map(es -> es.realtime).collect(Collectors.toList());
 
@@ -233,13 +231,4 @@ public class EnturNoConnection {
         processedData.transportMode = stopPlace.transportMode;
         return processedData;
     }
-
-    private String getIsoDateTime(String dateTimeWithoutColonInZone) {
-        String dateTime = StringUtils.substringBeforeLast(dateTimeWithoutColonInZone, "+");
-        String offset = StringUtils.substringAfterLast(dateTimeWithoutColonInZone, "+");
-
-        StringBuilder builder = new StringBuilder();
-        return builder.append(dateTime).append("+").append(StringUtils.substring(offset, 0, 2)).append(":00")
-                .toString();
-    }
 }
diff --git a/bundles/org.openhab.binding.enturno/src/main/java/org/openhab/binding/enturno/internal/dto/Data.java b/bundles/org.openhab.binding.enturno/src/main/java/org/openhab/binding/enturno/internal/dto/Data.java
new file mode 100644 (file)
index 0000000..c6a37b9
--- /dev/null
@@ -0,0 +1,24 @@
+/**
+ * Copyright (c) 2010-2023 Contributors to the openHAB project
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package org.openhab.binding.enturno.internal.dto;
+
+import org.openhab.binding.enturno.internal.dto.stopplace.StopPlace;
+
+/**
+ * Generated Plain Old Java Objects class for {@link Data} from JSON.
+ *
+ * @author Michal Kloc - Initial contribution
+ */
+public class Data {
+    public StopPlace stopPlace;
+}
diff --git a/bundles/org.openhab.binding.enturno/src/main/java/org/openhab/binding/enturno/internal/dto/EnturData.java b/bundles/org.openhab.binding.enturno/src/main/java/org/openhab/binding/enturno/internal/dto/EnturData.java
new file mode 100644 (file)
index 0000000..04293d7
--- /dev/null
@@ -0,0 +1,22 @@
+/**
+ * Copyright (c) 2010-2023 Contributors to the openHAB project
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package org.openhab.binding.enturno.internal.dto;
+
+/**
+ * Generated Plain Old Java Objects class for {@link Data} from JSON.
+ *
+ * @author Michal Kloc - Initial contribution
+ */
+public class EnturData {
+    public Data data;
+}
diff --git a/bundles/org.openhab.binding.enturno/src/main/java/org/openhab/binding/enturno/internal/dto/EnturJsonData.java b/bundles/org.openhab.binding.enturno/src/main/java/org/openhab/binding/enturno/internal/dto/EnturJsonData.java
new file mode 100644 (file)
index 0000000..f175af3
--- /dev/null
@@ -0,0 +1,22 @@
+/**
+ * Copyright (c) 2010-2023 Contributors to the openHAB project
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package org.openhab.binding.enturno.internal.dto;
+
+/**
+ * {@link EnturJsonData} is a root level class to holding reference of data generated from JSON.
+ *
+ * @author Michal Kloc - Initial contribution
+ */
+public class EnturJsonData {
+    public Data data;
+}
diff --git a/bundles/org.openhab.binding.enturno/src/main/java/org/openhab/binding/enturno/internal/dto/estimated/DestinationDisplay.java b/bundles/org.openhab.binding.enturno/src/main/java/org/openhab/binding/enturno/internal/dto/estimated/DestinationDisplay.java
new file mode 100644 (file)
index 0000000..4818da5
--- /dev/null
@@ -0,0 +1,22 @@
+/**
+ * Copyright (c) 2010-2023 Contributors to the openHAB project
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package org.openhab.binding.enturno.internal.dto.estimated;
+
+/**
+ * Generated Plain Old Java Objects class for {@link DestinationDisplay} from JSON.
+ *
+ * @author Michal Kloc - Initial contribution
+ */
+public class DestinationDisplay {
+    public String frontText;
+}
diff --git a/bundles/org.openhab.binding.enturno/src/main/java/org/openhab/binding/enturno/internal/dto/estimated/EstimatedCalls.java b/bundles/org.openhab.binding.enturno/src/main/java/org/openhab/binding/enturno/internal/dto/estimated/EstimatedCalls.java
new file mode 100644 (file)
index 0000000..c3a056c
--- /dev/null
@@ -0,0 +1,42 @@
+/**
+ * Copyright (c) 2010-2023 Contributors to the openHAB project
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package org.openhab.binding.enturno.internal.dto.estimated;
+
+/**
+ * Generated Plain Old Java Objects class for {@link EstimatedCalls} from JSON.
+ *
+ * @author Michal Kloc - Initial contribution
+ */
+public class EstimatedCalls {
+    public String aimedArrivalTime;
+
+    public String date;
+
+    public String realtime;
+
+    public String expectedDepartureTime;
+
+    public String forAlighting;
+
+    public DestinationDisplay destinationDisplay;
+
+    public String forBoarding;
+
+    public ServiceJourney serviceJourney;
+
+    public Quay quay;
+
+    public String aimedDepartureTime;
+
+    public String expectedArrivalTime;
+}
diff --git a/bundles/org.openhab.binding.enturno/src/main/java/org/openhab/binding/enturno/internal/dto/estimated/JourneyPattern.java b/bundles/org.openhab.binding.enturno/src/main/java/org/openhab/binding/enturno/internal/dto/estimated/JourneyPattern.java
new file mode 100644 (file)
index 0000000..e5ba379
--- /dev/null
@@ -0,0 +1,22 @@
+/**
+ * Copyright (c) 2010-2023 Contributors to the openHAB project
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package org.openhab.binding.enturno.internal.dto.estimated;
+
+/**
+ * Generated Plain Old Java Objects class for {@link JourneyPattern} from JSON.
+ *
+ * @author Michal Kloc - Initial contribution
+ */
+public class JourneyPattern {
+    public Line line;
+}
diff --git a/bundles/org.openhab.binding.enturno/src/main/java/org/openhab/binding/enturno/internal/dto/estimated/Line.java b/bundles/org.openhab.binding.enturno/src/main/java/org/openhab/binding/enturno/internal/dto/estimated/Line.java
new file mode 100644 (file)
index 0000000..db43d2e
--- /dev/null
@@ -0,0 +1,28 @@
+/**
+ * Copyright (c) 2010-2023 Contributors to the openHAB project
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package org.openhab.binding.enturno.internal.dto.estimated;
+
+/**
+ * Generated Plain Old Java Objects class for {@link Line} from JSON.
+ *
+ * @author Michal Kloc - Initial contribution
+ */
+public class Line {
+    public String name;
+
+    public String transportMode;
+
+    public String publicCode;
+
+    public String id;
+}
diff --git a/bundles/org.openhab.binding.enturno/src/main/java/org/openhab/binding/enturno/internal/dto/estimated/Quay.java b/bundles/org.openhab.binding.enturno/src/main/java/org/openhab/binding/enturno/internal/dto/estimated/Quay.java
new file mode 100644 (file)
index 0000000..310ff8e
--- /dev/null
@@ -0,0 +1,24 @@
+/**
+ * Copyright (c) 2010-2023 Contributors to the openHAB project
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package org.openhab.binding.enturno.internal.dto.estimated;
+
+/**
+ * Generated Plain Old Java Objects class for {@link Quay} from JSON.
+ *
+ * @author Michal Kloc - Initial contribution
+ */
+public class Quay {
+    public String publicCode;
+
+    public String id;
+}
diff --git a/bundles/org.openhab.binding.enturno/src/main/java/org/openhab/binding/enturno/internal/dto/estimated/ServiceJourney.java b/bundles/org.openhab.binding.enturno/src/main/java/org/openhab/binding/enturno/internal/dto/estimated/ServiceJourney.java
new file mode 100644 (file)
index 0000000..e5f35fd
--- /dev/null
@@ -0,0 +1,22 @@
+/**
+ * Copyright (c) 2010-2023 Contributors to the openHAB project
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package org.openhab.binding.enturno.internal.dto.estimated;
+
+/**
+ * Generated Plain Old Java Objects class for {@link ServiceJourney} from JSON.
+ *
+ * @author Michal Kloc - Initial contribution
+ */
+public class ServiceJourney {
+    public JourneyPattern journeyPattern;
+}
diff --git a/bundles/org.openhab.binding.enturno/src/main/java/org/openhab/binding/enturno/internal/dto/simplified/DisplayData.java b/bundles/org.openhab.binding.enturno/src/main/java/org/openhab/binding/enturno/internal/dto/simplified/DisplayData.java
new file mode 100644 (file)
index 0000000..2ed9afd
--- /dev/null
@@ -0,0 +1,36 @@
+/**
+ * Copyright (c) 2010-2023 Contributors to the openHAB project
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package org.openhab.binding.enturno.internal.dto.simplified;
+
+import java.util.List;
+
+/**
+ * {@link DisplayData} is a Plain Old Java Objects class to wrap only needed data after processing API call results.
+ *
+ * @author Michal Kloc - Initial contribution
+ */
+public class DisplayData {
+    public String stopPlaceId;
+
+    public String stopName;
+
+    public String transportMode;
+
+    public String lineCode;
+
+    public String frontText;
+
+    public List<String> departures;
+
+    public List<String> estimatedFlags;
+}
diff --git a/bundles/org.openhab.binding.enturno/src/main/java/org/openhab/binding/enturno/internal/dto/stopplace/StopPlace.java b/bundles/org.openhab.binding.enturno/src/main/java/org/openhab/binding/enturno/internal/dto/stopplace/StopPlace.java
new file mode 100644 (file)
index 0000000..7881e29
--- /dev/null
@@ -0,0 +1,30 @@
+/**
+ * Copyright (c) 2010-2023 Contributors to the openHAB project
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package org.openhab.binding.enturno.internal.dto.stopplace;
+
+import org.openhab.binding.enturno.internal.dto.estimated.EstimatedCalls;
+
+/**
+ * Generated Plain Old Java Objects class for {@link StopPlace} from JSON.
+ *
+ * @author Michal Kloc - Initial contribution
+ */
+public class StopPlace {
+    public java.util.List<EstimatedCalls> estimatedCalls;
+
+    public String name;
+
+    public String id;
+
+    public String transportMode;
+}
diff --git a/bundles/org.openhab.binding.enturno/src/main/java/org/openhab/binding/enturno/internal/model/Data.java b/bundles/org.openhab.binding.enturno/src/main/java/org/openhab/binding/enturno/internal/model/Data.java
deleted file mode 100644 (file)
index f17de89..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0
- *
- * SPDX-License-Identifier: EPL-2.0
- */
-package org.openhab.binding.enturno.internal.model;
-
-import org.openhab.binding.enturno.internal.model.stopplace.StopPlace;
-
-/**
- * Generated Plain Old Java Objects class for {@link Data} from JSON.
- *
- * @author Michal Kloc - Initial contribution
- */
-public class Data {
-    public StopPlace stopPlace;
-}
diff --git a/bundles/org.openhab.binding.enturno/src/main/java/org/openhab/binding/enturno/internal/model/EnturData.java b/bundles/org.openhab.binding.enturno/src/main/java/org/openhab/binding/enturno/internal/model/EnturData.java
deleted file mode 100644 (file)
index b6d5db3..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0
- *
- * SPDX-License-Identifier: EPL-2.0
- */
-package org.openhab.binding.enturno.internal.model;
-
-/**
- * Generated Plain Old Java Objects class for {@link Data} from JSON.
- *
- * @author Michal Kloc - Initial contribution
- */
-public class EnturData {
-    public Data data;
-}
diff --git a/bundles/org.openhab.binding.enturno/src/main/java/org/openhab/binding/enturno/internal/model/EnturJsonData.java b/bundles/org.openhab.binding.enturno/src/main/java/org/openhab/binding/enturno/internal/model/EnturJsonData.java
deleted file mode 100644 (file)
index 446a5ce..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0
- *
- * SPDX-License-Identifier: EPL-2.0
- */
-package org.openhab.binding.enturno.internal.model;
-
-/**
- * {@link EnturJsonData} is a root level class to holding reference of data generated from JSON.
- *
- * @author Michal Kloc - Initial contribution
- */
-public class EnturJsonData {
-    public Data data;
-}
diff --git a/bundles/org.openhab.binding.enturno/src/main/java/org/openhab/binding/enturno/internal/model/estimated/DestinationDisplay.java b/bundles/org.openhab.binding.enturno/src/main/java/org/openhab/binding/enturno/internal/model/estimated/DestinationDisplay.java
deleted file mode 100644 (file)
index d16d3c3..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0
- *
- * SPDX-License-Identifier: EPL-2.0
- */
-package org.openhab.binding.enturno.internal.model.estimated;
-
-/**
- * Generated Plain Old Java Objects class for {@link DestinationDisplay} from JSON.
- *
- * @author Michal Kloc - Initial contribution
- */
-public class DestinationDisplay {
-    public String frontText;
-}
diff --git a/bundles/org.openhab.binding.enturno/src/main/java/org/openhab/binding/enturno/internal/model/estimated/EstimatedCalls.java b/bundles/org.openhab.binding.enturno/src/main/java/org/openhab/binding/enturno/internal/model/estimated/EstimatedCalls.java
deleted file mode 100644 (file)
index 52f51a7..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0
- *
- * SPDX-License-Identifier: EPL-2.0
- */
-package org.openhab.binding.enturno.internal.model.estimated;
-
-/**
- * Generated Plain Old Java Objects class for {@link EstimatedCalls} from JSON.
- *
- * @author Michal Kloc - Initial contribution
- */
-public class EstimatedCalls {
-    public String aimedArrivalTime;
-
-    public String date;
-
-    public String realtime;
-
-    public String expectedDepartureTime;
-
-    public String forAlighting;
-
-    public DestinationDisplay destinationDisplay;
-
-    public String forBoarding;
-
-    public ServiceJourney serviceJourney;
-
-    public Quay quay;
-
-    public String aimedDepartureTime;
-
-    public String expectedArrivalTime;
-}
diff --git a/bundles/org.openhab.binding.enturno/src/main/java/org/openhab/binding/enturno/internal/model/estimated/JourneyPattern.java b/bundles/org.openhab.binding.enturno/src/main/java/org/openhab/binding/enturno/internal/model/estimated/JourneyPattern.java
deleted file mode 100644 (file)
index 39bbcd5..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0
- *
- * SPDX-License-Identifier: EPL-2.0
- */
-package org.openhab.binding.enturno.internal.model.estimated;
-
-/**
- * Generated Plain Old Java Objects class for {@link JourneyPattern} from JSON.
- *
- * @author Michal Kloc - Initial contribution
- */
-public class JourneyPattern {
-    public Line line;
-}
diff --git a/bundles/org.openhab.binding.enturno/src/main/java/org/openhab/binding/enturno/internal/model/estimated/Line.java b/bundles/org.openhab.binding.enturno/src/main/java/org/openhab/binding/enturno/internal/model/estimated/Line.java
deleted file mode 100644 (file)
index 068d066..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0
- *
- * SPDX-License-Identifier: EPL-2.0
- */
-package org.openhab.binding.enturno.internal.model.estimated;
-
-/**
- * Generated Plain Old Java Objects class for {@link Line} from JSON.
- *
- * @author Michal Kloc - Initial contribution
- */
-public class Line {
-    public String name;
-
-    public String transportMode;
-
-    public String publicCode;
-
-    public String id;
-}
diff --git a/bundles/org.openhab.binding.enturno/src/main/java/org/openhab/binding/enturno/internal/model/estimated/Quay.java b/bundles/org.openhab.binding.enturno/src/main/java/org/openhab/binding/enturno/internal/model/estimated/Quay.java
deleted file mode 100644 (file)
index 1140724..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0
- *
- * SPDX-License-Identifier: EPL-2.0
- */
-package org.openhab.binding.enturno.internal.model.estimated;
-
-/**
- * Generated Plain Old Java Objects class for {@link Quay} from JSON.
- *
- * @author Michal Kloc - Initial contribution
- */
-public class Quay {
-    public String publicCode;
-
-    public String id;
-}
diff --git a/bundles/org.openhab.binding.enturno/src/main/java/org/openhab/binding/enturno/internal/model/estimated/ServiceJourney.java b/bundles/org.openhab.binding.enturno/src/main/java/org/openhab/binding/enturno/internal/model/estimated/ServiceJourney.java
deleted file mode 100644 (file)
index 7b7dbb9..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0
- *
- * SPDX-License-Identifier: EPL-2.0
- */
-package org.openhab.binding.enturno.internal.model.estimated;
-
-/**
- * Generated Plain Old Java Objects class for {@link ServiceJourney} from JSON.
- *
- * @author Michal Kloc - Initial contribution
- */
-public class ServiceJourney {
-    public JourneyPattern journeyPattern;
-}
diff --git a/bundles/org.openhab.binding.enturno/src/main/java/org/openhab/binding/enturno/internal/model/simplified/DisplayData.java b/bundles/org.openhab.binding.enturno/src/main/java/org/openhab/binding/enturno/internal/model/simplified/DisplayData.java
deleted file mode 100644 (file)
index bf210c3..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0
- *
- * SPDX-License-Identifier: EPL-2.0
- */
-package org.openhab.binding.enturno.internal.model.simplified;
-
-import java.util.List;
-
-/**
- * {@link DisplayData} is a Plain Old Java Objects class to wrap only needed data after processing API call results.
- *
- * @author Michal Kloc - Initial contribution
- */
-public class DisplayData {
-    public String stopPlaceId;
-
-    public String stopName;
-
-    public String transportMode;
-
-    public String lineCode;
-
-    public String frontText;
-
-    public List<String> departures;
-
-    public List<String> estimatedFlags;
-}
diff --git a/bundles/org.openhab.binding.enturno/src/main/java/org/openhab/binding/enturno/internal/model/stopplace/StopPlace.java b/bundles/org.openhab.binding.enturno/src/main/java/org/openhab/binding/enturno/internal/model/stopplace/StopPlace.java
deleted file mode 100644 (file)
index 0f0492a..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0
- *
- * SPDX-License-Identifier: EPL-2.0
- */
-package org.openhab.binding.enturno.internal.model.stopplace;
-
-import org.openhab.binding.enturno.internal.model.estimated.EstimatedCalls;
-
-/**
- * Generated Plain Old Java Objects class for {@link StopPlace} from JSON.
- *
- * @author Michal Kloc - Initial contribution
- */
-public class StopPlace {
-    public java.util.List<EstimatedCalls> estimatedCalls;
-
-    public String name;
-
-    public String id;
-
-    public String transportMode;
-}
diff --git a/bundles/org.openhab.binding.enturno/src/main/java/org/openhab/binding/enturno/internal/util/DateUtil.java b/bundles/org.openhab.binding.enturno/src/main/java/org/openhab/binding/enturno/internal/util/DateUtil.java
new file mode 100644 (file)
index 0000000..4f1be63
--- /dev/null
@@ -0,0 +1,51 @@
+/**
+ * Copyright (c) 2010-2023 Contributors to the openHAB project
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package org.openhab.binding.enturno.internal.util;
+
+import java.time.ZonedDateTime;
+import java.time.format.DateTimeFormatter;
+import java.time.format.DateTimeParseException;
+
+import org.eclipse.jdt.annotation.NonNullByDefault;
+
+/**
+ * EnturNo date utility methods.
+ *
+ * @author Jacob Laursen - Initial contribution
+ */
+@NonNullByDefault
+public class DateUtil {
+    /**
+     * Converts a zoned date time string that lacks a colon in the zone to an ISO-8601 formatted string.
+     * 
+     * @param dateTimeWithoutColonInZone
+     * @return ISO-8601 formatted string
+     */
+    public static String getIsoDateTime(String dateTimeWithoutColonInZone) {
+        ZonedDateTime zonedDateTime = null;
+        try {
+            zonedDateTime = ZonedDateTime.parse(dateTimeWithoutColonInZone);
+        } catch (DateTimeParseException e) {
+            // Skip
+        }
+        try {
+            zonedDateTime = ZonedDateTime.parse(dateTimeWithoutColonInZone.replaceAll("(\\d{2})(\\d{2})$", "$1:$2"));
+        } catch (DateTimeParseException e) {
+            // Skip
+        }
+        if (zonedDateTime != null) {
+            return DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(zonedDateTime);
+        }
+        return dateTimeWithoutColonInZone;
+    }
+}
diff --git a/bundles/org.openhab.binding.enturno/src/test/java/org/openhab/binding/enturno/internal/util/DateUtilTest.java b/bundles/org.openhab.binding.enturno/src/test/java/org/openhab/binding/enturno/internal/util/DateUtilTest.java
new file mode 100644 (file)
index 0000000..c9ac27d
--- /dev/null
@@ -0,0 +1,46 @@
+/**
+ * Copyright (c) 2010-2023 Contributors to the openHAB project
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package org.openhab.binding.enturno.internal.util;
+
+import static org.hamcrest.CoreMatchers.*;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+import java.util.stream.Stream;
+
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
+
+/**
+ * Tests for {@link DateUtil}.
+ *
+ * @author Jacob Laursen - Initial contribution
+ */
+@NonNullByDefault
+public class DateUtilTest {
+    @ParameterizedTest
+    @MethodSource("provideTestCasesForGetIsoDateTime")
+    void getIsoDateTime(String value, String expected) {
+        assertThat(DateUtil.getIsoDateTime(value), is(expected));
+    }
+
+    private static Stream<Arguments> provideTestCasesForGetIsoDateTime() {
+        return Stream.of( //
+                Arguments.of("2023-10-25T09:01:00+0200", "2023-10-25T09:01:00+02:00"),
+                Arguments.of("2023-10-25T09:01:00+02:00", "2023-10-25T09:01:00+02:00"),
+                Arguments.of("2023-10-25T09:01:00-0300", "2023-10-25T09:01:00-03:00"),
+                Arguments.of("2023-10-25T09:01:00+02:30", "2023-10-25T09:01:00+02:30"),
+                Arguments.of("2023-10-25T09:01:00", "2023-10-25T09:01:00"));
+    }
+}