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

org.immutables.fixture.ImmutableHasFirstRedactedCompletely Maven / Gradle / Ivy

There is a newer version: 2.10.1
Show newest version
package org.immutables.fixture;

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 HasFirstRedactedCompletely}.
 * 

* Use the builder to create immutable instances: * {@code ImmutableHasFirstRedactedCompletely.builder()}. */ @Generated(from = "HasFirstRedactedCompletely", generator = "Immutables") @SuppressWarnings({"all"}) @ParametersAreNonnullByDefault @javax.annotation.processing.Generated("org.immutables.processor.ProxyProcessor") @Immutable @CheckReturnValue public final class ImmutableHasFirstRedactedCompletely implements HasFirstRedactedCompletely { private final int a1; private final int a2; private ImmutableHasFirstRedactedCompletely(int a1, int a2) { this.a1 = a1; this.a2 = a2; } /** * @return The value of the {@code a1} attribute */ @Override public int a1() { return a1; } /** * @return The value of the {@code a2} attribute */ @Override public int a2() { return a2; } /** * Copy the current immutable object by setting a value for the {@link HasFirstRedactedCompletely#a1() a1} attribute. * A value equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for a1 * @return A modified copy of the {@code this} object */ public final ImmutableHasFirstRedactedCompletely withA1(int value) { if (this.a1 == value) return this; return new ImmutableHasFirstRedactedCompletely(value, this.a2); } /** * Copy the current immutable object by setting a value for the {@link HasFirstRedactedCompletely#a2() a2} attribute. * A value equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for a2 * @return A modified copy of the {@code this} object */ public final ImmutableHasFirstRedactedCompletely withA2(int value) { if (this.a2 == value) return this; return new ImmutableHasFirstRedactedCompletely(this.a1, value); } /** * This instance is equal to all instances of {@code ImmutableHasFirstRedactedCompletely} 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 ImmutableHasFirstRedactedCompletely && equalTo(0, (ImmutableHasFirstRedactedCompletely) another); } private boolean equalTo(int synthetic, ImmutableHasFirstRedactedCompletely another) { return a1 == another.a1 && a2 == another.a2; } /** * Computes a hash code from attributes: {@code a1}, {@code a2}. * @return hashCode value */ @Override public int hashCode() { @Var int h = 5381; h += (h << 5) + a1; h += (h << 5) + a2; return h; } /** * Prints the immutable value {@code HasFirstRedactedCompletely} with attribute values. * @return A string representation of the value */ @Override public String toString() { return "HasFirstRedactedCompletely{" + "a2=" + a2 + "}"; } /** * Creates an immutable copy of a {@link HasFirstRedactedCompletely} 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 HasFirstRedactedCompletely instance */ public static ImmutableHasFirstRedactedCompletely copyOf(HasFirstRedactedCompletely instance) { if (instance instanceof ImmutableHasFirstRedactedCompletely) { return (ImmutableHasFirstRedactedCompletely) instance; } return ImmutableHasFirstRedactedCompletely.builder() .from(instance) .build(); } /** * Creates a builder for {@link ImmutableHasFirstRedactedCompletely ImmutableHasFirstRedactedCompletely}. *

   * ImmutableHasFirstRedactedCompletely.builder()
   *    .a1(int) // required {@link HasFirstRedactedCompletely#a1() a1}
   *    .a2(int) // required {@link HasFirstRedactedCompletely#a2() a2}
   *    .build();
   * 
* @return A new ImmutableHasFirstRedactedCompletely builder */ public static ImmutableHasFirstRedactedCompletely.Builder builder() { return new ImmutableHasFirstRedactedCompletely.Builder(); } /** * Builds instances of type {@link ImmutableHasFirstRedactedCompletely ImmutableHasFirstRedactedCompletely}. * 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 = "HasFirstRedactedCompletely", generator = "Immutables") @NotThreadSafe public static final class Builder { private static final long INIT_BIT_A1 = 0x1L; private static final long INIT_BIT_A2 = 0x2L; private long initBits = 0x3L; private int a1; private int a2; private Builder() { } /** * Fill a builder with attribute values from the provided {@code HasFirstRedactedCompletely} 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(HasFirstRedactedCompletely instance) { Objects.requireNonNull(instance, "instance"); a1(instance.a1()); a2(instance.a2()); return this; } /** * Initializes the value for the {@link HasFirstRedactedCompletely#a1() a1} attribute. * @param a1 The value for a1 * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder a1(int a1) { this.a1 = a1; initBits &= ~INIT_BIT_A1; return this; } /** * Initializes the value for the {@link HasFirstRedactedCompletely#a2() a2} attribute. * @param a2 The value for a2 * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder a2(int a2) { this.a2 = a2; initBits &= ~INIT_BIT_A2; return this; } /** * Builds a new {@link ImmutableHasFirstRedactedCompletely ImmutableHasFirstRedactedCompletely}. * @return An immutable instance of HasFirstRedactedCompletely * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableHasFirstRedactedCompletely build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return new ImmutableHasFirstRedactedCompletely(a1, a2); } private String formatRequiredAttributesMessage() { List attributes = new ArrayList<>(); if ((initBits & INIT_BIT_A1) != 0) attributes.add("a1"); if ((initBits & INIT_BIT_A2) != 0) attributes.add("a2"); return "Cannot build HasFirstRedactedCompletely, some of required attributes are not set " + attributes; } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy