Skip to content

Commit 38df4ac

Browse files
authored
[neeo] Remove org.apache.common (openhab#14442)
Signed-off-by: Leo Siepel <[email protected]>
1 parent 089b415 commit 38df4ac

File tree

5 files changed

+39
-10
lines changed

5 files changed

+39
-10
lines changed

bundles/org.openhab.io.neeo/src/main/java/org/openhab/io/neeo/internal/AbstractServlet.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@
2323
import javax.servlet.http.HttpServletRequest;
2424
import javax.servlet.http.HttpServletResponse;
2525

26-
import org.apache.commons.lang3.StringUtils;
2726
import org.eclipse.jdt.annotation.NonNullByDefault;
2827
import org.eclipse.jdt.annotation.Nullable;
2928
import org.openhab.core.events.Event;
3029
import org.openhab.core.events.EventFilter;
3130
import org.openhab.io.neeo.NeeoService;
3231
import org.openhab.io.neeo.internal.servletservices.ServletService;
32+
import org.openhab.io.neeo.internal.util.StringUtils;
3333
import org.slf4j.Logger;
3434
import org.slf4j.LoggerFactory;
3535

@@ -115,7 +115,7 @@ protected void doGet(@Nullable HttpServletRequest req, @Nullable HttpServletResp
115115
return;
116116
}
117117

118-
final String[] paths = StringUtils.split(pathInfo.startsWith("/") ? pathInfo.substring(1) : pathInfo, '/');
118+
final String[] paths = StringUtils.split(pathInfo.startsWith("/") ? pathInfo.substring(1) : pathInfo, "/");
119119
final ServletService service = getService(paths);
120120

121121
if (service == null) {
@@ -142,7 +142,7 @@ protected void doPost(@Nullable HttpServletRequest req, @Nullable HttpServletRes
142142
}
143143

144144
final String pathInfo = NeeoUtil.decodeURIComponent(req.getPathInfo());
145-
final String[] paths = StringUtils.split(pathInfo.startsWith("/") ? pathInfo.substring(1) : pathInfo, '/');
145+
final String[] paths = StringUtils.split(pathInfo.startsWith("/") ? pathInfo.substring(1) : pathInfo, "/");
146146
final ServletService service = getService(paths);
147147

148148
if (service == null) {

bundles/org.openhab.io.neeo/src/main/java/org/openhab/io/neeo/internal/OpenHabToDeviceConverter.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import java.util.Objects;
2121
import java.util.Set;
2222

23-
import org.apache.commons.lang3.StringUtils;
2423
import org.eclipse.jdt.annotation.NonNullByDefault;
2524
import org.eclipse.jdt.annotation.Nullable;
2625
import org.openhab.core.items.Item;
@@ -38,6 +37,7 @@
3837
import org.openhab.io.neeo.internal.models.NeeoDeviceTiming;
3938
import org.openhab.io.neeo.internal.models.NeeoDeviceType;
4039
import org.openhab.io.neeo.internal.models.NeeoThingUID;
40+
import org.openhab.io.neeo.internal.util.StringUtils;
4141
import org.slf4j.Logger;
4242
import org.slf4j.LoggerFactory;
4343

@@ -146,7 +146,7 @@ NeeoDevice convert(Thing thing) {
146146
final NeeoDeviceTiming timing = new NeeoDeviceTiming(standbyDelay, switchDelay, shutDownDelay);
147147

148148
final String dc = properties.get("Device Capabilities");
149-
final String[] deviceCapabilities = dc == null || dc.isEmpty() ? new String[0] : StringUtils.split(dc, ',');
149+
final String[] deviceCapabilities = dc == null || dc.isEmpty() ? new String[0] : StringUtils.split(dc, ",");
150150

151151
try {
152152
return new NeeoDevice(new NeeoThingUID(thing.getUID()), 0,

bundles/org.openhab.io.neeo/src/main/java/org/openhab/io/neeo/internal/ServiceContext.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import java.util.Objects;
1616
import java.util.UUID;
1717

18-
import org.apache.commons.lang3.RandomStringUtils;
1918
import org.eclipse.jdt.annotation.NonNullByDefault;
2019
import org.openhab.core.addon.AddonInfoRegistry;
2120
import org.openhab.core.events.EventPublisher;
@@ -26,6 +25,7 @@
2625
import org.openhab.core.thing.link.ItemChannelLinkRegistry;
2726
import org.openhab.core.thing.type.ChannelTypeRegistry;
2827
import org.openhab.core.thing.type.ThingTypeRegistry;
28+
import org.openhab.core.util.StringUtils;
2929
import org.openhab.io.neeo.internal.models.NeeoThingUID;
3030
import org.osgi.service.component.ComponentContext;
3131
import org.osgi.service.http.HttpService;
@@ -238,7 +238,7 @@ public NeeoThingUID generate(String thingType) {
238238
NeeoUtil.requireNotEmpty(thingType, "thingType cannot be null");
239239

240240
for (int i = 0; i < 100; i++) {
241-
final String id = RandomStringUtils.randomAlphanumeric(8);
241+
final String id = StringUtils.getRandomAlphanumeric(8);
242242
final NeeoThingUID uid = new NeeoThingUID(thingType, id);
243243
if (getThingRegistry().get(uid.asThingUID()) == null) {
244244
return uid;

bundles/org.openhab.io.neeo/src/main/java/org/openhab/io/neeo/internal/models/NeeoThingUID.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
*/
1313
package org.openhab.io.neeo.internal.models;
1414

15-
import org.apache.commons.lang3.StringUtils;
1615
import org.eclipse.jdt.annotation.NonNullByDefault;
1716
import org.openhab.core.thing.ThingUID;
1817
import org.openhab.io.neeo.internal.NeeoConstants;
@@ -42,8 +41,8 @@ public NeeoThingUID(ThingUID uid) {
4241
* @param thingId the thing ID
4342
*/
4443
public NeeoThingUID(String thingId) {
45-
super(StringUtils.startsWith(thingId, NeeoConstants.NEEO_ADAPTER_PREFIX)
46-
? StringUtils.substring(thingId, NeeoConstants.NEEO_ADAPTER_PREFIX.length())
44+
super(thingId.startsWith(NeeoConstants.NEEO_ADAPTER_PREFIX)
45+
? thingId.substring(NeeoConstants.NEEO_ADAPTER_PREFIX.length())
4746
: thingId);
4847
}
4948

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/**
2+
* Copyright (c) 2010-2023 Contributors to the openHAB project
3+
*
4+
* See the NOTICE file(s) distributed with this work for additional
5+
* information.
6+
*
7+
* This program and the accompanying materials are made available under the
8+
* terms of the Eclipse Public License 2.0 which is available at
9+
* http://www.eclipse.org/legal/epl-2.0
10+
*
11+
* SPDX-License-Identifier: EPL-2.0
12+
*/
13+
package org.openhab.io.neeo.internal.util;
14+
15+
import java.util.Arrays;
16+
17+
import org.eclipse.jdt.annotation.NonNullByDefault;
18+
19+
/**
20+
* The {@link StringUtils} class defines some static string utility methods
21+
*
22+
* @author Leo Siepel - Initial contribution
23+
*/
24+
@NonNullByDefault
25+
public class StringUtils {
26+
27+
public static String[] split(String input, String delimiter) {
28+
return Arrays.stream(input.split(delimiter)).filter(str -> !str.isEmpty()).toArray(String[]::new);
29+
}
30+
}

0 commit comments

Comments
 (0)