2 * Copyright (c) 2010-2021 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.gardena.internal.config;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
19 * The main Gardena config class.
21 * @author Gerhard Riegler - Initial contribution
24 public class GardenaConfig {
25 private static final Integer DEFAULT_CONNECTION_TIMEOUT = 10;
27 private @Nullable String email;
28 private @Nullable String password;
29 private @Nullable String apiKey;
31 private transient Integer connectionTimeout = DEFAULT_CONNECTION_TIMEOUT;
33 public GardenaConfig() {
36 public GardenaConfig(String email, String password) {
38 this.password = password;
42 * Returns the email to connect to Gardena smart system.
44 public @Nullable String getEmail() {
49 * Sets the email to connect to Gardena smart system.
51 public void setEmail(String email) {
56 * Returns the password to connect to Gardena smart system.
58 public @Nullable String getPassword() {
63 * Sets the password to connect to Gardena smart system.
65 public void setPassword(String password) {
66 this.password = password;
70 * Returns the connection timeout to Gardena smart system.
72 public Integer getConnectionTimeout() {
73 return connectionTimeout;
77 * Sets the connection timeout to Gardena smart system.
79 public void setConnectionTimeout(Integer connectionTimeout) {
80 this.connectionTimeout = connectionTimeout;
84 * Returns the api key.
86 public @Nullable String getApiKey() {
93 public void setApiKey(String apiKey) {
98 * Validate the config if email, password and apiKey is specified.
100 public boolean isValid() {
101 final String email = this.email;
102 final String password = this.password;
103 final String apiKey = this.apiKey;
104 return email != null && !email.isBlank() && password != null && !password.isBlank() && apiKey != null
105 && !apiKey.isBlank();
109 public String toString() {
110 StringBuilder sb = new StringBuilder(GardenaConfig.class.getSimpleName()).append("[");
111 sb.append("email: ").append(email).append(", ");
112 sb.append("connectionTimeout: ").append(connectionTimeout).append(", ");
113 sb.append("apiKey: ").append(apiKey);
114 return sb.append("]").toString();