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

io.resys.hdes.client.api.programs.ImmutableDecisionLogEntry 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.errorprone.annotations.CanIgnoreReturnValue;
import com.google.errorprone.annotations.Var;
import io.resys.hdes.client.api.ast.TypeDef;
import java.io.Serializable;
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 DecisionProgram.DecisionLogEntry}.
 * 

* Use the builder to create immutable instances: * {@code ImmutableDecisionLogEntry.builder()}. */ @Generated(from = "DecisionProgram.DecisionLogEntry", generator = "Immutables") @SuppressWarnings({"all"}) @ParametersAreNonnullByDefault @javax.annotation.processing.Generated("org.immutables.processor.ProxyProcessor") @Immutable @CheckReturnValue public final class ImmutableDecisionLogEntry implements DecisionProgram.DecisionLogEntry { private final Boolean match; private final TypeDef headerType; private final String expression; private final @Nullable Serializable usedValue; private ImmutableDecisionLogEntry( Boolean match, TypeDef headerType, String expression, @Nullable Serializable usedValue) { this.match = match; this.headerType = headerType; this.expression = expression; this.usedValue = usedValue; } /** * @return The value of the {@code match} attribute */ @Override public Boolean getMatch() { return match; } /** * @return The value of the {@code headerType} attribute */ @Override public TypeDef getHeaderType() { return headerType; } /** * @return The value of the {@code expression} attribute */ @Override public String getExpression() { return expression; } /** * @return The value of the {@code usedValue} attribute */ @Override public @Nullable Serializable getUsedValue() { return usedValue; } /** * Copy the current immutable object by setting a value for the {@link DecisionProgram.DecisionLogEntry#getMatch() match} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for match * @return A modified copy of the {@code this} object */ public final ImmutableDecisionLogEntry withMatch(Boolean value) { Boolean newValue = Objects.requireNonNull(value, "match"); if (this.match.equals(newValue)) return this; return new ImmutableDecisionLogEntry(newValue, this.headerType, this.expression, this.usedValue); } /** * Copy the current immutable object by setting a value for the {@link DecisionProgram.DecisionLogEntry#getHeaderType() headerType} 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 headerType * @return A modified copy of the {@code this} object */ public final ImmutableDecisionLogEntry withHeaderType(TypeDef value) { if (this.headerType == value) return this; TypeDef newValue = Objects.requireNonNull(value, "headerType"); return new ImmutableDecisionLogEntry(this.match, newValue, this.expression, this.usedValue); } /** * Copy the current immutable object by setting a value for the {@link DecisionProgram.DecisionLogEntry#getExpression() expression} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for expression * @return A modified copy of the {@code this} object */ public final ImmutableDecisionLogEntry withExpression(String value) { String newValue = Objects.requireNonNull(value, "expression"); if (this.expression.equals(newValue)) return this; return new ImmutableDecisionLogEntry(this.match, this.headerType, newValue, this.usedValue); } /** * Copy the current immutable object by setting a value for the {@link DecisionProgram.DecisionLogEntry#getUsedValue() usedValue} 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 usedValue (can be {@code null}) * @return A modified copy of the {@code this} object */ public final ImmutableDecisionLogEntry withUsedValue(@Nullable Serializable value) { if (this.usedValue == value) return this; return new ImmutableDecisionLogEntry(this.match, this.headerType, this.expression, value); } /** * This instance is equal to all instances of {@code ImmutableDecisionLogEntry} 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 ImmutableDecisionLogEntry && equalTo((ImmutableDecisionLogEntry) another); } private boolean equalTo(ImmutableDecisionLogEntry another) { return match.equals(another.match) && headerType.equals(another.headerType) && expression.equals(another.expression) && Objects.equals(usedValue, another.usedValue); } /** * Computes a hash code from attributes: {@code match}, {@code headerType}, {@code expression}, {@code usedValue}. * @return hashCode value */ @Override public int hashCode() { @Var int h = 5381; h += (h << 5) + match.hashCode(); h += (h << 5) + headerType.hashCode(); h += (h << 5) + expression.hashCode(); h += (h << 5) + Objects.hashCode(usedValue); return h; } /** * Prints the immutable value {@code DecisionLogEntry} with attribute values. * @return A string representation of the value */ @Override public String toString() { return MoreObjects.toStringHelper("DecisionLogEntry") .omitNullValues() .add("match", match) .add("headerType", headerType) .add("expression", expression) .add("usedValue", usedValue) .toString(); } /** * Creates an immutable copy of a {@link DecisionProgram.DecisionLogEntry} 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 DecisionLogEntry instance */ public static ImmutableDecisionLogEntry copyOf(DecisionProgram.DecisionLogEntry instance) { if (instance instanceof ImmutableDecisionLogEntry) { return (ImmutableDecisionLogEntry) instance; } return ImmutableDecisionLogEntry.builder() .from(instance) .build(); } /** * Creates a builder for {@link ImmutableDecisionLogEntry ImmutableDecisionLogEntry}. *

   * ImmutableDecisionLogEntry.builder()
   *    .match(Boolean) // required {@link DecisionProgram.DecisionLogEntry#getMatch() match}
   *    .headerType(io.resys.hdes.client.api.ast.TypeDef) // required {@link DecisionProgram.DecisionLogEntry#getHeaderType() headerType}
   *    .expression(String) // required {@link DecisionProgram.DecisionLogEntry#getExpression() expression}
   *    .usedValue(java.io.Serializable | null) // nullable {@link DecisionProgram.DecisionLogEntry#getUsedValue() usedValue}
   *    .build();
   * 
* @return A new ImmutableDecisionLogEntry builder */ public static ImmutableDecisionLogEntry.Builder builder() { return new ImmutableDecisionLogEntry.Builder(); } /** * Builds instances of type {@link ImmutableDecisionLogEntry ImmutableDecisionLogEntry}. * 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.DecisionLogEntry", generator = "Immutables") @NotThreadSafe public static final class Builder { private static final long INIT_BIT_MATCH = 0x1L; private static final long INIT_BIT_HEADER_TYPE = 0x2L; private static final long INIT_BIT_EXPRESSION = 0x4L; private long initBits = 0x7L; private @Nullable Boolean match; private @Nullable TypeDef headerType; private @Nullable String expression; private @Nullable Serializable usedValue; private Builder() { } /** * Fill a builder with attribute values from the provided {@code DecisionLogEntry} instance. * Regular attribute values will be replaced with those from the given instance. * Absent optional values will not replace present values. * @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.DecisionLogEntry instance) { Objects.requireNonNull(instance, "instance"); match(instance.getMatch()); headerType(instance.getHeaderType()); expression(instance.getExpression()); @Nullable Serializable usedValueValue = instance.getUsedValue(); if (usedValueValue != null) { usedValue(usedValueValue); } return this; } /** * Initializes the value for the {@link DecisionProgram.DecisionLogEntry#getMatch() match} attribute. * @param match The value for match * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder match(Boolean match) { this.match = Objects.requireNonNull(match, "match"); initBits &= ~INIT_BIT_MATCH; return this; } /** * Initializes the value for the {@link DecisionProgram.DecisionLogEntry#getHeaderType() headerType} attribute. * @param headerType The value for headerType * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder headerType(TypeDef headerType) { this.headerType = Objects.requireNonNull(headerType, "headerType"); initBits &= ~INIT_BIT_HEADER_TYPE; return this; } /** * Initializes the value for the {@link DecisionProgram.DecisionLogEntry#getExpression() expression} attribute. * @param expression The value for expression * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder expression(String expression) { this.expression = Objects.requireNonNull(expression, "expression"); initBits &= ~INIT_BIT_EXPRESSION; return this; } /** * Initializes the value for the {@link DecisionProgram.DecisionLogEntry#getUsedValue() usedValue} attribute. * @param usedValue The value for usedValue (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder usedValue(@Nullable Serializable usedValue) { this.usedValue = usedValue; return this; } /** * Builds a new {@link ImmutableDecisionLogEntry ImmutableDecisionLogEntry}. * @return An immutable instance of DecisionLogEntry * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableDecisionLogEntry build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return new ImmutableDecisionLogEntry(match, headerType, expression, usedValue); } private String formatRequiredAttributesMessage() { List attributes = new ArrayList<>(); if ((initBits & INIT_BIT_MATCH) != 0) attributes.add("match"); if ((initBits & INIT_BIT_HEADER_TYPE) != 0) attributes.add("headerType"); if ((initBits & INIT_BIT_EXPRESSION) != 0) attributes.add("expression"); return "Cannot build DecisionLogEntry, some of required attributes are not set " + attributes; } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy