]> git.basschouten.com Git - openhab-addons.git/blob
874789c79f5aa4c8b3f88d360ea081b3be6742ed
[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.pioneeravr.internal.protocol.avr;
14
15 import org.eclipse.jdt.annotation.Nullable;
16 import org.openhab.binding.pioneeravr.internal.protocol.Response.ResponseType;
17
18 /**
19  * Represent a response of the AVR.
20  *
21  * @author Antoine Besnard - Initial contribution
22  */
23 public interface AvrResponse {
24
25     /**
26      * Represent the type of a response.
27      */
28     interface AvrResponseType {
29
30         /**
31          * Return the prefix of the command of this type.
32          *
33          * @param zone
34          * @return
35          */
36         public String getResponsePrefix(int zone);
37
38         /**
39          * Return true if the responses of this type has to have a parameter.
40          *
41          * @return
42          */
43         public boolean hasParameter();
44
45         /**
46          * Return the parameter pattern (RegEx) of the response.
47          *
48          * @return
49          */
50         public @Nullable String getParameterPattern();
51
52         /**
53          * Return the zone number if the responseData matches a zone of this responseType.
54          *
55          * If any zone matches, return null.
56          *
57          * @param responseData
58          * @return
59          */
60         public Integer match(String responseData);
61
62         /**
63          * Return the parameter value of the given responseData.
64          *
65          * @param responseData
66          * @return
67          */
68         public String parseParameter(String responseData);
69     }
70
71     /**
72      * Return the response type of this response
73      *
74      * @return
75      */
76     ResponseType getResponseType();
77
78     /**
79      * Return the parameter of this response or null if the resposne has no parameter.
80      *
81      * @return
82      */
83     String getParameterValue();
84
85     /**
86      * Return true if this response has a parameter.
87      *
88      * @return
89      */
90     boolean hasParameter();
91
92     /**
93      * Return the zone number which is concerned by this response.
94      *
95      * @return
96      */
97     Integer getZone();
98 }