com.neotys.neoload.model.repository.ImmutableUserPath 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 com.neotys.neoload.model.core.Element;
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 UserPath}.
*
* Use the builder to create immutable instances:
* {@code ImmutableUserPath.builder()}.
*/
@SuppressWarnings({"all"})
@ParametersAreNonnullByDefault
@Generated({"Immutables.generator", "UserPath"})
@Deprecated
@Immutable
@CheckReturnValue
public final class ImmutableUserPath implements UserPath {
private final ContainerForMulti initContainer;
private final ContainerForMulti actionsContainer;
private final ContainerForMulti endContainer;
private final String name;
private final @Nullable String description;
private ImmutableUserPath(
ContainerForMulti initContainer,
ContainerForMulti actionsContainer,
ContainerForMulti endContainer,
String name,
@Nullable String description) {
this.initContainer = initContainer;
this.actionsContainer = actionsContainer;
this.endContainer = endContainer;
this.name = name;
this.description = description;
}
/**
* @return The value of the {@code initContainer} attribute
*/
@JsonProperty("initContainer")
@Override
public ContainerForMulti getInitContainer() {
return initContainer;
}
/**
* @return The value of the {@code actionsContainer} attribute
*/
@JsonProperty("actionsContainer")
@Override
public ContainerForMulti getActionsContainer() {
return actionsContainer;
}
/**
* @return The value of the {@code endContainer} attribute
*/
@JsonProperty("endContainer")
@Override
public ContainerForMulti getEndContainer() {
return endContainer;
}
/**
* @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);
}
/**
* Copy the current immutable object by setting a value for the {@link UserPath#getInitContainer() initContainer} 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 initContainer
* @return A modified copy of the {@code this} object
*/
public final ImmutableUserPath withInitContainer(ContainerForMulti value) {
if (this.initContainer == value) return this;
ContainerForMulti newValue = Objects.requireNonNull(value, "initContainer");
return new ImmutableUserPath(newValue, this.actionsContainer, this.endContainer, this.name, this.description);
}
/**
* Copy the current immutable object by setting a value for the {@link UserPath#getActionsContainer() actionsContainer} 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 actionsContainer
* @return A modified copy of the {@code this} object
*/
public final ImmutableUserPath withActionsContainer(ContainerForMulti value) {
if (this.actionsContainer == value) return this;
ContainerForMulti newValue = Objects.requireNonNull(value, "actionsContainer");
return new ImmutableUserPath(this.initContainer, newValue, this.endContainer, this.name, this.description);
}
/**
* Copy the current immutable object by setting a value for the {@link UserPath#getEndContainer() endContainer} 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 endContainer
* @return A modified copy of the {@code this} object
*/
public final ImmutableUserPath withEndContainer(ContainerForMulti value) {
if (this.endContainer == value) return this;
ContainerForMulti newValue = Objects.requireNonNull(value, "endContainer");
return new ImmutableUserPath(this.initContainer, this.actionsContainer, newValue, this.name, this.description);
}
/**
* 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
* @return A modified copy of the {@code this} object
*/
public final ImmutableUserPath withName(String value) {
if (this.name.equals(value)) return this;
String newValue = Objects.requireNonNull(value, "name");
return new ImmutableUserPath(this.initContainer, this.actionsContainer, this.endContainer, newValue, this.description);
}
/**
* 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.initContainer, this.actionsContainer, this.endContainer, this.name, newValue);
}
/**
* 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(Optional optional) {
@Nullable String value = optional.orElse(null);
if (Objects.equals(this.description, value)) return this;
return new ImmutableUserPath(this.initContainer, this.actionsContainer, this.endContainer, this.name, value);
}
/**
* 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 initContainer.equals(another.initContainer)
&& actionsContainer.equals(another.actionsContainer)
&& endContainer.equals(another.endContainer)
&& name.equals(another.name)
&& Objects.equals(description, another.description);
}
/**
* Computes a hash code from attributes: {@code initContainer}, {@code actionsContainer}, {@code endContainer}, {@code name}, {@code description}.
* @return hashCode value
*/
@Override
public int hashCode() {
int h = 5381;
h += (h << 5) + initContainer.hashCode();
h += (h << 5) + actionsContainer.hashCode();
h += (h << 5) + endContainer.hashCode();
h += (h << 5) + name.hashCode();
h += (h << 5) + Objects.hashCode(description);
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("initContainer", initContainer)
.add("actionsContainer", actionsContainer)
.add("endContainer", endContainer)
.add("name", name)
.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 UserPath {
@Nullable ContainerForMulti initContainer;
@Nullable ContainerForMulti actionsContainer;
@Nullable ContainerForMulti endContainer;
@Nullable String name;
Optional description = Optional.empty();
@JsonProperty("initContainer")
public void setInitContainer(ContainerForMulti initContainer) {
this.initContainer = initContainer;
}
@JsonProperty("actionsContainer")
public void setActionsContainer(ContainerForMulti actionsContainer) {
this.actionsContainer = actionsContainer;
}
@JsonProperty("endContainer")
public void setEndContainer(ContainerForMulti endContainer) {
this.endContainer = endContainer;
}
@JsonProperty("name")
public void setName(String name) {
this.name = name;
}
@JsonProperty("description")
public void setDescription(Optional description) {
this.description = description;
}
@Override
public Element withName(String of) { throw new UnsupportedOperationException(); }
@Override
public ContainerForMulti getInitContainer() { throw new UnsupportedOperationException(); }
@Override
public ContainerForMulti getActionsContainer() { throw new UnsupportedOperationException(); }
@Override
public ContainerForMulti getEndContainer() { throw new UnsupportedOperationException(); }
@Override
public String getName() { 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 ImmutableUserPath fromJson(Json json) {
ImmutableUserPath.Builder builder = ImmutableUserPath.builder();
if (json.initContainer != null) {
builder.initContainer(json.initContainer);
}
if (json.actionsContainer != null) {
builder.actionsContainer(json.actionsContainer);
}
if (json.endContainer != null) {
builder.endContainer(json.endContainer);
}
if (json.name != null) {
builder.name(json.name);
}
if (json.description != null) {
builder.description(json.description);
}
return 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 ImmutableUserPath.builder()
.from(instance)
.build();
}
/**
* Creates a builder for {@link ImmutableUserPath ImmutableUserPath}.
* @return A new ImmutableUserPath builder
*/
public static ImmutableUserPath.Builder builder() {
return new ImmutableUserPath.Builder();
}
/**
* 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 final class Builder {
private static final long INIT_BIT_INIT_CONTAINER = 0x1L;
private static final long INIT_BIT_ACTIONS_CONTAINER = 0x2L;
private static final long INIT_BIT_END_CONTAINER = 0x4L;
private static final long INIT_BIT_NAME = 0x8L;
private long initBits = 0xfL;
private @Nullable ContainerForMulti initContainer;
private @Nullable ContainerForMulti actionsContainer;
private @Nullable ContainerForMulti endContainer;
private @Nullable String name;
private @Nullable String description;
private Builder() {
}
/**
* Fill a builder with attribute values from the provided {@code com.neotys.neoload.model.repository.UserPath} 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(UserPath instance) {
Objects.requireNonNull(instance, "instance");
from((Object) instance);
return this;
}
/**
* Fill a builder with attribute values from the provided {@code com.neotys.neoload.model.core.Element} 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(Element instance) {
Objects.requireNonNull(instance, "instance");
from((Object) instance);
return this;
}
private void from(Object object) {
if (object instanceof UserPath) {
UserPath instance = (UserPath) object;
endContainer(instance.getEndContainer());
actionsContainer(instance.getActionsContainer());
initContainer(instance.getInitContainer());
}
if (object instanceof Element) {
Element instance = (Element) object;
name(instance.getName());
Optional descriptionOptional = instance.getDescription();
if (descriptionOptional.isPresent()) {
description(descriptionOptional);
}
}
}
/**
* Initializes the value for the {@link UserPath#getInitContainer() initContainer} attribute.
* @param initContainer The value for initContainer
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("initContainer")
public final Builder initContainer(ContainerForMulti initContainer) {
this.initContainer = Objects.requireNonNull(initContainer, "initContainer");
initBits &= ~INIT_BIT_INIT_CONTAINER;
return this;
}
/**
* Initializes the value for the {@link UserPath#getActionsContainer() actionsContainer} attribute.
* @param actionsContainer The value for actionsContainer
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("actionsContainer")
public final Builder actionsContainer(ContainerForMulti actionsContainer) {
this.actionsContainer = Objects.requireNonNull(actionsContainer, "actionsContainer");
initBits &= ~INIT_BIT_ACTIONS_CONTAINER;
return this;
}
/**
* Initializes the value for the {@link UserPath#getEndContainer() endContainer} attribute.
* @param endContainer The value for endContainer
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("endContainer")
public final Builder endContainer(ContainerForMulti endContainer) {
this.endContainer = Objects.requireNonNull(endContainer, "endContainer");
initBits &= ~INIT_BIT_END_CONTAINER;
return this;
}
/**
* Initializes the value for the {@link UserPath#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 UserPath#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 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 Builder description(Optional description) {
this.description = description.orElse(null);
return 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() {
if (initBits != 0) {
throw new IllegalStateException(formatRequiredAttributesMessage());
}
return new ImmutableUserPath(initContainer, actionsContainer, endContainer, name, description);
}
private String formatRequiredAttributesMessage() {
List attributes = Lists.newArrayList();
if ((initBits & INIT_BIT_INIT_CONTAINER) != 0) attributes.add("initContainer");
if ((initBits & INIT_BIT_ACTIONS_CONTAINER) != 0) attributes.add("actionsContainer");
if ((initBits & INIT_BIT_END_CONTAINER) != 0) attributes.add("endContainer");
if ((initBits & INIT_BIT_NAME) != 0) attributes.add("name");
return "Cannot build UserPath, some of required attributes are not set " + attributes;
}
}
}