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

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

There is a newer version: 3.3.3
Show newest version
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.common.collect.ImmutableList;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.errorprone.annotations.Var;
import com.neotys.neoload.model.v3.binding.serializer.MatchDeserializer;
import com.neotys.neoload.model.v3.binding.serializer.StepsDeserializer;
import com.neotys.neoload.model.v3.project.Element;
import java.util.ArrayList;
import java.util.List;
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 While}.
 * 

* Use the builder to create immutable instances: * {@code new While.Builder()}. */ @Generated(from = "While", generator = "Immutables") @SuppressWarnings({"all"}) @ParametersAreNonnullByDefault @javax.annotation.processing.Generated("org.immutables.processor.ProxyProcessor") @Immutable @CheckReturnValue public final class ImmutableWhile implements While { private final @Nullable String description; private final String name; private final ImmutableList conditions; private final Match match; private final ImmutableList steps; private ImmutableWhile(ImmutableWhile.Builder builder) { this.description = builder.description; this.conditions = builder.conditions.build(); this.steps = builder.steps.build(); if (builder.nameIsSet()) { initShim.name(builder.name); } if (builder.matchIsSet()) { initShim.match(builder.match); } this.name = initShim.getName(); this.match = initShim.getMatch(); this.initShim = null; } private ImmutableWhile( @Nullable String description, String name, ImmutableList conditions, Match match, ImmutableList steps) { this.description = description; this.name = name; this.conditions = conditions; this.match = match; this.steps = steps; this.initShim = null; } private static final byte STAGE_INITIALIZING = -1; private static final byte STAGE_UNINITIALIZED = 0; private static final byte STAGE_INITIALIZED = 1; @SuppressWarnings("Immutable") private transient volatile InitShim initShim = new InitShim(); @Generated(from = "While", generator = "Immutables") private final class InitShim { private byte nameBuildStage = STAGE_UNINITIALIZED; private String name; String getName() { if (nameBuildStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage()); if (nameBuildStage == STAGE_UNINITIALIZED) { nameBuildStage = STAGE_INITIALIZING; this.name = getNameInitialize(); nameBuildStage = STAGE_INITIALIZED; } return this.name; } void name(String name) { this.name = name; nameBuildStage = STAGE_INITIALIZED; } private byte matchBuildStage = STAGE_UNINITIALIZED; private Match match; Match getMatch() { if (matchBuildStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage()); if (matchBuildStage == STAGE_UNINITIALIZED) { matchBuildStage = STAGE_INITIALIZING; this.match = getMatchInitialize(); matchBuildStage = STAGE_INITIALIZED; } return this.match; } void match(Match match) { this.match = match; matchBuildStage = STAGE_INITIALIZED; } private String formatInitCycleMessage() { List attributes = new ArrayList<>(); if (nameBuildStage == STAGE_INITIALIZING) attributes.add("name"); if (matchBuildStage == STAGE_INITIALIZING) attributes.add("match"); return "Cannot build While, attribute initializers form cycle " + attributes; } } private String getNameInitialize() { return While.super.getName(); } private Match getMatchInitialize() { return While.super.getMatch(); } /** * @return The value of the {@code description} attribute */ @JsonProperty("description") @Override public Optional getDescription() { return Optional.ofNullable(description); } /** * @return The value of the {@code name} attribute */ @JsonProperty("name") @Override public String getName() { InitShim shim = this.initShim; return shim != null ? shim.getName() : this.name; } /** * @return The value of the {@code conditions} attribute */ @JsonProperty("conditions") @Override public ImmutableList getConditions() { return conditions; } /** * @return The value of the {@code match} attribute */ @JsonProperty("match") @JsonDeserialize(using = MatchDeserializer.class) @Override public Match getMatch() { InitShim shim = this.initShim; return shim != null ? shim.getMatch() : this.match; } /** * @return The value of the {@code steps} attribute */ @JsonProperty("steps") @JsonDeserialize(using = StepsDeserializer.class) @Override public ImmutableList getSteps() { return steps; } /** * Copy the current immutable object by setting a present value for the optional {@link While#getDescription() description} attribute. * @param value The value for description * @return A modified copy of {@code this} object */ public final ImmutableWhile withDescription(String value) { String newValue = Objects.requireNonNull(value, "description"); if (Objects.equals(this.description, newValue)) return this; return new ImmutableWhile(newValue, this.name, this.conditions, this.match, this.steps); } /** * Copy the current immutable object by setting an optional value for the {@link While#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 ImmutableWhile withDescription(Optional optional) { @Nullable String value = optional.orElse(null); if (Objects.equals(this.description, value)) return this; return new ImmutableWhile(value, this.name, this.conditions, this.match, this.steps); } /** * Copy the current immutable object by setting a value for the {@link While#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 ImmutableWhile withName(String value) { String newValue = value; if (this.name.equals(newValue)) return this; return new ImmutableWhile(this.description, newValue, this.conditions, this.match, this.steps); } /** * Copy the current immutable object with elements that replace the content of {@link While#getConditions() conditions}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final ImmutableWhile withConditions(Condition... elements) { ImmutableList newValue = ImmutableList.copyOf(elements); return new ImmutableWhile(this.description, this.name, newValue, this.match, this.steps); } /** * Copy the current immutable object with elements that replace the content of {@link While#getConditions() conditions}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of conditions elements to set * @return A modified copy of {@code this} object */ public final ImmutableWhile withConditions(Iterable elements) { if (this.conditions == elements) return this; ImmutableList newValue = ImmutableList.copyOf(elements); return new ImmutableWhile(this.description, this.name, newValue, this.match, this.steps); } /** * Copy the current immutable object by setting a value for the {@link While#getMatch() match} attribute. * A value equality check is 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 ImmutableWhile withMatch(Match value) { Match newValue = value; if (this.match == newValue) return this; return new ImmutableWhile(this.description, this.name, this.conditions, newValue, this.steps); } /** * Copy the current immutable object with elements that replace the content of {@link While#getSteps() steps}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final ImmutableWhile withSteps(Step... elements) { ImmutableList newValue = ImmutableList.copyOf(elements); return new ImmutableWhile(this.description, this.name, this.conditions, this.match, newValue); } /** * Copy the current immutable object with elements that replace the content of {@link While#getSteps() steps}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of steps elements to set * @return A modified copy of {@code this} object */ public final ImmutableWhile withSteps(Iterable elements) { if (this.steps == elements) return this; ImmutableList newValue = ImmutableList.copyOf(elements); return new ImmutableWhile(this.description, this.name, this.conditions, this.match, newValue); } /** * This instance is equal to all instances of {@code ImmutableWhile} 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 ImmutableWhile && equalTo(0, (ImmutableWhile) another); } private boolean equalTo(int synthetic, ImmutableWhile another) { return Objects.equals(description, another.description) && name.equals(another.name) && conditions.equals(another.conditions) && match.equals(another.match) && steps.equals(another.steps); } /** * Computes a hash code from attributes: {@code description}, {@code name}, {@code conditions}, {@code match}, {@code steps}. * @return hashCode value */ @Override public int hashCode() { @Var int h = 5381; h += (h << 5) + Objects.hashCode(description); h += (h << 5) + name.hashCode(); h += (h << 5) + conditions.hashCode(); h += (h << 5) + match.hashCode(); h += (h << 5) + steps.hashCode(); return h; } /** * Prints the immutable value {@code While} with attribute values. * @return A string representation of the value */ @Override public String toString() { return MoreObjects.toStringHelper("While") .omitNullValues() .add("description", description) .add("name", name) .add("conditions", conditions) .add("match", match) .add("steps", steps) .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 = "While", generator = "Immutables") @Deprecated @SuppressWarnings("Immutable") @JsonDeserialize @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE) static final class Json implements While { @Nullable Optional description = Optional.empty(); @Nullable String name; boolean nameIsSet; @Nullable List conditions = ImmutableList.of(); @Nullable Match match; boolean matchIsSet; @Nullable List steps = ImmutableList.of(); @JsonProperty("description") public void setDescription(Optional description) { this.description = description; } @JsonProperty("name") public void setName(String name) { this.name = name; this.nameIsSet = null != name; } @JsonProperty("conditions") public void setConditions(List conditions) { this.conditions = conditions; } @JsonProperty("match") @JsonDeserialize(using = MatchDeserializer.class) public void setMatch(Match match) { this.match = match; this.matchIsSet = null != match; } @JsonProperty("steps") @JsonDeserialize(using = StepsDeserializer.class) public void setSteps(List steps) { this.steps = steps; } @Override public Element withName(String of) { throw new UnsupportedOperationException(); } @Override public Optional getDescription() { throw new UnsupportedOperationException(); } @Override public String getName() { throw new UnsupportedOperationException(); } @Override public List getConditions() { throw new UnsupportedOperationException(); } @Override public Match getMatch() { throw new UnsupportedOperationException(); } @Override public List getSteps() { 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 ImmutableWhile fromJson(Json json) { While.Builder builder = new While.Builder(); if (json.description != null) { builder.description(json.description); } if (json.nameIsSet) { builder.name(json.name); } if (json.conditions != null) { builder.addAllConditions(json.conditions); } if (json.matchIsSet) { builder.match(json.match); } if (json.steps != null) { builder.addAllSteps(json.steps); } return (ImmutableWhile) builder.build(); } /** * Creates an immutable copy of a {@link While} 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 While instance */ public static ImmutableWhile copyOf(While instance) { if (instance instanceof ImmutableWhile) { return (ImmutableWhile) instance; } return new While.Builder() .from(instance) .build(); } /** * Builds instances of type {@link ImmutableWhile ImmutableWhile}. * 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 = "While", generator = "Immutables") @NotThreadSafe public static class Builder { private static final long OPT_BIT_NAME = 0x1L; private static final long OPT_BIT_MATCH = 0x2L; private long optBits; private @Nullable String description; private @Nullable String name; private ImmutableList.Builder conditions = ImmutableList.builder(); private @Nullable Match match; private ImmutableList.Builder steps = ImmutableList.builder(); /** * Creates a builder for {@link ImmutableWhile ImmutableWhile} instances. *

     * new While.Builder()
     *    .description(String) // optional {@link While#getDescription() description}
     *    .name(String) // optional {@link While#getName() name}
     *    .addConditions|addAllConditions(com.neotys.neoload.model.v3.project.userpath.Condition) // {@link While#getConditions() conditions} elements
     *    .match(com.neotys.neoload.model.v3.project.userpath.Match) // optional {@link While#getMatch() match}
     *    .addSteps|addAllSteps(com.neotys.neoload.model.v3.project.userpath.Step) // {@link While#getSteps() steps} elements
     *    .build();
     * 
*/ public Builder() { if (!(this instanceof While.Builder)) { throw new UnsupportedOperationException("Use: new While.Builder()"); } } /** * Fill a builder with attribute values from the provided {@code com.neotys.neoload.model.v3.project.userpath.Step} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final While.Builder from(Step instance) { Objects.requireNonNull(instance, "instance"); from((Object) instance); return (While.Builder) this; } /** * Fill a builder with attribute values from the provided {@code com.neotys.neoload.model.v3.project.Element} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final While.Builder from(Element instance) { Objects.requireNonNull(instance, "instance"); from((Object) instance); return (While.Builder) this; } /** * Fill a builder with attribute values from the provided {@code com.neotys.neoload.model.v3.project.userpath.While} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final While.Builder from(While instance) { Objects.requireNonNull(instance, "instance"); from((Object) instance); return (While.Builder) this; } private void from(Object object) { @Var long bits = 0; if (object instanceof Step) { Step instance = (Step) object; if ((bits & 0x1L) == 0) { name(instance.getName()); bits |= 0x1L; } if ((bits & 0x2L) == 0) { Optional descriptionOptional = instance.getDescription(); if (descriptionOptional.isPresent()) { description(descriptionOptional); } bits |= 0x2L; } } if (object instanceof Element) { Element instance = (Element) object; if ((bits & 0x1L) == 0) { name(instance.getName()); bits |= 0x1L; } if ((bits & 0x2L) == 0) { Optional descriptionOptional = instance.getDescription(); if (descriptionOptional.isPresent()) { description(descriptionOptional); } bits |= 0x2L; } } if (object instanceof While) { While instance = (While) object; if ((bits & 0x1L) == 0) { name(instance.getName()); bits |= 0x1L; } match(instance.getMatch()); if ((bits & 0x2L) == 0) { Optional descriptionOptional = instance.getDescription(); if (descriptionOptional.isPresent()) { description(descriptionOptional); } bits |= 0x2L; } addAllConditions(instance.getConditions()); addAllSteps(instance.getSteps()); } } /** * Initializes the optional value {@link While#getDescription() description} to description. * @param description The value for description * @return {@code this} builder for chained invocation */ @CanIgnoreReturnValue public final While.Builder description(String description) { this.description = Objects.requireNonNull(description, "description"); return (While.Builder) this; } /** * Initializes the optional value {@link While#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 While.Builder description(Optional description) { this.description = description.orElse(null); return (While.Builder) this; } /** * Initializes the value for the {@link While#getName() name} attribute. *

If not set, this attribute will have a default value as returned by the initializer of {@link While#getName() name}. * @param name The value for name * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("name") public final While.Builder name(String name) { this.name = name; optBits |= OPT_BIT_NAME; return (While.Builder) this; } /** * Adds one element to {@link While#getConditions() conditions} list. * @param element A conditions element * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final While.Builder addConditions(@Nullable Condition element) { this.conditions.add(element); return (While.Builder) this; } /** * Adds elements to {@link While#getConditions() conditions} list. * @param elements An array of conditions elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final While.Builder addConditions(Condition... elements) { this.conditions.add(elements); return (While.Builder) this; } /** * Sets or replaces all elements for {@link While#getConditions() conditions} list. * @param elements An iterable of conditions elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("conditions") public final While.Builder conditions(Iterable elements) { this.conditions = ImmutableList.builder(); return addAllConditions(elements); } /** * Adds elements to {@link While#getConditions() conditions} list. * @param elements An iterable of conditions elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final While.Builder addAllConditions(Iterable elements) { this.conditions.addAll(elements); return (While.Builder) this; } /** * Initializes the value for the {@link While#getMatch() match} attribute. *

If not set, this attribute will have a default value as returned by the initializer of {@link While#getMatch() match}. * @param match The value for match * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("match") @JsonDeserialize(using = MatchDeserializer.class) public final While.Builder match(Match match) { this.match = match; optBits |= OPT_BIT_MATCH; return (While.Builder) this; } /** * Adds one element to {@link While#getSteps() steps} list. * @param element A steps element * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final While.Builder addSteps(@Nullable Step element) { this.steps.add(element); return (While.Builder) this; } /** * Adds elements to {@link While#getSteps() steps} list. * @param elements An array of steps elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final While.Builder addSteps(Step... elements) { this.steps.add(elements); return (While.Builder) this; } /** * Sets or replaces all elements for {@link While#getSteps() steps} list. * @param elements An iterable of steps elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("steps") @JsonDeserialize(using = StepsDeserializer.class) public final While.Builder steps(Iterable elements) { this.steps = ImmutableList.builder(); return addAllSteps(elements); } /** * Adds elements to {@link While#getSteps() steps} list. * @param elements An iterable of steps elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final While.Builder addAllSteps(Iterable elements) { this.steps.addAll(elements); return (While.Builder) this; } /** * Builds a new {@link ImmutableWhile ImmutableWhile}. * @return An immutable instance of While * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableWhile build() { return new ImmutableWhile(this); } private boolean nameIsSet() { return (optBits & OPT_BIT_NAME) != 0; } private boolean matchIsSet() { return (optBits & OPT_BIT_MATCH) != 0; } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy