]> git.basschouten.com Git - openhab-addons.git/blob
9be37db04760097ba7d96c82f368937410021c4f
[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.binding.digiplex.internal.communication;
14
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
17
18 /**
19  * Response for {@link ZoneStatusRequest}
20  *
21  * @author Robert Michalak - Initial contribution
22  *
23  */
24 @NonNullByDefault
25 public class ZoneStatusResponse extends AbstractResponse {
26
27     public final int zoneNo;
28     @Nullable
29     public final ZoneStatus status;
30     public final boolean alarm;
31     public final boolean fireAlarm;
32     public final boolean supervisionLost;
33     public final boolean lowBattery;
34
35     private ZoneStatusResponse(int zoneNo, ZoneStatus status, boolean alarm, boolean fireAlarm, boolean supervisionLost,
36             boolean lowBattery) {
37         super(true);
38         this.zoneNo = zoneNo;
39         this.status = status;
40         this.alarm = alarm;
41         this.fireAlarm = fireAlarm;
42         this.supervisionLost = supervisionLost;
43         this.lowBattery = lowBattery;
44     }
45
46     private ZoneStatusResponse(int zoneNo) {
47         super(false);
48         this.zoneNo = zoneNo;
49         this.status = null;
50         this.alarm = false;
51         this.fireAlarm = false;
52         this.supervisionLost = false;
53         this.lowBattery = false;
54     }
55
56     /**
57      * Builds a response for a given zoneNo. Indicates that request failed.
58      */
59     public static ZoneStatusResponse failure(int zoneNo) {
60         return new ZoneStatusResponse(zoneNo);
61     }
62
63     /**
64      * Builds a response for a given zoneNo. Indicates that request was successful.
65      */
66     public static ZoneStatusResponse success(int zoneNo, ZoneStatus status, boolean alarm, boolean fireAlarm,
67             boolean supervisionLost, boolean lowBattery) {
68         return new ZoneStatusResponse(zoneNo, status, alarm, fireAlarm, supervisionLost, lowBattery);
69     }
70
71     @Override
72     public void accept(DigiplexMessageHandler visitor) {
73         visitor.handleZoneStatusResponse(this);
74     }
75 }