All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.thestencil.iam.api.ImmutableIAMClientConfig Maven / Gradle / Ivy

The newest version!
package io.thestencil.iam.api;

import com.google.common.base.MoreObjects;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.errorprone.annotations.Var;
import io.vertx.mutiny.ext.web.client.WebClient;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import javax.annotation.CheckReturnValue;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import javax.annotation.concurrent.Immutable;
import javax.annotation.concurrent.NotThreadSafe;
import org.eclipse.microprofile.jwt.JsonWebToken;
import org.immutables.value.Generated;

/**
 * Immutable implementation of {@link IAMClient.IAMClientConfig}.
 * 

* Use the builder to create immutable instances: * {@code ImmutableIAMClientConfig.builder()}. */ @Generated(from = "IAMClient.IAMClientConfig", generator = "Immutables") @SuppressWarnings({"all"}) @ParametersAreNonnullByDefault @javax.annotation.processing.Generated("org.immutables.processor.ProxyProcessor") @Immutable @CheckReturnValue public final class ImmutableIAMClientConfig implements IAMClient.IAMClientConfig { private final JsonWebToken token; private final WebClient webClient; private final String servicePath; private final RemoteIntegration personSecurityProxy; private final RemoteIntegration companySecurityProxy; private ImmutableIAMClientConfig( JsonWebToken token, WebClient webClient, String servicePath, RemoteIntegration personSecurityProxy, RemoteIntegration companySecurityProxy) { this.token = token; this.webClient = webClient; this.servicePath = servicePath; this.personSecurityProxy = personSecurityProxy; this.companySecurityProxy = companySecurityProxy; } /** * @return The value of the {@code token} attribute */ @Override public JsonWebToken getToken() { return token; } /** * @return The value of the {@code webClient} attribute */ @Override public WebClient getWebClient() { return webClient; } /** * @return The value of the {@code servicePath} attribute */ @Override public String getServicePath() { return servicePath; } /** * @return The value of the {@code personSecurityProxy} attribute */ @Override public RemoteIntegration getPersonSecurityProxy() { return personSecurityProxy; } /** * @return The value of the {@code companySecurityProxy} attribute */ @Override public RemoteIntegration getCompanySecurityProxy() { return companySecurityProxy; } /** * Copy the current immutable object by setting a value for the {@link IAMClient.IAMClientConfig#getToken() token} attribute. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for token * @return A modified copy of the {@code this} object */ public final ImmutableIAMClientConfig withToken(JsonWebToken value) { if (this.token == value) return this; JsonWebToken newValue = Objects.requireNonNull(value, "token"); return new ImmutableIAMClientConfig(newValue, this.webClient, this.servicePath, this.personSecurityProxy, this.companySecurityProxy); } /** * Copy the current immutable object by setting a value for the {@link IAMClient.IAMClientConfig#getWebClient() webClient} attribute. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for webClient * @return A modified copy of the {@code this} object */ public final ImmutableIAMClientConfig withWebClient(WebClient value) { if (this.webClient == value) return this; WebClient newValue = Objects.requireNonNull(value, "webClient"); return new ImmutableIAMClientConfig(this.token, newValue, this.servicePath, this.personSecurityProxy, this.companySecurityProxy); } /** * Copy the current immutable object by setting a value for the {@link IAMClient.IAMClientConfig#getServicePath() servicePath} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for servicePath * @return A modified copy of the {@code this} object */ public final ImmutableIAMClientConfig withServicePath(String value) { String newValue = Objects.requireNonNull(value, "servicePath"); if (this.servicePath.equals(newValue)) return this; return new ImmutableIAMClientConfig(this.token, this.webClient, newValue, this.personSecurityProxy, this.companySecurityProxy); } /** * Copy the current immutable object by setting a value for the {@link IAMClient.IAMClientConfig#getPersonSecurityProxy() personSecurityProxy} attribute. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for personSecurityProxy * @return A modified copy of the {@code this} object */ public final ImmutableIAMClientConfig withPersonSecurityProxy(RemoteIntegration value) { if (this.personSecurityProxy == value) return this; RemoteIntegration newValue = Objects.requireNonNull(value, "personSecurityProxy"); return new ImmutableIAMClientConfig(this.token, this.webClient, this.servicePath, newValue, this.companySecurityProxy); } /** * Copy the current immutable object by setting a value for the {@link IAMClient.IAMClientConfig#getCompanySecurityProxy() companySecurityProxy} attribute. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for companySecurityProxy * @return A modified copy of the {@code this} object */ public final ImmutableIAMClientConfig withCompanySecurityProxy(RemoteIntegration value) { if (this.companySecurityProxy == value) return this; RemoteIntegration newValue = Objects.requireNonNull(value, "companySecurityProxy"); return new ImmutableIAMClientConfig(this.token, this.webClient, this.servicePath, this.personSecurityProxy, newValue); } /** * This instance is equal to all instances of {@code ImmutableIAMClientConfig} 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 ImmutableIAMClientConfig && equalTo((ImmutableIAMClientConfig) another); } private boolean equalTo(ImmutableIAMClientConfig another) { return token.equals(another.token) && webClient.equals(another.webClient) && servicePath.equals(another.servicePath) && personSecurityProxy.equals(another.personSecurityProxy) && companySecurityProxy.equals(another.companySecurityProxy); } /** * Computes a hash code from attributes: {@code token}, {@code webClient}, {@code servicePath}, {@code personSecurityProxy}, {@code companySecurityProxy}. * @return hashCode value */ @Override public int hashCode() { @Var int h = 5381; h += (h << 5) + token.hashCode(); h += (h << 5) + webClient.hashCode(); h += (h << 5) + servicePath.hashCode(); h += (h << 5) + personSecurityProxy.hashCode(); h += (h << 5) + companySecurityProxy.hashCode(); return h; } /** * Prints the immutable value {@code IAMClientConfig} with attribute values. * @return A string representation of the value */ @Override public String toString() { return MoreObjects.toStringHelper("IAMClientConfig") .omitNullValues() .add("token", token) .add("webClient", webClient) .add("servicePath", servicePath) .add("personSecurityProxy", personSecurityProxy) .add("companySecurityProxy", companySecurityProxy) .toString(); } /** * Creates an immutable copy of a {@link IAMClient.IAMClientConfig} 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 IAMClientConfig instance */ public static ImmutableIAMClientConfig copyOf(IAMClient.IAMClientConfig instance) { if (instance instanceof ImmutableIAMClientConfig) { return (ImmutableIAMClientConfig) instance; } return ImmutableIAMClientConfig.builder() .from(instance) .build(); } /** * Creates a builder for {@link ImmutableIAMClientConfig ImmutableIAMClientConfig}. *

   * ImmutableIAMClientConfig.builder()
   *    .token(org.eclipse.microprofile.jwt.JsonWebToken) // required {@link IAMClient.IAMClientConfig#getToken() token}
   *    .webClient(io.vertx.mutiny.ext.web.client.WebClient) // required {@link IAMClient.IAMClientConfig#getWebClient() webClient}
   *    .servicePath(String) // required {@link IAMClient.IAMClientConfig#getServicePath() servicePath}
   *    .personSecurityProxy(io.thestencil.iam.api.RemoteIntegration) // required {@link IAMClient.IAMClientConfig#getPersonSecurityProxy() personSecurityProxy}
   *    .companySecurityProxy(io.thestencil.iam.api.RemoteIntegration) // required {@link IAMClient.IAMClientConfig#getCompanySecurityProxy() companySecurityProxy}
   *    .build();
   * 
* @return A new ImmutableIAMClientConfig builder */ public static ImmutableIAMClientConfig.Builder builder() { return new ImmutableIAMClientConfig.Builder(); } /** * Builds instances of type {@link ImmutableIAMClientConfig ImmutableIAMClientConfig}. * 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. */ @Generated(from = "IAMClient.IAMClientConfig", generator = "Immutables") @NotThreadSafe public static final class Builder { private static final long INIT_BIT_TOKEN = 0x1L; private static final long INIT_BIT_WEB_CLIENT = 0x2L; private static final long INIT_BIT_SERVICE_PATH = 0x4L; private static final long INIT_BIT_PERSON_SECURITY_PROXY = 0x8L; private static final long INIT_BIT_COMPANY_SECURITY_PROXY = 0x10L; private long initBits = 0x1fL; private @Nullable JsonWebToken token; private @Nullable WebClient webClient; private @Nullable String servicePath; private @Nullable RemoteIntegration personSecurityProxy; private @Nullable RemoteIntegration companySecurityProxy; private Builder() { } /** * Fill a builder with attribute values from the provided {@code IAMClientConfig} 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 */ @CanIgnoreReturnValue public final Builder from(IAMClient.IAMClientConfig instance) { Objects.requireNonNull(instance, "instance"); token(instance.getToken()); webClient(instance.getWebClient()); servicePath(instance.getServicePath()); personSecurityProxy(instance.getPersonSecurityProxy()); companySecurityProxy(instance.getCompanySecurityProxy()); return this; } /** * Initializes the value for the {@link IAMClient.IAMClientConfig#getToken() token} attribute. * @param token The value for token * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder token(JsonWebToken token) { this.token = Objects.requireNonNull(token, "token"); initBits &= ~INIT_BIT_TOKEN; return this; } /** * Initializes the value for the {@link IAMClient.IAMClientConfig#getWebClient() webClient} attribute. * @param webClient The value for webClient * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder webClient(WebClient webClient) { this.webClient = Objects.requireNonNull(webClient, "webClient"); initBits &= ~INIT_BIT_WEB_CLIENT; return this; } /** * Initializes the value for the {@link IAMClient.IAMClientConfig#getServicePath() servicePath} attribute. * @param servicePath The value for servicePath * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder servicePath(String servicePath) { this.servicePath = Objects.requireNonNull(servicePath, "servicePath"); initBits &= ~INIT_BIT_SERVICE_PATH; return this; } /** * Initializes the value for the {@link IAMClient.IAMClientConfig#getPersonSecurityProxy() personSecurityProxy} attribute. * @param personSecurityProxy The value for personSecurityProxy * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder personSecurityProxy(RemoteIntegration personSecurityProxy) { this.personSecurityProxy = Objects.requireNonNull(personSecurityProxy, "personSecurityProxy"); initBits &= ~INIT_BIT_PERSON_SECURITY_PROXY; return this; } /** * Initializes the value for the {@link IAMClient.IAMClientConfig#getCompanySecurityProxy() companySecurityProxy} attribute. * @param companySecurityProxy The value for companySecurityProxy * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder companySecurityProxy(RemoteIntegration companySecurityProxy) { this.companySecurityProxy = Objects.requireNonNull(companySecurityProxy, "companySecurityProxy"); initBits &= ~INIT_BIT_COMPANY_SECURITY_PROXY; return this; } /** * Builds a new {@link ImmutableIAMClientConfig ImmutableIAMClientConfig}. * @return An immutable instance of IAMClientConfig * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableIAMClientConfig build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return new ImmutableIAMClientConfig(token, webClient, servicePath, personSecurityProxy, companySecurityProxy); } private String formatRequiredAttributesMessage() { List attributes = new ArrayList<>(); if ((initBits & INIT_BIT_TOKEN) != 0) attributes.add("token"); if ((initBits & INIT_BIT_WEB_CLIENT) != 0) attributes.add("webClient"); if ((initBits & INIT_BIT_SERVICE_PATH) != 0) attributes.add("servicePath"); if ((initBits & INIT_BIT_PERSON_SECURITY_PROXY) != 0) attributes.add("personSecurityProxy"); if ((initBits & INIT_BIT_COMPANY_SECURITY_PROXY) != 0) attributes.add("companySecurityProxy"); return "Cannot build IAMClientConfig, some of required attributes are not set " + attributes; } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy