[neeo] Remove org.apache.common (#14442)

Signed-off-by: Leo Siepel <leosiepel@gmail.com>
This commit is contained in:
lsiepel 2023-10-21 22:25:29 +02:00 committed by GitHub
parent 089b4152c0
commit 38df4ac713
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 39 additions and 10 deletions

View File

@ -23,13 +23,13 @@ import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable; import org.eclipse.jdt.annotation.Nullable;
import org.openhab.core.events.Event; import org.openhab.core.events.Event;
import org.openhab.core.events.EventFilter; import org.openhab.core.events.EventFilter;
import org.openhab.io.neeo.NeeoService; import org.openhab.io.neeo.NeeoService;
import org.openhab.io.neeo.internal.servletservices.ServletService; import org.openhab.io.neeo.internal.servletservices.ServletService;
import org.openhab.io.neeo.internal.util.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -115,7 +115,7 @@ public abstract class AbstractServlet extends HttpServlet implements AutoCloseab
return; 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); final ServletService service = getService(paths);
if (service == null) { if (service == null) {
@ -142,7 +142,7 @@ public abstract class AbstractServlet extends HttpServlet implements AutoCloseab
} }
final String pathInfo = NeeoUtil.decodeURIComponent(req.getPathInfo()); 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); final ServletService service = getService(paths);
if (service == null) { if (service == null) {

View File

@ -20,7 +20,6 @@ import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.Set; import java.util.Set;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable; import org.eclipse.jdt.annotation.Nullable;
import org.openhab.core.items.Item; 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.NeeoDeviceTiming;
import org.openhab.io.neeo.internal.models.NeeoDeviceType; import org.openhab.io.neeo.internal.models.NeeoDeviceType;
import org.openhab.io.neeo.internal.models.NeeoThingUID; import org.openhab.io.neeo.internal.models.NeeoThingUID;
import org.openhab.io.neeo.internal.util.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -146,7 +146,7 @@ class OpenHabToDeviceConverter {
final NeeoDeviceTiming timing = new NeeoDeviceTiming(standbyDelay, switchDelay, shutDownDelay); final NeeoDeviceTiming timing = new NeeoDeviceTiming(standbyDelay, switchDelay, shutDownDelay);
final String dc = properties.get("Device Capabilities"); 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 { try {
return new NeeoDevice(new NeeoThingUID(thing.getUID()), 0, return new NeeoDevice(new NeeoThingUID(thing.getUID()), 0,

View File

@ -15,7 +15,6 @@ package org.openhab.io.neeo.internal;
import java.util.Objects; import java.util.Objects;
import java.util.UUID; import java.util.UUID;
import org.apache.commons.lang3.RandomStringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.core.addon.AddonInfoRegistry; import org.openhab.core.addon.AddonInfoRegistry;
import org.openhab.core.events.EventPublisher; 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.link.ItemChannelLinkRegistry;
import org.openhab.core.thing.type.ChannelTypeRegistry; import org.openhab.core.thing.type.ChannelTypeRegistry;
import org.openhab.core.thing.type.ThingTypeRegistry; import org.openhab.core.thing.type.ThingTypeRegistry;
import org.openhab.core.util.StringUtils;
import org.openhab.io.neeo.internal.models.NeeoThingUID; import org.openhab.io.neeo.internal.models.NeeoThingUID;
import org.osgi.service.component.ComponentContext; import org.osgi.service.component.ComponentContext;
import org.osgi.service.http.HttpService; import org.osgi.service.http.HttpService;
@ -238,7 +238,7 @@ public class ServiceContext {
NeeoUtil.requireNotEmpty(thingType, "thingType cannot be null"); NeeoUtil.requireNotEmpty(thingType, "thingType cannot be null");
for (int i = 0; i < 100; i++) { 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); final NeeoThingUID uid = new NeeoThingUID(thingType, id);
if (getThingRegistry().get(uid.asThingUID()) == null) { if (getThingRegistry().get(uid.asThingUID()) == null) {
return uid; return uid;

View File

@ -12,7 +12,6 @@
*/ */
package org.openhab.io.neeo.internal.models; package org.openhab.io.neeo.internal.models;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.core.thing.ThingUID; import org.openhab.core.thing.ThingUID;
import org.openhab.io.neeo.internal.NeeoConstants; import org.openhab.io.neeo.internal.NeeoConstants;
@ -42,8 +41,8 @@ public class NeeoThingUID extends ThingUID {
* @param thingId the thing ID * @param thingId the thing ID
*/ */
public NeeoThingUID(String thingId) { public NeeoThingUID(String thingId) {
super(StringUtils.startsWith(thingId, NeeoConstants.NEEO_ADAPTER_PREFIX) super(thingId.startsWith(NeeoConstants.NEEO_ADAPTER_PREFIX)
? StringUtils.substring(thingId, NeeoConstants.NEEO_ADAPTER_PREFIX.length()) ? thingId.substring(NeeoConstants.NEEO_ADAPTER_PREFIX.length())
: thingId); : thingId);
} }

View File

@ -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);
}
}