1 /*
2 MailClena - Copyright (C) 2018, Aiki IT
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17 */
18 package de.aikiit.mailclena;
19
20 import lombok.Builder;
21 import org.apache.commons.lang3.StringUtils;
22
23 import java.util.Objects;
24
25 /**
26 * Immutable configuration of this application.
27 *
28 * @param host mail server hostname.
29 * @param username mailbox username.
30 * @param password mailbox password, excluded from {@link #toString()}.
31 * @param command command to execute.
32 */
33 @Builder
34 public record MailConfiguration(String host, String username, String password, String command) {
35
36 /**
37 * Creates a configuration with all required values.
38 *
39 * @param host mail server hostname.
40 * @param username mailbox username.
41 * @param password mailbox password.
42 * @param command command to execute.
43 * @throws NullPointerException if any value is null.
44 */
45 public MailConfiguration {
46 Objects.requireNonNull(host, "host");
47 Objects.requireNonNull(username, "username");
48 Objects.requireNonNull(password, "password");
49 Objects.requireNonNull(command, "command");
50 }
51
52 @Override
53 public String toString() {
54 return "MailConfiguration[host=" + host + ", username=" + username + ", command=" + command + ", isPasswordSet=" + StringUtils.isNotEmpty(password) + "]";
55 }
56 }