diff --git a/bundles/org.openhab.core.addon.marketplace.karaf/src/main/java/org/openhab/core/addon/marketplace/karaf/internal/community/CommunityKarafAddonHandler.java b/bundles/org.openhab.core.addon.marketplace.karaf/src/main/java/org/openhab/core/addon/marketplace/karaf/internal/community/CommunityKarafAddonHandler.java index 6dc61c0efad..04f0f490b66 100644 --- a/bundles/org.openhab.core.addon.marketplace.karaf/src/main/java/org/openhab/core/addon/marketplace/karaf/internal/community/CommunityKarafAddonHandler.java +++ b/bundles/org.openhab.core.addon.marketplace.karaf/src/main/java/org/openhab/core/addon/marketplace/karaf/internal/community/CommunityKarafAddonHandler.java @@ -25,7 +25,6 @@ import java.nio.file.StandardCopyOption; import java.util.List; import java.util.concurrent.ScheduledExecutorService; -import java.util.stream.Collectors; import java.util.stream.Stream; import org.apache.karaf.kar.KarService; @@ -123,7 +122,7 @@ public void uninstall(Addon addon) throws MarketplaceHandlerException { try { Path addonPath = getAddonCacheDirectory(addon.getUid()); List repositories = karService.list(); - for (Path path : karFilesStream(addonPath).collect(Collectors.toList())) { + for (Path path : karFilesStream(addonPath).toList()) { String karRepoName = pathToKarRepoName(path); if (repositories.contains(karRepoName)) { karService.uninstall(karRepoName); diff --git a/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/AbstractRemoteAddonService.java b/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/AbstractRemoteAddonService.java index 95f4b79f9e4..4aa5f4dc7be 100644 --- a/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/AbstractRemoteAddonService.java +++ b/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/AbstractRemoteAddonService.java @@ -23,7 +23,6 @@ import java.util.Map; import java.util.Objects; import java.util.Set; -import java.util.stream.Collectors; import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; @@ -117,7 +116,7 @@ public void refreshSource() { } // create lookup list to make sure installed addons take precedence - List installedAddons = addons.stream().map(Addon::getUid).collect(Collectors.toList()); + List installedAddons = addons.stream().map(Addon::getUid).toList(); if (remoteEnabled()) { List remoteAddons = Objects.requireNonNullElse(cachedRemoteAddons.getValue(), List.of()); diff --git a/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/internal/community/CommunityMarketplaceAddonService.java b/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/internal/community/CommunityMarketplaceAddonService.java index 69104bec7e0..f1224b2d037 100644 --- a/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/internal/community/CommunityMarketplaceAddonService.java +++ b/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/internal/community/CommunityMarketplaceAddonService.java @@ -30,7 +30,6 @@ import java.util.Optional; import java.util.regex.Matcher; import java.util.regex.Pattern; -import java.util.stream.Collectors; import java.util.stream.Stream; import org.eclipse.jdt.annotation.NonNullByDefault; @@ -188,7 +187,7 @@ protected List getRemoteAddons() { } } - List users = pages.stream().flatMap(p -> Stream.of(p.users)).collect(Collectors.toList()); + List users = pages.stream().flatMap(p -> Stream.of(p.users)).toList(); pages.stream().flatMap(p -> Stream.of(p.topicList.topics)) .filter(t -> showUnpublished || Arrays.asList(t.tags).contains(PUBLISHED_TAG)) .map(t -> Optional.ofNullable(convertTopicItemToAddon(t, users))) diff --git a/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/internal/community/SerializedNameAnnotationIntrospector.java b/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/internal/community/SerializedNameAnnotationIntrospector.java index 5e32f55a245..fb55deabd6b 100644 --- a/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/internal/community/SerializedNameAnnotationIntrospector.java +++ b/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/internal/community/SerializedNameAnnotationIntrospector.java @@ -14,7 +14,6 @@ import java.util.List; import java.util.Optional; -import java.util.stream.Collectors; import java.util.stream.Stream; import org.eclipse.jdt.annotation.NonNullByDefault; @@ -46,7 +45,7 @@ public PropertyName findNameForDeserialization(Annotated annotated) { @NonNullByDefault({}) public List findPropertyAliases(Annotated annotated) { 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)); } diff --git a/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/internal/json/JsonAddonService.java b/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/internal/json/JsonAddonService.java index f349e242ac7..362f5311ea1 100644 --- a/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/internal/json/JsonAddonService.java +++ b/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/internal/json/JsonAddonService.java @@ -25,7 +25,6 @@ import java.util.Locale; import java.util.Map; import java.util.Objects; -import java.util.stream.Collectors; import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; @@ -133,8 +132,7 @@ protected List getRemoteAddons() { return List.of(); } }).flatMap(List::stream).filter(Objects::nonNull).map(e -> (AddonEntryDTO) e) - .filter(e -> showUnstable || "stable".equals(e.maturity)).map(this::fromAddonEntry) - .collect(Collectors.toList()); + .filter(e -> showUnstable || "stable".equals(e.maturity)).map(this::fromAddonEntry).toList(); } @Override diff --git a/bundles/org.openhab.core.addon.marketplace/src/test/java/org/openhab/core/addon/marketplace/test/TestAddonService.java b/bundles/org.openhab.core.addon.marketplace/src/test/java/org/openhab/core/addon/marketplace/test/TestAddonService.java index fe5bc672a5a..1471c6d11ba 100644 --- a/bundles/org.openhab.core.addon.marketplace/src/test/java/org/openhab/core/addon/marketplace/test/TestAddonService.java +++ b/bundles/org.openhab.core.addon.marketplace/src/test/java/org/openhab/core/addon/marketplace/test/TestAddonService.java @@ -16,7 +16,6 @@ import java.util.List; import java.util.Locale; import java.util.Set; -import java.util.stream.Collectors; import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; @@ -76,7 +75,7 @@ protected List getRemoteAddons() { remoteCalls++; return REMOTE_ADDONS.stream().map(id -> Addon.create(SERVICE_PID + ":" + id).withType("binding") .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 diff --git a/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/internal/AudioManagerImpl.java b/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/internal/AudioManagerImpl.java index eb79b9344f5..41a77393797 100644 --- a/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/internal/AudioManagerImpl.java +++ b/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/internal/AudioManagerImpl.java @@ -13,7 +13,6 @@ package org.openhab.core.audio.internal; import static java.util.Comparator.comparing; -import static java.util.stream.Collectors.toList; import java.io.File; import java.io.IOException; @@ -312,10 +311,10 @@ public Set getSinkIds(String pattern) { final Locale safeLocale = locale != null ? locale : Locale.getDefault(); if (CONFIG_DEFAULT_SOURCE.equals(param)) { 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)) { 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; diff --git a/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/internal/AudioServlet.java b/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/internal/AudioServlet.java index f36fd82d46c..7238df8fbbb 100644 --- a/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/internal/AudioServlet.java +++ b/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/internal/AudioServlet.java @@ -31,7 +31,6 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicLong; -import java.util.stream.Collectors; import java.util.stream.Stream; import javax.servlet.Servlet; @@ -172,7 +171,7 @@ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws Se final String streamId = substringBefore(substringAfterLast(requestURI, "/"), "."); List acceptedMimeTypes = Stream.of(Objects.requireNonNullElse(req.getHeader("Accept"), "").split(",")) - .map(String::trim).collect(Collectors.toList()); + .map(String::trim).toList(); StreamServed servedStream = servedStreams.get(streamId); if (servedStream == null) { @@ -219,7 +218,7 @@ private synchronized void removeTimedOutStreams() { long now = System.nanoTime(); final List toRemove = servedStreams.entrySet().stream() .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 -> { // the stream has expired and no one is using it, we need to remove it! diff --git a/bundles/org.openhab.core.automation.module.media/src/main/java/org/openhab/core/automation/module/media/internal/MediaActionTypeProvider.java b/bundles/org.openhab.core.automation.module.media/src/main/java/org/openhab/core/automation/module/media/internal/MediaActionTypeProvider.java index 7a52a6602c6..e9fa7cac3c4 100644 --- a/bundles/org.openhab.core.automation.module.media/src/main/java/org/openhab/core/automation/module/media/internal/MediaActionTypeProvider.java +++ b/bundles/org.openhab.core.automation.module.media/src/main/java/org/openhab/core/automation/module/media/internal/MediaActionTypeProvider.java @@ -13,7 +13,6 @@ package org.openhab.core.automation.module.media.internal; import static java.util.Comparator.comparing; -import static java.util.stream.Collectors.toList; import java.io.File; import java.math.BigDecimal; @@ -162,7 +161,7 @@ private List getSoundOptions() { private List getSinkOptions(@Nullable Locale locale) { final Locale safeLocale = locale != null ? locale : Locale.getDefault(); 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 diff --git a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/ScriptTransformationService.java b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/ScriptTransformationService.java index c5f22eb8d81..e784aa6c0a1 100644 --- a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/ScriptTransformationService.java +++ b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/ScriptTransformationService.java @@ -29,7 +29,6 @@ import java.util.concurrent.locks.ReentrantLock; import java.util.regex.Matcher; import java.util.regex.Pattern; -import java.util.stream.Collectors; import javax.script.Compilable; import javax.script.CompiledScript; @@ -246,7 +245,7 @@ public void updated(Transformation oldElement, Transformation element) { if (ScriptProfile.CONFIG_TO_HANDLER_SCRIPT.equals(param) || ScriptProfile.CONFIG_TO_ITEM_SCRIPT.equals(param)) { 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; } diff --git a/bundles/org.openhab.core.automation.rest/src/main/java/org/openhab/core/automation/rest/internal/RuleResource.java b/bundles/org.openhab.core.automation.rest/src/main/java/org/openhab/core/automation/rest/internal/RuleResource.java index cb78591b104..09b163c3f76 100644 --- a/bundles/org.openhab.core.automation.rest/src/main/java/org/openhab/core/automation/rest/internal/RuleResource.java +++ b/bundles/org.openhab.core.automation.rest/src/main/java/org/openhab/core/automation/rest/internal/RuleResource.java @@ -25,7 +25,6 @@ import java.util.List; import java.util.Map; import java.util.function.Predicate; -import java.util.stream.Collectors; import java.util.stream.Stream; import javax.annotation.security.RolesAllowed; @@ -433,7 +432,7 @@ public Response simulateRules( } final Stream 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) { diff --git a/bundles/org.openhab.core.automation.rest/src/main/java/org/openhab/core/automation/rest/internal/TemplateResource.java b/bundles/org.openhab.core.automation.rest/src/main/java/org/openhab/core/automation/rest/internal/TemplateResource.java index 58979ae0290..20e1d78e1c5 100644 --- a/bundles/org.openhab.core.automation.rest/src/main/java/org/openhab/core/automation/rest/internal/TemplateResource.java +++ b/bundles/org.openhab.core.automation.rest/src/main/java/org/openhab/core/automation/rest/internal/TemplateResource.java @@ -14,7 +14,6 @@ import java.util.Collection; import java.util.Locale; -import java.util.stream.Collectors; import javax.ws.rs.GET; import javax.ws.rs.HeaderParam; @@ -92,7 +91,7 @@ public Response getAll( @HeaderParam("Accept-Language") @Parameter(description = "language") @Nullable String language) { Locale locale = localeService.getLocale(language); Collection result = templateRegistry.getAll(locale).stream() - .map(template -> RuleTemplateDTOMapper.map(template)).collect(Collectors.toList()); + .map(template -> RuleTemplateDTOMapper.map(template)).toList(); return Response.ok(result).build(); } diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/AbstractResourceBundleProvider.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/AbstractResourceBundleProvider.java index 77758f80d4f..c50b7431c83 100644 --- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/AbstractResourceBundleProvider.java +++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/AbstractResourceBundleProvider.java @@ -30,7 +30,6 @@ import java.util.Map.Entry; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; -import java.util.stream.Collectors; import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jdt.annotation.NonNullByDefault; @@ -388,7 +387,7 @@ protected List getLocalizedConfigurationDescription( URI uri = new URI(prefix + ":" + uid + ".name"); return config.stream() .map(p -> localConfigI18nService.getLocalizedConfigDescriptionParameter(bundle, uri, p, locale)) - .collect(Collectors.toList()); + .toList(); } catch (URISyntaxException e) { logger.error("Constructed invalid uri '{}:{}.name'", prefix, uid, e); return config; diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/ruleengine/WrappedRule.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/ruleengine/WrappedRule.java index a5b8f0727e0..db6ca936acc 100644 --- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/ruleengine/WrappedRule.java +++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/ruleengine/WrappedRule.java @@ -17,7 +17,6 @@ import java.util.LinkedList; import java.util.List; import java.util.function.Function; -import java.util.stream.Collectors; import org.eclipse.jdt.annotation.NonNullByDefault; import org.openhab.core.automation.Module; @@ -37,12 +36,11 @@ public class WrappedRule { private static List map(final List in, Function factory, final Collection> coll) { - // explicit cast to List as JDK compiler complains - return Collections.unmodifiableList((List) in.stream().map(module -> { + return in.stream().map(module -> { final T impl = factory.apply(module); coll.add(impl); return impl; - }).collect(Collectors.toList())); + }).toList(); } private final Rule rule; diff --git a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/ConfigUtil.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/ConfigUtil.java index 88e92affcca..4cee1ae025b 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/ConfigUtil.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/ConfigUtil.java @@ -17,7 +17,6 @@ import java.math.BigDecimal; import java.math.RoundingMode; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.HashMap; @@ -25,7 +24,7 @@ import java.util.Map; import java.util.Map.Entry; 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.NonNullByDefault; @@ -118,14 +117,13 @@ public static void applyDefaultConfiguration(Configuration configuration, if (defaultValue != null && configuration.get(parameter.getName()) == null) { if (parameter.isMultiple()) { if (defaultValue.contains(DEFAULT_LIST_DELIMITER)) { - List values = (List) List.of(defaultValue.split(DEFAULT_LIST_DELIMITER)) - .stream() // + List values = (List) Stream.of(defaultValue.split(DEFAULT_LIST_DELIMITER)) .map(String::trim) // .filter(not(String::isEmpty)) // .map(value -> ConfigUtil.getDefaultValueAsCorrectType(parameter.getName(), parameter.getType(), value)) // .filter(Objects::nonNull) // - .collect(Collectors.toList()); + .toList(); Integer multipleLimit = parameter.getMultipleLimit(); if (multipleLimit != null && values.size() > multipleLimit.intValue()) { LoggerFactory.getLogger(ConfigUtil.class).warn( @@ -136,7 +134,7 @@ public static void applyDefaultConfiguration(Configuration configuration, } else { Object value = ConfigUtil.getDefaultValueAsCorrectType(parameter); if (value != null) { - configuration.put(parameter.getName(), Arrays.asList(value)); + configuration.put(parameter.getName(), List.of(value)); } } } else { diff --git a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/i18n/I18nConfigOptionsProvider.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/i18n/I18nConfigOptionsProvider.java index c5613ca8cc0..13df696aa4f 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/i18n/I18nConfigOptionsProvider.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/i18n/I18nConfigOptionsProvider.java @@ -21,7 +21,6 @@ import java.util.TimeZone; import java.util.concurrent.TimeUnit; import java.util.function.Function; -import java.util.stream.Collectors; import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; @@ -82,7 +81,7 @@ private Collection processTimeZoneParam() { Comparator byOffset = (t1, t2) -> t1.getRawOffset() - t2.getRawOffset(); Comparator byID = (t1, t2) -> t1.getID().compareTo(t2.getID()); 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) { @@ -107,6 +106,6 @@ private Collection getAvailable(@Nullable Locale locale, .distinct() // .filter(po -> !po.getValue().isEmpty()) // .sorted(Comparator.comparing(a -> a.getLabel())) // - .collect(Collectors.toList()); + .toList(); } } diff --git a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/net/NetworkConfigOptionProvider.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/net/NetworkConfigOptionProvider.java index ab4b9bbfb82..72556d5b594 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/net/NetworkConfigOptionProvider.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/net/NetworkConfigOptionProvider.java @@ -18,7 +18,6 @@ import java.util.Collection; import java.util.List; import java.util.Locale; -import java.util.stream.Collectors; import java.util.stream.Stream; import org.eclipse.jdt.annotation.NonNullByDefault; @@ -52,13 +51,11 @@ public class NetworkConfigOptionProvider implements ConfigOptionProvider { case PARAM_PRIMARY_ADDRESS: Stream ipv4Addresses = NetUtil.getAllInterfaceAddresses().stream() .filter(a -> a.getAddress() instanceof Inet4Address); - return ipv4Addresses.map(a -> new ParameterOption(a.toString(), a.toString())) - .collect(Collectors.toList()); + return ipv4Addresses.map(a -> new ParameterOption(a.toString(), a.toString())).toList(); case PARAM_BROADCAST_ADDRESS: List broadcastAddrList = new ArrayList<>(NetUtil.getAllBroadcastAddresses()); broadcastAddrList.add("255.255.255.255"); - return broadcastAddrList.stream().distinct().map(a -> new ParameterOption(a, a)) - .collect(Collectors.toList()); + return broadcastAddrList.stream().distinct().map(a -> new ParameterOption(a, a)).toList(); default: return null; } diff --git a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/status/ConfigStatusInfo.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/status/ConfigStatusInfo.java index 386f8481b81..e195d7147eb 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/status/ConfigStatusInfo.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/status/ConfigStatusInfo.java @@ -18,7 +18,6 @@ import java.util.Collections; import java.util.Objects; import java.util.function.Predicate; -import java.util.stream.Collectors; import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; @@ -137,7 +136,7 @@ private Collection filter(Collection filter, Predicate filterConfigStatusMessages( Collection configStatusMessages, Predicate predicate) { - return configStatusMessages.stream().filter(predicate).collect(Collectors.toList()); + return configStatusMessages.stream().filter(predicate).toList(); } @Override diff --git a/bundles/org.openhab.core.config.core/src/test/java/org/openhab/core/config/core/internal/normalization/NormalizerTest.java b/bundles/org.openhab.core.config.core/src/test/java/org/openhab/core/config/core/internal/normalization/NormalizerTest.java index 1947612013f..bd0a466cffb 100644 --- a/bundles/org.openhab.core.config.core/src/test/java/org/openhab/core/config/core/internal/normalization/NormalizerTest.java +++ b/bundles/org.openhab.core.config.core/src/test/java/org/openhab/core/config/core/internal/normalization/NormalizerTest.java @@ -12,7 +12,6 @@ */ package org.openhab.core.config.core.internal.normalization; -import static java.util.stream.Collectors.toList; import static org.hamcrest.CoreMatchers.*; import static org.hamcrest.MatcherAssert.assertThat; @@ -153,14 +152,13 @@ public void testListNormalizer() { assertThat(normalizer.normalize(null), is(nullValue())); - List expectedList = Stream.of(true, false, true).collect(toList()); + List 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).collect(toList()).toArray()), - is(equalTo(expectedList))); - assertThat(normalizer.normalize(new TreeSet<>(Stream.of(false, true).collect(toList()))), - is(equalTo(Stream.of(false, true).collect(toList())))); - assertThat(normalizer.normalize(Stream.of(true, "false", true).collect(toList())), is(equalTo(expectedList))); - assertThat(normalizer.normalize(Stream.of(true, 0, "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).toArray()), is(equalTo(expectedList))); + assertThat(normalizer.normalize(new TreeSet<>(Stream.of(false, true).toList())), + is(equalTo(Stream.of(false, true).toList()))); + assertThat(normalizer.normalize(Stream.of(true, "false", true).toList()), is(equalTo(expectedList))); + assertThat(normalizer.normalize(Stream.of(true, 0, "true").toList()), is(equalTo(expectedList))); } } diff --git a/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/internal/AutomaticInboxProcessor.java b/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/internal/AutomaticInboxProcessor.java index b39702e2357..64a20ca37e8 100644 --- a/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/internal/AutomaticInboxProcessor.java +++ b/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/internal/AutomaticInboxProcessor.java @@ -20,7 +20,6 @@ import java.util.Optional; import java.util.Set; import java.util.concurrent.CopyOnWriteArraySet; -import java.util.stream.Collectors; import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; @@ -214,7 +213,7 @@ private void checkAndIgnoreInInbox(@Nullable Thing thing) { private void ignoreInInbox(ThingTypeUID thingtypeUID, String representationValue) { List results = inbox.stream().filter(withRepresentationPropertyValue(representationValue)) - .filter(forThingTypeUID(thingtypeUID)).collect(Collectors.toList()); + .filter(forThingTypeUID(thingtypeUID)).toList(); if (results.size() == 1) { logger.debug("Auto-ignoring the inbox entry for the representation value '{}'.", representationValue); @@ -252,8 +251,7 @@ private void removePossiblyIgnoredResultInInbox(@Nullable Thing thing) { private void removeFromInbox(ThingTypeUID thingtypeUID, String representationValue) { List results = inbox.stream().filter(withRepresentationPropertyValue(representationValue)) - .filter(forThingTypeUID(thingtypeUID)).filter(withFlag(DiscoveryResultFlag.IGNORED)) - .collect(Collectors.toList()); + .filter(forThingTypeUID(thingtypeUID)).filter(withFlag(DiscoveryResultFlag.IGNORED)).toList(); if (results.size() == 1) { logger.debug("Removing the ignored result from the inbox for the representation value '{}'.", representationValue); diff --git a/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/internal/PersistentInbox.java b/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/internal/PersistentInbox.java index c56a661426d..30288ef57ab 100644 --- a/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/internal/PersistentInbox.java +++ b/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/internal/PersistentInbox.java @@ -33,7 +33,6 @@ import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; -import java.util.stream.Collectors; import java.util.stream.Stream; import org.eclipse.jdt.annotation.NonNullByDefault; @@ -189,7 +188,7 @@ protected void deactivate() { if (thingUID == null) { throw new IllegalArgumentException("Thing UID must not be null"); } - List results = stream().filter(forThingUID(thingUID)).collect(Collectors.toList()); + List results = stream().filter(forThingUID(thingUID)).toList(); if (results.isEmpty()) { throw new IllegalArgumentException("No Thing with UID " + thingUID.getAsString() + " in inbox"); } @@ -268,7 +267,7 @@ private void internalAdd(DiscoveryResultWrapper discoveryResultWrapper) { } List configurationParameters = getConfigDescParams(thingType).stream() - .map(ConfigDescriptionParameter::getName).collect(Collectors.toList()); + .map(ConfigDescriptionParameter::getName).toList(); discoveryResult.normalizePropertiesOnConfigDescription(configurationParameters); @@ -369,7 +368,7 @@ public void addInboxListener(@Nullable InboxListener listener) throws IllegalSta @Override public List getAll() { - return stream().collect(Collectors.toList()); + return stream().toList(); } @Override diff --git a/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/internal/console/InboxConsoleCommandExtension.java b/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/internal/console/InboxConsoleCommandExtension.java index e798c6aa63e..74a9ded549c 100644 --- a/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/internal/console/InboxConsoleCommandExtension.java +++ b/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/internal/console/InboxConsoleCommandExtension.java @@ -18,7 +18,6 @@ import java.util.List; import java.util.Map; import java.util.Objects; -import java.util.stream.Collectors; import org.eclipse.jdt.annotation.NonNullByDefault; import org.openhab.core.config.discovery.DiscoveryResult; @@ -73,8 +72,7 @@ public void execute(String[] args, Console console) { } try { ThingUID thingUID = new ThingUID(args[1]); - List results = inbox.stream().filter(forThingUID(thingUID)) - .collect(Collectors.toList()); + List results = inbox.stream().filter(forThingUID(thingUID)).toList(); if (results.isEmpty()) { console.println("No matching inbox entry could be found."); return; @@ -102,12 +100,10 @@ public void execute(String[] args, Console console) { } break; case SUBCMD_LIST: - printInboxEntries(console, - inbox.stream().filter(withFlag((DiscoveryResultFlag.NEW))).collect(Collectors.toList())); + printInboxEntries(console, inbox.stream().filter(withFlag((DiscoveryResultFlag.NEW))).toList()); break; case SUBCMD_LIST_IGNORED: - printInboxEntries(console, inbox.stream().filter(withFlag((DiscoveryResultFlag.IGNORED))) - .collect(Collectors.toList())); + printInboxEntries(console, inbox.stream().filter(withFlag((DiscoveryResultFlag.IGNORED))).toList()); break; case SUBCMD_CLEAR: clearInboxEntries(console, inbox.getAll()); @@ -117,8 +113,7 @@ public void execute(String[] args, Console console) { boolean validParam = true; try { ThingUID thingUID = new ThingUID(args[1]); - List results = inbox.stream().filter(forThingUID(thingUID)) - .collect(Collectors.toList()); + List results = inbox.stream().filter(forThingUID(thingUID)).toList(); if (results.isEmpty()) { console.println("No matching inbox entry could be found."); } else { @@ -131,7 +126,7 @@ public void execute(String[] args, Console console) { try { ThingTypeUID thingTypeUID = new ThingTypeUID(args[1]); List results = inbox.stream().filter(forThingTypeUID(thingTypeUID)) - .collect(Collectors.toList()); + .toList(); if (results.isEmpty()) { console.println("No matching inbox entry could be found."); } else { diff --git a/bundles/org.openhab.core.config.discovery/src/test/java/org/openhab/core/config/discovery/inbox/InboxPredicatesTest.java b/bundles/org.openhab.core.config.discovery/src/test/java/org/openhab/core/config/discovery/inbox/InboxPredicatesTest.java index a4848115469..b00e5771e12 100644 --- a/bundles/org.openhab.core.config.discovery/src/test/java/org/openhab/core/config/discovery/inbox/InboxPredicatesTest.java +++ b/bundles/org.openhab.core.config.discovery/src/test/java/org/openhab/core/config/discovery/inbox/InboxPredicatesTest.java @@ -19,7 +19,6 @@ import java.util.List; import java.util.Map; -import java.util.stream.Collectors; import org.eclipse.jdt.annotation.NonNullByDefault; import org.junit.jupiter.api.BeforeEach; @@ -79,89 +78,75 @@ public void setUp() throws Exception { @Test 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)).collect(Collectors.toList()).get(0), - is(equalTo(RESULTS.get(3)))); + assertThat(RESULTS.stream().filter(forBinding(BINDING_ID2)).toList().size(), is(1)); + assertThat(RESULTS.stream().filter(forBinding(BINDING_ID2)).toList().get(0), is(equalTo(RESULTS.get(3)))); - assertThat(RESULTS.stream().filter(forBinding(BINDING_ID2)).filter(withFlag(DiscoveryResultFlag.NEW)) - .collect(Collectors.toList()).size(), is(0)); + assertThat(RESULTS.stream().filter(forBinding(BINDING_ID2)).filter(withFlag(DiscoveryResultFlag.NEW)).toList() + .size(), is(0)); 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)) - .collect(Collectors.toList()).get(0), is(equalTo(RESULTS.get(3)))); + .toList().get(0), is(equalTo(RESULTS.get(3)))); } @Test public void testForThingTypeUID() { - assertThat(RESULTS.stream().filter(forThingTypeUID(THING_TYPE_UID11)).collect(Collectors.toList()).size(), - is(2)); + assertThat(RESULTS.stream().filter(forThingTypeUID(THING_TYPE_UID11)).toList().size(), is(2)); - assertThat(RESULTS.stream().filter(forThingTypeUID(THING_TYPE_UID12)).collect(Collectors.toList()).size(), - is(1)); - assertThat(RESULTS.stream().filter(forThingTypeUID(THING_TYPE_UID12)).collect(Collectors.toList()).get(0), + assertThat(RESULTS.stream().filter(forThingTypeUID(THING_TYPE_UID12)).toList().size(), is(1)); + assertThat(RESULTS.stream().filter(forThingTypeUID(THING_TYPE_UID12)).toList().get(0), is(equalTo(RESULTS.get(2)))); } @Test public void testForThingUID() { - assertThat(RESULTS.stream().filter(forThingUID(THING_UID11)).collect(Collectors.toList()).size(), is(1)); - assertThat(RESULTS.stream().filter(forThingUID(THING_UID11)).collect(Collectors.toList()).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)).filter(forThingTypeUID(THING_TYPE_UID12)) - .collect(Collectors.toList()).size(), is(1)); - assertThat(RESULTS.stream().filter(forThingUID(THING_UID12)).filter(forThingTypeUID(THING_TYPE_UID12)) - .collect(Collectors.toList()).get(0), is(equalTo(RESULTS.get(2)))); + assertThat(RESULTS.stream().filter(forThingUID(THING_UID11)).toList().size(), is(1)); + assertThat(RESULTS.stream().filter(forThingUID(THING_UID11)).toList().get(0), is(equalTo(RESULTS.get(0)))); + + assertThat(RESULTS.stream().filter(forThingUID(THING_UID12)).toList().size(), is(2)); + assertThat(RESULTS.stream().filter(forThingUID(THING_UID12)).filter(forThingTypeUID(THING_TYPE_UID12)).toList() + .size(), is(1)); + assertThat(RESULTS.stream().filter(forThingUID(THING_UID12)).filter(forThingTypeUID(THING_TYPE_UID12)).toList() + .get(0), is(equalTo(RESULTS.get(2)))); } @Test public void testWithFlag() { - assertThat(RESULTS.stream().filter(withFlag(DiscoveryResultFlag.NEW)).collect(Collectors.toList()).size(), - is(3)); - assertThat(RESULTS.stream().filter(withFlag(DiscoveryResultFlag.IGNORED)).collect(Collectors.toList()).size(), - is(1)); - assertThat(RESULTS.stream().filter(withFlag(DiscoveryResultFlag.IGNORED)).collect(Collectors.toList()).get(0), + assertThat(RESULTS.stream().filter(withFlag(DiscoveryResultFlag.NEW)).toList().size(), is(3)); + assertThat(RESULTS.stream().filter(withFlag(DiscoveryResultFlag.IGNORED)).toList().size(), is(1)); + assertThat(RESULTS.stream().filter(withFlag(DiscoveryResultFlag.IGNORED)).toList().get(0), is(equalTo(RESULTS.get(3)))); } @Test public void testWithProperty() { - assertThat(RESULTS.stream().filter(withProperty(PROP1, PROP_VAL1)).collect(Collectors.toList()).size(), is(2)); - assertThat(RESULTS.stream().filter(withProperty(PROP2, PROP_VAL2)).collect(Collectors.toList()).size(), is(4)); - assertThat(RESULTS.stream().filter(withProperty(PROP1, PROP_VAL2)).collect(Collectors.toList()).size(), is(0)); - assertThat(RESULTS.stream().filter(withProperty(PROP2, PROP_VAL1)).collect(Collectors.toList()).size(), is(0)); - assertThat(RESULTS.stream().filter(withProperty(null, PROP_VAL1)).collect(Collectors.toList()).size(), is(0)); + assertThat(RESULTS.stream().filter(withProperty(PROP1, PROP_VAL1)).toList().size(), is(2)); + assertThat(RESULTS.stream().filter(withProperty(PROP2, PROP_VAL2)).toList().size(), is(4)); + assertThat(RESULTS.stream().filter(withProperty(PROP1, PROP_VAL2)).toList().size(), is(0)); + assertThat(RESULTS.stream().filter(withProperty(PROP2, PROP_VAL1)).toList().size(), is(0)); + assertThat(RESULTS.stream().filter(withProperty(null, PROP_VAL1)).toList().size(), is(0)); } @Test public void testWithRepresentationProperty() { - assertThat(RESULTS.stream().filter(withRepresentationProperty(PROP1)).collect(Collectors.toList()).size(), - is(1)); - assertThat(RESULTS.stream().filter(withRepresentationProperty(PROP1)).collect(Collectors.toList()).get(0), + assertThat(RESULTS.stream().filter(withRepresentationProperty(PROP1)).toList().size(), is(1)); + assertThat(RESULTS.stream().filter(withRepresentationProperty(PROP1)).toList().get(0), is(equalTo(RESULTS.get(0)))); - assertThat(RESULTS.stream().filter(withRepresentationProperty(PROP2)).collect(Collectors.toList()).size(), - is(1)); - assertThat(RESULTS.stream().filter(withRepresentationProperty(PROP2)).collect(Collectors.toList()).get(0), + assertThat(RESULTS.stream().filter(withRepresentationProperty(PROP2)).toList().size(), is(1)); + assertThat(RESULTS.stream().filter(withRepresentationProperty(PROP2)).toList().get(0), is(equalTo(RESULTS.get(2)))); } @Test public void testWithRepresentationPropertyValue() { - assertThat( - RESULTS.stream().filter(withRepresentationPropertyValue(PROP_VAL1)).collect(Collectors.toList()).size(), - is(1)); - assertThat( - RESULTS.stream().filter(withRepresentationPropertyValue(PROP_VAL1)).collect(Collectors.toList()).get(0), + assertThat(RESULTS.stream().filter(withRepresentationPropertyValue(PROP_VAL1)).toList().size(), is(1)); + assertThat(RESULTS.stream().filter(withRepresentationPropertyValue(PROP_VAL1)).toList().get(0), is(equalTo(RESULTS.get(0)))); - assertThat( - RESULTS.stream().filter(withRepresentationPropertyValue(PROP_VAL2)).collect(Collectors.toList()).size(), - is(1)); - assertThat( - RESULTS.stream().filter(withRepresentationPropertyValue(PROP_VAL2)).collect(Collectors.toList()).get(0), + assertThat(RESULTS.stream().filter(withRepresentationPropertyValue(PROP_VAL2)).toList().size(), is(1)); + assertThat(RESULTS.stream().filter(withRepresentationPropertyValue(PROP_VAL2)).toList().get(0), is(equalTo(RESULTS.get(2)))); } } diff --git a/bundles/org.openhab.core.config.discovery/src/test/java/org/openhab/core/config/discovery/internal/AutomaticInboxProcessorTest.java b/bundles/org.openhab.core.config.discovery/src/test/java/org/openhab/core/config/discovery/internal/AutomaticInboxProcessorTest.java index 9f8f2fe7718..a4140bd54fb 100644 --- a/bundles/org.openhab.core.config.discovery/src/test/java/org/openhab/core/config/discovery/internal/AutomaticInboxProcessorTest.java +++ b/bundles/org.openhab.core.config.discovery/src/test/java/org/openhab/core/config/discovery/internal/AutomaticInboxProcessorTest.java @@ -23,7 +23,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.stream.Collectors; import java.util.stream.Stream; import org.eclipse.jdt.annotation.NonNullByDefault; @@ -169,8 +168,7 @@ public void testThingWithOtherBindingIDButSameRepresentationPropertyWentOnline() .withRepresentationProperty(DEVICE_ID_KEY).build()); // Then there is a discovery result which is NEW - List results = inbox.stream().filter(withFlag(DiscoveryResultFlag.NEW)) - .collect(Collectors.toList()); + List results = inbox.stream().filter(withFlag(DiscoveryResultFlag.NEW)).toList(); assertThat(results.size(), is(1)); assertThat(results.get(0).getThingUID(), is(equalTo(THING_UID))); @@ -183,10 +181,10 @@ public void testThingWithOtherBindingIDButSameRepresentationPropertyWentOnline() automaticInboxProcessor.receive(thingStatusInfoChangedEventMock); // 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.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)); } @@ -201,12 +199,11 @@ public void testThingWithOtherBindingIDButSameRepresentationPropertyIsDiscovered .withRepresentationProperty(DEVICE_ID_KEY).build()); // Do NOT ignore this discovery result because it has a different binding ID - List results = inbox.stream().filter(withFlag(DiscoveryResultFlag.IGNORED)) - .collect(Collectors.toList()); + List results = inbox.stream().filter(withFlag(DiscoveryResultFlag.IGNORED)).toList(); assertThat(results.size(), is(0)); // 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.get(0).getThingUID(), is(equalTo(THING_UID3))); } @@ -216,8 +213,7 @@ public void testThingWentOnline() { inbox.add(DiscoveryResultBuilder.create(THING_UID).withProperty(DEVICE_ID_KEY, DEVICE_ID) .withRepresentationProperty(DEVICE_ID_KEY).build()); - List results = inbox.stream().filter(withFlag(DiscoveryResultFlag.NEW)) - .collect(Collectors.toList()); + List results = inbox.stream().filter(withFlag(DiscoveryResultFlag.NEW)).toList(); assertThat(results.size(), is(1)); assertThat(results.get(0).getThingUID(), is(equalTo(THING_UID))); @@ -227,25 +223,23 @@ public void testThingWentOnline() { when(thingStatusInfoChangedEventMock.getThingUID()).thenReturn(THING_UID); 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)); - 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.get(0).getThingUID(), is(equalTo(THING_UID))); } @Test public void testNoDiscoveryResultIfNoRepresentationPropertySet() { - List results = inbox.stream().filter(withFlag(DiscoveryResultFlag.NEW)) - .collect(Collectors.toList()); + List results = inbox.stream().filter(withFlag(DiscoveryResultFlag.NEW)).toList(); assertThat(results.size(), is(0)); } @Test public void testThingWhenNoRepresentationPropertySet() { inbox.add(DiscoveryResultBuilder.create(THING_UID).withProperty(DEVICE_ID_KEY, DEVICE_ID).build()); - List results = inbox.stream().filter(withFlag(DiscoveryResultFlag.NEW)) - .collect(Collectors.toList()); + List results = inbox.stream().filter(withFlag(DiscoveryResultFlag.NEW)).toList(); assertThat(results.size(), is(1)); assertThat(results.get(0).getThingUID(), is(equalTo(THING_UID))); @@ -255,7 +249,7 @@ public void testThingWhenNoRepresentationPropertySet() { when(thingStatusInfoChangedEventMock.getThingUID()).thenReturn(THING_UID); 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)); } @@ -270,10 +264,9 @@ public void testInboxHasBeenChanged() { inbox.add(DiscoveryResultBuilder.create(THING_UID2).withProperty(DEVICE_ID_KEY, DEVICE_ID) .withRepresentationProperty(DEVICE_ID_KEY).build()); - List results = inbox.stream().filter(withFlag(DiscoveryResultFlag.NEW)) - .collect(Collectors.toList()); + List results = inbox.stream().filter(withFlag(DiscoveryResultFlag.NEW)).toList(); 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.get(0).getThingUID(), is(equalTo(THING_UID2))); } @@ -284,8 +277,7 @@ public void testThingIsBeingRemoved() { .withRepresentationProperty(DEVICE_ID_KEY).build()); inbox.setFlag(THING_UID, DiscoveryResultFlag.IGNORED); - List results = inbox.stream().filter(withFlag(DiscoveryResultFlag.IGNORED)) - .collect(Collectors.toList()); + List results = inbox.stream().filter(withFlag(DiscoveryResultFlag.IGNORED)).toList(); assertThat(results.size(), is(1)); assertThat(results.get(0).getThingUID(), is(equalTo(THING_UID))); @@ -305,8 +297,7 @@ public void testOneThingOutOfTwoWithSameRepresentationPropertyButDifferentBindin .withRepresentationProperty(DEVICE_ID_KEY).build()); inbox.setFlag(THING_UID3, DiscoveryResultFlag.IGNORED); - List results = inbox.stream().filter(withFlag(DiscoveryResultFlag.IGNORED)) - .collect(Collectors.toList()); + List results = inbox.stream().filter(withFlag(DiscoveryResultFlag.IGNORED)).toList(); assertThat(results.size(), is(2)); automaticInboxProcessor.removed(thingMock); @@ -321,8 +312,7 @@ public void testThingWithConfigWentOnline() { inbox.add(DiscoveryResultBuilder.create(THING_UID2).withProperty(OTHER_KEY, OTHER_VALUE) .withRepresentationProperty(OTHER_KEY).build()); - List results = inbox.stream().filter(withFlag(DiscoveryResultFlag.NEW)) - .collect(Collectors.toList()); + List results = inbox.stream().filter(withFlag(DiscoveryResultFlag.NEW)).toList(); assertThat(results.size(), is(1)); assertThat(results.get(0).getThingUID(), is(equalTo(THING_UID2))); @@ -332,9 +322,9 @@ public void testThingWithConfigWentOnline() { when(thingStatusInfoChangedEventMock.getThingUID()).thenReturn(THING_UID2); 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)); - 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.get(0).getThingUID(), is(equalTo(THING_UID2))); } @@ -350,10 +340,9 @@ public void testInboxWithConfigHasBeenChanged() { inbox.add(DiscoveryResultBuilder.create(THING_UID).withProperty(OTHER_KEY, OTHER_VALUE) .withRepresentationProperty(OTHER_KEY).build()); - List results = inbox.stream().filter(withFlag(DiscoveryResultFlag.NEW)) - .collect(Collectors.toList()); + List results = inbox.stream().filter(withFlag(DiscoveryResultFlag.NEW)).toList(); 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.get(0).getThingUID(), is(equalTo(THING_UID))); } @@ -364,8 +353,7 @@ public void testThingWithConfigIsBeingRemoved() { .withRepresentationProperty(OTHER_KEY).build()); inbox.setFlag(THING_UID2, DiscoveryResultFlag.IGNORED); - List results = inbox.stream().filter(withFlag(DiscoveryResultFlag.IGNORED)) - .collect(Collectors.toList()); + List results = inbox.stream().filter(withFlag(DiscoveryResultFlag.IGNORED)).toList(); assertThat(results.size(), is(1)); assertThat(results.get(0).getThingUID(), is(equalTo(THING_UID2))); diff --git a/bundles/org.openhab.core.config.dispatch/src/main/java/org/openhab/core/config/dispatch/internal/ConfigDispatcher.java b/bundles/org.openhab.core.config.dispatch/src/main/java/org/openhab/core/config/dispatch/internal/ConfigDispatcher.java index 3246d06dcb1..ee1175d6ade 100644 --- a/bundles/org.openhab.core.config.dispatch/src/main/java/org/openhab/core/config/dispatch/internal/ConfigDispatcher.java +++ b/bundles/org.openhab.core.config.dispatch/src/main/java/org/openhab/core/config/dispatch/internal/ConfigDispatcher.java @@ -28,7 +28,6 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Properties; -import java.util.stream.Collectors; import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; @@ -436,14 +435,14 @@ private ParseLineResult parseLine(final String filePath, final String line) { String value = trimmedLine.substring(property.length() + 1).trim(); if (value.startsWith(DEFAULT_LIST_STARTING_CHARACTER) && value.endsWith(DEFAULT_LIST_ENDING_CHARACTER)) { logger.debug("Found list in value '{}'", value); - List values = Arrays.asList(value // + // + List values = Arrays.stream(value // .replace(DEFAULT_LIST_STARTING_CHARACTER, "") // .replace(DEFAULT_LIST_ENDING_CHARACTER, "")// .split(DEFAULT_LIST_DELIMITER))// - .stream()// .map(v -> v.trim())// .filter(v -> !v.isEmpty())// - .collect(Collectors.toList()); + .toList(); return new ParseLineResult(pid, property.trim(), values); } else { return new ParseLineResult(pid, property.trim(), value); @@ -539,7 +538,7 @@ public void initializeProcessPIDMapping() { */ public List getOrphanPIDs() { return processedPIDMapping.entrySet().stream().filter(e -> e.getValue() == null).map(e -> e.getKey()) - .collect(Collectors.toList()); + .toList(); } /** @@ -547,7 +546,7 @@ public List getOrphanPIDs() { */ public void setCurrentExclusivePIDList() { 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) { diff --git a/bundles/org.openhab.core.config.serial/src/main/java/org/openhab/core/config/serial/internal/SerialConfigOptionProvider.java b/bundles/org.openhab.core.config.serial/src/main/java/org/openhab/core/config/serial/internal/SerialConfigOptionProvider.java index 1cb89ed044a..db2f556aa5b 100644 --- a/bundles/org.openhab.core.config.serial/src/main/java/org/openhab/core/config/serial/internal/SerialConfigOptionProvider.java +++ b/bundles/org.openhab.core.config.serial/src/main/java/org/openhab/core/config/serial/internal/SerialConfigOptionProvider.java @@ -17,7 +17,6 @@ import java.util.Locale; import java.util.Set; import java.util.concurrent.CopyOnWriteArraySet; -import java.util.stream.Collectors; import java.util.stream.Stream; import org.eclipse.jdt.annotation.NonNullByDefault; @@ -87,7 +86,7 @@ public void usbSerialDeviceRemoved(UsbSerialDeviceInformation usbSerialDeviceInf previouslyDiscovered.stream().map(UsbSerialDeviceInformation::getSerialPort)) .distinct() // .map(serialPortName -> new ParameterOption(serialPortName, serialPortName)) // - .collect(Collectors.toList()); + .toList(); } return null; } diff --git a/bundles/org.openhab.core.config.serial/src/test/java/org/openhab/core/config/serial/internal/SerialConfigOptionProviderTest.java b/bundles/org.openhab.core.config.serial/src/test/java/org/openhab/core/config/serial/internal/SerialConfigOptionProviderTest.java index 1e8668f0687..204997a4b07 100644 --- a/bundles/org.openhab.core.config.serial/src/test/java/org/openhab/core/config/serial/internal/SerialConfigOptionProviderTest.java +++ b/bundles/org.openhab.core.config.serial/src/test/java/org/openhab/core/config/serial/internal/SerialConfigOptionProviderTest.java @@ -20,7 +20,6 @@ import java.net.URI; import java.util.Arrays; import java.util.Collection; -import java.util.stream.Collectors; import java.util.stream.Stream; import org.eclipse.jdt.annotation.NonNullByDefault; @@ -83,7 +82,7 @@ private void assertParameterOptions(String... serialPortIdentifiers) { Collection actual = provider.getParameterOptions(URI.create("uri"), "serialPort", SERIAL_PORT, null); Collection expected = Arrays.stream(serialPortIdentifiers) - .map(id -> new ParameterOption(id, id)).collect(Collectors.toList()); + .map(id -> new ParameterOption(id, id)).toList(); assertThat(actual, is(expected)); } diff --git a/bundles/org.openhab.core.ephemeris/src/main/java/org/openhab/core/ephemeris/internal/EphemerisManagerImpl.java b/bundles/org.openhab.core.ephemeris/src/main/java/org/openhab/core/ephemeris/internal/EphemerisManagerImpl.java index 65b9b8bf9d0..a1a35fa2073 100644 --- a/bundles/org.openhab.core.ephemeris/src/main/java/org/openhab/core/ephemeris/internal/EphemerisManagerImpl.java +++ b/bundles/org.openhab.core.ephemeris/src/main/java/org/openhab/core/ephemeris/internal/EphemerisManagerImpl.java @@ -36,7 +36,6 @@ import java.util.Optional; import java.util.Properties; import java.util.Set; -import java.util.stream.Collectors; import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; @@ -259,7 +258,7 @@ private List getHolidays(ZonedDateTime from, int span, HolidayManager h LocalDate toDate = from.plusDays(span).toLocalDate(); Set 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 diff --git a/bundles/org.openhab.core.io.console/src/main/java/org/openhab/core/io/console/internal/extension/ItemConsoleCommandCompleter.java b/bundles/org.openhab.core.io.console/src/main/java/org/openhab/core/io/console/internal/extension/ItemConsoleCommandCompleter.java index b80c788ed09..a3981197b2f 100644 --- a/bundles/org.openhab.core.io.console/src/main/java/org/openhab/core/io/console/internal/extension/ItemConsoleCommandCompleter.java +++ b/bundles/org.openhab.core.io.console/src/main/java/org/openhab/core/io/console/internal/extension/ItemConsoleCommandCompleter.java @@ -15,7 +15,6 @@ import java.util.List; import java.util.Objects; import java.util.function.Function; -import java.util.stream.Collectors; import java.util.stream.Stream; import org.eclipse.jdt.annotation.NonNullByDefault; @@ -51,8 +50,7 @@ public ItemConsoleCommandCompleter(ItemRegistry itemRegistry, Function candidates) { if (cursorArgumentIndex <= 0) { - return new StringsCompleter( - itemRegistry.getAll().stream().map(i -> i.getName()).collect(Collectors.toList()), true) + return new StringsCompleter(itemRegistry.getAll().stream().map(i -> i.getName()).toList(), true) .complete(args, cursorArgumentIndex, cursorPosition, candidates); } var localDataTypeGetter = dataTypeGetter; @@ -62,8 +60,8 @@ public boolean complete(String[] args, int cursorArgumentIndex, int cursorPositi Stream> enums = Stream.of(localDataTypeGetter.apply(item)).filter(Class::isEnum); Stream> enumConstants = enums.flatMap( t -> Stream.of(Objects.requireNonNull(((Class>) t).getEnumConstants()))); - return new StringsCompleter(enumConstants.map(Object::toString).collect(Collectors.toList()), false) - .complete(args, cursorArgumentIndex, cursorPosition, candidates); + return new StringsCompleter(enumConstants.map(Object::toString).toList(), false).complete(args, + cursorArgumentIndex, cursorPosition, candidates); } catch (ItemNotFoundException | ItemNotUniqueException e) { return false; } diff --git a/bundles/org.openhab.core.io.console/src/main/java/org/openhab/core/io/console/internal/extension/ItemConsoleCommandExtension.java b/bundles/org.openhab.core.io.console/src/main/java/org/openhab/core/io/console/internal/extension/ItemConsoleCommandExtension.java index 4cd4d45dc97..3ec4654518e 100644 --- a/bundles/org.openhab.core.io.console/src/main/java/org/openhab/core/io/console/internal/extension/ItemConsoleCommandExtension.java +++ b/bundles/org.openhab.core.io.console/src/main/java/org/openhab/core/io/console/internal/extension/ItemConsoleCommandExtension.java @@ -17,7 +17,6 @@ import java.util.List; import java.util.Set; import java.util.function.Consumer; -import java.util.stream.Collectors; import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; @@ -74,8 +73,8 @@ public boolean complete(String[] args, int cursorArgumentIndex, int cursorPositi default: return false; } - return new StringsCompleter(items.stream().map(i -> i.getName()).collect(Collectors.toList()), true) - .complete(args, cursorArgumentIndex, cursorPosition, candidates); + return new StringsCompleter(items.stream().map(i -> i.getName()).toList(), true).complete(args, + cursorArgumentIndex, cursorPosition, candidates); } if (cursorArgumentIndex == 2 && args[0].equals(SUBCMD_RMTAG)) { Item item = managedItemProvider.get(args[1]); diff --git a/bundles/org.openhab.core.io.net/src/test/java/org/openhab/core/io/net/http/internal/ExtensibleTrustManagerImplTest.java b/bundles/org.openhab.core.io.net/src/test/java/org/openhab/core/io/net/http/internal/ExtensibleTrustManagerImplTest.java index 63060c62eaa..9f5f651ebc2 100644 --- a/bundles/org.openhab.core.io.net/src/test/java/org/openhab/core/io/net/http/internal/ExtensibleTrustManagerImplTest.java +++ b/bundles/org.openhab.core.io.net/src/test/java/org/openhab/core/io/net/http/internal/ExtensibleTrustManagerImplTest.java @@ -22,7 +22,6 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; -import java.util.stream.Collectors; import java.util.stream.Stream; import javax.net.ssl.SSLEngine; @@ -174,7 +173,7 @@ public void shouldNotForwardCallsToMockForDifferentCN() throws CertificateExcept private Collection> constructAlternativeNames(String... alternatives) { Collection> alternativeNames = new ArrayList<>(); for (String alternative : alternatives) { - alternativeNames.add(Stream.of(0, alternative).collect(Collectors.toList())); + alternativeNames.add(Stream.of(0, alternative).toList()); } return alternativeNames; diff --git a/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/config/EnrichedConfigDescriptionParameterDTO.java b/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/config/EnrichedConfigDescriptionParameterDTO.java index d736cb11fcf..754aa5739fe 100644 --- a/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/config/EnrichedConfigDescriptionParameterDTO.java +++ b/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/config/EnrichedConfigDescriptionParameterDTO.java @@ -16,7 +16,7 @@ import java.util.Collection; import java.util.List; 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.Nullable; @@ -49,8 +49,8 @@ public EnrichedConfigDescriptionParameterDTO(String name, Type type, BigDecimal if (multiple && defaultValue != null) { if (defaultValue.contains(DEFAULT_LIST_DELIMITER)) { - defaultValues = List.of(defaultValue.split(DEFAULT_LIST_DELIMITER)).stream().map(v -> v.trim()) - .filter(v -> !v.isEmpty()).collect(Collectors.toList()); + defaultValues = Stream.of(defaultValue.split(DEFAULT_LIST_DELIMITER)).map(String::trim) + .filter(v -> !v.isEmpty()).toList(); } else { defaultValues = Set.of(defaultValue); } diff --git a/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/item/ItemResource.java b/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/item/ItemResource.java index 570eb0ed7ba..ccc7936c1b3 100644 --- a/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/item/ItemResource.java +++ b/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/item/ItemResource.java @@ -386,7 +386,7 @@ public Response getPlainItemState(@PathParam("itemname") @Parameter(description public Response getBinaryItemState(@HeaderParam("Accept") @Nullable String mediaType, @PathParam("itemname") @Parameter(description = "item name") String itemname) { List acceptedMediaTypes = Arrays.stream(Objects.requireNonNullElse(mediaType, "").split(",")) - .map(String::trim).collect(Collectors.toList()); + .map(String::trim).toList(); Item item = getItem(itemname); diff --git a/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/link/ItemChannelLinkResource.java b/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/link/ItemChannelLinkResource.java index abb25863eab..ab158eb2380 100644 --- a/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/link/ItemChannelLinkResource.java +++ b/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/link/ItemChannelLinkResource.java @@ -14,7 +14,6 @@ import java.util.List; import java.util.Map; -import java.util.stream.Collectors; import java.util.stream.Stream; import javax.annotation.security.RolesAllowed; @@ -172,10 +171,9 @@ public Response getLink(@PathParam("itemName") @Parameter(description = "item na @PathParam("channelUID") @Parameter(description = "channel UID") String channelUid) { List links = itemChannelLinkRegistry.stream() .filter(link -> channelUid.equals(link.getLinkedUID().getAsString())) - .filter(link -> itemName.equals(link.getItemName())) - .map(link -> EnrichedItemChannelLinkDTOMapper.map(link, - isEditable(AbstractLink.getIDFor(link.getItemName(), link.getLinkedUID())))) - .collect(Collectors.toList()); + .filter(link -> itemName.equals(link.getItemName())).map(link -> EnrichedItemChannelLinkDTOMapper + .map(link, isEditable(AbstractLink.getIDFor(link.getItemName(), link.getLinkedUID())))) + .toList(); if (!links.isEmpty()) { return JSONResponse.createResponse(Status.OK, links.get(0), null); diff --git a/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/service/ConfigurableServiceResource.java b/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/service/ConfigurableServiceResource.java index 1b5f5490cf1..dacf9f3058f 100644 --- a/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/service/ConfigurableServiceResource.java +++ b/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/service/ConfigurableServiceResource.java @@ -22,7 +22,6 @@ import java.util.List; import java.util.Locale; import java.util.Map; -import java.util.stream.Collectors; import javax.annotation.security.RolesAllowed; import javax.ws.rs.Consumes; @@ -369,7 +368,7 @@ private String getServiceId(ServiceReference serviceReference) { } else if (pid instanceof String[] pids) { serviceId = getServicePID(cn, Arrays.asList(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 { logger.warn("The component \"{}\" is using an unhandled service PID type ({}). Use component name.", cn, pid.getClass()); diff --git a/bundles/org.openhab.core.io.rest.voice/src/main/java/org/openhab/core/io/rest/voice/internal/VoiceResource.java b/bundles/org.openhab.core.io.rest.voice/src/main/java/org/openhab/core/io/rest/voice/internal/VoiceResource.java index dc6f0a7039d..c0c84ebe96b 100644 --- a/bundles/org.openhab.core.io.rest.voice/src/main/java/org/openhab/core/io/rest/voice/internal/VoiceResource.java +++ b/bundles/org.openhab.core.io.rest.voice/src/main/java/org/openhab/core/io/rest/voice/internal/VoiceResource.java @@ -15,7 +15,6 @@ import java.util.List; import java.util.Locale; import java.util.Objects; -import java.util.stream.Collectors; import javax.annotation.security.RolesAllowed; import javax.ws.rs.Consumes; @@ -114,7 +113,7 @@ public Response getInterpreters( @HeaderParam(HttpHeaders.ACCEPT_LANGUAGE) @Parameter(description = "language") @Nullable String language) { final Locale locale = localeService.getLocale(language); List dtos = voiceManager.getHLIs().stream().map(hli -> HLIMapper.map(hli, locale)) - .collect(Collectors.toList()); + .toList(); return Response.ok(dtos).build(); } @@ -203,7 +202,7 @@ public Response interpret( @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)))) }) public Response getVoices() { - List dtos = voiceManager.getAllVoices().stream().map(VoiceMapper::map).collect(Collectors.toList()); + List dtos = voiceManager.getAllVoices().stream().map(VoiceMapper::map).toList(); return Response.ok(dtos).build(); } diff --git a/bundles/org.openhab.core.io.rest/src/main/java/org/openhab/core/io/rest/internal/DTOMapperImpl.java b/bundles/org.openhab.core.io.rest/src/main/java/org/openhab/core/io/rest/internal/DTOMapperImpl.java index 764bbe8c0bd..4ce2559d543 100644 --- a/bundles/org.openhab.core.io.rest/src/main/java/org/openhab/core/io/rest/internal/DTOMapperImpl.java +++ b/bundles/org.openhab.core.io.rest/src/main/java/org/openhab/core/io/rest/internal/DTOMapperImpl.java @@ -14,7 +14,6 @@ import java.lang.reflect.Field; import java.util.List; -import java.util.stream.Collectors; import java.util.stream.Stream; import org.eclipse.jdt.annotation.NonNull; @@ -42,7 +41,7 @@ public class DTOMapperImpl implements DTOMapper { if (fields == null || fields.trim().isEmpty()) { return itemStream; } - List fieldList = Stream.of(fields.split(",")).map(field -> field.trim()).collect(Collectors.toList()); + List fieldList = Stream.of(fields.split(",")).map(String::trim).toList(); return itemStream.map(dto -> { for (Field field : dto.getClass().getFields()) { if (!fieldList.contains(field.getName())) { diff --git a/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/internal/ModbusLibraryWrapper.java b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/internal/ModbusLibraryWrapper.java index b0a9a56cb92..b8a15504266 100644 --- a/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/internal/ModbusLibraryWrapper.java +++ b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/internal/ModbusLibraryWrapper.java @@ -14,7 +14,6 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; -import java.util.stream.Collectors; import java.util.stream.IntStream; import org.eclipse.jdt.annotation.NonNull; @@ -269,8 +268,8 @@ public static BitVector convertBits(BitArray bits) { * @return */ public static Register[] convertRegisters(ModbusRegisterArray arr) { - return IntStream.range(0, arr.size()).mapToObj(i -> new SimpleInputRegister(arr.getRegister(i))) - .collect(Collectors.toList()).toArray(new Register[0]); + return IntStream.range(0, arr.size()).mapToObj(i -> new SimpleInputRegister(arr.getRegister(i))).toList() + .toArray(new Register[0]); } /** diff --git a/bundles/org.openhab.core.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/BitUtilitiesExtractIndividualMethodsTest.java b/bundles/org.openhab.core.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/BitUtilitiesExtractIndividualMethodsTest.java index 710294134e0..e191fbbbf1b 100644 --- a/bundles/org.openhab.core.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/BitUtilitiesExtractIndividualMethodsTest.java +++ b/bundles/org.openhab.core.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/BitUtilitiesExtractIndividualMethodsTest.java @@ -19,7 +19,6 @@ import java.util.Optional; import java.util.function.Function; import java.util.function.Supplier; -import java.util.stream.Collectors; import java.util.stream.Stream; import java.util.stream.Stream.Builder; @@ -51,7 +50,7 @@ public static Collection data() { ModbusRegisterArray registers = (ModbusRegisterArray) values[2]; int index = (int) values[3]; return registerVariations(expectedResult, type, registers, index); - }).collect(Collectors.toList()); + }).toList(); } public static Stream filteredTestData(ValueType type) { diff --git a/bundles/org.openhab.core.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/BitUtilitiesExtractStateFromRegistersTest.java b/bundles/org.openhab.core.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/BitUtilitiesExtractStateFromRegistersTest.java index acaf4768aba..2676a841af5 100644 --- a/bundles/org.openhab.core.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/BitUtilitiesExtractStateFromRegistersTest.java +++ b/bundles/org.openhab.core.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/BitUtilitiesExtractStateFromRegistersTest.java @@ -17,9 +17,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows; import java.util.Collection; -import java.util.Collections; import java.util.Optional; -import java.util.stream.Collectors; import java.util.stream.Stream; import org.eclipse.jdt.annotation.NonNullByDefault; @@ -41,7 +39,7 @@ private static ModbusRegisterArray shortArrayToRegisterArray(int... arr) { } public static Collection data() { - return Collections.unmodifiableList(Stream.of( + return Stream.of( // // BIT // @@ -351,7 +349,7 @@ ValueType.INT64_SWAP, shortArrayToRegisterArray(0x0, 0x0, 0x8, 0x0), 0 }, // out of bounds of unsigned 64bit new DecimalType("16124500437522872585"), ValueType.UINT64_SWAP, shortArrayToRegisterArray(0x7909, 0x772E, 0xBBB7, 0xDFC5), 0 }) - .collect(Collectors.toList())); + .toList(); } @SuppressWarnings("unchecked") diff --git a/bundles/org.openhab.core.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/BitUtilitiesExtractStringTest.java b/bundles/org.openhab.core.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/BitUtilitiesExtractStringTest.java index 0338c9daa54..e68592bd19e 100644 --- a/bundles/org.openhab.core.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/BitUtilitiesExtractStringTest.java +++ b/bundles/org.openhab.core.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/BitUtilitiesExtractStringTest.java @@ -17,8 +17,6 @@ import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.util.Collection; -import java.util.Collections; -import java.util.stream.Collectors; import java.util.stream.Stream; import java.util.stream.Stream.Builder; @@ -39,8 +37,7 @@ private static ModbusRegisterArray shortArrayToRegisterArray(int... arr) { } public static Collection data() { - return Collections.unmodifiableList(Stream.of( - new Object[] { "", shortArrayToRegisterArray(0), 0, 0, StandardCharsets.UTF_8 }, + return Stream.of(new Object[] { "", shortArrayToRegisterArray(0), 0, 0, StandardCharsets.UTF_8 }, new Object[] { "hello", shortArrayToRegisterArray(0x6865, 0x6c6c, 0x6f00), 0, 5, StandardCharsets.UTF_8 }, new Object[] { "he", shortArrayToRegisterArray(0x6865, 0x6c6c, 0x6f00), 0, 2, StandardCharsets.UTF_8 }, // limited @@ -77,7 +74,7 @@ public static Collection data() { // out of bounds new Object[] { IllegalArgumentException.class, shortArrayToRegisterArray(0, 0), 0, 5, StandardCharsets.UTF_8 }) - .collect(Collectors.toList())); + .toList(); } public static Stream dataWithByteVariations() { diff --git a/bundles/org.openhab.core.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/WriteRequestJsonUtilitiesTest.java b/bundles/org.openhab.core.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/WriteRequestJsonUtilitiesTest.java index 260d0e3cf2c..7090b96c8e2 100644 --- a/bundles/org.openhab.core.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/WriteRequestJsonUtilitiesTest.java +++ b/bundles/org.openhab.core.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/WriteRequestJsonUtilitiesTest.java @@ -20,7 +20,6 @@ import java.util.Collection; import java.util.List; -import java.util.stream.Collectors; import java.util.stream.IntStream; import org.eclipse.jdt.annotation.NonNullByDefault; @@ -37,14 +36,13 @@ public class WriteRequestJsonUtilitiesTest { private static final List MAX_REGISTERS = IntStream.range(0, MAX_REGISTERS_WRITE_COUNT).mapToObj(i -> "1") - .collect(Collectors.toList()); + .toList(); private static final List 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 MAX_COILS = IntStream.range(0, MAX_BITS_WRITE_COUNT).mapToObj(i -> "1") - .collect(Collectors.toList()); + private static final List MAX_COILS = IntStream.range(0, MAX_BITS_WRITE_COUNT).mapToObj(i -> "1").toList(); private static final List OVER_MAX_COILS = IntStream.range(0, MAX_BITS_WRITE_COUNT + 1).mapToObj(i -> "1") - .collect(Collectors.toList()); + .toList(); @Test public void testEmptyArray() { diff --git a/bundles/org.openhab.core.io.transport.serial/src/main/java/org/openhab/core/io/transport/serial/internal/SerialPortRegistry.java b/bundles/org.openhab.core.io.transport.serial/src/main/java/org/openhab/core/io/transport/serial/internal/SerialPortRegistry.java index 2e46df1e99f..17c9f570762 100644 --- a/bundles/org.openhab.core.io.transport.serial/src/main/java/org/openhab/core/io/transport/serial/internal/SerialPortRegistry.java +++ b/bundles/org.openhab.core.io.transport.serial/src/main/java/org/openhab/core/io/transport/serial/internal/SerialPortRegistry.java @@ -17,7 +17,6 @@ import java.util.Collections; import java.util.HashSet; import java.util.function.Predicate; -import java.util.stream.Collectors; import org.eclipse.jdt.annotation.NonNullByDefault; import org.openhab.core.io.transport.serial.ProtocolType.PathType; @@ -79,7 +78,7 @@ public Collection getPortProvidersForPortName(URI portName) .count() > 0; } - return portCreators.stream().filter(filter).collect(Collectors.toList()); + return portCreators.stream().filter(filter).toList(); } public Collection getPortCreators() { diff --git a/bundles/org.openhab.core.io.transport.serial/src/main/java/org/openhab/core/io/transport/serial/internal/console/SerialCommandExtension.java b/bundles/org.openhab.core.io.transport.serial/src/main/java/org/openhab/core/io/transport/serial/internal/console/SerialCommandExtension.java index 521f1693f60..a643b8e7399 100644 --- a/bundles/org.openhab.core.io.transport.serial/src/main/java/org/openhab/core/io/transport/serial/internal/console/SerialCommandExtension.java +++ b/bundles/org.openhab.core.io.transport.serial/src/main/java/org/openhab/core/io/transport/serial/internal/console/SerialCommandExtension.java @@ -16,7 +16,6 @@ import java.util.Deque; import java.util.LinkedList; import java.util.List; -import java.util.stream.Collectors; import org.eclipse.jdt.annotation.Nullable; import org.openhab.core.io.console.Console; @@ -79,9 +78,8 @@ public void execute(String[] args, Console console) { case SUBCMD_PORT_CREATORS: serialPortRegistry.getPortCreators().forEach(provider -> { console.printf("%s, accepted protocols: %s, port identifiers: %s%n", provider.getClass(), - provider.getAcceptedProtocols().collect(Collectors.toList()), - provider.getSerialPortIdentifiers().map(SerialCommandExtension::str) - .collect(Collectors.toList())); + provider.getAcceptedProtocols().toList(), + provider.getSerialPortIdentifiers().map(SerialCommandExtension::str).toList()); }); return; default: diff --git a/bundles/org.openhab.core.karaf/src/main/java/org/openhab/core/karaf/internal/FeatureInstaller.java b/bundles/org.openhab.core.karaf/src/main/java/org/openhab/core/karaf/internal/FeatureInstaller.java index 5f49fa5f748..0d22594c6fd 100644 --- a/bundles/org.openhab.core.karaf/src/main/java/org/openhab/core/karaf/internal/FeatureInstaller.java +++ b/bundles/org.openhab.core.karaf/src/main/java/org/openhab/core/karaf/internal/FeatureInstaller.java @@ -89,8 +89,7 @@ public class FeatureInstaller implements ConfigurationListener { private static final String ADDONS_PID = "org.openhab.addons"; private static final String PROPERTY_MVN_REPOS = "org.ops4j.pax.url.mvn.repositories"; - public static final List ADDON_TYPES = AddonType.DEFAULT_TYPES.stream().map(AddonType::getId) - .collect(Collectors.toList()); + public static final List ADDON_TYPES = AddonType.DEFAULT_TYPES.stream().map(AddonType::getId).toList(); private final Logger logger = LoggerFactory.getLogger(FeatureInstaller.class); diff --git a/bundles/org.openhab.core.karaf/src/main/java/org/openhab/core/karaf/internal/LoggerBean.java b/bundles/org.openhab.core.karaf/src/main/java/org/openhab/core/karaf/internal/LoggerBean.java index 50a6369cfdf..4b29642fa9f 100644 --- a/bundles/org.openhab.core.karaf/src/main/java/org/openhab/core/karaf/internal/LoggerBean.java +++ b/bundles/org.openhab.core.karaf/src/main/java/org/openhab/core/karaf/internal/LoggerBean.java @@ -14,7 +14,6 @@ import java.util.List; import java.util.Map; -import java.util.stream.Collectors; import org.eclipse.jdt.annotation.NonNullByDefault; @@ -39,7 +38,6 @@ public LoggerInfo(String loggerName, String level) { } public LoggerBean(Map logLevels) { - loggers = logLevels.entrySet().stream().map(l -> new LoggerInfo(l.getKey(), l.getValue())) - .collect(Collectors.toList()); + loggers = logLevels.entrySet().stream().map(l -> new LoggerInfo(l.getKey(), l.getValue())).toList(); } } diff --git a/bundles/org.openhab.core.karaf/src/main/java/org/openhab/core/karaf/internal/jaas/ManagedUserBackingEngine.java b/bundles/org.openhab.core.karaf/src/main/java/org/openhab/core/karaf/internal/jaas/ManagedUserBackingEngine.java index 4215712d1cb..20eaa287a0e 100644 --- a/bundles/org.openhab.core.karaf/src/main/java/org/openhab/core/karaf/internal/jaas/ManagedUserBackingEngine.java +++ b/bundles/org.openhab.core.karaf/src/main/java/org/openhab/core/karaf/internal/jaas/ManagedUserBackingEngine.java @@ -18,7 +18,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.stream.Collectors; import org.apache.karaf.jaas.boot.principal.GroupPrincipal; import org.apache.karaf.jaas.boot.principal.RolePrincipal; @@ -54,7 +53,7 @@ public void deleteUser(String username) { @Override public List 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 @@ -95,7 +94,7 @@ public void deleteGroup(String username, String group) { public List listRoles(Principal principal) { User user = userRegistry.get(principal.getName()); 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(); } diff --git a/bundles/org.openhab.core.model.core/src/main/java/org/openhab/core/model/core/internal/ModelRepositoryImpl.java b/bundles/org.openhab.core.model.core/src/main/java/org/openhab/core/model/core/internal/ModelRepositoryImpl.java index 4b016f4d312..5a6eb142689 100644 --- a/bundles/org.openhab.core.model.core/src/main/java/org/openhab/core/model/core/internal/ModelRepositoryImpl.java +++ b/bundles/org.openhab.core.model.core/src/main/java/org/openhab/core/model/core/internal/ModelRepositoryImpl.java @@ -173,7 +173,7 @@ public Iterable getAllModelNamesOfType(final String modelType) { return resourceListCopy.stream() .filter(input -> input.getURI().lastSegment().contains(".") && input.isLoaded() && modelType.equalsIgnoreCase(input.getURI().fileExtension())) - .map(from -> from.getURI().path()).collect(Collectors.toList()); + .map(from -> from.getURI().path()).toList(); } } diff --git a/bundles/org.openhab.core.model.script.runtime/src/org/openhab/core/model/script/runtime/internal/engine/ScriptEngineImpl.java b/bundles/org.openhab.core.model.script.runtime/src/org/openhab/core/model/script/runtime/internal/engine/ScriptEngineImpl.java index faaa97a6fc7..0fadd736e9b 100644 --- a/bundles/org.openhab.core.model.script.runtime/src/org/openhab/core/model/script/runtime/internal/engine/ScriptEngineImpl.java +++ b/bundles/org.openhab.core.model.script.runtime/src/org/openhab/core/model/script/runtime/internal/engine/ScriptEngineImpl.java @@ -16,7 +16,6 @@ import java.nio.charset.StandardCharsets; import java.util.Collections; import java.util.List; -import java.util.stream.Collectors; import org.eclipse.emf.common.util.EList; import org.eclipse.emf.common.util.URI; @@ -179,7 +178,7 @@ protected List validate(EObject model) { protected Iterable getValidationErrors(final EObject model) { final List 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 diff --git a/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/actions/BusEvent.java b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/actions/BusEvent.java index c2cf8e1a3b1..15ccd3bb146 100644 --- a/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/actions/BusEvent.java +++ b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/actions/BusEvent.java @@ -16,7 +16,6 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; -import java.util.stream.Collectors; import org.openhab.core.events.EventPublisher; import org.openhab.core.items.GroupItem; @@ -98,7 +97,7 @@ public static Object sendCommand(String itemName, String commandString) { } private static List 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 static Object postUpdate(String itemName, String stateString) { } private static List getAcceptedDataTypeNames(Item item) { - return item.getAcceptedDataTypes().stream().map(t -> t.getSimpleName()).collect(Collectors.toList()); + return item.getAcceptedDataTypes().stream().map(Class::getSimpleName).toList(); } /** diff --git a/bundles/org.openhab.core.model.thing/src/org/openhab/core/model/thing/internal/GenericItemChannelLinkProvider.java b/bundles/org.openhab.core.model.thing/src/org/openhab/core/model/thing/internal/GenericItemChannelLinkProvider.java index a98595405ae..06c05c88aa3 100644 --- a/bundles/org.openhab.core.model.thing/src/org/openhab/core/model/thing/internal/GenericItemChannelLinkProvider.java +++ b/bundles/org.openhab.core.model.thing/src/org/openhab/core/model/thing/internal/GenericItemChannelLinkProvider.java @@ -19,7 +19,6 @@ import java.util.Optional; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; -import java.util.stream.Collectors; import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; @@ -142,6 +141,6 @@ public void stopConfigurationUpdate(String context) { @Override public Collection getAll() { - return itemChannelLinkMap.values().stream().flatMap(Collection::stream).collect(Collectors.toList()); + return itemChannelLinkMap.values().stream().flatMap(Collection::stream).toList(); } } diff --git a/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/internal/PersistenceManager.java b/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/internal/PersistenceManager.java index 26144f920af..040be881101 100644 --- a/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/internal/PersistenceManager.java +++ b/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/internal/PersistenceManager.java @@ -24,7 +24,6 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; -import java.util.stream.Collectors; import java.util.stream.Stream; import org.eclipse.jdt.annotation.NonNullByDefault; @@ -446,8 +445,7 @@ public void schedulePersistJobs() { .forEach(strategy -> { PersistenceCronStrategy cronStrategy = (PersistenceCronStrategy) strategy; String cronExpression = cronStrategy.getCronExpression(); - List itemConfigs = getMatchingConfigurations(strategy) - .collect(Collectors.toList()); + List itemConfigs = getMatchingConfigurations(strategy).toList(); jobs.add(scheduler.schedule(() -> persistJob(itemConfigs), cronExpression)); logger.debug("Scheduled strategy {} with cron expression {} for service {}", diff --git a/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/internal/metadata/MagicMetadataProvider.java b/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/internal/metadata/MagicMetadataProvider.java index 3052de47c23..990fa604d0c 100644 --- a/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/internal/metadata/MagicMetadataProvider.java +++ b/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/internal/metadata/MagicMetadataProvider.java @@ -12,7 +12,6 @@ */ package org.openhab.core.magic.internal.metadata; -import static java.util.stream.Collectors.toList; import static org.openhab.core.config.core.ConfigDescriptionParameterBuilder.create; import java.util.List; @@ -51,7 +50,7 @@ public String getNamespace() { return Stream.of( // new ParameterOption("just", "Just Magic"), // new ParameterOption("pure", "Pure Magic") // - ).collect(toList()); + ).toList(); } @Override @@ -60,7 +59,7 @@ public String getNamespace() { case "just": return Stream.of( // create("electric", Type.BOOLEAN).withLabel("Use Electricity").build() // - ).collect(toList()); + ).toList(); case "pure": return Stream.of( // create("spell", Type.TEXT).withLabel("Spell").withDescription("The exact spell to use").build(), // @@ -72,8 +71,8 @@ public String getNamespace() { new ParameterOption("1", "Incredible"), // new ParameterOption("2", "Insane"), // new ParameterOption("3", "Ludicrous") // - ).collect(toList())).build() // - ).collect(toList()); + ).toList()).build() // + ).toList(); } return null; } diff --git a/bundles/org.openhab.core.test/src/main/java/org/openhab/core/test/internal/java/MissingServiceAnalyzer.java b/bundles/org.openhab.core.test/src/main/java/org/openhab/core/test/internal/java/MissingServiceAnalyzer.java index 64441bc562d..48bd23e5025 100644 --- a/bundles/org.openhab.core.test/src/main/java/org/openhab/core/test/internal/java/MissingServiceAnalyzer.java +++ b/bundles/org.openhab.core.test/src/main/java/org/openhab/core/test/internal/java/MissingServiceAnalyzer.java @@ -91,19 +91,19 @@ private List getUnsatisfiedReferences(ComponentDescriptionDTO desc .collect(toSet()); return Stream.of(description.references) // .filter(ref -> unsatisfiedRefNames.contains(ref.name)) // - .collect(toList()); + .toList(); } private List getComponentDescriptions(ServiceComponentRuntime scr, String interfaceName, Bundle[] allBundlesArrays) { return scr.getComponentDescriptionDTOs(allBundlesArrays).stream() .filter(description -> Stream.of(description.serviceInterfaces).anyMatch(s -> s.equals(interfaceName))) - .collect(toList()); + .toList(); } private Bundle[] getAllBundles() { List 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()]); } diff --git a/bundles/org.openhab.core.test/src/main/java/org/openhab/core/test/java/JavaOSGiTest.java b/bundles/org.openhab.core.test/src/main/java/org/openhab/core/test/java/JavaOSGiTest.java index 4f944c548da..73c09d85e2e 100644 --- a/bundles/org.openhab.core.test/src/main/java/org/openhab/core/test/java/JavaOSGiTest.java +++ b/bundles/org.openhab.core.test/src/main/java/org/openhab/core/test/java/JavaOSGiTest.java @@ -24,7 +24,6 @@ import java.util.List; import java.util.Map; import java.util.function.Predicate; -import java.util.stream.Collectors; import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; @@ -118,11 +117,11 @@ protected List getServices(Class clazz, Predicate> return Collections.emptyList(); } - return Arrays // + return (List) Arrays // .stream(serviceReferences) // .filter(filter) // apply the predicate .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 @@ protected List getServices(Class clazz, Class implemen .map(this::unrefService) // get the actual services from the references .filter(implementationClass::isInstance) // check that are of 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 @@ private void saveServiceRegistration(final String interfaceName, final ServiceRe * The given interface names are used as OSGi service interface name. * * @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 * @return service registration object */ diff --git a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/AbstractStorageBasedTypeProvider.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/AbstractStorageBasedTypeProvider.java index 1a646a5389d..b6f4740115c 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/AbstractStorageBasedTypeProvider.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/AbstractStorageBasedTypeProvider.java @@ -20,7 +20,6 @@ import java.util.Map; import java.util.Objects; import java.util.Set; -import java.util.stream.Collectors; import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; @@ -199,7 +198,7 @@ static ThingTypeEntity mapToEntity(ThingType thingType) { entity.configDescriptionUri = thingType.getConfigDescriptionURI(); entity.category = thingType.getCategory(); entity.channelGroupDefinitions = thingType.getChannelGroupDefinitions().stream() - .map(AbstractStorageBasedTypeProvider::mapToEntity).collect(Collectors.toList()); + .map(AbstractStorageBasedTypeProvider::mapToEntity).toList(); entity.channelDefinitions = thingType.getChannelDefinitions().stream() .map(AbstractStorageBasedTypeProvider::mapToEntity).toList(); entity.representationProperty = thingType.getRepresentationProperty(); diff --git a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/AutoUpdateConfigDescriptionProvider.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/AutoUpdateConfigDescriptionProvider.java index b8c45a9be7e..ea1c3b93d8d 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/AutoUpdateConfigDescriptionProvider.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/AutoUpdateConfigDescriptionProvider.java @@ -12,8 +12,6 @@ */ package org.openhab.core.thing.internal; -import static java.util.stream.Collectors.toList; - import java.util.List; import java.util.Locale; import java.util.stream.Stream; @@ -49,7 +47,7 @@ public String getNamespace() { return Stream.of( // new ParameterOption("true", "Enforce an auto update"), // new ParameterOption("false", "Veto an auto update") // - ).collect(toList()); + ).toList(); } @Override diff --git a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/firmware/FirmwareRegistryImpl.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/firmware/FirmwareRegistryImpl.java index fb3b05f58cd..d7d5bbb1211 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/firmware/FirmwareRegistryImpl.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/firmware/FirmwareRegistryImpl.java @@ -20,7 +20,6 @@ import java.util.Set; import java.util.TreeSet; import java.util.concurrent.CopyOnWriteArrayList; -import java.util.stream.Collectors; import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; @@ -121,9 +120,7 @@ public Collection getFirmwares(Thing thing, @Nullable Locale locale) { try { Collection result = firmwareProvider.getFirmwares(thing, loc); if (result != null) { - List suitableFirmwares = result.stream().filter(firmware -> firmware.isSuitableFor(thing)) - .collect(Collectors.toList()); - firmwares.addAll(suitableFirmwares); + result.stream().filter(firmware -> firmware.isSuitableFor(thing)).forEach(firmwares::add); } } catch (Exception e) { logger.warn( diff --git a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/link/ItemChannelLinkConfigDescriptionProvider.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/link/ItemChannelLinkConfigDescriptionProvider.java index 4261f215504..00694f6c6f9 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/link/ItemChannelLinkConfigDescriptionProvider.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/link/ItemChannelLinkConfigDescriptionProvider.java @@ -17,7 +17,6 @@ import java.util.List; import java.util.Locale; import java.util.Set; -import java.util.stream.Collectors; import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; @@ -116,8 +115,7 @@ private List getOptions(ItemChannelLink link, Item item, Channe default: throw new IllegalArgumentException("Unknown channel kind: " + channel.getKind()); } - }).map(profileType -> new ParameterOption(profileType.getUID().toString(), profileType.getLabel())) - .collect(Collectors.toList()); + }).map(profileType -> new ParameterOption(profileType.getUID().toString(), profileType.getLabel())).toList(); } private boolean isSupportedItemType(ProfileType profileType, Item item) { diff --git a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/profiles/SystemProfileFactory.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/profiles/SystemProfileFactory.java index 3fc73152db4..c5ffdc4b69f 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/profiles/SystemProfileFactory.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/profiles/SystemProfileFactory.java @@ -15,12 +15,10 @@ import static org.openhab.core.thing.profiles.SystemProfiles.*; import java.util.Collection; -import java.util.Collections; import java.util.Locale; import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; -import java.util.stream.Collectors; import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; @@ -219,8 +217,7 @@ public SystemProfileFactory(final @Reference ChannelTypeRegistry channelTypeRegi @Override public Collection getProfileTypes(@Nullable Locale locale) { - return Collections.unmodifiableList(SUPPORTED_PROFILE_TYPES.stream() - .map(p -> createLocalizedProfileType(p, locale)).collect(Collectors.toList())); + return SUPPORTED_PROFILE_TYPES.stream().map(p -> createLocalizedProfileType(p, locale)).toList(); } @Override diff --git a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/xml/internal/ThingTypeConverter.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/xml/internal/ThingTypeConverter.java index 1f17c8843e3..6164f20dd25 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/xml/internal/ThingTypeConverter.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/xml/internal/ThingTypeConverter.java @@ -12,8 +12,6 @@ */ package org.openhab.core.thing.xml.internal; -import static java.util.stream.Collectors.toList; - import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -116,7 +114,7 @@ protected List getExtensibleChannelTypeIds(Map attribute 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) { diff --git a/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/util/ThingHelperTest.java b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/util/ThingHelperTest.java index 3a5f96e0e85..056f40cdcd5 100644 --- a/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/util/ThingHelperTest.java +++ b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/util/ThingHelperTest.java @@ -12,7 +12,6 @@ */ package org.openhab.core.thing.util; -import static java.util.stream.Collectors.toList; import static org.junit.jupiter.api.Assertions.*; import java.util.List; @@ -138,10 +137,11 @@ public void assertThatNoDuplicateChannelsCanBeAdded() { .build(); assertThrows(IllegalArgumentException.class, - () -> ThingHelper.addChannelsToThing(thing, - Stream.of(ChannelBuilder.create(new ChannelUID(thingUID, "channel2"), "").build(), - ChannelBuilder.create(new ChannelUID(thingUID, "channel3"), "").build()) - .collect(toList()))); + () -> ThingHelper + .addChannelsToThing(thing, + Stream.of(ChannelBuilder.create(new ChannelUID(thingUID, "channel2"), "").build(), + ChannelBuilder.create(new ChannelUID(thingUID, "channel3"), "").build()) + .toList())); } @Test diff --git a/bundles/org.openhab.core.transform/src/main/java/org/openhab/core/transform/AbstractFileTransformationService.java b/bundles/org.openhab.core.transform/src/main/java/org/openhab/core/transform/AbstractFileTransformationService.java index 0de4a6838cd..91e35fc936a 100644 --- a/bundles/org.openhab.core.transform/src/main/java/org/openhab/core/transform/AbstractFileTransformationService.java +++ b/bundles/org.openhab.core.transform/src/main/java/org/openhab/core/transform/AbstractFileTransformationService.java @@ -29,7 +29,6 @@ import java.util.Locale; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; -import java.util.stream.Collectors; import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; @@ -296,8 +295,7 @@ protected String getSourcePath() { */ protected List getFilenames(String[] validExtensions) { File path = new File(getSourcePath()); - return Arrays.asList(path.listFiles(new FileExtensionsFilter(validExtensions))).stream().map(f -> f.getName()) - .collect(Collectors.toList()); + return Arrays.stream(path.listFiles(new FileExtensionsFilter(validExtensions))).map(File::getName).toList(); } protected class FileExtensionsFilter implements FilenameFilter { diff --git a/bundles/org.openhab.core.transform/src/main/java/org/openhab/core/transform/internal/TransformationRegistryImpl.java b/bundles/org.openhab.core.transform/src/main/java/org/openhab/core/transform/internal/TransformationRegistryImpl.java index bb18679fbb8..f6b4b0aba3a 100644 --- a/bundles/org.openhab.core.transform/src/main/java/org/openhab/core/transform/internal/TransformationRegistryImpl.java +++ b/bundles/org.openhab.core.transform/src/main/java/org/openhab/core/transform/internal/TransformationRegistryImpl.java @@ -17,7 +17,6 @@ import java.util.Objects; import java.util.regex.Matcher; import java.util.regex.Pattern; -import java.util.stream.Collectors; import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; @@ -82,7 +81,7 @@ public TransformationRegistryImpl(@Reference LocaleProvider localeProvider) { @Override public Collection getTransformations(Collection 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) diff --git a/bundles/org.openhab.core.voice/src/main/java/org/openhab/core/voice/internal/DialogProcessor.java b/bundles/org.openhab.core.voice/src/main/java/org/openhab/core/voice/internal/DialogProcessor.java index d171d989cd5..2df6b01c752 100644 --- a/bundles/org.openhab.core.voice/src/main/java/org/openhab/core/voice/internal/DialogProcessor.java +++ b/bundles/org.openhab.core.voice/src/main/java/org/openhab/core/voice/internal/DialogProcessor.java @@ -18,7 +18,6 @@ import java.util.List; import java.util.Objects; import java.util.WeakHashMap; -import java.util.stream.Collectors; import java.util.stream.Stream; import org.eclipse.jdt.annotation.NonNullByDefault; @@ -426,12 +425,12 @@ protected void say(@Nullable String text) { private void playStartSound() { 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() { 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() { diff --git a/bundles/org.openhab.core.voice/src/main/java/org/openhab/core/voice/internal/VoiceConsoleCommandExtension.java b/bundles/org.openhab.core.voice/src/main/java/org/openhab/core/voice/internal/VoiceConsoleCommandExtension.java index 7817952d31c..08f942700fa 100644 --- a/bundles/org.openhab.core.voice/src/main/java/org/openhab/core/voice/internal/VoiceConsoleCommandExtension.java +++ b/bundles/org.openhab.core.voice/src/main/java/org/openhab/core/voice/internal/VoiceConsoleCommandExtension.java @@ -492,7 +492,7 @@ private DialogRegistration parseDialogRegistration(String[] args) { String hliIds = parameters.remove("hlis"); 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()) { throw new IllegalStateException( diff --git a/bundles/org.openhab.core.voice/src/main/java/org/openhab/core/voice/internal/VoiceManagerImpl.java b/bundles/org.openhab.core.voice/src/main/java/org/openhab/core/voice/internal/VoiceManagerImpl.java index 6b5c5285002..070bf0824c7 100644 --- a/bundles/org.openhab.core.voice/src/main/java/org/openhab/core/voice/internal/VoiceManagerImpl.java +++ b/bundles/org.openhab.core.voice/src/main/java/org/openhab/core/voice/internal/VoiceManagerImpl.java @@ -500,7 +500,7 @@ public DialogContext.Builder getDialogContextBuilder() { @Override public List getDialogsContexts() { - return dialogProcessors.values().stream().map(DialogProcessor::getContext).collect(Collectors.toList()); + return dialogProcessors.values().stream().map(DialogProcessor::getContext).toList(); } @Override @@ -900,30 +900,27 @@ private Comparator createVoiceComparator(Locale locale) { case CONFIG_DEFAULT_HLI: return humanLanguageInterpreters.values().stream() .sorted((hli1, hli2) -> hli1.getLabel(locale).compareToIgnoreCase(hli2.getLabel(locale))) - .map(hli -> new ParameterOption(hli.getId(), hli.getLabel(locale))) - .collect(Collectors.toList()); + .map(hli -> new ParameterOption(hli.getId(), hli.getLabel(locale))).toList(); case CONFIG_DEFAULT_KS: return ksServices.values().stream() .sorted((ks1, ks2) -> ks1.getLabel(locale).compareToIgnoreCase(ks2.getLabel(locale))) - .map(ks -> new ParameterOption(ks.getId(), ks.getLabel(locale))) - .collect(Collectors.toList()); + .map(ks -> new ParameterOption(ks.getId(), ks.getLabel(locale))).toList(); case CONFIG_DEFAULT_STT: return sttServices.values().stream() .sorted((stt1, stt2) -> stt1.getLabel(locale).compareToIgnoreCase(stt2.getLabel(locale))) - .map(stt -> new ParameterOption(stt.getId(), stt.getLabel(locale))) - .collect(Collectors.toList()); + .map(stt -> new ParameterOption(stt.getId(), stt.getLabel(locale))).toList(); case CONFIG_DEFAULT_TTS: return ttsServices.values().stream() .sorted((tts1, tts2) -> tts1.getLabel(locale).compareToIgnoreCase(tts2.getLabel(locale))) - .map(tts -> new ParameterOption(tts.getId(), tts.getLabel(locale))) - .collect(Collectors.toList()); + .map(tts -> new ParameterOption(tts.getId(), tts.getLabel(locale))).toList(); case CONFIG_DEFAULT_VOICE: Locale nullSafeLocale = locale != null ? locale : localeProvider.getLocale(); - return getAllVoicesSorted(nullSafeLocale).stream().filter(v -> getTTS(v) != null) - .map(v -> new ParameterOption(v.getUID(), - String.format("%s - %s - %s", getTTS(v).getLabel(nullSafeLocale), - v.getLocale().getDisplayName(nullSafeLocale), v.getLabel()))) - .collect(Collectors.toList()); + return getAllVoicesSorted(nullSafeLocale) + .stream().filter(v -> getTTS(v) != null).map( + v -> new ParameterOption(v.getUID(), + String.format("%s - %s - %s", getTTS(v).getLabel(nullSafeLocale), + v.getLocale().getDisplayName(nullSafeLocale), v.getLabel()))) + .toList(); } } return null; diff --git a/bundles/org.openhab.core.voice/src/main/java/org/openhab/core/voice/text/TokenList.java b/bundles/org.openhab.core.voice/src/main/java/org/openhab/core/voice/text/TokenList.java index f69485090c2..3155b5b5208 100644 --- a/bundles/org.openhab.core.voice/src/main/java/org/openhab/core/voice/text/TokenList.java +++ b/bundles/org.openhab.core.voice/src/main/java/org/openhab/core/voice/text/TokenList.java @@ -12,8 +12,6 @@ */ package org.openhab.core.voice.text; -import java.util.ArrayList; -import java.util.Collections; import java.util.List; /** @@ -34,7 +32,7 @@ public class TokenList { * @param list of the initial tokens */ public TokenList(List list) { - this.list = Collections.unmodifiableList(new ArrayList<>(list)); + this.list = List.copyOf(list); this.head = 0; this.tail = list.size() - 1; } diff --git a/bundles/org.openhab.core/src/main/java/org/openhab/core/common/registry/AbstractManagedProvider.java b/bundles/org.openhab.core/src/main/java/org/openhab/core/common/registry/AbstractManagedProvider.java index 0a1e183cbe1..de3679885b4 100644 --- a/bundles/org.openhab.core/src/main/java/org/openhab/core/common/registry/AbstractManagedProvider.java +++ b/bundles/org.openhab.core/src/main/java/org/openhab/core/common/registry/AbstractManagedProvider.java @@ -14,7 +14,6 @@ import java.util.Collection; import java.util.Objects; -import java.util.stream.Collectors; import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jdt.annotation.NonNullByDefault; @@ -70,8 +69,7 @@ public void add(E element) { @Override public Collection getAll() { - return (Collection) storage.getKeys().stream().map(this::getElement).filter(Objects::nonNull) - .collect(Collectors.toList()); + return (Collection) storage.getKeys().stream().map(this::getElement).filter(Objects::nonNull).toList(); } @Override diff --git a/bundles/org.openhab.core/src/main/java/org/openhab/core/internal/items/ItemRegistryImpl.java b/bundles/org.openhab.core/src/main/java/org/openhab/core/internal/items/ItemRegistryImpl.java index daeba98f4c8..0d16988214e 100644 --- a/bundles/org.openhab.core/src/main/java/org/openhab/core/internal/items/ItemRegistryImpl.java +++ b/bundles/org.openhab.core/src/main/java/org/openhab/core/internal/items/ItemRegistryImpl.java @@ -12,8 +12,6 @@ */ package org.openhab.core.internal.items; -import static java.util.stream.Collectors.toList; - import java.util.ArrayList; import java.util.Collection; import java.util.List; @@ -262,11 +260,11 @@ protected void onUpdateElement(Item oldItem, Item item) { // don't use #initialize and retain order of items in groups: List oldNames = oldItem.getGroupNames(); List newNames = item.getGroupNames(); - List commonNames = oldNames.stream().filter(newNames::contains).collect(toList()); + List 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); - 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) { addMembersToGroupItem(groupItem); } diff --git a/bundles/org.openhab.core/src/main/java/org/openhab/core/internal/items/MetadataStateDescriptionFragmentProvider.java b/bundles/org.openhab.core/src/main/java/org/openhab/core/internal/items/MetadataStateDescriptionFragmentProvider.java index a61bd846e64..04a50dd25aa 100644 --- a/bundles/org.openhab.core/src/main/java/org/openhab/core/internal/items/MetadataStateDescriptionFragmentProvider.java +++ b/bundles/org.openhab.core/src/main/java/org/openhab/core/internal/items/MetadataStateDescriptionFragmentProvider.java @@ -19,7 +19,6 @@ import java.util.List; import java.util.Locale; import java.util.Map; -import java.util.stream.Collectors; import java.util.stream.Stream; import org.eclipse.jdt.annotation.NonNullByDefault; @@ -111,7 +110,7 @@ public MetadataStateDescriptionFragmentProvider(final @Reference MetadataRegistr } else { return new StateOption(o.trim(), null); } - }).collect(Collectors.toList()); + }).toList(); builder.withOptions(stateOptions); } diff --git a/bundles/org.openhab.core/src/main/java/org/openhab/core/items/GenericItem.java b/bundles/org.openhab.core/src/main/java/org/openhab/core/items/GenericItem.java index f7ab33b0311..f72c5d0b28d 100644 --- a/bundles/org.openhab.core/src/main/java/org/openhab/core/items/GenericItem.java +++ b/bundles/org.openhab.core/src/main/java/org/openhab/core/items/GenericItem.java @@ -116,7 +116,7 @@ public String getType() { @Override public List getGroupNames() { - return Collections.unmodifiableList(new ArrayList<>(groupNames)); + return List.copyOf(groupNames); } /** diff --git a/bundles/org.openhab.core/src/main/java/org/openhab/core/library/types/HSBType.java b/bundles/org.openhab.core/src/main/java/org/openhab/core/library/types/HSBType.java index 5744ae67b10..676420a35ee 100644 --- a/bundles/org.openhab.core/src/main/java/org/openhab/core/library/types/HSBType.java +++ b/bundles/org.openhab.core/src/main/java/org/openhab/core/library/types/HSBType.java @@ -18,7 +18,6 @@ import java.util.List; import java.util.SortedMap; import java.util.TreeMap; -import java.util.stream.Collectors; import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; @@ -86,7 +85,7 @@ public HSBType(DecimalType h, PercentType s, PercentType b) { * @param value a stringified HSBType value in the format "hue,saturation,brightness" */ public HSBType(String value) { - List constituents = Arrays.stream(value.split(",")).map(String::trim).collect(Collectors.toList()); + List constituents = Arrays.stream(value.split(",")).map(String::trim).toList(); if (constituents.size() == 3) { this.hue = new BigDecimal(constituents.get(0)); this.saturation = new BigDecimal(constituents.get(1)); diff --git a/bundles/org.openhab.core/src/main/java/org/openhab/core/library/types/PointType.java b/bundles/org.openhab.core/src/main/java/org/openhab/core/library/types/PointType.java index 40db3682d20..216c45ca96d 100644 --- a/bundles/org.openhab.core/src/main/java/org/openhab/core/library/types/PointType.java +++ b/bundles/org.openhab.core/src/main/java/org/openhab/core/library/types/PointType.java @@ -18,7 +18,6 @@ import java.util.List; import java.util.SortedMap; import java.util.TreeMap; -import java.util.stream.Collectors; import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; @@ -85,7 +84,7 @@ public PointType(StringType latitude, StringType longitude, StringType altitude) public PointType(String value) { if (!value.isEmpty()) { - List elements = Arrays.stream(value.split(",")).map(String::trim).collect(Collectors.toList()); + List elements = Arrays.stream(value.split(",")).map(String::trim).toList(); if (elements.size() >= 2) { canonicalize(new DecimalType(elements.get(0)), new DecimalType(elements.get(1))); if (elements.size() == 3) { diff --git a/bundles/org.openhab.core/src/main/java/org/openhab/core/library/types/StringListType.java b/bundles/org.openhab.core/src/main/java/org/openhab/core/library/types/StringListType.java index c2edc1b4e8d..416134f0da3 100644 --- a/bundles/org.openhab.core/src/main/java/org/openhab/core/library/types/StringListType.java +++ b/bundles/org.openhab.core/src/main/java/org/openhab/core/library/types/StringListType.java @@ -49,7 +49,7 @@ public StringListType(List 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) { @@ -61,7 +61,7 @@ public StringListType(String... rows) { */ public StringListType(String serialized) { 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) { diff --git a/bundles/org.openhab.core/src/main/java/org/openhab/core/net/NetUtil.java b/bundles/org.openhab.core/src/main/java/org/openhab/core/net/NetUtil.java index b213d6718f7..d20f624a7cf 100644 --- a/bundles/org.openhab.core/src/main/java/org/openhab/core/net/NetUtil.java +++ b/bundles/org.openhab.core/src/main/java/org/openhab/core/net/NetUtil.java @@ -34,7 +34,6 @@ import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; import java.util.regex.Pattern; -import java.util.stream.Collectors; import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; @@ -319,7 +318,7 @@ public static List getAllBroadcastAddresses() { * * Example to get a list of only IPv4 addresses in string representation: * List 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. * @@ -531,19 +530,20 @@ private void pollAndNotifyNetworkInterfaceAddress() { // Look for added addresses to notify List added = newInterfaceAddresses.stream() - .filter(newInterfaceAddr -> !lastKnownInterfaceAddresses.contains(newInterfaceAddr)) - .collect(Collectors.toList()); + .filter(newInterfaceAddr -> !lastKnownInterfaceAddresses.contains(newInterfaceAddr)).toList(); // Look for removed addresses to notify List removed = lastKnownInterfaceAddresses.stream() - .filter(lastKnownInterfaceAddr -> !newInterfaceAddresses.contains(lastKnownInterfaceAddr)) - .collect(Collectors.toList()); + .filter(lastKnownInterfaceAddr -> !newInterfaceAddresses.contains(lastKnownInterfaceAddr)).toList(); lastKnownInterfaceAddresses = newInterfaceAddresses; if (!added.isEmpty() || !removed.isEmpty()) { - LOGGER.debug("added {} network interfaces: {}", added.size(), Arrays.deepToString(added.toArray())); - LOGGER.debug("removed {} network interfaces: {}", removed.size(), Arrays.deepToString(removed.toArray())); + if (LOGGER.isDebugEnabled()) { + 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); } diff --git a/bundles/org.openhab.core/src/test/java/org/openhab/core/cache/lru/LRUMediaCacheEntryTest.java b/bundles/org.openhab.core/src/test/java/org/openhab/core/cache/lru/LRUMediaCacheEntryTest.java index 619ee0c0923..ffdc89ecc63 100644 --- a/bundles/org.openhab.core/src/test/java/org/openhab/core/cache/lru/LRUMediaCacheEntryTest.java +++ b/bundles/org.openhab.core/src/test/java/org/openhab/core/cache/lru/LRUMediaCacheEntryTest.java @@ -24,7 +24,6 @@ import java.util.List; import java.util.Random; import java.util.function.Supplier; -import java.util.stream.Collectors; import org.apache.commons.lang3.mutable.Mutable; import org.apache.commons.lang3.mutable.MutableObject; @@ -202,7 +201,7 @@ public void loadTwoThreadsAtTheSameTimeFromTheSameSupplierTest() throws IOExcept exceptionCatched.setValue(e); return new byte[0]; } - }).collect(Collectors.toList()); + }).toList(); IOException possibleException = exceptionCatched.getValue(); if (possibleException != null) { diff --git a/itests/org.openhab.core.automation.integration.tests/src/main/java/org/openhab/core/automation/integration/test/AutomationIntegrationTest.java b/itests/org.openhab.core.automation.integration.tests/src/main/java/org/openhab/core/automation/integration/test/AutomationIntegrationTest.java index 167371f7c40..62d2c321bd1 100644 --- a/itests/org.openhab.core.automation.integration.tests/src/main/java/org/openhab/core/automation/integration/test/AutomationIntegrationTest.java +++ b/itests/org.openhab.core.automation.integration.tests/src/main/java/org/openhab/core/automation/integration/test/AutomationIntegrationTest.java @@ -919,7 +919,7 @@ public void assertARuleWithGenericConditionWorks() throws ItemNotFoundException ModuleBuilder.createCondition().withId("ItemStateCondition" + (random + 1)) .withTypeUID("core.GenericCompareCondition").withConfiguration(condition2Config) .withInputs(Map.of("input", triggerId + ".event")).build()) - .collect(toList()); + .toList(); List actions = List.of(ModuleBuilder.createAction().withId("ItemPostCommandAction" + random) .withTypeUID("core.ItemCommandAction").withConfiguration(actionConfig).build()); diff --git a/itests/org.openhab.core.automation.integration.tests/src/main/java/org/openhab/core/automation/integration/test/RuleSimulationTest.java b/itests/org.openhab.core.automation.integration.tests/src/main/java/org/openhab/core/automation/integration/test/RuleSimulationTest.java index 3852e61c248..66b3dc2dcb0 100644 --- a/itests/org.openhab.core.automation.integration.tests/src/main/java/org/openhab/core/automation/integration/test/RuleSimulationTest.java +++ b/itests/org.openhab.core.automation.integration.tests/src/main/java/org/openhab/core/automation/integration/test/RuleSimulationTest.java @@ -31,7 +31,6 @@ import java.util.Map; import java.util.Random; import java.util.Set; -import java.util.stream.Collectors; import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; @@ -147,7 +146,7 @@ public void removeProviderChangeListener(ProviderChangeListener listener) 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()); - List executions = ruleEngine.simulateRuleExecutions(from, until).collect(Collectors.toList()); + List executions = ruleEngine.simulateRuleExecutions(from, until).toList(); // 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. diff --git a/itests/org.openhab.core.automation.tests/src/main/java/org/openhab/core/automation/event/RuleEventTest.java b/itests/org.openhab.core.automation.tests/src/main/java/org/openhab/core/automation/event/RuleEventTest.java index 78ef39f2280..ca1205606b3 100644 --- a/itests/org.openhab.core.automation.tests/src/main/java/org/openhab/core/automation/event/RuleEventTest.java +++ b/itests/org.openhab.core.automation.tests/src/main/java/org/openhab/core/automation/event/RuleEventTest.java @@ -25,7 +25,6 @@ import java.util.Objects; import java.util.Optional; import java.util.Set; -import java.util.stream.Collectors; import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; @@ -199,7 +198,7 @@ public Set getSubscribedEventTypes() { assertThat(ruleEvents.stream().filter(e -> "openhab/rules/myRule21/state".equals(e.getTopic())).findFirst() .isPresent(), is(true)); List stateEvents = ruleEvents.stream().filter(e -> "openhab/rules/myRule21/state".equals(e.getTopic())) - .collect(Collectors.toList()); + .toList(); assertThat(stateEvents, is(notNullValue())); Optional runningEvent = stateEvents.stream() .filter(e -> ((RuleStatusInfoEvent) e).getStatusInfo().getStatus() == RuleStatus.RUNNING).findFirst(); diff --git a/itests/org.openhab.core.automation.tests/src/main/java/org/openhab/core/automation/internal/RuleRegistryTest.java b/itests/org.openhab.core.automation.tests/src/main/java/org/openhab/core/automation/internal/RuleRegistryTest.java index 25439da0797..0189761dfe4 100644 --- a/itests/org.openhab.core.automation.tests/src/main/java/org/openhab/core/automation/internal/RuleRegistryTest.java +++ b/itests/org.openhab.core.automation.tests/src/main/java/org/openhab/core/automation/internal/RuleRegistryTest.java @@ -19,7 +19,6 @@ import java.util.HashSet; import java.util.Set; import java.util.function.Predicate; -import java.util.stream.Collectors; import org.eclipse.jdt.annotation.NonNullByDefault; import org.junit.jupiter.api.BeforeEach; @@ -82,13 +81,12 @@ public void testAddRetrieveRules() { //////////////////////////////////////////////////////////////////////////////////////////////////////////////// // 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 //////////////////////////////////////////////////////////////////////////////////////////////////////////////// - assertEquals(1, ruleRegistry.stream().filter(hasNoTags()).collect(Collectors.toList()).size(), - "RuleImpl list size"); + assertEquals(1, ruleRegistry.stream().filter(hasNoTags()).toList().size(), "RuleImpl list size"); //////////////////////////////////////////////////////////////////////////////////////////////////////////////// // checking rule with 1 tag @@ -112,7 +110,7 @@ public void testAddRetrieveRules() { //////////////////////////////////////////////////////////////////////////////////////////////////////////////// // 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 rulesWithTag1 = ruleRegistry.getByTags(tag1); assertEquals(1, rulesWithTag1.size(), "RuleImpl list size"); @@ -120,18 +118,13 @@ public void testAddRetrieveRules() { //////////////////////////////////////////////////////////////////////////////////////////////////////////////// // checking predicates //////////////////////////////////////////////////////////////////////////////////////////////////////////////// - assertEquals(1, ruleRegistry.stream().filter(hasNoTags()).collect(Collectors.toList()).size(), - "RuleImpl list size"); + assertEquals(1, ruleRegistry.stream().filter(hasNoTags()).toList().size(), "RuleImpl list size"); - assertEquals(1, ruleRegistry.stream().filter(hasAnyOfTags(tags)).collect(Collectors.toList()).size(), - "RuleImpl list size"); - assertEquals(1, ruleRegistry.stream().filter(hasAnyOfTags(tag1)).collect(Collectors.toList()).size(), - "RuleImpl list size"); + assertEquals(1, ruleRegistry.stream().filter(hasAnyOfTags(tags)).toList().size(), "RuleImpl list size"); + assertEquals(1, ruleRegistry.stream().filter(hasAnyOfTags(tag1)).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)).collect(Collectors.toList()).size(), - "RuleImpl list size"); + assertEquals(1, ruleRegistry.stream().filter(hasAllTags(tags)).toList().size(), "RuleImpl list size"); + assertEquals(1, ruleRegistry.stream().filter(hasAllTags(tag1)).toList().size(), "RuleImpl list size"); //////////////////////////////////////////////////////////////////////////////////////////////////////////////// // checking rule with 2 tags @@ -156,7 +149,7 @@ public void testAddRetrieveRules() { //////////////////////////////////////////////////////////////////////////////////////////////////////////////// // 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); assertEquals(2, rulesWithTag1.size(), "RuleImpl list size"); @@ -170,35 +163,26 @@ public void testAddRetrieveRules() { //////////////////////////////////////////////////////////////////////////////////////////////////////////////// // checking predicates //////////////////////////////////////////////////////////////////////////////////////////////////////////////// - assertEquals(1, ruleRegistry.stream().filter(hasNoTags()).collect(Collectors.toList()).size(), - "RuleImpl list size"); + assertEquals(1, ruleRegistry.stream().filter(hasNoTags()).toList().size(), "RuleImpl list size"); - assertEquals(2, ruleRegistry.stream().filter(hasAnyOfTags(tags)).collect(Collectors.toList()).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(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(tag2)).collect(Collectors.toList()).size(), + assertEquals(1, ruleRegistry.stream().filter(hasAnyOfTags(tag1).and(hasAnyOfTags(tag2))).toList().size(), "RuleImpl list size"); - assertEquals(1, ruleRegistry.stream().filter(hasAnyOfTags(tag1).and(hasAnyOfTags(tag2))) - .collect(Collectors.toList()).size(), "RuleImpl list size"); + assertEquals(2, ruleRegistry.stream().filter(hasAllTags(tag1)).toList().size(), "RuleImpl list size"); - assertEquals(2, ruleRegistry.stream().filter(hasAllTags(tag1)).collect(Collectors.toList()).size(), - "RuleImpl list size"); + assertEquals(1, ruleRegistry.stream().filter(hasAllTags(tags)).toList().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(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(), + assertEquals(1, ruleRegistry.stream().filter(hasAllTags(tag1).and(hasAllTags(tag2))).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 //////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -223,7 +207,7 @@ public void testAddRetrieveRules() { //////////////////////////////////////////////////////////////////////////////////////////////////////////////// // 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); assertEquals(3, rulesWithTag1.size(), "RuleImpl list size"); @@ -246,46 +230,34 @@ public void testAddRetrieveRules() { //////////////////////////////////////////////////////////////////////////////////////////////////////////////// // checking predicates //////////////////////////////////////////////////////////////////////////////////////////////////////////////// - assertEquals(1, ruleRegistry.stream().filter(hasNoTags()).collect(Collectors.toList()).size(), - "RuleImpl list size"); + assertEquals(1, ruleRegistry.stream().filter(hasNoTags()).toList().size(), "RuleImpl list size"); - assertEquals(3, ruleRegistry.stream().filter(hasAnyOfTags(tags)).collect(Collectors.toList()).size(), - "RuleImpl list size"); - assertEquals(3, ruleRegistry.stream().filter(hasAnyOfTags(tag1)).collect(Collectors.toList()).size(), - "RuleImpl list size"); - assertEquals(3, ruleRegistry.stream().filter(hasAnyOfTags(tag1, tag2)).collect(Collectors.toList()).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"); - assertEquals(3, - ruleRegistry.stream().filter(hasAnyOfTags(tag1, tag2, tag3)).collect(Collectors.toList()).size(), + + assertEquals(2, ruleRegistry.stream().filter(hasAnyOfTags(tag2)).toList().size(), "RuleImpl list size"); + assertEquals(2, ruleRegistry.stream().filter(hasAnyOfTags(tag2, tag3)).toList().size(), "RuleImpl list size"); + + assertEquals(2, ruleRegistry.stream().filter(hasAnyOfTags(tag1).and(hasAnyOfTags(tag2))).toList().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"); - 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"); - assertEquals(2, ruleRegistry.stream().filter(hasAnyOfTags(tag1).and(hasAnyOfTags(tag2))) - .collect(Collectors.toList()).size(), "RuleImpl list size"); + assertEquals(1, ruleRegistry.stream().filter(hasAnyOfTags(tag3)).toList().size(), "RuleImpl list size"); - assertEquals(1, ruleRegistry.stream().filter(hasAnyOfTags(tag1).and(hasAnyOfTags(tag3))) - .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(3, ruleRegistry.stream().filter(hasAllTags(tag1)).toList().size(), "RuleImpl list size"); - assertEquals(1, ruleRegistry.stream().filter(hasAnyOfTags(tag3)).collect(Collectors.toList()).size(), - "RuleImpl list size"); + assertEquals(2, ruleRegistry.stream().filter(hasAllTags(tag2)).toList().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(), - "RuleImpl list 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(), + assertEquals(1, ruleRegistry.stream().filter(hasAllTags(tags)).toList().size(), "RuleImpl list size"); + assertEquals(1, ruleRegistry.stream().filter(hasAllTags(tag1, tag2, tag3)).toList().size(), "RuleImpl list size"); } } diff --git a/itests/org.openhab.core.config.discovery.tests/src/main/java/org/openhab/core/config/discovery/internal/InboxOSGiTest.java b/itests/org.openhab.core.config.discovery.tests/src/main/java/org/openhab/core/config/discovery/internal/InboxOSGiTest.java index 5646ab4264c..f22abe47df3 100644 --- a/itests/org.openhab.core.config.discovery.tests/src/main/java/org/openhab/core/config/discovery/internal/InboxOSGiTest.java +++ b/itests/org.openhab.core.config.discovery.tests/src/main/java/org/openhab/core/config/discovery/internal/InboxOSGiTest.java @@ -808,7 +808,7 @@ public Set getSubscribedEventTypes() { .anyMatch(forThingUID(THING1_WITH_BRIDGE.getThingUID()).and(withFlag(DiscoveryResultFlag.NEW)))); assertFalse(inbox.stream() .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)); waitForAssert(() -> { assertThat(receivedEvents.size(), is(3)); @@ -845,7 +845,7 @@ public Set getSubscribedEventTypes() { registry.add(BridgeBuilder.create(BRIDGE_THING_TYPE_UID, BRIDGE_THING_UID).build()); 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)); waitForAssert(() -> { assertThat(receivedEvents.size(), is(1)); @@ -879,7 +879,7 @@ public Set getSubscribedEventTypes() { inbox.add(THING2_WITH_BRIDGE); inbox.add(THING_WITHOUT_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)); registry.forceRemove(BRIDGE.getThingUID()); @@ -889,7 +889,7 @@ public Set getSubscribedEventTypes() { .anyMatch(forThingUID(THING1_WITH_BRIDGE.getThingUID()).and(withFlag(DiscoveryResultFlag.NEW)))); assertFalse(inbox.stream() .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)); }); } diff --git a/itests/org.openhab.core.io.rest.core.tests/src/main/java/org/openhab/core/io/rest/core/internal/profile/ProfileTypeResourceTest.java b/itests/org.openhab.core.io.rest.core.tests/src/main/java/org/openhab/core/io/rest/core/internal/profile/ProfileTypeResourceTest.java index 487aff02b61..e8b5071a4db 100644 --- a/itests/org.openhab.core.io.rest.core.tests/src/main/java/org/openhab/core/io/rest/core/internal/profile/ProfileTypeResourceTest.java +++ b/itests/org.openhab.core.io.rest.core.tests/src/main/java/org/openhab/core/io/rest/core/internal/profile/ProfileTypeResourceTest.java @@ -19,7 +19,6 @@ import java.util.ArrayList; import java.util.List; -import java.util.stream.Collectors; import java.util.stream.Stream; import org.eclipse.jdt.annotation.NonNullByDefault; @@ -113,14 +112,14 @@ public void beforeEach() { public void testGetAll() { Stream result = resource.getProfileTypes(null, null, null); - List list = result.collect(Collectors.toList()); + List list = result.toList(); assertThat(list.size(), is(4)); } @Test public void testGetProfileTypesForStateChannel1() { Stream result = resource.getProfileTypes(null, pt1ChannelType1UID.toString(), null); - List list = result.collect(Collectors.toList()); + List list = result.toList(); // should be both state profiles because the second state profile supports ALL item types on the channel side assertThat(list.size(), is(2)); @@ -133,7 +132,7 @@ public void testGetProfileTypesForStateChannel1() { @Test public void testGetProfileTypesForOtherChannel() { Stream result = resource.getProfileTypes(null, otherStateChannelTypeUID.toString(), null); - List list = result.collect(Collectors.toList()); + List list = result.toList(); // should be only the second state profile because the first one is restricted to another item type on the // channel side @@ -148,7 +147,7 @@ public void testGetProfileTypesForOtherChannel() { @Test public void testGetProfileTypesForTriggerChannel1() { Stream result = resource.getProfileTypes(null, pt3ChannelType1UID.toString(), null); - List list = result.collect(Collectors.toList()); + List list = result.toList(); // should be both trigger profiles because the second trigger profile supports ALL channel types assertThat(list.size(), is(2)); @@ -161,7 +160,7 @@ public void testGetProfileTypesForTriggerChannel1() { @Test public void testGetProfileTypesForTriggerChannel2() { Stream result = resource.getProfileTypes(null, otherTriggerChannelTypeUID.toString(), null); - List list = result.collect(Collectors.toList()); + List list = result.toList(); // should be only the second trigger profile because the first one is restricted to another channel type UID assertThat(list.size(), is(1)); diff --git a/itests/org.openhab.core.model.thing.tests/src/main/java/org/openhab/core/model/thing/test/hue/GenericThingProviderTest3.java b/itests/org.openhab.core.model.thing.tests/src/main/java/org/openhab/core/model/thing/test/hue/GenericThingProviderTest3.java index 7d555915649..13afd35b4e4 100644 --- a/itests/org.openhab.core.model.thing.tests/src/main/java/org/openhab/core/model/thing/test/hue/GenericThingProviderTest3.java +++ b/itests/org.openhab.core.model.thing.tests/src/main/java/org/openhab/core/model/thing/test/hue/GenericThingProviderTest3.java @@ -12,7 +12,6 @@ */ package org.openhab.core.model.thing.test.hue; -import static java.util.stream.Collectors.toList; import static org.hamcrest.CoreMatchers.*; import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.ArgumentMatchers.any; @@ -97,7 +96,7 @@ public void setUp() throws Exception { .withRequired(false).withDefault("hello world").build(), ConfigDescriptionParameterBuilder.create("testConf", ConfigDescriptionParameter.Type.TEXT) .withRequired(false).withDefault("bar").build()) - .collect(toList())) + .toList()) .build(); ConfigDescriptionProvider configDescriptionProvider = mock(ConfigDescriptionProvider.class); diff --git a/itests/org.openhab.core.tests/src/main/java/org/openhab/core/items/GroupItemOSGiTest.java b/itests/org.openhab.core.tests/src/main/java/org/openhab/core/items/GroupItemOSGiTest.java index f398598ded4..4f4a404f57d 100644 --- a/itests/org.openhab.core.tests/src/main/java/org/openhab/core/items/GroupItemOSGiTest.java +++ b/itests/org.openhab.core.tests/src/main/java/org/openhab/core/items/GroupItemOSGiTest.java @@ -23,7 +23,6 @@ import java.util.LinkedList; import java.util.List; import java.util.Set; -import java.util.stream.Collectors; import javax.measure.Quantity; import javax.measure.quantity.Dimensionless; @@ -137,8 +136,7 @@ public void testItemUpdateWithItemRegistry() { itemRegistry.update(updatedItem); waitForAssert(() -> assertThat(events.size(), is(1))); - List stateChanges = events.stream().filter(ItemUpdatedEvent.class::isInstance) - .collect(Collectors.toList()); + List stateChanges = events.stream().filter(ItemUpdatedEvent.class::isInstance).toList(); assertThat(stateChanges.size(), is(1)); ItemUpdatedEvent change = (ItemUpdatedEvent) stateChanges.get(0); @@ -442,8 +440,7 @@ public void assertThatGroupItemPostsEventsForChangesCorrectly() { waitForAssert(() -> assertThat(events.size(), is(2))); - List updates = events.stream().filter(GroupStateUpdatedEvent.class::isInstance) - .collect(Collectors.toList()); + List updates = events.stream().filter(GroupStateUpdatedEvent.class::isInstance).toList(); assertThat(updates.size(), is(1)); GroupStateUpdatedEvent update = (GroupStateUpdatedEvent) updates.get(0); @@ -453,8 +450,7 @@ public void assertThatGroupItemPostsEventsForChangesCorrectly() { .replace("{itemName}", groupItem.getName()))); assertThat(update.getItemState(), is(groupItem.getState())); - List changes = events.stream().filter(GroupItemStateChangedEvent.class::isInstance) - .collect(Collectors.toList()); + List changes = events.stream().filter(GroupItemStateChangedEvent.class::isInstance).toList(); assertThat(changes.size(), is(1)); GroupItemStateChangedEvent change = (GroupItemStateChangedEvent) changes.get(0); @@ -493,7 +489,7 @@ public void assertThatGroupItemChangesRespectGroupFunctionOR() throws Interrupte waitForAssert(() -> assertThat(events, hasSize(2))); List groupItemStateChangedEvents = events.stream().filter(GroupItemStateChangedEvent.class::isInstance) - .collect(Collectors.toList()); + .toList(); assertThat(groupItemStateChangedEvents, hasSize(1)); GroupItemStateChangedEvent change = (GroupItemStateChangedEvent) groupItemStateChangedEvents.get(0); @@ -535,12 +531,11 @@ public void assertThatItemCommandEventsAreEmittedFromCommand() { waitForAssert(() -> assertThat(events, hasSize(2))); - List itemCommandEvents = events.stream().filter(ItemCommandEvent.class::isInstance) - .collect(Collectors.toList()); + List itemCommandEvents = events.stream().filter(ItemCommandEvent.class::isInstance).toList(); assertThat(itemCommandEvents, hasSize(2)); List groupItemStateChangedEvents = events.stream().filter(GroupItemStateChangedEvent.class::isInstance) - .collect(Collectors.toList()); + .toList(); assertThat(groupItemStateChangedEvents, hasSize(0)); assertThat(groupItem.getState(), is(UnDefType.NULL)); @@ -565,12 +560,10 @@ public void assertThatGroupItemChangesRespectGroupFunctionORWithUNDEF() throws I waitForAssert(() -> assertThat(events, hasSize(2))); - List changes = events.stream().filter(GroupItemStateChangedEvent.class::isInstance) - .collect(Collectors.toList()); + List changes = events.stream().filter(GroupItemStateChangedEvent.class::isInstance).toList(); assertThat(changes, hasSize(1)); - List updates = events.stream().filter(GroupStateUpdatedEvent.class::isInstance) - .collect(Collectors.toList()); + List updates = events.stream().filter(GroupStateUpdatedEvent.class::isInstance).toList(); assertThat(updates, hasSize(1)); GroupItemStateChangedEvent change = (GroupItemStateChangedEvent) changes.get(0); @@ -594,10 +587,10 @@ public void assertThatGroupItemChangesRespectGroupFunctionORWithUNDEF() throws I 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)); - updates = events.stream().filter(GroupStateUpdatedEvent.class::isInstance).collect(Collectors.toList()); + updates = events.stream().filter(GroupStateUpdatedEvent.class::isInstance).toList(); assertThat(updates, hasSize(2)); assertThat(groupItem.getState(), is(OnOffType.ON)); @@ -622,8 +615,7 @@ public void assertThatGroupItemChangesRespectGroupFunctionAND() { waitForAssert(() -> assertThat(events, hasSize(2))); - List changes = events.stream().filter(GroupItemStateChangedEvent.class::isInstance) - .collect(Collectors.toList()); + List changes = events.stream().filter(GroupItemStateChangedEvent.class::isInstance).toList(); assertThat(changes, hasSize(1)); GroupItemStateChangedEvent change = (GroupItemStateChangedEvent) changes.get(0); @@ -642,7 +634,7 @@ public void assertThatGroupItemChangesRespectGroupFunctionAND() { 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)); change = (GroupItemStateChangedEvent) changes.get(0); @@ -756,8 +748,7 @@ public void assertThatGroupItemwithDimmeritemAcceptsGetsPercentTypeStateIfMember waitForAssert(() -> assertThat(events.size(), is(2))); - List changes = events.stream().filter(GroupItemStateChangedEvent.class::isInstance) - .collect(Collectors.toList()); + List changes = events.stream().filter(GroupItemStateChangedEvent.class::isInstance).toList(); GroupItemStateChangedEvent change = (GroupItemStateChangedEvent) changes.get(0); assertThat(change.getItemName(), is(groupItem.getName())); @@ -775,7 +766,7 @@ public void assertThatGroupItemwithDimmeritemAcceptsGetsPercentTypeStateIfMember 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)); change = (GroupItemStateChangedEvent) changes.get(0); diff --git a/itests/org.openhab.core.tests/src/main/java/org/openhab/core/items/ItemRegistryImplTest.java b/itests/org.openhab.core.tests/src/main/java/org/openhab/core/items/ItemRegistryImplTest.java index f435ce58cd1..a07a05522c2 100644 --- a/itests/org.openhab.core.tests/src/main/java/org/openhab/core/items/ItemRegistryImplTest.java +++ b/itests/org.openhab.core.tests/src/main/java/org/openhab/core/items/ItemRegistryImplTest.java @@ -12,7 +12,6 @@ */ package org.openhab.core.items; -import static java.util.stream.Collectors.toList; import static org.hamcrest.CoreMatchers.*; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.collection.IsCollectionWithSize.hasSize; @@ -132,7 +131,7 @@ public void assertGetItemsByTagReturnsItemFromRegisteredItemProvider() { List items = new ArrayList<>(itemRegistry.getItemsByTag(CAMERA_TAG)); assertThat(items, hasSize(4)); - List itemNames = items.stream().map(Item::getName).collect(toList()); + List itemNames = items.stream().map(Item::getName).toList(); assertThat(itemNames, hasItem(CAMERA_ITEM_NAME1)); assertThat(itemNames, hasItem(CAMERA_ITEM_NAME2)); assertThat(itemNames, hasItem(CAMERA_ITEM_NAME3)); @@ -144,7 +143,7 @@ public void assertGetItemsByTagInUppercaseReturnsItemFromRegisteredItemProvider( List items = new ArrayList<>(itemRegistry.getItemsByTag(CAMERA_TAG_UPPERCASE)); assertThat(items, hasSize(4)); - List itemNames = items.stream().map(Item::getName).collect(toList()); + List itemNames = items.stream().map(Item::getName).toList(); assertThat(itemNames, hasItem(CAMERA_ITEM_NAME1)); assertThat(itemNames, hasItem(CAMERA_ITEM_NAME2)); assertThat(itemNames, hasItem(CAMERA_ITEM_NAME3)); @@ -156,7 +155,7 @@ public void assertGetItemsByTagAndTypeReturnsItemFromRegistereItemProvider() { List items = new ArrayList<>(itemRegistry.getItemsByTagAndType("Switch", CAMERA_TAG)); assertThat(items, hasSize(2)); - List itemNames = items.stream().map(Item::getName).collect(toList()); + List itemNames = items.stream().map(Item::getName).toList(); assertThat(itemNames, hasItem(CAMERA_ITEM_NAME1)); assertThat(itemNames, hasItem(CAMERA_ITEM_NAME2)); } @@ -178,7 +177,7 @@ public void assertGetItemsByTagCanFilterByClassAndTag() { List items = new ArrayList<>(itemRegistry.getItemsByTag(SwitchItem.class, CAMERA_TAG)); assertThat(items, hasSize(2)); - List itemNames = items.stream().map(GenericItem::getName).collect(toList()); + List itemNames = items.stream().map(GenericItem::getName).toList(); assertThat(itemNames, hasItem(CAMERA_ITEM_NAME1)); assertThat(itemNames, hasItem(CAMERA_ITEM_NAME2)); } diff --git a/itests/org.openhab.core.thing.tests/src/main/java/org/openhab/core/thing/binding/ThingFactoryTest.java b/itests/org.openhab.core.thing.tests/src/main/java/org/openhab/core/thing/binding/ThingFactoryTest.java index c9e0631919b..05a9323a08d 100644 --- a/itests/org.openhab.core.thing.tests/src/main/java/org/openhab/core/thing/binding/ThingFactoryTest.java +++ b/itests/org.openhab.core.thing.tests/src/main/java/org/openhab/core/thing/binding/ThingFactoryTest.java @@ -126,7 +126,7 @@ private List getChannelDefinitions() throws Exception { ChannelDefinition cd1 = new ChannelDefinitionBuilder("channel1", channelType1.getUID()).build(); ChannelDefinition cd2 = new ChannelDefinitionBuilder("channel2", channelType2.getUID()).build(); - return Stream.of(cd1, cd2).collect(toList()); + return Stream.of(cd1, cd2).toList(); } @Test @@ -204,7 +204,7 @@ public void createThingWithDifferentDefaultValueTypes() throws Exception { .withMultiple(true).withLimitToOptions(true).build(); 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(); } }); diff --git a/itests/org.openhab.core.thing.tests/src/main/java/org/openhab/core/thing/internal/ChannelLinkNotifierOSGiTest.java b/itests/org.openhab.core.thing.tests/src/main/java/org/openhab/core/thing/internal/ChannelLinkNotifierOSGiTest.java index f6e74158452..d496e07c2ac 100644 --- a/itests/org.openhab.core.thing.tests/src/main/java/org/openhab/core/thing/internal/ChannelLinkNotifierOSGiTest.java +++ b/itests/org.openhab.core.thing.tests/src/main/java/org/openhab/core/thing/internal/ChannelLinkNotifierOSGiTest.java @@ -284,7 +284,7 @@ private Thing addUninitializedThing() { private Thing createThing() { ThingUID thingUID = new ThingUID(THING_TYPE_UID, "thing" + thingCount++); List 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(); } diff --git a/itests/org.openhab.core.thing.tests/src/main/java/org/openhab/core/thing/internal/CommunicationManagerOSGiTest.java b/itests/org.openhab.core.thing.tests/src/main/java/org/openhab/core/thing/internal/CommunicationManagerOSGiTest.java index cd351a7c27c..777d4a228db 100644 --- a/itests/org.openhab.core.thing.tests/src/main/java/org/openhab/core/thing/internal/CommunicationManagerOSGiTest.java +++ b/itests/org.openhab.core.thing.tests/src/main/java/org/openhab/core/thing/internal/CommunicationManagerOSGiTest.java @@ -18,7 +18,6 @@ import java.util.Collection; import java.util.List; -import java.util.stream.Collectors; import java.util.stream.Stream; import javax.measure.quantity.Temperature; @@ -196,8 +195,8 @@ public void beforeEach() { }).when(profileFactoryMock).createProfile(isA(ProfileTypeUID.class), isA(ProfileCallback.class), isA(ProfileContext.class)); - when(profileFactoryMock.getSupportedProfileTypeUIDs()).thenReturn(Stream - .of(new ProfileTypeUID("test:state"), new ProfileTypeUID("test:trigger")).collect(Collectors.toList())); + when(profileFactoryMock.getSupportedProfileTypeUIDs()) + .thenReturn(Stream.of(new ProfileTypeUID("test:state"), new ProfileTypeUID("test:trigger")).toList()); manager.addProfileFactory(profileFactoryMock); manager.addProfileAdvisor(profileAdvisorMock); diff --git a/itests/org.openhab.core.thing.tests/src/main/java/org/openhab/core/thing/internal/firmware/FirmwareUpdateServiceTest.java b/itests/org.openhab.core.thing.tests/src/main/java/org/openhab/core/thing/internal/firmware/FirmwareUpdateServiceTest.java index b76c45ed81d..0f678c972c1 100644 --- a/itests/org.openhab.core.thing.tests/src/main/java/org/openhab/core/thing/internal/firmware/FirmwareUpdateServiceTest.java +++ b/itests/org.openhab.core.thing.tests/src/main/java/org/openhab/core/thing/internal/firmware/FirmwareUpdateServiceTest.java @@ -702,8 +702,7 @@ public void testEvents() { verify(eventPublisherMock, atLeast(SEQUENCE.length + 1)).post(eventCaptor.capture()); }); events.get().addAll(eventCaptor.getAllValues()); - List list = events.get().stream().filter(FirmwareUpdateProgressInfoEvent.class::isInstance) - .collect(Collectors.toList()); + List list = events.get().stream().filter(FirmwareUpdateProgressInfoEvent.class::isInstance).toList(); assertTrue(list.size() >= SEQUENCE.length); for (int i = 0; i < SEQUENCE.length; i++) { FirmwareUpdateProgressInfoEvent event = (FirmwareUpdateProgressInfoEvent) list.get(i); @@ -903,7 +902,7 @@ private void assertResultInfoEvent(ThingUID thingUID, Firmware firmware, String ArgumentCaptor eventCaptor = ArgumentCaptor.forClass(Event.class); verify(eventPublisherMock, atLeast(expectedEventCount)).post(eventCaptor.capture()); List allValues = eventCaptor.getAllValues().stream() - .filter(FirmwareUpdateResultInfoEvent.class::isInstance).collect(Collectors.toList()); + .filter(FirmwareUpdateResultInfoEvent.class::isInstance).toList(); assertEquals(expectedEventCount, allValues.size()); assertFailedFirmwareUpdate(THING1_UID, allValues.get(expectedEventCount - 1), text); }); diff --git a/itests/org.openhab.core.thing.tests/src/main/java/org/openhab/core/thing/link/ItemChannelLinkOSGiTest.java b/itests/org.openhab.core.thing.tests/src/main/java/org/openhab/core/thing/link/ItemChannelLinkOSGiTest.java index 9d5f044f020..c55b19fee18 100644 --- a/itests/org.openhab.core.thing.tests/src/main/java/org/openhab/core/thing/link/ItemChannelLinkOSGiTest.java +++ b/itests/org.openhab.core.thing.tests/src/main/java/org/openhab/core/thing/link/ItemChannelLinkOSGiTest.java @@ -21,7 +21,6 @@ import java.util.Hashtable; import java.util.List; import java.util.Set; -import java.util.stream.Collectors; import org.eclipse.jdt.annotation.NonNullByDefault; import org.junit.jupiter.api.AfterEach; @@ -154,7 +153,7 @@ public void assertThatAllLinksForItemCanBeDeleted() { int removed = itemChannelLinkRegistry.removeLinksForItem(itemToRemove); assertThat(removed, is(1)); - assertThat(itemChannelLinkRegistry.stream().map(ItemChannelLink::getItemName).collect(Collectors.toList()), + assertThat(itemChannelLinkRegistry.stream().map(ItemChannelLink::getItemName).toList(), not(hasItem(itemToRemove))); assertThat(itemChannelLinkRegistry.getAll(), hasSize(BULK_ITEM_COUNT * BULK_THING_COUNT * BULK_CHANNEL_COUNT - 1)); @@ -169,7 +168,7 @@ public void assertThatAllLinksForThingCanBeDeleted() { assertThat(removed, is(BULK_CHANNEL_COUNT)); assertThat(itemChannelLinkRegistry.stream().map(ItemChannelLink::getLinkedUID).map(ChannelUID::getThingUID) - .collect(Collectors.toList()), not(hasItem(thingToRemove))); + .toList(), not(hasItem(thingToRemove))); assertThat(itemChannelLinkRegistry.getAll(), hasSize((BULK_ITEM_COUNT * BULK_THING_COUNT - 1) * BULK_CHANNEL_COUNT)); } diff --git a/itests/org.openhab.core.thing.tests/src/main/java/org/openhab/core/thing/xml/test/SystemChannelsInChannelGroupsTest.java b/itests/org.openhab.core.thing.tests/src/main/java/org/openhab/core/thing/xml/test/SystemChannelsInChannelGroupsTest.java index 84bb53a2c8a..f7064f08081 100644 --- a/itests/org.openhab.core.thing.tests/src/main/java/org/openhab/core/thing/xml/test/SystemChannelsInChannelGroupsTest.java +++ b/itests/org.openhab.core.thing.tests/src/main/java/org/openhab/core/thing/xml/test/SystemChannelsInChannelGroupsTest.java @@ -16,7 +16,6 @@ import static org.hamcrest.MatcherAssert.assertThat; import java.util.List; -import java.util.stream.Collectors; import org.eclipse.jdt.annotation.NonNullByDefault; import org.junit.jupiter.api.BeforeEach; @@ -68,7 +67,7 @@ public void systemChannelsInChannelGroupsShouldLoadAndUnload() throws Exception public void thingTypesWithSystemChannelsInChannelsGoupsShouldHavePorperChannelDefinitions() throws Exception { try (final AutoCloseable unused = loadedTestBundle()) { List 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)); List channelGroupTypes = channelGroupTypeRegistry.getChannelGroupTypes(); @@ -82,17 +81,13 @@ public void thingTypesWithSystemChannelsInChannelsGoupsShouldHavePorperChannelDe List myChannel = channelDefs.stream().filter( it -> "test".equals(it.getId()) && "system:my-channel".equals(it.getChannelTypeUID().getAsString())) - .collect(Collectors.toList()); + .toList(); - List sigStr = channelDefs.stream() - .filter(it -> "sigstr".equals(it.getId()) - && "system:signal-strength".equals(it.getChannelTypeUID().getAsString())) - .collect(Collectors.toList()); + List sigStr = channelDefs.stream().filter(it -> "sigstr".equals(it.getId()) + && "system:signal-strength".equals(it.getChannelTypeUID().getAsString())).toList(); - List lowBat = channelDefs.stream() - .filter(it -> "lowbat".equals(it.getId()) - && "system:low-battery".equals(it.getChannelTypeUID().getAsString())) - .collect(Collectors.toList()); + List lowBat = channelDefs.stream().filter(it -> "lowbat".equals(it.getId()) + && "system:low-battery".equals(it.getChannelTypeUID().getAsString())).toList(); assertThat(myChannel.size(), is(1)); assertThat(sigStr.size(), is(1)); diff --git a/tools/i18n-plugin/src/main/java/org/openhab/core/tools/i18n/plugin/BundleInfoReader.java b/tools/i18n-plugin/src/main/java/org/openhab/core/tools/i18n/plugin/BundleInfoReader.java index 0462066d2db..4f1c884596b 100644 --- a/tools/i18n-plugin/src/main/java/org/openhab/core/tools/i18n/plugin/BundleInfoReader.java +++ b/tools/i18n-plugin/src/main/java/org/openhab/core/tools/i18n/plugin/BundleInfoReader.java @@ -19,7 +19,6 @@ import java.util.List; import java.util.Map; import java.util.function.Predicate; -import java.util.stream.Collectors; import java.util.stream.Stream; import java.util.stream.StreamSupport; @@ -144,7 +143,7 @@ private void readModuleTypeInfo(Path ohinfPath, BundleInfo bundleInfo) throws IO if (Files.exists(modulePath)) { try (Stream files = Files.walk(modulePath)) { List moduleTypes = files.filter(isJsonFile).flatMap(this::readJsonElementsFromFile) - .map(JsonElement::getAsJsonObject).collect(Collectors.toList()); + .map(JsonElement::getAsJsonObject).toList(); if (!moduleTypes.isEmpty()) { bundleInfo.setModuleTypesJson(moduleTypes); } @@ -157,7 +156,7 @@ private void readRuleTemplateInfo(Path ohinfPath, BundleInfo bundleInfo) throws if (Files.exists(template)) { try (Stream files = Files.walk(template)) { List ruleTemplates = files.filter(isJsonFile).flatMap(this::readJsonElementsFromFile) - .map(JsonElement::getAsJsonObject).collect(Collectors.toList()); + .map(JsonElement::getAsJsonObject).toList(); if (!ruleTemplates.isEmpty()) { bundleInfo.setRuleTemplateJson(ruleTemplates); }