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.elerotransmitterstick.internal.stick;
15 import java.util.Arrays;
18 * @author Volker Bier - Initial contribution
20 public class Response {
21 private ResponseStatus status;
22 private int[] channels;
24 public Response(ResponseStatus status, int[] channels) {
26 this.channels = channels;
29 public Response(int[] channels) {
30 this.channels = channels;
33 public boolean isMoving() {
34 return status == ResponseStatus.MOVING_DOWN || status == ResponseStatus.MOVING_UP;
37 public int[] getChannelIds() {
41 public boolean hasStatus() {
42 return status != null;
45 public ResponseStatus getStatus() {
49 public boolean isResponseFor(CommandPacket cmd) {
50 if (cmd == null || cmd.isEasyCheck()) {
54 byte[] cmdBytes = cmd.getBytes();
55 int[] cmdChannels = ResponseUtil.getChannelIds(cmdBytes[3], cmdBytes[4]);
56 return Arrays.equals(channels, cmdChannels);
60 public String toString() {
61 return status + " for channels " + Arrays.toString(channels);