2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.velux.internal.handler;
15 import java.util.HashSet;
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.openhab.binding.velux.internal.handler.utils.ExtendedBaseBridgeHandler;
20 import org.openhab.core.thing.Channel;
21 import org.openhab.core.thing.ChannelUID;
22 import org.openhab.core.thing.Thing;
23 import org.slf4j.Logger;
24 import org.slf4j.LoggerFactory;
27 * The class {@link BridgeChannels} provides methods for dealing with
30 * <li>{@link #getAllChannelUIDs}</LI>
31 * <li>{@link #getAllLinkedChannelUIDs}</LI>
34 * Noninstantiable utility class
37 * @author Guenther Schreiner - Initial contribution
40 final class BridgeChannels {
41 private static final Logger LOGGER = LoggerFactory.getLogger(BridgeChannels.class);
44 * ************************
45 * ***** Constructors *****
48 // Suppress default constructor for non-instantiability
50 private BridgeChannels() {
51 throw new AssertionError();
55 * **************************
56 * ***** Public Methods *****
60 * Return the Channel identifiers of all child things and the bridge things.
63 * @param bridge which will be scrutinized for things.
64 * @return <b>channelUIDs</B> of type {@link Set} of {@link ChannelUID}s.
66 static Set<ChannelUID> getAllChannelUIDs(ExtendedBaseBridgeHandler bridge) {
67 Set<ChannelUID> channelUIDs = new HashSet<>();
68 Set<Thing> things = new HashSet<>(bridge.getThing().getThings());
69 things.add(bridge.getThing());
70 for (Thing thing : things) {
71 for (Channel channel : thing.getChannels()) {
72 channelUIDs.add(channel.getUID());
75 LOGGER.trace("getAllChannelUIDs() returns {}.", channelUIDs);
80 * Return the Channel identifiers of all child things and the bridge things,
84 * @param bridge which will be scrutinized for things.
85 * @return <b>channelUIDs</B> of type {@link Set} of {@link ChannelUID}s.
87 static Set<ChannelUID> getAllLinkedChannelUIDs(ExtendedBaseBridgeHandler bridge) {
88 Set<ChannelUID> channelUIDs = new HashSet<>();
89 Set<Thing> things = new HashSet<>(bridge.getThing().getThings());
90 things.add(bridge.getThing());
91 for (Thing thing : things) {
92 for (Channel channel : thing.getChannels()) {
93 if (bridge.isLinked(channel.getUID())) {
94 channelUIDs.add(channel.getUID());
98 LOGGER.trace("getAllLinkedChannelUIDs() returns {}.", channelUIDs);