2 * Copyright (c) 2010-2024 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.freeathomesystem.internal.type;
15 import java.util.ArrayList;
16 import java.util.Collection;
17 import java.util.HashMap;
18 import java.util.Locale;
21 import org.eclipse.jdt.annotation.NonNullByDefault;
22 import org.eclipse.jdt.annotation.Nullable;
23 import org.openhab.core.thing.type.ChannelType;
24 import org.openhab.core.thing.type.ChannelTypeProvider;
25 import org.openhab.core.thing.type.ChannelTypeUID;
26 import org.osgi.service.component.annotations.Component;
30 * @author Andras Uhrin - Initial contribution
33 @Component(service = { FreeAtHomeChannelTypeProvider.class, ChannelTypeProvider.class })
35 public class FreeAtHomeChannelTypeProviderImpl implements FreeAtHomeChannelTypeProvider {
37 private final Map<ChannelTypeUID, ChannelType> channelTypesByUID = new HashMap<>();
40 public Collection<ChannelType> getChannelTypes(@Nullable Locale locale) {
41 Collection<ChannelType> result = new ArrayList<>();
43 for (ChannelTypeUID uid : channelTypesByUID.keySet()) {
44 ChannelType channelType = channelTypesByUID.get(uid);
46 if (channelType != null) {
47 result.add(channelType);
55 public @Nullable ChannelType getChannelType(@Nullable ChannelTypeUID channelTypeUID, @Nullable Locale locale) {
56 return channelTypesByUID.get(channelTypeUID);
60 public void addChannelType(@Nullable ChannelType channelType) {
61 if (channelType != null) {
62 channelTypesByUID.put(channelType.getUID(), channelType);