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

com.neotys.neoload.model.v3.project.userpath.ImmutableCondition Maven / Gradle / Ivy

package com.neotys.neoload.model.v3.project.userpath;

import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.google.common.base.MoreObjects;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.errorprone.annotations.Var;
import java.util.Objects;
import java.util.Optional;
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 Condition}.
 * 

* Use the builder to create immutable instances: * {@code new Condition.Builder()}. */ @Generated(from = "Condition", generator = "Immutables") @SuppressWarnings({"all"}) @ParametersAreNonnullByDefault @javax.annotation.processing.Generated("org.immutables.processor.ProxyProcessor") @Immutable @CheckReturnValue public final class ImmutableCondition implements Condition { private final String operand1; private final Condition.Operator operator; private final @Nullable String operand2; private ImmutableCondition( String operand1, Condition.Operator operator, @Nullable String operand2) { this.operand1 = operand1; this.operator = operator; this.operand2 = operand2; } /** * @return The value of the {@code operand1} attribute */ @JsonProperty("operand1") @Override public String getOperand1() { return operand1; } /** * @return The value of the {@code operator} attribute */ @JsonProperty("operator") @Override public Condition.Operator getOperator() { return operator; } /** * @return The value of the {@code operand2} attribute */ @JsonProperty("operand2") @Override public Optional getOperand2() { return Optional.ofNullable(operand2); } /** * Copy the current immutable object by setting a value for the {@link Condition#getOperand1() operand1} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for operand1 (can be {@code null}) * @return A modified copy of the {@code this} object */ public final ImmutableCondition withOperand1(String value) { if (Objects.equals(this.operand1, value)) return this; return new ImmutableCondition(value, this.operator, this.operand2); } /** * Copy the current immutable object by setting a value for the {@link Condition#getOperator() operator} attribute. * A value equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for operator (can be {@code null}) * @return A modified copy of the {@code this} object */ public final ImmutableCondition withOperator(Condition.Operator value) { if (this.operator == value) return this; return new ImmutableCondition(this.operand1, value, this.operand2); } /** * Copy the current immutable object by setting a present value for the optional {@link Condition#getOperand2() operand2} attribute. * @param value The value for operand2 * @return A modified copy of {@code this} object */ public final ImmutableCondition withOperand2(String value) { String newValue = Objects.requireNonNull(value, "operand2"); if (Objects.equals(this.operand2, newValue)) return this; return new ImmutableCondition(this.operand1, this.operator, newValue); } /** * Copy the current immutable object by setting an optional value for the {@link Condition#getOperand2() operand2} attribute. * An equality check is used on inner nullable value to prevent copying of the same value by returning {@code this}. * @param optional A value for operand2 * @return A modified copy of {@code this} object */ public final ImmutableCondition withOperand2(Optional optional) { @Nullable String value = optional.orElse(null); if (Objects.equals(this.operand2, value)) return this; return new ImmutableCondition(this.operand1, this.operator, value); } /** * This instance is equal to all instances of {@code ImmutableCondition} 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 ImmutableCondition && equalTo(0, (ImmutableCondition) another); } private boolean equalTo(int synthetic, ImmutableCondition another) { return Objects.equals(operand1, another.operand1) && Objects.equals(operator, another.operator) && Objects.equals(operand2, another.operand2); } /** * Computes a hash code from attributes: {@code operand1}, {@code operator}, {@code operand2}. * @return hashCode value */ @Override public int hashCode() { @Var int h = 5381; h += (h << 5) + Objects.hashCode(operand1); h += (h << 5) + Objects.hashCode(operator); h += (h << 5) + Objects.hashCode(operand2); return h; } /** * Prints the immutable value {@code Condition} with attribute values. * @return A string representation of the value */ @Override public String toString() { return MoreObjects.toStringHelper("Condition") .omitNullValues() .add("operand1", operand1) .add("operator", operator) .add("operand2", operand2) .toString(); } /** * Utility type used to correctly read immutable object from JSON representation. * @deprecated Do not use this type directly, it exists only for the Jackson-binding infrastructure */ @Generated(from = "Condition", generator = "Immutables") @Deprecated @SuppressWarnings("Immutable") @JsonDeserialize @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE) static final class Json implements Condition { @Nullable String operand1; @Nullable Condition.Operator operator; @Nullable Optional operand2 = Optional.empty(); @JsonProperty("operand1") public void setOperand1(String operand1) { this.operand1 = operand1; } @JsonProperty("operator") public void setOperator(Condition.Operator operator) { this.operator = operator; } @JsonProperty("operand2") public void setOperand2(Optional operand2) { this.operand2 = operand2; } @Override public String getOperand1() { throw new UnsupportedOperationException(); } @Override public Condition.Operator getOperator() { throw new UnsupportedOperationException(); } @Override public Optional getOperand2() { throw new UnsupportedOperationException(); } } /** * @param json A JSON-bindable data structure * @return An immutable value type * @deprecated Do not use this method directly, it exists only for the Jackson-binding infrastructure */ @Deprecated @JsonCreator(mode = JsonCreator.Mode.DELEGATING) static ImmutableCondition fromJson(Json json) { Condition.Builder builder = new Condition.Builder(); if (json.operand1 != null) { builder.operand1(json.operand1); } if (json.operator != null) { builder.operator(json.operator); } if (json.operand2 != null) { builder.operand2(json.operand2); } return (ImmutableCondition) builder.build(); } /** * Creates an immutable copy of a {@link Condition} 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 Condition instance */ public static ImmutableCondition copyOf(Condition instance) { if (instance instanceof ImmutableCondition) { return (ImmutableCondition) instance; } return new Condition.Builder() .from(instance) .build(); } /** * Builds instances of type {@link ImmutableCondition ImmutableCondition}. * 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 = "Condition", generator = "Immutables") @NotThreadSafe public static class Builder { private @Nullable String operand1; private @Nullable Condition.Operator operator; private @Nullable String operand2; /** * Creates a builder for {@link ImmutableCondition ImmutableCondition} instances. *

     * new Condition.Builder()
     *    .operand1(String | null) // nullable {@link Condition#getOperand1() operand1}
     *    .operator(com.neotys.neoload.model.v3.project.userpath.Condition.Operator | null) // nullable {@link Condition#getOperator() operator}
     *    .operand2(String) // optional {@link Condition#getOperand2() operand2}
     *    .build();
     * 
*/ public Builder() { if (!(this instanceof Condition.Builder)) { throw new UnsupportedOperationException("Use: new Condition.Builder()"); } } /** * Fill a builder with attribute values from the provided {@code Condition} 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 Condition.Builder from(Condition instance) { Objects.requireNonNull(instance, "instance"); String operand1Value = instance.getOperand1(); if (operand1Value != null) { operand1(operand1Value); } Condition.Operator operatorValue = instance.getOperator(); if (operatorValue != null) { operator(operatorValue); } Optional operand2Optional = instance.getOperand2(); if (operand2Optional.isPresent()) { operand2(operand2Optional); } return (Condition.Builder) this; } /** * Initializes the value for the {@link Condition#getOperand1() operand1} attribute. * @param operand1 The value for operand1 (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("operand1") public final Condition.Builder operand1(String operand1) { this.operand1 = operand1; return (Condition.Builder) this; } /** * Initializes the value for the {@link Condition#getOperator() operator} attribute. * @param operator The value for operator (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("operator") public final Condition.Builder operator(Condition.Operator operator) { this.operator = operator; return (Condition.Builder) this; } /** * Initializes the optional value {@link Condition#getOperand2() operand2} to operand2. * @param operand2 The value for operand2 * @return {@code this} builder for chained invocation */ @CanIgnoreReturnValue public final Condition.Builder operand2(String operand2) { this.operand2 = Objects.requireNonNull(operand2, "operand2"); return (Condition.Builder) this; } /** * Initializes the optional value {@link Condition#getOperand2() operand2} to operand2. * @param operand2 The value for operand2 * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("operand2") public final Condition.Builder operand2(Optional operand2) { this.operand2 = operand2.orElse(null); return (Condition.Builder) this; } /** * Builds a new {@link ImmutableCondition ImmutableCondition}. * @return An immutable instance of Condition * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableCondition build() { return new ImmutableCondition(operand1, operator, operand2); } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy