]> git.basschouten.com Git - openhab-addons.git/blob
646819de7716bd3d6ef949f496548f0540bcd44a
[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 org.openhab.core.events.EventPublisher;
16 import org.openhab.core.items.Item;
17 import org.openhab.io.imperihome.internal.model.device.AbstractDevice;
18 import org.slf4j.Logger;
19 import org.slf4j.LoggerFactory;
20
21 /**
22  * Abstract action, called through the API by ImperiHome clients.
23  *
24  * @author Pepijn de Geus - Initial contribution
25  */
26 public abstract class Action {
27
28     protected final transient Logger logger = LoggerFactory.getLogger(getClass());
29
30     protected static final String COMMAND_SOURCE = "imperihome";
31
32     protected final EventPublisher eventPublisher;
33
34     protected Action(EventPublisher eventPublisher) {
35         this.eventPublisher = eventPublisher;
36     }
37
38     /**
39      * Indicates if this action can be performed on the given Item.
40      *
41      * @param device
42      * @param item Item to check compatibility with.
43      * @return True if the Item is supported.
44      */
45     public abstract boolean supports(AbstractDevice device, Item item);
46
47     /**
48      * Perform this action on the given Item.
49      * 
50      * @param device
51      * @param item Item to perform action on.
52      * @param value Action parameter value.
53      */
54     public abstract void perform(AbstractDevice device, Item item, String value);
55 }