
org.cloudfoundry.reactor.util.ProxyContext Maven / Gradle / Ivy
package org.cloudfoundry.reactor.util;
import io.netty.channel.ChannelHandler;
import java.util.Objects;
import java.util.Optional;
import javax.annotation.Generated;
import org.cloudfoundry.Nullable;
/**
* Immutable implementation of {@link _ProxyContext}.
*
* Use the builder to create immutable instances:
* {@code ProxyContext.builder()}.
*/
@SuppressWarnings("all")
@Generated({"Immutables.generator", "_ProxyContext"})
public final class ProxyContext extends org.cloudfoundry.reactor.util._ProxyContext {
private final @Nullable String host;
private final Optional httpProxyHandler;
private final @Nullable String password;
private final @Nullable Integer port;
private final @Nullable String username;
private ProxyContext(ProxyContext.Builder builder) {
this.host = builder.host;
this.password = builder.password;
this.port = builder.port;
this.username = builder.username;
this.httpProxyHandler = Objects.requireNonNull(super.getHttpProxyHandler(), "httpProxyHandler");
}
/**
* @return The value of the {@code host} attribute
*/
@Override
public @Nullable String getHost() {
return host;
}
/**
* @return The computed-at-construction value of the {@code httpProxyHandler} attribute
*/
@Override
public Optional getHttpProxyHandler() {
return httpProxyHandler;
}
/**
* @return The value of the {@code password} attribute
*/
@Override
public @Nullable String getPassword() {
return password;
}
/**
* @return The value of the {@code port} attribute
*/
@Override
public @Nullable Integer getPort() {
return port;
}
/**
* @return The value of the {@code username} attribute
*/
@Override
public @Nullable String getUsername() {
return username;
}
/**
* This instance is equal to all instances of {@code ProxyContext} that have equal attribute values.
* @return {@code true} if {@code this} is equal to {@code another} instance
*/
@Override
public boolean equals(Object another) {
if (this == another) return true;
return another instanceof ProxyContext
&& equalTo((ProxyContext) another);
}
private boolean equalTo(ProxyContext another) {
return Objects.equals(host, another.host)
&& httpProxyHandler.equals(another.httpProxyHandler)
&& Objects.equals(password, another.password)
&& Objects.equals(port, another.port)
&& Objects.equals(username, another.username);
}
/**
* Computes a hash code from attributes: {@code host}, {@code httpProxyHandler}, {@code password}, {@code port}, {@code username}.
* @return hashCode value
*/
@Override
public int hashCode() {
int h = 31;
h = h * 17 + Objects.hashCode(host);
h = h * 17 + httpProxyHandler.hashCode();
h = h * 17 + Objects.hashCode(password);
h = h * 17 + Objects.hashCode(port);
h = h * 17 + Objects.hashCode(username);
return h;
}
/**
* Prints the immutable value {@code ProxyContext} with attribute values.
* @return A string representation of the value
*/
@Override
public String toString() {
return "ProxyContext{"
+ "host=" + host
+ ", httpProxyHandler=" + httpProxyHandler
+ ", password=" + password
+ ", port=" + port
+ ", username=" + username
+ "}";
}
/**
* Creates a builder for {@link ProxyContext ProxyContext}.
* @return A new ProxyContext builder
*/
public static ProxyContext.Builder builder() {
return new ProxyContext.Builder();
}
/**
* Builds instances of type {@link ProxyContext ProxyContext}.
* 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.
*/
public static final class Builder {
private String host;
private String password;
private Integer port;
private String username;
private Builder() {
}
/**
* Fill a builder with attribute values from the provided {@code ProxyContext} instance.
* Regular attribute values will be replaced with those from the given instance.
* Absent optional values will not replace present values.
* @param instance The instance from which to copy values
* @return {@code this} builder for use in a chained invocation
*/
public final Builder from(ProxyContext instance) {
return from((_ProxyContext) instance);
}
/**
* Copy abstract value type {@code _ProxyContext} instance into builder.
* @param instance The instance from which to copy values
* @return {@code this} builder for use in a chained invocation
*/
final Builder from(_ProxyContext instance) {
Objects.requireNonNull(instance, "instance");
String hostValue = instance.getHost();
if (hostValue != null) {
host(hostValue);
}
String passwordValue = instance.getPassword();
if (passwordValue != null) {
password(passwordValue);
}
Integer portValue = instance.getPort();
if (portValue != null) {
port(portValue);
}
String usernameValue = instance.getUsername();
if (usernameValue != null) {
username(usernameValue);
}
return this;
}
/**
* Initializes the value for the {@link _ProxyContext#getHost() host} attribute.
* @param host The value for host (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
public final Builder host(@Nullable String host) {
this.host = host;
return this;
}
/**
* Initializes the value for the {@link _ProxyContext#getPassword() password} attribute.
* @param password The value for password (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
public final Builder password(@Nullable String password) {
this.password = password;
return this;
}
/**
* Initializes the value for the {@link _ProxyContext#getPort() port} attribute.
* @param port The value for port (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
public final Builder port(@Nullable Integer port) {
this.port = port;
return this;
}
/**
* Initializes the value for the {@link _ProxyContext#getUsername() username} attribute.
* @param username The value for username (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
public final Builder username(@Nullable String username) {
this.username = username;
return this;
}
/**
* Builds a new {@link ProxyContext ProxyContext}.
* @return An immutable instance of ProxyContext
* @throws java.lang.IllegalStateException if any required attributes are missing
*/
public ProxyContext build() {
return new ProxyContext(this);
}
}
}