mirror of
https://github.com/danieldemus/openhab-core.git
synced 2025-01-25 19:55:48 +01:00
Removed usage of org.apache.commons.lang.ArrayUtils (#1357)
Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
This commit is contained in:
parent
bb3e8694e3
commit
79523d3a99
@ -21,6 +21,7 @@ import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.WatchEvent;
|
||||
import java.nio.file.WatchEvent.Kind;
|
||||
import java.util.Arrays;
|
||||
import java.util.Dictionary;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
@ -33,8 +34,6 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.openhab.core.config.core.ConfigConstants;
|
||||
import org.openhab.core.model.core.ModelParser;
|
||||
import org.openhab.core.model.core.ModelRepository;
|
||||
@ -109,7 +108,7 @@ public class FolderObserver extends AbstractWatchService {
|
||||
Enumeration<String> keys = config.keys();
|
||||
while (keys.hasMoreElements()) {
|
||||
String foldername = keys.nextElement();
|
||||
if (!StringUtils.isAlphanumeric(foldername)) {
|
||||
if (!foldername.matches("[A-Za-z0-9_]*")) {
|
||||
// we allow only simple alphanumeric names for model folders - everything else might be other service
|
||||
// properties
|
||||
continue;
|
||||
@ -263,15 +262,15 @@ public class FolderObserver extends AbstractWatchService {
|
||||
}
|
||||
|
||||
private File getFileByFileExtMap(Map<String, String[]> folderFileExtMap, String filename) {
|
||||
if (StringUtils.isNotBlank(filename) && isNotEmpty(folderFileExtMap)) {
|
||||
if (filename != null && !filename.trim().isEmpty() && isNotEmpty(folderFileExtMap)) {
|
||||
String extension = getExtension(filename);
|
||||
if (StringUtils.isNotBlank(extension)) {
|
||||
if (extension != null && !extension.trim().isEmpty()) {
|
||||
Set<Entry<String, String[]>> entries = folderFileExtMap.entrySet();
|
||||
Iterator<Entry<String, String[]>> iterator = entries.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Entry<String, String[]> entry = iterator.next();
|
||||
|
||||
if (ArrayUtils.contains(entry.getValue(), extension)) {
|
||||
if (Arrays.stream(entry.getValue()).anyMatch(extension::equals)) {
|
||||
return new File(getFile(entry.getKey()) + File.separator + filename);
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,9 @@ import static org.junit.Assert.assertThat;
|
||||
import static org.mockito.Mockito.*;
|
||||
import static org.mockito.MockitoAnnotations.initMocks;
|
||||
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import java.util.Arrays;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mock;
|
||||
@ -46,7 +48,8 @@ public class HttpServiceUtilTest {
|
||||
ServiceReference<?>[] secureHttpServiceReferences = getSecureHttpServiceReferences();
|
||||
|
||||
when(bundleContext.getAllServiceReferences(ORG_OSGI_SERVICE_HTTP_SERVICE, null)).thenReturn(
|
||||
(ServiceReference<?>[]) ArrayUtils.addAll(httpServiceReferences, secureHttpServiceReferences));
|
||||
Stream.concat(Arrays.stream(httpServiceReferences), Arrays.stream(secureHttpServiceReferences))
|
||||
.toArray(ServiceReference<?>[]::new));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Loading…
Reference in New Issue
Block a user