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;
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) {
}
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) {
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;
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;
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,
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;
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;
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;
*/
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;
* @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);
}
--- /dev/null
+/**
+ * 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);
+ }
+}