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.knx.internal.channel;
15 import static java.util.stream.Collectors.toSet;
17 import java.util.Collections;
18 import java.util.Objects;
20 import java.util.stream.Stream;
22 import org.eclipse.jdt.annotation.NonNullByDefault;
23 import org.eclipse.jdt.annotation.Nullable;
24 import org.openhab.core.thing.type.ChannelTypeUID;
27 * Helper class to find the matching {@link KNXChannelType} for any given {@link ChannelTypeUID}.
29 * @author Simon Kaufmann - initial contribution and API.
33 public final class KNXChannelTypes {
35 private static final Set<KNXChannelType> TYPES = Collections.unmodifiableSet(Stream.of(//
38 new TypeDateTime(), //
41 new TypeRollershutter(), //
46 private KNXChannelTypes() {
47 // prevent instantiation
50 public static KNXChannelType getType(@Nullable ChannelTypeUID channelTypeUID) throws IllegalArgumentException {
51 Objects.requireNonNull(channelTypeUID);
52 for (KNXChannelType c : TYPES) {
53 if (c.getChannelIDs().contains(channelTypeUID.getId())) {
57 throw new IllegalArgumentException(channelTypeUID.getId() + " is not a valid value channel type ID");