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

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

package org.immutables.fixture;

import com.google.common.base.MoreObjects;
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;
import org.immutables.mongo.types.Id;

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

* Use the builder to create immutable instances: * {@code ImmutableSillyEntitySecond.builder()}. */ @SuppressWarnings("all") @ParametersAreNonnullByDefault @Generated({"Immutables.generator", "SillyEntitySecond"}) @Immutable public final class ImmutableSillyEntitySecond extends SillyEntitySecond { private final Id id; private ImmutableSillyEntitySecond(ImmutableSillyEntitySecond.Builder builder) { this.id = builder.id != null ? builder.id : Preconditions.checkNotNull(super.id(), "id"); } private ImmutableSillyEntitySecond(Id id) { this.id = id; } /** * @return The value of the {@code id} attribute */ @Override public Id id() { return id; } /** * Copy the current immutable object by setting a value for the {@link SillyEntitySecond#id() id} attribute. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param id A new value for id * @return A modified copy of the {@code this} object */ public final ImmutableSillyEntitySecond withId(Id id) { if (this.id == id) return this; Id newValue = Preconditions.checkNotNull(id, "id"); return new ImmutableSillyEntitySecond(newValue); } /** * This instance is equal to all instances of {@code ImmutableSillyEntitySecond} 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 ImmutableSillyEntitySecond && equalTo((ImmutableSillyEntitySecond) another); } private boolean equalTo(ImmutableSillyEntitySecond another) { return id.equals(another.id); } /** * Computes a hash code from attributes: {@code id}. * @return hashCode value */ @Override public int hashCode() { int h = 31; h = h * 17 + id.hashCode(); return h; } /** * Prints the immutable value {@code SillyEntitySecond} with attribute values. * @return A string representation of the value */ @Override public String toString() { return MoreObjects.toStringHelper("SillyEntitySecond") .omitNullValues() .add("id", id) .toString(); } /** * Creates an immutable copy of a {@link SillyEntitySecond} 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 SillyEntitySecond instance */ public static ImmutableSillyEntitySecond copyOf(SillyEntitySecond instance) { if (instance instanceof ImmutableSillyEntitySecond) { return (ImmutableSillyEntitySecond) instance; } return ImmutableSillyEntitySecond.builder() .from(instance) .build(); } /** * Creates a builder for {@link ImmutableSillyEntitySecond ImmutableSillyEntitySecond}. * @return A new ImmutableSillyEntitySecond builder */ public static ImmutableSillyEntitySecond.Builder builder() { return new ImmutableSillyEntitySecond.Builder(); } /** * Builds instances of type {@link ImmutableSillyEntitySecond ImmutableSillyEntitySecond}. * 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 @Nullable Id id; private Builder() { } /** * Fill a builder with attribute values from the provided {@code SillyEntitySecond} 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(SillyEntitySecond instance) { Preconditions.checkNotNull(instance, "instance"); id(instance.id()); return this; } /** * Initializes the value for the {@link SillyEntitySecond#id() id} attribute. *

If not set, this attribute will have a default value as returned by the initializer of {@link SillyEntitySecond#id() id}. * @param id The value for id * @return {@code this} builder for use in a chained invocation */ public final Builder id(Id id) { this.id = Preconditions.checkNotNull(id, "id"); return this; } /** * Builds a new {@link ImmutableSillyEntitySecond ImmutableSillyEntitySecond}. * @return An immutable instance of SillyEntitySecond * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableSillyEntitySecond build() { return new ImmutableSillyEntitySecond(this); } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy