]> git.basschouten.com Git - openhab-addons.git/blob
e3254a802765cc2a9897decd2ec24eb5eaafcaac
[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 AreaStatusRequest}
20  *
21  * @author Robert Michalak - Initial contribution
22  */
23 @NonNullByDefault
24 public class AreaStatusResponse extends AbstractResponse {
25
26     public final int areaNo;
27     public final @Nullable AreaStatus status;
28     public final boolean zoneInMemory;
29     public final boolean trouble;
30     public final boolean ready;
31     public final boolean inProgramming;
32     public final boolean alarm;
33     public final boolean strobe;
34
35     private AreaStatusResponse(int areaNo, AreaStatus status, boolean zoneInMemory, boolean trouble, boolean ready,
36             boolean inProgramming, boolean alarm, boolean strobe) {
37         this.areaNo = areaNo;
38         this.status = status;
39         this.zoneInMemory = zoneInMemory;
40         this.trouble = trouble;
41         this.ready = ready;
42         this.inProgramming = inProgramming;
43         this.alarm = alarm;
44         this.strobe = strobe;
45     }
46
47     private AreaStatusResponse(int areaNo) {
48         super(false);
49         this.areaNo = areaNo;
50         this.status = null;
51         this.zoneInMemory = false;
52         this.trouble = false;
53         this.ready = false;
54         this.inProgramming = false;
55         this.alarm = false;
56         this.strobe = false;
57     }
58
59     /**
60      * Builds a response for a given areaNo. Indicates that request failed.
61      */
62     public static AreaStatusResponse failure(int areaNo) {
63         return new AreaStatusResponse(areaNo);
64     }
65
66     /**
67      * Builds a response for a given parameters. Indicates that request was successful.
68      */
69     public static AreaStatusResponse success(int areaNo, AreaStatus status, boolean zoneInMemory, boolean trouble,
70             boolean ready, boolean inProgramming, boolean alarm, boolean strobe) {
71         return new AreaStatusResponse(areaNo, status, zoneInMemory, trouble, ready, inProgramming, alarm, strobe);
72     }
73
74     @Override
75     public void accept(DigiplexMessageHandler visitor) {
76         visitor.handleAreaStatusResponse(this);
77     }
78 }