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

io.resys.wrench.assets.flow.api.model.ImmutableFlowAutocomplete Maven / Gradle / Ivy

There is a newer version: 3.1.4
Show newest version
package io.resys.wrench.assets.flow.api.model;

import com.google.common.base.MoreObjects;
import com.google.common.collect.ImmutableList;
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 FlowAst.FlowAutocomplete}.
 * 

* Use the builder to create immutable instances: * {@code ImmutableFlowAutocomplete.builder()}. */ @Generated(from = "FlowAst.FlowAutocomplete", generator = "Immutables") @SuppressWarnings({"all"}) @ParametersAreNonnullByDefault @javax.annotation.processing.Generated("org.immutables.processor.ProxyProcessor") @Immutable @CheckReturnValue public final class ImmutableFlowAutocomplete implements FlowAst.FlowAutocomplete { private final String id; private final ImmutableList range; private final ImmutableList value; private ImmutableFlowAutocomplete( String id, ImmutableList range, ImmutableList value) { this.id = id; this.range = range; this.value = value; } /** * @return The value of the {@code id} attribute */ @Override public String getId() { return id; } /** * @return The value of the {@code range} attribute */ @Override public ImmutableList getRange() { return range; } /** * @return The value of the {@code value} attribute */ @Override public ImmutableList getValue() { return value; } /** * Copy the current immutable object by setting a value for the {@link FlowAst.FlowAutocomplete#getId() id} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for id * @return A modified copy of the {@code this} object */ public final ImmutableFlowAutocomplete withId(String value) { String newValue = Objects.requireNonNull(value, "id"); if (this.id.equals(newValue)) return this; return new ImmutableFlowAutocomplete(newValue, this.range, this.value); } /** * Copy the current immutable object with elements that replace the content of {@link FlowAst.FlowAutocomplete#getRange() range}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final ImmutableFlowAutocomplete withRange(FlowAst.FlowCommandRange... elements) { ImmutableList newValue = ImmutableList.copyOf(elements); return new ImmutableFlowAutocomplete(this.id, newValue, this.value); } /** * Copy the current immutable object with elements that replace the content of {@link FlowAst.FlowAutocomplete#getRange() range}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of range elements to set * @return A modified copy of {@code this} object */ public final ImmutableFlowAutocomplete withRange(Iterable elements) { if (this.range == elements) return this; ImmutableList newValue = ImmutableList.copyOf(elements); return new ImmutableFlowAutocomplete(this.id, newValue, this.value); } /** * Copy the current immutable object with elements that replace the content of {@link FlowAst.FlowAutocomplete#getValue() value}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final ImmutableFlowAutocomplete withValue(String... elements) { ImmutableList newValue = ImmutableList.copyOf(elements); return new ImmutableFlowAutocomplete(this.id, this.range, newValue); } /** * Copy the current immutable object with elements that replace the content of {@link FlowAst.FlowAutocomplete#getValue() value}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of value elements to set * @return A modified copy of {@code this} object */ public final ImmutableFlowAutocomplete withValue(Iterable elements) { if (this.value == elements) return this; ImmutableList newValue = ImmutableList.copyOf(elements); return new ImmutableFlowAutocomplete(this.id, this.range, newValue); } /** * This instance is equal to all instances of {@code ImmutableFlowAutocomplete} 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 ImmutableFlowAutocomplete && equalTo((ImmutableFlowAutocomplete) another); } private boolean equalTo(ImmutableFlowAutocomplete another) { return id.equals(another.id) && range.equals(another.range) && value.equals(another.value); } /** * Computes a hash code from attributes: {@code id}, {@code range}, {@code value}. * @return hashCode value */ @Override public int hashCode() { @Var int h = 5381; h += (h << 5) + id.hashCode(); h += (h << 5) + range.hashCode(); h += (h << 5) + value.hashCode(); return h; } /** * Prints the immutable value {@code FlowAutocomplete} with attribute values. * @return A string representation of the value */ @Override public String toString() { return MoreObjects.toStringHelper("FlowAutocomplete") .omitNullValues() .add("id", id) .add("range", range) .add("value", value) .toString(); } /** * Creates an immutable copy of a {@link FlowAst.FlowAutocomplete} 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 FlowAutocomplete instance */ public static ImmutableFlowAutocomplete copyOf(FlowAst.FlowAutocomplete instance) { if (instance instanceof ImmutableFlowAutocomplete) { return (ImmutableFlowAutocomplete) instance; } return ImmutableFlowAutocomplete.builder() .from(instance) .build(); } /** * Creates a builder for {@link ImmutableFlowAutocomplete ImmutableFlowAutocomplete}. *

   * ImmutableFlowAutocomplete.builder()
   *    .id(String) // required {@link FlowAst.FlowAutocomplete#getId() id}
   *    .addRange|addAllRange(io.resys.wrench.assets.flow.api.model.FlowAst.FlowCommandRange) // {@link FlowAst.FlowAutocomplete#getRange() range} elements
   *    .addValue|addAllValue(String) // {@link FlowAst.FlowAutocomplete#getValue() value} elements
   *    .build();
   * 
* @return A new ImmutableFlowAutocomplete builder */ public static ImmutableFlowAutocomplete.Builder builder() { return new ImmutableFlowAutocomplete.Builder(); } /** * Builds instances of type {@link ImmutableFlowAutocomplete ImmutableFlowAutocomplete}. * 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 = "FlowAst.FlowAutocomplete", generator = "Immutables") @NotThreadSafe public static final class Builder { private static final long INIT_BIT_ID = 0x1L; private long initBits = 0x1L; private @Nullable String id; private ImmutableList.Builder range = ImmutableList.builder(); private ImmutableList.Builder value = ImmutableList.builder(); private Builder() { } /** * Fill a builder with attribute values from the provided {@code FlowAutocomplete} instance. * Regular attribute values will be replaced with those from the given instance. * Absent optional values will not replace present values. * Collection elements and entries will be added, not replaced. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(FlowAst.FlowAutocomplete instance) { Objects.requireNonNull(instance, "instance"); id(instance.getId()); addAllRange(instance.getRange()); addAllValue(instance.getValue()); return this; } /** * Initializes the value for the {@link FlowAst.FlowAutocomplete#getId() id} attribute. * @param id The value for id * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder id(String id) { this.id = Objects.requireNonNull(id, "id"); initBits &= ~INIT_BIT_ID; return this; } /** * Adds one element to {@link FlowAst.FlowAutocomplete#getRange() range} list. * @param element A range element * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addRange(FlowAst.FlowCommandRange element) { this.range.add(element); return this; } /** * Adds elements to {@link FlowAst.FlowAutocomplete#getRange() range} list. * @param elements An array of range elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addRange(FlowAst.FlowCommandRange... elements) { this.range.add(elements); return this; } /** * Sets or replaces all elements for {@link FlowAst.FlowAutocomplete#getRange() range} list. * @param elements An iterable of range elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder range(Iterable elements) { this.range = ImmutableList.builder(); return addAllRange(elements); } /** * Adds elements to {@link FlowAst.FlowAutocomplete#getRange() range} list. * @param elements An iterable of range elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAllRange(Iterable elements) { this.range.addAll(elements); return this; } /** * Adds one element to {@link FlowAst.FlowAutocomplete#getValue() value} list. * @param element A value element * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addValue(String element) { this.value.add(element); return this; } /** * Adds elements to {@link FlowAst.FlowAutocomplete#getValue() value} list. * @param elements An array of value elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addValue(String... elements) { this.value.add(elements); return this; } /** * Sets or replaces all elements for {@link FlowAst.FlowAutocomplete#getValue() value} list. * @param elements An iterable of value elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder value(Iterable elements) { this.value = ImmutableList.builder(); return addAllValue(elements); } /** * Adds elements to {@link FlowAst.FlowAutocomplete#getValue() value} list. * @param elements An iterable of value elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAllValue(Iterable elements) { this.value.addAll(elements); return this; } /** * Builds a new {@link ImmutableFlowAutocomplete ImmutableFlowAutocomplete}. * @return An immutable instance of FlowAutocomplete * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableFlowAutocomplete build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return new ImmutableFlowAutocomplete(id, range.build(), value.build()); } private String formatRequiredAttributesMessage() { List attributes = new ArrayList<>(); if ((initBits & INIT_BIT_ID) != 0) attributes.add("id"); return "Cannot build FlowAutocomplete, some of required attributes are not set " + attributes; } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy