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

com.neotys.neoload.model.repository.ImmutableCounterNumberVariable Maven / Gradle / Ivy

package com.neotys.neoload.model.repository;

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.common.collect.Lists;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import javax.annotation.CheckReturnValue;
import javax.annotation.Generated;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import javax.annotation.concurrent.Immutable;
import javax.annotation.concurrent.NotThreadSafe;

/**
 * Immutable implementation of {@link CounterNumberVariable}.
 * 

* Use the builder to create immutable instances: * {@code ImmutableCounterNumberVariable.builder()}. */ @SuppressWarnings({"all"}) @ParametersAreNonnullByDefault @Generated({"Immutables.generator", "CounterNumberVariable"}) @Deprecated @Immutable @CheckReturnValue public final class ImmutableCounterNumberVariable implements CounterNumberVariable { private final int startValue; private final int maxValue; private final int increment; private final String name; private final @Nullable String description; private final @Nullable Variable.VariableOrder order; private final Variable.VariablePolicy policy; private final Variable.VariableScope scope; private final @Nullable Variable.VariableNoValuesLeftBehavior noValuesLeftBehavior; private ImmutableCounterNumberVariable( int startValue, int maxValue, int increment, String name, @Nullable String description, @Nullable Variable.VariableOrder order, Variable.VariablePolicy policy, Variable.VariableScope scope, @Nullable Variable.VariableNoValuesLeftBehavior noValuesLeftBehavior) { this.startValue = startValue; this.maxValue = maxValue; this.increment = increment; this.name = name; this.description = description; this.order = order; this.policy = policy; this.scope = scope; this.noValuesLeftBehavior = noValuesLeftBehavior; } /** * @return The value of the {@code startValue} attribute */ @JsonProperty("startValue") @Override public int getStartValue() { return startValue; } /** * @return The value of the {@code maxValue} attribute */ @JsonProperty("maxValue") @Override public int getMaxValue() { return maxValue; } /** * @return The value of the {@code increment} attribute */ @JsonProperty("increment") @Override public int getIncrement() { return increment; } /** * @return The value of the {@code name} attribute */ @JsonProperty("name") @Override public String getName() { return name; } /** * @return The value of the {@code description} attribute */ @JsonProperty("description") @Override public Optional getDescription() { return Optional.ofNullable(description); } /** * @return The value of the {@code order} attribute */ @JsonProperty("order") @Override public Optional getOrder() { return Optional.ofNullable(order); } /** * @return The value of the {@code policy} attribute */ @JsonProperty("policy") @Override public Variable.VariablePolicy getPolicy() { return policy; } /** * @return The value of the {@code scope} attribute */ @JsonProperty("scope") @Override public Variable.VariableScope getScope() { return scope; } /** * @return The value of the {@code noValuesLeftBehavior} attribute */ @JsonProperty("noValuesLeftBehavior") @Override public Optional getNoValuesLeftBehavior() { return Optional.ofNullable(noValuesLeftBehavior); } /** * Copy the current immutable object by setting a value for the {@link CounterNumberVariable#getStartValue() startValue} attribute. * A value equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for startValue * @return A modified copy of the {@code this} object */ public final ImmutableCounterNumberVariable withStartValue(int value) { if (this.startValue == value) return this; return new ImmutableCounterNumberVariable( value, this.maxValue, this.increment, this.name, this.description, this.order, this.policy, this.scope, this.noValuesLeftBehavior); } /** * Copy the current immutable object by setting a value for the {@link CounterNumberVariable#getMaxValue() maxValue} attribute. * A value equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for maxValue * @return A modified copy of the {@code this} object */ public final ImmutableCounterNumberVariable withMaxValue(int value) { if (this.maxValue == value) return this; return new ImmutableCounterNumberVariable( this.startValue, value, this.increment, this.name, this.description, this.order, this.policy, this.scope, this.noValuesLeftBehavior); } /** * Copy the current immutable object by setting a value for the {@link CounterNumberVariable#getIncrement() increment} attribute. * A value equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for increment * @return A modified copy of the {@code this} object */ public final ImmutableCounterNumberVariable withIncrement(int value) { if (this.increment == value) return this; return new ImmutableCounterNumberVariable( this.startValue, this.maxValue, value, this.name, this.description, this.order, this.policy, this.scope, this.noValuesLeftBehavior); } /** * Copy the current immutable object by setting a value for the {@link CounterNumberVariable#getName() name} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for name * @return A modified copy of the {@code this} object */ public final ImmutableCounterNumberVariable withName(String value) { if (this.name.equals(value)) return this; String newValue = Objects.requireNonNull(value, "name"); return new ImmutableCounterNumberVariable( this.startValue, this.maxValue, this.increment, newValue, this.description, this.order, this.policy, this.scope, this.noValuesLeftBehavior); } /** * Copy the current immutable object by setting a present value for the optional {@link CounterNumberVariable#getDescription() description} attribute. * @param value The value for description * @return A modified copy of {@code this} object */ public final ImmutableCounterNumberVariable withDescription(String value) { @Nullable String newValue = Objects.requireNonNull(value, "description"); if (Objects.equals(this.description, newValue)) return this; return new ImmutableCounterNumberVariable( this.startValue, this.maxValue, this.increment, this.name, newValue, this.order, this.policy, this.scope, this.noValuesLeftBehavior); } /** * Copy the current immutable object by setting an optional value for the {@link CounterNumberVariable#getDescription() description} 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 description * @return A modified copy of {@code this} object */ public final ImmutableCounterNumberVariable withDescription(Optional optional) { @Nullable String value = optional.orElse(null); if (Objects.equals(this.description, value)) return this; return new ImmutableCounterNumberVariable( this.startValue, this.maxValue, this.increment, this.name, value, this.order, this.policy, this.scope, this.noValuesLeftBehavior); } /** * Copy the current immutable object by setting a present value for the optional {@link CounterNumberVariable#getOrder() order} attribute. * @param value The value for order * @return A modified copy of {@code this} object */ public final ImmutableCounterNumberVariable withOrder(Variable.VariableOrder value) { @Nullable Variable.VariableOrder newValue = Objects.requireNonNull(value, "order"); if (this.order == newValue) return this; return new ImmutableCounterNumberVariable( this.startValue, this.maxValue, this.increment, this.name, this.description, newValue, this.policy, this.scope, this.noValuesLeftBehavior); } /** * Copy the current immutable object by setting an optional value for the {@link CounterNumberVariable#getOrder() order} 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 order * @return A modified copy of {@code this} object */ public final ImmutableCounterNumberVariable withOrder(Optional optional) { @Nullable Variable.VariableOrder value = optional.orElse(null); if (Objects.equals(this.order, value)) return this; return new ImmutableCounterNumberVariable( this.startValue, this.maxValue, this.increment, this.name, this.description, value, this.policy, this.scope, this.noValuesLeftBehavior); } /** * Copy the current immutable object by setting a value for the {@link CounterNumberVariable#getPolicy() policy} attribute. * A value equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for policy * @return A modified copy of the {@code this} object */ public final ImmutableCounterNumberVariable withPolicy(Variable.VariablePolicy value) { if (this.policy == value) return this; Variable.VariablePolicy newValue = Objects.requireNonNull(value, "policy"); return new ImmutableCounterNumberVariable( this.startValue, this.maxValue, this.increment, this.name, this.description, this.order, newValue, this.scope, this.noValuesLeftBehavior); } /** * Copy the current immutable object by setting a value for the {@link CounterNumberVariable#getScope() scope} attribute. * A value equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for scope * @return A modified copy of the {@code this} object */ public final ImmutableCounterNumberVariable withScope(Variable.VariableScope value) { if (this.scope == value) return this; Variable.VariableScope newValue = Objects.requireNonNull(value, "scope"); return new ImmutableCounterNumberVariable( this.startValue, this.maxValue, this.increment, this.name, this.description, this.order, this.policy, newValue, this.noValuesLeftBehavior); } /** * Copy the current immutable object by setting a present value for the optional {@link CounterNumberVariable#getNoValuesLeftBehavior() noValuesLeftBehavior} attribute. * @param value The value for noValuesLeftBehavior * @return A modified copy of {@code this} object */ public final ImmutableCounterNumberVariable withNoValuesLeftBehavior(Variable.VariableNoValuesLeftBehavior value) { @Nullable Variable.VariableNoValuesLeftBehavior newValue = Objects.requireNonNull(value, "noValuesLeftBehavior"); if (this.noValuesLeftBehavior == newValue) return this; return new ImmutableCounterNumberVariable( this.startValue, this.maxValue, this.increment, this.name, this.description, this.order, this.policy, this.scope, newValue); } /** * Copy the current immutable object by setting an optional value for the {@link CounterNumberVariable#getNoValuesLeftBehavior() noValuesLeftBehavior} 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 noValuesLeftBehavior * @return A modified copy of {@code this} object */ public final ImmutableCounterNumberVariable withNoValuesLeftBehavior(Optional optional) { @Nullable Variable.VariableNoValuesLeftBehavior value = optional.orElse(null); if (Objects.equals(this.noValuesLeftBehavior, value)) return this; return new ImmutableCounterNumberVariable( this.startValue, this.maxValue, this.increment, this.name, this.description, this.order, this.policy, this.scope, value); } /** * This instance is equal to all instances of {@code ImmutableCounterNumberVariable} 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 ImmutableCounterNumberVariable && equalTo((ImmutableCounterNumberVariable) another); } private boolean equalTo(ImmutableCounterNumberVariable another) { return startValue == another.startValue && maxValue == another.maxValue && increment == another.increment && name.equals(another.name) && Objects.equals(description, another.description) && Objects.equals(order, another.order) && policy.equals(another.policy) && scope.equals(another.scope) && Objects.equals(noValuesLeftBehavior, another.noValuesLeftBehavior); } /** * Computes a hash code from attributes: {@code startValue}, {@code maxValue}, {@code increment}, {@code name}, {@code description}, {@code order}, {@code policy}, {@code scope}, {@code noValuesLeftBehavior}. * @return hashCode value */ @Override public int hashCode() { int h = 5381; h += (h << 5) + startValue; h += (h << 5) + maxValue; h += (h << 5) + increment; h += (h << 5) + name.hashCode(); h += (h << 5) + Objects.hashCode(description); h += (h << 5) + Objects.hashCode(order); h += (h << 5) + policy.hashCode(); h += (h << 5) + scope.hashCode(); h += (h << 5) + Objects.hashCode(noValuesLeftBehavior); return h; } /** * Prints the immutable value {@code CounterNumberVariable} with attribute values. * @return A string representation of the value */ @Override public String toString() { return MoreObjects.toStringHelper("CounterNumberVariable") .omitNullValues() .add("startValue", startValue) .add("maxValue", maxValue) .add("increment", increment) .add("name", name) .add("description", description) .add("order", order) .add("policy", policy) .add("scope", scope) .add("noValuesLeftBehavior", noValuesLeftBehavior) .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 */ @Deprecated @JsonDeserialize @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE) static final class Json implements CounterNumberVariable { int startValue; boolean startValueIsSet; int maxValue; boolean maxValueIsSet; int increment; boolean incrementIsSet; @Nullable String name; Optional description = Optional.empty(); Optional order = Optional.empty(); @Nullable Variable.VariablePolicy policy; @Nullable Variable.VariableScope scope; Optional noValuesLeftBehavior = Optional.empty(); @JsonProperty("startValue") public void setStartValue(int startValue) { this.startValue = startValue; this.startValueIsSet = true; } @JsonProperty("maxValue") public void setMaxValue(int maxValue) { this.maxValue = maxValue; this.maxValueIsSet = true; } @JsonProperty("increment") public void setIncrement(int increment) { this.increment = increment; this.incrementIsSet = true; } @JsonProperty("name") public void setName(String name) { this.name = name; } @JsonProperty("description") public void setDescription(Optional description) { this.description = description; } @JsonProperty("order") public void setOrder(Optional order) { this.order = order; } @JsonProperty("policy") public void setPolicy(Variable.VariablePolicy policy) { this.policy = policy; } @JsonProperty("scope") public void setScope(Variable.VariableScope scope) { this.scope = scope; } @JsonProperty("noValuesLeftBehavior") public void setNoValuesLeftBehavior(Optional noValuesLeftBehavior) { this.noValuesLeftBehavior = noValuesLeftBehavior; } @Override public int getStartValue() { throw new UnsupportedOperationException(); } @Override public int getMaxValue() { throw new UnsupportedOperationException(); } @Override public int getIncrement() { throw new UnsupportedOperationException(); } @Override public String getName() { throw new UnsupportedOperationException(); } @Override public Optional getDescription() { throw new UnsupportedOperationException(); } @Override public Optional getOrder() { throw new UnsupportedOperationException(); } @Override public Variable.VariablePolicy getPolicy() { throw new UnsupportedOperationException(); } @Override public Variable.VariableScope getScope() { throw new UnsupportedOperationException(); } @Override public Optional getNoValuesLeftBehavior() { 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 ImmutableCounterNumberVariable fromJson(Json json) { ImmutableCounterNumberVariable.Builder builder = ImmutableCounterNumberVariable.builder(); if (json.startValueIsSet) { builder.startValue(json.startValue); } if (json.maxValueIsSet) { builder.maxValue(json.maxValue); } if (json.incrementIsSet) { builder.increment(json.increment); } if (json.name != null) { builder.name(json.name); } if (json.description != null) { builder.description(json.description); } if (json.order != null) { builder.order(json.order); } if (json.policy != null) { builder.policy(json.policy); } if (json.scope != null) { builder.scope(json.scope); } if (json.noValuesLeftBehavior != null) { builder.noValuesLeftBehavior(json.noValuesLeftBehavior); } return builder.build(); } /** * Creates an immutable copy of a {@link CounterNumberVariable} 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 CounterNumberVariable instance */ public static ImmutableCounterNumberVariable copyOf(CounterNumberVariable instance) { if (instance instanceof ImmutableCounterNumberVariable) { return (ImmutableCounterNumberVariable) instance; } return ImmutableCounterNumberVariable.builder() .from(instance) .build(); } /** * Creates a builder for {@link ImmutableCounterNumberVariable ImmutableCounterNumberVariable}. * @return A new ImmutableCounterNumberVariable builder */ public static ImmutableCounterNumberVariable.Builder builder() { return new ImmutableCounterNumberVariable.Builder(); } /** * Builds instances of type {@link ImmutableCounterNumberVariable ImmutableCounterNumberVariable}. * 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. */ @NotThreadSafe public static final class Builder { private static final long INIT_BIT_START_VALUE = 0x1L; private static final long INIT_BIT_MAX_VALUE = 0x2L; private static final long INIT_BIT_INCREMENT = 0x4L; private static final long INIT_BIT_NAME = 0x8L; private static final long INIT_BIT_POLICY = 0x10L; private static final long INIT_BIT_SCOPE = 0x20L; private long initBits = 0x3fL; private int startValue; private int maxValue; private int increment; private @Nullable String name; private @Nullable String description; private @Nullable Variable.VariableOrder order; private @Nullable Variable.VariablePolicy policy; private @Nullable Variable.VariableScope scope; private @Nullable Variable.VariableNoValuesLeftBehavior noValuesLeftBehavior; private Builder() { } /** * Fill a builder with attribute values from the provided {@code com.neotys.neoload.model.repository.Variable} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Variable instance) { Objects.requireNonNull(instance, "instance"); from((Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code com.neotys.neoload.model.repository.CounterNumberVariable} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(CounterNumberVariable instance) { Objects.requireNonNull(instance, "instance"); from((Object) instance); return this; } private void from(Object object) { if (object instanceof Variable) { Variable instance = (Variable) object; name(instance.getName()); Optional noValuesLeftBehaviorOptional = instance.getNoValuesLeftBehavior(); if (noValuesLeftBehaviorOptional.isPresent()) { noValuesLeftBehavior(noValuesLeftBehaviorOptional); } Optional descriptionOptional = instance.getDescription(); if (descriptionOptional.isPresent()) { description(descriptionOptional); } scope(instance.getScope()); Optional orderOptional = instance.getOrder(); if (orderOptional.isPresent()) { order(orderOptional); } policy(instance.getPolicy()); } if (object instanceof CounterNumberVariable) { CounterNumberVariable instance = (CounterNumberVariable) object; increment(instance.getIncrement()); maxValue(instance.getMaxValue()); startValue(instance.getStartValue()); } } /** * Initializes the value for the {@link CounterNumberVariable#getStartValue() startValue} attribute. * @param startValue The value for startValue * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("startValue") public final Builder startValue(int startValue) { this.startValue = startValue; initBits &= ~INIT_BIT_START_VALUE; return this; } /** * Initializes the value for the {@link CounterNumberVariable#getMaxValue() maxValue} attribute. * @param maxValue The value for maxValue * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("maxValue") public final Builder maxValue(int maxValue) { this.maxValue = maxValue; initBits &= ~INIT_BIT_MAX_VALUE; return this; } /** * Initializes the value for the {@link CounterNumberVariable#getIncrement() increment} attribute. * @param increment The value for increment * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("increment") public final Builder increment(int increment) { this.increment = increment; initBits &= ~INIT_BIT_INCREMENT; return this; } /** * Initializes the value for the {@link CounterNumberVariable#getName() name} attribute. * @param name The value for name * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("name") public final Builder name(String name) { this.name = Objects.requireNonNull(name, "name"); initBits &= ~INIT_BIT_NAME; return this; } /** * Initializes the optional value {@link CounterNumberVariable#getDescription() description} to description. * @param description The value for description * @return {@code this} builder for chained invocation */ @CanIgnoreReturnValue public final Builder description(String description) { this.description = Objects.requireNonNull(description, "description"); return this; } /** * Initializes the optional value {@link CounterNumberVariable#getDescription() description} to description. * @param description The value for description * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("description") public final Builder description(Optional description) { this.description = description.orElse(null); return this; } /** * Initializes the optional value {@link CounterNumberVariable#getOrder() order} to order. * @param order The value for order * @return {@code this} builder for chained invocation */ @CanIgnoreReturnValue public final Builder order(Variable.VariableOrder order) { this.order = Objects.requireNonNull(order, "order"); return this; } /** * Initializes the optional value {@link CounterNumberVariable#getOrder() order} to order. * @param order The value for order * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("order") public final Builder order(Optional order) { this.order = order.orElse(null); return this; } /** * Initializes the value for the {@link CounterNumberVariable#getPolicy() policy} attribute. * @param policy The value for policy * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("policy") public final Builder policy(Variable.VariablePolicy policy) { this.policy = Objects.requireNonNull(policy, "policy"); initBits &= ~INIT_BIT_POLICY; return this; } /** * Initializes the value for the {@link CounterNumberVariable#getScope() scope} attribute. * @param scope The value for scope * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("scope") public final Builder scope(Variable.VariableScope scope) { this.scope = Objects.requireNonNull(scope, "scope"); initBits &= ~INIT_BIT_SCOPE; return this; } /** * Initializes the optional value {@link CounterNumberVariable#getNoValuesLeftBehavior() noValuesLeftBehavior} to noValuesLeftBehavior. * @param noValuesLeftBehavior The value for noValuesLeftBehavior * @return {@code this} builder for chained invocation */ @CanIgnoreReturnValue public final Builder noValuesLeftBehavior(Variable.VariableNoValuesLeftBehavior noValuesLeftBehavior) { this.noValuesLeftBehavior = Objects.requireNonNull(noValuesLeftBehavior, "noValuesLeftBehavior"); return this; } /** * Initializes the optional value {@link CounterNumberVariable#getNoValuesLeftBehavior() noValuesLeftBehavior} to noValuesLeftBehavior. * @param noValuesLeftBehavior The value for noValuesLeftBehavior * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("noValuesLeftBehavior") public final Builder noValuesLeftBehavior(Optional noValuesLeftBehavior) { this.noValuesLeftBehavior = noValuesLeftBehavior.orElse(null); return this; } /** * Builds a new {@link ImmutableCounterNumberVariable ImmutableCounterNumberVariable}. * @return An immutable instance of CounterNumberVariable * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableCounterNumberVariable build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return new ImmutableCounterNumberVariable( startValue, maxValue, increment, name, description, order, policy, scope, noValuesLeftBehavior); } private String formatRequiredAttributesMessage() { List attributes = Lists.newArrayList(); if ((initBits & INIT_BIT_START_VALUE) != 0) attributes.add("startValue"); if ((initBits & INIT_BIT_MAX_VALUE) != 0) attributes.add("maxValue"); if ((initBits & INIT_BIT_INCREMENT) != 0) attributes.add("increment"); if ((initBits & INIT_BIT_NAME) != 0) attributes.add("name"); if ((initBits & INIT_BIT_POLICY) != 0) attributes.add("policy"); if ((initBits & INIT_BIT_SCOPE) != 0) attributes.add("scope"); return "Cannot build CounterNumberVariable, some of required attributes are not set " + attributes; } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy