org.immutables.fixture.nested.ImmutableInnerNested Maven / Gradle / Ivy
package org.immutables.fixture.nested;
import com.google.common.base.Preconditions;
import javax.annotation.Generated;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import javax.annotation.concurrent.Immutable;
import javax.annotation.concurrent.NotThreadSafe;
/**
* Immutable implementation of {@link InnerNested}.
*
* Use the builder to create immutable instances:
* {@code ImmutableInnerNested.builder()}.
*/
@SuppressWarnings("all")
@ParametersAreNonnullByDefault
@Generated({"Immutables.generator", "InnerNested"})
@Immutable
public final class ImmutableInnerNested implements InnerNested {
private ImmutableInnerNested(ImmutableInnerNested.Builder builder) {
}
/**
* This instance is equal to all instances of {@code ImmutableInnerNested} 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 ImmutableInnerNested
&& equalTo((ImmutableInnerNested) another);
}
private boolean equalTo(ImmutableInnerNested another) {
return true;
}
/**
* Returns a constant hash code value.
* @return hashCode value
*/
@Override
public int hashCode() {
return 1938187725;
}
/**
* Prints the immutable value {@code InnerNested}.
* @return A string representation of the value
*/
@Override
public String toString() {
return "InnerNested{}";
}
/**
* Creates an immutable copy of a {@link InnerNested} 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 InnerNested instance
*/
public static ImmutableInnerNested copyOf(InnerNested instance) {
if (instance instanceof ImmutableInnerNested) {
return (ImmutableInnerNested) instance;
}
return ImmutableInnerNested.builder()
.from(instance)
.build();
}
/**
* Creates a builder for {@link ImmutableInnerNested ImmutableInnerNested}.
* @return A new ImmutableInnerNested builder
*/
public static ImmutableInnerNested.Builder builder() {
return new ImmutableInnerNested.Builder();
}
/**
* Builds instances of type {@link ImmutableInnerNested ImmutableInnerNested}.
* 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.
*/
@NotThreadSafe
public static final class Builder {
private Builder() {
}
/**
* Fill a builder with attribute values from the provided {@code InnerNested} 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
*/
public final Builder from(InnerNested instance) {
Preconditions.checkNotNull(instance, "instance");
return this;
}
/**
* Builds a new {@link ImmutableInnerNested ImmutableInnerNested}.
* @return An immutable instance of InnerNested
* @throws java.lang.IllegalStateException if any required attributes are missing
*/
public ImmutableInnerNested build() {
return new ImmutableInnerNested(this);
}
}
/**
* Immutable implementation of {@link InnerNested.Inner}.
*
* Use the builder to create immutable instances:
* {@code ImmutableInnerNested.Inner.builder()}.
*/
@Immutable
public static final class Inner extends InnerNested.Inner {
private Inner(ImmutableInnerNested.Inner.Builder builder) {
}
/**
* This instance is equal to all instances of {@code Inner} 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 Inner
&& equalTo((Inner) another);
}
private boolean equalTo(Inner another) {
return true;
}
/**
* Returns a constant hash code value.
* @return hashCode value
*/
@Override
public int hashCode() {
return 1402615317;
}
/**
* Prints the immutable value {@code Inner}.
* @return A string representation of the value
*/
@Override
public String toString() {
return "Inner{}";
}
/**
* Creates an immutable copy of a {@link InnerNested.Inner} 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 Inner instance
*/
public static ImmutableInnerNested.Inner copyOf(InnerNested.Inner instance) {
if (instance instanceof ImmutableInnerNested.Inner) {
return (ImmutableInnerNested.Inner) instance;
}
return ImmutableInnerNested.Inner.builder()
.from(instance)
.build();
}
/**
* Creates a builder for {@link ImmutableInnerNested.Inner Inner}.
* @return A new Inner builder
*/
public static ImmutableInnerNested.Inner.Builder builder() {
return new ImmutableInnerNested.Inner.Builder();
}
/**
* Builds instances of type {@link ImmutableInnerNested.Inner Inner}.
* 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.
*/
@NotThreadSafe
public static final class Builder {
private Builder() {
}
/**
* Fill a builder with attribute values from the provided {@code Inner} 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
*/
public final Builder from(InnerNested.Inner instance) {
Preconditions.checkNotNull(instance, "instance");
return this;
}
/**
* Builds a new {@link ImmutableInnerNested.Inner Inner}.
* @return An immutable instance of Inner
* @throws java.lang.IllegalStateException if any required attributes are missing
*/
public ImmutableInnerNested.Inner build() {
return new ImmutableInnerNested.Inner(this);
}
}
}
/**
* Immutable implementation of {@link InnerNested.Nested}.
*
* Use the builder to create immutable instances:
* {@code ImmutableInnerNested.Nested.builder()}.
*/
@Immutable
public static final class Nested implements InnerNested.Nested {
private Nested(ImmutableInnerNested.Nested.Builder builder) {
}
/**
* This instance is equal to all instances of {@code Nested} 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 Nested
&& equalTo((Nested) another);
}
private boolean equalTo(Nested another) {
return true;
}
/**
* Returns a constant hash code value.
* @return hashCode value
*/
@Override
public int hashCode() {
return 666398070;
}
/**
* Prints the immutable value {@code Nested}.
* @return A string representation of the value
*/
@Override
public String toString() {
return "Nested{}";
}
/**
* Creates an immutable copy of a {@link InnerNested.Nested} 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 Nested instance
*/
public static ImmutableInnerNested.Nested copyOf(InnerNested.Nested instance) {
if (instance instanceof ImmutableInnerNested.Nested) {
return (ImmutableInnerNested.Nested) instance;
}
return ImmutableInnerNested.Nested.builder()
.from(instance)
.build();
}
/**
* Creates a builder for {@link ImmutableInnerNested.Nested Nested}.
* @return A new Nested builder
*/
public static ImmutableInnerNested.Nested.Builder builder() {
return new ImmutableInnerNested.Nested.Builder();
}
/**
* Builds instances of type {@link ImmutableInnerNested.Nested Nested}.
* 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.
*/
@NotThreadSafe
public static final class Builder {
private Builder() {
}
/**
* Fill a builder with attribute values from the provided {@code Nested} 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
*/
public final Builder from(InnerNested.Nested instance) {
Preconditions.checkNotNull(instance, "instance");
return this;
}
/**
* Builds a new {@link ImmutableInnerNested.Nested Nested}.
* @return An immutable instance of Nested
* @throws java.lang.IllegalStateException if any required attributes are missing
*/
public ImmutableInnerNested.Nested build() {
return new ImmutableInnerNested.Nested(this);
}
}
}
}