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

com.neotys.neoload.model.v3.project.population.ImmutableUserPathPolicy Maven / Gradle / Ivy

package com.neotys.neoload.model.v3.project.population;

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.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.google.common.base.MoreObjects;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.neotys.neoload.model.v3.binding.converter.DoubleToPercentageConverter;
import com.neotys.neoload.model.v3.binding.converter.PercentageToDoubleConverter;
import com.neotys.neoload.model.v3.project.Element;
import com.neotys.neoload.model.v3.validation.constraints.DigitsCheck;
import com.neotys.neoload.model.v3.validation.constraints.RangeCheck;
import com.neotys.neoload.model.v3.validation.groups.NeoLoad;
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;

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

* Use the builder to create immutable instances: * {@code new UserPathPolicy.Builder()}. */ @SuppressWarnings({"all"}) @ParametersAreNonnullByDefault @Generated({"Immutables.generator", "UserPathPolicy"}) @Immutable @CheckReturnValue public final class ImmutableUserPathPolicy implements UserPathPolicy { private final @Nullable Double distribution; private final String name; private final @Nullable String description; private ImmutableUserPathPolicy( @Nullable Double distribution, String name, @Nullable String description) { this.distribution = distribution; this.name = name; this.description = description; } /** * @return The value of the {@code distribution} attribute */ @JsonSerialize(converter = DoubleToPercentageConverter.class) @JsonDeserialize(converter = PercentageToDoubleConverter.class) @JsonProperty("distribution") @Override public java.util.@DigitsCheck(integer = 3, fraction = 1, groups = {NeoLoad.class}) @RangeCheck(min = 0, max = 100, groups = {NeoLoad.class}) Optional getDistribution() { return java.util.Optional.ofNullable(distribution); } /** * @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); } /** * Copy the current immutable object by setting a present value for the optional {@link UserPathPolicy#getDistribution() distribution} attribute. * @param value The value for distribution * @return A modified copy of {@code this} object */ public final ImmutableUserPathPolicy withDistribution(double value) { @Nullable Double newValue = value; if (Objects.equals(this.distribution, newValue)) return this; return new ImmutableUserPathPolicy(newValue, this.name, this.description); } /** * Copy the current immutable object by setting an optional value for the {@link UserPathPolicy#getDistribution() distribution} 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 distribution * @return A modified copy of {@code this} object */ public final ImmutableUserPathPolicy withDistribution(java.util.Optional optional) { @Nullable Double value = optional.orElse(null); if (Objects.equals(this.distribution, value)) return this; return new ImmutableUserPathPolicy(value, this.name, this.description); } /** * Copy the current immutable object by setting a value for the {@link UserPathPolicy#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 ImmutableUserPathPolicy withName(String value) { if (Objects.equals(this.name, value)) return this; return new ImmutableUserPathPolicy(this.distribution, value, this.description); } /** * Copy the current immutable object by setting a present value for the optional {@link UserPathPolicy#getDescription() description} attribute. * @param value The value for description * @return A modified copy of {@code this} object */ public final ImmutableUserPathPolicy withDescription(String value) { @Nullable String newValue = Objects.requireNonNull(value, "description"); if (Objects.equals(this.description, newValue)) return this; return new ImmutableUserPathPolicy(this.distribution, this.name, newValue); } /** * Copy the current immutable object by setting an optional value for the {@link UserPathPolicy#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 ImmutableUserPathPolicy withDescription(java.util.Optional optional) { @Nullable String value = optional.orElse(null); if (Objects.equals(this.description, value)) return this; return new ImmutableUserPathPolicy(this.distribution, this.name, value); } /** * This instance is equal to all instances of {@code ImmutableUserPathPolicy} 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 ImmutableUserPathPolicy && equalTo((ImmutableUserPathPolicy) another); } private boolean equalTo(ImmutableUserPathPolicy another) { return Objects.equals(distribution, another.distribution) && Objects.equals(name, another.name) && Objects.equals(description, another.description); } /** * Computes a hash code from attributes: {@code distribution}, {@code name}, {@code description}. * @return hashCode value */ @Override public int hashCode() { int h = 5381; h += (h << 5) + Objects.hashCode(distribution); h += (h << 5) + Objects.hashCode(name); h += (h << 5) + Objects.hashCode(description); return h; } /** * Prints the immutable value {@code UserPathPolicy} with attribute values. * @return A string representation of the value */ @Override public String toString() { return MoreObjects.toStringHelper("UserPathPolicy") .omitNullValues() .add("distribution", distribution) .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 UserPathPolicy { java.util.@DigitsCheck(integer = 3, fraction = 1, groups = {NeoLoad.class}) @RangeCheck(min = 0, max = 100, groups = {NeoLoad.class}) Optional distribution = java.util.Optional.empty(); @Nullable String name; java.util.Optional description = java.util.Optional.empty(); @JsonSerialize(converter = DoubleToPercentageConverter.class) @JsonDeserialize(converter = PercentageToDoubleConverter.class) @JsonProperty("distribution") public void setDistribution(java.util.@DigitsCheck(integer = 3, fraction = 1, groups = {NeoLoad.class}) @RangeCheck(min = 0, max = 100, groups = {NeoLoad.class}) Optional distribution) { this.distribution = distribution; } @JsonProperty("name") public void setName(String name) { this.name = name; } @JsonProperty("description") public void setDescription(java.util.Optional description) { this.description = description; } @Override public Element withName(String of) { throw new UnsupportedOperationException(); } @Override public java.util.@DigitsCheck(integer = 3, fraction = 1, groups = {NeoLoad.class}) @RangeCheck(min = 0, max = 100, groups = {NeoLoad.class}) Optional getDistribution() { throw new UnsupportedOperationException(); } @Override public String getName() { throw new UnsupportedOperationException(); } @Override public java.util.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 ImmutableUserPathPolicy fromJson(Json json) { UserPathPolicy.Builder builder = new UserPathPolicy.Builder(); if (json.distribution != null) { builder.distribution(json.distribution); } if (json.name != null) { builder.name(json.name); } if (json.description != null) { builder.description(json.description); } return (ImmutableUserPathPolicy) builder.build(); } /** * Creates an immutable copy of a {@link UserPathPolicy} 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 UserPathPolicy instance */ public static ImmutableUserPathPolicy copyOf(UserPathPolicy instance) { if (instance instanceof ImmutableUserPathPolicy) { return (ImmutableUserPathPolicy) instance; } return new UserPathPolicy.Builder() .from(instance) .build(); } /** * Builds instances of type {@link ImmutableUserPathPolicy ImmutableUserPathPolicy}. * 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 Double distribution; private @Nullable String name; private @Nullable String description; /** * Creates a builder for {@link ImmutableUserPathPolicy ImmutableUserPathPolicy} instances. */ public Builder() { if (!(this instanceof UserPathPolicy.Builder)) { throw new UnsupportedOperationException("Use: new UserPathPolicy.Builder()"); } } /** * Fill a builder with attribute values from the provided {@code com.neotys.neoload.model.v3.project.population.UserPathPolicy} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final UserPathPolicy.Builder from(UserPathPolicy instance) { Objects.requireNonNull(instance, "instance"); from((Object) instance); return (UserPathPolicy.Builder) this; } /** * 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 UserPathPolicy.Builder from(Element instance) { Objects.requireNonNull(instance, "instance"); from((Object) instance); return (UserPathPolicy.Builder) this; } private void from(Object object) { if (object instanceof UserPathPolicy) { UserPathPolicy instance = (UserPathPolicy) object; java.util.@DigitsCheck(integer = 3, fraction = 1, groups = {NeoLoad.class}) @RangeCheck(min = 0, max = 100, groups = {NeoLoad.class}) Optional distributionOptional = instance.getDistribution(); if (distributionOptional.isPresent()) { distribution(distributionOptional); } } 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); } } } /** * Initializes the optional value {@link UserPathPolicy#getDistribution() distribution} to distribution. * @param distribution The value for distribution * @return {@code this} builder for chained invocation */ @CanIgnoreReturnValue public final UserPathPolicy.Builder distribution(double distribution) { this.distribution = distribution; return (UserPathPolicy.Builder) this; } /** * Initializes the optional value {@link UserPathPolicy#getDistribution() distribution} to distribution. * @param distribution The value for distribution * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonSerialize(converter = DoubleToPercentageConverter.class) @JsonDeserialize(converter = PercentageToDoubleConverter.class) @JsonProperty("distribution") public final UserPathPolicy.Builder distribution(java.util.Optional distribution) { this.distribution = distribution.orElse(null); return (UserPathPolicy.Builder) this; } /** * Initializes the value for the {@link UserPathPolicy#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 UserPathPolicy.Builder name(String name) { this.name = name; return (UserPathPolicy.Builder) this; } /** * Initializes the optional value {@link UserPathPolicy#getDescription() description} to description. * @param description The value for description * @return {@code this} builder for chained invocation */ @CanIgnoreReturnValue public final UserPathPolicy.Builder description(String description) { this.description = Objects.requireNonNull(description, "description"); return (UserPathPolicy.Builder) this; } /** * Initializes the optional value {@link UserPathPolicy#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 UserPathPolicy.Builder description(java.util.Optional description) { this.description = description.orElse(null); return (UserPathPolicy.Builder) this; } /** * Builds a new {@link ImmutableUserPathPolicy ImmutableUserPathPolicy}. * @return An immutable instance of UserPathPolicy * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableUserPathPolicy build() { return new ImmutableUserPathPolicy(distribution, name, description); } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy