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

io.resys.hdes.client.api.programs.ImmutableDecisionResult 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.errorprone.annotations.CanIgnoreReturnValue;
import com.google.errorprone.annotations.Var;
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 DecisionProgram.DecisionResult}.
 * 

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

   * ImmutableDecisionResult.builder()
   *    .addRejections|addAllRejections(io.resys.hdes.client.api.programs.DecisionProgram.DecisionLog) // {@link DecisionProgram.DecisionResult#getRejections() rejections} elements
   *    .addMatches|addAllMatches(io.resys.hdes.client.api.programs.DecisionProgram.DecisionLog) // {@link DecisionProgram.DecisionResult#getMatches() matches} elements
   *    .build();
   * 
* @return A new ImmutableDecisionResult builder */ public static ImmutableDecisionResult.Builder builder() { return new ImmutableDecisionResult.Builder(); } /** * Builds instances of type {@link ImmutableDecisionResult ImmutableDecisionResult}. * 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 = "DecisionProgram.DecisionResult", generator = "Immutables") @NotThreadSafe public static final class Builder { private ImmutableList.Builder rejections = ImmutableList.builder(); private ImmutableList.Builder matches = ImmutableList.builder(); private Builder() { } /** * Fill a builder with attribute values from the provided {@code DecisionResult} 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(DecisionProgram.DecisionResult instance) { Objects.requireNonNull(instance, "instance"); addAllRejections(instance.getRejections()); addAllMatches(instance.getMatches()); return this; } /** * Adds one element to {@link DecisionProgram.DecisionResult#getRejections() rejections} list. * @param element A rejections element * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addRejections(DecisionProgram.DecisionLog element) { this.rejections.add(element); return this; } /** * Adds elements to {@link DecisionProgram.DecisionResult#getRejections() rejections} list. * @param elements An array of rejections elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addRejections(DecisionProgram.DecisionLog... elements) { this.rejections.add(elements); return this; } /** * Sets or replaces all elements for {@link DecisionProgram.DecisionResult#getRejections() rejections} list. * @param elements An iterable of rejections elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder rejections(Iterable elements) { this.rejections = ImmutableList.builder(); return addAllRejections(elements); } /** * Adds elements to {@link DecisionProgram.DecisionResult#getRejections() rejections} list. * @param elements An iterable of rejections elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAllRejections(Iterable elements) { this.rejections.addAll(elements); return this; } /** * Adds one element to {@link DecisionProgram.DecisionResult#getMatches() matches} list. * @param element A matches element * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addMatches(DecisionProgram.DecisionLog element) { this.matches.add(element); return this; } /** * Adds elements to {@link DecisionProgram.DecisionResult#getMatches() matches} list. * @param elements An array of matches elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addMatches(DecisionProgram.DecisionLog... elements) { this.matches.add(elements); return this; } /** * Sets or replaces all elements for {@link DecisionProgram.DecisionResult#getMatches() matches} list. * @param elements An iterable of matches elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder matches(Iterable elements) { this.matches = ImmutableList.builder(); return addAllMatches(elements); } /** * Adds elements to {@link DecisionProgram.DecisionResult#getMatches() matches} list. * @param elements An iterable of matches elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAllMatches(Iterable elements) { this.matches.addAll(elements); return this; } /** * Builds a new {@link ImmutableDecisionResult ImmutableDecisionResult}. * @return An immutable instance of DecisionResult * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableDecisionResult build() { return new ImmutableDecisionResult(rejections.build(), matches.build()); } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy