]> git.basschouten.com Git - openhab-addons.git/blob
30dec74966fb2dcd5ea27a6eb7d4ac08d80916b9
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
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
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.tacmi.internal;
14
15 import java.util.Collection;
16 import java.util.Collections;
17 import java.util.HashMap;
18 import java.util.Locale;
19 import java.util.Map;
20
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;
27
28 /**
29  * Provides all ChannelTypes for the schema binding...
30  *
31  * @author Christian Niessner - Initial contribution
32  */
33 @NonNullByDefault
34 @Component(service = { TACmiChannelTypeProvider.class, ChannelTypeProvider.class })
35 public class TACmiChannelTypeProvider implements ChannelTypeProvider {
36
37     private final Map<ChannelTypeUID, ChannelType> channelTypesByUID = new HashMap<>();
38
39     @Override
40     public Collection<ChannelType> getChannelTypes(@Nullable Locale locale) {
41         return Collections.unmodifiableCollection(channelTypesByUID.values());
42     }
43
44     @Override
45     public @Nullable ChannelType getChannelType(ChannelTypeUID channelTypeUID, @Nullable Locale locale) {
46         return channelTypesByUID.get(channelTypeUID);
47     }
48
49     public @Nullable ChannelType getInternalChannelType(ChannelTypeUID channelTypeUID) {
50         return channelTypesByUID.get(channelTypeUID);
51     }
52
53     public void addChannelType(ChannelType channelType) {
54         channelTypesByUID.put(channelType.getUID(), channelType);
55     }
56 }