com.neotys.neoload.model.v3.project.server.ImmutableNtlmAuthentication Maven / Gradle / Ivy
package com.neotys.neoload.model.v3.project.server;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.google.common.base.MoreObjects;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.util.Objects;
import java.util.Optional;
import javax.annotation.CheckReturnValue;
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 NtlmAuthentication}.
*
* Use the builder to create immutable instances:
* {@code new NtlmAuthentication.Builder()}.
*/
@SuppressWarnings({"all"})
@ParametersAreNonnullByDefault
@Generated({"Immutables.generator", "NtlmAuthentication"})
@Immutable
@CheckReturnValue
public final class ImmutableNtlmAuthentication
implements NtlmAuthentication {
private final @Nullable String domain;
private final String login;
private final String password;
private ImmutableNtlmAuthentication(
@Nullable String domain,
String login,
String password) {
this.domain = domain;
this.login = login;
this.password = password;
}
/**
* @return The value of the {@code domain} attribute
*/
@JsonProperty("domain")
@Override
public Optional getDomain() {
return Optional.ofNullable(domain);
}
/**
* @return The value of the {@code login} attribute
*/
@JsonProperty("login")
@Override
public String getLogin() {
return login;
}
/**
* @return The value of the {@code password} attribute
*/
@JsonProperty("password")
@Override
public String getPassword() {
return password;
}
/**
* Copy the current immutable object by setting a present value for the optional {@link NtlmAuthentication#getDomain() domain} attribute.
* @param value The value for domain
* @return A modified copy of {@code this} object
*/
public final ImmutableNtlmAuthentication withDomain(String value) {
@Nullable String newValue = Objects.requireNonNull(value, "domain");
if (Objects.equals(this.domain, newValue)) return this;
return new ImmutableNtlmAuthentication(newValue, this.login, this.password);
}
/**
* Copy the current immutable object by setting an optional value for the {@link NtlmAuthentication#getDomain() domain} attribute.
* An equality check is used on inner nullable value to prevent copying of the same value by returning {@code this}.
* @param optional A value for domain
* @return A modified copy of {@code this} object
*/
public final ImmutableNtlmAuthentication withDomain(Optional optional) {
@Nullable String value = optional.orElse(null);
if (Objects.equals(this.domain, value)) return this;
return new ImmutableNtlmAuthentication(value, this.login, this.password);
}
/**
* Copy the current immutable object by setting a value for the {@link NtlmAuthentication#getLogin() login} attribute.
* An equals check used to prevent copying of the same value by returning {@code this}.
* @param value A new value for login (can be {@code null})
* @return A modified copy of the {@code this} object
*/
public final ImmutableNtlmAuthentication withLogin(String value) {
if (Objects.equals(this.login, value)) return this;
return new ImmutableNtlmAuthentication(this.domain, value, this.password);
}
/**
* Copy the current immutable object by setting a value for the {@link NtlmAuthentication#getPassword() password} attribute.
* An equals check used to prevent copying of the same value by returning {@code this}.
* @param value A new value for password (can be {@code null})
* @return A modified copy of the {@code this} object
*/
public final ImmutableNtlmAuthentication withPassword(String value) {
if (Objects.equals(this.password, value)) return this;
return new ImmutableNtlmAuthentication(this.domain, this.login, value);
}
/**
* This instance is equal to all instances of {@code ImmutableNtlmAuthentication} that have 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 ImmutableNtlmAuthentication
&& equalTo((ImmutableNtlmAuthentication) another);
}
private boolean equalTo(ImmutableNtlmAuthentication another) {
return Objects.equals(domain, another.domain)
&& Objects.equals(login, another.login)
&& Objects.equals(password, another.password);
}
/**
* Computes a hash code from attributes: {@code domain}, {@code login}, {@code password}.
* @return hashCode value
*/
@Override
public int hashCode() {
int h = 5381;
h += (h << 5) + Objects.hashCode(domain);
h += (h << 5) + Objects.hashCode(login);
h += (h << 5) + Objects.hashCode(password);
return h;
}
/**
* Prints the immutable value {@code NtlmAuthentication} with attribute values.
* @return A string representation of the value
*/
@Override
public String toString() {
return MoreObjects.toStringHelper("NtlmAuthentication")
.omitNullValues()
.add("domain", domain)
.add("login", login)
.add("password", password)
.toString();
}
/**
* Utility type used to correctly read immutable object from JSON representation.
* @deprecated Do not use this type directly, it exists only for the Jackson-binding infrastructure
*/
@Deprecated
@JsonDeserialize
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE)
static final class Json implements NtlmAuthentication {
Optional domain = Optional.empty();
@Nullable String login;
@Nullable String password;
@JsonProperty("domain")
public void setDomain(Optional domain) {
this.domain = domain;
}
@JsonProperty("login")
public void setLogin(String login) {
this.login = login;
}
@JsonProperty("password")
public void setPassword(String password) {
this.password = password;
}
@Override
public Optional getDomain() { throw new UnsupportedOperationException(); }
@Override
public String getLogin() { throw new UnsupportedOperationException(); }
@Override
public String getPassword() { throw new UnsupportedOperationException(); }
}
/**
* @param json A JSON-bindable data structure
* @return An immutable value type
* @deprecated Do not use this method directly, it exists only for the Jackson-binding infrastructure
*/
@Deprecated
@JsonCreator(mode = JsonCreator.Mode.DELEGATING)
static ImmutableNtlmAuthentication fromJson(Json json) {
NtlmAuthentication.Builder builder = new NtlmAuthentication.Builder();
if (json.domain != null) {
builder.domain(json.domain);
}
if (json.login != null) {
builder.login(json.login);
}
if (json.password != null) {
builder.password(json.password);
}
return (ImmutableNtlmAuthentication) builder.build();
}
/**
* Creates an immutable copy of a {@link NtlmAuthentication} value.
* Uses accessors to get values to initialize the new immutable instance.
* If an instance is already immutable, it is returned as is.
* @param instance The instance to copy
* @return A copied immutable NtlmAuthentication instance
*/
public static ImmutableNtlmAuthentication copyOf(NtlmAuthentication instance) {
if (instance instanceof ImmutableNtlmAuthentication) {
return (ImmutableNtlmAuthentication) instance;
}
return new NtlmAuthentication.Builder()
.from(instance)
.build();
}
/**
* Builds instances of type {@link ImmutableNtlmAuthentication ImmutableNtlmAuthentication}.
* Initialize attributes and then invoke the {@link #build()} method to create an
* immutable instance.
* {@code Builder} is not thread-safe and generally should not be stored in a field or collection,
* but instead used immediately to create instances.
*/
@NotThreadSafe
public static class Builder {
private @Nullable String domain;
private @Nullable String login;
private @Nullable String password;
/**
* Creates a builder for {@link ImmutableNtlmAuthentication ImmutableNtlmAuthentication} instances.
*/
public Builder() {
if (!(this instanceof NtlmAuthentication.Builder)) {
throw new UnsupportedOperationException("Use: new NtlmAuthentication.Builder()");
}
}
/**
* Fill a builder with attribute values from the provided {@code com.neotys.neoload.model.v3.project.server.LoginPasswordAuthentication} instance.
* @param instance The instance from which to copy values
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final NtlmAuthentication.Builder from(LoginPasswordAuthentication instance) {
Objects.requireNonNull(instance, "instance");
from((Object) instance);
return (NtlmAuthentication.Builder) this;
}
/**
* Fill a builder with attribute values from the provided {@code com.neotys.neoload.model.v3.project.server.NtlmAuthentication} instance.
* @param instance The instance from which to copy values
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final NtlmAuthentication.Builder from(NtlmAuthentication instance) {
Objects.requireNonNull(instance, "instance");
from((Object) instance);
return (NtlmAuthentication.Builder) this;
}
private void from(Object object) {
if (object instanceof LoginPasswordAuthentication) {
LoginPasswordAuthentication instance = (LoginPasswordAuthentication) object;
String loginValue = instance.getLogin();
if (loginValue != null) {
login(loginValue);
}
String passwordValue = instance.getPassword();
if (passwordValue != null) {
password(passwordValue);
}
}
if (object instanceof NtlmAuthentication) {
NtlmAuthentication instance = (NtlmAuthentication) object;
Optional domainOptional = instance.getDomain();
if (domainOptional.isPresent()) {
domain(domainOptional);
}
}
}
/**
* Initializes the optional value {@link NtlmAuthentication#getDomain() domain} to domain.
* @param domain The value for domain
* @return {@code this} builder for chained invocation
*/
@CanIgnoreReturnValue
public final NtlmAuthentication.Builder domain(String domain) {
this.domain = Objects.requireNonNull(domain, "domain");
return (NtlmAuthentication.Builder) this;
}
/**
* Initializes the optional value {@link NtlmAuthentication#getDomain() domain} to domain.
* @param domain The value for domain
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("domain")
public final NtlmAuthentication.Builder domain(Optional domain) {
this.domain = domain.orElse(null);
return (NtlmAuthentication.Builder) this;
}
/**
* Initializes the value for the {@link NtlmAuthentication#getLogin() login} attribute.
* @param login The value for login (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("login")
public final NtlmAuthentication.Builder login(String login) {
this.login = login;
return (NtlmAuthentication.Builder) this;
}
/**
* Initializes the value for the {@link NtlmAuthentication#getPassword() password} attribute.
* @param password The value for password (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("password")
public final NtlmAuthentication.Builder password(String password) {
this.password = password;
return (NtlmAuthentication.Builder) this;
}
/**
* Builds a new {@link ImmutableNtlmAuthentication ImmutableNtlmAuthentication}.
* @return An immutable instance of NtlmAuthentication
* @throws java.lang.IllegalStateException if any required attributes are missing
*/
public ImmutableNtlmAuthentication build() {
return new ImmutableNtlmAuthentication(domain, login, password);
}
}
}