]> git.basschouten.com Git - openhab-addons.git/blob
1b6aa2c17ca1f17741e3f3f5383684ba64913c63
[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
17 /**
18  * Response for arm, quick arm and disarm requests
19  *
20  * @author Robert Michalak - Initial contribution
21  */
22 @NonNullByDefault
23 public class AreaArmDisarmResponse extends AbstractResponse {
24
25     public final int areaNo;
26     public final ArmDisarmType type;
27
28     private AreaArmDisarmResponse(int areaNo, ArmDisarmType type, boolean success) {
29         super(success);
30         this.areaNo = areaNo;
31         this.type = type;
32     }
33
34     /**
35      * Builds a response for a given areaNo and type. Indicates that request failed.
36      */
37     public static AreaArmDisarmResponse failure(int areaNo, ArmDisarmType type) {
38         return new AreaArmDisarmResponse(areaNo, type, false);
39     }
40
41     /**
42      * Builds a response for a given areaNo and type. Indicates that request was successful.
43      */
44     public static AreaArmDisarmResponse success(int areaNo, ArmDisarmType type) {
45         return new AreaArmDisarmResponse(areaNo, type, true);
46     }
47
48     @Override
49     public void accept(DigiplexMessageHandler visitor) {
50         visitor.handleArmDisarmAreaResponse(this);
51     }
52 }