2 * Copyright (c) 2010-2023 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.binding.satel.internal.command;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.openhab.binding.satel.internal.event.EventDispatcher;
17 import org.openhab.binding.satel.internal.protocol.SatelMessage;
20 * Interface for commands sent to communication module.
22 * @author Krzysztof Goworek - Initial contribution
25 public interface SatelCommand {
30 * <li>NEW - just created</li>
31 * <li>ENQUEUED - currently waiting in the queue</li>
32 * <li>SENT - sent to communication module</li>
33 * <li>SUCCEEDED - response received and successfully handled</li>
34 * <li>FAILED - either send failed or response is invalid</li>
37 * @author Krzysztof Goworek - Initial contribution
49 * Returns current state of the command.
51 * @return current state
56 * Sets state of the command.
58 * @param state new state
60 void setState(State state);
63 * Returns request's message object.
65 * @return {@link SatelMessage} request object
67 SatelMessage getRequest();
70 * Checks whether a response message matches request enclosed in this object.
72 * @param response response message
73 * @return <code>true</code> if given response matches the request
75 boolean matches(SatelMessage response);
78 * Handles response received for the command. Usually generates an event with received data.
80 * @param eventDispatcher event dispatcher
81 * @param response response to handle
82 * @return <code>true</code> if response has been successfully handled
84 boolean handleResponse(EventDispatcher eventDispatcher, SatelMessage response);