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