2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
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
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.lcn.internal.connection;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
17 import org.openhab.binding.lcn.internal.common.LcnDefs;
20 * Settings for a connection to LCN-PCHK.
22 * @author Tobias Jüttner - Initial Contribution
25 public class ConnectionSettings {
27 /** Unique identifier for this connection. */
28 private final String id;
30 /** The user name for authentication. */
31 private final String username;
33 /** The password for authentication. */
34 private final String password;
36 /** The TCP/IP address or IP of the connection. */
37 private final String address;
39 /** The TCP/IP port of the connection. */
40 private final int port;
42 /** The dimming mode to use. */
43 private final LcnDefs.OutputPortDimMode dimMode;
45 /** The status-messages mode to use. */
46 private final LcnDefs.OutputPortStatusMode statusMode;
48 /** Timeout for requests. */
49 private final long timeoutMSec;
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
63 public ConnectionSettings(String id, String address, int port, String username, String password,
64 LcnDefs.OutputPortDimMode dimMode, LcnDefs.OutputPortStatusMode statusMode, int timeout) {
66 this.address = address;
68 this.username = username;
69 this.password = password;
70 this.dimMode = dimMode;
71 this.statusMode = statusMode;
72 this.timeoutMSec = timeout;
76 * Gets the unique identifier for the connection.
78 * @return the unique identifier
80 public String getId() {
85 * Gets the user name used for authentication.
87 * @return the user name
89 public String getUsername() {
94 * Gets the password used for authentication.
96 * @return the password
98 public String getPassword() {
103 * Gets the TCP/IP address or IP of the connection.
105 * @return the address or IP
107 public String getAddress() {
112 * Gets the TCP/IP port of the connection.
116 public int getPort() {
121 * Gets the dimming mode to use for the connection.
123 * @return the dimming mode
125 public LcnDefs.OutputPortDimMode getDimMode() {
130 * Gets the status-messages mode to use for the connection.
132 * @return the status-messages mode
134 public LcnDefs.OutputPortStatusMode getStatusMode() {
135 return this.statusMode;
139 * Gets the request timeout.
141 * @return the timeout in milliseconds
143 public long getTimeout() {
144 return this.timeoutMSec;
148 public boolean equals(@Nullable Object o) {
149 if (!(o instanceof ConnectionSettings)) {
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;