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

org.projectnessie.versioned.gc.actions.ImmutableGcActionsConfig Maven / Gradle / Ivy

There is a newer version: 0.9.2
Show newest version
package org.projectnessie.versioned.gc.actions;

import com.google.common.base.MoreObjects;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.errorprone.annotations.Var;
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 GcActionsConfig}.
 * 

* Use the builder to create immutable instances: * {@code ImmutableGcActionsConfig.builder()}. */ @Generated(from = "GcActionsConfig", generator = "Immutables") @SuppressWarnings({"all"}) @ParametersAreNonnullByDefault @javax.annotation.Generated("org.immutables.processor.ProxyProcessor") @Immutable @CheckReturnValue public final class ImmutableGcActionsConfig implements GcActionsConfig { private final String dynamoRegion; private final @Nullable String dynamoEndpoint; private final GcActionsConfig.StoreType storeType; private ImmutableGcActionsConfig( String dynamoRegion, @Nullable String dynamoEndpoint, GcActionsConfig.StoreType storeType) { this.dynamoRegion = dynamoRegion; this.dynamoEndpoint = dynamoEndpoint; this.storeType = storeType; } /** * @return The value of the {@code dynamoRegion} attribute */ @Override public String getDynamoRegion() { return dynamoRegion; } /** * @return The value of the {@code dynamoEndpoint} attribute */ @Override public @Nullable String getDynamoEndpoint() { return dynamoEndpoint; } /** * @return The value of the {@code storeType} attribute */ @Override public GcActionsConfig.StoreType getStoreType() { return storeType; } /** * Copy the current immutable object by setting a value for the {@link GcActionsConfig#getDynamoRegion() dynamoRegion} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for dynamoRegion * @return A modified copy of the {@code this} object */ public final ImmutableGcActionsConfig withDynamoRegion(String value) { String newValue = Objects.requireNonNull(value, "dynamoRegion"); if (this.dynamoRegion.equals(newValue)) return this; return new ImmutableGcActionsConfig(newValue, this.dynamoEndpoint, this.storeType); } /** * Copy the current immutable object by setting a value for the {@link GcActionsConfig#getDynamoEndpoint() dynamoEndpoint} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for dynamoEndpoint (can be {@code null}) * @return A modified copy of the {@code this} object */ public final ImmutableGcActionsConfig withDynamoEndpoint(@Nullable String value) { if (Objects.equals(this.dynamoEndpoint, value)) return this; return new ImmutableGcActionsConfig(this.dynamoRegion, value, this.storeType); } /** * Copy the current immutable object by setting a value for the {@link GcActionsConfig#getStoreType() storeType} attribute. * A value equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for storeType * @return A modified copy of the {@code this} object */ public final ImmutableGcActionsConfig withStoreType(GcActionsConfig.StoreType value) { if (this.storeType == value) return this; GcActionsConfig.StoreType newValue = Objects.requireNonNull(value, "storeType"); if (this.storeType.equals(newValue)) return this; return new ImmutableGcActionsConfig(this.dynamoRegion, this.dynamoEndpoint, newValue); } /** * This instance is equal to all instances of {@code ImmutableGcActionsConfig} 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 ImmutableGcActionsConfig && equalTo((ImmutableGcActionsConfig) another); } private boolean equalTo(ImmutableGcActionsConfig another) { return dynamoRegion.equals(another.dynamoRegion) && Objects.equals(dynamoEndpoint, another.dynamoEndpoint) && storeType.equals(another.storeType); } /** * Computes a hash code from attributes: {@code dynamoRegion}, {@code dynamoEndpoint}, {@code storeType}. * @return hashCode value */ @Override public int hashCode() { @Var int h = 5381; h += (h << 5) + dynamoRegion.hashCode(); h += (h << 5) + Objects.hashCode(dynamoEndpoint); h += (h << 5) + storeType.hashCode(); return h; } /** * Prints the immutable value {@code GcActionsConfig} with attribute values. * @return A string representation of the value */ @Override public String toString() { return MoreObjects.toStringHelper("GcActionsConfig") .omitNullValues() .add("dynamoRegion", dynamoRegion) .add("dynamoEndpoint", dynamoEndpoint) .add("storeType", storeType) .toString(); } /** * Creates an immutable copy of a {@link GcActionsConfig} 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 GcActionsConfig instance */ public static ImmutableGcActionsConfig copyOf(GcActionsConfig instance) { if (instance instanceof ImmutableGcActionsConfig) { return (ImmutableGcActionsConfig) instance; } return ImmutableGcActionsConfig.builder() .from(instance) .build(); } /** * Creates a builder for {@link ImmutableGcActionsConfig ImmutableGcActionsConfig}. *

   * ImmutableGcActionsConfig.builder()
   *    .dynamoRegion(String) // required {@link GcActionsConfig#getDynamoRegion() dynamoRegion}
   *    .dynamoEndpoint(String | null) // nullable {@link GcActionsConfig#getDynamoEndpoint() dynamoEndpoint}
   *    .storeType(org.projectnessie.versioned.gc.actions.GcActionsConfig.StoreType) // required {@link GcActionsConfig#getStoreType() storeType}
   *    .build();
   * 
* @return A new ImmutableGcActionsConfig builder */ public static ImmutableGcActionsConfig.Builder builder() { return new ImmutableGcActionsConfig.Builder(); } /** * Builds instances of type {@link ImmutableGcActionsConfig ImmutableGcActionsConfig}. * 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 = "GcActionsConfig", generator = "Immutables") @NotThreadSafe public static final class Builder { private static final long INIT_BIT_DYNAMO_REGION = 0x1L; private static final long INIT_BIT_STORE_TYPE = 0x2L; private long initBits = 0x3L; private @Nullable String dynamoRegion; private @Nullable String dynamoEndpoint; private @Nullable GcActionsConfig.StoreType storeType; private Builder() { } /** * Fill a builder with attribute values from the provided {@code GcActionsConfig} 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(GcActionsConfig instance) { Objects.requireNonNull(instance, "instance"); dynamoRegion(instance.getDynamoRegion()); @Nullable String dynamoEndpointValue = instance.getDynamoEndpoint(); if (dynamoEndpointValue != null) { dynamoEndpoint(dynamoEndpointValue); } storeType(instance.getStoreType()); return this; } /** * Initializes the value for the {@link GcActionsConfig#getDynamoRegion() dynamoRegion} attribute. * @param dynamoRegion The value for dynamoRegion * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder dynamoRegion(String dynamoRegion) { this.dynamoRegion = Objects.requireNonNull(dynamoRegion, "dynamoRegion"); initBits &= ~INIT_BIT_DYNAMO_REGION; return this; } /** * Initializes the value for the {@link GcActionsConfig#getDynamoEndpoint() dynamoEndpoint} attribute. * @param dynamoEndpoint The value for dynamoEndpoint (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder dynamoEndpoint(@Nullable String dynamoEndpoint) { this.dynamoEndpoint = dynamoEndpoint; return this; } /** * Initializes the value for the {@link GcActionsConfig#getStoreType() storeType} attribute. * @param storeType The value for storeType * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder storeType(GcActionsConfig.StoreType storeType) { this.storeType = Objects.requireNonNull(storeType, "storeType"); initBits &= ~INIT_BIT_STORE_TYPE; return this; } /** * Builds a new {@link ImmutableGcActionsConfig ImmutableGcActionsConfig}. * @return An immutable instance of GcActionsConfig * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableGcActionsConfig build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return new ImmutableGcActionsConfig(dynamoRegion, dynamoEndpoint, storeType); } private String formatRequiredAttributesMessage() { List attributes = new ArrayList<>(); if ((initBits & INIT_BIT_DYNAMO_REGION) != 0) attributes.add("dynamoRegion"); if ((initBits & INIT_BIT_STORE_TYPE) != 0) attributes.add("storeType"); return "Cannot build GcActionsConfig, some of required attributes are not set " + attributes; } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy