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

org.immutables.criteria.backend.ImmutableInsert Maven / Gradle / Ivy

package org.immutables.criteria.backend;

import com.google.common.base.MoreObjects;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
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 StandardOperations.Insert}.
 * 

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

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





© 2015 - 2025 Weber Informatics LLC | Privacy Policy