]> git.basschouten.com Git - openhab-addons.git/blob
be21820a2f4db4936db2db670d6aaebbde88b1cd
[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.io.imperihome.internal.action;
14
15 import java.util.HashMap;
16 import java.util.Map;
17
18 import org.openhab.core.events.EventPublisher;
19 import org.openhab.io.imperihome.internal.processor.DeviceRegistry;
20
21 /**
22  * Action registry. Maps ImperiHome API action name to {@link Action} implementation.
23  *
24  * @author Pepijn de Geus - Initial contribution
25  */
26 public class ActionRegistry {
27
28     private final Map<String, Action> actions = new HashMap<>();
29
30     public ActionRegistry(EventPublisher eventPublisher, DeviceRegistry deviceRegistry) {
31         actions.put("setStatus", new SetStatusAction(eventPublisher));
32         actions.put("setColor", new SetColorAction(eventPublisher));
33         actions.put("setLevel", new SetLevelAction(eventPublisher));
34         actions.put("setChoice", new SetChoiceAction(eventPublisher));
35         actions.put("setMode", new SetModeAction(eventPublisher, deviceRegistry));
36         actions.put("setSetPoint", new SetSetPointAction(eventPublisher));
37         actions.put("launchScene", new LaunchSceneAction(eventPublisher));
38         actions.put("stopShutter", new StopShutterAction(eventPublisher, deviceRegistry));
39     }
40
41     public Action get(String action) {
42         return actions.get(action);
43     }
44 }