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.anel.internal;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
19 * The {@link AnelConfiguration} class contains fields mapping thing configuration parameters.
21 * @author Patrick Koenemann - Initial contribution
24 public class AnelConfiguration {
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;
34 public AnelConfiguration() {
37 public AnelConfiguration(@Nullable String hostname, @Nullable String user, @Nullable String password, int sendPort,
39 this.hostname = hostname;
41 this.password = password;
42 this.udpSendPort = sendPort;
43 this.udpReceivePort = receivePort;
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=");
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);
61 return builder.toString();
64 private @Nullable String mask(@Nullable String string) {
65 return string == null ? null : string.replaceAll(".", "X");