]> git.basschouten.com Git - openhab-addons.git/commitdiff
[neeo] Remove org.apache.common (#14442)
authorlsiepel <leosiepel@gmail.com>
Sat, 21 Oct 2023 20:25:29 +0000 (22:25 +0200)
committerGitHub <noreply@github.com>
Sat, 21 Oct 2023 20:25:29 +0000 (22:25 +0200)
Signed-off-by: Leo Siepel <leosiepel@gmail.com>
bundles/org.openhab.io.neeo/src/main/java/org/openhab/io/neeo/internal/AbstractServlet.java
bundles/org.openhab.io.neeo/src/main/java/org/openhab/io/neeo/internal/OpenHabToDeviceConverter.java
bundles/org.openhab.io.neeo/src/main/java/org/openhab/io/neeo/internal/ServiceContext.java
bundles/org.openhab.io.neeo/src/main/java/org/openhab/io/neeo/internal/models/NeeoThingUID.java
bundles/org.openhab.io.neeo/src/main/java/org/openhab/io/neeo/internal/util/StringUtils.java [new file with mode: 0644]

index 5332e60d928e7091b4800df40a55c5110dd94226..36c97cac4e4d2e13e103a94dc378f228e6aefd07 100644 (file)
@@ -23,13 +23,13 @@ import javax.servlet.http.HttpServlet;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
-import org.apache.commons.lang3.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.core.events.Event;
 import org.openhab.core.events.EventFilter;
 import org.openhab.io.neeo.NeeoService;
 import org.openhab.io.neeo.internal.servletservices.ServletService;
+import org.openhab.io.neeo.internal.util.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -115,7 +115,7 @@ public abstract class AbstractServlet extends HttpServlet implements AutoCloseab
             return;
         }
 
-        final String[] paths = StringUtils.split(pathInfo.startsWith("/") ? pathInfo.substring(1) : pathInfo, '/');
+        final String[] paths = StringUtils.split(pathInfo.startsWith("/") ? pathInfo.substring(1) : pathInfo, "/");
         final ServletService service = getService(paths);
 
         if (service == null) {
@@ -142,7 +142,7 @@ public abstract class AbstractServlet extends HttpServlet implements AutoCloseab
         }
 
         final String pathInfo = NeeoUtil.decodeURIComponent(req.getPathInfo());
-        final String[] paths = StringUtils.split(pathInfo.startsWith("/") ? pathInfo.substring(1) : pathInfo, '/');
+        final String[] paths = StringUtils.split(pathInfo.startsWith("/") ? pathInfo.substring(1) : pathInfo, "/");
         final ServletService service = getService(paths);
 
         if (service == null) {
index bb5a25cfc1f9e48339a142242637f9ed9b7f1809..a9fe8665a4eaf307e57d33f9e6a05b5214a5249d 100644 (file)
@@ -20,7 +20,6 @@ import java.util.Map;
 import java.util.Objects;
 import java.util.Set;
 
-import org.apache.commons.lang3.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.core.items.Item;
@@ -38,6 +37,7 @@ import org.openhab.io.neeo.internal.models.NeeoDeviceChannel;
 import org.openhab.io.neeo.internal.models.NeeoDeviceTiming;
 import org.openhab.io.neeo.internal.models.NeeoDeviceType;
 import org.openhab.io.neeo.internal.models.NeeoThingUID;
+import org.openhab.io.neeo.internal.util.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -146,7 +146,7 @@ class OpenHabToDeviceConverter {
             final NeeoDeviceTiming timing = new NeeoDeviceTiming(standbyDelay, switchDelay, shutDownDelay);
 
             final String dc = properties.get("Device Capabilities");
-            final String[] deviceCapabilities = dc == null || dc.isEmpty() ? new String[0] : StringUtils.split(dc, ',');
+            final String[] deviceCapabilities = dc == null || dc.isEmpty() ? new String[0] : StringUtils.split(dc, ",");
 
             try {
                 return new NeeoDevice(new NeeoThingUID(thing.getUID()), 0,
index 3e8f00e9e992555852dbd8dba09e863f45049a26..cd9c860655f9bf988cd9f77334d103faa48b3894 100644 (file)
@@ -15,7 +15,6 @@ package org.openhab.io.neeo.internal;
 import java.util.Objects;
 import java.util.UUID;
 
-import org.apache.commons.lang3.RandomStringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.core.addon.AddonInfoRegistry;
 import org.openhab.core.events.EventPublisher;
@@ -26,6 +25,7 @@ import org.openhab.core.thing.ThingRegistry;
 import org.openhab.core.thing.link.ItemChannelLinkRegistry;
 import org.openhab.core.thing.type.ChannelTypeRegistry;
 import org.openhab.core.thing.type.ThingTypeRegistry;
+import org.openhab.core.util.StringUtils;
 import org.openhab.io.neeo.internal.models.NeeoThingUID;
 import org.osgi.service.component.ComponentContext;
 import org.osgi.service.http.HttpService;
@@ -238,7 +238,7 @@ public class ServiceContext {
         NeeoUtil.requireNotEmpty(thingType, "thingType cannot be null");
 
         for (int i = 0; i < 100; i++) {
-            final String id = RandomStringUtils.randomAlphanumeric(8);
+            final String id = StringUtils.getRandomAlphanumeric(8);
             final NeeoThingUID uid = new NeeoThingUID(thingType, id);
             if (getThingRegistry().get(uid.asThingUID()) == null) {
                 return uid;
index 1aa803cb1165575f439c867ff8ada5d761a2260b..428a440786fcfeba7b42229cac406830005b0336 100644 (file)
@@ -12,7 +12,6 @@
  */
 package org.openhab.io.neeo.internal.models;
 
-import org.apache.commons.lang3.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.core.thing.ThingUID;
 import org.openhab.io.neeo.internal.NeeoConstants;
@@ -42,8 +41,8 @@ public class NeeoThingUID extends ThingUID {
      * @param thingId the thing ID
      */
     public NeeoThingUID(String thingId) {
-        super(StringUtils.startsWith(thingId, NeeoConstants.NEEO_ADAPTER_PREFIX)
-                ? StringUtils.substring(thingId, NeeoConstants.NEEO_ADAPTER_PREFIX.length())
+        super(thingId.startsWith(NeeoConstants.NEEO_ADAPTER_PREFIX)
+                ? thingId.substring(NeeoConstants.NEEO_ADAPTER_PREFIX.length())
                 : thingId);
     }
 
diff --git a/bundles/org.openhab.io.neeo/src/main/java/org/openhab/io/neeo/internal/util/StringUtils.java b/bundles/org.openhab.io.neeo/src/main/java/org/openhab/io/neeo/internal/util/StringUtils.java
new file mode 100644 (file)
index 0000000..5eb753b
--- /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.io.neeo.internal.util;
+
+import java.util.Arrays;
+
+import org.eclipse.jdt.annotation.NonNullByDefault;
+
+/**
+ * The {@link StringUtils} class defines some static string utility methods
+ *
+ * @author Leo Siepel - Initial contribution
+ */
+@NonNullByDefault
+public class StringUtils {
+
+    public static String[] split(String input, String delimiter) {
+        return Arrays.stream(input.split(delimiter)).filter(str -> !str.isEmpty()).toArray(String[]::new);
+    }
+}