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

com.neotys.neoload.model.v3.project.userpath.ImmutableCustomAction 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.common.collect.Lists;
import com.google.common.primitives.Booleans;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.neotys.neoload.model.v3.project.Element;
import java.nio.file.Path;
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 CustomAction}.
 * 

* Use the builder to create immutable instances: * {@code new CustomAction.Builder()}. */ @SuppressWarnings({"all"}) @ParametersAreNonnullByDefault @Generated({"Immutables.generator", "CustomAction"}) @Immutable @CheckReturnValue public final class ImmutableCustomAction implements CustomAction { private final String type; private final boolean asRequest; private final ImmutableList parameters; private final @Nullable Path libraryPath; private final String name; private final @Nullable String description; private ImmutableCustomAction( String type, boolean asRequest, ImmutableList parameters, @Nullable Path libraryPath, String name, @Nullable String description) { this.type = type; this.asRequest = asRequest; this.parameters = parameters; this.libraryPath = libraryPath; this.name = name; this.description = description; } /** * @return The value of the {@code type} attribute */ @JsonProperty("type") @Override public String getType() { return type; } /** * @return The value of the {@code asRequest} attribute */ @JsonProperty("asRequest") @Override public boolean asRequest() { return asRequest; } /** * @return The value of the {@code parameters} attribute */ @JsonProperty("parameters") @Override public ImmutableList getParameters() { return parameters; } /** * @return The value of the {@code libraryPath} attribute */ @JsonProperty("libraryPath") @Override public Optional getLibraryPath() { return Optional.ofNullable(libraryPath); } /** * @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 CustomAction#getType() type} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for type * @return A modified copy of the {@code this} object */ public final ImmutableCustomAction withType(String value) { if (this.type.equals(value)) return this; String newValue = Objects.requireNonNull(value, "type"); return new ImmutableCustomAction(newValue, this.asRequest, this.parameters, this.libraryPath, this.name, this.description); } /** * Copy the current immutable object by setting a value for the {@link CustomAction#asRequest() asRequest} attribute. * A value equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for asRequest * @return A modified copy of the {@code this} object */ public final ImmutableCustomAction withAsRequest(boolean value) { if (this.asRequest == value) return this; return new ImmutableCustomAction(this.type, value, this.parameters, this.libraryPath, this.name, this.description); } /** * Copy the current immutable object with elements that replace the content of {@link CustomAction#getParameters() parameters}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final ImmutableCustomAction withParameters(CustomActionParameter... elements) { ImmutableList newValue = ImmutableList.copyOf(elements); return new ImmutableCustomAction(this.type, this.asRequest, newValue, this.libraryPath, this.name, this.description); } /** * Copy the current immutable object with elements that replace the content of {@link CustomAction#getParameters() parameters}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of parameters elements to set * @return A modified copy of {@code this} object */ public final ImmutableCustomAction withParameters(Iterable elements) { if (this.parameters == elements) return this; ImmutableList newValue = ImmutableList.copyOf(elements); return new ImmutableCustomAction(this.type, this.asRequest, newValue, this.libraryPath, this.name, this.description); } /** * Copy the current immutable object by setting a present value for the optional {@link CustomAction#getLibraryPath() libraryPath} attribute. * @param value The value for libraryPath * @return A modified copy of {@code this} object */ public final ImmutableCustomAction withLibraryPath(Path value) { @Nullable Path newValue = Objects.requireNonNull(value, "libraryPath"); if (this.libraryPath == newValue) return this; return new ImmutableCustomAction(this.type, this.asRequest, this.parameters, newValue, this.name, this.description); } /** * Copy the current immutable object by setting an optional value for the {@link CustomAction#getLibraryPath() libraryPath} 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 libraryPath * @return A modified copy of {@code this} object */ public final ImmutableCustomAction withLibraryPath(Optional optional) { @Nullable Path value = optional.orElse(null); if (this.libraryPath == value) return this; return new ImmutableCustomAction(this.type, this.asRequest, this.parameters, value, this.name, this.description); } /** * Copy the current immutable object by setting a value for the {@link CustomAction#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 ImmutableCustomAction withName(String value) { if (this.name.equals(value)) return this; String newValue = Objects.requireNonNull(value, "name"); return new ImmutableCustomAction(this.type, this.asRequest, this.parameters, this.libraryPath, newValue, this.description); } /** * Copy the current immutable object by setting a present value for the optional {@link CustomAction#getDescription() description} attribute. * @param value The value for description * @return A modified copy of {@code this} object */ public final ImmutableCustomAction withDescription(String value) { @Nullable String newValue = Objects.requireNonNull(value, "description"); if (Objects.equals(this.description, newValue)) return this; return new ImmutableCustomAction(this.type, this.asRequest, this.parameters, this.libraryPath, this.name, newValue); } /** * Copy the current immutable object by setting an optional value for the {@link CustomAction#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 ImmutableCustomAction withDescription(Optional optional) { @Nullable String value = optional.orElse(null); if (Objects.equals(this.description, value)) return this; return new ImmutableCustomAction(this.type, this.asRequest, this.parameters, this.libraryPath, this.name, value); } /** * This instance is equal to all instances of {@code ImmutableCustomAction} 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 ImmutableCustomAction && equalTo((ImmutableCustomAction) another); } private boolean equalTo(ImmutableCustomAction another) { return type.equals(another.type) && asRequest == another.asRequest && parameters.equals(another.parameters) && Objects.equals(libraryPath, another.libraryPath) && name.equals(another.name) && Objects.equals(description, another.description); } /** * Computes a hash code from attributes: {@code type}, {@code asRequest}, {@code parameters}, {@code libraryPath}, {@code name}, {@code description}. * @return hashCode value */ @Override public int hashCode() { int h = 5381; h += (h << 5) + type.hashCode(); h += (h << 5) + Booleans.hashCode(asRequest); h += (h << 5) + parameters.hashCode(); h += (h << 5) + Objects.hashCode(libraryPath); h += (h << 5) + name.hashCode(); h += (h << 5) + Objects.hashCode(description); return h; } /** * Prints the immutable value {@code CustomAction} with attribute values. * @return A string representation of the value */ @Override public String toString() { return MoreObjects.toStringHelper("CustomAction") .omitNullValues() .add("type", type) .add("asRequest", asRequest) .add("parameters", parameters) .add("libraryPath", libraryPath) .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 CustomAction { @Nullable String type; boolean asRequest; boolean asRequestIsSet; List parameters = ImmutableList.of(); Optional libraryPath = Optional.empty(); @Nullable String name; Optional description = Optional.empty(); @JsonProperty("type") public void setType(String type) { this.type = type; } @JsonProperty("asRequest") public void setAsRequest(boolean asRequest) { this.asRequest = asRequest; this.asRequestIsSet = true; } @JsonProperty("parameters") public void setParameters(List parameters) { this.parameters = parameters; } @JsonProperty("libraryPath") public void setLibraryPath(Optional libraryPath) { this.libraryPath = libraryPath; } @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 String getType() { throw new UnsupportedOperationException(); } @Override public boolean asRequest() { throw new UnsupportedOperationException(); } @Override public List getParameters() { throw new UnsupportedOperationException(); } @Override public Optional getLibraryPath() { 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 ImmutableCustomAction fromJson(Json json) { CustomAction.Builder builder = new CustomAction.Builder(); if (json.type != null) { builder.type(json.type); } if (json.asRequestIsSet) { builder.asRequest(json.asRequest); } if (json.parameters != null) { builder.addAllParameters(json.parameters); } if (json.libraryPath != null) { builder.libraryPath(json.libraryPath); } if (json.name != null) { builder.name(json.name); } if (json.description != null) { builder.description(json.description); } return (ImmutableCustomAction) builder.build(); } /** * Creates an immutable copy of a {@link CustomAction} 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 CustomAction instance */ public static ImmutableCustomAction copyOf(CustomAction instance) { if (instance instanceof ImmutableCustomAction) { return (ImmutableCustomAction) instance; } return new CustomAction.Builder() .from(instance) .build(); } /** * Builds instances of type {@link ImmutableCustomAction ImmutableCustomAction}. * 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 static final long INIT_BIT_TYPE = 0x1L; private static final long INIT_BIT_AS_REQUEST = 0x2L; private static final long INIT_BIT_NAME = 0x4L; private long initBits = 0x7L; private @Nullable String type; private boolean asRequest; private ImmutableList.Builder parameters = ImmutableList.builder(); private @Nullable Path libraryPath; private @Nullable String name; private @Nullable String description; /** * Creates a builder for {@link ImmutableCustomAction ImmutableCustomAction} instances. */ public Builder() { if (!(this instanceof CustomAction.Builder)) { throw new UnsupportedOperationException("Use: new CustomAction.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 CustomAction.Builder from(Element instance) { Objects.requireNonNull(instance, "instance"); from((Object) instance); return (CustomAction.Builder) this; } /** * Fill a builder with attribute values from the provided {@code com.neotys.neoload.model.v3.project.userpath.CustomAction} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final CustomAction.Builder from(CustomAction instance) { Objects.requireNonNull(instance, "instance"); from((Object) instance); return (CustomAction.Builder) this; } private void from(Object object) { if (object instanceof Element) { Element instance = (Element) object; name(instance.getName()); Optional descriptionOptional = instance.getDescription(); if (descriptionOptional.isPresent()) { description(descriptionOptional); } } if (object instanceof CustomAction) { CustomAction instance = (CustomAction) object; asRequest(instance.asRequest()); type(instance.getType()); addAllParameters(instance.getParameters()); Optional libraryPathOptional = instance.getLibraryPath(); if (libraryPathOptional.isPresent()) { libraryPath(libraryPathOptional); } } } /** * Initializes the value for the {@link CustomAction#getType() type} attribute. * @param type The value for type * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("type") public final CustomAction.Builder type(String type) { this.type = Objects.requireNonNull(type, "type"); initBits &= ~INIT_BIT_TYPE; return (CustomAction.Builder) this; } /** * Initializes the value for the {@link CustomAction#asRequest() asRequest} attribute. * @param asRequest The value for asRequest * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("asRequest") public final CustomAction.Builder asRequest(boolean asRequest) { this.asRequest = asRequest; initBits &= ~INIT_BIT_AS_REQUEST; return (CustomAction.Builder) this; } /** * Adds one element to {@link CustomAction#getParameters() parameters} list. * @param element A parameters element * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final CustomAction.Builder addParameters(CustomActionParameter element) { this.parameters.add(element); return (CustomAction.Builder) this; } /** * Adds elements to {@link CustomAction#getParameters() parameters} list. * @param elements An array of parameters elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final CustomAction.Builder addParameters(CustomActionParameter... elements) { this.parameters.add(elements); return (CustomAction.Builder) this; } /** * Sets or replaces all elements for {@link CustomAction#getParameters() parameters} list. * @param elements An iterable of parameters elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("parameters") public final CustomAction.Builder parameters(Iterable elements) { this.parameters = ImmutableList.builder(); return addAllParameters(elements); } /** * Adds elements to {@link CustomAction#getParameters() parameters} list. * @param elements An iterable of parameters elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final CustomAction.Builder addAllParameters(Iterable elements) { this.parameters.addAll(elements); return (CustomAction.Builder) this; } /** * Initializes the optional value {@link CustomAction#getLibraryPath() libraryPath} to libraryPath. * @param libraryPath The value for libraryPath * @return {@code this} builder for chained invocation */ @CanIgnoreReturnValue public final CustomAction.Builder libraryPath(Path libraryPath) { this.libraryPath = Objects.requireNonNull(libraryPath, "libraryPath"); return (CustomAction.Builder) this; } /** * Initializes the optional value {@link CustomAction#getLibraryPath() libraryPath} to libraryPath. * @param libraryPath The value for libraryPath * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("libraryPath") public final CustomAction.Builder libraryPath(Optional libraryPath) { this.libraryPath = libraryPath.orElse(null); return (CustomAction.Builder) this; } /** * Initializes the value for the {@link CustomAction#getName() name} attribute. * @param name The value for name * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("name") public final CustomAction.Builder name(String name) { this.name = Objects.requireNonNull(name, "name"); initBits &= ~INIT_BIT_NAME; return (CustomAction.Builder) this; } /** * Initializes the optional value {@link CustomAction#getDescription() description} to description. * @param description The value for description * @return {@code this} builder for chained invocation */ @CanIgnoreReturnValue public final CustomAction.Builder description(String description) { this.description = Objects.requireNonNull(description, "description"); return (CustomAction.Builder) this; } /** * Initializes the optional value {@link CustomAction#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 CustomAction.Builder description(Optional description) { this.description = description.orElse(null); return (CustomAction.Builder) this; } /** * Builds a new {@link ImmutableCustomAction ImmutableCustomAction}. * @return An immutable instance of CustomAction * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableCustomAction build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return new ImmutableCustomAction(type, asRequest, parameters.build(), libraryPath, name, description); } private String formatRequiredAttributesMessage() { List attributes = Lists.newArrayList(); if ((initBits & INIT_BIT_TYPE) != 0) attributes.add("type"); if ((initBits & INIT_BIT_AS_REQUEST) != 0) attributes.add("asRequest"); if ((initBits & INIT_BIT_NAME) != 0) attributes.add("name"); return "Cannot build CustomAction, some of required attributes are not set " + attributes; } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy