]> git.basschouten.com Git - openhab-addons.git/blob
d782d25faeccdb1d7e4fbc051d7cda61f4b4a3ce
[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.russound.internal.rio.system;
14
15 /**
16  * Configuration class for the {@link RioSystemHandler}
17  *
18  * @author Tim Roberts - Initial contribution
19  */
20 public class RioSystemConfig {
21
22     /**
23      * Constant defined for the "ipAddress" configuration field
24      */
25     public static final String IP_ADDRESS = "ipAddress";
26
27     /**
28      * Constant defined for the "ping" configuration field
29      */
30     public static final String PING = "ping";
31
32     /**
33      * Constant defined for the "retryPolling" configuration field
34      */
35     public static final String RETRY_POLLING = "retryPolling";
36
37     /**
38      * Constant defined for the "scanDevice" configuration field
39      */
40     public static final String SCAN_DEVICE = "scanDevice";
41
42     /**
43      * IP Address (or host name) of system
44      */
45     private String ipAddress;
46
47     /**
48      * Ping time (in seconds) to keep the connection alive.
49      */
50     private int ping;
51
52     /**
53      * Polling time (in seconds) to attempt a reconnect if the socket session has failed
54      */
55     private int retryPolling;
56
57     /**
58      * Whether to scan the device at startup (and create zones, source, etc dynamically)
59      */
60     private boolean scanDevice;
61
62     /**
63      * Returns the IP address or host name
64      *
65      * @return the IP address or host name
66      */
67     public String getIpAddress() {
68         return ipAddress;
69     }
70
71     /**
72      * Sets the IP address or host name
73      *
74      * @param ipAddress the IP Address or host name
75      */
76     public void setIpAddress(String ipAddress) {
77         this.ipAddress = ipAddress;
78     }
79
80     /**
81      * Gets the polling (in seconds) to reconnect
82      *
83      * @return the polling (in seconds) to reconnect
84      */
85     public int getRetryPolling() {
86         return retryPolling;
87     }
88
89     /**
90      * Sets the polling (in seconds) to reconnect
91      *
92      * @param retryPolling the polling (in seconds to reconnect)
93      */
94     public void setRetryPolling(int retryPolling) {
95         this.retryPolling = retryPolling;
96     }
97
98     /**
99      * Gets the ping interval (in seconds)
100      *
101      * @return the ping interval (in seconds)
102      */
103     public int getPing() {
104         return ping;
105     }
106
107     /**
108      * Sets the ping interval (in seconds)
109      *
110      * @param ping the ping interval (in seconds)
111      */
112     public void setPing(int ping) {
113         this.ping = ping;
114     }
115
116     /**
117      * Whether the device should be scanned at startup
118      *
119      * @return true to scan, false otherwise
120      */
121     public boolean isScanDevice() {
122         return scanDevice;
123     }
124
125     /**
126      * Sets whether the device should be scanned at startup
127      *
128      * @param scanDevice true to scan, false otherwise
129      */
130     public void setScanDevice(boolean scanDevice) {
131         this.scanDevice = scanDevice;
132     }
133
134     @Override
135     public int hashCode() {
136         final int prime = 31;
137         int result = 1;
138         result = prime * result + ((ipAddress == null) ? 0 : ipAddress.hashCode());
139         result = prime * result + ping;
140         result = prime * result + retryPolling;
141         result = prime * result + (scanDevice ? 1231 : 1237);
142         return result;
143     }
144
145     @Override
146     public boolean equals(Object obj) {
147         if (this == obj) {
148             return true;
149         }
150         if (obj == null) {
151             return false;
152         }
153         if (getClass() != obj.getClass()) {
154             return false;
155         }
156         final RioSystemConfig other = (RioSystemConfig) obj;
157         if (ipAddress == null) {
158             if (other.ipAddress != null) {
159                 return false;
160             }
161         } else if (!ipAddress.equals(other.ipAddress)) {
162             return false;
163         }
164         if (ping != other.ping) {
165             return false;
166         }
167         if (retryPolling != other.retryPolling) {
168             return false;
169         }
170         if (scanDevice != other.scanDevice) {
171             return false;
172         }
173         return true;
174     }
175 }