mirror of
https://github.com/danieldemus/openhab-core.git
synced 2025-01-10 13:21:53 +01:00
Simplify code using Stream.toList (#3831)
Stream.toList was introduced in Java 16 and creates an unmodifiable List so it can be used to simplify code whenever the List is not expected to be modified. Signed-off-by: Wouter Born <github@maindrain.net>
This commit is contained in:
parent
2794c973d3
commit
09b3160a55
@ -25,7 +25,6 @@ import java.nio.file.Path;
|
|||||||
import java.nio.file.StandardCopyOption;
|
import java.nio.file.StandardCopyOption;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import org.apache.karaf.kar.KarService;
|
import org.apache.karaf.kar.KarService;
|
||||||
@ -123,7 +122,7 @@ public class CommunityKarafAddonHandler implements MarketplaceAddonHandler {
|
|||||||
try {
|
try {
|
||||||
Path addonPath = getAddonCacheDirectory(addon.getUid());
|
Path addonPath = getAddonCacheDirectory(addon.getUid());
|
||||||
List<String> repositories = karService.list();
|
List<String> repositories = karService.list();
|
||||||
for (Path path : karFilesStream(addonPath).collect(Collectors.toList())) {
|
for (Path path : karFilesStream(addonPath).toList()) {
|
||||||
String karRepoName = pathToKarRepoName(path);
|
String karRepoName = pathToKarRepoName(path);
|
||||||
if (repositories.contains(karRepoName)) {
|
if (repositories.contains(karRepoName)) {
|
||||||
karService.uninstall(karRepoName);
|
karService.uninstall(karRepoName);
|
||||||
|
@ -23,7 +23,6 @@ import java.util.Locale;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.eclipse.jdt.annotation.Nullable;
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
@ -117,7 +116,7 @@ public abstract class AbstractRemoteAddonService implements AddonService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// create lookup list to make sure installed addons take precedence
|
// create lookup list to make sure installed addons take precedence
|
||||||
List<String> installedAddons = addons.stream().map(Addon::getUid).collect(Collectors.toList());
|
List<String> installedAddons = addons.stream().map(Addon::getUid).toList();
|
||||||
|
|
||||||
if (remoteEnabled()) {
|
if (remoteEnabled()) {
|
||||||
List<Addon> remoteAddons = Objects.requireNonNullElse(cachedRemoteAddons.getValue(), List.of());
|
List<Addon> remoteAddons = Objects.requireNonNullElse(cachedRemoteAddons.getValue(), List.of());
|
||||||
|
@ -30,7 +30,6 @@ import java.util.Objects;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
@ -188,7 +187,7 @@ public class CommunityMarketplaceAddonService extends AbstractRemoteAddonService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
List<DiscourseUser> users = pages.stream().flatMap(p -> Stream.of(p.users)).collect(Collectors.toList());
|
List<DiscourseUser> users = pages.stream().flatMap(p -> Stream.of(p.users)).toList();
|
||||||
pages.stream().flatMap(p -> Stream.of(p.topicList.topics))
|
pages.stream().flatMap(p -> Stream.of(p.topicList.topics))
|
||||||
.filter(t -> showUnpublished || Arrays.asList(t.tags).contains(PUBLISHED_TAG))
|
.filter(t -> showUnpublished || Arrays.asList(t.tags).contains(PUBLISHED_TAG))
|
||||||
.map(t -> Optional.ofNullable(convertTopicItemToAddon(t, users)))
|
.map(t -> Optional.ofNullable(convertTopicItemToAddon(t, users)))
|
||||||
|
@ -14,7 +14,6 @@ package org.openhab.core.addon.marketplace.internal.community;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
@ -46,7 +45,7 @@ final class SerializedNameAnnotationIntrospector extends AnnotationIntrospector
|
|||||||
@NonNullByDefault({})
|
@NonNullByDefault({})
|
||||||
public List<PropertyName> findPropertyAliases(Annotated annotated) {
|
public List<PropertyName> findPropertyAliases(Annotated annotated) {
|
||||||
return Optional.ofNullable(annotated.getAnnotation(SerializedName.class))
|
return Optional.ofNullable(annotated.getAnnotation(SerializedName.class))
|
||||||
.map(s -> Stream.of(s.alternate()).map(PropertyName::new).collect(Collectors.toList()))
|
.map(s -> Stream.of(s.alternate()).map(PropertyName::new).toList())
|
||||||
.orElseGet(() -> super.findPropertyAliases(annotated));
|
.orElseGet(() -> super.findPropertyAliases(annotated));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,7 +25,6 @@ import java.util.List;
|
|||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.eclipse.jdt.annotation.Nullable;
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
@ -133,8 +132,7 @@ public class JsonAddonService extends AbstractRemoteAddonService {
|
|||||||
return List.of();
|
return List.of();
|
||||||
}
|
}
|
||||||
}).flatMap(List::stream).filter(Objects::nonNull).map(e -> (AddonEntryDTO) e)
|
}).flatMap(List::stream).filter(Objects::nonNull).map(e -> (AddonEntryDTO) e)
|
||||||
.filter(e -> showUnstable || "stable".equals(e.maturity)).map(this::fromAddonEntry)
|
.filter(e -> showUnstable || "stable".equals(e.maturity)).map(this::fromAddonEntry).toList();
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -16,7 +16,6 @@ import java.net.URI;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.eclipse.jdt.annotation.Nullable;
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
@ -76,7 +75,7 @@ public class TestAddonService extends AbstractRemoteAddonService {
|
|||||||
remoteCalls++;
|
remoteCalls++;
|
||||||
return REMOTE_ADDONS.stream().map(id -> Addon.create(SERVICE_PID + ":" + id).withType("binding")
|
return REMOTE_ADDONS.stream().map(id -> Addon.create(SERVICE_PID + ":" + id).withType("binding")
|
||||||
.withId(id.substring("binding-".length())).withContentType(TestAddonHandler.TEST_ADDON_CONTENT_TYPE)
|
.withId(id.substring("binding-".length())).withContentType(TestAddonHandler.TEST_ADDON_CONTENT_TYPE)
|
||||||
.withCompatible(!id.equals(INCOMPATIBLE_VERSION)).build()).collect(Collectors.toList());
|
.withCompatible(!id.equals(INCOMPATIBLE_VERSION)).build()).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
package org.openhab.core.audio.internal;
|
package org.openhab.core.audio.internal;
|
||||||
|
|
||||||
import static java.util.Comparator.comparing;
|
import static java.util.Comparator.comparing;
|
||||||
import static java.util.stream.Collectors.toList;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -312,10 +311,10 @@ public class AudioManagerImpl implements AudioManager, ConfigOptionProvider {
|
|||||||
final Locale safeLocale = locale != null ? locale : Locale.getDefault();
|
final Locale safeLocale = locale != null ? locale : Locale.getDefault();
|
||||||
if (CONFIG_DEFAULT_SOURCE.equals(param)) {
|
if (CONFIG_DEFAULT_SOURCE.equals(param)) {
|
||||||
return audioSources.values().stream().sorted(comparing(s -> s.getLabel(safeLocale)))
|
return audioSources.values().stream().sorted(comparing(s -> s.getLabel(safeLocale)))
|
||||||
.map(s -> new ParameterOption(s.getId(), s.getLabel(safeLocale))).collect(toList());
|
.map(s -> new ParameterOption(s.getId(), s.getLabel(safeLocale))).toList();
|
||||||
} else if (CONFIG_DEFAULT_SINK.equals(param)) {
|
} else if (CONFIG_DEFAULT_SINK.equals(param)) {
|
||||||
return audioSinks.values().stream().sorted(comparing(s -> s.getLabel(safeLocale)))
|
return audioSinks.values().stream().sorted(comparing(s -> s.getLabel(safeLocale)))
|
||||||
.map(s -> new ParameterOption(s.getId(), s.getLabel(safeLocale))).collect(toList());
|
.map(s -> new ParameterOption(s.getId(), s.getLabel(safeLocale))).toList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -31,7 +31,6 @@ import java.util.concurrent.ScheduledFuture;
|
|||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import javax.servlet.Servlet;
|
import javax.servlet.Servlet;
|
||||||
@ -172,7 +171,7 @@ public class AudioServlet extends HttpServlet implements AudioHTTPServer {
|
|||||||
final String streamId = substringBefore(substringAfterLast(requestURI, "/"), ".");
|
final String streamId = substringBefore(substringAfterLast(requestURI, "/"), ".");
|
||||||
|
|
||||||
List<String> acceptedMimeTypes = Stream.of(Objects.requireNonNullElse(req.getHeader("Accept"), "").split(","))
|
List<String> acceptedMimeTypes = Stream.of(Objects.requireNonNullElse(req.getHeader("Accept"), "").split(","))
|
||||||
.map(String::trim).collect(Collectors.toList());
|
.map(String::trim).toList();
|
||||||
|
|
||||||
StreamServed servedStream = servedStreams.get(streamId);
|
StreamServed servedStream = servedStreams.get(streamId);
|
||||||
if (servedStream == null) {
|
if (servedStream == null) {
|
||||||
@ -219,7 +218,7 @@ public class AudioServlet extends HttpServlet implements AudioHTTPServer {
|
|||||||
long now = System.nanoTime();
|
long now = System.nanoTime();
|
||||||
final List<String> toRemove = servedStreams.entrySet().stream()
|
final List<String> toRemove = servedStreams.entrySet().stream()
|
||||||
.filter(e -> e.getValue().timeout().get() < now && e.getValue().currentlyServedStream().get() <= 0)
|
.filter(e -> e.getValue().timeout().get() < now && e.getValue().currentlyServedStream().get() <= 0)
|
||||||
.map(Entry::getKey).collect(Collectors.toList());
|
.map(Entry::getKey).toList();
|
||||||
|
|
||||||
toRemove.forEach(streamId -> {
|
toRemove.forEach(streamId -> {
|
||||||
// the stream has expired and no one is using it, we need to remove it!
|
// the stream has expired and no one is using it, we need to remove it!
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
package org.openhab.core.automation.module.media.internal;
|
package org.openhab.core.automation.module.media.internal;
|
||||||
|
|
||||||
import static java.util.Comparator.comparing;
|
import static java.util.Comparator.comparing;
|
||||||
import static java.util.stream.Collectors.toList;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
@ -162,7 +161,7 @@ public class MediaActionTypeProvider implements ModuleTypeProvider {
|
|||||||
private List<ParameterOption> getSinkOptions(@Nullable Locale locale) {
|
private List<ParameterOption> getSinkOptions(@Nullable Locale locale) {
|
||||||
final Locale safeLocale = locale != null ? locale : Locale.getDefault();
|
final Locale safeLocale = locale != null ? locale : Locale.getDefault();
|
||||||
return audioManager.getAllSinks().stream().sorted(comparing(s -> s.getLabel(safeLocale)))
|
return audioManager.getAllSinks().stream().sorted(comparing(s -> s.getLabel(safeLocale)))
|
||||||
.map(s -> new ParameterOption(s.getId(), s.getLabel(safeLocale))).collect(toList());
|
.map(s -> new ParameterOption(s.getId(), s.getLabel(safeLocale))).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -29,7 +29,6 @@ import java.util.concurrent.locks.Lock;
|
|||||||
import java.util.concurrent.locks.ReentrantLock;
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import javax.script.Compilable;
|
import javax.script.Compilable;
|
||||||
import javax.script.CompiledScript;
|
import javax.script.CompiledScript;
|
||||||
@ -246,7 +245,7 @@ public class ScriptTransformationService implements TransformationService, Confi
|
|||||||
|
|
||||||
if (ScriptProfile.CONFIG_TO_HANDLER_SCRIPT.equals(param) || ScriptProfile.CONFIG_TO_ITEM_SCRIPT.equals(param)) {
|
if (ScriptProfile.CONFIG_TO_HANDLER_SCRIPT.equals(param) || ScriptProfile.CONFIG_TO_ITEM_SCRIPT.equals(param)) {
|
||||||
return transformationRegistry.getTransformations(List.of(scriptType.toLowerCase())).stream()
|
return transformationRegistry.getTransformations(List.of(scriptType.toLowerCase())).stream()
|
||||||
.map(c -> new ParameterOption(c.getUID(), c.getLabel())).collect(Collectors.toList());
|
.map(c -> new ParameterOption(c.getUID(), c.getLabel())).toList();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,6 @@ import java.util.Date;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import javax.annotation.security.RolesAllowed;
|
import javax.annotation.security.RolesAllowed;
|
||||||
@ -433,7 +432,7 @@ public class RuleResource implements RESTResource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final Stream<RuleExecution> ruleExecutions = ruleManager.simulateRuleExecutions(fromDate, untilDate);
|
final Stream<RuleExecution> ruleExecutions = ruleManager.simulateRuleExecutions(fromDate, untilDate);
|
||||||
return Response.ok(ruleExecutions.collect(Collectors.toList())).build();
|
return Response.ok(ruleExecutions.toList()).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ZonedDateTime parseTime(String sTime) {
|
private static ZonedDateTime parseTime(String sTime) {
|
||||||
|
@ -14,7 +14,6 @@ package org.openhab.core.automation.rest.internal;
|
|||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import javax.ws.rs.GET;
|
import javax.ws.rs.GET;
|
||||||
import javax.ws.rs.HeaderParam;
|
import javax.ws.rs.HeaderParam;
|
||||||
@ -92,7 +91,7 @@ public class TemplateResource implements RESTResource {
|
|||||||
@HeaderParam("Accept-Language") @Parameter(description = "language") @Nullable String language) {
|
@HeaderParam("Accept-Language") @Parameter(description = "language") @Nullable String language) {
|
||||||
Locale locale = localeService.getLocale(language);
|
Locale locale = localeService.getLocale(language);
|
||||||
Collection<RuleTemplateDTO> result = templateRegistry.getAll(locale).stream()
|
Collection<RuleTemplateDTO> result = templateRegistry.getAll(locale).stream()
|
||||||
.map(template -> RuleTemplateDTOMapper.map(template)).collect(Collectors.toList());
|
.map(template -> RuleTemplateDTOMapper.map(template)).toList();
|
||||||
return Response.ok(result).build();
|
return Response.ok(result).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,7 +30,6 @@ import java.util.Map;
|
|||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNull;
|
import org.eclipse.jdt.annotation.NonNull;
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
@ -388,7 +387,7 @@ public abstract class AbstractResourceBundleProvider<@NonNull E> {
|
|||||||
URI uri = new URI(prefix + ":" + uid + ".name");
|
URI uri = new URI(prefix + ":" + uid + ".name");
|
||||||
return config.stream()
|
return config.stream()
|
||||||
.map(p -> localConfigI18nService.getLocalizedConfigDescriptionParameter(bundle, uri, p, locale))
|
.map(p -> localConfigI18nService.getLocalizedConfigDescriptionParameter(bundle, uri, p, locale))
|
||||||
.collect(Collectors.toList());
|
.toList();
|
||||||
} catch (URISyntaxException e) {
|
} catch (URISyntaxException e) {
|
||||||
logger.error("Constructed invalid uri '{}:{}.name'", prefix, uid, e);
|
logger.error("Constructed invalid uri '{}:{}.name'", prefix, uid, e);
|
||||||
return config;
|
return config;
|
||||||
|
@ -17,7 +17,6 @@ import java.util.Collections;
|
|||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.openhab.core.automation.Module;
|
import org.openhab.core.automation.Module;
|
||||||
@ -37,12 +36,11 @@ public class WrappedRule {
|
|||||||
|
|
||||||
private static <T extends WrappedModule, U extends Module> List<T> map(final List<U> in, Function<U, T> factory,
|
private static <T extends WrappedModule, U extends Module> List<T> map(final List<U> in, Function<U, T> factory,
|
||||||
final Collection<WrappedModule<Module, ModuleHandler>> coll) {
|
final Collection<WrappedModule<Module, ModuleHandler>> coll) {
|
||||||
// explicit cast to List <? extends T> as JDK compiler complains
|
return in.stream().map(module -> {
|
||||||
return Collections.unmodifiableList((List<? extends T>) in.stream().map(module -> {
|
|
||||||
final T impl = factory.apply(module);
|
final T impl = factory.apply(module);
|
||||||
coll.add(impl);
|
coll.add(impl);
|
||||||
return impl;
|
return impl;
|
||||||
}).collect(Collectors.toList()));
|
}).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Rule rule;
|
private final Rule rule;
|
||||||
|
@ -17,7 +17,6 @@ import static java.util.function.Predicate.not;
|
|||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.RoundingMode;
|
import java.math.RoundingMode;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -25,7 +24,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNull;
|
import org.eclipse.jdt.annotation.NonNull;
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
@ -118,14 +117,13 @@ public class ConfigUtil {
|
|||||||
if (defaultValue != null && configuration.get(parameter.getName()) == null) {
|
if (defaultValue != null && configuration.get(parameter.getName()) == null) {
|
||||||
if (parameter.isMultiple()) {
|
if (parameter.isMultiple()) {
|
||||||
if (defaultValue.contains(DEFAULT_LIST_DELIMITER)) {
|
if (defaultValue.contains(DEFAULT_LIST_DELIMITER)) {
|
||||||
List<Object> values = (List<Object>) List.of(defaultValue.split(DEFAULT_LIST_DELIMITER))
|
List<Object> values = (List<Object>) Stream.of(defaultValue.split(DEFAULT_LIST_DELIMITER))
|
||||||
.stream() //
|
|
||||||
.map(String::trim) //
|
.map(String::trim) //
|
||||||
.filter(not(String::isEmpty)) //
|
.filter(not(String::isEmpty)) //
|
||||||
.map(value -> ConfigUtil.getDefaultValueAsCorrectType(parameter.getName(),
|
.map(value -> ConfigUtil.getDefaultValueAsCorrectType(parameter.getName(),
|
||||||
parameter.getType(), value)) //
|
parameter.getType(), value)) //
|
||||||
.filter(Objects::nonNull) //
|
.filter(Objects::nonNull) //
|
||||||
.collect(Collectors.toList());
|
.toList();
|
||||||
Integer multipleLimit = parameter.getMultipleLimit();
|
Integer multipleLimit = parameter.getMultipleLimit();
|
||||||
if (multipleLimit != null && values.size() > multipleLimit.intValue()) {
|
if (multipleLimit != null && values.size() > multipleLimit.intValue()) {
|
||||||
LoggerFactory.getLogger(ConfigUtil.class).warn(
|
LoggerFactory.getLogger(ConfigUtil.class).warn(
|
||||||
@ -136,7 +134,7 @@ public class ConfigUtil {
|
|||||||
} else {
|
} else {
|
||||||
Object value = ConfigUtil.getDefaultValueAsCorrectType(parameter);
|
Object value = ConfigUtil.getDefaultValueAsCorrectType(parameter);
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
configuration.put(parameter.getName(), Arrays.asList(value));
|
configuration.put(parameter.getName(), List.of(value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -21,7 +21,6 @@ import java.util.Locale;
|
|||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.eclipse.jdt.annotation.Nullable;
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
@ -82,7 +81,7 @@ public class I18nConfigOptionsProvider implements ConfigOptionProvider {
|
|||||||
Comparator<TimeZone> byOffset = (t1, t2) -> t1.getRawOffset() - t2.getRawOffset();
|
Comparator<TimeZone> byOffset = (t1, t2) -> t1.getRawOffset() - t2.getRawOffset();
|
||||||
Comparator<TimeZone> byID = (t1, t2) -> t1.getID().compareTo(t2.getID());
|
Comparator<TimeZone> byID = (t1, t2) -> t1.getID().compareTo(t2.getID());
|
||||||
return ZoneId.getAvailableZoneIds().stream().map(TimeZone::getTimeZone).sorted(byOffset.thenComparing(byID))
|
return ZoneId.getAvailableZoneIds().stream().map(TimeZone::getTimeZone).sorted(byOffset.thenComparing(byID))
|
||||||
.map(tz -> new ParameterOption(tz.getID(), getTimeZoneRepresentation(tz))).collect(Collectors.toList());
|
.map(tz -> new ParameterOption(tz.getID(), getTimeZoneRepresentation(tz))).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getTimeZoneRepresentation(TimeZone tz) {
|
private static String getTimeZoneRepresentation(TimeZone tz) {
|
||||||
@ -107,6 +106,6 @@ public class I18nConfigOptionsProvider implements ConfigOptionProvider {
|
|||||||
.distinct() //
|
.distinct() //
|
||||||
.filter(po -> !po.getValue().isEmpty()) //
|
.filter(po -> !po.getValue().isEmpty()) //
|
||||||
.sorted(Comparator.comparing(a -> a.getLabel())) //
|
.sorted(Comparator.comparing(a -> a.getLabel())) //
|
||||||
.collect(Collectors.toList());
|
.toList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@ import java.util.ArrayList;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
@ -52,13 +51,11 @@ public class NetworkConfigOptionProvider implements ConfigOptionProvider {
|
|||||||
case PARAM_PRIMARY_ADDRESS:
|
case PARAM_PRIMARY_ADDRESS:
|
||||||
Stream<CidrAddress> ipv4Addresses = NetUtil.getAllInterfaceAddresses().stream()
|
Stream<CidrAddress> ipv4Addresses = NetUtil.getAllInterfaceAddresses().stream()
|
||||||
.filter(a -> a.getAddress() instanceof Inet4Address);
|
.filter(a -> a.getAddress() instanceof Inet4Address);
|
||||||
return ipv4Addresses.map(a -> new ParameterOption(a.toString(), a.toString()))
|
return ipv4Addresses.map(a -> new ParameterOption(a.toString(), a.toString())).toList();
|
||||||
.collect(Collectors.toList());
|
|
||||||
case PARAM_BROADCAST_ADDRESS:
|
case PARAM_BROADCAST_ADDRESS:
|
||||||
List<String> broadcastAddrList = new ArrayList<>(NetUtil.getAllBroadcastAddresses());
|
List<String> broadcastAddrList = new ArrayList<>(NetUtil.getAllBroadcastAddresses());
|
||||||
broadcastAddrList.add("255.255.255.255");
|
broadcastAddrList.add("255.255.255.255");
|
||||||
return broadcastAddrList.stream().distinct().map(a -> new ParameterOption(a, a))
|
return broadcastAddrList.stream().distinct().map(a -> new ParameterOption(a, a)).toList();
|
||||||
.collect(Collectors.toList());
|
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@ import java.util.Collection;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.eclipse.jdt.annotation.Nullable;
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
@ -137,7 +136,7 @@ public final class ConfigStatusInfo {
|
|||||||
|
|
||||||
private static Collection<ConfigStatusMessage> filterConfigStatusMessages(
|
private static Collection<ConfigStatusMessage> filterConfigStatusMessages(
|
||||||
Collection<ConfigStatusMessage> configStatusMessages, Predicate<? super ConfigStatusMessage> predicate) {
|
Collection<ConfigStatusMessage> configStatusMessages, Predicate<? super ConfigStatusMessage> predicate) {
|
||||||
return configStatusMessages.stream().filter(predicate).collect(Collectors.toList());
|
return configStatusMessages.stream().filter(predicate).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.openhab.core.config.core.internal.normalization;
|
package org.openhab.core.config.core.internal.normalization;
|
||||||
|
|
||||||
import static java.util.stream.Collectors.toList;
|
|
||||||
import static org.hamcrest.CoreMatchers.*;
|
import static org.hamcrest.CoreMatchers.*;
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
|
|
||||||
@ -153,14 +152,13 @@ public class NormalizerTest {
|
|||||||
|
|
||||||
assertThat(normalizer.normalize(null), is(nullValue()));
|
assertThat(normalizer.normalize(null), is(nullValue()));
|
||||||
|
|
||||||
List<Boolean> expectedList = Stream.of(true, false, true).collect(toList());
|
List<Boolean> expectedList = Stream.of(true, false, true).toList();
|
||||||
|
|
||||||
assertThat(normalizer.normalize(Stream.of(true, false, true).collect(toList())), is(equalTo(expectedList)));
|
assertThat(normalizer.normalize(Stream.of(true, false, true).toList()), is(equalTo(expectedList)));
|
||||||
assertThat(normalizer.normalize(Stream.of(true, false, true).collect(toList()).toArray()),
|
assertThat(normalizer.normalize(Stream.of(true, false, true).toArray()), is(equalTo(expectedList)));
|
||||||
is(equalTo(expectedList)));
|
assertThat(normalizer.normalize(new TreeSet<>(Stream.of(false, true).toList())),
|
||||||
assertThat(normalizer.normalize(new TreeSet<>(Stream.of(false, true).collect(toList()))),
|
is(equalTo(Stream.of(false, true).toList())));
|
||||||
is(equalTo(Stream.of(false, true).collect(toList()))));
|
assertThat(normalizer.normalize(Stream.of(true, "false", true).toList()), is(equalTo(expectedList)));
|
||||||
assertThat(normalizer.normalize(Stream.of(true, "false", true).collect(toList())), is(equalTo(expectedList)));
|
assertThat(normalizer.normalize(Stream.of(true, 0, "true").toList()), is(equalTo(expectedList)));
|
||||||
assertThat(normalizer.normalize(Stream.of(true, 0, "true").collect(toList())), is(equalTo(expectedList)));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,6 @@ import java.util.Objects;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.CopyOnWriteArraySet;
|
import java.util.concurrent.CopyOnWriteArraySet;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.eclipse.jdt.annotation.Nullable;
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
@ -214,7 +213,7 @@ public class AutomaticInboxProcessor extends AbstractTypedEventSubscriber<ThingS
|
|||||||
|
|
||||||
private void ignoreInInbox(ThingTypeUID thingtypeUID, String representationValue) {
|
private void ignoreInInbox(ThingTypeUID thingtypeUID, String representationValue) {
|
||||||
List<DiscoveryResult> results = inbox.stream().filter(withRepresentationPropertyValue(representationValue))
|
List<DiscoveryResult> results = inbox.stream().filter(withRepresentationPropertyValue(representationValue))
|
||||||
.filter(forThingTypeUID(thingtypeUID)).collect(Collectors.toList());
|
.filter(forThingTypeUID(thingtypeUID)).toList();
|
||||||
if (results.size() == 1) {
|
if (results.size() == 1) {
|
||||||
logger.debug("Auto-ignoring the inbox entry for the representation value '{}'.", representationValue);
|
logger.debug("Auto-ignoring the inbox entry for the representation value '{}'.", representationValue);
|
||||||
|
|
||||||
@ -252,8 +251,7 @@ public class AutomaticInboxProcessor extends AbstractTypedEventSubscriber<ThingS
|
|||||||
|
|
||||||
private void removeFromInbox(ThingTypeUID thingtypeUID, String representationValue) {
|
private void removeFromInbox(ThingTypeUID thingtypeUID, String representationValue) {
|
||||||
List<DiscoveryResult> results = inbox.stream().filter(withRepresentationPropertyValue(representationValue))
|
List<DiscoveryResult> results = inbox.stream().filter(withRepresentationPropertyValue(representationValue))
|
||||||
.filter(forThingTypeUID(thingtypeUID)).filter(withFlag(DiscoveryResultFlag.IGNORED))
|
.filter(forThingTypeUID(thingtypeUID)).filter(withFlag(DiscoveryResultFlag.IGNORED)).toList();
|
||||||
.collect(Collectors.toList());
|
|
||||||
if (results.size() == 1) {
|
if (results.size() == 1) {
|
||||||
logger.debug("Removing the ignored result from the inbox for the representation value '{}'.",
|
logger.debug("Removing the ignored result from the inbox for the representation value '{}'.",
|
||||||
representationValue);
|
representationValue);
|
||||||
|
@ -33,7 +33,6 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
|||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
import java.util.concurrent.ScheduledFuture;
|
import java.util.concurrent.ScheduledFuture;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
@ -189,7 +188,7 @@ public final class PersistentInbox implements Inbox, DiscoveryListener, ThingReg
|
|||||||
if (thingUID == null) {
|
if (thingUID == null) {
|
||||||
throw new IllegalArgumentException("Thing UID must not be null");
|
throw new IllegalArgumentException("Thing UID must not be null");
|
||||||
}
|
}
|
||||||
List<DiscoveryResult> results = stream().filter(forThingUID(thingUID)).collect(Collectors.toList());
|
List<DiscoveryResult> results = stream().filter(forThingUID(thingUID)).toList();
|
||||||
if (results.isEmpty()) {
|
if (results.isEmpty()) {
|
||||||
throw new IllegalArgumentException("No Thing with UID " + thingUID.getAsString() + " in inbox");
|
throw new IllegalArgumentException("No Thing with UID " + thingUID.getAsString() + " in inbox");
|
||||||
}
|
}
|
||||||
@ -268,7 +267,7 @@ public final class PersistentInbox implements Inbox, DiscoveryListener, ThingReg
|
|||||||
}
|
}
|
||||||
|
|
||||||
List<String> configurationParameters = getConfigDescParams(thingType).stream()
|
List<String> configurationParameters = getConfigDescParams(thingType).stream()
|
||||||
.map(ConfigDescriptionParameter::getName).collect(Collectors.toList());
|
.map(ConfigDescriptionParameter::getName).toList();
|
||||||
|
|
||||||
discoveryResult.normalizePropertiesOnConfigDescription(configurationParameters);
|
discoveryResult.normalizePropertiesOnConfigDescription(configurationParameters);
|
||||||
|
|
||||||
@ -369,7 +368,7 @@ public final class PersistentInbox implements Inbox, DiscoveryListener, ThingReg
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<DiscoveryResult> getAll() {
|
public List<DiscoveryResult> getAll() {
|
||||||
return stream().collect(Collectors.toList());
|
return stream().toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -18,7 +18,6 @@ import java.util.Date;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.openhab.core.config.discovery.DiscoveryResult;
|
import org.openhab.core.config.discovery.DiscoveryResult;
|
||||||
@ -73,8 +72,7 @@ public class InboxConsoleCommandExtension extends AbstractConsoleCommandExtensio
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
ThingUID thingUID = new ThingUID(args[1]);
|
ThingUID thingUID = new ThingUID(args[1]);
|
||||||
List<DiscoveryResult> results = inbox.stream().filter(forThingUID(thingUID))
|
List<DiscoveryResult> results = inbox.stream().filter(forThingUID(thingUID)).toList();
|
||||||
.collect(Collectors.toList());
|
|
||||||
if (results.isEmpty()) {
|
if (results.isEmpty()) {
|
||||||
console.println("No matching inbox entry could be found.");
|
console.println("No matching inbox entry could be found.");
|
||||||
return;
|
return;
|
||||||
@ -102,12 +100,10 @@ public class InboxConsoleCommandExtension extends AbstractConsoleCommandExtensio
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SUBCMD_LIST:
|
case SUBCMD_LIST:
|
||||||
printInboxEntries(console,
|
printInboxEntries(console, inbox.stream().filter(withFlag((DiscoveryResultFlag.NEW))).toList());
|
||||||
inbox.stream().filter(withFlag((DiscoveryResultFlag.NEW))).collect(Collectors.toList()));
|
|
||||||
break;
|
break;
|
||||||
case SUBCMD_LIST_IGNORED:
|
case SUBCMD_LIST_IGNORED:
|
||||||
printInboxEntries(console, inbox.stream().filter(withFlag((DiscoveryResultFlag.IGNORED)))
|
printInboxEntries(console, inbox.stream().filter(withFlag((DiscoveryResultFlag.IGNORED))).toList());
|
||||||
.collect(Collectors.toList()));
|
|
||||||
break;
|
break;
|
||||||
case SUBCMD_CLEAR:
|
case SUBCMD_CLEAR:
|
||||||
clearInboxEntries(console, inbox.getAll());
|
clearInboxEntries(console, inbox.getAll());
|
||||||
@ -117,8 +113,7 @@ public class InboxConsoleCommandExtension extends AbstractConsoleCommandExtensio
|
|||||||
boolean validParam = true;
|
boolean validParam = true;
|
||||||
try {
|
try {
|
||||||
ThingUID thingUID = new ThingUID(args[1]);
|
ThingUID thingUID = new ThingUID(args[1]);
|
||||||
List<DiscoveryResult> results = inbox.stream().filter(forThingUID(thingUID))
|
List<DiscoveryResult> results = inbox.stream().filter(forThingUID(thingUID)).toList();
|
||||||
.collect(Collectors.toList());
|
|
||||||
if (results.isEmpty()) {
|
if (results.isEmpty()) {
|
||||||
console.println("No matching inbox entry could be found.");
|
console.println("No matching inbox entry could be found.");
|
||||||
} else {
|
} else {
|
||||||
@ -131,7 +126,7 @@ public class InboxConsoleCommandExtension extends AbstractConsoleCommandExtensio
|
|||||||
try {
|
try {
|
||||||
ThingTypeUID thingTypeUID = new ThingTypeUID(args[1]);
|
ThingTypeUID thingTypeUID = new ThingTypeUID(args[1]);
|
||||||
List<DiscoveryResult> results = inbox.stream().filter(forThingTypeUID(thingTypeUID))
|
List<DiscoveryResult> results = inbox.stream().filter(forThingTypeUID(thingTypeUID))
|
||||||
.collect(Collectors.toList());
|
.toList();
|
||||||
if (results.isEmpty()) {
|
if (results.isEmpty()) {
|
||||||
console.println("No matching inbox entry could be found.");
|
console.println("No matching inbox entry could be found.");
|
||||||
} else {
|
} else {
|
||||||
|
@ -19,7 +19,6 @@ import static org.openhab.core.config.discovery.inbox.InboxPredicates.*;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
@ -79,89 +78,75 @@ public class InboxPredicatesTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testForBinding() {
|
public void testForBinding() {
|
||||||
assertThat(RESULTS.stream().filter(forBinding(BINDING_ID1)).collect(Collectors.toList()).size(), is(3));
|
assertThat(RESULTS.stream().filter(forBinding(BINDING_ID1)).toList().size(), is(3));
|
||||||
|
|
||||||
assertThat(RESULTS.stream().filter(forBinding(BINDING_ID2)).collect(Collectors.toList()).size(), is(1));
|
assertThat(RESULTS.stream().filter(forBinding(BINDING_ID2)).toList().size(), is(1));
|
||||||
assertThat(RESULTS.stream().filter(forBinding(BINDING_ID2)).collect(Collectors.toList()).get(0),
|
assertThat(RESULTS.stream().filter(forBinding(BINDING_ID2)).toList().get(0), is(equalTo(RESULTS.get(3))));
|
||||||
is(equalTo(RESULTS.get(3))));
|
|
||||||
|
|
||||||
assertThat(RESULTS.stream().filter(forBinding(BINDING_ID2)).filter(withFlag(DiscoveryResultFlag.NEW))
|
assertThat(RESULTS.stream().filter(forBinding(BINDING_ID2)).filter(withFlag(DiscoveryResultFlag.NEW)).toList()
|
||||||
.collect(Collectors.toList()).size(), is(0));
|
.size(), is(0));
|
||||||
|
|
||||||
assertThat(RESULTS.stream().filter(forBinding(BINDING_ID2)).filter(withFlag(DiscoveryResultFlag.IGNORED))
|
assertThat(RESULTS.stream().filter(forBinding(BINDING_ID2)).filter(withFlag(DiscoveryResultFlag.IGNORED))
|
||||||
.collect(Collectors.toList()).size(), is(1));
|
.toList().size(), is(1));
|
||||||
assertThat(RESULTS.stream().filter(forBinding(BINDING_ID2)).filter(withFlag(DiscoveryResultFlag.IGNORED))
|
assertThat(RESULTS.stream().filter(forBinding(BINDING_ID2)).filter(withFlag(DiscoveryResultFlag.IGNORED))
|
||||||
.collect(Collectors.toList()).get(0), is(equalTo(RESULTS.get(3))));
|
.toList().get(0), is(equalTo(RESULTS.get(3))));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testForThingTypeUID() {
|
public void testForThingTypeUID() {
|
||||||
assertThat(RESULTS.stream().filter(forThingTypeUID(THING_TYPE_UID11)).collect(Collectors.toList()).size(),
|
assertThat(RESULTS.stream().filter(forThingTypeUID(THING_TYPE_UID11)).toList().size(), is(2));
|
||||||
is(2));
|
|
||||||
|
|
||||||
assertThat(RESULTS.stream().filter(forThingTypeUID(THING_TYPE_UID12)).collect(Collectors.toList()).size(),
|
assertThat(RESULTS.stream().filter(forThingTypeUID(THING_TYPE_UID12)).toList().size(), is(1));
|
||||||
is(1));
|
assertThat(RESULTS.stream().filter(forThingTypeUID(THING_TYPE_UID12)).toList().get(0),
|
||||||
assertThat(RESULTS.stream().filter(forThingTypeUID(THING_TYPE_UID12)).collect(Collectors.toList()).get(0),
|
|
||||||
is(equalTo(RESULTS.get(2))));
|
is(equalTo(RESULTS.get(2))));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testForThingUID() {
|
public void testForThingUID() {
|
||||||
assertThat(RESULTS.stream().filter(forThingUID(THING_UID11)).collect(Collectors.toList()).size(), is(1));
|
assertThat(RESULTS.stream().filter(forThingUID(THING_UID11)).toList().size(), is(1));
|
||||||
assertThat(RESULTS.stream().filter(forThingUID(THING_UID11)).collect(Collectors.toList()).get(0),
|
assertThat(RESULTS.stream().filter(forThingUID(THING_UID11)).toList().get(0), is(equalTo(RESULTS.get(0))));
|
||||||
is(equalTo(RESULTS.get(0))));
|
|
||||||
|
|
||||||
assertThat(RESULTS.stream().filter(forThingUID(THING_UID12)).collect(Collectors.toList()).size(), is(2));
|
assertThat(RESULTS.stream().filter(forThingUID(THING_UID12)).toList().size(), is(2));
|
||||||
assertThat(RESULTS.stream().filter(forThingUID(THING_UID12)).filter(forThingTypeUID(THING_TYPE_UID12))
|
assertThat(RESULTS.stream().filter(forThingUID(THING_UID12)).filter(forThingTypeUID(THING_TYPE_UID12)).toList()
|
||||||
.collect(Collectors.toList()).size(), is(1));
|
.size(), is(1));
|
||||||
assertThat(RESULTS.stream().filter(forThingUID(THING_UID12)).filter(forThingTypeUID(THING_TYPE_UID12))
|
assertThat(RESULTS.stream().filter(forThingUID(THING_UID12)).filter(forThingTypeUID(THING_TYPE_UID12)).toList()
|
||||||
.collect(Collectors.toList()).get(0), is(equalTo(RESULTS.get(2))));
|
.get(0), is(equalTo(RESULTS.get(2))));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testWithFlag() {
|
public void testWithFlag() {
|
||||||
assertThat(RESULTS.stream().filter(withFlag(DiscoveryResultFlag.NEW)).collect(Collectors.toList()).size(),
|
assertThat(RESULTS.stream().filter(withFlag(DiscoveryResultFlag.NEW)).toList().size(), is(3));
|
||||||
is(3));
|
assertThat(RESULTS.stream().filter(withFlag(DiscoveryResultFlag.IGNORED)).toList().size(), is(1));
|
||||||
assertThat(RESULTS.stream().filter(withFlag(DiscoveryResultFlag.IGNORED)).collect(Collectors.toList()).size(),
|
assertThat(RESULTS.stream().filter(withFlag(DiscoveryResultFlag.IGNORED)).toList().get(0),
|
||||||
is(1));
|
|
||||||
assertThat(RESULTS.stream().filter(withFlag(DiscoveryResultFlag.IGNORED)).collect(Collectors.toList()).get(0),
|
|
||||||
is(equalTo(RESULTS.get(3))));
|
is(equalTo(RESULTS.get(3))));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testWithProperty() {
|
public void testWithProperty() {
|
||||||
assertThat(RESULTS.stream().filter(withProperty(PROP1, PROP_VAL1)).collect(Collectors.toList()).size(), is(2));
|
assertThat(RESULTS.stream().filter(withProperty(PROP1, PROP_VAL1)).toList().size(), is(2));
|
||||||
assertThat(RESULTS.stream().filter(withProperty(PROP2, PROP_VAL2)).collect(Collectors.toList()).size(), is(4));
|
assertThat(RESULTS.stream().filter(withProperty(PROP2, PROP_VAL2)).toList().size(), is(4));
|
||||||
assertThat(RESULTS.stream().filter(withProperty(PROP1, PROP_VAL2)).collect(Collectors.toList()).size(), is(0));
|
assertThat(RESULTS.stream().filter(withProperty(PROP1, PROP_VAL2)).toList().size(), is(0));
|
||||||
assertThat(RESULTS.stream().filter(withProperty(PROP2, PROP_VAL1)).collect(Collectors.toList()).size(), is(0));
|
assertThat(RESULTS.stream().filter(withProperty(PROP2, PROP_VAL1)).toList().size(), is(0));
|
||||||
assertThat(RESULTS.stream().filter(withProperty(null, PROP_VAL1)).collect(Collectors.toList()).size(), is(0));
|
assertThat(RESULTS.stream().filter(withProperty(null, PROP_VAL1)).toList().size(), is(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testWithRepresentationProperty() {
|
public void testWithRepresentationProperty() {
|
||||||
assertThat(RESULTS.stream().filter(withRepresentationProperty(PROP1)).collect(Collectors.toList()).size(),
|
assertThat(RESULTS.stream().filter(withRepresentationProperty(PROP1)).toList().size(), is(1));
|
||||||
is(1));
|
assertThat(RESULTS.stream().filter(withRepresentationProperty(PROP1)).toList().get(0),
|
||||||
assertThat(RESULTS.stream().filter(withRepresentationProperty(PROP1)).collect(Collectors.toList()).get(0),
|
|
||||||
is(equalTo(RESULTS.get(0))));
|
is(equalTo(RESULTS.get(0))));
|
||||||
assertThat(RESULTS.stream().filter(withRepresentationProperty(PROP2)).collect(Collectors.toList()).size(),
|
assertThat(RESULTS.stream().filter(withRepresentationProperty(PROP2)).toList().size(), is(1));
|
||||||
is(1));
|
assertThat(RESULTS.stream().filter(withRepresentationProperty(PROP2)).toList().get(0),
|
||||||
assertThat(RESULTS.stream().filter(withRepresentationProperty(PROP2)).collect(Collectors.toList()).get(0),
|
|
||||||
is(equalTo(RESULTS.get(2))));
|
is(equalTo(RESULTS.get(2))));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testWithRepresentationPropertyValue() {
|
public void testWithRepresentationPropertyValue() {
|
||||||
assertThat(
|
assertThat(RESULTS.stream().filter(withRepresentationPropertyValue(PROP_VAL1)).toList().size(), is(1));
|
||||||
RESULTS.stream().filter(withRepresentationPropertyValue(PROP_VAL1)).collect(Collectors.toList()).size(),
|
assertThat(RESULTS.stream().filter(withRepresentationPropertyValue(PROP_VAL1)).toList().get(0),
|
||||||
is(1));
|
|
||||||
assertThat(
|
|
||||||
RESULTS.stream().filter(withRepresentationPropertyValue(PROP_VAL1)).collect(Collectors.toList()).get(0),
|
|
||||||
is(equalTo(RESULTS.get(0))));
|
is(equalTo(RESULTS.get(0))));
|
||||||
assertThat(
|
assertThat(RESULTS.stream().filter(withRepresentationPropertyValue(PROP_VAL2)).toList().size(), is(1));
|
||||||
RESULTS.stream().filter(withRepresentationPropertyValue(PROP_VAL2)).collect(Collectors.toList()).size(),
|
assertThat(RESULTS.stream().filter(withRepresentationPropertyValue(PROP_VAL2)).toList().get(0),
|
||||||
is(1));
|
|
||||||
assertThat(
|
|
||||||
RESULTS.stream().filter(withRepresentationPropertyValue(PROP_VAL2)).collect(Collectors.toList()).get(0),
|
|
||||||
is(equalTo(RESULTS.get(2))));
|
is(equalTo(RESULTS.get(2))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,6 @@ import java.util.Collections;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
@ -169,8 +168,7 @@ public class AutomaticInboxProcessorTest {
|
|||||||
.withRepresentationProperty(DEVICE_ID_KEY).build());
|
.withRepresentationProperty(DEVICE_ID_KEY).build());
|
||||||
|
|
||||||
// Then there is a discovery result which is NEW
|
// Then there is a discovery result which is NEW
|
||||||
List<DiscoveryResult> results = inbox.stream().filter(withFlag(DiscoveryResultFlag.NEW))
|
List<DiscoveryResult> results = inbox.stream().filter(withFlag(DiscoveryResultFlag.NEW)).toList();
|
||||||
.collect(Collectors.toList());
|
|
||||||
assertThat(results.size(), is(1));
|
assertThat(results.size(), is(1));
|
||||||
assertThat(results.get(0).getThingUID(), is(equalTo(THING_UID)));
|
assertThat(results.get(0).getThingUID(), is(equalTo(THING_UID)));
|
||||||
|
|
||||||
@ -183,10 +181,10 @@ public class AutomaticInboxProcessorTest {
|
|||||||
automaticInboxProcessor.receive(thingStatusInfoChangedEventMock);
|
automaticInboxProcessor.receive(thingStatusInfoChangedEventMock);
|
||||||
|
|
||||||
// Then there should still be the NEW discovery result, but no IGNORED discovery result
|
// Then there should still be the NEW discovery result, but no IGNORED discovery result
|
||||||
results = inbox.stream().filter(withFlag(DiscoveryResultFlag.NEW)).collect(Collectors.toList());
|
results = inbox.stream().filter(withFlag(DiscoveryResultFlag.NEW)).toList();
|
||||||
assertThat(results.size(), is(1));
|
assertThat(results.size(), is(1));
|
||||||
assertThat(results.get(0).getThingUID(), is(equalTo(THING_UID)));
|
assertThat(results.get(0).getThingUID(), is(equalTo(THING_UID)));
|
||||||
results = inbox.stream().filter(withFlag(DiscoveryResultFlag.IGNORED)).collect(Collectors.toList());
|
results = inbox.stream().filter(withFlag(DiscoveryResultFlag.IGNORED)).toList();
|
||||||
assertThat(results.size(), is(0));
|
assertThat(results.size(), is(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -201,12 +199,11 @@ public class AutomaticInboxProcessorTest {
|
|||||||
.withRepresentationProperty(DEVICE_ID_KEY).build());
|
.withRepresentationProperty(DEVICE_ID_KEY).build());
|
||||||
|
|
||||||
// Do NOT ignore this discovery result because it has a different binding ID
|
// Do NOT ignore this discovery result because it has a different binding ID
|
||||||
List<DiscoveryResult> results = inbox.stream().filter(withFlag(DiscoveryResultFlag.IGNORED))
|
List<DiscoveryResult> results = inbox.stream().filter(withFlag(DiscoveryResultFlag.IGNORED)).toList();
|
||||||
.collect(Collectors.toList());
|
|
||||||
assertThat(results.size(), is(0));
|
assertThat(results.size(), is(0));
|
||||||
|
|
||||||
// Then there is a discovery result which is NEW
|
// Then there is a discovery result which is NEW
|
||||||
results = inbox.stream().filter(withFlag(DiscoveryResultFlag.NEW)).collect(Collectors.toList());
|
results = inbox.stream().filter(withFlag(DiscoveryResultFlag.NEW)).toList();
|
||||||
assertThat(results.size(), is(1));
|
assertThat(results.size(), is(1));
|
||||||
assertThat(results.get(0).getThingUID(), is(equalTo(THING_UID3)));
|
assertThat(results.get(0).getThingUID(), is(equalTo(THING_UID3)));
|
||||||
}
|
}
|
||||||
@ -216,8 +213,7 @@ public class AutomaticInboxProcessorTest {
|
|||||||
inbox.add(DiscoveryResultBuilder.create(THING_UID).withProperty(DEVICE_ID_KEY, DEVICE_ID)
|
inbox.add(DiscoveryResultBuilder.create(THING_UID).withProperty(DEVICE_ID_KEY, DEVICE_ID)
|
||||||
.withRepresentationProperty(DEVICE_ID_KEY).build());
|
.withRepresentationProperty(DEVICE_ID_KEY).build());
|
||||||
|
|
||||||
List<DiscoveryResult> results = inbox.stream().filter(withFlag(DiscoveryResultFlag.NEW))
|
List<DiscoveryResult> results = inbox.stream().filter(withFlag(DiscoveryResultFlag.NEW)).toList();
|
||||||
.collect(Collectors.toList());
|
|
||||||
assertThat(results.size(), is(1));
|
assertThat(results.size(), is(1));
|
||||||
assertThat(results.get(0).getThingUID(), is(equalTo(THING_UID)));
|
assertThat(results.get(0).getThingUID(), is(equalTo(THING_UID)));
|
||||||
|
|
||||||
@ -227,25 +223,23 @@ public class AutomaticInboxProcessorTest {
|
|||||||
when(thingStatusInfoChangedEventMock.getThingUID()).thenReturn(THING_UID);
|
when(thingStatusInfoChangedEventMock.getThingUID()).thenReturn(THING_UID);
|
||||||
automaticInboxProcessor.receive(thingStatusInfoChangedEventMock);
|
automaticInboxProcessor.receive(thingStatusInfoChangedEventMock);
|
||||||
|
|
||||||
results = inbox.stream().filter(withFlag(DiscoveryResultFlag.NEW)).collect(Collectors.toList());
|
results = inbox.stream().filter(withFlag(DiscoveryResultFlag.NEW)).toList();
|
||||||
assertThat(results.size(), is(0));
|
assertThat(results.size(), is(0));
|
||||||
results = inbox.stream().filter(withFlag(DiscoveryResultFlag.IGNORED)).collect(Collectors.toList());
|
results = inbox.stream().filter(withFlag(DiscoveryResultFlag.IGNORED)).toList();
|
||||||
assertThat(results.size(), is(1));
|
assertThat(results.size(), is(1));
|
||||||
assertThat(results.get(0).getThingUID(), is(equalTo(THING_UID)));
|
assertThat(results.get(0).getThingUID(), is(equalTo(THING_UID)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNoDiscoveryResultIfNoRepresentationPropertySet() {
|
public void testNoDiscoveryResultIfNoRepresentationPropertySet() {
|
||||||
List<DiscoveryResult> results = inbox.stream().filter(withFlag(DiscoveryResultFlag.NEW))
|
List<DiscoveryResult> results = inbox.stream().filter(withFlag(DiscoveryResultFlag.NEW)).toList();
|
||||||
.collect(Collectors.toList());
|
|
||||||
assertThat(results.size(), is(0));
|
assertThat(results.size(), is(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testThingWhenNoRepresentationPropertySet() {
|
public void testThingWhenNoRepresentationPropertySet() {
|
||||||
inbox.add(DiscoveryResultBuilder.create(THING_UID).withProperty(DEVICE_ID_KEY, DEVICE_ID).build());
|
inbox.add(DiscoveryResultBuilder.create(THING_UID).withProperty(DEVICE_ID_KEY, DEVICE_ID).build());
|
||||||
List<DiscoveryResult> results = inbox.stream().filter(withFlag(DiscoveryResultFlag.NEW))
|
List<DiscoveryResult> results = inbox.stream().filter(withFlag(DiscoveryResultFlag.NEW)).toList();
|
||||||
.collect(Collectors.toList());
|
|
||||||
assertThat(results.size(), is(1));
|
assertThat(results.size(), is(1));
|
||||||
assertThat(results.get(0).getThingUID(), is(equalTo(THING_UID)));
|
assertThat(results.get(0).getThingUID(), is(equalTo(THING_UID)));
|
||||||
|
|
||||||
@ -255,7 +249,7 @@ public class AutomaticInboxProcessorTest {
|
|||||||
when(thingStatusInfoChangedEventMock.getThingUID()).thenReturn(THING_UID);
|
when(thingStatusInfoChangedEventMock.getThingUID()).thenReturn(THING_UID);
|
||||||
automaticInboxProcessor.receive(thingStatusInfoChangedEventMock);
|
automaticInboxProcessor.receive(thingStatusInfoChangedEventMock);
|
||||||
|
|
||||||
results = inbox.stream().filter(withFlag(DiscoveryResultFlag.IGNORED)).collect(Collectors.toList());
|
results = inbox.stream().filter(withFlag(DiscoveryResultFlag.IGNORED)).toList();
|
||||||
assertThat(results.size(), is(0));
|
assertThat(results.size(), is(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -270,10 +264,9 @@ public class AutomaticInboxProcessorTest {
|
|||||||
inbox.add(DiscoveryResultBuilder.create(THING_UID2).withProperty(DEVICE_ID_KEY, DEVICE_ID)
|
inbox.add(DiscoveryResultBuilder.create(THING_UID2).withProperty(DEVICE_ID_KEY, DEVICE_ID)
|
||||||
.withRepresentationProperty(DEVICE_ID_KEY).build());
|
.withRepresentationProperty(DEVICE_ID_KEY).build());
|
||||||
|
|
||||||
List<DiscoveryResult> results = inbox.stream().filter(withFlag(DiscoveryResultFlag.NEW))
|
List<DiscoveryResult> results = inbox.stream().filter(withFlag(DiscoveryResultFlag.NEW)).toList();
|
||||||
.collect(Collectors.toList());
|
|
||||||
assertThat(results.size(), is(0));
|
assertThat(results.size(), is(0));
|
||||||
results = inbox.stream().filter(withFlag(DiscoveryResultFlag.IGNORED)).collect(Collectors.toList());
|
results = inbox.stream().filter(withFlag(DiscoveryResultFlag.IGNORED)).toList();
|
||||||
assertThat(results.size(), is(1));
|
assertThat(results.size(), is(1));
|
||||||
assertThat(results.get(0).getThingUID(), is(equalTo(THING_UID2)));
|
assertThat(results.get(0).getThingUID(), is(equalTo(THING_UID2)));
|
||||||
}
|
}
|
||||||
@ -284,8 +277,7 @@ public class AutomaticInboxProcessorTest {
|
|||||||
.withRepresentationProperty(DEVICE_ID_KEY).build());
|
.withRepresentationProperty(DEVICE_ID_KEY).build());
|
||||||
|
|
||||||
inbox.setFlag(THING_UID, DiscoveryResultFlag.IGNORED);
|
inbox.setFlag(THING_UID, DiscoveryResultFlag.IGNORED);
|
||||||
List<DiscoveryResult> results = inbox.stream().filter(withFlag(DiscoveryResultFlag.IGNORED))
|
List<DiscoveryResult> results = inbox.stream().filter(withFlag(DiscoveryResultFlag.IGNORED)).toList();
|
||||||
.collect(Collectors.toList());
|
|
||||||
assertThat(results.size(), is(1));
|
assertThat(results.size(), is(1));
|
||||||
assertThat(results.get(0).getThingUID(), is(equalTo(THING_UID)));
|
assertThat(results.get(0).getThingUID(), is(equalTo(THING_UID)));
|
||||||
|
|
||||||
@ -305,8 +297,7 @@ public class AutomaticInboxProcessorTest {
|
|||||||
.withRepresentationProperty(DEVICE_ID_KEY).build());
|
.withRepresentationProperty(DEVICE_ID_KEY).build());
|
||||||
inbox.setFlag(THING_UID3, DiscoveryResultFlag.IGNORED);
|
inbox.setFlag(THING_UID3, DiscoveryResultFlag.IGNORED);
|
||||||
|
|
||||||
List<DiscoveryResult> results = inbox.stream().filter(withFlag(DiscoveryResultFlag.IGNORED))
|
List<DiscoveryResult> results = inbox.stream().filter(withFlag(DiscoveryResultFlag.IGNORED)).toList();
|
||||||
.collect(Collectors.toList());
|
|
||||||
assertThat(results.size(), is(2));
|
assertThat(results.size(), is(2));
|
||||||
|
|
||||||
automaticInboxProcessor.removed(thingMock);
|
automaticInboxProcessor.removed(thingMock);
|
||||||
@ -321,8 +312,7 @@ public class AutomaticInboxProcessorTest {
|
|||||||
inbox.add(DiscoveryResultBuilder.create(THING_UID2).withProperty(OTHER_KEY, OTHER_VALUE)
|
inbox.add(DiscoveryResultBuilder.create(THING_UID2).withProperty(OTHER_KEY, OTHER_VALUE)
|
||||||
.withRepresentationProperty(OTHER_KEY).build());
|
.withRepresentationProperty(OTHER_KEY).build());
|
||||||
|
|
||||||
List<DiscoveryResult> results = inbox.stream().filter(withFlag(DiscoveryResultFlag.NEW))
|
List<DiscoveryResult> results = inbox.stream().filter(withFlag(DiscoveryResultFlag.NEW)).toList();
|
||||||
.collect(Collectors.toList());
|
|
||||||
assertThat(results.size(), is(1));
|
assertThat(results.size(), is(1));
|
||||||
assertThat(results.get(0).getThingUID(), is(equalTo(THING_UID2)));
|
assertThat(results.get(0).getThingUID(), is(equalTo(THING_UID2)));
|
||||||
|
|
||||||
@ -332,9 +322,9 @@ public class AutomaticInboxProcessorTest {
|
|||||||
when(thingStatusInfoChangedEventMock.getThingUID()).thenReturn(THING_UID2);
|
when(thingStatusInfoChangedEventMock.getThingUID()).thenReturn(THING_UID2);
|
||||||
automaticInboxProcessor.receive(thingStatusInfoChangedEventMock);
|
automaticInboxProcessor.receive(thingStatusInfoChangedEventMock);
|
||||||
|
|
||||||
results = inbox.stream().filter(withFlag(DiscoveryResultFlag.NEW)).collect(Collectors.toList());
|
results = inbox.stream().filter(withFlag(DiscoveryResultFlag.NEW)).toList();
|
||||||
assertThat(results.size(), is(0));
|
assertThat(results.size(), is(0));
|
||||||
results = inbox.stream().filter(withFlag(DiscoveryResultFlag.IGNORED)).collect(Collectors.toList());
|
results = inbox.stream().filter(withFlag(DiscoveryResultFlag.IGNORED)).toList();
|
||||||
assertThat(results.size(), is(1));
|
assertThat(results.size(), is(1));
|
||||||
assertThat(results.get(0).getThingUID(), is(equalTo(THING_UID2)));
|
assertThat(results.get(0).getThingUID(), is(equalTo(THING_UID2)));
|
||||||
}
|
}
|
||||||
@ -350,10 +340,9 @@ public class AutomaticInboxProcessorTest {
|
|||||||
inbox.add(DiscoveryResultBuilder.create(THING_UID).withProperty(OTHER_KEY, OTHER_VALUE)
|
inbox.add(DiscoveryResultBuilder.create(THING_UID).withProperty(OTHER_KEY, OTHER_VALUE)
|
||||||
.withRepresentationProperty(OTHER_KEY).build());
|
.withRepresentationProperty(OTHER_KEY).build());
|
||||||
|
|
||||||
List<DiscoveryResult> results = inbox.stream().filter(withFlag(DiscoveryResultFlag.NEW))
|
List<DiscoveryResult> results = inbox.stream().filter(withFlag(DiscoveryResultFlag.NEW)).toList();
|
||||||
.collect(Collectors.toList());
|
|
||||||
assertThat(results.size(), is(0));
|
assertThat(results.size(), is(0));
|
||||||
results = inbox.stream().filter(withFlag(DiscoveryResultFlag.IGNORED)).collect(Collectors.toList());
|
results = inbox.stream().filter(withFlag(DiscoveryResultFlag.IGNORED)).toList();
|
||||||
assertThat(results.size(), is(1));
|
assertThat(results.size(), is(1));
|
||||||
assertThat(results.get(0).getThingUID(), is(equalTo(THING_UID)));
|
assertThat(results.get(0).getThingUID(), is(equalTo(THING_UID)));
|
||||||
}
|
}
|
||||||
@ -364,8 +353,7 @@ public class AutomaticInboxProcessorTest {
|
|||||||
.withRepresentationProperty(OTHER_KEY).build());
|
.withRepresentationProperty(OTHER_KEY).build());
|
||||||
|
|
||||||
inbox.setFlag(THING_UID2, DiscoveryResultFlag.IGNORED);
|
inbox.setFlag(THING_UID2, DiscoveryResultFlag.IGNORED);
|
||||||
List<DiscoveryResult> results = inbox.stream().filter(withFlag(DiscoveryResultFlag.IGNORED))
|
List<DiscoveryResult> results = inbox.stream().filter(withFlag(DiscoveryResultFlag.IGNORED)).toList();
|
||||||
.collect(Collectors.toList());
|
|
||||||
assertThat(results.size(), is(1));
|
assertThat(results.size(), is(1));
|
||||||
assertThat(results.get(0).getThingUID(), is(equalTo(THING_UID2)));
|
assertThat(results.get(0).getThingUID(), is(equalTo(THING_UID2)));
|
||||||
|
|
||||||
|
@ -28,7 +28,6 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.eclipse.jdt.annotation.Nullable;
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
@ -436,14 +435,14 @@ public class ConfigDispatcher {
|
|||||||
String value = trimmedLine.substring(property.length() + 1).trim();
|
String value = trimmedLine.substring(property.length() + 1).trim();
|
||||||
if (value.startsWith(DEFAULT_LIST_STARTING_CHARACTER) && value.endsWith(DEFAULT_LIST_ENDING_CHARACTER)) {
|
if (value.startsWith(DEFAULT_LIST_STARTING_CHARACTER) && value.endsWith(DEFAULT_LIST_ENDING_CHARACTER)) {
|
||||||
logger.debug("Found list in value '{}'", value);
|
logger.debug("Found list in value '{}'", value);
|
||||||
List<String> values = Arrays.asList(value //
|
//
|
||||||
|
List<String> values = Arrays.stream(value //
|
||||||
.replace(DEFAULT_LIST_STARTING_CHARACTER, "") //
|
.replace(DEFAULT_LIST_STARTING_CHARACTER, "") //
|
||||||
.replace(DEFAULT_LIST_ENDING_CHARACTER, "")//
|
.replace(DEFAULT_LIST_ENDING_CHARACTER, "")//
|
||||||
.split(DEFAULT_LIST_DELIMITER))//
|
.split(DEFAULT_LIST_DELIMITER))//
|
||||||
.stream()//
|
|
||||||
.map(v -> v.trim())//
|
.map(v -> v.trim())//
|
||||||
.filter(v -> !v.isEmpty())//
|
.filter(v -> !v.isEmpty())//
|
||||||
.collect(Collectors.toList());
|
.toList();
|
||||||
return new ParseLineResult(pid, property.trim(), values);
|
return new ParseLineResult(pid, property.trim(), values);
|
||||||
} else {
|
} else {
|
||||||
return new ParseLineResult(pid, property.trim(), value);
|
return new ParseLineResult(pid, property.trim(), value);
|
||||||
@ -539,7 +538,7 @@ public class ConfigDispatcher {
|
|||||||
*/
|
*/
|
||||||
public List<String> getOrphanPIDs() {
|
public List<String> getOrphanPIDs() {
|
||||||
return processedPIDMapping.entrySet().stream().filter(e -> e.getValue() == null).map(e -> e.getKey())
|
return processedPIDMapping.entrySet().stream().filter(e -> e.getValue() == null).map(e -> e.getKey())
|
||||||
.collect(Collectors.toList());
|
.toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -547,7 +546,7 @@ public class ConfigDispatcher {
|
|||||||
*/
|
*/
|
||||||
public void setCurrentExclusivePIDList() {
|
public void setCurrentExclusivePIDList() {
|
||||||
exclusivePIDs = processedPIDMapping.entrySet().stream().filter(e -> e.getValue() != null)
|
exclusivePIDs = processedPIDMapping.entrySet().stream().filter(e -> e.getValue() != null)
|
||||||
.map(e -> e.getKey()).collect(Collectors.toList());
|
.map(e -> e.getKey()).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean contains(String pid) {
|
public boolean contains(String pid) {
|
||||||
|
@ -17,7 +17,6 @@ import java.util.Collection;
|
|||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.CopyOnWriteArraySet;
|
import java.util.concurrent.CopyOnWriteArraySet;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
@ -87,7 +86,7 @@ public class SerialConfigOptionProvider implements ConfigOptionProvider, UsbSeri
|
|||||||
previouslyDiscovered.stream().map(UsbSerialDeviceInformation::getSerialPort))
|
previouslyDiscovered.stream().map(UsbSerialDeviceInformation::getSerialPort))
|
||||||
.distinct() //
|
.distinct() //
|
||||||
.map(serialPortName -> new ParameterOption(serialPortName, serialPortName)) //
|
.map(serialPortName -> new ParameterOption(serialPortName, serialPortName)) //
|
||||||
.collect(Collectors.toList());
|
.toList();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,6 @@ import static org.openhab.core.config.serial.internal.SerialConfigOptionProvider
|
|||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
@ -83,7 +82,7 @@ public class SerialConfigOptionProviderTest {
|
|||||||
Collection<ParameterOption> actual = provider.getParameterOptions(URI.create("uri"), "serialPort", SERIAL_PORT,
|
Collection<ParameterOption> actual = provider.getParameterOptions(URI.create("uri"), "serialPort", SERIAL_PORT,
|
||||||
null);
|
null);
|
||||||
Collection<ParameterOption> expected = Arrays.stream(serialPortIdentifiers)
|
Collection<ParameterOption> expected = Arrays.stream(serialPortIdentifiers)
|
||||||
.map(id -> new ParameterOption(id, id)).collect(Collectors.toList());
|
.map(id -> new ParameterOption(id, id)).toList();
|
||||||
assertThat(actual, is(expected));
|
assertThat(actual, is(expected));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +36,6 @@ import java.util.Map;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.eclipse.jdt.annotation.Nullable;
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
@ -259,7 +258,7 @@ public class EphemerisManagerImpl implements EphemerisManager, ConfigOptionProvi
|
|||||||
LocalDate toDate = from.plusDays(span).toLocalDate();
|
LocalDate toDate = from.plusDays(span).toLocalDate();
|
||||||
|
|
||||||
Set<Holiday> days = holidayManager.getHolidays(fromDate, toDate, countryParameters.toArray(new String[0]));
|
Set<Holiday> days = holidayManager.getHolidays(fromDate, toDate, countryParameters.toArray(new String[0]));
|
||||||
return days.stream().sorted(Comparator.comparing(Holiday::getDate)).collect(Collectors.toList());
|
return days.stream().sorted(Comparator.comparing(Holiday::getDate)).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -15,7 +15,6 @@ package org.openhab.core.io.console.internal.extension;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
@ -51,8 +50,7 @@ public class ItemConsoleCommandCompleter implements ConsoleCommandCompleter {
|
|||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public boolean complete(String[] args, int cursorArgumentIndex, int cursorPosition, List<String> candidates) {
|
public boolean complete(String[] args, int cursorArgumentIndex, int cursorPosition, List<String> candidates) {
|
||||||
if (cursorArgumentIndex <= 0) {
|
if (cursorArgumentIndex <= 0) {
|
||||||
return new StringsCompleter(
|
return new StringsCompleter(itemRegistry.getAll().stream().map(i -> i.getName()).toList(), true)
|
||||||
itemRegistry.getAll().stream().map(i -> i.getName()).collect(Collectors.toList()), true)
|
|
||||||
.complete(args, cursorArgumentIndex, cursorPosition, candidates);
|
.complete(args, cursorArgumentIndex, cursorPosition, candidates);
|
||||||
}
|
}
|
||||||
var localDataTypeGetter = dataTypeGetter;
|
var localDataTypeGetter = dataTypeGetter;
|
||||||
@ -62,8 +60,8 @@ public class ItemConsoleCommandCompleter implements ConsoleCommandCompleter {
|
|||||||
Stream<Class<?>> enums = Stream.of(localDataTypeGetter.apply(item)).filter(Class::isEnum);
|
Stream<Class<?>> enums = Stream.of(localDataTypeGetter.apply(item)).filter(Class::isEnum);
|
||||||
Stream<? super Enum<?>> enumConstants = enums.flatMap(
|
Stream<? super Enum<?>> enumConstants = enums.flatMap(
|
||||||
t -> Stream.of(Objects.requireNonNull(((Class<? extends Enum<?>>) t).getEnumConstants())));
|
t -> Stream.of(Objects.requireNonNull(((Class<? extends Enum<?>>) t).getEnumConstants())));
|
||||||
return new StringsCompleter(enumConstants.map(Object::toString).collect(Collectors.toList()), false)
|
return new StringsCompleter(enumConstants.map(Object::toString).toList(), false).complete(args,
|
||||||
.complete(args, cursorArgumentIndex, cursorPosition, candidates);
|
cursorArgumentIndex, cursorPosition, candidates);
|
||||||
} catch (ItemNotFoundException | ItemNotUniqueException e) {
|
} catch (ItemNotFoundException | ItemNotUniqueException e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,6 @@ import java.util.Collection;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.eclipse.jdt.annotation.Nullable;
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
@ -74,8 +73,8 @@ public class ItemConsoleCommandExtension extends AbstractConsoleCommandExtension
|
|||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return new StringsCompleter(items.stream().map(i -> i.getName()).collect(Collectors.toList()), true)
|
return new StringsCompleter(items.stream().map(i -> i.getName()).toList(), true).complete(args,
|
||||||
.complete(args, cursorArgumentIndex, cursorPosition, candidates);
|
cursorArgumentIndex, cursorPosition, candidates);
|
||||||
}
|
}
|
||||||
if (cursorArgumentIndex == 2 && args[0].equals(SUBCMD_RMTAG)) {
|
if (cursorArgumentIndex == 2 && args[0].equals(SUBCMD_RMTAG)) {
|
||||||
Item item = managedItemProvider.get(args[1]);
|
Item item = managedItemProvider.get(args[1]);
|
||||||
|
@ -22,7 +22,6 @@ import java.security.cert.X509Certificate;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import javax.net.ssl.SSLEngine;
|
import javax.net.ssl.SSLEngine;
|
||||||
@ -174,7 +173,7 @@ public class ExtensibleTrustManagerImplTest {
|
|||||||
private Collection<List<?>> constructAlternativeNames(String... alternatives) {
|
private Collection<List<?>> constructAlternativeNames(String... alternatives) {
|
||||||
Collection<List<?>> alternativeNames = new ArrayList<>();
|
Collection<List<?>> alternativeNames = new ArrayList<>();
|
||||||
for (String alternative : alternatives) {
|
for (String alternative : alternatives) {
|
||||||
alternativeNames.add(Stream.of(0, alternative).collect(Collectors.toList()));
|
alternativeNames.add(Stream.of(0, alternative).toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
return alternativeNames;
|
return alternativeNames;
|
||||||
|
@ -16,7 +16,7 @@ import java.math.BigDecimal;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.eclipse.jdt.annotation.Nullable;
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
@ -49,8 +49,8 @@ public class EnrichedConfigDescriptionParameterDTO extends ConfigDescriptionPara
|
|||||||
|
|
||||||
if (multiple && defaultValue != null) {
|
if (multiple && defaultValue != null) {
|
||||||
if (defaultValue.contains(DEFAULT_LIST_DELIMITER)) {
|
if (defaultValue.contains(DEFAULT_LIST_DELIMITER)) {
|
||||||
defaultValues = List.of(defaultValue.split(DEFAULT_LIST_DELIMITER)).stream().map(v -> v.trim())
|
defaultValues = Stream.of(defaultValue.split(DEFAULT_LIST_DELIMITER)).map(String::trim)
|
||||||
.filter(v -> !v.isEmpty()).collect(Collectors.toList());
|
.filter(v -> !v.isEmpty()).toList();
|
||||||
} else {
|
} else {
|
||||||
defaultValues = Set.of(defaultValue);
|
defaultValues = Set.of(defaultValue);
|
||||||
}
|
}
|
||||||
|
@ -386,7 +386,7 @@ public class ItemResource implements RESTResource {
|
|||||||
public Response getBinaryItemState(@HeaderParam("Accept") @Nullable String mediaType,
|
public Response getBinaryItemState(@HeaderParam("Accept") @Nullable String mediaType,
|
||||||
@PathParam("itemname") @Parameter(description = "item name") String itemname) {
|
@PathParam("itemname") @Parameter(description = "item name") String itemname) {
|
||||||
List<String> acceptedMediaTypes = Arrays.stream(Objects.requireNonNullElse(mediaType, "").split(","))
|
List<String> acceptedMediaTypes = Arrays.stream(Objects.requireNonNullElse(mediaType, "").split(","))
|
||||||
.map(String::trim).collect(Collectors.toList());
|
.map(String::trim).toList();
|
||||||
|
|
||||||
Item item = getItem(itemname);
|
Item item = getItem(itemname);
|
||||||
|
|
||||||
|
@ -14,7 +14,6 @@ package org.openhab.core.io.rest.core.internal.link;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import javax.annotation.security.RolesAllowed;
|
import javax.annotation.security.RolesAllowed;
|
||||||
@ -172,10 +171,9 @@ public class ItemChannelLinkResource implements RESTResource {
|
|||||||
@PathParam("channelUID") @Parameter(description = "channel UID") String channelUid) {
|
@PathParam("channelUID") @Parameter(description = "channel UID") String channelUid) {
|
||||||
List<EnrichedItemChannelLinkDTO> links = itemChannelLinkRegistry.stream()
|
List<EnrichedItemChannelLinkDTO> links = itemChannelLinkRegistry.stream()
|
||||||
.filter(link -> channelUid.equals(link.getLinkedUID().getAsString()))
|
.filter(link -> channelUid.equals(link.getLinkedUID().getAsString()))
|
||||||
.filter(link -> itemName.equals(link.getItemName()))
|
.filter(link -> itemName.equals(link.getItemName())).map(link -> EnrichedItemChannelLinkDTOMapper
|
||||||
.map(link -> EnrichedItemChannelLinkDTOMapper.map(link,
|
.map(link, isEditable(AbstractLink.getIDFor(link.getItemName(), link.getLinkedUID()))))
|
||||||
isEditable(AbstractLink.getIDFor(link.getItemName(), link.getLinkedUID()))))
|
.toList();
|
||||||
.collect(Collectors.toList());
|
|
||||||
|
|
||||||
if (!links.isEmpty()) {
|
if (!links.isEmpty()) {
|
||||||
return JSONResponse.createResponse(Status.OK, links.get(0), null);
|
return JSONResponse.createResponse(Status.OK, links.get(0), null);
|
||||||
|
@ -22,7 +22,6 @@ import java.util.Collections;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import javax.annotation.security.RolesAllowed;
|
import javax.annotation.security.RolesAllowed;
|
||||||
import javax.ws.rs.Consumes;
|
import javax.ws.rs.Consumes;
|
||||||
@ -369,7 +368,7 @@ public class ConfigurableServiceResource implements RESTResource {
|
|||||||
} else if (pid instanceof String[] pids) {
|
} else if (pid instanceof String[] pids) {
|
||||||
serviceId = getServicePID(cn, Arrays.asList(pids));
|
serviceId = getServicePID(cn, Arrays.asList(pids));
|
||||||
} else if (pid instanceof Collection<?> pids) {
|
} else if (pid instanceof Collection<?> pids) {
|
||||||
serviceId = getServicePID(cn, pids.stream().map(entry -> entry.toString()).collect(Collectors.toList()));
|
serviceId = getServicePID(cn, pids.stream().map(Object::toString).toList());
|
||||||
} else {
|
} else {
|
||||||
logger.warn("The component \"{}\" is using an unhandled service PID type ({}). Use component name.", cn,
|
logger.warn("The component \"{}\" is using an unhandled service PID type ({}). Use component name.", cn,
|
||||||
pid.getClass());
|
pid.getClass());
|
||||||
|
@ -15,7 +15,6 @@ package org.openhab.core.io.rest.voice.internal;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import javax.annotation.security.RolesAllowed;
|
import javax.annotation.security.RolesAllowed;
|
||||||
import javax.ws.rs.Consumes;
|
import javax.ws.rs.Consumes;
|
||||||
@ -114,7 +113,7 @@ public class VoiceResource implements RESTResource {
|
|||||||
@HeaderParam(HttpHeaders.ACCEPT_LANGUAGE) @Parameter(description = "language") @Nullable String language) {
|
@HeaderParam(HttpHeaders.ACCEPT_LANGUAGE) @Parameter(description = "language") @Nullable String language) {
|
||||||
final Locale locale = localeService.getLocale(language);
|
final Locale locale = localeService.getLocale(language);
|
||||||
List<HumanLanguageInterpreterDTO> dtos = voiceManager.getHLIs().stream().map(hli -> HLIMapper.map(hli, locale))
|
List<HumanLanguageInterpreterDTO> dtos = voiceManager.getHLIs().stream().map(hli -> HLIMapper.map(hli, locale))
|
||||||
.collect(Collectors.toList());
|
.toList();
|
||||||
return Response.ok(dtos).build();
|
return Response.ok(dtos).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -203,7 +202,7 @@ public class VoiceResource implements RESTResource {
|
|||||||
@Operation(operationId = "getVoices", summary = "Get the list of all voices.", responses = {
|
@Operation(operationId = "getVoices", summary = "Get the list of all voices.", responses = {
|
||||||
@ApiResponse(responseCode = "200", description = "OK", content = @Content(array = @ArraySchema(schema = @Schema(implementation = VoiceDTO.class)))) })
|
@ApiResponse(responseCode = "200", description = "OK", content = @Content(array = @ArraySchema(schema = @Schema(implementation = VoiceDTO.class)))) })
|
||||||
public Response getVoices() {
|
public Response getVoices() {
|
||||||
List<VoiceDTO> dtos = voiceManager.getAllVoices().stream().map(VoiceMapper::map).collect(Collectors.toList());
|
List<VoiceDTO> dtos = voiceManager.getAllVoices().stream().map(VoiceMapper::map).toList();
|
||||||
return Response.ok(dtos).build();
|
return Response.ok(dtos).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,6 @@ package org.openhab.core.io.rest.internal;
|
|||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNull;
|
import org.eclipse.jdt.annotation.NonNull;
|
||||||
@ -42,7 +41,7 @@ public class DTOMapperImpl implements DTOMapper {
|
|||||||
if (fields == null || fields.trim().isEmpty()) {
|
if (fields == null || fields.trim().isEmpty()) {
|
||||||
return itemStream;
|
return itemStream;
|
||||||
}
|
}
|
||||||
List<String> fieldList = Stream.of(fields.split(",")).map(field -> field.trim()).collect(Collectors.toList());
|
List<String> fieldList = Stream.of(fields.split(",")).map(String::trim).toList();
|
||||||
return itemStream.map(dto -> {
|
return itemStream.map(dto -> {
|
||||||
for (Field field : dto.getClass().getFields()) {
|
for (Field field : dto.getClass().getFields()) {
|
||||||
if (!fieldList.contains(field.getName())) {
|
if (!fieldList.contains(field.getName())) {
|
||||||
|
@ -14,7 +14,6 @@ package org.openhab.core.io.transport.modbus.internal;
|
|||||||
|
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import java.util.stream.IntStream;
|
import java.util.stream.IntStream;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNull;
|
import org.eclipse.jdt.annotation.NonNull;
|
||||||
@ -269,8 +268,8 @@ public class ModbusLibraryWrapper {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static Register[] convertRegisters(ModbusRegisterArray arr) {
|
public static Register[] convertRegisters(ModbusRegisterArray arr) {
|
||||||
return IntStream.range(0, arr.size()).mapToObj(i -> new SimpleInputRegister(arr.getRegister(i)))
|
return IntStream.range(0, arr.size()).mapToObj(i -> new SimpleInputRegister(arr.getRegister(i))).toList()
|
||||||
.collect(Collectors.toList()).toArray(new Register[0]);
|
.toArray(new Register[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -19,7 +19,6 @@ import java.util.Collection;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
import java.util.stream.Stream.Builder;
|
import java.util.stream.Stream.Builder;
|
||||||
|
|
||||||
@ -51,7 +50,7 @@ public class BitUtilitiesExtractIndividualMethodsTest {
|
|||||||
ModbusRegisterArray registers = (ModbusRegisterArray) values[2];
|
ModbusRegisterArray registers = (ModbusRegisterArray) values[2];
|
||||||
int index = (int) values[3];
|
int index = (int) values[3];
|
||||||
return registerVariations(expectedResult, type, registers, index);
|
return registerVariations(expectedResult, type, registers, index);
|
||||||
}).collect(Collectors.toList());
|
}).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Stream<Object[]> filteredTestData(ValueType type) {
|
public static Stream<Object[]> filteredTestData(ValueType type) {
|
||||||
|
@ -17,9 +17,7 @@ import static org.hamcrest.MatcherAssert.assertThat;
|
|||||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
@ -41,7 +39,7 @@ public class BitUtilitiesExtractStateFromRegistersTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Collection<Object[]> data() {
|
public static Collection<Object[]> data() {
|
||||||
return Collections.unmodifiableList(Stream.of(
|
return Stream.of(
|
||||||
//
|
//
|
||||||
// BIT
|
// BIT
|
||||||
//
|
//
|
||||||
@ -351,7 +349,7 @@ public class BitUtilitiesExtractStateFromRegistersTest {
|
|||||||
// out of bounds of unsigned 64bit
|
// out of bounds of unsigned 64bit
|
||||||
new DecimalType("16124500437522872585"), ValueType.UINT64_SWAP,
|
new DecimalType("16124500437522872585"), ValueType.UINT64_SWAP,
|
||||||
shortArrayToRegisterArray(0x7909, 0x772E, 0xBBB7, 0xDFC5), 0 })
|
shortArrayToRegisterArray(0x7909, 0x772E, 0xBBB7, 0xDFC5), 0 })
|
||||||
.collect(Collectors.toList()));
|
.toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
@ -17,8 +17,6 @@ import static org.junit.jupiter.api.Assertions.*;
|
|||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
import java.util.stream.Stream.Builder;
|
import java.util.stream.Stream.Builder;
|
||||||
|
|
||||||
@ -39,8 +37,7 @@ public class BitUtilitiesExtractStringTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Collection<Object[]> data() {
|
public static Collection<Object[]> data() {
|
||||||
return Collections.unmodifiableList(Stream.of(
|
return Stream.of(new Object[] { "", shortArrayToRegisterArray(0), 0, 0, StandardCharsets.UTF_8 },
|
||||||
new Object[] { "", shortArrayToRegisterArray(0), 0, 0, StandardCharsets.UTF_8 },
|
|
||||||
new Object[] { "hello", shortArrayToRegisterArray(0x6865, 0x6c6c, 0x6f00), 0, 5,
|
new Object[] { "hello", shortArrayToRegisterArray(0x6865, 0x6c6c, 0x6f00), 0, 5,
|
||||||
StandardCharsets.UTF_8 },
|
StandardCharsets.UTF_8 },
|
||||||
new Object[] { "he", shortArrayToRegisterArray(0x6865, 0x6c6c, 0x6f00), 0, 2, StandardCharsets.UTF_8 }, // limited
|
new Object[] { "he", shortArrayToRegisterArray(0x6865, 0x6c6c, 0x6f00), 0, 2, StandardCharsets.UTF_8 }, // limited
|
||||||
@ -77,7 +74,7 @@ public class BitUtilitiesExtractStringTest {
|
|||||||
// out of bounds
|
// out of bounds
|
||||||
new Object[] { IllegalArgumentException.class, shortArrayToRegisterArray(0, 0), 0, 5,
|
new Object[] { IllegalArgumentException.class, shortArrayToRegisterArray(0, 0), 0, 5,
|
||||||
StandardCharsets.UTF_8 })
|
StandardCharsets.UTF_8 })
|
||||||
.collect(Collectors.toList()));
|
.toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Stream<Object[]> dataWithByteVariations() {
|
public static Stream<Object[]> dataWithByteVariations() {
|
||||||
|
@ -20,7 +20,6 @@ import static org.openhab.core.io.transport.modbus.ModbusConstants.*;
|
|||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import java.util.stream.IntStream;
|
import java.util.stream.IntStream;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
@ -37,14 +36,13 @@ import org.openhab.core.io.transport.modbus.json.WriteRequestJsonUtilities;
|
|||||||
public class WriteRequestJsonUtilitiesTest {
|
public class WriteRequestJsonUtilitiesTest {
|
||||||
|
|
||||||
private static final List<String> MAX_REGISTERS = IntStream.range(0, MAX_REGISTERS_WRITE_COUNT).mapToObj(i -> "1")
|
private static final List<String> MAX_REGISTERS = IntStream.range(0, MAX_REGISTERS_WRITE_COUNT).mapToObj(i -> "1")
|
||||||
.collect(Collectors.toList());
|
.toList();
|
||||||
private static final List<String> OVER_MAX_REGISTERS = IntStream.range(0, MAX_REGISTERS_WRITE_COUNT + 1)
|
private static final List<String> OVER_MAX_REGISTERS = IntStream.range(0, MAX_REGISTERS_WRITE_COUNT + 1)
|
||||||
.mapToObj(i -> "1").collect(Collectors.toList());
|
.mapToObj(i -> "1").toList();
|
||||||
|
|
||||||
private static final List<String> MAX_COILS = IntStream.range(0, MAX_BITS_WRITE_COUNT).mapToObj(i -> "1")
|
private static final List<String> MAX_COILS = IntStream.range(0, MAX_BITS_WRITE_COUNT).mapToObj(i -> "1").toList();
|
||||||
.collect(Collectors.toList());
|
|
||||||
private static final List<String> OVER_MAX_COILS = IntStream.range(0, MAX_BITS_WRITE_COUNT + 1).mapToObj(i -> "1")
|
private static final List<String> OVER_MAX_COILS = IntStream.range(0, MAX_BITS_WRITE_COUNT + 1).mapToObj(i -> "1")
|
||||||
.collect(Collectors.toList());
|
.toList();
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEmptyArray() {
|
public void testEmptyArray() {
|
||||||
|
@ -17,7 +17,6 @@ import java.util.Collection;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.openhab.core.io.transport.serial.ProtocolType.PathType;
|
import org.openhab.core.io.transport.serial.ProtocolType.PathType;
|
||||||
@ -79,7 +78,7 @@ public class SerialPortRegistry {
|
|||||||
.count() > 0;
|
.count() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return portCreators.stream().filter(filter).collect(Collectors.toList());
|
return portCreators.stream().filter(filter).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Collection<SerialPortProvider> getPortCreators() {
|
public Collection<SerialPortProvider> getPortCreators() {
|
||||||
|
@ -16,7 +16,6 @@ import java.util.Arrays;
|
|||||||
import java.util.Deque;
|
import java.util.Deque;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.Nullable;
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
import org.openhab.core.io.console.Console;
|
import org.openhab.core.io.console.Console;
|
||||||
@ -79,9 +78,8 @@ public class SerialCommandExtension extends AbstractConsoleCommandExtension {
|
|||||||
case SUBCMD_PORT_CREATORS:
|
case SUBCMD_PORT_CREATORS:
|
||||||
serialPortRegistry.getPortCreators().forEach(provider -> {
|
serialPortRegistry.getPortCreators().forEach(provider -> {
|
||||||
console.printf("%s, accepted protocols: %s, port identifiers: %s%n", provider.getClass(),
|
console.printf("%s, accepted protocols: %s, port identifiers: %s%n", provider.getClass(),
|
||||||
provider.getAcceptedProtocols().collect(Collectors.toList()),
|
provider.getAcceptedProtocols().toList(),
|
||||||
provider.getSerialPortIdentifiers().map(SerialCommandExtension::str)
|
provider.getSerialPortIdentifiers().map(SerialCommandExtension::str).toList());
|
||||||
.collect(Collectors.toList()));
|
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
|
@ -89,8 +89,7 @@ public class FeatureInstaller implements ConfigurationListener {
|
|||||||
private static final String ADDONS_PID = "org.openhab.addons";
|
private static final String ADDONS_PID = "org.openhab.addons";
|
||||||
private static final String PROPERTY_MVN_REPOS = "org.ops4j.pax.url.mvn.repositories";
|
private static final String PROPERTY_MVN_REPOS = "org.ops4j.pax.url.mvn.repositories";
|
||||||
|
|
||||||
public static final List<String> ADDON_TYPES = AddonType.DEFAULT_TYPES.stream().map(AddonType::getId)
|
public static final List<String> ADDON_TYPES = AddonType.DEFAULT_TYPES.stream().map(AddonType::getId).toList();
|
||||||
.collect(Collectors.toList());
|
|
||||||
|
|
||||||
private final Logger logger = LoggerFactory.getLogger(FeatureInstaller.class);
|
private final Logger logger = LoggerFactory.getLogger(FeatureInstaller.class);
|
||||||
|
|
||||||
|
@ -14,7 +14,6 @@ package org.openhab.core.karaf.internal;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
|
|
||||||
@ -39,7 +38,6 @@ public class LoggerBean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public LoggerBean(Map<String, String> logLevels) {
|
public LoggerBean(Map<String, String> logLevels) {
|
||||||
loggers = logLevels.entrySet().stream().map(l -> new LoggerInfo(l.getKey(), l.getValue()))
|
loggers = logLevels.entrySet().stream().map(l -> new LoggerInfo(l.getKey(), l.getValue())).toList();
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@ import java.util.HashSet;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import org.apache.karaf.jaas.boot.principal.GroupPrincipal;
|
import org.apache.karaf.jaas.boot.principal.GroupPrincipal;
|
||||||
import org.apache.karaf.jaas.boot.principal.RolePrincipal;
|
import org.apache.karaf.jaas.boot.principal.RolePrincipal;
|
||||||
@ -54,7 +53,7 @@ public class ManagedUserBackingEngine implements BackingEngine {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<UserPrincipal> listUsers() {
|
public List<UserPrincipal> listUsers() {
|
||||||
return userRegistry.getAll().stream().map(u -> new UserPrincipal(u.getName())).collect(Collectors.toList());
|
return userRegistry.getAll().stream().map(u -> new UserPrincipal(u.getName())).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -95,7 +94,7 @@ public class ManagedUserBackingEngine implements BackingEngine {
|
|||||||
public List<RolePrincipal> listRoles(Principal principal) {
|
public List<RolePrincipal> listRoles(Principal principal) {
|
||||||
User user = userRegistry.get(principal.getName());
|
User user = userRegistry.get(principal.getName());
|
||||||
if (user != null) {
|
if (user != null) {
|
||||||
return user.getRoles().stream().map(r -> new RolePrincipal(r)).collect(Collectors.toList());
|
return user.getRoles().stream().map(r -> new RolePrincipal(r)).toList();
|
||||||
}
|
}
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
@ -173,7 +173,7 @@ public class ModelRepositoryImpl implements ModelRepository {
|
|||||||
return resourceListCopy.stream()
|
return resourceListCopy.stream()
|
||||||
.filter(input -> input.getURI().lastSegment().contains(".") && input.isLoaded()
|
.filter(input -> input.getURI().lastSegment().contains(".") && input.isLoaded()
|
||||||
&& modelType.equalsIgnoreCase(input.getURI().fileExtension()))
|
&& modelType.equalsIgnoreCase(input.getURI().fileExtension()))
|
||||||
.map(from -> from.getURI().path()).collect(Collectors.toList());
|
.map(from -> from.getURI().path()).toList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,7 +16,6 @@ import java.io.IOException;
|
|||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import org.eclipse.emf.common.util.EList;
|
import org.eclipse.emf.common.util.EList;
|
||||||
import org.eclipse.emf.common.util.URI;
|
import org.eclipse.emf.common.util.URI;
|
||||||
@ -179,7 +178,7 @@ public class ScriptEngineImpl implements ScriptEngine, ModelParser {
|
|||||||
|
|
||||||
protected Iterable<Issue> getValidationErrors(final EObject model) {
|
protected Iterable<Issue> getValidationErrors(final EObject model) {
|
||||||
final List<Issue> validate = validate(model);
|
final List<Issue> validate = validate(model);
|
||||||
return validate.stream().filter(input -> Severity.ERROR == input.getSeverity()).collect(Collectors.toList());
|
return validate.stream().filter(input -> Severity.ERROR == input.getSeverity()).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -16,7 +16,6 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import org.openhab.core.events.EventPublisher;
|
import org.openhab.core.events.EventPublisher;
|
||||||
import org.openhab.core.items.GroupItem;
|
import org.openhab.core.items.GroupItem;
|
||||||
@ -98,7 +97,7 @@ public class BusEvent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static <T extends State> List<String> getAcceptedCommandNames(Item item) {
|
private static <T extends State> List<String> getAcceptedCommandNames(Item item) {
|
||||||
return item.getAcceptedCommandTypes().stream().map(t -> t.getSimpleName()).collect(Collectors.toList());
|
return item.getAcceptedCommandTypes().stream().map(Class::getSimpleName).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -171,7 +170,7 @@ public class BusEvent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static <T extends State> List<String> getAcceptedDataTypeNames(Item item) {
|
private static <T extends State> List<String> getAcceptedDataTypeNames(Item item) {
|
||||||
return item.getAcceptedDataTypes().stream().map(t -> t.getSimpleName()).collect(Collectors.toList());
|
return item.getAcceptedDataTypes().stream().map(Class::getSimpleName).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -19,7 +19,6 @@ import java.util.Map;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.eclipse.jdt.annotation.Nullable;
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
@ -142,6 +141,6 @@ public class GenericItemChannelLinkProvider extends AbstractProvider<ItemChannel
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<ItemChannelLink> getAll() {
|
public Collection<ItemChannelLink> getAll() {
|
||||||
return itemChannelLinkMap.values().stream().flatMap(Collection::stream).collect(Collectors.toList());
|
return itemChannelLinkMap.values().stream().flatMap(Collection::stream).toList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,6 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
@ -446,8 +445,7 @@ public class PersistenceManager implements ItemRegistryChangeListener, StateChan
|
|||||||
.forEach(strategy -> {
|
.forEach(strategy -> {
|
||||||
PersistenceCronStrategy cronStrategy = (PersistenceCronStrategy) strategy;
|
PersistenceCronStrategy cronStrategy = (PersistenceCronStrategy) strategy;
|
||||||
String cronExpression = cronStrategy.getCronExpression();
|
String cronExpression = cronStrategy.getCronExpression();
|
||||||
List<PersistenceItemConfiguration> itemConfigs = getMatchingConfigurations(strategy)
|
List<PersistenceItemConfiguration> itemConfigs = getMatchingConfigurations(strategy).toList();
|
||||||
.collect(Collectors.toList());
|
|
||||||
jobs.add(scheduler.schedule(() -> persistJob(itemConfigs), cronExpression));
|
jobs.add(scheduler.schedule(() -> persistJob(itemConfigs), cronExpression));
|
||||||
|
|
||||||
logger.debug("Scheduled strategy {} with cron expression {} for service {}",
|
logger.debug("Scheduled strategy {} with cron expression {} for service {}",
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.openhab.core.magic.internal.metadata;
|
package org.openhab.core.magic.internal.metadata;
|
||||||
|
|
||||||
import static java.util.stream.Collectors.toList;
|
|
||||||
import static org.openhab.core.config.core.ConfigDescriptionParameterBuilder.create;
|
import static org.openhab.core.config.core.ConfigDescriptionParameterBuilder.create;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -51,7 +50,7 @@ public class MagicMetadataProvider implements MetadataConfigDescriptionProvider
|
|||||||
return Stream.of( //
|
return Stream.of( //
|
||||||
new ParameterOption("just", "Just Magic"), //
|
new ParameterOption("just", "Just Magic"), //
|
||||||
new ParameterOption("pure", "Pure Magic") //
|
new ParameterOption("pure", "Pure Magic") //
|
||||||
).collect(toList());
|
).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -60,7 +59,7 @@ public class MagicMetadataProvider implements MetadataConfigDescriptionProvider
|
|||||||
case "just":
|
case "just":
|
||||||
return Stream.of( //
|
return Stream.of( //
|
||||||
create("electric", Type.BOOLEAN).withLabel("Use Electricity").build() //
|
create("electric", Type.BOOLEAN).withLabel("Use Electricity").build() //
|
||||||
).collect(toList());
|
).toList();
|
||||||
case "pure":
|
case "pure":
|
||||||
return Stream.of( //
|
return Stream.of( //
|
||||||
create("spell", Type.TEXT).withLabel("Spell").withDescription("The exact spell to use").build(), //
|
create("spell", Type.TEXT).withLabel("Spell").withDescription("The exact spell to use").build(), //
|
||||||
@ -72,8 +71,8 @@ public class MagicMetadataProvider implements MetadataConfigDescriptionProvider
|
|||||||
new ParameterOption("1", "Incredible"), //
|
new ParameterOption("1", "Incredible"), //
|
||||||
new ParameterOption("2", "Insane"), //
|
new ParameterOption("2", "Insane"), //
|
||||||
new ParameterOption("3", "Ludicrous") //
|
new ParameterOption("3", "Ludicrous") //
|
||||||
).collect(toList())).build() //
|
).toList()).build() //
|
||||||
).collect(toList());
|
).toList();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -91,19 +91,19 @@ public class MissingServiceAnalyzer {
|
|||||||
.collect(toSet());
|
.collect(toSet());
|
||||||
return Stream.of(description.references) //
|
return Stream.of(description.references) //
|
||||||
.filter(ref -> unsatisfiedRefNames.contains(ref.name)) //
|
.filter(ref -> unsatisfiedRefNames.contains(ref.name)) //
|
||||||
.collect(toList());
|
.toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<ComponentDescriptionDTO> getComponentDescriptions(ServiceComponentRuntime scr, String interfaceName,
|
private List<ComponentDescriptionDTO> getComponentDescriptions(ServiceComponentRuntime scr, String interfaceName,
|
||||||
Bundle[] allBundlesArrays) {
|
Bundle[] allBundlesArrays) {
|
||||||
return scr.getComponentDescriptionDTOs(allBundlesArrays).stream()
|
return scr.getComponentDescriptionDTOs(allBundlesArrays).stream()
|
||||||
.filter(description -> Stream.of(description.serviceInterfaces).anyMatch(s -> s.equals(interfaceName)))
|
.filter(description -> Stream.of(description.serviceInterfaces).anyMatch(s -> s.equals(interfaceName)))
|
||||||
.collect(toList());
|
.toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Bundle[] getAllBundles() {
|
private Bundle[] getAllBundles() {
|
||||||
List<Bundle> allBundles = Arrays.stream(bundleContext.getBundles())
|
List<Bundle> allBundles = Arrays.stream(bundleContext.getBundles())
|
||||||
.filter(b -> b.getHeaders().get(Constants.FRAGMENT_HOST) == null).collect(toList());
|
.filter(b -> b.getHeaders().get(Constants.FRAGMENT_HOST) == null).toList();
|
||||||
return allBundles.toArray(new Bundle[allBundles.size()]);
|
return allBundles.toArray(new Bundle[allBundles.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,6 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.eclipse.jdt.annotation.Nullable;
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
@ -118,11 +117,11 @@ public class JavaOSGiTest extends JavaTest {
|
|||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
return Arrays //
|
return (List<T>) Arrays //
|
||||||
.stream(serviceReferences) //
|
.stream(serviceReferences) //
|
||||||
.filter(filter) // apply the predicate
|
.filter(filter) // apply the predicate
|
||||||
.map(this::unrefService) // get the actual services from the references
|
.map(this::unrefService) // get the actual services from the references
|
||||||
.collect(Collectors.toList()); // get the result as List
|
.toList(); // get the result as List
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -204,7 +203,7 @@ public class JavaOSGiTest extends JavaTest {
|
|||||||
.map(this::unrefService) // get the actual services from the references
|
.map(this::unrefService) // get the actual services from the references
|
||||||
.filter(implementationClass::isInstance) // check that are of implementationClass
|
.filter(implementationClass::isInstance) // check that are of implementationClass
|
||||||
.map(implementationClass::cast) // cast instances to implementationClass
|
.map(implementationClass::cast) // cast instances to implementationClass
|
||||||
.collect(Collectors.toList()) // get the result as List
|
.toList() // get the result as List
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -281,7 +280,7 @@ public class JavaOSGiTest extends JavaTest {
|
|||||||
* The given interface names are used as OSGi service interface name.
|
* The given interface names are used as OSGi service interface name.
|
||||||
*
|
*
|
||||||
* @param service service to be registered
|
* @param service service to be registered
|
||||||
* @param interfaceName interface name of the OSGi service
|
* @param interfaceNames interface names of the OSGi service
|
||||||
* @param properties OSGi service properties
|
* @param properties OSGi service properties
|
||||||
* @return service registration object
|
* @return service registration object
|
||||||
*/
|
*/
|
||||||
|
@ -20,7 +20,6 @@ import java.util.Locale;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.eclipse.jdt.annotation.Nullable;
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
@ -199,7 +198,7 @@ public abstract class AbstractStorageBasedTypeProvider
|
|||||||
entity.configDescriptionUri = thingType.getConfigDescriptionURI();
|
entity.configDescriptionUri = thingType.getConfigDescriptionURI();
|
||||||
entity.category = thingType.getCategory();
|
entity.category = thingType.getCategory();
|
||||||
entity.channelGroupDefinitions = thingType.getChannelGroupDefinitions().stream()
|
entity.channelGroupDefinitions = thingType.getChannelGroupDefinitions().stream()
|
||||||
.map(AbstractStorageBasedTypeProvider::mapToEntity).collect(Collectors.toList());
|
.map(AbstractStorageBasedTypeProvider::mapToEntity).toList();
|
||||||
entity.channelDefinitions = thingType.getChannelDefinitions().stream()
|
entity.channelDefinitions = thingType.getChannelDefinitions().stream()
|
||||||
.map(AbstractStorageBasedTypeProvider::mapToEntity).toList();
|
.map(AbstractStorageBasedTypeProvider::mapToEntity).toList();
|
||||||
entity.representationProperty = thingType.getRepresentationProperty();
|
entity.representationProperty = thingType.getRepresentationProperty();
|
||||||
|
@ -12,8 +12,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.openhab.core.thing.internal;
|
package org.openhab.core.thing.internal;
|
||||||
|
|
||||||
import static java.util.stream.Collectors.toList;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
@ -49,7 +47,7 @@ public class AutoUpdateConfigDescriptionProvider implements MetadataConfigDescri
|
|||||||
return Stream.of( //
|
return Stream.of( //
|
||||||
new ParameterOption("true", "Enforce an auto update"), //
|
new ParameterOption("true", "Enforce an auto update"), //
|
||||||
new ParameterOption("false", "Veto an auto update") //
|
new ParameterOption("false", "Veto an auto update") //
|
||||||
).collect(toList());
|
).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -20,7 +20,6 @@ import java.util.Optional;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.eclipse.jdt.annotation.Nullable;
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
@ -121,9 +120,7 @@ public final class FirmwareRegistryImpl implements FirmwareRegistry {
|
|||||||
try {
|
try {
|
||||||
Collection<Firmware> result = firmwareProvider.getFirmwares(thing, loc);
|
Collection<Firmware> result = firmwareProvider.getFirmwares(thing, loc);
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
List<Firmware> suitableFirmwares = result.stream().filter(firmware -> firmware.isSuitableFor(thing))
|
result.stream().filter(firmware -> firmware.isSuitableFor(thing)).forEach(firmwares::add);
|
||||||
.collect(Collectors.toList());
|
|
||||||
firmwares.addAll(suitableFirmwares);
|
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.warn(
|
logger.warn(
|
||||||
|
@ -17,7 +17,6 @@ import java.util.Collection;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.eclipse.jdt.annotation.Nullable;
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
@ -116,8 +115,7 @@ public class ItemChannelLinkConfigDescriptionProvider implements ConfigDescripti
|
|||||||
default:
|
default:
|
||||||
throw new IllegalArgumentException("Unknown channel kind: " + channel.getKind());
|
throw new IllegalArgumentException("Unknown channel kind: " + channel.getKind());
|
||||||
}
|
}
|
||||||
}).map(profileType -> new ParameterOption(profileType.getUID().toString(), profileType.getLabel()))
|
}).map(profileType -> new ParameterOption(profileType.getUID().toString(), profileType.getLabel())).toList();
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isSupportedItemType(ProfileType profileType, Item item) {
|
private boolean isSupportedItemType(ProfileType profileType, Item item) {
|
||||||
|
@ -15,12 +15,10 @@ package org.openhab.core.thing.internal.profiles;
|
|||||||
import static org.openhab.core.thing.profiles.SystemProfiles.*;
|
import static org.openhab.core.thing.profiles.SystemProfiles.*;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.eclipse.jdt.annotation.Nullable;
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
@ -219,8 +217,7 @@ public class SystemProfileFactory implements ProfileFactory, ProfileAdvisor, Pro
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<ProfileType> getProfileTypes(@Nullable Locale locale) {
|
public Collection<ProfileType> getProfileTypes(@Nullable Locale locale) {
|
||||||
return Collections.unmodifiableList(SUPPORTED_PROFILE_TYPES.stream()
|
return SUPPORTED_PROFILE_TYPES.stream().map(p -> createLocalizedProfileType(p, locale)).toList();
|
||||||
.map(p -> createLocalizedProfileType(p, locale)).collect(Collectors.toList()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -12,8 +12,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.openhab.core.thing.xml.internal;
|
package org.openhab.core.thing.xml.internal;
|
||||||
|
|
||||||
import static java.util.stream.Collectors.toList;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -116,7 +114,7 @@ public class ThingTypeConverter extends AbstractDescriptionTypeConverter<ThingTy
|
|||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
return Arrays.stream(extensible.split(",")).map(String::trim).collect(toList());
|
return Arrays.stream(extensible.split(",")).map(String::trim).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected @Nullable String readCategory(NodeIterator nodeIterator) {
|
protected @Nullable String readCategory(NodeIterator nodeIterator) {
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.openhab.core.thing.util;
|
package org.openhab.core.thing.util;
|
||||||
|
|
||||||
import static java.util.stream.Collectors.toList;
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -138,10 +137,11 @@ public class ThingHelperTest {
|
|||||||
.build();
|
.build();
|
||||||
|
|
||||||
assertThrows(IllegalArgumentException.class,
|
assertThrows(IllegalArgumentException.class,
|
||||||
() -> ThingHelper.addChannelsToThing(thing,
|
() -> ThingHelper
|
||||||
Stream.of(ChannelBuilder.create(new ChannelUID(thingUID, "channel2"), "").build(),
|
.addChannelsToThing(thing,
|
||||||
ChannelBuilder.create(new ChannelUID(thingUID, "channel3"), "").build())
|
Stream.of(ChannelBuilder.create(new ChannelUID(thingUID, "channel2"), "").build(),
|
||||||
.collect(toList())));
|
ChannelBuilder.create(new ChannelUID(thingUID, "channel3"), "").build())
|
||||||
|
.toList()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -29,7 +29,6 @@ import java.util.List;
|
|||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.eclipse.jdt.annotation.Nullable;
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
@ -296,8 +295,7 @@ public abstract class AbstractFileTransformationService<T> implements Transforma
|
|||||||
*/
|
*/
|
||||||
protected List<String> getFilenames(String[] validExtensions) {
|
protected List<String> getFilenames(String[] validExtensions) {
|
||||||
File path = new File(getSourcePath());
|
File path = new File(getSourcePath());
|
||||||
return Arrays.asList(path.listFiles(new FileExtensionsFilter(validExtensions))).stream().map(f -> f.getName())
|
return Arrays.stream(path.listFiles(new FileExtensionsFilter(validExtensions))).map(File::getName).toList();
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected class FileExtensionsFilter implements FilenameFilter {
|
protected class FileExtensionsFilter implements FilenameFilter {
|
||||||
|
@ -17,7 +17,6 @@ import java.util.Locale;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.eclipse.jdt.annotation.Nullable;
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
@ -82,7 +81,7 @@ public class TransformationRegistryImpl extends AbstractRegistry<Transformation,
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<Transformation> getTransformations(Collection<String> types) {
|
public Collection<Transformation> getTransformations(Collection<String> types) {
|
||||||
return getAll().stream().filter(e -> types.contains(e.getType())).collect(Collectors.toList());
|
return getAll().stream().filter(e -> types.contains(e.getType())).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Reference(cardinality = ReferenceCardinality.OPTIONAL, policy = ReferencePolicy.DYNAMIC)
|
@Reference(cardinality = ReferenceCardinality.OPTIONAL, policy = ReferencePolicy.DYNAMIC)
|
||||||
|
@ -18,7 +18,6 @@ import java.util.HashSet;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.WeakHashMap;
|
import java.util.WeakHashMap;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
@ -426,12 +425,12 @@ public class DialogProcessor implements KSListener, STTListener {
|
|||||||
|
|
||||||
private void playStartSound() {
|
private void playStartSound() {
|
||||||
playNotes(Stream.of(ToneSynthesizer.Note.G, ToneSynthesizer.Note.A, ToneSynthesizer.Note.B)
|
playNotes(Stream.of(ToneSynthesizer.Note.G, ToneSynthesizer.Note.A, ToneSynthesizer.Note.B)
|
||||||
.map(note -> ToneSynthesizer.noteTone(note, 100L)).collect(Collectors.toList()));
|
.map(note -> ToneSynthesizer.noteTone(note, 100L)).toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void playStopSound() {
|
private void playStopSound() {
|
||||||
playNotes(Stream.of(ToneSynthesizer.Note.B, ToneSynthesizer.Note.A, ToneSynthesizer.Note.G)
|
playNotes(Stream.of(ToneSynthesizer.Note.B, ToneSynthesizer.Note.A, ToneSynthesizer.Note.G)
|
||||||
.map(note -> ToneSynthesizer.noteTone(note, 100L)).collect(Collectors.toList()));
|
.map(note -> ToneSynthesizer.noteTone(note, 100L)).toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void playOnListeningSound() {
|
private void playOnListeningSound() {
|
||||||
|
@ -492,7 +492,7 @@ public class VoiceConsoleCommandExtension extends AbstractConsoleCommandExtensio
|
|||||||
|
|
||||||
String hliIds = parameters.remove("hlis");
|
String hliIds = parameters.remove("hlis");
|
||||||
if (hliIds != null) {
|
if (hliIds != null) {
|
||||||
dr.hliIds = Arrays.stream(hliIds.split(",")).map(String::trim).collect(Collectors.toList());
|
dr.hliIds = Arrays.stream(hliIds.split(",")).map(String::trim).toList();
|
||||||
}
|
}
|
||||||
if (!parameters.isEmpty()) {
|
if (!parameters.isEmpty()) {
|
||||||
throw new IllegalStateException(
|
throw new IllegalStateException(
|
||||||
|
@ -500,7 +500,7 @@ public class VoiceManagerImpl implements VoiceManager, ConfigOptionProvider, Dia
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<DialogContext> getDialogsContexts() {
|
public List<DialogContext> getDialogsContexts() {
|
||||||
return dialogProcessors.values().stream().map(DialogProcessor::getContext).collect(Collectors.toList());
|
return dialogProcessors.values().stream().map(DialogProcessor::getContext).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -900,30 +900,27 @@ public class VoiceManagerImpl implements VoiceManager, ConfigOptionProvider, Dia
|
|||||||
case CONFIG_DEFAULT_HLI:
|
case CONFIG_DEFAULT_HLI:
|
||||||
return humanLanguageInterpreters.values().stream()
|
return humanLanguageInterpreters.values().stream()
|
||||||
.sorted((hli1, hli2) -> hli1.getLabel(locale).compareToIgnoreCase(hli2.getLabel(locale)))
|
.sorted((hli1, hli2) -> hli1.getLabel(locale).compareToIgnoreCase(hli2.getLabel(locale)))
|
||||||
.map(hli -> new ParameterOption(hli.getId(), hli.getLabel(locale)))
|
.map(hli -> new ParameterOption(hli.getId(), hli.getLabel(locale))).toList();
|
||||||
.collect(Collectors.toList());
|
|
||||||
case CONFIG_DEFAULT_KS:
|
case CONFIG_DEFAULT_KS:
|
||||||
return ksServices.values().stream()
|
return ksServices.values().stream()
|
||||||
.sorted((ks1, ks2) -> ks1.getLabel(locale).compareToIgnoreCase(ks2.getLabel(locale)))
|
.sorted((ks1, ks2) -> ks1.getLabel(locale).compareToIgnoreCase(ks2.getLabel(locale)))
|
||||||
.map(ks -> new ParameterOption(ks.getId(), ks.getLabel(locale)))
|
.map(ks -> new ParameterOption(ks.getId(), ks.getLabel(locale))).toList();
|
||||||
.collect(Collectors.toList());
|
|
||||||
case CONFIG_DEFAULT_STT:
|
case CONFIG_DEFAULT_STT:
|
||||||
return sttServices.values().stream()
|
return sttServices.values().stream()
|
||||||
.sorted((stt1, stt2) -> stt1.getLabel(locale).compareToIgnoreCase(stt2.getLabel(locale)))
|
.sorted((stt1, stt2) -> stt1.getLabel(locale).compareToIgnoreCase(stt2.getLabel(locale)))
|
||||||
.map(stt -> new ParameterOption(stt.getId(), stt.getLabel(locale)))
|
.map(stt -> new ParameterOption(stt.getId(), stt.getLabel(locale))).toList();
|
||||||
.collect(Collectors.toList());
|
|
||||||
case CONFIG_DEFAULT_TTS:
|
case CONFIG_DEFAULT_TTS:
|
||||||
return ttsServices.values().stream()
|
return ttsServices.values().stream()
|
||||||
.sorted((tts1, tts2) -> tts1.getLabel(locale).compareToIgnoreCase(tts2.getLabel(locale)))
|
.sorted((tts1, tts2) -> tts1.getLabel(locale).compareToIgnoreCase(tts2.getLabel(locale)))
|
||||||
.map(tts -> new ParameterOption(tts.getId(), tts.getLabel(locale)))
|
.map(tts -> new ParameterOption(tts.getId(), tts.getLabel(locale))).toList();
|
||||||
.collect(Collectors.toList());
|
|
||||||
case CONFIG_DEFAULT_VOICE:
|
case CONFIG_DEFAULT_VOICE:
|
||||||
Locale nullSafeLocale = locale != null ? locale : localeProvider.getLocale();
|
Locale nullSafeLocale = locale != null ? locale : localeProvider.getLocale();
|
||||||
return getAllVoicesSorted(nullSafeLocale).stream().filter(v -> getTTS(v) != null)
|
return getAllVoicesSorted(nullSafeLocale)
|
||||||
.map(v -> new ParameterOption(v.getUID(),
|
.stream().filter(v -> getTTS(v) != null).map(
|
||||||
String.format("%s - %s - %s", getTTS(v).getLabel(nullSafeLocale),
|
v -> new ParameterOption(v.getUID(),
|
||||||
v.getLocale().getDisplayName(nullSafeLocale), v.getLabel())))
|
String.format("%s - %s - %s", getTTS(v).getLabel(nullSafeLocale),
|
||||||
.collect(Collectors.toList());
|
v.getLocale().getDisplayName(nullSafeLocale), v.getLabel())))
|
||||||
|
.toList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -12,8 +12,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.openhab.core.voice.text;
|
package org.openhab.core.voice.text;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -34,7 +32,7 @@ public class TokenList {
|
|||||||
* @param list of the initial tokens
|
* @param list of the initial tokens
|
||||||
*/
|
*/
|
||||||
public TokenList(List<String> list) {
|
public TokenList(List<String> list) {
|
||||||
this.list = Collections.unmodifiableList(new ArrayList<>(list));
|
this.list = List.copyOf(list);
|
||||||
this.head = 0;
|
this.head = 0;
|
||||||
this.tail = list.size() - 1;
|
this.tail = list.size() - 1;
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,6 @@ package org.openhab.core.common.registry;
|
|||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNull;
|
import org.eclipse.jdt.annotation.NonNull;
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
@ -70,8 +69,7 @@ public abstract class AbstractManagedProvider<@NonNull E extends Identifiable<K>
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<E> getAll() {
|
public Collection<E> getAll() {
|
||||||
return (Collection<E>) storage.getKeys().stream().map(this::getElement).filter(Objects::nonNull)
|
return (Collection<E>) storage.getKeys().stream().map(this::getElement).filter(Objects::nonNull).toList();
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -12,8 +12,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.openhab.core.internal.items;
|
package org.openhab.core.internal.items;
|
||||||
|
|
||||||
import static java.util.stream.Collectors.toList;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -262,11 +260,11 @@ public class ItemRegistryImpl extends AbstractRegistry<Item, String, ItemProvide
|
|||||||
// don't use #initialize and retain order of items in groups:
|
// don't use #initialize and retain order of items in groups:
|
||||||
List<String> oldNames = oldItem.getGroupNames();
|
List<String> oldNames = oldItem.getGroupNames();
|
||||||
List<String> newNames = item.getGroupNames();
|
List<String> newNames = item.getGroupNames();
|
||||||
List<String> commonNames = oldNames.stream().filter(newNames::contains).collect(toList());
|
List<String> commonNames = oldNames.stream().filter(newNames::contains).toList();
|
||||||
|
|
||||||
removeFromGroupItems(oldItem, oldNames.stream().filter(name -> !commonNames.contains(name)).collect(toList()));
|
removeFromGroupItems(oldItem, oldNames.stream().filter(name -> !commonNames.contains(name)).toList());
|
||||||
replaceInGroupItems(oldItem, item, commonNames);
|
replaceInGroupItems(oldItem, item, commonNames);
|
||||||
addToGroupItems(item, newNames.stream().filter(name -> !commonNames.contains(name)).collect(toList()));
|
addToGroupItems(item, newNames.stream().filter(name -> !commonNames.contains(name)).toList());
|
||||||
if (item instanceof GroupItem groupItem) {
|
if (item instanceof GroupItem groupItem) {
|
||||||
addMembersToGroupItem(groupItem);
|
addMembersToGroupItem(groupItem);
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,6 @@ import java.math.BigInteger;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
@ -111,7 +110,7 @@ public class MetadataStateDescriptionFragmentProvider implements StateDescriptio
|
|||||||
} else {
|
} else {
|
||||||
return new StateOption(o.trim(), null);
|
return new StateOption(o.trim(), null);
|
||||||
}
|
}
|
||||||
}).collect(Collectors.toList());
|
}).toList();
|
||||||
builder.withOptions(stateOptions);
|
builder.withOptions(stateOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ public abstract class GenericItem implements ActiveItem {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getGroupNames() {
|
public List<String> getGroupNames() {
|
||||||
return Collections.unmodifiableList(new ArrayList<>(groupNames));
|
return List.copyOf(groupNames);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -18,7 +18,6 @@ import java.util.Arrays;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.SortedMap;
|
import java.util.SortedMap;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.eclipse.jdt.annotation.Nullable;
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
@ -86,7 +85,7 @@ public class HSBType extends PercentType implements ComplexType, State, Command
|
|||||||
* @param value a stringified HSBType value in the format "hue,saturation,brightness"
|
* @param value a stringified HSBType value in the format "hue,saturation,brightness"
|
||||||
*/
|
*/
|
||||||
public HSBType(String value) {
|
public HSBType(String value) {
|
||||||
List<String> constituents = Arrays.stream(value.split(",")).map(String::trim).collect(Collectors.toList());
|
List<String> constituents = Arrays.stream(value.split(",")).map(String::trim).toList();
|
||||||
if (constituents.size() == 3) {
|
if (constituents.size() == 3) {
|
||||||
this.hue = new BigDecimal(constituents.get(0));
|
this.hue = new BigDecimal(constituents.get(0));
|
||||||
this.saturation = new BigDecimal(constituents.get(1));
|
this.saturation = new BigDecimal(constituents.get(1));
|
||||||
|
@ -18,7 +18,6 @@ import java.util.Formatter;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.SortedMap;
|
import java.util.SortedMap;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.eclipse.jdt.annotation.Nullable;
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
@ -85,7 +84,7 @@ public class PointType implements ComplexType, Command, State {
|
|||||||
|
|
||||||
public PointType(String value) {
|
public PointType(String value) {
|
||||||
if (!value.isEmpty()) {
|
if (!value.isEmpty()) {
|
||||||
List<String> elements = Arrays.stream(value.split(",")).map(String::trim).collect(Collectors.toList());
|
List<String> elements = Arrays.stream(value.split(",")).map(String::trim).toList();
|
||||||
if (elements.size() >= 2) {
|
if (elements.size() >= 2) {
|
||||||
canonicalize(new DecimalType(elements.get(0)), new DecimalType(elements.get(1)));
|
canonicalize(new DecimalType(elements.get(0)), new DecimalType(elements.get(1)));
|
||||||
if (elements.size() == 3) {
|
if (elements.size() == 3) {
|
||||||
|
@ -49,7 +49,7 @@ public class StringListType implements Command, State {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public StringListType(StringType... rows) {
|
public StringListType(StringType... rows) {
|
||||||
typeDetails = Arrays.stream(rows).map(StringType::toString).collect(Collectors.toList());
|
typeDetails = Arrays.stream(rows).map(StringType::toString).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public StringListType(String... rows) {
|
public StringListType(String... rows) {
|
||||||
@ -61,7 +61,7 @@ public class StringListType implements Command, State {
|
|||||||
*/
|
*/
|
||||||
public StringListType(String serialized) {
|
public StringListType(String serialized) {
|
||||||
typeDetails = Arrays.stream(serialized.split(REGEX_SPLITTER, -1))
|
typeDetails = Arrays.stream(serialized.split(REGEX_SPLITTER, -1))
|
||||||
.map(s -> s.replace(ESCAPED_DELIMITER, DELIMITER)).collect(Collectors.toList());
|
.map(s -> s.replace(ESCAPED_DELIMITER, DELIMITER)).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getValue(final int index) {
|
public String getValue(final int index) {
|
||||||
|
@ -34,7 +34,6 @@ import java.util.concurrent.ScheduledExecutorService;
|
|||||||
import java.util.concurrent.ScheduledFuture;
|
import java.util.concurrent.ScheduledFuture;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.eclipse.jdt.annotation.Nullable;
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
@ -319,7 +318,7 @@ public class NetUtil implements NetworkAddressService {
|
|||||||
*
|
*
|
||||||
* Example to get a list of only IPv4 addresses in string representation:
|
* Example to get a list of only IPv4 addresses in string representation:
|
||||||
* List<String> l = getAllInterfaceAddresses().stream().filter(a->a.getAddress() instanceof
|
* List<String> l = getAllInterfaceAddresses().stream().filter(a->a.getAddress() instanceof
|
||||||
* Inet4Address).map(a->a.getAddress().getHostAddress()).collect(Collectors.toList());
|
* Inet4Address).map(a->a.getAddress().getHostAddress()).toList();
|
||||||
*
|
*
|
||||||
* down, or loopback interfaces are skipped.
|
* down, or loopback interfaces are skipped.
|
||||||
*
|
*
|
||||||
@ -531,19 +530,20 @@ public class NetUtil implements NetworkAddressService {
|
|||||||
|
|
||||||
// Look for added addresses to notify
|
// Look for added addresses to notify
|
||||||
List<CidrAddress> added = newInterfaceAddresses.stream()
|
List<CidrAddress> added = newInterfaceAddresses.stream()
|
||||||
.filter(newInterfaceAddr -> !lastKnownInterfaceAddresses.contains(newInterfaceAddr))
|
.filter(newInterfaceAddr -> !lastKnownInterfaceAddresses.contains(newInterfaceAddr)).toList();
|
||||||
.collect(Collectors.toList());
|
|
||||||
|
|
||||||
// Look for removed addresses to notify
|
// Look for removed addresses to notify
|
||||||
List<CidrAddress> removed = lastKnownInterfaceAddresses.stream()
|
List<CidrAddress> removed = lastKnownInterfaceAddresses.stream()
|
||||||
.filter(lastKnownInterfaceAddr -> !newInterfaceAddresses.contains(lastKnownInterfaceAddr))
|
.filter(lastKnownInterfaceAddr -> !newInterfaceAddresses.contains(lastKnownInterfaceAddr)).toList();
|
||||||
.collect(Collectors.toList());
|
|
||||||
|
|
||||||
lastKnownInterfaceAddresses = newInterfaceAddresses;
|
lastKnownInterfaceAddresses = newInterfaceAddresses;
|
||||||
|
|
||||||
if (!added.isEmpty() || !removed.isEmpty()) {
|
if (!added.isEmpty() || !removed.isEmpty()) {
|
||||||
LOGGER.debug("added {} network interfaces: {}", added.size(), Arrays.deepToString(added.toArray()));
|
if (LOGGER.isDebugEnabled()) {
|
||||||
LOGGER.debug("removed {} network interfaces: {}", removed.size(), Arrays.deepToString(removed.toArray()));
|
LOGGER.debug("added {} network interfaces: {}", added.size(), Arrays.deepToString(added.toArray()));
|
||||||
|
LOGGER.debug("removed {} network interfaces: {}", removed.size(),
|
||||||
|
Arrays.deepToString(removed.toArray()));
|
||||||
|
}
|
||||||
|
|
||||||
notifyListeners(added, removed);
|
notifyListeners(added, removed);
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,6 @@ import java.util.Arrays;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import org.apache.commons.lang3.mutable.Mutable;
|
import org.apache.commons.lang3.mutable.Mutable;
|
||||||
import org.apache.commons.lang3.mutable.MutableObject;
|
import org.apache.commons.lang3.mutable.MutableObject;
|
||||||
@ -202,7 +201,7 @@ public class LRUMediaCacheEntryTest {
|
|||||||
exceptionCatched.setValue(e);
|
exceptionCatched.setValue(e);
|
||||||
return new byte[0];
|
return new byte[0];
|
||||||
}
|
}
|
||||||
}).collect(Collectors.toList());
|
}).toList();
|
||||||
|
|
||||||
IOException possibleException = exceptionCatched.getValue();
|
IOException possibleException = exceptionCatched.getValue();
|
||||||
if (possibleException != null) {
|
if (possibleException != null) {
|
||||||
|
@ -919,7 +919,7 @@ public class AutomationIntegrationTest extends JavaOSGiTest {
|
|||||||
ModuleBuilder.createCondition().withId("ItemStateCondition" + (random + 1))
|
ModuleBuilder.createCondition().withId("ItemStateCondition" + (random + 1))
|
||||||
.withTypeUID("core.GenericCompareCondition").withConfiguration(condition2Config)
|
.withTypeUID("core.GenericCompareCondition").withConfiguration(condition2Config)
|
||||||
.withInputs(Map.of("input", triggerId + ".event")).build())
|
.withInputs(Map.of("input", triggerId + ".event")).build())
|
||||||
.collect(toList());
|
.toList();
|
||||||
|
|
||||||
List<Action> actions = List.of(ModuleBuilder.createAction().withId("ItemPostCommandAction" + random)
|
List<Action> actions = List.of(ModuleBuilder.createAction().withId("ItemPostCommandAction" + random)
|
||||||
.withTypeUID("core.ItemCommandAction").withConfiguration(actionConfig).build());
|
.withTypeUID("core.ItemCommandAction").withConfiguration(actionConfig).build());
|
||||||
|
@ -31,7 +31,6 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.eclipse.jdt.annotation.Nullable;
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
@ -147,7 +146,7 @@ public class RuleSimulationTest extends JavaOSGiTest {
|
|||||||
final ZonedDateTime from = ZonedDateTime.of(2021, 1, 4, 0, 0, 0, 0, ZoneId.systemDefault());
|
final ZonedDateTime from = ZonedDateTime.of(2021, 1, 4, 0, 0, 0, 0, ZoneId.systemDefault());
|
||||||
final ZonedDateTime until = ZonedDateTime.of(2021, 1, 17, 23, 59, 59, 0, ZoneId.systemDefault());
|
final ZonedDateTime until = ZonedDateTime.of(2021, 1, 17, 23, 59, 59, 0, ZoneId.systemDefault());
|
||||||
|
|
||||||
List<RuleExecution> executions = ruleEngine.simulateRuleExecutions(from, until).collect(Collectors.toList());
|
List<RuleExecution> executions = ruleEngine.simulateRuleExecutions(from, until).toList();
|
||||||
|
|
||||||
// Every rule fires twice a week. We simulate for two weeks so we expect 12 executions
|
// Every rule fires twice a week. We simulate for two weeks so we expect 12 executions
|
||||||
// TODO: must be 12, but Ephemeris Condition is not yet evaluated in test, because dayset is not configured.
|
// TODO: must be 12, but Ephemeris Condition is not yet evaluated in test, because dayset is not configured.
|
||||||
|
@ -25,7 +25,6 @@ import java.util.Map;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.eclipse.jdt.annotation.Nullable;
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
@ -199,7 +198,7 @@ public class RuleEventTest extends JavaOSGiTest {
|
|||||||
assertThat(ruleEvents.stream().filter(e -> "openhab/rules/myRule21/state".equals(e.getTopic())).findFirst()
|
assertThat(ruleEvents.stream().filter(e -> "openhab/rules/myRule21/state".equals(e.getTopic())).findFirst()
|
||||||
.isPresent(), is(true));
|
.isPresent(), is(true));
|
||||||
List<Event> stateEvents = ruleEvents.stream().filter(e -> "openhab/rules/myRule21/state".equals(e.getTopic()))
|
List<Event> stateEvents = ruleEvents.stream().filter(e -> "openhab/rules/myRule21/state".equals(e.getTopic()))
|
||||||
.collect(Collectors.toList());
|
.toList();
|
||||||
assertThat(stateEvents, is(notNullValue()));
|
assertThat(stateEvents, is(notNullValue()));
|
||||||
Optional<Event> runningEvent = stateEvents.stream()
|
Optional<Event> runningEvent = stateEvents.stream()
|
||||||
.filter(e -> ((RuleStatusInfoEvent) e).getStatusInfo().getStatus() == RuleStatus.RUNNING).findFirst();
|
.filter(e -> ((RuleStatusInfoEvent) e).getStatusInfo().getStatus() == RuleStatus.RUNNING).findFirst();
|
||||||
|
@ -19,7 +19,6 @@ import java.util.Collection;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
@ -82,13 +81,12 @@ public class RuleRegistryTest extends JavaOSGiTest {
|
|||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// checking that results from stream() have the same size as getAll() above
|
// checking that results from stream() have the same size as getAll() above
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
assertEquals(1, ruleRegistry.stream().collect(Collectors.toList()).size(), "RuleImpl list size");
|
assertEquals(1, ruleRegistry.stream().toList().size(), "RuleImpl list size");
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// checking predicates
|
// checking predicates
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
assertEquals(1, ruleRegistry.stream().filter(hasNoTags()).collect(Collectors.toList()).size(),
|
assertEquals(1, ruleRegistry.stream().filter(hasNoTags()).toList().size(), "RuleImpl list size");
|
||||||
"RuleImpl list size");
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// checking rule with 1 tag
|
// checking rule with 1 tag
|
||||||
@ -112,7 +110,7 @@ public class RuleRegistryTest extends JavaOSGiTest {
|
|||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// checking that results from stream() have the same size as getAll() above
|
// checking that results from stream() have the same size as getAll() above
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
assertEquals(2, ruleRegistry.stream().collect(Collectors.toList()).size(), "RuleImpl list size");
|
assertEquals(2, ruleRegistry.stream().toList().size(), "RuleImpl list size");
|
||||||
|
|
||||||
Collection<Rule> rulesWithTag1 = ruleRegistry.getByTags(tag1);
|
Collection<Rule> rulesWithTag1 = ruleRegistry.getByTags(tag1);
|
||||||
assertEquals(1, rulesWithTag1.size(), "RuleImpl list size");
|
assertEquals(1, rulesWithTag1.size(), "RuleImpl list size");
|
||||||
@ -120,18 +118,13 @@ public class RuleRegistryTest extends JavaOSGiTest {
|
|||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// checking predicates
|
// checking predicates
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
assertEquals(1, ruleRegistry.stream().filter(hasNoTags()).collect(Collectors.toList()).size(),
|
assertEquals(1, ruleRegistry.stream().filter(hasNoTags()).toList().size(), "RuleImpl list size");
|
||||||
"RuleImpl list size");
|
|
||||||
|
|
||||||
assertEquals(1, ruleRegistry.stream().filter(hasAnyOfTags(tags)).collect(Collectors.toList()).size(),
|
assertEquals(1, ruleRegistry.stream().filter(hasAnyOfTags(tags)).toList().size(), "RuleImpl list size");
|
||||||
"RuleImpl list size");
|
assertEquals(1, ruleRegistry.stream().filter(hasAnyOfTags(tag1)).toList().size(), "RuleImpl list size");
|
||||||
assertEquals(1, ruleRegistry.stream().filter(hasAnyOfTags(tag1)).collect(Collectors.toList()).size(),
|
|
||||||
"RuleImpl list size");
|
|
||||||
|
|
||||||
assertEquals(1, ruleRegistry.stream().filter(hasAllTags(tags)).collect(Collectors.toList()).size(),
|
assertEquals(1, ruleRegistry.stream().filter(hasAllTags(tags)).toList().size(), "RuleImpl list size");
|
||||||
"RuleImpl list size");
|
assertEquals(1, ruleRegistry.stream().filter(hasAllTags(tag1)).toList().size(), "RuleImpl list size");
|
||||||
assertEquals(1, ruleRegistry.stream().filter(hasAllTags(tag1)).collect(Collectors.toList()).size(),
|
|
||||||
"RuleImpl list size");
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// checking rule with 2 tags
|
// checking rule with 2 tags
|
||||||
@ -156,7 +149,7 @@ public class RuleRegistryTest extends JavaOSGiTest {
|
|||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// checking that results from stream() have the same size as getAll() above
|
// checking that results from stream() have the same size as getAll() above
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
assertEquals(3, ruleRegistry.stream().collect(Collectors.toList()).size(), "RuleImpl list size");
|
assertEquals(3, ruleRegistry.stream().toList().size(), "RuleImpl list size");
|
||||||
|
|
||||||
rulesWithTag1 = ruleRegistry.getByTags(tag1);
|
rulesWithTag1 = ruleRegistry.getByTags(tag1);
|
||||||
assertEquals(2, rulesWithTag1.size(), "RuleImpl list size");
|
assertEquals(2, rulesWithTag1.size(), "RuleImpl list size");
|
||||||
@ -170,35 +163,26 @@ public class RuleRegistryTest extends JavaOSGiTest {
|
|||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// checking predicates
|
// checking predicates
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
assertEquals(1, ruleRegistry.stream().filter(hasNoTags()).collect(Collectors.toList()).size(),
|
assertEquals(1, ruleRegistry.stream().filter(hasNoTags()).toList().size(), "RuleImpl list size");
|
||||||
|
|
||||||
|
assertEquals(2, ruleRegistry.stream().filter(hasAnyOfTags(tags)).toList().size(), "RuleImpl list size");
|
||||||
|
assertEquals(2, ruleRegistry.stream().filter(hasAnyOfTags(tag1)).toList().size(), "RuleImpl list size");
|
||||||
|
assertEquals(2, ruleRegistry.stream().filter(hasAnyOfTags(tag1, tag2)).toList().size(), "RuleImpl list size");
|
||||||
|
|
||||||
|
assertEquals(1, ruleRegistry.stream().filter(hasAnyOfTags(tag2)).toList().size(), "RuleImpl list size");
|
||||||
|
|
||||||
|
assertEquals(1, ruleRegistry.stream().filter(hasAnyOfTags(tag1).and(hasAnyOfTags(tag2))).toList().size(),
|
||||||
"RuleImpl list size");
|
"RuleImpl list size");
|
||||||
|
|
||||||
assertEquals(2, ruleRegistry.stream().filter(hasAnyOfTags(tags)).collect(Collectors.toList()).size(),
|
assertEquals(2, ruleRegistry.stream().filter(hasAllTags(tag1)).toList().size(), "RuleImpl list size");
|
||||||
"RuleImpl list size");
|
|
||||||
assertEquals(2, ruleRegistry.stream().filter(hasAnyOfTags(tag1)).collect(Collectors.toList()).size(),
|
|
||||||
"RuleImpl list size");
|
|
||||||
assertEquals(2, ruleRegistry.stream().filter(hasAnyOfTags(tag1, tag2)).collect(Collectors.toList()).size(),
|
|
||||||
"RuleImpl list size");
|
|
||||||
|
|
||||||
assertEquals(1, ruleRegistry.stream().filter(hasAnyOfTags(tag2)).collect(Collectors.toList()).size(),
|
assertEquals(1, ruleRegistry.stream().filter(hasAllTags(tags)).toList().size(), "RuleImpl list size");
|
||||||
"RuleImpl list size");
|
assertEquals(1, ruleRegistry.stream().filter(hasAllTags(tag1, tag2)).toList().size(), "RuleImpl list size");
|
||||||
|
assertEquals(1, ruleRegistry.stream().filter(hasAllTags(tag2)).toList().size(), "RuleImpl list size");
|
||||||
|
|
||||||
assertEquals(1, ruleRegistry.stream().filter(hasAnyOfTags(tag1).and(hasAnyOfTags(tag2)))
|
assertEquals(1, ruleRegistry.stream().filter(hasAllTags(tag1).and(hasAllTags(tag2))).toList().size(),
|
||||||
.collect(Collectors.toList()).size(), "RuleImpl list size");
|
|
||||||
|
|
||||||
assertEquals(2, ruleRegistry.stream().filter(hasAllTags(tag1)).collect(Collectors.toList()).size(),
|
|
||||||
"RuleImpl list size");
|
"RuleImpl list size");
|
||||||
|
|
||||||
assertEquals(1, ruleRegistry.stream().filter(hasAllTags(tags)).collect(Collectors.toList()).size(),
|
|
||||||
"RuleImpl list size");
|
|
||||||
assertEquals(1, ruleRegistry.stream().filter(hasAllTags(tag1, tag2)).collect(Collectors.toList()).size(),
|
|
||||||
"RuleImpl list size");
|
|
||||||
assertEquals(1, ruleRegistry.stream().filter(hasAllTags(tag2)).collect(Collectors.toList()).size(),
|
|
||||||
"RuleImpl list size");
|
|
||||||
|
|
||||||
assertEquals(1, ruleRegistry.stream().filter(hasAllTags(tag1).and(hasAllTags(tag2)))
|
|
||||||
.collect(Collectors.toList()).size(), "RuleImpl list size");
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// checking rule with 3 tags
|
// checking rule with 3 tags
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -223,7 +207,7 @@ public class RuleRegistryTest extends JavaOSGiTest {
|
|||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// checking that results from stream() have the same size as getAll() above
|
// checking that results from stream() have the same size as getAll() above
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
assertEquals(4, ruleRegistry.stream().collect(Collectors.toList()).size(), "RuleImpl list size");
|
assertEquals(4, ruleRegistry.stream().toList().size(), "RuleImpl list size");
|
||||||
|
|
||||||
rulesWithTag1 = ruleRegistry.getByTags(tag1);
|
rulesWithTag1 = ruleRegistry.getByTags(tag1);
|
||||||
assertEquals(3, rulesWithTag1.size(), "RuleImpl list size");
|
assertEquals(3, rulesWithTag1.size(), "RuleImpl list size");
|
||||||
@ -246,46 +230,34 @@ public class RuleRegistryTest extends JavaOSGiTest {
|
|||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// checking predicates
|
// checking predicates
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
assertEquals(1, ruleRegistry.stream().filter(hasNoTags()).collect(Collectors.toList()).size(),
|
assertEquals(1, ruleRegistry.stream().filter(hasNoTags()).toList().size(), "RuleImpl list size");
|
||||||
|
|
||||||
|
assertEquals(3, ruleRegistry.stream().filter(hasAnyOfTags(tags)).toList().size(), "RuleImpl list size");
|
||||||
|
assertEquals(3, ruleRegistry.stream().filter(hasAnyOfTags(tag1)).toList().size(), "RuleImpl list size");
|
||||||
|
assertEquals(3, ruleRegistry.stream().filter(hasAnyOfTags(tag1, tag2)).toList().size(), "RuleImpl list size");
|
||||||
|
assertEquals(3, ruleRegistry.stream().filter(hasAnyOfTags(tag1, tag2, tag3)).toList().size(),
|
||||||
"RuleImpl list size");
|
"RuleImpl list size");
|
||||||
|
|
||||||
assertEquals(3, ruleRegistry.stream().filter(hasAnyOfTags(tags)).collect(Collectors.toList()).size(),
|
assertEquals(2, ruleRegistry.stream().filter(hasAnyOfTags(tag2)).toList().size(), "RuleImpl list size");
|
||||||
"RuleImpl list size");
|
assertEquals(2, ruleRegistry.stream().filter(hasAnyOfTags(tag2, tag3)).toList().size(), "RuleImpl list size");
|
||||||
assertEquals(3, ruleRegistry.stream().filter(hasAnyOfTags(tag1)).collect(Collectors.toList()).size(),
|
|
||||||
"RuleImpl list size");
|
assertEquals(2, ruleRegistry.stream().filter(hasAnyOfTags(tag1).and(hasAnyOfTags(tag2))).toList().size(),
|
||||||
assertEquals(3, ruleRegistry.stream().filter(hasAnyOfTags(tag1, tag2)).collect(Collectors.toList()).size(),
|
|
||||||
"RuleImpl list size");
|
|
||||||
assertEquals(3,
|
|
||||||
ruleRegistry.stream().filter(hasAnyOfTags(tag1, tag2, tag3)).collect(Collectors.toList()).size(),
|
|
||||||
"RuleImpl list size");
|
"RuleImpl list size");
|
||||||
|
|
||||||
assertEquals(2, ruleRegistry.stream().filter(hasAnyOfTags(tag2)).collect(Collectors.toList()).size(),
|
assertEquals(1, ruleRegistry.stream().filter(hasAnyOfTags(tag1).and(hasAnyOfTags(tag3))).toList().size(),
|
||||||
"RuleImpl list size");
|
"RuleImpl list size");
|
||||||
assertEquals(2, ruleRegistry.stream().filter(hasAnyOfTags(tag2, tag3)).collect(Collectors.toList()).size(),
|
assertEquals(1, ruleRegistry.stream().filter(hasAnyOfTags(tag2).and(hasAnyOfTags(tag3))).toList().size(),
|
||||||
"RuleImpl list size");
|
"RuleImpl list size");
|
||||||
|
|
||||||
assertEquals(2, ruleRegistry.stream().filter(hasAnyOfTags(tag1).and(hasAnyOfTags(tag2)))
|
assertEquals(1, ruleRegistry.stream().filter(hasAnyOfTags(tag3)).toList().size(), "RuleImpl list size");
|
||||||
.collect(Collectors.toList()).size(), "RuleImpl list size");
|
|
||||||
|
|
||||||
assertEquals(1, ruleRegistry.stream().filter(hasAnyOfTags(tag1).and(hasAnyOfTags(tag3)))
|
assertEquals(3, ruleRegistry.stream().filter(hasAllTags(tag1)).toList().size(), "RuleImpl list size");
|
||||||
.collect(Collectors.toList()).size(), "RuleImpl list size");
|
|
||||||
assertEquals(1, ruleRegistry.stream().filter(hasAnyOfTags(tag2).and(hasAnyOfTags(tag3)))
|
|
||||||
.collect(Collectors.toList()).size(), "RuleImpl list size");
|
|
||||||
|
|
||||||
assertEquals(1, ruleRegistry.stream().filter(hasAnyOfTags(tag3)).collect(Collectors.toList()).size(),
|
assertEquals(2, ruleRegistry.stream().filter(hasAllTags(tag2)).toList().size(), "RuleImpl list size");
|
||||||
"RuleImpl list size");
|
assertEquals(2, ruleRegistry.stream().filter(hasAllTags(tag1, tag2)).toList().size(), "RuleImpl list size");
|
||||||
|
|
||||||
assertEquals(3, ruleRegistry.stream().filter(hasAllTags(tag1)).collect(Collectors.toList()).size(),
|
assertEquals(1, ruleRegistry.stream().filter(hasAllTags(tags)).toList().size(), "RuleImpl list size");
|
||||||
"RuleImpl list size");
|
assertEquals(1, ruleRegistry.stream().filter(hasAllTags(tag1, tag2, tag3)).toList().size(),
|
||||||
|
|
||||||
assertEquals(2, ruleRegistry.stream().filter(hasAllTags(tag2)).collect(Collectors.toList()).size(),
|
|
||||||
"RuleImpl list size");
|
|
||||||
assertEquals(2, ruleRegistry.stream().filter(hasAllTags(tag1, tag2)).collect(Collectors.toList()).size(),
|
|
||||||
"RuleImpl list size");
|
|
||||||
|
|
||||||
assertEquals(1, ruleRegistry.stream().filter(hasAllTags(tags)).collect(Collectors.toList()).size(),
|
|
||||||
"RuleImpl list size");
|
|
||||||
assertEquals(1, ruleRegistry.stream().filter(hasAllTags(tag1, tag2, tag3)).collect(Collectors.toList()).size(),
|
|
||||||
"RuleImpl list size");
|
"RuleImpl list size");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -808,7 +808,7 @@ public class InboxOSGiTest extends JavaOSGiTest {
|
|||||||
.anyMatch(forThingUID(THING1_WITH_BRIDGE.getThingUID()).and(withFlag(DiscoveryResultFlag.NEW))));
|
.anyMatch(forThingUID(THING1_WITH_BRIDGE.getThingUID()).and(withFlag(DiscoveryResultFlag.NEW))));
|
||||||
assertFalse(inbox.stream()
|
assertFalse(inbox.stream()
|
||||||
.anyMatch(forThingUID(THING2_WITH_BRIDGE.getThingUID()).and(withFlag(DiscoveryResultFlag.NEW))));
|
.anyMatch(forThingUID(THING2_WITH_BRIDGE.getThingUID()).and(withFlag(DiscoveryResultFlag.NEW))));
|
||||||
assertThat(inbox.stream().filter(withFlag(DiscoveryResultFlag.NEW)).collect(Collectors.toList()),
|
assertThat(inbox.stream().filter(withFlag(DiscoveryResultFlag.NEW)).toList(),
|
||||||
hasItems(THING_WITHOUT_BRIDGE, THING_WITH_OTHER_BRIDGE));
|
hasItems(THING_WITHOUT_BRIDGE, THING_WITH_OTHER_BRIDGE));
|
||||||
waitForAssert(() -> {
|
waitForAssert(() -> {
|
||||||
assertThat(receivedEvents.size(), is(3));
|
assertThat(receivedEvents.size(), is(3));
|
||||||
@ -845,7 +845,7 @@ public class InboxOSGiTest extends JavaOSGiTest {
|
|||||||
|
|
||||||
registry.add(BridgeBuilder.create(BRIDGE_THING_TYPE_UID, BRIDGE_THING_UID).build());
|
registry.add(BridgeBuilder.create(BRIDGE_THING_TYPE_UID, BRIDGE_THING_UID).build());
|
||||||
assertFalse(inbox.stream().anyMatch(forThingUID(BRIDGE.getThingUID()).and(withFlag(DiscoveryResultFlag.NEW))));
|
assertFalse(inbox.stream().anyMatch(forThingUID(BRIDGE.getThingUID()).and(withFlag(DiscoveryResultFlag.NEW))));
|
||||||
assertThat(inbox.stream().filter(withFlag(DiscoveryResultFlag.NEW)).collect(Collectors.toList()),
|
assertThat(inbox.stream().filter(withFlag(DiscoveryResultFlag.NEW)).toList(),
|
||||||
hasItems(THING1_WITH_BRIDGE, THING2_WITH_BRIDGE, THING_WITHOUT_BRIDGE));
|
hasItems(THING1_WITH_BRIDGE, THING2_WITH_BRIDGE, THING_WITHOUT_BRIDGE));
|
||||||
waitForAssert(() -> {
|
waitForAssert(() -> {
|
||||||
assertThat(receivedEvents.size(), is(1));
|
assertThat(receivedEvents.size(), is(1));
|
||||||
@ -879,7 +879,7 @@ public class InboxOSGiTest extends JavaOSGiTest {
|
|||||||
inbox.add(THING2_WITH_BRIDGE);
|
inbox.add(THING2_WITH_BRIDGE);
|
||||||
inbox.add(THING_WITHOUT_BRIDGE);
|
inbox.add(THING_WITHOUT_BRIDGE);
|
||||||
inbox.add(THING_WITH_OTHER_BRIDGE);
|
inbox.add(THING_WITH_OTHER_BRIDGE);
|
||||||
assertThat(inbox.stream().filter(withFlag(DiscoveryResultFlag.NEW)).collect(Collectors.toList()),
|
assertThat(inbox.stream().filter(withFlag(DiscoveryResultFlag.NEW)).toList(),
|
||||||
hasItems(THING1_WITH_BRIDGE, THING2_WITH_BRIDGE, THING_WITHOUT_BRIDGE, THING_WITH_OTHER_BRIDGE));
|
hasItems(THING1_WITH_BRIDGE, THING2_WITH_BRIDGE, THING_WITHOUT_BRIDGE, THING_WITH_OTHER_BRIDGE));
|
||||||
|
|
||||||
registry.forceRemove(BRIDGE.getThingUID());
|
registry.forceRemove(BRIDGE.getThingUID());
|
||||||
@ -889,7 +889,7 @@ public class InboxOSGiTest extends JavaOSGiTest {
|
|||||||
.anyMatch(forThingUID(THING1_WITH_BRIDGE.getThingUID()).and(withFlag(DiscoveryResultFlag.NEW))));
|
.anyMatch(forThingUID(THING1_WITH_BRIDGE.getThingUID()).and(withFlag(DiscoveryResultFlag.NEW))));
|
||||||
assertFalse(inbox.stream()
|
assertFalse(inbox.stream()
|
||||||
.anyMatch(forThingUID(THING2_WITH_BRIDGE.getThingUID()).and(withFlag(DiscoveryResultFlag.NEW))));
|
.anyMatch(forThingUID(THING2_WITH_BRIDGE.getThingUID()).and(withFlag(DiscoveryResultFlag.NEW))));
|
||||||
assertThat(inbox.stream().filter(withFlag(DiscoveryResultFlag.NEW)).collect(Collectors.toList()),
|
assertThat(inbox.stream().filter(withFlag(DiscoveryResultFlag.NEW)).toList(),
|
||||||
hasItems(THING_WITHOUT_BRIDGE, THING_WITH_OTHER_BRIDGE));
|
hasItems(THING_WITHOUT_BRIDGE, THING_WITH_OTHER_BRIDGE));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,6 @@ import static org.mockito.Mockito.when;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
@ -113,14 +112,14 @@ public class ProfileTypeResourceTest extends JavaTest {
|
|||||||
public void testGetAll() {
|
public void testGetAll() {
|
||||||
Stream<ProfileTypeDTO> result = resource.getProfileTypes(null, null, null);
|
Stream<ProfileTypeDTO> result = resource.getProfileTypes(null, null, null);
|
||||||
|
|
||||||
List<ProfileTypeDTO> list = result.collect(Collectors.toList());
|
List<ProfileTypeDTO> list = result.toList();
|
||||||
assertThat(list.size(), is(4));
|
assertThat(list.size(), is(4));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetProfileTypesForStateChannel1() {
|
public void testGetProfileTypesForStateChannel1() {
|
||||||
Stream<ProfileTypeDTO> result = resource.getProfileTypes(null, pt1ChannelType1UID.toString(), null);
|
Stream<ProfileTypeDTO> result = resource.getProfileTypes(null, pt1ChannelType1UID.toString(), null);
|
||||||
List<ProfileTypeDTO> list = result.collect(Collectors.toList());
|
List<ProfileTypeDTO> list = result.toList();
|
||||||
|
|
||||||
// should be both state profiles because the second state profile supports ALL item types on the channel side
|
// should be both state profiles because the second state profile supports ALL item types on the channel side
|
||||||
assertThat(list.size(), is(2));
|
assertThat(list.size(), is(2));
|
||||||
@ -133,7 +132,7 @@ public class ProfileTypeResourceTest extends JavaTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testGetProfileTypesForOtherChannel() {
|
public void testGetProfileTypesForOtherChannel() {
|
||||||
Stream<ProfileTypeDTO> result = resource.getProfileTypes(null, otherStateChannelTypeUID.toString(), null);
|
Stream<ProfileTypeDTO> result = resource.getProfileTypes(null, otherStateChannelTypeUID.toString(), null);
|
||||||
List<ProfileTypeDTO> list = result.collect(Collectors.toList());
|
List<ProfileTypeDTO> list = result.toList();
|
||||||
|
|
||||||
// should be only the second state profile because the first one is restricted to another item type on the
|
// should be only the second state profile because the first one is restricted to another item type on the
|
||||||
// channel side
|
// channel side
|
||||||
@ -148,7 +147,7 @@ public class ProfileTypeResourceTest extends JavaTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testGetProfileTypesForTriggerChannel1() {
|
public void testGetProfileTypesForTriggerChannel1() {
|
||||||
Stream<ProfileTypeDTO> result = resource.getProfileTypes(null, pt3ChannelType1UID.toString(), null);
|
Stream<ProfileTypeDTO> result = resource.getProfileTypes(null, pt3ChannelType1UID.toString(), null);
|
||||||
List<ProfileTypeDTO> list = result.collect(Collectors.toList());
|
List<ProfileTypeDTO> list = result.toList();
|
||||||
|
|
||||||
// should be both trigger profiles because the second trigger profile supports ALL channel types
|
// should be both trigger profiles because the second trigger profile supports ALL channel types
|
||||||
assertThat(list.size(), is(2));
|
assertThat(list.size(), is(2));
|
||||||
@ -161,7 +160,7 @@ public class ProfileTypeResourceTest extends JavaTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testGetProfileTypesForTriggerChannel2() {
|
public void testGetProfileTypesForTriggerChannel2() {
|
||||||
Stream<ProfileTypeDTO> result = resource.getProfileTypes(null, otherTriggerChannelTypeUID.toString(), null);
|
Stream<ProfileTypeDTO> result = resource.getProfileTypes(null, otherTriggerChannelTypeUID.toString(), null);
|
||||||
List<ProfileTypeDTO> list = result.collect(Collectors.toList());
|
List<ProfileTypeDTO> list = result.toList();
|
||||||
|
|
||||||
// should be only the second trigger profile because the first one is restricted to another channel type UID
|
// should be only the second trigger profile because the first one is restricted to another channel type UID
|
||||||
assertThat(list.size(), is(1));
|
assertThat(list.size(), is(1));
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.openhab.core.model.thing.test.hue;
|
package org.openhab.core.model.thing.test.hue;
|
||||||
|
|
||||||
import static java.util.stream.Collectors.toList;
|
|
||||||
import static org.hamcrest.CoreMatchers.*;
|
import static org.hamcrest.CoreMatchers.*;
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
@ -97,7 +96,7 @@ public class GenericThingProviderTest3 extends JavaOSGiTest {
|
|||||||
.withRequired(false).withDefault("hello world").build(),
|
.withRequired(false).withDefault("hello world").build(),
|
||||||
ConfigDescriptionParameterBuilder.create("testConf", ConfigDescriptionParameter.Type.TEXT)
|
ConfigDescriptionParameterBuilder.create("testConf", ConfigDescriptionParameter.Type.TEXT)
|
||||||
.withRequired(false).withDefault("bar").build())
|
.withRequired(false).withDefault("bar").build())
|
||||||
.collect(toList()))
|
.toList())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
ConfigDescriptionProvider configDescriptionProvider = mock(ConfigDescriptionProvider.class);
|
ConfigDescriptionProvider configDescriptionProvider = mock(ConfigDescriptionProvider.class);
|
||||||
|
@ -23,7 +23,6 @@ import java.util.HashSet;
|
|||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import javax.measure.Quantity;
|
import javax.measure.Quantity;
|
||||||
import javax.measure.quantity.Dimensionless;
|
import javax.measure.quantity.Dimensionless;
|
||||||
@ -137,8 +136,7 @@ public class GroupItemOSGiTest extends JavaOSGiTest {
|
|||||||
itemRegistry.update(updatedItem);
|
itemRegistry.update(updatedItem);
|
||||||
waitForAssert(() -> assertThat(events.size(), is(1)));
|
waitForAssert(() -> assertThat(events.size(), is(1)));
|
||||||
|
|
||||||
List<Event> stateChanges = events.stream().filter(ItemUpdatedEvent.class::isInstance)
|
List<Event> stateChanges = events.stream().filter(ItemUpdatedEvent.class::isInstance).toList();
|
||||||
.collect(Collectors.toList());
|
|
||||||
assertThat(stateChanges.size(), is(1));
|
assertThat(stateChanges.size(), is(1));
|
||||||
|
|
||||||
ItemUpdatedEvent change = (ItemUpdatedEvent) stateChanges.get(0);
|
ItemUpdatedEvent change = (ItemUpdatedEvent) stateChanges.get(0);
|
||||||
@ -442,8 +440,7 @@ public class GroupItemOSGiTest extends JavaOSGiTest {
|
|||||||
|
|
||||||
waitForAssert(() -> assertThat(events.size(), is(2)));
|
waitForAssert(() -> assertThat(events.size(), is(2)));
|
||||||
|
|
||||||
List<Event> updates = events.stream().filter(GroupStateUpdatedEvent.class::isInstance)
|
List<Event> updates = events.stream().filter(GroupStateUpdatedEvent.class::isInstance).toList();
|
||||||
.collect(Collectors.toList());
|
|
||||||
assertThat(updates.size(), is(1));
|
assertThat(updates.size(), is(1));
|
||||||
|
|
||||||
GroupStateUpdatedEvent update = (GroupStateUpdatedEvent) updates.get(0);
|
GroupStateUpdatedEvent update = (GroupStateUpdatedEvent) updates.get(0);
|
||||||
@ -453,8 +450,7 @@ public class GroupItemOSGiTest extends JavaOSGiTest {
|
|||||||
.replace("{itemName}", groupItem.getName())));
|
.replace("{itemName}", groupItem.getName())));
|
||||||
assertThat(update.getItemState(), is(groupItem.getState()));
|
assertThat(update.getItemState(), is(groupItem.getState()));
|
||||||
|
|
||||||
List<Event> changes = events.stream().filter(GroupItemStateChangedEvent.class::isInstance)
|
List<Event> changes = events.stream().filter(GroupItemStateChangedEvent.class::isInstance).toList();
|
||||||
.collect(Collectors.toList());
|
|
||||||
assertThat(changes.size(), is(1));
|
assertThat(changes.size(), is(1));
|
||||||
|
|
||||||
GroupItemStateChangedEvent change = (GroupItemStateChangedEvent) changes.get(0);
|
GroupItemStateChangedEvent change = (GroupItemStateChangedEvent) changes.get(0);
|
||||||
@ -493,7 +489,7 @@ public class GroupItemOSGiTest extends JavaOSGiTest {
|
|||||||
waitForAssert(() -> assertThat(events, hasSize(2)));
|
waitForAssert(() -> assertThat(events, hasSize(2)));
|
||||||
|
|
||||||
List<Event> groupItemStateChangedEvents = events.stream().filter(GroupItemStateChangedEvent.class::isInstance)
|
List<Event> groupItemStateChangedEvents = events.stream().filter(GroupItemStateChangedEvent.class::isInstance)
|
||||||
.collect(Collectors.toList());
|
.toList();
|
||||||
assertThat(groupItemStateChangedEvents, hasSize(1));
|
assertThat(groupItemStateChangedEvents, hasSize(1));
|
||||||
|
|
||||||
GroupItemStateChangedEvent change = (GroupItemStateChangedEvent) groupItemStateChangedEvents.get(0);
|
GroupItemStateChangedEvent change = (GroupItemStateChangedEvent) groupItemStateChangedEvents.get(0);
|
||||||
@ -535,12 +531,11 @@ public class GroupItemOSGiTest extends JavaOSGiTest {
|
|||||||
|
|
||||||
waitForAssert(() -> assertThat(events, hasSize(2)));
|
waitForAssert(() -> assertThat(events, hasSize(2)));
|
||||||
|
|
||||||
List<Event> itemCommandEvents = events.stream().filter(ItemCommandEvent.class::isInstance)
|
List<Event> itemCommandEvents = events.stream().filter(ItemCommandEvent.class::isInstance).toList();
|
||||||
.collect(Collectors.toList());
|
|
||||||
assertThat(itemCommandEvents, hasSize(2));
|
assertThat(itemCommandEvents, hasSize(2));
|
||||||
|
|
||||||
List<Event> groupItemStateChangedEvents = events.stream().filter(GroupItemStateChangedEvent.class::isInstance)
|
List<Event> groupItemStateChangedEvents = events.stream().filter(GroupItemStateChangedEvent.class::isInstance)
|
||||||
.collect(Collectors.toList());
|
.toList();
|
||||||
assertThat(groupItemStateChangedEvents, hasSize(0));
|
assertThat(groupItemStateChangedEvents, hasSize(0));
|
||||||
|
|
||||||
assertThat(groupItem.getState(), is(UnDefType.NULL));
|
assertThat(groupItem.getState(), is(UnDefType.NULL));
|
||||||
@ -565,12 +560,10 @@ public class GroupItemOSGiTest extends JavaOSGiTest {
|
|||||||
|
|
||||||
waitForAssert(() -> assertThat(events, hasSize(2)));
|
waitForAssert(() -> assertThat(events, hasSize(2)));
|
||||||
|
|
||||||
List<Event> changes = events.stream().filter(GroupItemStateChangedEvent.class::isInstance)
|
List<Event> changes = events.stream().filter(GroupItemStateChangedEvent.class::isInstance).toList();
|
||||||
.collect(Collectors.toList());
|
|
||||||
assertThat(changes, hasSize(1));
|
assertThat(changes, hasSize(1));
|
||||||
|
|
||||||
List<Event> updates = events.stream().filter(GroupStateUpdatedEvent.class::isInstance)
|
List<Event> updates = events.stream().filter(GroupStateUpdatedEvent.class::isInstance).toList();
|
||||||
.collect(Collectors.toList());
|
|
||||||
assertThat(updates, hasSize(1));
|
assertThat(updates, hasSize(1));
|
||||||
|
|
||||||
GroupItemStateChangedEvent change = (GroupItemStateChangedEvent) changes.get(0);
|
GroupItemStateChangedEvent change = (GroupItemStateChangedEvent) changes.get(0);
|
||||||
@ -594,10 +587,10 @@ public class GroupItemOSGiTest extends JavaOSGiTest {
|
|||||||
|
|
||||||
assertThat(events, hasSize(2));
|
assertThat(events, hasSize(2));
|
||||||
|
|
||||||
changes = events.stream().filter(GroupItemStateChangedEvent.class::isInstance).collect(Collectors.toList());
|
changes = events.stream().filter(GroupItemStateChangedEvent.class::isInstance).toList();
|
||||||
assertThat(changes, hasSize(0));
|
assertThat(changes, hasSize(0));
|
||||||
|
|
||||||
updates = events.stream().filter(GroupStateUpdatedEvent.class::isInstance).collect(Collectors.toList());
|
updates = events.stream().filter(GroupStateUpdatedEvent.class::isInstance).toList();
|
||||||
assertThat(updates, hasSize(2));
|
assertThat(updates, hasSize(2));
|
||||||
|
|
||||||
assertThat(groupItem.getState(), is(OnOffType.ON));
|
assertThat(groupItem.getState(), is(OnOffType.ON));
|
||||||
@ -622,8 +615,7 @@ public class GroupItemOSGiTest extends JavaOSGiTest {
|
|||||||
|
|
||||||
waitForAssert(() -> assertThat(events, hasSize(2)));
|
waitForAssert(() -> assertThat(events, hasSize(2)));
|
||||||
|
|
||||||
List<Event> changes = events.stream().filter(GroupItemStateChangedEvent.class::isInstance)
|
List<Event> changes = events.stream().filter(GroupItemStateChangedEvent.class::isInstance).toList();
|
||||||
.collect(Collectors.toList());
|
|
||||||
assertThat(changes, hasSize(1));
|
assertThat(changes, hasSize(1));
|
||||||
|
|
||||||
GroupItemStateChangedEvent change = (GroupItemStateChangedEvent) changes.get(0);
|
GroupItemStateChangedEvent change = (GroupItemStateChangedEvent) changes.get(0);
|
||||||
@ -642,7 +634,7 @@ public class GroupItemOSGiTest extends JavaOSGiTest {
|
|||||||
|
|
||||||
waitForAssert(() -> assertThat(events, hasSize(2)));
|
waitForAssert(() -> assertThat(events, hasSize(2)));
|
||||||
|
|
||||||
changes = events.stream().filter(GroupItemStateChangedEvent.class::isInstance).collect(Collectors.toList());
|
changes = events.stream().filter(GroupItemStateChangedEvent.class::isInstance).toList();
|
||||||
assertThat(changes, hasSize(1));
|
assertThat(changes, hasSize(1));
|
||||||
|
|
||||||
change = (GroupItemStateChangedEvent) changes.get(0);
|
change = (GroupItemStateChangedEvent) changes.get(0);
|
||||||
@ -756,8 +748,7 @@ public class GroupItemOSGiTest extends JavaOSGiTest {
|
|||||||
|
|
||||||
waitForAssert(() -> assertThat(events.size(), is(2)));
|
waitForAssert(() -> assertThat(events.size(), is(2)));
|
||||||
|
|
||||||
List<Event> changes = events.stream().filter(GroupItemStateChangedEvent.class::isInstance)
|
List<Event> changes = events.stream().filter(GroupItemStateChangedEvent.class::isInstance).toList();
|
||||||
.collect(Collectors.toList());
|
|
||||||
GroupItemStateChangedEvent change = (GroupItemStateChangedEvent) changes.get(0);
|
GroupItemStateChangedEvent change = (GroupItemStateChangedEvent) changes.get(0);
|
||||||
assertThat(change.getItemName(), is(groupItem.getName()));
|
assertThat(change.getItemName(), is(groupItem.getName()));
|
||||||
|
|
||||||
@ -775,7 +766,7 @@ public class GroupItemOSGiTest extends JavaOSGiTest {
|
|||||||
|
|
||||||
waitForAssert(() -> assertThat(events.size(), is(2)));
|
waitForAssert(() -> assertThat(events.size(), is(2)));
|
||||||
|
|
||||||
changes = events.stream().filter(GroupItemStateChangedEvent.class::isInstance).collect(Collectors.toList());
|
changes = events.stream().filter(GroupItemStateChangedEvent.class::isInstance).toList();
|
||||||
assertThat(changes.size(), is(1));
|
assertThat(changes.size(), is(1));
|
||||||
|
|
||||||
change = (GroupItemStateChangedEvent) changes.get(0);
|
change = (GroupItemStateChangedEvent) changes.get(0);
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.openhab.core.items;
|
package org.openhab.core.items;
|
||||||
|
|
||||||
import static java.util.stream.Collectors.toList;
|
|
||||||
import static org.hamcrest.CoreMatchers.*;
|
import static org.hamcrest.CoreMatchers.*;
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
import static org.hamcrest.collection.IsCollectionWithSize.hasSize;
|
import static org.hamcrest.collection.IsCollectionWithSize.hasSize;
|
||||||
@ -132,7 +131,7 @@ public class ItemRegistryImplTest extends JavaTest {
|
|||||||
List<Item> items = new ArrayList<>(itemRegistry.getItemsByTag(CAMERA_TAG));
|
List<Item> items = new ArrayList<>(itemRegistry.getItemsByTag(CAMERA_TAG));
|
||||||
assertThat(items, hasSize(4));
|
assertThat(items, hasSize(4));
|
||||||
|
|
||||||
List<String> itemNames = items.stream().map(Item::getName).collect(toList());
|
List<String> itemNames = items.stream().map(Item::getName).toList();
|
||||||
assertThat(itemNames, hasItem(CAMERA_ITEM_NAME1));
|
assertThat(itemNames, hasItem(CAMERA_ITEM_NAME1));
|
||||||
assertThat(itemNames, hasItem(CAMERA_ITEM_NAME2));
|
assertThat(itemNames, hasItem(CAMERA_ITEM_NAME2));
|
||||||
assertThat(itemNames, hasItem(CAMERA_ITEM_NAME3));
|
assertThat(itemNames, hasItem(CAMERA_ITEM_NAME3));
|
||||||
@ -144,7 +143,7 @@ public class ItemRegistryImplTest extends JavaTest {
|
|||||||
List<Item> items = new ArrayList<>(itemRegistry.getItemsByTag(CAMERA_TAG_UPPERCASE));
|
List<Item> items = new ArrayList<>(itemRegistry.getItemsByTag(CAMERA_TAG_UPPERCASE));
|
||||||
assertThat(items, hasSize(4));
|
assertThat(items, hasSize(4));
|
||||||
|
|
||||||
List<String> itemNames = items.stream().map(Item::getName).collect(toList());
|
List<String> itemNames = items.stream().map(Item::getName).toList();
|
||||||
assertThat(itemNames, hasItem(CAMERA_ITEM_NAME1));
|
assertThat(itemNames, hasItem(CAMERA_ITEM_NAME1));
|
||||||
assertThat(itemNames, hasItem(CAMERA_ITEM_NAME2));
|
assertThat(itemNames, hasItem(CAMERA_ITEM_NAME2));
|
||||||
assertThat(itemNames, hasItem(CAMERA_ITEM_NAME3));
|
assertThat(itemNames, hasItem(CAMERA_ITEM_NAME3));
|
||||||
@ -156,7 +155,7 @@ public class ItemRegistryImplTest extends JavaTest {
|
|||||||
List<Item> items = new ArrayList<>(itemRegistry.getItemsByTagAndType("Switch", CAMERA_TAG));
|
List<Item> items = new ArrayList<>(itemRegistry.getItemsByTagAndType("Switch", CAMERA_TAG));
|
||||||
assertThat(items, hasSize(2));
|
assertThat(items, hasSize(2));
|
||||||
|
|
||||||
List<String> itemNames = items.stream().map(Item::getName).collect(toList());
|
List<String> itemNames = items.stream().map(Item::getName).toList();
|
||||||
assertThat(itemNames, hasItem(CAMERA_ITEM_NAME1));
|
assertThat(itemNames, hasItem(CAMERA_ITEM_NAME1));
|
||||||
assertThat(itemNames, hasItem(CAMERA_ITEM_NAME2));
|
assertThat(itemNames, hasItem(CAMERA_ITEM_NAME2));
|
||||||
}
|
}
|
||||||
@ -178,7 +177,7 @@ public class ItemRegistryImplTest extends JavaTest {
|
|||||||
List<SwitchItem> items = new ArrayList<>(itemRegistry.getItemsByTag(SwitchItem.class, CAMERA_TAG));
|
List<SwitchItem> items = new ArrayList<>(itemRegistry.getItemsByTag(SwitchItem.class, CAMERA_TAG));
|
||||||
assertThat(items, hasSize(2));
|
assertThat(items, hasSize(2));
|
||||||
|
|
||||||
List<String> itemNames = items.stream().map(GenericItem::getName).collect(toList());
|
List<String> itemNames = items.stream().map(GenericItem::getName).toList();
|
||||||
assertThat(itemNames, hasItem(CAMERA_ITEM_NAME1));
|
assertThat(itemNames, hasItem(CAMERA_ITEM_NAME1));
|
||||||
assertThat(itemNames, hasItem(CAMERA_ITEM_NAME2));
|
assertThat(itemNames, hasItem(CAMERA_ITEM_NAME2));
|
||||||
}
|
}
|
||||||
|
@ -126,7 +126,7 @@ public class ThingFactoryTest extends JavaOSGiTest {
|
|||||||
ChannelDefinition cd1 = new ChannelDefinitionBuilder("channel1", channelType1.getUID()).build();
|
ChannelDefinition cd1 = new ChannelDefinitionBuilder("channel1", channelType1.getUID()).build();
|
||||||
ChannelDefinition cd2 = new ChannelDefinitionBuilder("channel2", channelType2.getUID()).build();
|
ChannelDefinition cd2 = new ChannelDefinitionBuilder("channel2", channelType2.getUID()).build();
|
||||||
|
|
||||||
return Stream.of(cd1, cd2).collect(toList());
|
return Stream.of(cd1, cd2).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -204,7 +204,7 @@ public class ThingFactoryTest extends JavaOSGiTest {
|
|||||||
.withMultiple(true).withLimitToOptions(true).build();
|
.withMultiple(true).withLimitToOptions(true).build();
|
||||||
|
|
||||||
return ConfigDescriptionBuilder.create(uri)
|
return ConfigDescriptionBuilder.create(uri)
|
||||||
.withParameters(Stream.of(p1, p2, p3, p4, p5, p6).collect(toList())).build();
|
.withParameters(Stream.of(p1, p2, p3, p4, p5, p6).toList()).build();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -284,7 +284,7 @@ public class ChannelLinkNotifierOSGiTest extends JavaOSGiTest {
|
|||||||
private Thing createThing() {
|
private Thing createThing() {
|
||||||
ThingUID thingUID = new ThingUID(THING_TYPE_UID, "thing" + thingCount++);
|
ThingUID thingUID = new ThingUID(THING_TYPE_UID, "thing" + thingCount++);
|
||||||
List<Channel> channels = IntStream.range(0, CHANNEL_COUNT).mapToObj(index -> createChannel(thingUID, index))
|
List<Channel> channels = IntStream.range(0, CHANNEL_COUNT).mapToObj(index -> createChannel(thingUID, index))
|
||||||
.collect(Collectors.toList());
|
.toList();
|
||||||
return ThingBuilder.create(THING_TYPE_UID, thingUID).withChannels(channels).build();
|
return ThingBuilder.create(THING_TYPE_UID, thingUID).withChannels(channels).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,7 +18,6 @@ import static org.mockito.Mockito.*;
|
|||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import javax.measure.quantity.Temperature;
|
import javax.measure.quantity.Temperature;
|
||||||
@ -196,8 +195,8 @@ public class CommunicationManagerOSGiTest extends JavaOSGiTest {
|
|||||||
}).when(profileFactoryMock).createProfile(isA(ProfileTypeUID.class), isA(ProfileCallback.class),
|
}).when(profileFactoryMock).createProfile(isA(ProfileTypeUID.class), isA(ProfileCallback.class),
|
||||||
isA(ProfileContext.class));
|
isA(ProfileContext.class));
|
||||||
|
|
||||||
when(profileFactoryMock.getSupportedProfileTypeUIDs()).thenReturn(Stream
|
when(profileFactoryMock.getSupportedProfileTypeUIDs())
|
||||||
.of(new ProfileTypeUID("test:state"), new ProfileTypeUID("test:trigger")).collect(Collectors.toList()));
|
.thenReturn(Stream.of(new ProfileTypeUID("test:state"), new ProfileTypeUID("test:trigger")).toList());
|
||||||
|
|
||||||
manager.addProfileFactory(profileFactoryMock);
|
manager.addProfileFactory(profileFactoryMock);
|
||||||
manager.addProfileAdvisor(profileAdvisorMock);
|
manager.addProfileAdvisor(profileAdvisorMock);
|
||||||
|
@ -702,8 +702,7 @@ public class FirmwareUpdateServiceTest extends JavaOSGiTest {
|
|||||||
verify(eventPublisherMock, atLeast(SEQUENCE.length + 1)).post(eventCaptor.capture());
|
verify(eventPublisherMock, atLeast(SEQUENCE.length + 1)).post(eventCaptor.capture());
|
||||||
});
|
});
|
||||||
events.get().addAll(eventCaptor.getAllValues());
|
events.get().addAll(eventCaptor.getAllValues());
|
||||||
List<Event> list = events.get().stream().filter(FirmwareUpdateProgressInfoEvent.class::isInstance)
|
List<Event> list = events.get().stream().filter(FirmwareUpdateProgressInfoEvent.class::isInstance).toList();
|
||||||
.collect(Collectors.toList());
|
|
||||||
assertTrue(list.size() >= SEQUENCE.length);
|
assertTrue(list.size() >= SEQUENCE.length);
|
||||||
for (int i = 0; i < SEQUENCE.length; i++) {
|
for (int i = 0; i < SEQUENCE.length; i++) {
|
||||||
FirmwareUpdateProgressInfoEvent event = (FirmwareUpdateProgressInfoEvent) list.get(i);
|
FirmwareUpdateProgressInfoEvent event = (FirmwareUpdateProgressInfoEvent) list.get(i);
|
||||||
@ -903,7 +902,7 @@ public class FirmwareUpdateServiceTest extends JavaOSGiTest {
|
|||||||
ArgumentCaptor<Event> eventCaptor = ArgumentCaptor.forClass(Event.class);
|
ArgumentCaptor<Event> eventCaptor = ArgumentCaptor.forClass(Event.class);
|
||||||
verify(eventPublisherMock, atLeast(expectedEventCount)).post(eventCaptor.capture());
|
verify(eventPublisherMock, atLeast(expectedEventCount)).post(eventCaptor.capture());
|
||||||
List<Event> allValues = eventCaptor.getAllValues().stream()
|
List<Event> allValues = eventCaptor.getAllValues().stream()
|
||||||
.filter(FirmwareUpdateResultInfoEvent.class::isInstance).collect(Collectors.toList());
|
.filter(FirmwareUpdateResultInfoEvent.class::isInstance).toList();
|
||||||
assertEquals(expectedEventCount, allValues.size());
|
assertEquals(expectedEventCount, allValues.size());
|
||||||
assertFailedFirmwareUpdate(THING1_UID, allValues.get(expectedEventCount - 1), text);
|
assertFailedFirmwareUpdate(THING1_UID, allValues.get(expectedEventCount - 1), text);
|
||||||
});
|
});
|
||||||
|
@ -21,7 +21,6 @@ import java.util.ArrayList;
|
|||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.junit.jupiter.api.AfterEach;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
@ -154,7 +153,7 @@ public class ItemChannelLinkOSGiTest extends JavaOSGiTest {
|
|||||||
int removed = itemChannelLinkRegistry.removeLinksForItem(itemToRemove);
|
int removed = itemChannelLinkRegistry.removeLinksForItem(itemToRemove);
|
||||||
assertThat(removed, is(1));
|
assertThat(removed, is(1));
|
||||||
|
|
||||||
assertThat(itemChannelLinkRegistry.stream().map(ItemChannelLink::getItemName).collect(Collectors.toList()),
|
assertThat(itemChannelLinkRegistry.stream().map(ItemChannelLink::getItemName).toList(),
|
||||||
not(hasItem(itemToRemove)));
|
not(hasItem(itemToRemove)));
|
||||||
assertThat(itemChannelLinkRegistry.getAll(),
|
assertThat(itemChannelLinkRegistry.getAll(),
|
||||||
hasSize(BULK_ITEM_COUNT * BULK_THING_COUNT * BULK_CHANNEL_COUNT - 1));
|
hasSize(BULK_ITEM_COUNT * BULK_THING_COUNT * BULK_CHANNEL_COUNT - 1));
|
||||||
@ -169,7 +168,7 @@ public class ItemChannelLinkOSGiTest extends JavaOSGiTest {
|
|||||||
assertThat(removed, is(BULK_CHANNEL_COUNT));
|
assertThat(removed, is(BULK_CHANNEL_COUNT));
|
||||||
|
|
||||||
assertThat(itemChannelLinkRegistry.stream().map(ItemChannelLink::getLinkedUID).map(ChannelUID::getThingUID)
|
assertThat(itemChannelLinkRegistry.stream().map(ItemChannelLink::getLinkedUID).map(ChannelUID::getThingUID)
|
||||||
.collect(Collectors.toList()), not(hasItem(thingToRemove)));
|
.toList(), not(hasItem(thingToRemove)));
|
||||||
assertThat(itemChannelLinkRegistry.getAll(),
|
assertThat(itemChannelLinkRegistry.getAll(),
|
||||||
hasSize((BULK_ITEM_COUNT * BULK_THING_COUNT - 1) * BULK_CHANNEL_COUNT));
|
hasSize((BULK_ITEM_COUNT * BULK_THING_COUNT - 1) * BULK_CHANNEL_COUNT));
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,6 @@ import static org.hamcrest.CoreMatchers.*;
|
|||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
@ -68,7 +67,7 @@ public class SystemChannelsInChannelGroupsTest extends JavaOSGiTest {
|
|||||||
public void thingTypesWithSystemChannelsInChannelsGoupsShouldHavePorperChannelDefinitions() throws Exception {
|
public void thingTypesWithSystemChannelsInChannelsGoupsShouldHavePorperChannelDefinitions() throws Exception {
|
||||||
try (final AutoCloseable unused = loadedTestBundle()) {
|
try (final AutoCloseable unused = loadedTestBundle()) {
|
||||||
List<ThingType> thingTypes = thingTypeProvider.getThingTypes(null).stream()
|
List<ThingType> thingTypes = thingTypeProvider.getThingTypes(null).stream()
|
||||||
.filter(it -> "wireless-router".equals(it.getUID().getId())).collect(Collectors.toList());
|
.filter(it -> "wireless-router".equals(it.getUID().getId())).toList();
|
||||||
assertThat(thingTypes.size(), is(1));
|
assertThat(thingTypes.size(), is(1));
|
||||||
|
|
||||||
List<ChannelGroupType> channelGroupTypes = channelGroupTypeRegistry.getChannelGroupTypes();
|
List<ChannelGroupType> channelGroupTypes = channelGroupTypeRegistry.getChannelGroupTypes();
|
||||||
@ -82,17 +81,13 @@ public class SystemChannelsInChannelGroupsTest extends JavaOSGiTest {
|
|||||||
|
|
||||||
List<ChannelDefinition> myChannel = channelDefs.stream().filter(
|
List<ChannelDefinition> myChannel = channelDefs.stream().filter(
|
||||||
it -> "test".equals(it.getId()) && "system:my-channel".equals(it.getChannelTypeUID().getAsString()))
|
it -> "test".equals(it.getId()) && "system:my-channel".equals(it.getChannelTypeUID().getAsString()))
|
||||||
.collect(Collectors.toList());
|
.toList();
|
||||||
|
|
||||||
List<ChannelDefinition> sigStr = channelDefs.stream()
|
List<ChannelDefinition> sigStr = channelDefs.stream().filter(it -> "sigstr".equals(it.getId())
|
||||||
.filter(it -> "sigstr".equals(it.getId())
|
&& "system:signal-strength".equals(it.getChannelTypeUID().getAsString())).toList();
|
||||||
&& "system:signal-strength".equals(it.getChannelTypeUID().getAsString()))
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
|
|
||||||
List<ChannelDefinition> lowBat = channelDefs.stream()
|
List<ChannelDefinition> lowBat = channelDefs.stream().filter(it -> "lowbat".equals(it.getId())
|
||||||
.filter(it -> "lowbat".equals(it.getId())
|
&& "system:low-battery".equals(it.getChannelTypeUID().getAsString())).toList();
|
||||||
&& "system:low-battery".equals(it.getChannelTypeUID().getAsString()))
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
|
|
||||||
assertThat(myChannel.size(), is(1));
|
assertThat(myChannel.size(), is(1));
|
||||||
assertThat(sigStr.size(), is(1));
|
assertThat(sigStr.size(), is(1));
|
||||||
|
@ -19,7 +19,6 @@ import java.nio.file.Path;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
import java.util.stream.StreamSupport;
|
import java.util.stream.StreamSupport;
|
||||||
|
|
||||||
@ -144,7 +143,7 @@ public class BundleInfoReader {
|
|||||||
if (Files.exists(modulePath)) {
|
if (Files.exists(modulePath)) {
|
||||||
try (Stream<Path> files = Files.walk(modulePath)) {
|
try (Stream<Path> files = Files.walk(modulePath)) {
|
||||||
List<JsonObject> moduleTypes = files.filter(isJsonFile).flatMap(this::readJsonElementsFromFile)
|
List<JsonObject> moduleTypes = files.filter(isJsonFile).flatMap(this::readJsonElementsFromFile)
|
||||||
.map(JsonElement::getAsJsonObject).collect(Collectors.toList());
|
.map(JsonElement::getAsJsonObject).toList();
|
||||||
if (!moduleTypes.isEmpty()) {
|
if (!moduleTypes.isEmpty()) {
|
||||||
bundleInfo.setModuleTypesJson(moduleTypes);
|
bundleInfo.setModuleTypesJson(moduleTypes);
|
||||||
}
|
}
|
||||||
@ -157,7 +156,7 @@ public class BundleInfoReader {
|
|||||||
if (Files.exists(template)) {
|
if (Files.exists(template)) {
|
||||||
try (Stream<Path> files = Files.walk(template)) {
|
try (Stream<Path> files = Files.walk(template)) {
|
||||||
List<JsonObject> ruleTemplates = files.filter(isJsonFile).flatMap(this::readJsonElementsFromFile)
|
List<JsonObject> ruleTemplates = files.filter(isJsonFile).flatMap(this::readJsonElementsFromFile)
|
||||||
.map(JsonElement::getAsJsonObject).collect(Collectors.toList());
|
.map(JsonElement::getAsJsonObject).toList();
|
||||||
if (!ruleTemplates.isEmpty()) {
|
if (!ruleTemplates.isEmpty()) {
|
||||||
bundleInfo.setRuleTemplateJson(ruleTemplates);
|
bundleInfo.setRuleTemplateJson(ruleTemplates);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user