Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
org.cloudfoundry.reactor.util.DefaultConnectionContext Maven / Gradle / Ivy
package org.cloudfoundry.reactor.util;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import javax.annotation.Generated;
import org.cloudfoundry.Nullable;
import reactor.core.publisher.Mono;
import reactor.io.netty.http.HttpClient;
/**
* Immutable implementation of {@link _DefaultConnectionContext}.
*
* Use the builder to create immutable instances:
* {@code DefaultConnectionContext.builder()}.
*/
@SuppressWarnings("all")
@Generated({"Immutables.generator", "_DefaultConnectionContext"})
public final class DefaultConnectionContext extends org.cloudfoundry.reactor.util._DefaultConnectionContext {
private final AuthorizationProvider authorizationProvider;
private final String clientId;
private final String clientSecret;
private final HttpClient httpClient;
private final ObjectMapper objectMapper;
private final Mono root;
private final String host;
private final Mono> info;
private final @Nullable Integer port;
private final ProxyContext proxyContext;
private final @Nullable String proxyHost;
private final @Nullable String proxyPassword;
private final @Nullable Integer proxyPort;
private final @Nullable String proxyUsername;
private final Optional sslCertificateTruster;
private final @Nullable Boolean trustCertificates;
private DefaultConnectionContext(DefaultConnectionContext.Builder builder) {
this.authorizationProvider = builder.authorizationProvider;
this.host = builder.host;
this.port = builder.port;
this.proxyHost = builder.proxyHost;
this.proxyPassword = builder.proxyPassword;
this.proxyPort = builder.proxyPort;
this.proxyUsername = builder.proxyUsername;
this.trustCertificates = builder.trustCertificates;
if (builder.clientId != null) {
initShim.clientId(builder.clientId);
}
if (builder.clientSecret != null) {
initShim.clientSecret(builder.clientSecret);
}
if (builder.objectMapper != null) {
initShim.objectMapper(builder.objectMapper);
}
this.clientId = initShim.getClientId();
this.clientSecret = initShim.getClientSecret();
this.objectMapper = initShim.getObjectMapper();
this.httpClient = initShim.getHttpClient();
this.root = initShim.getRoot();
this.info = initShim.getInfo();
this.proxyContext = initShim.getProxyContext();
this.sslCertificateTruster = initShim.getSslCertificateTruster();
this.initShim = null;
}
private static final int STAGE_INITIALIZING = -1;
private static final int STAGE_UNINITIALIZED = 0;
private static final int STAGE_INITIALIZED = 1;
private transient volatile InitShim initShim = new InitShim();
private final class InitShim {
private String clientId;
private int clientIdStage;
String getClientId() {
if (clientIdStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage());
if (clientIdStage == STAGE_UNINITIALIZED) {
clientIdStage = STAGE_INITIALIZING;
this.clientId = Objects.requireNonNull(DefaultConnectionContext.super.getClientId(), "clientId");
clientIdStage = STAGE_INITIALIZED;
}
return this.clientId;
}
void clientId(String clientId) {
this.clientId = clientId;
clientIdStage = STAGE_INITIALIZED;
}
private String clientSecret;
private int clientSecretStage;
String getClientSecret() {
if (clientSecretStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage());
if (clientSecretStage == STAGE_UNINITIALIZED) {
clientSecretStage = STAGE_INITIALIZING;
this.clientSecret = Objects.requireNonNull(DefaultConnectionContext.super.getClientSecret(), "clientSecret");
clientSecretStage = STAGE_INITIALIZED;
}
return this.clientSecret;
}
void clientSecret(String clientSecret) {
this.clientSecret = clientSecret;
clientSecretStage = STAGE_INITIALIZED;
}
private HttpClient httpClient;
private int httpClientStage;
HttpClient getHttpClient() {
if (httpClientStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage());
if (httpClientStage == STAGE_UNINITIALIZED) {
httpClientStage = STAGE_INITIALIZING;
this.httpClient = Objects.requireNonNull(DefaultConnectionContext.super.getHttpClient(), "httpClient");
httpClientStage = STAGE_INITIALIZED;
}
return this.httpClient;
}
private ObjectMapper objectMapper;
private int objectMapperStage;
ObjectMapper getObjectMapper() {
if (objectMapperStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage());
if (objectMapperStage == STAGE_UNINITIALIZED) {
objectMapperStage = STAGE_INITIALIZING;
this.objectMapper = Objects.requireNonNull(DefaultConnectionContext.super.getObjectMapper(), "objectMapper");
objectMapperStage = STAGE_INITIALIZED;
}
return this.objectMapper;
}
void objectMapper(ObjectMapper objectMapper) {
this.objectMapper = objectMapper;
objectMapperStage = STAGE_INITIALIZED;
}
private Mono root;
private int rootStage;
Mono getRoot() {
if (rootStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage());
if (rootStage == STAGE_UNINITIALIZED) {
rootStage = STAGE_INITIALIZING;
this.root = Objects.requireNonNull(DefaultConnectionContext.super.getRoot(), "root");
rootStage = STAGE_INITIALIZED;
}
return this.root;
}
private Mono> info;
private int infoStage;
Mono> getInfo() {
if (infoStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage());
if (infoStage == STAGE_UNINITIALIZED) {
infoStage = STAGE_INITIALIZING;
this.info = Objects.requireNonNull(DefaultConnectionContext.super.getInfo(), "info");
infoStage = STAGE_INITIALIZED;
}
return this.info;
}
private ProxyContext proxyContext;
private int proxyContextStage;
ProxyContext getProxyContext() {
if (proxyContextStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage());
if (proxyContextStage == STAGE_UNINITIALIZED) {
proxyContextStage = STAGE_INITIALIZING;
this.proxyContext = Objects.requireNonNull(DefaultConnectionContext.super.getProxyContext(), "proxyContext");
proxyContextStage = STAGE_INITIALIZED;
}
return this.proxyContext;
}
private Optional sslCertificateTruster;
private int sslCertificateTrusterStage;
Optional getSslCertificateTruster() {
if (sslCertificateTrusterStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage());
if (sslCertificateTrusterStage == STAGE_UNINITIALIZED) {
sslCertificateTrusterStage = STAGE_INITIALIZING;
this.sslCertificateTruster = Objects.requireNonNull(DefaultConnectionContext.super.getSslCertificateTruster(), "sslCertificateTruster");
sslCertificateTrusterStage = STAGE_INITIALIZED;
}
return this.sslCertificateTruster;
}
private String formatInitCycleMessage() {
ArrayList attributes = new ArrayList();
if (clientIdStage == STAGE_INITIALIZING) attributes.add("clientId");
if (clientSecretStage == STAGE_INITIALIZING) attributes.add("clientSecret");
if (httpClientStage == STAGE_INITIALIZING) attributes.add("httpClient");
if (objectMapperStage == STAGE_INITIALIZING) attributes.add("objectMapper");
if (rootStage == STAGE_INITIALIZING) attributes.add("root");
if (infoStage == STAGE_INITIALIZING) attributes.add("info");
if (proxyContextStage == STAGE_INITIALIZING) attributes.add("proxyContext");
if (sslCertificateTrusterStage == STAGE_INITIALIZING) attributes.add("sslCertificateTruster");
return "Cannot build DefaultConnectionContext, attribute initializers form cycle" + attributes;
}
}
/**
* @return The value of the {@code authorizationProvider} attribute
*/
@Override
public AuthorizationProvider getAuthorizationProvider() {
return authorizationProvider;
}
/**
* @return The value of the {@code clientId} attribute
*/
@Override
public String getClientId() {
InitShim shim = this.initShim;
return shim != null
? shim.getClientId()
: this.clientId;
}
/**
* @return The value of the {@code clientSecret} attribute
*/
@Override
public String getClientSecret() {
InitShim shim = this.initShim;
return shim != null
? shim.getClientSecret()
: this.clientSecret;
}
/**
* @return The computed-at-construction value of the {@code httpClient} attribute
*/
@Override
public HttpClient getHttpClient() {
InitShim shim = this.initShim;
return shim != null
? shim.getHttpClient()
: this.httpClient;
}
/**
* @return The value of the {@code objectMapper} attribute
*/
@Override
public ObjectMapper getObjectMapper() {
InitShim shim = this.initShim;
return shim != null
? shim.getObjectMapper()
: this.objectMapper;
}
/**
* @return The computed-at-construction value of the {@code root} attribute
*/
@Override
public Mono getRoot() {
InitShim shim = this.initShim;
return shim != null
? shim.getRoot()
: this.root;
}
/**
* @return The value of the {@code host} attribute
*/
@Override
public String getHost() {
return host;
}
/**
* @return The computed-at-construction value of the {@code info} attribute
*/
@Override
public Mono> getInfo() {
InitShim shim = this.initShim;
return shim != null
? shim.getInfo()
: this.info;
}
/**
* @return The value of the {@code port} attribute
*/
@Override
public @Nullable Integer getPort() {
return port;
}
/**
* @return The computed-at-construction value of the {@code proxyContext} attribute
*/
@Override
public ProxyContext getProxyContext() {
InitShim shim = this.initShim;
return shim != null
? shim.getProxyContext()
: this.proxyContext;
}
/**
* @return The value of the {@code proxyHost} attribute
*/
@Override
public @Nullable String getProxyHost() {
return proxyHost;
}
/**
* @return The value of the {@code proxyPassword} attribute
*/
@Override
public @Nullable String getProxyPassword() {
return proxyPassword;
}
/**
* @return The value of the {@code proxyPort} attribute
*/
@Override
public @Nullable Integer getProxyPort() {
return proxyPort;
}
/**
* @return The value of the {@code proxyUsername} attribute
*/
@Override
public @Nullable String getProxyUsername() {
return proxyUsername;
}
/**
* @return The computed-at-construction value of the {@code sslCertificateTruster} attribute
*/
@Override
public Optional getSslCertificateTruster() {
InitShim shim = this.initShim;
return shim != null
? shim.getSslCertificateTruster()
: this.sslCertificateTruster;
}
/**
* @return The value of the {@code trustCertificates} attribute
*/
@Override
public @Nullable Boolean getTrustCertificates() {
return trustCertificates;
}
/**
* This instance is equal to all instances of {@code DefaultConnectionContext} 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 DefaultConnectionContext
&& equalTo((DefaultConnectionContext) another);
}
private boolean equalTo(DefaultConnectionContext another) {
return authorizationProvider.equals(another.authorizationProvider)
&& clientId.equals(another.clientId)
&& clientSecret.equals(another.clientSecret)
&& httpClient.equals(another.httpClient)
&& objectMapper.equals(another.objectMapper)
&& root.equals(another.root)
&& host.equals(another.host)
&& info.equals(another.info)
&& Objects.equals(port, another.port)
&& proxyContext.equals(another.proxyContext)
&& Objects.equals(proxyHost, another.proxyHost)
&& Objects.equals(proxyPassword, another.proxyPassword)
&& Objects.equals(proxyPort, another.proxyPort)
&& Objects.equals(proxyUsername, another.proxyUsername)
&& sslCertificateTruster.equals(another.sslCertificateTruster)
&& Objects.equals(trustCertificates, another.trustCertificates);
}
/**
* Computes a hash code from attributes: {@code authorizationProvider}, {@code clientId}, {@code clientSecret}, {@code httpClient}, {@code objectMapper}, {@code root}, {@code host}, {@code info}, {@code port}, {@code proxyContext}, {@code proxyHost}, {@code proxyPassword}, {@code proxyPort}, {@code proxyUsername}, {@code sslCertificateTruster}, {@code trustCertificates}.
* @return hashCode value
*/
@Override
public int hashCode() {
int h = 31;
h = h * 17 + authorizationProvider.hashCode();
h = h * 17 + clientId.hashCode();
h = h * 17 + clientSecret.hashCode();
h = h * 17 + httpClient.hashCode();
h = h * 17 + objectMapper.hashCode();
h = h * 17 + root.hashCode();
h = h * 17 + host.hashCode();
h = h * 17 + info.hashCode();
h = h * 17 + Objects.hashCode(port);
h = h * 17 + proxyContext.hashCode();
h = h * 17 + Objects.hashCode(proxyHost);
h = h * 17 + Objects.hashCode(proxyPassword);
h = h * 17 + Objects.hashCode(proxyPort);
h = h * 17 + Objects.hashCode(proxyUsername);
h = h * 17 + sslCertificateTruster.hashCode();
h = h * 17 + Objects.hashCode(trustCertificates);
return h;
}
/**
* Prints the immutable value {@code DefaultConnectionContext} with attribute values.
* @return A string representation of the value
*/
@Override
public String toString() {
return "DefaultConnectionContext{"
+ "authorizationProvider=" + authorizationProvider
+ ", clientId=" + clientId
+ ", clientSecret=" + clientSecret
+ ", httpClient=" + httpClient
+ ", objectMapper=" + objectMapper
+ ", root=" + root
+ ", host=" + host
+ ", info=" + info
+ ", port=" + port
+ ", proxyContext=" + proxyContext
+ ", proxyHost=" + proxyHost
+ ", proxyPassword=" + proxyPassword
+ ", proxyPort=" + proxyPort
+ ", proxyUsername=" + proxyUsername
+ ", sslCertificateTruster=" + sslCertificateTruster
+ ", trustCertificates=" + trustCertificates
+ "}";
}
/**
* Creates a builder for {@link DefaultConnectionContext DefaultConnectionContext}.
* @return A new DefaultConnectionContext builder
*/
public static DefaultConnectionContext.Builder builder() {
return new DefaultConnectionContext.Builder();
}
/**
* Builds instances of type {@link DefaultConnectionContext DefaultConnectionContext}.
* 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 static final long INIT_BIT_AUTHORIZATION_PROVIDER = 0x1L;
private static final long INIT_BIT_HOST = 0x2L;
private long initBits = 0x3L;
private AuthorizationProvider authorizationProvider;
private String clientId;
private String clientSecret;
private ObjectMapper objectMapper;
private String host;
private Integer port;
private String proxyHost;
private String proxyPassword;
private Integer proxyPort;
private String proxyUsername;
private Boolean trustCertificates;
private Builder() {
}
/**
* Fill a builder with attribute values from the provided {@code org.cloudfoundry.reactor.util.ConnectionContext} instance.
* @param instance The instance from which to copy values
* @return {@code this} builder for use in a chained invocation
*/
public final Builder from(ConnectionContext instance) {
Objects.requireNonNull(instance, "instance");
from((Object) instance);
return this;
}
/**
* Fill a builder with attribute values from the provided {@code DefaultConnectionContext} instance.
* @param instance The instance from which to copy values
* @return {@code this} builder for use in a chained invocation
*/
public final Builder from(DefaultConnectionContext instance) {
Objects.requireNonNull(instance, "instance");
from((Object) instance);
return this;
}
/**
* Copy abstract value type {@code _DefaultConnectionContext} 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(_DefaultConnectionContext instance) {
Objects.requireNonNull(instance, "instance");
from((Object) instance);
return this;
}
private void from(Object object) {
long bits = 0;
if (object instanceof ConnectionContext) {
ConnectionContext instance = (ConnectionContext) object;
if ((bits & 0x4L) == 0) {
authorizationProvider(instance.getAuthorizationProvider());
bits |= 0x4L;
}
if ((bits & 0x8L) == 0) {
clientSecret(instance.getClientSecret());
bits |= 0x8L;
}
if ((bits & 0x1L) == 0) {
clientId(instance.getClientId());
bits |= 0x1L;
}
if ((bits & 0x2L) == 0) {
objectMapper(instance.getObjectMapper());
bits |= 0x2L;
}
}
if (object instanceof org.cloudfoundry.reactor.util._DefaultConnectionContext) {
org.cloudfoundry.reactor.util._DefaultConnectionContext instance = (org.cloudfoundry.reactor.util._DefaultConnectionContext) object;
Integer proxyPortValue = instance.getProxyPort();
if (proxyPortValue != null) {
proxyPort(proxyPortValue);
}
if ((bits & 0x1L) == 0) {
clientId(instance.getClientId());
bits |= 0x1L;
}
if ((bits & 0x2L) == 0) {
objectMapper(instance.getObjectMapper());
bits |= 0x2L;
}
Integer portValue = instance.getPort();
if (portValue != null) {
port(portValue);
}
String proxyUsernameValue = instance.getProxyUsername();
if (proxyUsernameValue != null) {
proxyUsername(proxyUsernameValue);
}
host(instance.getHost());
String proxyPasswordValue = instance.getProxyPassword();
if (proxyPasswordValue != null) {
proxyPassword(proxyPasswordValue);
}
if ((bits & 0x4L) == 0) {
authorizationProvider(instance.getAuthorizationProvider());
bits |= 0x4L;
}
if ((bits & 0x8L) == 0) {
clientSecret(instance.getClientSecret());
bits |= 0x8L;
}
String proxyHostValue = instance.getProxyHost();
if (proxyHostValue != null) {
proxyHost(proxyHostValue);
}
Boolean trustCertificatesValue = instance.getTrustCertificates();
if (trustCertificatesValue != null) {
trustCertificates(trustCertificatesValue);
}
}
}
/**
* Initializes the value for the {@link _DefaultConnectionContext#getAuthorizationProvider() authorizationProvider} attribute.
* @param authorizationProvider The value for authorizationProvider
* @return {@code this} builder for use in a chained invocation
*/
public final Builder authorizationProvider(AuthorizationProvider authorizationProvider) {
this.authorizationProvider = Objects.requireNonNull(authorizationProvider, "authorizationProvider");
initBits &= ~INIT_BIT_AUTHORIZATION_PROVIDER;
return this;
}
/**
* Initializes the value for the {@link _DefaultConnectionContext#getClientId() clientId} attribute.
*
If not set, this attribute will have a default value as returned by the initializer of {@link _DefaultConnectionContext#getClientId() clientId}.
* @param clientId The value for clientId
* @return {@code this} builder for use in a chained invocation
*/
public final Builder clientId(String clientId) {
this.clientId = Objects.requireNonNull(clientId, "clientId");
return this;
}
/**
* Initializes the value for the {@link _DefaultConnectionContext#getClientSecret() clientSecret} attribute.
*
If not set, this attribute will have a default value as returned by the initializer of {@link _DefaultConnectionContext#getClientSecret() clientSecret}.
* @param clientSecret The value for clientSecret
* @return {@code this} builder for use in a chained invocation
*/
public final Builder clientSecret(String clientSecret) {
this.clientSecret = Objects.requireNonNull(clientSecret, "clientSecret");
return this;
}
/**
* Initializes the value for the {@link _DefaultConnectionContext#getObjectMapper() objectMapper} attribute.
*
If not set, this attribute will have a default value as returned by the initializer of {@link _DefaultConnectionContext#getObjectMapper() objectMapper}.
* @param objectMapper The value for objectMapper
* @return {@code this} builder for use in a chained invocation
*/
public final Builder objectMapper(ObjectMapper objectMapper) {
this.objectMapper = Objects.requireNonNull(objectMapper, "objectMapper");
return this;
}
/**
* Initializes the value for the {@link _DefaultConnectionContext#getHost() host} attribute.
* @param host The value for host
* @return {@code this} builder for use in a chained invocation
*/
public final Builder host(String host) {
this.host = Objects.requireNonNull(host, "host");
initBits &= ~INIT_BIT_HOST;
return this;
}
/**
* Initializes the value for the {@link _DefaultConnectionContext#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 _DefaultConnectionContext#getProxyHost() proxyHost} attribute.
* @param proxyHost The value for proxyHost (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
public final Builder proxyHost(@Nullable String proxyHost) {
this.proxyHost = proxyHost;
return this;
}
/**
* Initializes the value for the {@link _DefaultConnectionContext#getProxyPassword() proxyPassword} attribute.
* @param proxyPassword The value for proxyPassword (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
public final Builder proxyPassword(@Nullable String proxyPassword) {
this.proxyPassword = proxyPassword;
return this;
}
/**
* Initializes the value for the {@link _DefaultConnectionContext#getProxyPort() proxyPort} attribute.
* @param proxyPort The value for proxyPort (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
public final Builder proxyPort(@Nullable Integer proxyPort) {
this.proxyPort = proxyPort;
return this;
}
/**
* Initializes the value for the {@link _DefaultConnectionContext#getProxyUsername() proxyUsername} attribute.
* @param proxyUsername The value for proxyUsername (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
public final Builder proxyUsername(@Nullable String proxyUsername) {
this.proxyUsername = proxyUsername;
return this;
}
/**
* Initializes the value for the {@link _DefaultConnectionContext#getTrustCertificates() trustCertificates} attribute.
* @param trustCertificates The value for trustCertificates (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
public final Builder trustCertificates(@Nullable Boolean trustCertificates) {
this.trustCertificates = trustCertificates;
return this;
}
/**
* Builds a new {@link DefaultConnectionContext DefaultConnectionContext}.
* @return An immutable instance of DefaultConnectionContext
* @throws java.lang.IllegalStateException if any required attributes are missing
*/
public DefaultConnectionContext build() {
if (initBits != 0) {
throw new IllegalStateException(formatRequiredAttributesMessage());
}
return new DefaultConnectionContext(this);
}
private String formatRequiredAttributesMessage() {
List attributes = new ArrayList();
if ((initBits & INIT_BIT_AUTHORIZATION_PROVIDER) != 0) attributes.add("authorizationProvider");
if ((initBits & INIT_BIT_HOST) != 0) attributes.add("host");
return "Cannot build DefaultConnectionContext, some of required attributes are not set " + attributes;
}
}
}