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

io.resys.hdes.client.api.programs.ImmutableFlowResult 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.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.errorprone.annotations.Var;
import java.io.Serializable;
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.FlowResult}.
 * 

* Use the builder to create immutable instances: * {@code ImmutableFlowResult.builder()}. */ @Generated(from = "FlowProgram.FlowResult", generator = "Immutables") @SuppressWarnings({"all"}) @ParametersAreNonnullByDefault @javax.annotation.processing.Generated("org.immutables.processor.ProxyProcessor") @Immutable @CheckReturnValue public final class ImmutableFlowResult implements FlowProgram.FlowResult { private final String stepId; private final String shortHistory; private final ImmutableList logs; private final FlowProgram.FlowExecutionStatus status; private final ImmutableMap accepts; private final ImmutableMap returns; private ImmutableFlowResult( String stepId, String shortHistory, ImmutableList logs, FlowProgram.FlowExecutionStatus status, ImmutableMap accepts, ImmutableMap returns) { this.stepId = stepId; this.shortHistory = shortHistory; this.logs = logs; this.status = status; this.accepts = accepts; this.returns = returns; } /** * @return The value of the {@code stepId} attribute */ @Override public String getStepId() { return stepId; } /** * @return The value of the {@code shortHistory} attribute */ @Override public String getShortHistory() { return shortHistory; } /** * @return The value of the {@code logs} attribute */ @Override public ImmutableList getLogs() { return logs; } /** * @return The value of the {@code status} attribute */ @Override public FlowProgram.FlowExecutionStatus getStatus() { return status; } /** * @return The value of the {@code accepts} attribute */ @Override public ImmutableMap getAccepts() { return accepts; } /** * @return The value of the {@code returns} attribute */ @Override public ImmutableMap getReturns() { return returns; } /** * Copy the current immutable object by setting a value for the {@link FlowProgram.FlowResult#getStepId() stepId} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for stepId * @return A modified copy of the {@code this} object */ public final ImmutableFlowResult withStepId(String value) { String newValue = Objects.requireNonNull(value, "stepId"); if (this.stepId.equals(newValue)) return this; return new ImmutableFlowResult(newValue, this.shortHistory, this.logs, this.status, this.accepts, this.returns); } /** * Copy the current immutable object by setting a value for the {@link FlowProgram.FlowResult#getShortHistory() shortHistory} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for shortHistory * @return A modified copy of the {@code this} object */ public final ImmutableFlowResult withShortHistory(String value) { String newValue = Objects.requireNonNull(value, "shortHistory"); if (this.shortHistory.equals(newValue)) return this; return new ImmutableFlowResult(this.stepId, newValue, this.logs, this.status, this.accepts, this.returns); } /** * Copy the current immutable object with elements that replace the content of {@link FlowProgram.FlowResult#getLogs() logs}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final ImmutableFlowResult withLogs(FlowProgram.FlowResultLog... elements) { ImmutableList newValue = ImmutableList.copyOf(elements); return new ImmutableFlowResult(this.stepId, this.shortHistory, newValue, this.status, this.accepts, this.returns); } /** * Copy the current immutable object with elements that replace the content of {@link FlowProgram.FlowResult#getLogs() logs}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of logs elements to set * @return A modified copy of {@code this} object */ public final ImmutableFlowResult withLogs(Iterable elements) { if (this.logs == elements) return this; ImmutableList newValue = ImmutableList.copyOf(elements); return new ImmutableFlowResult(this.stepId, this.shortHistory, newValue, this.status, this.accepts, this.returns); } /** * Copy the current immutable object by setting a value for the {@link FlowProgram.FlowResult#getStatus() status} attribute. * A value equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for status * @return A modified copy of the {@code this} object */ public final ImmutableFlowResult withStatus(FlowProgram.FlowExecutionStatus value) { if (this.status == value) return this; FlowProgram.FlowExecutionStatus newValue = Objects.requireNonNull(value, "status"); if (this.status.equals(newValue)) return this; return new ImmutableFlowResult(this.stepId, this.shortHistory, this.logs, newValue, this.accepts, this.returns); } /** * Copy the current immutable object by replacing the {@link FlowProgram.FlowResult#getAccepts() accepts} 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 accepts map * @return A modified copy of {@code this} object */ public final ImmutableFlowResult withAccepts(Map entries) { if (this.accepts == entries) return this; ImmutableMap newValue = ImmutableMap.copyOf(entries); return new ImmutableFlowResult(this.stepId, this.shortHistory, this.logs, this.status, newValue, this.returns); } /** * Copy the current immutable object by replacing the {@link FlowProgram.FlowResult#getReturns() returns} 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 returns map * @return A modified copy of {@code this} object */ public final ImmutableFlowResult withReturns(Map entries) { if (this.returns == entries) return this; ImmutableMap newValue = ImmutableMap.copyOf(entries); return new ImmutableFlowResult(this.stepId, this.shortHistory, this.logs, this.status, this.accepts, newValue); } /** * This instance is equal to all instances of {@code ImmutableFlowResult} 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 ImmutableFlowResult && equalTo((ImmutableFlowResult) another); } private boolean equalTo(ImmutableFlowResult another) { return stepId.equals(another.stepId) && shortHistory.equals(another.shortHistory) && logs.equals(another.logs) && status.equals(another.status) && accepts.equals(another.accepts) && returns.equals(another.returns); } /** * Computes a hash code from attributes: {@code stepId}, {@code shortHistory}, {@code logs}, {@code status}, {@code accepts}, {@code returns}. * @return hashCode value */ @Override public int hashCode() { @Var int h = 5381; h += (h << 5) + stepId.hashCode(); h += (h << 5) + shortHistory.hashCode(); h += (h << 5) + logs.hashCode(); h += (h << 5) + status.hashCode(); h += (h << 5) + accepts.hashCode(); h += (h << 5) + returns.hashCode(); return h; } /** * Prints the immutable value {@code FlowResult} with attribute values. * @return A string representation of the value */ @Override public String toString() { return MoreObjects.toStringHelper("FlowResult") .omitNullValues() .add("stepId", stepId) .add("shortHistory", shortHistory) .add("logs", logs) .add("status", status) .add("accepts", accepts) .add("returns", returns) .toString(); } /** * Creates an immutable copy of a {@link FlowProgram.FlowResult} 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 FlowResult instance */ public static ImmutableFlowResult copyOf(FlowProgram.FlowResult instance) { if (instance instanceof ImmutableFlowResult) { return (ImmutableFlowResult) instance; } return ImmutableFlowResult.builder() .from(instance) .build(); } /** * Creates a builder for {@link ImmutableFlowResult ImmutableFlowResult}. *

   * ImmutableFlowResult.builder()
   *    .stepId(String) // required {@link FlowProgram.FlowResult#getStepId() stepId}
   *    .shortHistory(String) // required {@link FlowProgram.FlowResult#getShortHistory() shortHistory}
   *    .addLogs|addAllLogs(io.resys.hdes.client.api.programs.FlowProgram.FlowResultLog) // {@link FlowProgram.FlowResult#getLogs() logs} elements
   *    .status(io.resys.hdes.client.api.programs.FlowProgram.FlowExecutionStatus) // required {@link FlowProgram.FlowResult#getStatus() status}
   *    .putAccepts|putAllAccepts(String => java.io.Serializable) // {@link FlowProgram.FlowResult#getAccepts() accepts} mappings
   *    .putReturns|putAllReturns(String => java.io.Serializable) // {@link FlowProgram.FlowResult#getReturns() returns} mappings
   *    .build();
   * 
* @return A new ImmutableFlowResult builder */ public static ImmutableFlowResult.Builder builder() { return new ImmutableFlowResult.Builder(); } /** * Builds instances of type {@link ImmutableFlowResult ImmutableFlowResult}. * 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.FlowResult", generator = "Immutables") @NotThreadSafe public static final class Builder { private static final long INIT_BIT_STEP_ID = 0x1L; private static final long INIT_BIT_SHORT_HISTORY = 0x2L; private static final long INIT_BIT_STATUS = 0x4L; private long initBits = 0x7L; private @Nullable String stepId; private @Nullable String shortHistory; private ImmutableList.Builder logs = ImmutableList.builder(); private @Nullable FlowProgram.FlowExecutionStatus status; private ImmutableMap.Builder accepts = ImmutableMap.builder(); private ImmutableMap.Builder returns = ImmutableMap.builder(); private Builder() { } /** * Fill a builder with attribute values from the provided {@code FlowResult} 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.FlowResult instance) { Objects.requireNonNull(instance, "instance"); stepId(instance.getStepId()); shortHistory(instance.getShortHistory()); addAllLogs(instance.getLogs()); status(instance.getStatus()); putAllAccepts(instance.getAccepts()); putAllReturns(instance.getReturns()); return this; } /** * Initializes the value for the {@link FlowProgram.FlowResult#getStepId() stepId} attribute. * @param stepId The value for stepId * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder stepId(String stepId) { this.stepId = Objects.requireNonNull(stepId, "stepId"); initBits &= ~INIT_BIT_STEP_ID; return this; } /** * Initializes the value for the {@link FlowProgram.FlowResult#getShortHistory() shortHistory} attribute. * @param shortHistory The value for shortHistory * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder shortHistory(String shortHistory) { this.shortHistory = Objects.requireNonNull(shortHistory, "shortHistory"); initBits &= ~INIT_BIT_SHORT_HISTORY; return this; } /** * Adds one element to {@link FlowProgram.FlowResult#getLogs() logs} list. * @param element A logs element * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addLogs(FlowProgram.FlowResultLog element) { this.logs.add(element); return this; } /** * Adds elements to {@link FlowProgram.FlowResult#getLogs() logs} list. * @param elements An array of logs elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addLogs(FlowProgram.FlowResultLog... elements) { this.logs.add(elements); return this; } /** * Sets or replaces all elements for {@link FlowProgram.FlowResult#getLogs() logs} list. * @param elements An iterable of logs elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder logs(Iterable elements) { this.logs = ImmutableList.builder(); return addAllLogs(elements); } /** * Adds elements to {@link FlowProgram.FlowResult#getLogs() logs} list. * @param elements An iterable of logs elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAllLogs(Iterable elements) { this.logs.addAll(elements); return this; } /** * Initializes the value for the {@link FlowProgram.FlowResult#getStatus() status} attribute. * @param status The value for status * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder status(FlowProgram.FlowExecutionStatus status) { this.status = Objects.requireNonNull(status, "status"); initBits &= ~INIT_BIT_STATUS; return this; } /** * Put one entry to the {@link FlowProgram.FlowResult#getAccepts() accepts} map. * @param key The key in the accepts map * @param value The associated value in the accepts map * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder putAccepts(String key, Serializable value) { this.accepts.put(key, value); return this; } /** * Put one entry to the {@link FlowProgram.FlowResult#getAccepts() accepts} 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 putAccepts(Map.Entry entry) { this.accepts.put(entry); return this; } /** * Sets or replaces all mappings from the specified map as entries for the {@link FlowProgram.FlowResult#getAccepts() accepts} map. Nulls are not permitted * @param entries The entries that will be added to the accepts map * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder accepts(Map entries) { this.accepts = ImmutableMap.builder(); return putAllAccepts(entries); } /** * Put all mappings from the specified map as entries to {@link FlowProgram.FlowResult#getAccepts() accepts} map. Nulls are not permitted * @param entries The entries that will be added to the accepts map * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder putAllAccepts(Map entries) { this.accepts.putAll(entries); return this; } /** * Put one entry to the {@link FlowProgram.FlowResult#getReturns() returns} map. * @param key The key in the returns map * @param value The associated value in the returns map * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder putReturns(String key, Serializable value) { this.returns.put(key, value); return this; } /** * Put one entry to the {@link FlowProgram.FlowResult#getReturns() returns} 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 putReturns(Map.Entry entry) { this.returns.put(entry); return this; } /** * Sets or replaces all mappings from the specified map as entries for the {@link FlowProgram.FlowResult#getReturns() returns} map. Nulls are not permitted * @param entries The entries that will be added to the returns map * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder returns(Map entries) { this.returns = ImmutableMap.builder(); return putAllReturns(entries); } /** * Put all mappings from the specified map as entries to {@link FlowProgram.FlowResult#getReturns() returns} map. Nulls are not permitted * @param entries The entries that will be added to the returns map * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder putAllReturns(Map entries) { this.returns.putAll(entries); return this; } /** * Builds a new {@link ImmutableFlowResult ImmutableFlowResult}. * @return An immutable instance of FlowResult * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableFlowResult build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return new ImmutableFlowResult(stepId, shortHistory, logs.build(), status, accepts.build(), returns.build()); } private String formatRequiredAttributesMessage() { List attributes = new ArrayList<>(); if ((initBits & INIT_BIT_STEP_ID) != 0) attributes.add("stepId"); if ((initBits & INIT_BIT_SHORT_HISTORY) != 0) attributes.add("shortHistory"); if ((initBits & INIT_BIT_STATUS) != 0) attributes.add("status"); return "Cannot build FlowResult, some of required attributes are not set " + attributes; } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy