
org.glowroot.ui.ImmutableSmtpConfigDto Maven / Gradle / Ivy
package org.glowroot.ui;
import org.glowroot.agent.shaded.fasterxml.jackson.annotation.JsonCreator;
import org.glowroot.agent.shaded.fasterxml.jackson.annotation.JsonProperty;
import org.glowroot.agent.shaded.google.common.base.MoreObjects;
import org.glowroot.agent.shaded.google.common.base.Objects;
import org.glowroot.agent.shaded.google.common.base.Preconditions;
import org.glowroot.agent.shaded.google.common.collect.ImmutableMap;
import org.glowroot.agent.shaded.google.common.collect.Lists;
import org.glowroot.agent.shaded.google.common.primitives.Booleans;
import java.util.List;
import java.util.Map;
import javax.annotation.Generated;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import javax.annotation.concurrent.Immutable;
import javax.annotation.concurrent.NotThreadSafe;
/**
* Immutable implementation of {@link ConfigJsonService.SmtpConfigDto}.
*
* Use builder to create immutable instances:
* {@code ImmutableSmtpConfigDto.builder()}.
*/
@SuppressWarnings("all")
@ParametersAreNonnullByDefault
@Generated({"Immutables.generator", "ConfigJsonService.SmtpConfigDto"})
@Immutable
final class ImmutableSmtpConfigDto extends ConfigJsonService.SmtpConfigDto {
private final String fromEmailAddress;
private final String fromDisplayName;
private final String host;
private final @Nullable Integer port;
private final boolean ssl;
private final String username;
private final boolean passwordExists;
private final ImmutableMap additionalProperties;
private final String newPassword;
private final @Nullable String testEmailRecipient;
private final String version;
private ImmutableSmtpConfigDto(ImmutableSmtpConfigDto.Builder builder) {
this.fromEmailAddress = builder.fromEmailAddress;
this.fromDisplayName = builder.fromDisplayName;
this.host = builder.host;
this.port = builder.port;
this.ssl = builder.ssl;
this.username = builder.username;
this.passwordExists = builder.passwordExists;
this.additionalProperties = builder.additionalPropertiesBuilder.build();
this.testEmailRecipient = builder.testEmailRecipient;
this.version = builder.version;
this.newPassword = builder.newPassword != null
? builder.newPassword
: Preconditions.checkNotNull(super.newPassword());
}
private ImmutableSmtpConfigDto(
String fromEmailAddress,
String fromDisplayName,
String host,
@Nullable Integer port,
boolean ssl,
String username,
boolean passwordExists,
ImmutableMap additionalProperties,
String newPassword,
@Nullable String testEmailRecipient,
String version) {
this.fromEmailAddress = fromEmailAddress;
this.fromDisplayName = fromDisplayName;
this.host = host;
this.port = port;
this.ssl = ssl;
this.username = username;
this.passwordExists = passwordExists;
this.additionalProperties = additionalProperties;
this.newPassword = newPassword;
this.testEmailRecipient = testEmailRecipient;
this.version = version;
}
/**
* @return value of {@code fromEmailAddress} attribute
*/
@JsonProperty
@Override
String fromEmailAddress() {
return fromEmailAddress;
}
/**
* @return value of {@code fromDisplayName} attribute
*/
@JsonProperty
@Override
String fromDisplayName() {
return fromDisplayName;
}
/**
* @return value of {@code host} attribute
*/
@JsonProperty
@Override
String host() {
return host;
}
/**
* @return value of {@code port} attribute
*/
@JsonProperty
@Override
@Nullable Integer port() {
return port;
}
/**
* @return value of {@code ssl} attribute
*/
@JsonProperty
@Override
boolean ssl() {
return ssl;
}
/**
* @return value of {@code username} attribute
*/
@JsonProperty
@Override
String username() {
return username;
}
/**
* @return value of {@code passwordExists} attribute
*/
@JsonProperty
@Override
boolean passwordExists() {
return passwordExists;
}
/**
* @return value of {@code additionalProperties} attribute
*/
@JsonProperty
@Override
ImmutableMap additionalProperties() {
return additionalProperties;
}
/**
* @return value of {@code newPassword} attribute
*/
@JsonProperty
@Override
String newPassword() {
return newPassword;
}
/**
* @return value of {@code testEmailRecipient} attribute
*/
@JsonProperty
@Override
@Nullable String testEmailRecipient() {
return testEmailRecipient;
}
/**
* @return value of {@code version} attribute
*/
@JsonProperty
@Override
String version() {
return version;
}
/**
* Copy current immutable object by setting value for {@link ConfigJsonService.SmtpConfigDto#fromEmailAddress() fromEmailAddress}.
* Shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param value new value for fromEmailAddress
* @return modified copy of the {@code this} object
*/
public final ImmutableSmtpConfigDto withFromEmailAddress(String value) {
if (this.fromEmailAddress == value) return this;
String newValue = Preconditions.checkNotNull(value);
return new ImmutableSmtpConfigDto(
newValue,
this.fromDisplayName,
this.host,
this.port,
this.ssl,
this.username,
this.passwordExists,
this.additionalProperties,
this.newPassword,
this.testEmailRecipient,
this.version);
}
/**
* Copy current immutable object by setting value for {@link ConfigJsonService.SmtpConfigDto#fromDisplayName() fromDisplayName}.
* Shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param value new value for fromDisplayName
* @return modified copy of the {@code this} object
*/
public final ImmutableSmtpConfigDto withFromDisplayName(String value) {
if (this.fromDisplayName == value) return this;
String newValue = Preconditions.checkNotNull(value);
return new ImmutableSmtpConfigDto(
this.fromEmailAddress,
newValue,
this.host,
this.port,
this.ssl,
this.username,
this.passwordExists,
this.additionalProperties,
this.newPassword,
this.testEmailRecipient,
this.version);
}
/**
* Copy current immutable object by setting value for {@link ConfigJsonService.SmtpConfigDto#host() host}.
* Shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param value new value for host
* @return modified copy of the {@code this} object
*/
public final ImmutableSmtpConfigDto withHost(String value) {
if (this.host == value) return this;
String newValue = Preconditions.checkNotNull(value);
return new ImmutableSmtpConfigDto(
this.fromEmailAddress,
this.fromDisplayName,
newValue,
this.port,
this.ssl,
this.username,
this.passwordExists,
this.additionalProperties,
this.newPassword,
this.testEmailRecipient,
this.version);
}
/**
* Copy current immutable object by setting value for {@link ConfigJsonService.SmtpConfigDto#port() port}.
* Shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param value new value for port, can be {@code null}
* @return modified copy of the {@code this} object
*/
public final ImmutableSmtpConfigDto withPort(@Nullable Integer value) {
if (this.port == value) return this;
@Nullable Integer newValue = value;
return new ImmutableSmtpConfigDto(
this.fromEmailAddress,
this.fromDisplayName,
this.host,
newValue,
this.ssl,
this.username,
this.passwordExists,
this.additionalProperties,
this.newPassword,
this.testEmailRecipient,
this.version);
}
/**
* Copy current immutable object by setting value for {@link ConfigJsonService.SmtpConfigDto#ssl() ssl}.
* Value equality check is used to prevent copying of the same value by returning {@code this}.
* @param value new value for ssl
* @return modified copy of the {@code this} object
*/
public final ImmutableSmtpConfigDto withSsl(boolean value) {
if (this.ssl == value) return this;
boolean newValue = value;
return new ImmutableSmtpConfigDto(
this.fromEmailAddress,
this.fromDisplayName,
this.host,
this.port,
newValue,
this.username,
this.passwordExists,
this.additionalProperties,
this.newPassword,
this.testEmailRecipient,
this.version);
}
/**
* Copy current immutable object by setting value for {@link ConfigJsonService.SmtpConfigDto#username() username}.
* Shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param value new value for username
* @return modified copy of the {@code this} object
*/
public final ImmutableSmtpConfigDto withUsername(String value) {
if (this.username == value) return this;
String newValue = Preconditions.checkNotNull(value);
return new ImmutableSmtpConfigDto(
this.fromEmailAddress,
this.fromDisplayName,
this.host,
this.port,
this.ssl,
newValue,
this.passwordExists,
this.additionalProperties,
this.newPassword,
this.testEmailRecipient,
this.version);
}
/**
* Copy current immutable object by setting value for {@link ConfigJsonService.SmtpConfigDto#passwordExists() passwordExists}.
* Value equality check is used to prevent copying of the same value by returning {@code this}.
* @param value new value for passwordExists
* @return modified copy of the {@code this} object
*/
public final ImmutableSmtpConfigDto withPasswordExists(boolean value) {
if (this.passwordExists == value) return this;
boolean newValue = value;
return new ImmutableSmtpConfigDto(
this.fromEmailAddress,
this.fromDisplayName,
this.host,
this.port,
this.ssl,
this.username,
newValue,
this.additionalProperties,
this.newPassword,
this.testEmailRecipient,
this.version);
}
/**
* Copy current immutable object by replacing {@link ConfigJsonService.SmtpConfigDto#additionalProperties() additionalProperties} map with specified map.
* Nulls are not permitted as keys or values.
* Shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param entries to be added to additionalProperties map
* @return modified copy of {@code this} object
*/
public final ImmutableSmtpConfigDto withAdditionalProperties(Map entries) {
if (this.additionalProperties == entries) return this;
ImmutableMap newValue = ImmutableMap.copyOf(entries);
return new ImmutableSmtpConfigDto(
this.fromEmailAddress,
this.fromDisplayName,
this.host,
this.port,
this.ssl,
this.username,
this.passwordExists,
newValue,
this.newPassword,
this.testEmailRecipient,
this.version);
}
/**
* Copy current immutable object by setting value for {@link ConfigJsonService.SmtpConfigDto#newPassword() newPassword}.
* Shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param value new value for newPassword
* @return modified copy of the {@code this} object
*/
public final ImmutableSmtpConfigDto withNewPassword(String value) {
if (this.newPassword == value) return this;
String newValue = Preconditions.checkNotNull(value);
return new ImmutableSmtpConfigDto(
this.fromEmailAddress,
this.fromDisplayName,
this.host,
this.port,
this.ssl,
this.username,
this.passwordExists,
this.additionalProperties,
newValue,
this.testEmailRecipient,
this.version);
}
/**
* Copy current immutable object by setting value for {@link ConfigJsonService.SmtpConfigDto#testEmailRecipient() testEmailRecipient}.
* Shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param value new value for testEmailRecipient, can be {@code null}
* @return modified copy of the {@code this} object
*/
public final ImmutableSmtpConfigDto withTestEmailRecipient(@Nullable String value) {
if (this.testEmailRecipient == value) return this;
@Nullable String newValue = value;
return new ImmutableSmtpConfigDto(
this.fromEmailAddress,
this.fromDisplayName,
this.host,
this.port,
this.ssl,
this.username,
this.passwordExists,
this.additionalProperties,
this.newPassword,
newValue,
this.version);
}
/**
* Copy current immutable object by setting value for {@link ConfigJsonService.SmtpConfigDto#version() version}.
* Shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param value new value for version
* @return modified copy of the {@code this} object
*/
public final ImmutableSmtpConfigDto withVersion(String value) {
if (this.version == value) return this;
String newValue = Preconditions.checkNotNull(value);
return new ImmutableSmtpConfigDto(
this.fromEmailAddress,
this.fromDisplayName,
this.host,
this.port,
this.ssl,
this.username,
this.passwordExists,
this.additionalProperties,
this.newPassword,
this.testEmailRecipient,
newValue);
}
/**
* This instance is equal to instances of {@code ImmutableSmtpConfigDto} with equal attribute values.
* @return {@code true} if {@code this} is equal to {@code another} instance
*/
@Override
public boolean equals(@Nullable Object another) {
if (this == another) return true;
return another instanceof ImmutableSmtpConfigDto
&& equalTo((ImmutableSmtpConfigDto) another);
}
private boolean equalTo(ImmutableSmtpConfigDto another) {
return fromEmailAddress.equals(another.fromEmailAddress)
&& fromDisplayName.equals(another.fromDisplayName)
&& host.equals(another.host)
&& Objects.equal(port, another.port)
&& ssl == another.ssl
&& username.equals(another.username)
&& passwordExists == another.passwordExists
&& additionalProperties.equals(another.additionalProperties)
&& newPassword.equals(another.newPassword)
&& Objects.equal(testEmailRecipient, another.testEmailRecipient)
&& version.equals(another.version);
}
/**
* Computes hash code from attributes: {@code fromEmailAddress}, {@code fromDisplayName}, {@code host}, {@code port}, {@code ssl}, {@code username}, {@code passwordExists}, {@code additionalProperties}, {@code newPassword}, {@code testEmailRecipient}, {@code version}.
* @return hashCode value
*/
@Override
public int hashCode() {
int h = 31;
h = h * 17 + fromEmailAddress.hashCode();
h = h * 17 + fromDisplayName.hashCode();
h = h * 17 + host.hashCode();
h = h * 17 + Objects.hashCode(port);
h = h * 17 + Booleans.hashCode(ssl);
h = h * 17 + username.hashCode();
h = h * 17 + Booleans.hashCode(passwordExists);
h = h * 17 + additionalProperties.hashCode();
h = h * 17 + newPassword.hashCode();
h = h * 17 + Objects.hashCode(testEmailRecipient);
h = h * 17 + version.hashCode();
return h;
}
/**
* Prints immutable value {@code SmtpConfigDto...} with attribute values,
* excluding any non-generated and auxiliary attributes.
* @return string representation of value
*/
@Override
public String toString() {
return MoreObjects.toStringHelper("SmtpConfigDto")
.add("fromEmailAddress", fromEmailAddress)
.add("fromDisplayName", fromDisplayName)
.add("host", host)
.add("port", port)
.add("ssl", ssl)
.add("username", username)
.add("passwordExists", passwordExists)
.add("additionalProperties", additionalProperties)
.add("newPassword", newPassword)
.add("testEmailRecipient", testEmailRecipient)
.add("version", version)
.toString();
}
/**
* Simple representation of this value type suitable Jackson binding
* @deprecated Do not use this type directly, it exists only for Jackson-binding infrastructure
*/
@Deprecated
static final class Json {
@JsonProperty
@Nullable String fromEmailAddress;
@JsonProperty
@Nullable String fromDisplayName;
@JsonProperty
@Nullable String host;
@JsonProperty
@Nullable Integer port;
@JsonProperty
@Nullable Boolean ssl;
@JsonProperty
@Nullable String username;
@JsonProperty
@Nullable Boolean passwordExists;
@JsonProperty
@Nullable Map additionalProperties;
@JsonProperty
@Nullable String newPassword;
@JsonProperty
@Nullable String testEmailRecipient;
@JsonProperty
@Nullable String version;
}
/**
* @param json JSON-bindable data structure
* @return immutable value type
* @deprecated Do not use this method directly, it exists only for Jackson-binding infrastructure
*/
@Deprecated
@JsonCreator
static ImmutableSmtpConfigDto fromJson(Json json) {
ImmutableSmtpConfigDto.Builder builder = ImmutableSmtpConfigDto.builder();
if (json.fromEmailAddress != null) {
builder.fromEmailAddress(json.fromEmailAddress);
}
if (json.fromDisplayName != null) {
builder.fromDisplayName(json.fromDisplayName);
}
if (json.host != null) {
builder.host(json.host);
}
if (json.port != null) {
builder.port(json.port);
}
if (json.ssl != null) {
builder.ssl(json.ssl);
}
if (json.username != null) {
builder.username(json.username);
}
if (json.passwordExists != null) {
builder.passwordExists(json.passwordExists);
}
if (json.additionalProperties != null) {
builder.putAllAdditionalProperties(json.additionalProperties);
}
if (json.newPassword != null) {
builder.newPassword(json.newPassword);
}
if (json.testEmailRecipient != null) {
builder.testEmailRecipient(json.testEmailRecipient);
}
if (json.version != null) {
builder.version(json.version);
}
return builder.build();
}
/**
* Creates immutable copy of {@link ConfigJsonService.SmtpConfigDto}.
* Uses accessors to get values to initialize immutable instance.
* If an instance is already immutable, it is returned as is.
* @param instance instance to copy
* @return copied immutable SmtpConfigDto instance
*/
static ImmutableSmtpConfigDto copyOf(ConfigJsonService.SmtpConfigDto instance) {
if (instance instanceof ImmutableSmtpConfigDto) {
return (ImmutableSmtpConfigDto) instance;
}
return ImmutableSmtpConfigDto.builder()
.copyFrom(instance)
.build();
}
/**
* Creates builder for {@link org.glowroot.ui.ImmutableSmtpConfigDto ImmutableSmtpConfigDto}.
* @return new ImmutableSmtpConfigDto builder
*/
static ImmutableSmtpConfigDto.Builder builder() {
return new ImmutableSmtpConfigDto.Builder();
}
/**
* Builds instances of {@link org.glowroot.ui.ImmutableSmtpConfigDto ImmutableSmtpConfigDto}.
* Initialize attributes and then invoke {@link #build()} method to create
* immutable instance.
* {@code Builder} is not thread safe and generally should not be stored in field or collection,
* but used immediately to create instances.
*/
@NotThreadSafe
static final class Builder {
private static final long INIT_BIT_FROM_EMAIL_ADDRESS = 0x1L;
private static final long INIT_BIT_FROM_DISPLAY_NAME = 0x2L;
private static final long INIT_BIT_HOST = 0x4L;
private static final long INIT_BIT_SSL = 0x8L;
private static final long INIT_BIT_USERNAME = 0x10L;
private static final long INIT_BIT_PASSWORD_EXISTS = 0x20L;
private static final long INIT_BIT_VERSION = 0x40L;
private long initBits = 0x7f;
private @Nullable String fromEmailAddress;
private @Nullable String fromDisplayName;
private @Nullable String host;
private @Nullable Integer port;
private boolean ssl;
private @Nullable String username;
private boolean passwordExists;
private ImmutableMap.Builder additionalPropertiesBuilder = ImmutableMap.builder();
private @Nullable String newPassword;
private @Nullable String testEmailRecipient;
private @Nullable String version;
private Builder() {}
/**
* Fill builder with attribute values from provided {@link ConfigJsonService.SmtpConfigDto} instance.
* Regular attribute values will be replaced with ones of an instance.
* Instance's absent optional values will not replace present values.
* Collection elements and entries will be added, not replaced.
* @param instance instance to copy values from
* @return {@code this} builder for chained invocation
*/
public final Builder copyFrom(ConfigJsonService.SmtpConfigDto instance) {
Preconditions.checkNotNull(instance);
fromEmailAddress(instance.fromEmailAddress());
fromDisplayName(instance.fromDisplayName());
host(instance.host());
@Nullable Integer portValue = instance.port();
if (portValue != null) {
port(portValue);
}
ssl(instance.ssl());
username(instance.username());
passwordExists(instance.passwordExists());
putAllAdditionalProperties(instance.additionalProperties());
newPassword(instance.newPassword());
@Nullable String testEmailRecipientValue = instance.testEmailRecipient();
if (testEmailRecipientValue != null) {
testEmailRecipient(testEmailRecipientValue);
}
version(instance.version());
return this;
}
/**
* Initializes value for {@link ConfigJsonService.SmtpConfigDto#fromEmailAddress() fromEmailAddress}.
* @param fromEmailAddress value for fromEmailAddress
* @return {@code this} builder for chained invocation
*/
public final Builder fromEmailAddress(String fromEmailAddress) {
this.fromEmailAddress = Preconditions.checkNotNull(fromEmailAddress);
initBits &= ~INIT_BIT_FROM_EMAIL_ADDRESS;
return this;
}
/**
* Initializes value for {@link ConfigJsonService.SmtpConfigDto#fromDisplayName() fromDisplayName}.
* @param fromDisplayName value for fromDisplayName
* @return {@code this} builder for chained invocation
*/
public final Builder fromDisplayName(String fromDisplayName) {
this.fromDisplayName = Preconditions.checkNotNull(fromDisplayName);
initBits &= ~INIT_BIT_FROM_DISPLAY_NAME;
return this;
}
/**
* Initializes value for {@link ConfigJsonService.SmtpConfigDto#host() host}.
* @param host value for host
* @return {@code this} builder for chained invocation
*/
public final Builder host(String host) {
this.host = Preconditions.checkNotNull(host);
initBits &= ~INIT_BIT_HOST;
return this;
}
/**
* Initializes value for {@link ConfigJsonService.SmtpConfigDto#port() port}.
* @param port value for port, can be {@code null}
* @return {@code this} builder for chained invocation
*/
public final Builder port(@Nullable Integer port) {
this.port = port;
return this;
}
/**
* Initializes value for {@link ConfigJsonService.SmtpConfigDto#ssl() ssl}.
* @param ssl value for ssl
* @return {@code this} builder for chained invocation
*/
public final Builder ssl(boolean ssl) {
this.ssl = ssl;
initBits &= ~INIT_BIT_SSL;
return this;
}
/**
* Initializes value for {@link ConfigJsonService.SmtpConfigDto#username() username}.
* @param username value for username
* @return {@code this} builder for chained invocation
*/
public final Builder username(String username) {
this.username = Preconditions.checkNotNull(username);
initBits &= ~INIT_BIT_USERNAME;
return this;
}
/**
* Initializes value for {@link ConfigJsonService.SmtpConfigDto#passwordExists() passwordExists}.
* @param passwordExists value for passwordExists
* @return {@code this} builder for chained invocation
*/
public final Builder passwordExists(boolean passwordExists) {
this.passwordExists = passwordExists;
initBits &= ~INIT_BIT_PASSWORD_EXISTS;
return this;
}
/**
* Put one entry to {@link ConfigJsonService.SmtpConfigDto#additionalProperties() additionalProperties} map.
* @param key the key in additionalProperties map
* @param value the associated value in additionalProperties map
* @return {@code this} builder for chained invocation
*/
public final Builder putAdditionalProperties(String key, String value) {
additionalPropertiesBuilder.put(key, value);
return this;
}
/**
* Put one entry to {@link ConfigJsonService.SmtpConfigDto#additionalProperties() additionalProperties} map. Nulls are not permitted
* @param entry the key and value entry
* @return {@code this} builder for chained invocation
*/
public final Builder putAdditionalProperties(Map.Entry entry) {
additionalPropertiesBuilder.put(entry);
return this;
}
/**
* Sets or replaces all mappings from specified map as entries for {@link ConfigJsonService.SmtpConfigDto#additionalProperties() additionalProperties} map. Nulls are not permitted
* @param entries to be added to additionalProperties map
* @return {@code this} builder for chained invocation
*/
public final Builder additionalProperties(Map entries) {
additionalPropertiesBuilder = ImmutableMap.builder();
return putAllAdditionalProperties(entries);
}
/**
* Put all mappings from specified map as entries to {@link ConfigJsonService.SmtpConfigDto#additionalProperties() additionalProperties} map. Nulls are not permitted
* @param entries to be added to additionalProperties map
* @return {@code this} builder for chained invocation
*/
public final Builder putAllAdditionalProperties(Map entries) {
additionalPropertiesBuilder.putAll(entries);
return this;
}
/**
* Initializes value for {@link ConfigJsonService.SmtpConfigDto#newPassword() newPassword}.
* If not set, this attribute will have default value returned by initializer of {@link ConfigJsonService.SmtpConfigDto#newPassword() newPassword}.
* @param newPassword value for newPassword
* @return {@code this} builder for chained invocation
*/
public final Builder newPassword(String newPassword) {
this.newPassword = Preconditions.checkNotNull(newPassword);
return this;
}
/**
* Initializes value for {@link ConfigJsonService.SmtpConfigDto#testEmailRecipient() testEmailRecipient}.
* @param testEmailRecipient value for testEmailRecipient, can be {@code null}
* @return {@code this} builder for chained invocation
*/
public final Builder testEmailRecipient(@Nullable String testEmailRecipient) {
this.testEmailRecipient = testEmailRecipient;
return this;
}
/**
* Initializes value for {@link ConfigJsonService.SmtpConfigDto#version() version}.
* @param version value for version
* @return {@code this} builder for chained invocation
*/
public final Builder version(String version) {
this.version = Preconditions.checkNotNull(version);
initBits &= ~INIT_BIT_VERSION;
return this;
}
/**
* Builds new {@link org.glowroot.ui.ImmutableSmtpConfigDto ImmutableSmtpConfigDto}.
* @return immutable instance of SmtpConfigDto
* @throws exception {@code java.lang.IllegalStateException} if any required attributes are missing
*/
public ImmutableSmtpConfigDto build()
throws IllegalStateException {
checkRequiredAttributes(); return new ImmutableSmtpConfigDto(this);
}
private boolean fromEmailAddressIsSet() {
return (initBits & INIT_BIT_FROM_EMAIL_ADDRESS) == 0;
}
private boolean fromDisplayNameIsSet() {
return (initBits & INIT_BIT_FROM_DISPLAY_NAME) == 0;
}
private boolean hostIsSet() {
return (initBits & INIT_BIT_HOST) == 0;
}
private boolean sslIsSet() {
return (initBits & INIT_BIT_SSL) == 0;
}
private boolean usernameIsSet() {
return (initBits & INIT_BIT_USERNAME) == 0;
}
private boolean passwordExistsIsSet() {
return (initBits & INIT_BIT_PASSWORD_EXISTS) == 0;
}
private boolean versionIsSet() {
return (initBits & INIT_BIT_VERSION) == 0;
}
private void checkRequiredAttributes() throws IllegalStateException {
if (initBits != 0) {
throw new IllegalStateException(formatRequiredAttributesMessage());
}
}
private String formatRequiredAttributesMessage() {
List attributes = Lists.newArrayList();
if (!fromEmailAddressIsSet()) attributes.add("fromEmailAddress");
if (!fromDisplayNameIsSet()) attributes.add("fromDisplayName");
if (!hostIsSet()) attributes.add("host");
if (!sslIsSet()) attributes.add("ssl");
if (!usernameIsSet()) attributes.add("username");
if (!passwordExistsIsSet()) attributes.add("passwordExists");
if (!versionIsSet()) attributes.add("version");
return "Cannot build SmtpConfigDto, some of required attributes are not set " + attributes;
}
}
}