2 * Copyright (c) 2010-2022 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.automation.pwm.internal.type;
15 import java.util.Collection;
16 import java.util.Collections;
17 import java.util.Locale;
20 import org.eclipse.jdt.annotation.NonNullByDefault;
21 import org.eclipse.jdt.annotation.Nullable;
22 import org.openhab.automation.pwm.internal.handler.PWMTriggerHandler;
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;
29 * Provides the module types for the rules engine.
31 * @author Fabian Wolter - Initial Contribution
35 public class PWMModuleTypeProvider implements ModuleTypeProvider {
36 private static final Map<String, ModuleType> PROVIDED_MODULE_TYPES = Map.of(PWMTriggerHandler.MODULE_TYPE_ID,
37 PWMTriggerType.initialize());
39 @SuppressWarnings("unchecked")
41 public <T extends ModuleType> T getModuleType(@Nullable String UID, @Nullable Locale locale) {
42 return (T) PROVIDED_MODULE_TYPES.get(UID);
45 @SuppressWarnings("unchecked")
47 public <T extends ModuleType> Collection<T> getModuleTypes(@Nullable Locale locale) {
48 return (Collection<T>) PROVIDED_MODULE_TYPES.values();
52 public void addProviderChangeListener(ProviderChangeListener<ModuleType> listener) {
53 // does nothing because this provider does not change
57 public Collection<ModuleType> getAll() {
58 return Collections.unmodifiableCollection(PROVIDED_MODULE_TYPES.values());
62 public void removeProviderChangeListener(ProviderChangeListener<ModuleType> listener) {
63 // does nothing because this provider does not change