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

io.resys.hdes.client.api.programs.ImmutableFlowProgramStepBody Maven / Gradle / Ivy

There is a newer version: 3.130.78
Show newest version
package io.resys.hdes.client.api.programs;

import com.google.common.base.MoreObjects;
import com.google.common.collect.ImmutableMap;
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 FlowProgram.FlowProgramStepBody}.
 * 

* Use the builder to create immutable instances: * {@code ImmutableFlowProgramStepBody.builder()}. */ @Generated(from = "FlowProgram.FlowProgramStepBody", generator = "Immutables") @SuppressWarnings({"all"}) @ParametersAreNonnullByDefault @javax.annotation.processing.Generated("org.immutables.processor.ProxyProcessor") @Immutable @CheckReturnValue public final class ImmutableFlowProgramStepBody implements FlowProgram.FlowProgramStepBody { private final String ref; private final FlowProgram.FlowProgramStepRefType refType; private final ImmutableMap inputMapping; private final Boolean collection; private ImmutableFlowProgramStepBody( String ref, FlowProgram.FlowProgramStepRefType refType, ImmutableMap inputMapping, Boolean collection) { this.ref = ref; this.refType = refType; this.inputMapping = inputMapping; this.collection = collection; } /** * @return The value of the {@code ref} attribute */ @Override public String getRef() { return ref; } /** * @return The value of the {@code refType} attribute */ @Override public FlowProgram.FlowProgramStepRefType getRefType() { return refType; } /** * @return The value of the {@code inputMapping} attribute */ @Override public ImmutableMap getInputMapping() { return inputMapping; } /** * @return The value of the {@code collection} attribute */ @Override public Boolean getCollection() { return collection; } /** * Copy the current immutable object by setting a value for the {@link FlowProgram.FlowProgramStepBody#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 * @return A modified copy of the {@code this} object */ public final ImmutableFlowProgramStepBody withRef(String value) { String newValue = Objects.requireNonNull(value, "ref"); if (this.ref.equals(newValue)) return this; return new ImmutableFlowProgramStepBody(newValue, this.refType, this.inputMapping, this.collection); } /** * Copy the current immutable object by setting a value for the {@link FlowProgram.FlowProgramStepBody#getRefType() refType} attribute. * A value equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for refType * @return A modified copy of the {@code this} object */ public final ImmutableFlowProgramStepBody withRefType(FlowProgram.FlowProgramStepRefType value) { if (this.refType == value) return this; FlowProgram.FlowProgramStepRefType newValue = Objects.requireNonNull(value, "refType"); if (this.refType.equals(newValue)) return this; return new ImmutableFlowProgramStepBody(this.ref, newValue, this.inputMapping, this.collection); } /** * Copy the current immutable object by replacing the {@link FlowProgram.FlowProgramStepBody#getInputMapping() inputMapping} 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 inputMapping map * @return A modified copy of {@code this} object */ public final ImmutableFlowProgramStepBody withInputMapping(Map entries) { if (this.inputMapping == entries) return this; ImmutableMap newValue = ImmutableMap.copyOf(entries); return new ImmutableFlowProgramStepBody(this.ref, this.refType, newValue, this.collection); } /** * Copy the current immutable object by setting a value for the {@link FlowProgram.FlowProgramStepBody#getCollection() collection} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for collection * @return A modified copy of the {@code this} object */ public final ImmutableFlowProgramStepBody withCollection(Boolean value) { Boolean newValue = Objects.requireNonNull(value, "collection"); if (this.collection.equals(newValue)) return this; return new ImmutableFlowProgramStepBody(this.ref, this.refType, this.inputMapping, newValue); } /** * This instance is equal to all instances of {@code ImmutableFlowProgramStepBody} 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 ImmutableFlowProgramStepBody && equalTo((ImmutableFlowProgramStepBody) another); } private boolean equalTo(ImmutableFlowProgramStepBody another) { return ref.equals(another.ref) && refType.equals(another.refType) && inputMapping.equals(another.inputMapping) && collection.equals(another.collection); } /** * Computes a hash code from attributes: {@code ref}, {@code refType}, {@code inputMapping}, {@code collection}. * @return hashCode value */ @Override public int hashCode() { @Var int h = 5381; h += (h << 5) + ref.hashCode(); h += (h << 5) + refType.hashCode(); h += (h << 5) + inputMapping.hashCode(); h += (h << 5) + collection.hashCode(); return h; } /** * Prints the immutable value {@code FlowProgramStepBody} with attribute values. * @return A string representation of the value */ @Override public String toString() { return MoreObjects.toStringHelper("FlowProgramStepBody") .omitNullValues() .add("ref", ref) .add("refType", refType) .add("inputMapping", inputMapping) .add("collection", collection) .toString(); } /** * Creates an immutable copy of a {@link FlowProgram.FlowProgramStepBody} 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 FlowProgramStepBody instance */ public static ImmutableFlowProgramStepBody copyOf(FlowProgram.FlowProgramStepBody instance) { if (instance instanceof ImmutableFlowProgramStepBody) { return (ImmutableFlowProgramStepBody) instance; } return ImmutableFlowProgramStepBody.builder() .from(instance) .build(); } /** * Creates a builder for {@link ImmutableFlowProgramStepBody ImmutableFlowProgramStepBody}. *

   * ImmutableFlowProgramStepBody.builder()
   *    .ref(String) // required {@link FlowProgram.FlowProgramStepBody#getRef() ref}
   *    .refType(io.resys.hdes.client.api.programs.FlowProgram.FlowProgramStepRefType) // required {@link FlowProgram.FlowProgramStepBody#getRefType() refType}
   *    .putInputMapping|putAllInputMapping(String => String) // {@link FlowProgram.FlowProgramStepBody#getInputMapping() inputMapping} mappings
   *    .collection(Boolean) // required {@link FlowProgram.FlowProgramStepBody#getCollection() collection}
   *    .build();
   * 
* @return A new ImmutableFlowProgramStepBody builder */ public static ImmutableFlowProgramStepBody.Builder builder() { return new ImmutableFlowProgramStepBody.Builder(); } /** * Builds instances of type {@link ImmutableFlowProgramStepBody ImmutableFlowProgramStepBody}. * 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 = "FlowProgram.FlowProgramStepBody", generator = "Immutables") @NotThreadSafe public static final class Builder { private static final long INIT_BIT_REF = 0x1L; private static final long INIT_BIT_REF_TYPE = 0x2L; private static final long INIT_BIT_COLLECTION = 0x4L; private long initBits = 0x7L; private @Nullable String ref; private @Nullable FlowProgram.FlowProgramStepRefType refType; private ImmutableMap.Builder inputMapping = ImmutableMap.builder(); private @Nullable Boolean collection; private Builder() { } /** * Fill a builder with attribute values from the provided {@code FlowProgramStepBody} 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(FlowProgram.FlowProgramStepBody instance) { Objects.requireNonNull(instance, "instance"); ref(instance.getRef()); refType(instance.getRefType()); putAllInputMapping(instance.getInputMapping()); collection(instance.getCollection()); return this; } /** * Initializes the value for the {@link FlowProgram.FlowProgramStepBody#getRef() ref} attribute. * @param ref The value for ref * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder ref(String ref) { this.ref = Objects.requireNonNull(ref, "ref"); initBits &= ~INIT_BIT_REF; return this; } /** * Initializes the value for the {@link FlowProgram.FlowProgramStepBody#getRefType() refType} attribute. * @param refType The value for refType * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder refType(FlowProgram.FlowProgramStepRefType refType) { this.refType = Objects.requireNonNull(refType, "refType"); initBits &= ~INIT_BIT_REF_TYPE; return this; } /** * Put one entry to the {@link FlowProgram.FlowProgramStepBody#getInputMapping() inputMapping} map. * @param key The key in the inputMapping map * @param value The associated value in the inputMapping map * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder putInputMapping(String key, String value) { this.inputMapping.put(key, value); return this; } /** * Put one entry to the {@link FlowProgram.FlowProgramStepBody#getInputMapping() inputMapping} 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 putInputMapping(Map.Entry entry) { this.inputMapping.put(entry); return this; } /** * Sets or replaces all mappings from the specified map as entries for the {@link FlowProgram.FlowProgramStepBody#getInputMapping() inputMapping} map. Nulls are not permitted * @param entries The entries that will be added to the inputMapping map * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder inputMapping(Map entries) { this.inputMapping = ImmutableMap.builder(); return putAllInputMapping(entries); } /** * Put all mappings from the specified map as entries to {@link FlowProgram.FlowProgramStepBody#getInputMapping() inputMapping} map. Nulls are not permitted * @param entries The entries that will be added to the inputMapping map * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder putAllInputMapping(Map entries) { this.inputMapping.putAll(entries); return this; } /** * Initializes the value for the {@link FlowProgram.FlowProgramStepBody#getCollection() collection} attribute. * @param collection The value for collection * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder collection(Boolean collection) { this.collection = Objects.requireNonNull(collection, "collection"); initBits &= ~INIT_BIT_COLLECTION; return this; } /** * Builds a new {@link ImmutableFlowProgramStepBody ImmutableFlowProgramStepBody}. * @return An immutable instance of FlowProgramStepBody * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableFlowProgramStepBody build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return new ImmutableFlowProgramStepBody(ref, refType, inputMapping.build(), collection); } private String formatRequiredAttributesMessage() { List attributes = new ArrayList<>(); if ((initBits & INIT_BIT_REF) != 0) attributes.add("ref"); if ((initBits & INIT_BIT_REF_TYPE) != 0) attributes.add("refType"); if ((initBits & INIT_BIT_COLLECTION) != 0) attributes.add("collection"); return "Cannot build FlowProgramStepBody, some of required attributes are not set " + attributes; } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy