]> git.basschouten.com Git - openhab-addons.git/blob
e865a59d874f330dc8802db7b855d8a019ccbb43
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2022 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.template;
14
15 import java.util.Collection;
16 import java.util.Locale;
17 import java.util.Set;
18
19 import org.eclipse.jdt.annotation.NonNullByDefault;
20 import org.eclipse.jdt.annotation.Nullable;
21 import org.openhab.core.automation.template.RuleTemplate;
22 import org.openhab.core.automation.template.RuleTemplateProvider;
23 import org.openhab.core.common.registry.ProviderChangeListener;
24 import org.osgi.service.component.annotations.Component;
25
26 /**
27  *
28  * @author Hilbrand Bouwkamp - Initial Contribution
29  */
30 @Component
31 @NonNullByDefault
32 public class PIDControllerTemplateProvider implements RuleTemplateProvider {
33     private static final RuleTemplate PROVIDED_RULE_TEMPLATE = PIDControllerRuleTemplate.initialize();
34
35     @Override
36     public @Nullable RuleTemplate getTemplate(String uid, @Nullable Locale locale) {
37         return uid.equals(PIDControllerRuleTemplate.UID) ? PROVIDED_RULE_TEMPLATE : null;
38     }
39
40     @Override
41     public Collection<RuleTemplate> getTemplates(@Nullable Locale locale) {
42         return Set.of(PROVIDED_RULE_TEMPLATE);
43     }
44
45     @Override
46     public void addProviderChangeListener(ProviderChangeListener<RuleTemplate> listener) {
47         // does nothing because this provider does not change
48     }
49
50     @Override
51     public Collection<RuleTemplate> getAll() {
52         return Set.of(PROVIDED_RULE_TEMPLATE);
53     }
54
55     @Override
56     public void removeProviderChangeListener(ProviderChangeListener<RuleTemplate> listener) {
57         // does nothing because this provider does not change
58     }
59 }