org.immutables.fixture.style.nested.ImmutableEnclosingOvershadow Maven / Gradle / Ivy
Show all versions of value-fixture Show documentation
package org.immutables.fixture.style.nested;
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;
/**
* {@code ImmutableEnclosingOvershadow} contains immutable implementation classes generated from
* abstract value types defined as nested inside {@link EnclosingOvershadow}.
* @see EnclosingOvershadow.Foo
* @see EnclosingOvershadow.Foo.Bar
* @see EnclosingOvershadow.Foo.Bar.Baz
*/
@Generated(from = "EnclosingOvershadow", generator = "Immutables")
@SuppressWarnings({"all"})
@ParametersAreNonnullByDefault
@javax.annotation.Generated("org.immutables.processor.ProxyProcessor")
public final class ImmutableEnclosingOvershadow {
private ImmutableEnclosingOvershadow() {}
/**
* Immutable implementation of {@link EnclosingOvershadow.Foo}.
*
* Use the builder to create immutable instances:
* {@code new EnclosingOvershadow.Foo.Builder()}.
*/
@Generated(from = "EnclosingOvershadow.Foo", generator = "Immutables")
@Immutable
@CheckReturnValue
static final class Foo implements EnclosingOvershadow.Foo {
private final int a;
private Foo(int a) {
this.a = a;
}
/**
* @return The value of the {@code a} attribute
*/
@Override
public int a() {
return a;
}
/**
* Copy the current immutable object by setting a value for the {@link EnclosingOvershadow.Foo#a() a} attribute.
* A value equality check is used to prevent copying of the same value by returning {@code this}.
* @param value A new value for a
* @return A modified copy of the {@code this} object
*/
public final ImmutableEnclosingOvershadow.Foo withA(int value) {
if (this.a == value) return this;
return new ImmutableEnclosingOvershadow.Foo(value);
}
/**
* This instance is equal to all instances of {@code Foo} 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 ImmutableEnclosingOvershadow.Foo
&& equalTo(0, (ImmutableEnclosingOvershadow.Foo) another);
}
private boolean equalTo(int synthetic, ImmutableEnclosingOvershadow.Foo another) {
return a == another.a;
}
/**
* Computes a hash code from attributes: {@code a}.
* @return hashCode value
*/
@Override
public int hashCode() {
@Var int h = 5381;
h += (h << 5) + a;
return h;
}
/**
* Prints the immutable value {@code Foo} with attribute values.
* @return A string representation of the value
*/
@Override
public String toString() {
return MoreObjects.toStringHelper("Foo")
.omitNullValues()
.add("a", a)
.toString();
}
/**
* Creates an immutable copy of a {@link EnclosingOvershadow.Foo} 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 Foo instance
*/
public static EnclosingOvershadow.Foo copyOf(EnclosingOvershadow.Foo instance) {
if (instance instanceof ImmutableEnclosingOvershadow.Foo) {
return (ImmutableEnclosingOvershadow.Foo) instance;
}
return new EnclosingOvershadow.Foo.Builder()
.from(instance)
.build();
}
/**
* Builds instances of type {@link EnclosingOvershadow.Foo Foo}.
* 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 = "EnclosingOvershadow.Foo", generator = "Immutables")
@NotThreadSafe
public static class Builder {
private static final long INIT_BIT_A = 0x1L;
private long initBits = 0x1L;
private int a;
/**
* Creates a builder for {@link EnclosingOvershadow.Foo Foo} instances.
*
* new EnclosingOvershadow.Foo.Builder()
* .a(int) // required {@link EnclosingOvershadow.Foo#a() a}
* .build();
*
*/
public Builder() {
if (!(this instanceof EnclosingOvershadow.Foo.Builder)) {
throw new UnsupportedOperationException("Use: new EnclosingOvershadow.Foo.Builder()");
}
}
/**
* Fill a builder with attribute values from the provided {@code Foo} 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 EnclosingOvershadow.Foo.Builder from(EnclosingOvershadow.Foo instance) {
Objects.requireNonNull(instance, "instance");
a(instance.a());
return (EnclosingOvershadow.Foo.Builder) this;
}
/**
* Initializes the value for the {@link EnclosingOvershadow.Foo#a() a} attribute.
* @param a The value for a
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final EnclosingOvershadow.Foo.Builder a(int a) {
this.a = a;
initBits &= ~INIT_BIT_A;
return (EnclosingOvershadow.Foo.Builder) this;
}
/**
* Builds a new {@link EnclosingOvershadow.Foo Foo}.
* @return An immutable instance of Foo
* @throws java.lang.IllegalStateException if any required attributes are missing
*/
public EnclosingOvershadow.Foo build() {
if (initBits != 0) {
throw new IllegalStateException(formatRequiredAttributesMessage());
}
return new ImmutableEnclosingOvershadow.Foo(a);
}
private String formatRequiredAttributesMessage() {
List attributes = new ArrayList<>();
if ((initBits & INIT_BIT_A) != 0) attributes.add("a");
return "Cannot build Foo, some of required attributes are not set " + attributes;
}
}
}
/**
* Immutable implementation of {@link EnclosingOvershadow.Foo.Bar}.
*
* Use the builder to create immutable instances:
* {@code new EnclosingOvershadow.Foo.Bar.Builder()}.
*/
@Generated(from = "EnclosingOvershadow.Foo.Bar", generator = "Immutables")
@Immutable
@CheckReturnValue
public static final class Bar implements EnclosingOvershadow.Foo.Bar {
private final int b;
private Bar(int b) {
this.b = b;
}
/**
* @return The value of the {@code b} attribute
*/
@Override
public int b() {
return b;
}
/**
* Copy the current immutable object by setting a value for the {@link EnclosingOvershadow.Foo.Bar#b() b} attribute.
* A value equality check is used to prevent copying of the same value by returning {@code this}.
* @param value A new value for b
* @return A modified copy of the {@code this} object
*/
public final ImmutableEnclosingOvershadow.Bar withB(int value) {
if (this.b == value) return this;
return new ImmutableEnclosingOvershadow.Bar(value);
}
/**
* This instance is equal to all instances of {@code Bar} 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 ImmutableEnclosingOvershadow.Bar
&& equalTo(0, (ImmutableEnclosingOvershadow.Bar) another);
}
private boolean equalTo(int synthetic, ImmutableEnclosingOvershadow.Bar another) {
return b == another.b;
}
/**
* Computes a hash code from attributes: {@code b}.
* @return hashCode value
*/
@Override
public int hashCode() {
@Var int h = 5381;
h += (h << 5) + b;
return h;
}
/**
* Prints the immutable value {@code Bar} with attribute values.
* @return A string representation of the value
*/
@Override
public String toString() {
return MoreObjects.toStringHelper("Bar")
.omitNullValues()
.add("b", b)
.toString();
}
/**
* Creates an immutable copy of a {@link EnclosingOvershadow.Foo.Bar} 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 Bar instance
*/
public static EnclosingOvershadow.Foo.Bar copyOf(EnclosingOvershadow.Foo.Bar instance) {
if (instance instanceof ImmutableEnclosingOvershadow.Bar) {
return (ImmutableEnclosingOvershadow.Bar) instance;
}
return new EnclosingOvershadow.Foo.Bar.Builder()
.from(instance)
.build();
}
/**
* Builds instances of type {@link EnclosingOvershadow.Foo.Bar Bar}.
* 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 = "EnclosingOvershadow.Foo.Bar", generator = "Immutables")
@NotThreadSafe
public static class Builder {
private static final long INIT_BIT_B = 0x1L;
private long initBits = 0x1L;
private int b;
/**
* Creates a builder for {@link EnclosingOvershadow.Foo.Bar Bar} instances.
*
* new EnclosingOvershadow.Foo.Bar.Builder()
* .b(int) // required {@link EnclosingOvershadow.Foo.Bar#b() b}
* .build();
*
*/
public Builder() {
if (!(this instanceof EnclosingOvershadow.Foo.Bar.Builder)) {
throw new UnsupportedOperationException("Use: new EnclosingOvershadow.Foo.Bar.Builder()");
}
}
/**
* Fill a builder with attribute values from the provided {@code Bar} 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 EnclosingOvershadow.Foo.Bar.Builder from(EnclosingOvershadow.Foo.Bar instance) {
Objects.requireNonNull(instance, "instance");
b(instance.b());
return (EnclosingOvershadow.Foo.Bar.Builder) this;
}
/**
* Initializes the value for the {@link EnclosingOvershadow.Foo.Bar#b() b} attribute.
* @param b The value for b
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final EnclosingOvershadow.Foo.Bar.Builder b(int b) {
this.b = b;
initBits &= ~INIT_BIT_B;
return (EnclosingOvershadow.Foo.Bar.Builder) this;
}
/**
* Builds a new {@link EnclosingOvershadow.Foo.Bar Bar}.
* @return An immutable instance of Bar
* @throws java.lang.IllegalStateException if any required attributes are missing
*/
public EnclosingOvershadow.Foo.Bar build() {
if (initBits != 0) {
throw new IllegalStateException(formatRequiredAttributesMessage());
}
return new ImmutableEnclosingOvershadow.Bar(b);
}
private String formatRequiredAttributesMessage() {
List attributes = new ArrayList<>();
if ((initBits & INIT_BIT_B) != 0) attributes.add("b");
return "Cannot build Bar, some of required attributes are not set " + attributes;
}
}
}
/**
* Immutable implementation of {@link EnclosingOvershadow.Foo.Bar.Baz}.
*
* Use the builder to create immutable instances:
* {@code new EnclosingOvershadow.Foo.Bar.Baz.Builder()}.
*/
@Generated(from = "EnclosingOvershadow.Foo.Bar.Baz", generator = "Immutables")
@Immutable
@CheckReturnValue
public static final class Baz implements EnclosingOvershadow.Foo.Bar.Baz {
private final int c;
private Baz(int c) {
this.c = c;
}
/**
* @return The value of the {@code c} attribute
*/
@Override
public int c() {
return c;
}
/**
* Copy the current immutable object by setting a value for the {@link EnclosingOvershadow.Foo.Bar.Baz#c() c} attribute.
* A value equality check is used to prevent copying of the same value by returning {@code this}.
* @param value A new value for c
* @return A modified copy of the {@code this} object
*/
public final ImmutableEnclosingOvershadow.Baz withC(int value) {
if (this.c == value) return this;
return new ImmutableEnclosingOvershadow.Baz(value);
}
/**
* This instance is equal to all instances of {@code Baz} 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 ImmutableEnclosingOvershadow.Baz
&& equalTo(0, (ImmutableEnclosingOvershadow.Baz) another);
}
private boolean equalTo(int synthetic, ImmutableEnclosingOvershadow.Baz another) {
return c == another.c;
}
/**
* Computes a hash code from attributes: {@code c}.
* @return hashCode value
*/
@Override
public int hashCode() {
@Var int h = 5381;
h += (h << 5) + c;
return h;
}
/**
* Prints the immutable value {@code Baz} with attribute values.
* @return A string representation of the value
*/
@Override
public String toString() {
return MoreObjects.toStringHelper("Baz")
.omitNullValues()
.add("c", c)
.toString();
}
/**
* Creates an immutable copy of a {@link EnclosingOvershadow.Foo.Bar.Baz} 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 Baz instance
*/
public static EnclosingOvershadow.Foo.Bar.Baz copyOf(EnclosingOvershadow.Foo.Bar.Baz instance) {
if (instance instanceof ImmutableEnclosingOvershadow.Baz) {
return (ImmutableEnclosingOvershadow.Baz) instance;
}
return new EnclosingOvershadow.Foo.Bar.Baz.Builder()
.from(instance)
.build();
}
/**
* Builds instances of type {@link EnclosingOvershadow.Foo.Bar.Baz Baz}.
* 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 = "EnclosingOvershadow.Foo.Bar.Baz", generator = "Immutables")
@NotThreadSafe
public static class Builder {
private static final long INIT_BIT_C = 0x1L;
private long initBits = 0x1L;
private int c;
/**
* Creates a builder for {@link EnclosingOvershadow.Foo.Bar.Baz Baz} instances.
*
* new EnclosingOvershadow.Foo.Bar.Baz.Builder()
* .c(int) // required {@link EnclosingOvershadow.Foo.Bar.Baz#c() c}
* .build();
*
*/
public Builder() {
if (!(this instanceof EnclosingOvershadow.Foo.Bar.Baz.Builder)) {
throw new UnsupportedOperationException("Use: new EnclosingOvershadow.Foo.Bar.Baz.Builder()");
}
}
/**
* Fill a builder with attribute values from the provided {@code Baz} 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 EnclosingOvershadow.Foo.Bar.Baz.Builder from(EnclosingOvershadow.Foo.Bar.Baz instance) {
Objects.requireNonNull(instance, "instance");
c(instance.c());
return (EnclosingOvershadow.Foo.Bar.Baz.Builder) this;
}
/**
* Initializes the value for the {@link EnclosingOvershadow.Foo.Bar.Baz#c() c} attribute.
* @param c The value for c
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final EnclosingOvershadow.Foo.Bar.Baz.Builder c(int c) {
this.c = c;
initBits &= ~INIT_BIT_C;
return (EnclosingOvershadow.Foo.Bar.Baz.Builder) this;
}
/**
* Builds a new {@link EnclosingOvershadow.Foo.Bar.Baz Baz}.
* @return An immutable instance of Baz
* @throws java.lang.IllegalStateException if any required attributes are missing
*/
public EnclosingOvershadow.Foo.Bar.Baz build() {
if (initBits != 0) {
throw new IllegalStateException(formatRequiredAttributesMessage());
}
return new ImmutableEnclosingOvershadow.Baz(c);
}
private String formatRequiredAttributesMessage() {
List attributes = new ArrayList<>();
if ((initBits & INIT_BIT_C) != 0) attributes.add("c");
return "Cannot build Baz, some of required attributes are not set " + attributes;
}
}
}
}