]> git.basschouten.com Git - openhab-addons.git/blob
f1049b4efb860b1daf71c07d665961db76a9cdfd
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2020 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.automation.pidcontroller.internal.type;
14
15 import java.util.Collection;
16 import java.util.Collections;
17 import java.util.Locale;
18 import java.util.Map;
19
20 import org.eclipse.jdt.annotation.NonNullByDefault;
21 import org.eclipse.jdt.annotation.Nullable;
22 import org.openhab.automation.pidcontroller.internal.handler.PIDControllerActionHandler;
23 import org.openhab.automation.pidcontroller.internal.handler.PIDControllerTriggerHandler;
24 import org.openhab.core.automation.type.ModuleType;
25 import org.openhab.core.automation.type.ModuleTypeProvider;
26 import org.openhab.core.common.registry.ProviderChangeListener;
27 import org.osgi.service.component.annotations.Component;
28
29 /**
30  *
31  * @author Hilbrand Bouwkamp - Initial Contribution
32  */
33 @Component
34 @NonNullByDefault
35 public class PIDControllerModuleTypeProvider implements ModuleTypeProvider {
36     private static final Map<String, ModuleType> PROVIDED_MODULE_TYPES = Map.of(
37             PIDControllerActionHandler.MODULE_TYPE_ID, PIDControllerActionType.initialize(),
38             PIDControllerTriggerHandler.MODULE_TYPE_ID, PIDControllerTriggerType.initialize());
39
40     @SuppressWarnings("unchecked")
41     @Override
42     public <T extends ModuleType> T getModuleType(@Nullable String UID, @Nullable Locale locale) {
43         return (T) PROVIDED_MODULE_TYPES.get(UID);
44     }
45
46     @SuppressWarnings("unchecked")
47     @Override
48     public <T extends ModuleType> Collection<T> getModuleTypes(@Nullable Locale locale) {
49         return (Collection<T>) PROVIDED_MODULE_TYPES.values();
50     }
51
52     @Override
53     public void addProviderChangeListener(ProviderChangeListener<ModuleType> listener) {
54         // does nothing because this provider does not change
55     }
56
57     @Override
58     public Collection<ModuleType> getAll() {
59         return Collections.unmodifiableCollection(PROVIDED_MODULE_TYPES.values());
60     }
61
62     @Override
63     public void removeProviderChangeListener(ProviderChangeListener<ModuleType> listener) {
64         // does nothing because this provider does not change
65     }
66 }