]> git.basschouten.com Git - openhab-addons.git/blob
4e4f1ac274f7b9bf03cdeee7bee046e03cb0b1b7
[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.lcn.internal.connection;
14
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
17 import org.openhab.binding.lcn.internal.common.LcnDefs;
18
19 /**
20  * Settings for a connection to LCN-PCHK.
21  *
22  * @author Tobias Jüttner - Initial Contribution
23  */
24 @NonNullByDefault
25 public class ConnectionSettings {
26
27     /** Unique identifier for this connection. */
28     private final String id;
29
30     /** The user name for authentication. */
31     private final String username;
32
33     /** The password for authentication. */
34     private final String password;
35
36     /** The TCP/IP address or IP of the connection. */
37     private final String address;
38
39     /** The TCP/IP port of the connection. */
40     private final int port;
41
42     /** The dimming mode to use. */
43     private final LcnDefs.OutputPortDimMode dimMode;
44
45     /** The status-messages mode to use. */
46     private final LcnDefs.OutputPortStatusMode statusMode;
47
48     /** Timeout for requests. */
49     private final long timeoutMSec;
50
51     /**
52      * Constructor.
53      *
54      * @param id the connnection's unique identifier
55      * @param address the connection's TCP/IP address or IP
56      * @param port the connection's TCP/IP port
57      * @param username the user name for authentication
58      * @param password the password for authentication
59      * @param dimMode the dimming mode
60      * @param statusMode the status-messages mode
61      * @param timeout the request timeout
62      */
63     public ConnectionSettings(String id, String address, int port, String username, String password,
64             LcnDefs.OutputPortDimMode dimMode, LcnDefs.OutputPortStatusMode statusMode, int timeout) {
65         this.id = id;
66         this.address = address;
67         this.port = port;
68         this.username = username;
69         this.password = password;
70         this.dimMode = dimMode;
71         this.statusMode = statusMode;
72         this.timeoutMSec = timeout;
73     }
74
75     /**
76      * Gets the unique identifier for the connection.
77      *
78      * @return the unique identifier
79      */
80     public String getId() {
81         return this.id;
82     }
83
84     /**
85      * Gets the user name used for authentication.
86      *
87      * @return the user name
88      */
89     public String getUsername() {
90         return this.username;
91     }
92
93     /**
94      * Gets the password used for authentication.
95      *
96      * @return the password
97      */
98     public String getPassword() {
99         return this.password;
100     }
101
102     /**
103      * Gets the TCP/IP address or IP of the connection.
104      *
105      * @return the address or IP
106      */
107     public String getAddress() {
108         return this.address;
109     }
110
111     /**
112      * Gets the TCP/IP port of the connection.
113      *
114      * @return the port
115      */
116     public int getPort() {
117         return this.port;
118     }
119
120     /**
121      * Gets the dimming mode to use for the connection.
122      *
123      * @return the dimming mode
124      */
125     public LcnDefs.OutputPortDimMode getDimMode() {
126         return this.dimMode;
127     }
128
129     /**
130      * Gets the status-messages mode to use for the connection.
131      *
132      * @return the status-messages mode
133      */
134     public LcnDefs.OutputPortStatusMode getStatusMode() {
135         return this.statusMode;
136     }
137
138     /**
139      * Gets the request timeout.
140      *
141      * @return the timeout in milliseconds
142      */
143     public long getTimeout() {
144         return this.timeoutMSec;
145     }
146
147     @Override
148     public boolean equals(@Nullable Object o) {
149         if (!(o instanceof ConnectionSettings)) {
150             return false;
151         }
152         ConnectionSettings other = (ConnectionSettings) o;
153         return this.id.equals(other.id) && this.address.equals(other.address) && this.port == other.port
154                 && this.username.equals(other.username) && this.password.equals(other.password)
155                 && this.dimMode == other.dimMode && this.statusMode == other.statusMode
156                 && this.timeoutMSec == other.timeoutMSec;
157     }
158 }