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

io.resys.thena.docdb.sql.support.ImmutableSqlClientWrapper Maven / Gradle / Ivy

The newest version!
package io.resys.thena.docdb.sql.support;

import com.google.common.base.MoreObjects;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.errorprone.annotations.Var;
import io.resys.thena.docdb.api.models.Repo;
import io.resys.thena.docdb.spi.ClientCollections;
import io.vertx.mutiny.sqlclient.Pool;
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.immutables.value.Generated;

/**
 * Immutable implementation of {@link SqlClientWrapper}.
 * 

* Use the builder to create immutable instances: * {@code ImmutableSqlClientWrapper.builder()}. */ @Generated(from = "SqlClientWrapper", generator = "Immutables") @SuppressWarnings({"all"}) @ParametersAreNonnullByDefault @javax.annotation.processing.Generated("org.immutables.processor.ProxyProcessor") @Immutable @CheckReturnValue public final class ImmutableSqlClientWrapper implements SqlClientWrapper { private final Repo repo; private final Pool client; private final ClientCollections names; private ImmutableSqlClientWrapper( Repo repo, Pool client, ClientCollections names) { this.repo = repo; this.client = client; this.names = names; } /** * @return The value of the {@code repo} attribute */ @Override public Repo getRepo() { return repo; } /** * @return The value of the {@code client} attribute */ @Override public Pool getClient() { return client; } /** * @return The value of the {@code names} attribute */ @Override public ClientCollections getNames() { return names; } /** * Copy the current immutable object by setting a value for the {@link SqlClientWrapper#getRepo() repo} 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 repo * @return A modified copy of the {@code this} object */ public final ImmutableSqlClientWrapper withRepo(Repo value) { if (this.repo == value) return this; Repo newValue = Objects.requireNonNull(value, "repo"); return new ImmutableSqlClientWrapper(newValue, this.client, this.names); } /** * Copy the current immutable object by setting a value for the {@link SqlClientWrapper#getClient() client} 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 client * @return A modified copy of the {@code this} object */ public final ImmutableSqlClientWrapper withClient(Pool value) { if (this.client == value) return this; Pool newValue = Objects.requireNonNull(value, "client"); return new ImmutableSqlClientWrapper(this.repo, newValue, this.names); } /** * Copy the current immutable object by setting a value for the {@link SqlClientWrapper#getNames() names} 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 names * @return A modified copy of the {@code this} object */ public final ImmutableSqlClientWrapper withNames(ClientCollections value) { if (this.names == value) return this; ClientCollections newValue = Objects.requireNonNull(value, "names"); return new ImmutableSqlClientWrapper(this.repo, this.client, newValue); } /** * This instance is equal to all instances of {@code ImmutableSqlClientWrapper} 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 ImmutableSqlClientWrapper && equalTo(0, (ImmutableSqlClientWrapper) another); } private boolean equalTo(int synthetic, ImmutableSqlClientWrapper another) { return repo.equals(another.repo) && client.equals(another.client) && names.equals(another.names); } /** * Computes a hash code from attributes: {@code repo}, {@code client}, {@code names}. * @return hashCode value */ @Override public int hashCode() { @Var int h = 5381; h += (h << 5) + repo.hashCode(); h += (h << 5) + client.hashCode(); h += (h << 5) + names.hashCode(); return h; } /** * Prints the immutable value {@code SqlClientWrapper} with attribute values. * @return A string representation of the value */ @Override public String toString() { return MoreObjects.toStringHelper("SqlClientWrapper") .omitNullValues() .add("repo", repo) .add("client", client) .add("names", names) .toString(); } /** * Creates an immutable copy of a {@link SqlClientWrapper} 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 SqlClientWrapper instance */ public static ImmutableSqlClientWrapper copyOf(SqlClientWrapper instance) { if (instance instanceof ImmutableSqlClientWrapper) { return (ImmutableSqlClientWrapper) instance; } return ImmutableSqlClientWrapper.builder() .from(instance) .build(); } /** * Creates a builder for {@link ImmutableSqlClientWrapper ImmutableSqlClientWrapper}. *

   * ImmutableSqlClientWrapper.builder()
   *    .repo(io.resys.thena.docdb.api.models.Repo) // required {@link SqlClientWrapper#getRepo() repo}
   *    .client(io.vertx.mutiny.sqlclient.Pool) // required {@link SqlClientWrapper#getClient() client}
   *    .names(io.resys.thena.docdb.spi.ClientCollections) // required {@link SqlClientWrapper#getNames() names}
   *    .build();
   * 
* @return A new ImmutableSqlClientWrapper builder */ public static ImmutableSqlClientWrapper.Builder builder() { return new ImmutableSqlClientWrapper.Builder(); } /** * Builds instances of type {@link ImmutableSqlClientWrapper ImmutableSqlClientWrapper}. * 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 = "SqlClientWrapper", generator = "Immutables") @NotThreadSafe public static final class Builder { private static final long INIT_BIT_REPO = 0x1L; private static final long INIT_BIT_CLIENT = 0x2L; private static final long INIT_BIT_NAMES = 0x4L; private long initBits = 0x7L; private @Nullable Repo repo; private @Nullable Pool client; private @Nullable ClientCollections names; private Builder() { } /** * Fill a builder with attribute values from the provided {@code SqlClientWrapper} 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(SqlClientWrapper instance) { Objects.requireNonNull(instance, "instance"); this.repo(instance.getRepo()); this.client(instance.getClient()); this.names(instance.getNames()); return this; } /** * Initializes the value for the {@link SqlClientWrapper#getRepo() repo} attribute. * @param repo The value for repo * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder repo(Repo repo) { this.repo = Objects.requireNonNull(repo, "repo"); initBits &= ~INIT_BIT_REPO; return this; } /** * Initializes the value for the {@link SqlClientWrapper#getClient() client} attribute. * @param client The value for client * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder client(Pool client) { this.client = Objects.requireNonNull(client, "client"); initBits &= ~INIT_BIT_CLIENT; return this; } /** * Initializes the value for the {@link SqlClientWrapper#getNames() names} attribute. * @param names The value for names * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder names(ClientCollections names) { this.names = Objects.requireNonNull(names, "names"); initBits &= ~INIT_BIT_NAMES; return this; } /** * Builds a new {@link ImmutableSqlClientWrapper ImmutableSqlClientWrapper}. * @return An immutable instance of SqlClientWrapper * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableSqlClientWrapper build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return new ImmutableSqlClientWrapper(repo, client, names); } private String formatRequiredAttributesMessage() { List attributes = new ArrayList<>(); if ((initBits & INIT_BIT_REPO) != 0) attributes.add("repo"); if ((initBits & INIT_BIT_CLIENT) != 0) attributes.add("client"); if ((initBits & INIT_BIT_NAMES) != 0) attributes.add("names"); return "Cannot build SqlClientWrapper, some of required attributes are not set " + attributes; } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy