]> git.basschouten.com Git - openhab-addons.git/blob
78d334f000e195754b298bd08b2be4f1efec8f68
[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.anel.internal;
14
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
17
18 /**
19  * The {@link AnelConfiguration} class contains fields mapping thing configuration parameters.
20  *
21  * @author Patrick Koenemann - Initial contribution
22  */
23 @NonNullByDefault
24 public class AnelConfiguration {
25
26     public @Nullable String hostname;
27     public @Nullable String user;
28     public @Nullable String password;
29     /** Port to send data from openhab to device. */
30     public int udpSendPort = IAnelConstants.DEFAULT_SEND_PORT;
31     /** Openhab receives messages via this port from device. */
32     public int udpReceivePort = IAnelConstants.DEFAULT_RECEIVE_PORT;
33
34     public AnelConfiguration() {
35     }
36
37     public AnelConfiguration(@Nullable String hostname, @Nullable String user, @Nullable String password, int sendPort,
38             int receivePort) {
39         this.hostname = hostname;
40         this.user = user;
41         this.password = password;
42         this.udpSendPort = sendPort;
43         this.udpReceivePort = receivePort;
44     }
45
46     @Override
47     public String toString() {
48         final StringBuilder builder = new StringBuilder();
49         builder.append(getClass().getSimpleName());
50         builder.append("[hostname=");
51         builder.append(hostname);
52         builder.append(",user=");
53         builder.append(user);
54         builder.append(",password=");
55         builder.append(mask(password));
56         builder.append(",udpSendPort=");
57         builder.append(udpSendPort);
58         builder.append(",udpReceivePort=");
59         builder.append(udpReceivePort);
60         builder.append("]");
61         return builder.toString();
62     }
63
64     private @Nullable String mask(@Nullable String string) {
65         return string == null ? null : string.replaceAll(".", "X");
66     }
67 }