com.neotys.neoload.model.v3.project.userpath.ImmutableUserPath 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.JsonInclude;
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.project.Element;
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 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 UserPath}.
*
* Use the builder to create immutable instances:
* {@code new UserPath.Builder()}.
*/
@SuppressWarnings({"all"})
@ParametersAreNonnullByDefault
@Generated({"Immutables.generator", "UserPath"})
@Immutable
@CheckReturnValue
public final class ImmutableUserPath implements UserPath {
private final UserPath.UserSession userSession;
private final @Nullable Container init;
private final com.neotys.neoload.model.v3.project.userpath.@Valid Container actions;
private final @Nullable Container end;
private final String name;
private final @Nullable String description;
private final ImmutableList contentAssertions;
private ImmutableUserPath(ImmutableUserPath.Builder builder) {
this.init = builder.init;
this.actions = builder.actions;
this.end = builder.end;
this.name = builder.name;
this.description = builder.description;
this.contentAssertions = builder.contentAssertions.build();
this.userSession = builder.userSession != null
? builder.userSession
: Objects.requireNonNull(UserPath.super.getUserSession(), "userSession");
}
private ImmutableUserPath(
UserPath.UserSession userSession,
@Nullable Container init,
com.neotys.neoload.model.v3.project.userpath.@Valid Container actions,
@Nullable Container end,
String name,
@Nullable String description,
ImmutableList contentAssertions) {
this.userSession = userSession;
this.init = init;
this.actions = actions;
this.end = end;
this.name = name;
this.description = description;
this.contentAssertions = contentAssertions;
}
/**
* @return The value of the {@code userSession} attribute
*/
@JsonProperty("userSession")
@JsonInclude(JsonInclude.Include.NON_DEFAULT)
@Override
public UserPath.UserSession getUserSession() {
return userSession;
}
/**
* @return The value of the {@code init} attribute
*/
@JsonProperty("init")
@Override
public java.util.@Valid Optional getInit() {
return java.util.Optional.ofNullable(init);
}
/**
* @return The value of the {@code actions} attribute
*/
@JsonProperty("actions")
@Override
public com.neotys.neoload.model.v3.project.userpath.@Valid Container getActions() {
return actions;
}
/**
* @return The value of the {@code end} attribute
*/
@JsonProperty("end")
@Override
public java.util.@Valid Optional getEnd() {
return java.util.Optional.ofNullable(end);
}
/**
* @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 java.util.Optional getDescription() {
return java.util.Optional.ofNullable(description);
}
/**
* @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 UserPath#getUserSession() userSession} attribute.
* A value equality check is used to prevent copying of the same value by returning {@code this}.
* @param value A new value for userSession
* @return A modified copy of the {@code this} object
*/
public final ImmutableUserPath withUserSession(UserPath.UserSession value) {
if (this.userSession == value) return this;
UserPath.UserSession newValue = Objects.requireNonNull(value, "userSession");
return new ImmutableUserPath(
newValue,
this.init,
this.actions,
this.end,
this.name,
this.description,
this.contentAssertions);
}
/**
* Copy the current immutable object by setting a present value for the optional {@link UserPath#getInit() init} attribute.
* @param value The value for init
* @return A modified copy of {@code this} object
*/
public final ImmutableUserPath withInit(Container value) {
@Nullable Container newValue = Objects.requireNonNull(value, "init");
if (this.init == newValue) return this;
return new ImmutableUserPath(
this.userSession,
newValue,
this.actions,
this.end,
this.name,
this.description,
this.contentAssertions);
}
/**
* Copy the current immutable object by setting an optional value for the {@link UserPath#getInit() init} attribute.
* A shallow reference equality check is used on unboxed optional value to prevent copying of the same value by returning {@code this}.
* @param optional A value for init
* @return A modified copy of {@code this} object
*/
public final ImmutableUserPath withInit(java.util.Optional extends Container> optional) {
@Nullable Container value = optional.orElse(null);
if (this.init == value) return this;
return new ImmutableUserPath(
this.userSession,
value,
this.actions,
this.end,
this.name,
this.description,
this.contentAssertions);
}
/**
* Copy the current immutable object by setting a value for the {@link UserPath#getActions() actions} 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 actions (can be {@code null})
* @return A modified copy of the {@code this} object
*/
public final ImmutableUserPath withActions(com.neotys.neoload.model.v3.project.userpath.@Valid Container value) {
if (this.actions == value) return this;
return new ImmutableUserPath(
this.userSession,
this.init,
value,
this.end,
this.name,
this.description,
this.contentAssertions);
}
/**
* Copy the current immutable object by setting a present value for the optional {@link UserPath#getEnd() end} attribute.
* @param value The value for end
* @return A modified copy of {@code this} object
*/
public final ImmutableUserPath withEnd(Container value) {
@Nullable Container newValue = Objects.requireNonNull(value, "end");
if (this.end == newValue) return this;
return new ImmutableUserPath(
this.userSession,
this.init,
this.actions,
newValue,
this.name,
this.description,
this.contentAssertions);
}
/**
* Copy the current immutable object by setting an optional value for the {@link UserPath#getEnd() end} attribute.
* A shallow reference equality check is used on unboxed optional value to prevent copying of the same value by returning {@code this}.
* @param optional A value for end
* @return A modified copy of {@code this} object
*/
public final ImmutableUserPath withEnd(java.util.Optional extends Container> optional) {
@Nullable Container value = optional.orElse(null);
if (this.end == value) return this;
return new ImmutableUserPath(
this.userSession,
this.init,
this.actions,
value,
this.name,
this.description,
this.contentAssertions);
}
/**
* Copy the current immutable object by setting a value for the {@link UserPath#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 (can be {@code null})
* @return A modified copy of the {@code this} object
*/
public final ImmutableUserPath withName(String value) {
if (Objects.equals(this.name, value)) return this;
return new ImmutableUserPath(
this.userSession,
this.init,
this.actions,
this.end,
value,
this.description,
this.contentAssertions);
}
/**
* Copy the current immutable object by setting a present value for the optional {@link UserPath#getDescription() description} attribute.
* @param value The value for description
* @return A modified copy of {@code this} object
*/
public final ImmutableUserPath withDescription(String value) {
@Nullable String newValue = Objects.requireNonNull(value, "description");
if (Objects.equals(this.description, newValue)) return this;
return new ImmutableUserPath(
this.userSession,
this.init,
this.actions,
this.end,
this.name,
newValue,
this.contentAssertions);
}
/**
* Copy the current immutable object by setting an optional value for the {@link UserPath#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 ImmutableUserPath withDescription(java.util.Optional optional) {
@Nullable String value = optional.orElse(null);
if (Objects.equals(this.description, value)) return this;
return new ImmutableUserPath(this.userSession, this.init, this.actions, this.end, this.name, value, this.contentAssertions);
}
/**
* Copy the current immutable object with elements that replace the content of {@link UserPath#getContentAssertions() contentAssertions}.
* @param elements The elements to set
* @return A modified copy of {@code this} object
*/
public final ImmutableUserPath withContentAssertions(ContentAssertion... elements) {
ImmutableList newValue = ImmutableList.copyOf(elements);
return new ImmutableUserPath(this.userSession, this.init, this.actions, this.end, this.name, this.description, newValue);
}
/**
* Copy the current immutable object with elements that replace the content of {@link UserPath#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 ImmutableUserPath withContentAssertions(Iterable extends ContentAssertion> elements) {
if (this.contentAssertions == elements) return this;
ImmutableList newValue = ImmutableList.copyOf(elements);
return new ImmutableUserPath(this.userSession, this.init, this.actions, this.end, this.name, this.description, newValue);
}
/**
* This instance is equal to all instances of {@code ImmutableUserPath} 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 ImmutableUserPath
&& equalTo((ImmutableUserPath) another);
}
private boolean equalTo(ImmutableUserPath another) {
return userSession.equals(another.userSession)
&& Objects.equals(init, another.init)
&& Objects.equals(actions, another.actions)
&& Objects.equals(end, another.end)
&& Objects.equals(name, another.name)
&& Objects.equals(description, another.description)
&& contentAssertions.equals(another.contentAssertions);
}
/**
* Computes a hash code from attributes: {@code userSession}, {@code init}, {@code actions}, {@code end}, {@code name}, {@code description}, {@code contentAssertions}.
* @return hashCode value
*/
@Override
public int hashCode() {
int h = 5381;
h += (h << 5) + userSession.hashCode();
h += (h << 5) + Objects.hashCode(init);
h += (h << 5) + Objects.hashCode(actions);
h += (h << 5) + Objects.hashCode(end);
h += (h << 5) + Objects.hashCode(name);
h += (h << 5) + Objects.hashCode(description);
h += (h << 5) + contentAssertions.hashCode();
return h;
}
/**
* Prints the immutable value {@code UserPath} with attribute values.
* @return A string representation of the value
*/
@Override
public String toString() {
return MoreObjects.toStringHelper("UserPath")
.omitNullValues()
.add("userSession", userSession)
.add("init", init)
.add("actions", actions)
.add("end", end)
.add("name", name)
.add("description", description)
.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 UserPath {
@Nullable UserPath.UserSession userSession;
java.util.@Valid Optional init = java.util.Optional.empty();
@Nullable com.neotys.neoload.model.v3.project.userpath.@Valid Container actions;
java.util.@Valid Optional end = java.util.Optional.empty();
@Nullable String name;
java.util.Optional description = java.util.Optional.empty();
java.util.@Valid List contentAssertions = ImmutableList.of();
@JsonProperty("userSession")
@JsonInclude(JsonInclude.Include.NON_DEFAULT)
public void setUserSession(UserPath.UserSession userSession) {
this.userSession = userSession;
}
@JsonProperty("init")
public void setInit(java.util.@Valid Optional init) {
this.init = init;
}
@JsonProperty("actions")
public void setActions(com.neotys.neoload.model.v3.project.userpath.@Valid Container actions) {
this.actions = actions;
}
@JsonProperty("end")
public void setEnd(java.util.@Valid Optional end) {
this.end = end;
}
@JsonProperty("name")
public void setName(String name) {
this.name = name;
}
@JsonProperty("description")
public void setDescription(java.util.Optional description) {
this.description = description;
}
@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 UserPath.UserSession getUserSession() { throw new UnsupportedOperationException(); }
@Override
public java.util.@Valid Optional getInit() { throw new UnsupportedOperationException(); }
@Override
public com.neotys.neoload.model.v3.project.userpath.@Valid Container getActions() { throw new UnsupportedOperationException(); }
@Override
public java.util.@Valid Optional getEnd() { throw new UnsupportedOperationException(); }
@Override
public String getName() { throw new UnsupportedOperationException(); }
@Override
public java.util.Optional getDescription() { 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 ImmutableUserPath fromJson(Json json) {
UserPath.Builder builder = new UserPath.Builder();
if (json.userSession != null) {
builder.userSession(json.userSession);
}
if (json.init != null) {
builder.init(json.init);
}
if (json.actions != null) {
builder.actions(json.actions);
}
if (json.end != null) {
builder.end(json.end);
}
if (json.name != null) {
builder.name(json.name);
}
if (json.description != null) {
builder.description(json.description);
}
if (json.contentAssertions != null) {
builder.addAllContentAssertions(json.contentAssertions);
}
return (ImmutableUserPath) builder.build();
}
/**
* Creates an immutable copy of a {@link UserPath} 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 UserPath instance
*/
public static ImmutableUserPath copyOf(UserPath instance) {
if (instance instanceof ImmutableUserPath) {
return (ImmutableUserPath) instance;
}
return new UserPath.Builder()
.from(instance)
.build();
}
/**
* Builds instances of type {@link ImmutableUserPath ImmutableUserPath}.
* 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 UserPath.UserSession userSession;
private @Nullable Container init;
private @Nullable com.neotys.neoload.model.v3.project.userpath.@Valid Container actions;
private @Nullable Container end;
private @Nullable String name;
private @Nullable String description;
private ImmutableList.Builder contentAssertions = ImmutableList.builder();
/**
* Creates a builder for {@link ImmutableUserPath ImmutableUserPath} instances.
*/
public Builder() {
if (!(this instanceof UserPath.Builder)) {
throw new UnsupportedOperationException("Use: new UserPath.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 UserPath.Builder from(Element instance) {
Objects.requireNonNull(instance, "instance");
from((Object) instance);
return (UserPath.Builder) this;
}
/**
* Fill a builder with attribute values from the provided {@code com.neotys.neoload.model.v3.project.userpath.UserPath} instance.
* @param instance The instance from which to copy values
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final UserPath.Builder from(UserPath instance) {
Objects.requireNonNull(instance, "instance");
from((Object) instance);
return (UserPath.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 UserPath.Builder from(ContentAssertionElement instance) {
Objects.requireNonNull(instance, "instance");
from((Object) instance);
return (UserPath.Builder) this;
}
private void from(Object object) {
if (object instanceof Element) {
Element instance = (Element) object;
String nameValue = instance.getName();
if (nameValue != null) {
name(nameValue);
}
java.util.Optional descriptionOptional = instance.getDescription();
if (descriptionOptional.isPresent()) {
description(descriptionOptional);
}
}
if (object instanceof UserPath) {
UserPath instance = (UserPath) object;
java.util.@Valid Optional initOptional = instance.getInit();
if (initOptional.isPresent()) {
init(initOptional);
}
userSession(instance.getUserSession());
java.util.@Valid Optional endOptional = instance.getEnd();
if (endOptional.isPresent()) {
end(endOptional);
}
com.neotys.neoload.model.v3.project.userpath.@Valid Container actionsValue = instance.getActions();
if (actionsValue != null) {
actions(actionsValue);
}
}
if (object instanceof ContentAssertionElement) {
ContentAssertionElement instance = (ContentAssertionElement) object;
addAllContentAssertions(instance.getContentAssertions());
}
}
/**
* Initializes the value for the {@link UserPath#getUserSession() userSession} attribute.
* If not set, this attribute will have a default value as returned by the initializer of {@link UserPath#getUserSession() userSession}.
* @param userSession The value for userSession
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("userSession")
@JsonInclude(JsonInclude.Include.NON_DEFAULT)
public final UserPath.Builder userSession(UserPath.UserSession userSession) {
this.userSession = Objects.requireNonNull(userSession, "userSession");
return (UserPath.Builder) this;
}
/**
* Initializes the optional value {@link UserPath#getInit() init} to init.
* @param init The value for init
* @return {@code this} builder for chained invocation
*/
@CanIgnoreReturnValue
public final UserPath.Builder init(Container init) {
this.init = Objects.requireNonNull(init, "init");
return (UserPath.Builder) this;
}
/**
* Initializes the optional value {@link UserPath#getInit() init} to init.
* @param init The value for init
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("init")
public final UserPath.Builder init(java.util.Optional extends Container> init) {
this.init = init.orElse(null);
return (UserPath.Builder) this;
}
/**
* Initializes the value for the {@link UserPath#getActions() actions} attribute.
* @param actions The value for actions (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("actions")
public final UserPath.Builder actions(com.neotys.neoload.model.v3.project.userpath.@Valid Container actions) {
this.actions = actions;
return (UserPath.Builder) this;
}
/**
* Initializes the optional value {@link UserPath#getEnd() end} to end.
* @param end The value for end
* @return {@code this} builder for chained invocation
*/
@CanIgnoreReturnValue
public final UserPath.Builder end(Container end) {
this.end = Objects.requireNonNull(end, "end");
return (UserPath.Builder) this;
}
/**
* Initializes the optional value {@link UserPath#getEnd() end} to end.
* @param end The value for end
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("end")
public final UserPath.Builder end(java.util.Optional extends Container> end) {
this.end = end.orElse(null);
return (UserPath.Builder) this;
}
/**
* Initializes the value for the {@link UserPath#getName() name} attribute.
* @param name The value for name (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("name")
public final UserPath.Builder name(String name) {
this.name = name;
return (UserPath.Builder) this;
}
/**
* Initializes the optional value {@link UserPath#getDescription() description} to description.
* @param description The value for description
* @return {@code this} builder for chained invocation
*/
@CanIgnoreReturnValue
public final UserPath.Builder description(String description) {
this.description = Objects.requireNonNull(description, "description");
return (UserPath.Builder) this;
}
/**
* Initializes the optional value {@link UserPath#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 UserPath.Builder description(java.util.Optional description) {
this.description = description.orElse(null);
return (UserPath.Builder) this;
}
/**
* Adds one element to {@link UserPath#getContentAssertions() contentAssertions} list.
* @param element A contentAssertions element
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final UserPath.Builder addContentAssertions(ContentAssertion element) {
this.contentAssertions.add(element);
return (UserPath.Builder) this;
}
/**
* Adds elements to {@link UserPath#getContentAssertions() contentAssertions} list.
* @param elements An array of contentAssertions elements
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final UserPath.Builder addContentAssertions(ContentAssertion... elements) {
this.contentAssertions.add(elements);
return (UserPath.Builder) this;
}
/**
* Sets or replaces all elements for {@link UserPath#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 UserPath.Builder contentAssertions(Iterable extends ContentAssertion> elements) {
this.contentAssertions = ImmutableList.builder();
return addAllContentAssertions(elements);
}
/**
* Adds elements to {@link UserPath#getContentAssertions() contentAssertions} list.
* @param elements An iterable of contentAssertions elements
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final UserPath.Builder addAllContentAssertions(Iterable extends ContentAssertion> elements) {
this.contentAssertions.addAll(elements);
return (UserPath.Builder) this;
}
/**
* Builds a new {@link ImmutableUserPath ImmutableUserPath}.
* @return An immutable instance of UserPath
* @throws java.lang.IllegalStateException if any required attributes are missing
*/
public ImmutableUserPath build() {
return new ImmutableUserPath(this);
}
}
}