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

com.neotys.neoload.model.v3.project.userpath.ImmutableCase 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.StepsDeserializer;
import com.neotys.neoload.model.v3.project.Element;
import com.neotys.neoload.model.v3.project.SlaElement;
import com.neotys.neoload.model.v3.project.userpath.assertion.ContentAssertion;
import com.neotys.neoload.model.v3.project.userpath.assertion.ContentAssertionElement;
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;

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

* Use the builder to create immutable instances: * {@code new Case.Builder()}. */ @SuppressWarnings({"all"}) @ParametersAreNonnullByDefault @Generated({"Immutables.generator", "Case"}) @Immutable @CheckReturnValue public final class ImmutableCase implements Case { private final String name; private final java.lang.@Valid String value; private final java.lang.@Valid Boolean isBreak; private final ImmutableList steps; private final @Nullable String description; private final @Nullable String slaProfile; private final ImmutableList contentAssertions; private ImmutableCase(ImmutableCase.Builder builder) { this.value = builder.value; this.isBreak = builder.isBreak; this.steps = builder.steps.build(); this.description = builder.description; this.slaProfile = builder.slaProfile; this.contentAssertions = builder.contentAssertions.build(); this.name = builder.name != null ? builder.name : Objects.requireNonNull(Case.super.getName(), "name"); } private ImmutableCase( String name, java.lang.@Valid String value, java.lang.@Valid Boolean isBreak, ImmutableList steps, @Nullable String description, @Nullable String slaProfile, ImmutableList contentAssertions) { this.name = name; this.value = value; this.isBreak = isBreak; this.steps = steps; this.description = description; this.slaProfile = slaProfile; this.contentAssertions = contentAssertions; } /** * @return The value of the {@code name} attribute */ @JsonProperty("name") @Override public String getName() { return name; } /** * @return The value of the {@code value} attribute */ @JsonProperty("value") @Override public java.lang.@Valid String getValue() { return value; } /** * @return The value of the {@code isBreak} attribute */ @JsonProperty("break") @Override public java.lang.@Valid Boolean isBreak() { return isBreak; } /** * @return The value of the {@code steps} attribute */ @JsonProperty("steps") @JsonDeserialize(using = StepsDeserializer.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); } /** * @return The value of the {@code slaProfile} attribute */ @JsonProperty("sla_profile") @Override public Optional getSlaProfile() { return Optional.ofNullable(slaProfile); } /** * @return The value of the {@code contentAssertions} attribute */ @JsonProperty("assert_content") @Override public ImmutableList getContentAssertions() { return contentAssertions; } /** * Copy the current immutable object by setting a value for the {@link Case#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 ImmutableCase withName(String value) { if (this.name.equals(value)) return this; String newValue = Objects.requireNonNull(value, "name"); return new ImmutableCase( newValue, this.value, this.isBreak, this.steps, this.description, this.slaProfile, this.contentAssertions); } /** * Copy the current immutable object by setting a value for the {@link Case#getValue() value} 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 value (can be {@code null}) * @return A modified copy of the {@code this} object */ public final ImmutableCase withValue(java.lang.@Valid String value) { if (this.value == value) return this; return new ImmutableCase( this.name, value, this.isBreak, this.steps, this.description, this.slaProfile, this.contentAssertions); } /** * Copy the current immutable object by setting a value for the {@link Case#isBreak() isBreak} 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 isBreak (can be {@code null}) * @return A modified copy of the {@code this} object */ public final ImmutableCase withIsBreak(java.lang.@Valid Boolean value) { if (this.isBreak == value) return this; return new ImmutableCase( this.name, this.value, value, this.steps, this.description, this.slaProfile, this.contentAssertions); } /** * Copy the current immutable object with elements that replace the content of {@link Case#getSteps() steps}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final ImmutableCase withSteps(Step... elements) { ImmutableList newValue = ImmutableList.copyOf(elements); return new ImmutableCase( this.name, this.value, this.isBreak, newValue, this.description, this.slaProfile, this.contentAssertions); } /** * Copy the current immutable object with elements that replace the content of {@link Case#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 ImmutableCase withSteps(Iterable elements) { if (this.steps == elements) return this; ImmutableList newValue = ImmutableList.copyOf(elements); return new ImmutableCase( this.name, this.value, this.isBreak, newValue, this.description, this.slaProfile, this.contentAssertions); } /** * Copy the current immutable object by setting a present value for the optional {@link Case#getDescription() description} attribute. * @param value The value for description * @return A modified copy of {@code this} object */ public final ImmutableCase withDescription(String value) { @Nullable String newValue = Objects.requireNonNull(value, "description"); if (Objects.equals(this.description, newValue)) return this; return new ImmutableCase( this.name, this.value, this.isBreak, this.steps, newValue, this.slaProfile, this.contentAssertions); } /** * Copy the current immutable object by setting an optional value for the {@link Case#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 ImmutableCase withDescription(Optional optional) { @Nullable String value = optional.orElse(null); if (Objects.equals(this.description, value)) return this; return new ImmutableCase(this.name, this.value, this.isBreak, this.steps, value, this.slaProfile, this.contentAssertions); } /** * Copy the current immutable object by setting a present value for the optional {@link Case#getSlaProfile() slaProfile} attribute. * @param value The value for slaProfile * @return A modified copy of {@code this} object */ public final ImmutableCase withSlaProfile(String value) { @Nullable String newValue = Objects.requireNonNull(value, "slaProfile"); if (Objects.equals(this.slaProfile, newValue)) return this; return new ImmutableCase( this.name, this.value, this.isBreak, this.steps, this.description, newValue, this.contentAssertions); } /** * Copy the current immutable object by setting an optional value for the {@link Case#getSlaProfile() slaProfile} 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 slaProfile * @return A modified copy of {@code this} object */ public final ImmutableCase withSlaProfile(Optional optional) { @Nullable String value = optional.orElse(null); if (Objects.equals(this.slaProfile, value)) return this; return new ImmutableCase( this.name, this.value, this.isBreak, this.steps, this.description, value, this.contentAssertions); } /** * Copy the current immutable object with elements that replace the content of {@link Case#getContentAssertions() contentAssertions}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final ImmutableCase withContentAssertions(ContentAssertion... elements) { ImmutableList newValue = ImmutableList.copyOf(elements); return new ImmutableCase(this.name, this.value, this.isBreak, this.steps, this.description, this.slaProfile, newValue); } /** * Copy the current immutable object with elements that replace the content of {@link Case#getContentAssertions() contentAssertions}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of contentAssertions elements to set * @return A modified copy of {@code this} object */ public final ImmutableCase withContentAssertions(Iterable elements) { if (this.contentAssertions == elements) return this; ImmutableList newValue = ImmutableList.copyOf(elements); return new ImmutableCase(this.name, this.value, this.isBreak, this.steps, this.description, this.slaProfile, newValue); } /** * This instance is equal to all instances of {@code ImmutableCase} 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 ImmutableCase && equalTo((ImmutableCase) another); } private boolean equalTo(ImmutableCase another) { return name.equals(another.name) && Objects.equals(value, another.value) && Objects.equals(isBreak, another.isBreak) && steps.equals(another.steps) && Objects.equals(description, another.description) && Objects.equals(slaProfile, another.slaProfile) && contentAssertions.equals(another.contentAssertions); } /** * Computes a hash code from attributes: {@code name}, {@code value}, {@code isBreak}, {@code steps}, {@code description}, {@code slaProfile}, {@code contentAssertions}. * @return hashCode value */ @Override public int hashCode() { int h = 5381; h += (h << 5) + name.hashCode(); h += (h << 5) + Objects.hashCode(value); h += (h << 5) + Objects.hashCode(isBreak); h += (h << 5) + steps.hashCode(); h += (h << 5) + Objects.hashCode(description); h += (h << 5) + Objects.hashCode(slaProfile); h += (h << 5) + contentAssertions.hashCode(); return h; } /** * Prints the immutable value {@code Case} with attribute values. * @return A string representation of the value */ @Override public String toString() { return MoreObjects.toStringHelper("Case") .omitNullValues() .add("name", name) .add("value", value) .add("isBreak", isBreak) .add("steps", steps) .add("description", description) .add("slaProfile", slaProfile) .add("contentAssertions", contentAssertions) .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 Case { @Nullable String name; @Nullable java.lang.@Valid String value; @Nullable java.lang.@Valid Boolean isBreak; java.util.@Valid List steps = ImmutableList.of(); Optional description = Optional.empty(); Optional slaProfile = Optional.empty(); java.util.@Valid List contentAssertions = ImmutableList.of(); @JsonProperty("name") public void setName(String name) { this.name = name; } @JsonProperty("value") public void setValue(java.lang.@Valid String value) { this.value = value; } @JsonProperty("break") public void setIsBreak(java.lang.@Valid Boolean isBreak) { this.isBreak = isBreak; } @JsonProperty("steps") @JsonDeserialize(using = StepsDeserializer.class) public void setSteps(java.util.@Valid List steps) { this.steps = steps; } @JsonProperty("description") public void setDescription(Optional description) { this.description = description; } @JsonProperty("sla_profile") public void setSlaProfile(Optional slaProfile) { this.slaProfile = slaProfile; } @JsonProperty("assert_content") public void setContentAssertions(java.util.@Valid List contentAssertions) { this.contentAssertions = contentAssertions; } @Override public Element withName(String of) { throw new UnsupportedOperationException(); } @Override public String getName() { throw new UnsupportedOperationException(); } @Override public java.lang.@Valid String getValue() { throw new UnsupportedOperationException(); } @Override public java.lang.@Valid Boolean isBreak() { throw new UnsupportedOperationException(); } @Override public java.util.@Valid List getSteps() { throw new UnsupportedOperationException(); } @Override public Optional getDescription() { throw new UnsupportedOperationException(); } @Override public Optional getSlaProfile() { throw new UnsupportedOperationException(); } @Override public java.util.@Valid List getContentAssertions() { 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 ImmutableCase fromJson(Json json) { Case.Builder builder = new Case.Builder(); if (json.name != null) { builder.name(json.name); } if (json.value != null) { builder.value(json.value); } if (json.isBreak != null) { builder.isBreak(json.isBreak); } if (json.steps != null) { builder.addAllSteps(json.steps); } if (json.description != null) { builder.description(json.description); } if (json.slaProfile != null) { builder.slaProfile(json.slaProfile); } if (json.contentAssertions != null) { builder.addAllContentAssertions(json.contentAssertions); } return (ImmutableCase) builder.build(); } /** * Creates an immutable copy of a {@link Case} 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 Case instance */ public static ImmutableCase copyOf(Case instance) { if (instance instanceof ImmutableCase) { return (ImmutableCase) instance; } return new Case.Builder() .from(instance) .build(); } /** * Builds instances of type {@link ImmutableCase ImmutableCase}. * 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 String value; private @Nullable java.lang.@Valid Boolean isBreak; private ImmutableList.Builder steps = ImmutableList.builder(); private @Nullable String description; private @Nullable String slaProfile; private ImmutableList.Builder contentAssertions = ImmutableList.builder(); /** * Creates a builder for {@link ImmutableCase ImmutableCase} instances. */ public Builder() { if (!(this instanceof Case.Builder)) { throw new UnsupportedOperationException("Use: new Case.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 Case.Builder from(Element instance) { Objects.requireNonNull(instance, "instance"); from((Object) instance); return (Case.Builder) this; } /** * Fill a builder with attribute values from the provided {@code com.neotys.neoload.model.v3.project.SlaElement} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Case.Builder from(SlaElement instance) { Objects.requireNonNull(instance, "instance"); from((Object) instance); return (Case.Builder) this; } /** * Fill a builder with attribute values from the provided {@code com.neotys.neoload.model.v3.project.userpath.Case} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Case.Builder from(Case instance) { Objects.requireNonNull(instance, "instance"); from((Object) instance); return (Case.Builder) this; } /** * Fill a builder with attribute values from the provided {@code com.neotys.neoload.model.v3.project.userpath.assertion.ContentAssertionElement} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Case.Builder from(ContentAssertionElement instance) { Objects.requireNonNull(instance, "instance"); from((Object) instance); return (Case.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 SlaElement) { SlaElement instance = (SlaElement) object; Optional slaProfileOptional = instance.getSlaProfile(); if (slaProfileOptional.isPresent()) { slaProfile(slaProfileOptional); } } if (object instanceof Case) { Case instance = (Case) object; if ((bits & 0x1L) == 0) { name(instance.getName()); bits |= 0x1L; } java.lang.@Valid String valueValue = instance.getValue(); if (valueValue != null) { value(valueValue); } addAllSteps(instance.getSteps()); java.lang.@Valid Boolean isBreakValue = instance.isBreak(); if (isBreakValue != null) { isBreak(isBreakValue); } } if (object instanceof ContentAssertionElement) { ContentAssertionElement instance = (ContentAssertionElement) object; addAllContentAssertions(instance.getContentAssertions()); } } /** * Initializes the value for the {@link Case#getName() name} attribute. *

If not set, this attribute will have a default value as returned by the initializer of {@link Case#getName() name}. * @param name The value for name * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("name") public final Case.Builder name(String name) { this.name = Objects.requireNonNull(name, "name"); return (Case.Builder) this; } /** * Initializes the value for the {@link Case#getValue() value} attribute. * @param value The value for value (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("value") public final Case.Builder value(java.lang.@Valid String value) { this.value = value; return (Case.Builder) this; } /** * Initializes the value for the {@link Case#isBreak() isBreak} attribute. * @param isBreak The value for isBreak (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("break") public final Case.Builder isBreak(java.lang.@Valid Boolean isBreak) { this.isBreak = isBreak; return (Case.Builder) this; } /** * Adds one element to {@link Case#getSteps() steps} list. * @param element A steps element * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Case.Builder addSteps(Step element) { this.steps.add(element); return (Case.Builder) this; } /** * Adds elements to {@link Case#getSteps() steps} list. * @param elements An array of steps elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Case.Builder addSteps(Step... elements) { this.steps.add(elements); return (Case.Builder) this; } /** * Sets or replaces all elements for {@link Case#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 Case.Builder steps(Iterable elements) { this.steps = ImmutableList.builder(); return addAllSteps(elements); } /** * Adds elements to {@link Case#getSteps() steps} list. * @param elements An iterable of steps elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Case.Builder addAllSteps(Iterable elements) { this.steps.addAll(elements); return (Case.Builder) this; } /** * Initializes the optional value {@link Case#getDescription() description} to description. * @param description The value for description * @return {@code this} builder for chained invocation */ @CanIgnoreReturnValue public final Case.Builder description(String description) { this.description = Objects.requireNonNull(description, "description"); return (Case.Builder) this; } /** * Initializes the optional value {@link Case#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 Case.Builder description(Optional description) { this.description = description.orElse(null); return (Case.Builder) this; } /** * Initializes the optional value {@link Case#getSlaProfile() slaProfile} to slaProfile. * @param slaProfile The value for slaProfile * @return {@code this} builder for chained invocation */ @CanIgnoreReturnValue public final Case.Builder slaProfile(String slaProfile) { this.slaProfile = Objects.requireNonNull(slaProfile, "slaProfile"); return (Case.Builder) this; } /** * Initializes the optional value {@link Case#getSlaProfile() slaProfile} to slaProfile. * @param slaProfile The value for slaProfile * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("sla_profile") public final Case.Builder slaProfile(Optional slaProfile) { this.slaProfile = slaProfile.orElse(null); return (Case.Builder) this; } /** * Adds one element to {@link Case#getContentAssertions() contentAssertions} list. * @param element A contentAssertions element * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Case.Builder addContentAssertions(ContentAssertion element) { this.contentAssertions.add(element); return (Case.Builder) this; } /** * Adds elements to {@link Case#getContentAssertions() contentAssertions} list. * @param elements An array of contentAssertions elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Case.Builder addContentAssertions(ContentAssertion... elements) { this.contentAssertions.add(elements); return (Case.Builder) this; } /** * Sets or replaces all elements for {@link Case#getContentAssertions() contentAssertions} list. * @param elements An iterable of contentAssertions elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("assert_content") public final Case.Builder contentAssertions(Iterable elements) { this.contentAssertions = ImmutableList.builder(); return addAllContentAssertions(elements); } /** * Adds elements to {@link Case#getContentAssertions() contentAssertions} list. * @param elements An iterable of contentAssertions elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Case.Builder addAllContentAssertions(Iterable elements) { this.contentAssertions.addAll(elements); return (Case.Builder) this; } /** * Builds a new {@link ImmutableCase ImmutableCase}. * @return An immutable instance of Case * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableCase build() { return new ImmutableCase(this); } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy