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

com.neotys.neoload.model.v3.project.userpath.ImmutableLoop 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.common.collect.ImmutableList;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.neotys.neoload.model.v3.binding.serializer.ElementsDeserializer;
import com.neotys.neoload.model.v3.project.Element;
import com.neotys.neoload.model.v3.validation.groups.NeoLoad;
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;
import javax.validation.Valid;
import javax.validation.constraints.Pattern;

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

* Use the builder to create immutable instances: * {@code new Loop.Builder()}. */ @SuppressWarnings({"all"}) @ParametersAreNonnullByDefault @Generated({"Immutables.generator", "Loop"}) @Immutable @CheckReturnValue public final class ImmutableLoop implements Loop { private final String name; private final java.lang.@Valid @Pattern(regexp = "(\\d+|\\$\\{\\w+\\})", groups = {NeoLoad.class}) String count; private final ImmutableList steps; private final @Nullable String description; private ImmutableLoop(ImmutableLoop.Builder builder) { this.count = builder.count; this.steps = builder.steps.build(); this.description = builder.description; this.name = builder.name != null ? builder.name : Objects.requireNonNull(Loop.super.getName(), "name"); } private ImmutableLoop( String name, java.lang.@Valid @Pattern(regexp = "(\\d+|\\$\\{\\w+\\})", groups = {NeoLoad.class}) String count, ImmutableList steps, @Nullable String description) { this.name = name; this.count = count; this.steps = steps; this.description = description; } /** * @return The value of the {@code name} attribute */ @JsonProperty("name") @Override public String getName() { return name; } /** * @return The value of the {@code count} attribute */ @JsonProperty("count") @Override public java.lang.@Valid @Pattern(regexp = "(\\d+|\\$\\{\\w+\\})", groups = {NeoLoad.class}) String getCount() { return count; } /** * @return The value of the {@code steps} attribute */ @JsonProperty("steps") @JsonDeserialize(using = ElementsDeserializer.class) @Override public ImmutableList getSteps() { return steps; } /** * @return The value of the {@code description} attribute */ @JsonProperty("description") @Override public Optional getDescription() { return Optional.ofNullable(description); } /** * Copy the current immutable object by setting a value for the {@link Loop#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 ImmutableLoop withName(String value) { if (this.name.equals(value)) return this; String newValue = Objects.requireNonNull(value, "name"); return new ImmutableLoop(newValue, this.count, this.steps, this.description); } /** * Copy the current immutable object by setting a value for the {@link Loop#getCount() count} 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 count (can be {@code null}) * @return A modified copy of the {@code this} object */ public final ImmutableLoop withCount(java.lang.@Valid @Pattern(regexp = "(\\d+|\\$\\{\\w+\\})", groups = {NeoLoad.class}) String value) { if (this.count == value) return this; return new ImmutableLoop(this.name, value, this.steps, this.description); } /** * Copy the current immutable object with elements that replace the content of {@link Loop#getSteps() steps}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final ImmutableLoop withSteps(Step... elements) { ImmutableList newValue = ImmutableList.copyOf(elements); return new ImmutableLoop(this.name, this.count, newValue, this.description); } /** * Copy the current immutable object with elements that replace the content of {@link Loop#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 ImmutableLoop withSteps(Iterable elements) { if (this.steps == elements) return this; ImmutableList newValue = ImmutableList.copyOf(elements); return new ImmutableLoop(this.name, this.count, newValue, this.description); } /** * Copy the current immutable object by setting a present value for the optional {@link Loop#getDescription() description} attribute. * @param value The value for description * @return A modified copy of {@code this} object */ public final ImmutableLoop withDescription(String value) { @Nullable String newValue = Objects.requireNonNull(value, "description"); if (Objects.equals(this.description, newValue)) return this; return new ImmutableLoop(this.name, this.count, this.steps, newValue); } /** * Copy the current immutable object by setting an optional value for the {@link Loop#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 ImmutableLoop withDescription(Optional optional) { @Nullable String value = optional.orElse(null); if (Objects.equals(this.description, value)) return this; return new ImmutableLoop(this.name, this.count, this.steps, value); } /** * This instance is equal to all instances of {@code ImmutableLoop} 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 ImmutableLoop && equalTo((ImmutableLoop) another); } private boolean equalTo(ImmutableLoop another) { return name.equals(another.name) && Objects.equals(count, another.count) && steps.equals(another.steps) && Objects.equals(description, another.description); } /** * Computes a hash code from attributes: {@code name}, {@code count}, {@code steps}, {@code description}. * @return hashCode value */ @Override public int hashCode() { int h = 5381; h += (h << 5) + name.hashCode(); h += (h << 5) + Objects.hashCode(count); h += (h << 5) + steps.hashCode(); h += (h << 5) + Objects.hashCode(description); return h; } /** * Prints the immutable value {@code Loop} with attribute values. * @return A string representation of the value */ @Override public String toString() { return MoreObjects.toStringHelper("Loop") .omitNullValues() .add("name", name) .add("count", count) .add("steps", steps) .add("description", description) .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 Loop { @Nullable String name; @Nullable java.lang.@Valid @Pattern(regexp = "(\\d+|\\$\\{\\w+\\})", groups = {NeoLoad.class}) String count; java.util.@Valid List steps = ImmutableList.of(); Optional description = Optional.empty(); @JsonProperty("name") public void setName(String name) { this.name = name; } @JsonProperty("count") public void setCount(java.lang.@Valid @Pattern(regexp = "(\\d+|\\$\\{\\w+\\})", groups = {NeoLoad.class}) String count) { this.count = count; } @JsonProperty("steps") @JsonDeserialize(using = ElementsDeserializer.class) public void setSteps(java.util.@Valid List steps) { this.steps = steps; } @JsonProperty("description") public void setDescription(Optional description) { this.description = description; } @Override public Element withName(String of) { throw new UnsupportedOperationException(); } @Override public String getName() { throw new UnsupportedOperationException(); } @Override public java.lang.@Valid @Pattern(regexp = "(\\d+|\\$\\{\\w+\\})", groups = {NeoLoad.class}) String getCount() { throw new UnsupportedOperationException(); } @Override public java.util.@Valid List getSteps() { throw new UnsupportedOperationException(); } @Override public Optional getDescription() { 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 ImmutableLoop fromJson(Json json) { Loop.Builder builder = new Loop.Builder(); if (json.name != null) { builder.name(json.name); } if (json.count != null) { builder.count(json.count); } if (json.steps != null) { builder.addAllSteps(json.steps); } if (json.description != null) { builder.description(json.description); } return (ImmutableLoop) builder.build(); } /** * Creates an immutable copy of a {@link Loop} 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 Loop instance */ public static ImmutableLoop copyOf(Loop instance) { if (instance instanceof ImmutableLoop) { return (ImmutableLoop) instance; } return new Loop.Builder() .from(instance) .build(); } /** * Builds instances of type {@link ImmutableLoop ImmutableLoop}. * 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 class Builder { private @Nullable String name; private @Nullable java.lang.@Valid @Pattern(regexp = "(\\d+|\\$\\{\\w+\\})", groups = {NeoLoad.class}) String count; private ImmutableList.Builder steps = ImmutableList.builder(); private @Nullable String description; /** * Creates a builder for {@link ImmutableLoop ImmutableLoop} instances. */ public Builder() { if (!(this instanceof Loop.Builder)) { throw new UnsupportedOperationException("Use: new Loop.Builder()"); } } /** * 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 Loop.Builder from(Element instance) { Objects.requireNonNull(instance, "instance"); from((Object) instance); return (Loop.Builder) this; } /** * Fill a builder with attribute values from the provided {@code com.neotys.neoload.model.v3.project.userpath.Loop} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Loop.Builder from(Loop instance) { Objects.requireNonNull(instance, "instance"); from((Object) instance); return (Loop.Builder) this; } private void from(Object object) { long bits = 0; if (object instanceof Element) { Element instance = (Element) object; if ((bits & 0x1L) == 0) { name(instance.getName()); bits |= 0x1L; } Optional descriptionOptional = instance.getDescription(); if (descriptionOptional.isPresent()) { description(descriptionOptional); } } if (object instanceof Loop) { Loop instance = (Loop) object; if ((bits & 0x1L) == 0) { name(instance.getName()); bits |= 0x1L; } java.lang.@Valid @Pattern(regexp = "(\\d+|\\$\\{\\w+\\})", groups = {NeoLoad.class}) String countValue = instance.getCount(); if (countValue != null) { count(countValue); } addAllSteps(instance.getSteps()); } } /** * Initializes the value for the {@link Loop#getName() name} attribute. *

If not set, this attribute will have a default value as returned by the initializer of {@link Loop#getName() name}. * @param name The value for name * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("name") public final Loop.Builder name(String name) { this.name = Objects.requireNonNull(name, "name"); return (Loop.Builder) this; } /** * Initializes the value for the {@link Loop#getCount() count} attribute. * @param count The value for count (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("count") public final Loop.Builder count(java.lang.@Valid @Pattern(regexp = "(\\d+|\\$\\{\\w+\\})", groups = {NeoLoad.class}) String count) { this.count = count; return (Loop.Builder) this; } /** * Adds one element to {@link Loop#getSteps() steps} list. * @param element A steps element * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Loop.Builder addSteps(Step element) { this.steps.add(element); return (Loop.Builder) this; } /** * Adds elements to {@link Loop#getSteps() steps} list. * @param elements An array of steps elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Loop.Builder addSteps(Step... elements) { this.steps.add(elements); return (Loop.Builder) this; } /** * Sets or replaces all elements for {@link Loop#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 = ElementsDeserializer.class) public final Loop.Builder steps(Iterable elements) { this.steps = ImmutableList.builder(); return addAllSteps(elements); } /** * Adds elements to {@link Loop#getSteps() steps} list. * @param elements An iterable of steps elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Loop.Builder addAllSteps(Iterable elements) { this.steps.addAll(elements); return (Loop.Builder) this; } /** * Initializes the optional value {@link Loop#getDescription() description} to description. * @param description The value for description * @return {@code this} builder for chained invocation */ @CanIgnoreReturnValue public final Loop.Builder description(String description) { this.description = Objects.requireNonNull(description, "description"); return (Loop.Builder) this; } /** * Initializes the optional value {@link Loop#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 Loop.Builder description(Optional description) { this.description = description.orElse(null); return (Loop.Builder) this; } /** * Builds a new {@link ImmutableLoop ImmutableLoop}. * @return An immutable instance of Loop * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableLoop build() { return new ImmutableLoop(this); } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy