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

com.neotys.neoload.model.v3.project.scenario.ImmutableCustomPolicyStep Maven / Gradle / Ivy

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

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.errorprone.annotations.CanIgnoreReturnValue;
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;
import javax.validation.constraints.PositiveOrZero;

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

* Use the builder to create immutable instances: * {@code new CustomPolicyStep.Builder()}. */ @SuppressWarnings({"all"}) @ParametersAreNonnullByDefault @Generated({"Immutables.generator", "CustomPolicyStep"}) @Immutable @CheckReturnValue public final class ImmutableCustomPolicyStep implements CustomPolicyStep { private final LoadDuration when; private final java.lang.@PositiveOrZero(groups = {NeoLoad.class}) Integer users; private ImmutableCustomPolicyStep( LoadDuration when, java.lang.@PositiveOrZero(groups = {NeoLoad.class}) Integer users) { this.when = when; this.users = users; } /** * @return The value of the {@code when} attribute */ @JsonProperty("when") @Override public LoadDuration getWhen() { return when; } /** * @return The value of the {@code users} attribute */ @JsonProperty("users") @Override public java.lang.@PositiveOrZero(groups = {NeoLoad.class}) Integer getUsers() { return users; } /** * Copy the current immutable object by setting a value for the {@link CustomPolicyStep#getWhen() when} 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 when (can be {@code null}) * @return A modified copy of the {@code this} object */ public final ImmutableCustomPolicyStep withWhen(LoadDuration value) { if (this.when == value) return this; return new ImmutableCustomPolicyStep(value, this.users); } /** * Copy the current immutable object by setting a value for the {@link CustomPolicyStep#getUsers() users} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for users (can be {@code null}) * @return A modified copy of the {@code this} object */ public final ImmutableCustomPolicyStep withUsers(java.lang.@PositiveOrZero(groups = {NeoLoad.class}) Integer value) { if (Objects.equals(this.users, value)) return this; return new ImmutableCustomPolicyStep(this.when, value); } /** * This instance is equal to all instances of {@code ImmutableCustomPolicyStep} 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 ImmutableCustomPolicyStep && equalTo((ImmutableCustomPolicyStep) another); } private boolean equalTo(ImmutableCustomPolicyStep another) { return Objects.equals(when, another.when) && Objects.equals(users, another.users); } /** * Computes a hash code from attributes: {@code when}, {@code users}. * @return hashCode value */ @Override public int hashCode() { int h = 5381; h += (h << 5) + Objects.hashCode(when); h += (h << 5) + Objects.hashCode(users); return h; } /** * Prints the immutable value {@code CustomPolicyStep} with attribute values. * @return A string representation of the value */ @Override public String toString() { return MoreObjects.toStringHelper("CustomPolicyStep") .omitNullValues() .add("when", when) .add("users", users) .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 CustomPolicyStep { @Nullable LoadDuration when; @Nullable java.lang.@PositiveOrZero(groups = {NeoLoad.class}) Integer users; @JsonProperty("when") public void setWhen(LoadDuration when) { this.when = when; } @JsonProperty("users") public void setUsers(java.lang.@PositiveOrZero(groups = {NeoLoad.class}) Integer users) { this.users = users; } @Override public LoadDuration getWhen() { throw new UnsupportedOperationException(); } @Override public java.lang.@PositiveOrZero(groups = {NeoLoad.class}) Integer getUsers() { 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 ImmutableCustomPolicyStep fromJson(Json json) { CustomPolicyStep.Builder builder = new CustomPolicyStep.Builder(); if (json.when != null) { builder.when(json.when); } if (json.users != null) { builder.users(json.users); } return (ImmutableCustomPolicyStep) builder.build(); } /** * Creates an immutable copy of a {@link CustomPolicyStep} 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 CustomPolicyStep instance */ public static ImmutableCustomPolicyStep copyOf(CustomPolicyStep instance) { if (instance instanceof ImmutableCustomPolicyStep) { return (ImmutableCustomPolicyStep) instance; } return new CustomPolicyStep.Builder() .from(instance) .build(); } /** * Builds instances of type {@link ImmutableCustomPolicyStep ImmutableCustomPolicyStep}. * 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 LoadDuration when; private @Nullable java.lang.@PositiveOrZero(groups = {NeoLoad.class}) Integer users; /** * Creates a builder for {@link ImmutableCustomPolicyStep ImmutableCustomPolicyStep} instances. */ public Builder() { if (!(this instanceof CustomPolicyStep.Builder)) { throw new UnsupportedOperationException("Use: new CustomPolicyStep.Builder()"); } } /** * Fill a builder with attribute values from the provided {@code CustomPolicyStep} instance. * Regular attribute values will be replaced with those from the given instance. * Absent optional values will not replace present values. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final CustomPolicyStep.Builder from(CustomPolicyStep instance) { Objects.requireNonNull(instance, "instance"); LoadDuration whenValue = instance.getWhen(); if (whenValue != null) { when(whenValue); } java.lang.@PositiveOrZero(groups = {NeoLoad.class}) Integer usersValue = instance.getUsers(); if (usersValue != null) { users(usersValue); } return (CustomPolicyStep.Builder) this; } /** * Initializes the value for the {@link CustomPolicyStep#getWhen() when} attribute. * @param when The value for when (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("when") public final CustomPolicyStep.Builder when(LoadDuration when) { this.when = when; return (CustomPolicyStep.Builder) this; } /** * Initializes the value for the {@link CustomPolicyStep#getUsers() users} attribute. * @param users The value for users (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("users") public final CustomPolicyStep.Builder users(java.lang.@PositiveOrZero(groups = {NeoLoad.class}) Integer users) { this.users = users; return (CustomPolicyStep.Builder) this; } /** * Builds a new {@link ImmutableCustomPolicyStep ImmutableCustomPolicyStep}. * @return An immutable instance of CustomPolicyStep * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableCustomPolicyStep build() { return new ImmutableCustomPolicyStep(when, users); } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy