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

com.neotys.neoload.model.v3.project.userpath.ImmutableSwitch 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.project.Element;
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 Switch}.
 * 

* Use the builder to create immutable instances: * {@code new Switch.Builder()}. */ @SuppressWarnings({"all"}) @ParametersAreNonnullByDefault @Generated({"Immutables.generator", "Switch"}) @Immutable @CheckReturnValue public final class ImmutableSwitch implements Switch { private final String name; private final java.lang.@Valid String value; private final ImmutableList cases; private final com.neotys.neoload.model.v3.project.userpath.@Valid Container getDefault; private final @Nullable String description; private ImmutableSwitch(ImmutableSwitch.Builder builder) { this.value = builder.value; this.cases = builder.cases.build(); this.getDefault = builder.getDefault; this.description = builder.description; this.name = builder.name != null ? builder.name : Objects.requireNonNull(Switch.super.getName(), "name"); } private ImmutableSwitch( String name, java.lang.@Valid String value, ImmutableList cases, com.neotys.neoload.model.v3.project.userpath.@Valid Container getDefault, @Nullable String description) { this.name = name; this.value = value; this.cases = cases; this.getDefault = getDefault; 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 value} attribute */ @JsonProperty("value") @Override public java.lang.@Valid String getValue() { return value; } /** * @return The value of the {@code cases} attribute */ @JsonProperty("case") @Override public ImmutableList getCases() { return cases; } /** * @return The value of the {@code getDefault} attribute */ @JsonProperty("default") @Override public com.neotys.neoload.model.v3.project.userpath.@Valid Container getDefault() { return getDefault; } /** * @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 Switch#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 ImmutableSwitch withName(String value) { if (this.name.equals(value)) return this; String newValue = Objects.requireNonNull(value, "name"); return new ImmutableSwitch(newValue, this.value, this.cases, this.getDefault, this.description); } /** * Copy the current immutable object by setting a value for the {@link Switch#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 ImmutableSwitch withValue(java.lang.@Valid String value) { if (this.value == value) return this; return new ImmutableSwitch(this.name, value, this.cases, this.getDefault, this.description); } /** * Copy the current immutable object with elements that replace the content of {@link Switch#getCases() cases}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final ImmutableSwitch withCases(Case... elements) { ImmutableList newValue = ImmutableList.copyOf(elements); return new ImmutableSwitch(this.name, this.value, newValue, this.getDefault, this.description); } /** * Copy the current immutable object with elements that replace the content of {@link Switch#getCases() cases}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of cases elements to set * @return A modified copy of {@code this} object */ public final ImmutableSwitch withCases(Iterable elements) { if (this.cases == elements) return this; ImmutableList newValue = ImmutableList.copyOf(elements); return new ImmutableSwitch(this.name, this.value, newValue, this.getDefault, this.description); } /** * Copy the current immutable object by setting a value for the {@link Switch#getDefault() default} 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 getDefault (can be {@code null}) * @return A modified copy of the {@code this} object */ public final ImmutableSwitch withDefault(com.neotys.neoload.model.v3.project.userpath.@Valid Container value) { if (this.getDefault == value) return this; return new ImmutableSwitch(this.name, this.value, this.cases, value, this.description); } /** * Copy the current immutable object by setting a present value for the optional {@link Switch#getDescription() description} attribute. * @param value The value for description * @return A modified copy of {@code this} object */ public final ImmutableSwitch withDescription(String value) { @Nullable String newValue = Objects.requireNonNull(value, "description"); if (Objects.equals(this.description, newValue)) return this; return new ImmutableSwitch(this.name, this.value, this.cases, this.getDefault, newValue); } /** * Copy the current immutable object by setting an optional value for the {@link Switch#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 ImmutableSwitch withDescription(Optional optional) { @Nullable String value = optional.orElse(null); if (Objects.equals(this.description, value)) return this; return new ImmutableSwitch(this.name, this.value, this.cases, this.getDefault, value); } /** * This instance is equal to all instances of {@code ImmutableSwitch} 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 ImmutableSwitch && equalTo((ImmutableSwitch) another); } private boolean equalTo(ImmutableSwitch another) { return name.equals(another.name) && Objects.equals(value, another.value) && cases.equals(another.cases) && Objects.equals(getDefault, another.getDefault) && Objects.equals(description, another.description); } /** * Computes a hash code from attributes: {@code name}, {@code value}, {@code cases}, {@code getDefault}, {@code description}. * @return hashCode value */ @Override public int hashCode() { int h = 5381; h += (h << 5) + name.hashCode(); h += (h << 5) + Objects.hashCode(value); h += (h << 5) + cases.hashCode(); h += (h << 5) + Objects.hashCode(getDefault); h += (h << 5) + Objects.hashCode(description); return h; } /** * Prints the immutable value {@code Switch} with attribute values. * @return A string representation of the value */ @Override public String toString() { return MoreObjects.toStringHelper("Switch") .omitNullValues() .add("name", name) .add("value", value) .add("cases", cases) .add("default", getDefault) .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 Switch { @Nullable String name; @Nullable java.lang.@Valid String value; java.util.@Valid List cases = ImmutableList.of(); @Nullable com.neotys.neoload.model.v3.project.userpath.@Valid Container getDefault; Optional description = Optional.empty(); @JsonProperty("name") public void setName(String name) { this.name = name; } @JsonProperty("value") public void setValue(java.lang.@Valid String value) { this.value = value; } @JsonProperty("case") public void setCases(java.util.@Valid List cases) { this.cases = cases; } @JsonProperty("default") public void setDefault(com.neotys.neoload.model.v3.project.userpath.@Valid Container getDefault) { this.getDefault = getDefault; } @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 String getValue() { throw new UnsupportedOperationException(); } @Override public java.util.@Valid List getCases() { throw new UnsupportedOperationException(); } @Override public com.neotys.neoload.model.v3.project.userpath.@Valid Container getDefault() { 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 ImmutableSwitch fromJson(Json json) { Switch.Builder builder = new Switch.Builder(); if (json.name != null) { builder.name(json.name); } if (json.value != null) { builder.value(json.value); } if (json.cases != null) { builder.addAllCases(json.cases); } if (json.getDefault != null) { builder.getDefault(json.getDefault); } if (json.description != null) { builder.description(json.description); } return (ImmutableSwitch) builder.build(); } /** * Creates an immutable copy of a {@link Switch} 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 Switch instance */ public static ImmutableSwitch copyOf(Switch instance) { if (instance instanceof ImmutableSwitch) { return (ImmutableSwitch) instance; } return new Switch.Builder() .from(instance) .build(); } /** * Builds instances of type {@link ImmutableSwitch ImmutableSwitch}. * 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 ImmutableList.Builder cases = ImmutableList.builder(); private @Nullable com.neotys.neoload.model.v3.project.userpath.@Valid Container getDefault; private @Nullable String description; /** * Creates a builder for {@link ImmutableSwitch ImmutableSwitch} instances. */ public Builder() { if (!(this instanceof Switch.Builder)) { throw new UnsupportedOperationException("Use: new Switch.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 Switch.Builder from(Element instance) { Objects.requireNonNull(instance, "instance"); from((Object) instance); return (Switch.Builder) this; } /** * Fill a builder with attribute values from the provided {@code com.neotys.neoload.model.v3.project.userpath.Switch} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Switch.Builder from(Switch instance) { Objects.requireNonNull(instance, "instance"); from((Object) instance); return (Switch.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 Switch) { Switch instance = (Switch) object; if ((bits & 0x1L) == 0) { name(instance.getName()); bits |= 0x1L; } com.neotys.neoload.model.v3.project.userpath.@Valid Container getDefaultValue = instance.getDefault(); if (getDefaultValue != null) { getDefault(getDefaultValue); } addAllCases(instance.getCases()); java.lang.@Valid String valueValue = instance.getValue(); if (valueValue != null) { value(valueValue); } } } /** * Initializes the value for the {@link Switch#getName() name} attribute. *

If not set, this attribute will have a default value as returned by the initializer of {@link Switch#getName() name}. * @param name The value for name * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("name") public final Switch.Builder name(String name) { this.name = Objects.requireNonNull(name, "name"); return (Switch.Builder) this; } /** * Initializes the value for the {@link Switch#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 Switch.Builder value(java.lang.@Valid String value) { this.value = value; return (Switch.Builder) this; } /** * Adds one element to {@link Switch#getCases() cases} list. * @param element A cases element * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Switch.Builder addCases(Case element) { this.cases.add(element); return (Switch.Builder) this; } /** * Adds elements to {@link Switch#getCases() cases} list. * @param elements An array of cases elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Switch.Builder addCases(Case... elements) { this.cases.add(elements); return (Switch.Builder) this; } /** * Sets or replaces all elements for {@link Switch#getCases() cases} list. * @param elements An iterable of cases elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("case") public final Switch.Builder cases(Iterable elements) { this.cases = ImmutableList.builder(); return addAllCases(elements); } /** * Adds elements to {@link Switch#getCases() cases} list. * @param elements An iterable of cases elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Switch.Builder addAllCases(Iterable elements) { this.cases.addAll(elements); return (Switch.Builder) this; } /** * Initializes the value for the {@link Switch#getDefault() default} attribute. * @param getDefault The value for getDefault (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("default") public final Switch.Builder getDefault(com.neotys.neoload.model.v3.project.userpath.@Valid Container getDefault) { this.getDefault = getDefault; return (Switch.Builder) this; } /** * Initializes the optional value {@link Switch#getDescription() description} to description. * @param description The value for description * @return {@code this} builder for chained invocation */ @CanIgnoreReturnValue public final Switch.Builder description(String description) { this.description = Objects.requireNonNull(description, "description"); return (Switch.Builder) this; } /** * Initializes the optional value {@link Switch#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 Switch.Builder description(Optional description) { this.description = description.orElse(null); return (Switch.Builder) this; } /** * Builds a new {@link ImmutableSwitch ImmutableSwitch}. * @return An immutable instance of Switch * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableSwitch build() { return new ImmutableSwitch(this); } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy