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

io.resys.wrench.assets.flow.api.model.ImmutableFlowTaskValue 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.ImmutableMap;
import com.google.common.primitives.Booleans;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.errorprone.annotations.Var;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
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 FlowModel.FlowTaskValue}.
 * 

* Use the builder to create immutable instances: * {@code ImmutableFlowTaskValue.builder()}. */ @Generated(from = "FlowModel.FlowTaskValue", generator = "Immutables") @SuppressWarnings({"all"}) @ParametersAreNonnullByDefault @javax.annotation.processing.Generated("org.immutables.processor.ProxyProcessor") @Immutable @CheckReturnValue public final class ImmutableFlowTaskValue implements FlowModel.FlowTaskValue { private final @Nullable String ref; private final @Nullable FlowModel.FlowTaskExpression expression; private final ImmutableMap inputs; private final boolean isCollection; private ImmutableFlowTaskValue( @Nullable String ref, @Nullable FlowModel.FlowTaskExpression expression, ImmutableMap inputs, boolean isCollection) { this.ref = ref; this.expression = expression; this.inputs = inputs; this.isCollection = isCollection; } /** * @return The value of the {@code ref} attribute */ @Override public @Nullable String getRef() { return ref; } /** * @return The value of the {@code expression} attribute */ @Override public @Nullable FlowModel.FlowTaskExpression getExpression() { return expression; } /** * @return The value of the {@code inputs} attribute */ @Override public ImmutableMap getInputs() { return inputs; } /** * @return The value of the {@code isCollection} attribute */ @Override public boolean isCollection() { return isCollection; } /** * Copy the current immutable object by setting a value for the {@link FlowModel.FlowTaskValue#getRef() ref} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for ref (can be {@code null}) * @return A modified copy of the {@code this} object */ public final ImmutableFlowTaskValue withRef(@Nullable String value) { if (Objects.equals(this.ref, value)) return this; return new ImmutableFlowTaskValue(value, this.expression, this.inputs, this.isCollection); } /** * Copy the current immutable object by setting a value for the {@link FlowModel.FlowTaskValue#getExpression() expression} 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 expression (can be {@code null}) * @return A modified copy of the {@code this} object */ public final ImmutableFlowTaskValue withExpression(@Nullable FlowModel.FlowTaskExpression value) { if (this.expression == value) return this; return new ImmutableFlowTaskValue(this.ref, value, this.inputs, this.isCollection); } /** * Copy the current immutable object by replacing the {@link FlowModel.FlowTaskValue#getInputs() inputs} map with the specified map. * Nulls are not permitted as keys or values. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param entries The entries to be added to the inputs map * @return A modified copy of {@code this} object */ public final ImmutableFlowTaskValue withInputs(Map entries) { if (this.inputs == entries) return this; ImmutableMap newValue = ImmutableMap.copyOf(entries); return new ImmutableFlowTaskValue(this.ref, this.expression, newValue, this.isCollection); } /** * Copy the current immutable object by setting a value for the {@link FlowModel.FlowTaskValue#isCollection() isCollection} attribute. * A value equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for isCollection * @return A modified copy of the {@code this} object */ public final ImmutableFlowTaskValue withIsCollection(boolean value) { if (this.isCollection == value) return this; return new ImmutableFlowTaskValue(this.ref, this.expression, this.inputs, value); } /** * This instance is equal to all instances of {@code ImmutableFlowTaskValue} 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 ImmutableFlowTaskValue && equalTo((ImmutableFlowTaskValue) another); } private boolean equalTo(ImmutableFlowTaskValue another) { return Objects.equals(ref, another.ref) && Objects.equals(expression, another.expression) && inputs.equals(another.inputs) && isCollection == another.isCollection; } /** * Computes a hash code from attributes: {@code ref}, {@code expression}, {@code inputs}, {@code isCollection}. * @return hashCode value */ @Override public int hashCode() { @Var int h = 5381; h += (h << 5) + Objects.hashCode(ref); h += (h << 5) + Objects.hashCode(expression); h += (h << 5) + inputs.hashCode(); h += (h << 5) + Booleans.hashCode(isCollection); return h; } /** * Prints the immutable value {@code FlowTaskValue} with attribute values. * @return A string representation of the value */ @Override public String toString() { return MoreObjects.toStringHelper("FlowTaskValue") .omitNullValues() .add("ref", ref) .add("expression", expression) .add("inputs", inputs) .add("isCollection", isCollection) .toString(); } /** * Creates an immutable copy of a {@link FlowModel.FlowTaskValue} 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 FlowTaskValue instance */ public static ImmutableFlowTaskValue copyOf(FlowModel.FlowTaskValue instance) { if (instance instanceof ImmutableFlowTaskValue) { return (ImmutableFlowTaskValue) instance; } return ImmutableFlowTaskValue.builder() .from(instance) .build(); } /** * Creates a builder for {@link ImmutableFlowTaskValue ImmutableFlowTaskValue}. *

   * ImmutableFlowTaskValue.builder()
   *    .ref(String | null) // nullable {@link FlowModel.FlowTaskValue#getRef() ref}
   *    .expression(io.resys.wrench.assets.flow.api.model.FlowModel.FlowTaskExpression | null) // nullable {@link FlowModel.FlowTaskValue#getExpression() expression}
   *    .putInputs|putAllInputs(String => String) // {@link FlowModel.FlowTaskValue#getInputs() inputs} mappings
   *    .isCollection(boolean) // required {@link FlowModel.FlowTaskValue#isCollection() isCollection}
   *    .build();
   * 
* @return A new ImmutableFlowTaskValue builder */ public static ImmutableFlowTaskValue.Builder builder() { return new ImmutableFlowTaskValue.Builder(); } /** * Builds instances of type {@link ImmutableFlowTaskValue ImmutableFlowTaskValue}. * 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 = "FlowModel.FlowTaskValue", generator = "Immutables") @NotThreadSafe public static final class Builder { private static final long INIT_BIT_IS_COLLECTION = 0x1L; private long initBits = 0x1L; private @Nullable String ref; private @Nullable FlowModel.FlowTaskExpression expression; private ImmutableMap.Builder inputs = ImmutableMap.builder(); private boolean isCollection; private Builder() { } /** * Fill a builder with attribute values from the provided {@code FlowTaskValue} 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(FlowModel.FlowTaskValue instance) { Objects.requireNonNull(instance, "instance"); @Nullable String refValue = instance.getRef(); if (refValue != null) { ref(refValue); } @Nullable FlowModel.FlowTaskExpression expressionValue = instance.getExpression(); if (expressionValue != null) { expression(expressionValue); } putAllInputs(instance.getInputs()); isCollection(instance.isCollection()); return this; } /** * Initializes the value for the {@link FlowModel.FlowTaskValue#getRef() ref} attribute. * @param ref The value for ref (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder ref(@Nullable String ref) { this.ref = ref; return this; } /** * Initializes the value for the {@link FlowModel.FlowTaskValue#getExpression() expression} attribute. * @param expression The value for expression (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder expression(@Nullable FlowModel.FlowTaskExpression expression) { this.expression = expression; return this; } /** * Put one entry to the {@link FlowModel.FlowTaskValue#getInputs() inputs} map. * @param key The key in the inputs map * @param value The associated value in the inputs map * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder putInputs(String key, String value) { this.inputs.put(key, value); return this; } /** * Put one entry to the {@link FlowModel.FlowTaskValue#getInputs() inputs} map. Nulls are not permitted * @param entry The key and value entry * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder putInputs(Map.Entry entry) { this.inputs.put(entry); return this; } /** * Sets or replaces all mappings from the specified map as entries for the {@link FlowModel.FlowTaskValue#getInputs() inputs} map. Nulls are not permitted * @param entries The entries that will be added to the inputs map * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder inputs(Map entries) { this.inputs = ImmutableMap.builder(); return putAllInputs(entries); } /** * Put all mappings from the specified map as entries to {@link FlowModel.FlowTaskValue#getInputs() inputs} map. Nulls are not permitted * @param entries The entries that will be added to the inputs map * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder putAllInputs(Map entries) { this.inputs.putAll(entries); return this; } /** * Initializes the value for the {@link FlowModel.FlowTaskValue#isCollection() isCollection} attribute. * @param isCollection The value for isCollection * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder isCollection(boolean isCollection) { this.isCollection = isCollection; initBits &= ~INIT_BIT_IS_COLLECTION; return this; } /** * Builds a new {@link ImmutableFlowTaskValue ImmutableFlowTaskValue}. * @return An immutable instance of FlowTaskValue * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableFlowTaskValue build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return new ImmutableFlowTaskValue(ref, expression, inputs.build(), isCollection); } private String formatRequiredAttributesMessage() { List attributes = new ArrayList<>(); if ((initBits & INIT_BIT_IS_COLLECTION) != 0) attributes.add("isCollection"); return "Cannot build FlowTaskValue, some of required attributes are not set " + attributes; } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy