com.neotys.neoload.model.v3.project.scenario.ImmutableConstantLoadPolicy 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 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.Valid;
/**
* Immutable implementation of {@link ConstantLoadPolicy}.
*
* Use the builder to create immutable instances:
* {@code new ConstantLoadPolicy.Builder()}.
*/
@SuppressWarnings({"all"})
@ParametersAreNonnullByDefault
@Generated({"Immutables.generator", "ConstantLoadPolicy"})
@Immutable
@CheckReturnValue
public final class ImmutableConstantLoadPolicy
implements ConstantLoadPolicy {
private final int users;
private final Integer rampup;
private final com.neotys.neoload.model.v3.project.scenario.@Valid LoadDuration duration;
private final com.neotys.neoload.model.v3.project.scenario.@Valid StartAfter startAfter;
private final com.neotys.neoload.model.v3.project.scenario.@Valid StopAfter stopAfter;
private ImmutableConstantLoadPolicy(
int users,
Integer rampup,
com.neotys.neoload.model.v3.project.scenario.@Valid LoadDuration duration,
com.neotys.neoload.model.v3.project.scenario.@Valid StartAfter startAfter,
com.neotys.neoload.model.v3.project.scenario.@Valid StopAfter stopAfter) {
this.users = users;
this.rampup = rampup;
this.duration = duration;
this.startAfter = startAfter;
this.stopAfter = stopAfter;
}
/**
* @return The value of the {@code users} attribute
*/
@JsonProperty("users")
@Override
public int getUsers() {
return users;
}
/**
* @return The value of the {@code rampup} attribute
*/
@JsonProperty("rampup")
@Override
public Integer getRampup() {
return rampup;
}
/**
* @return The value of the {@code duration} attribute
*/
@JsonProperty("duration")
@Override
public com.neotys.neoload.model.v3.project.scenario.@Valid LoadDuration getDuration() {
return duration;
}
/**
* @return The value of the {@code startAfter} attribute
*/
@JsonProperty("start_after")
@Override
public com.neotys.neoload.model.v3.project.scenario.@Valid StartAfter getStartAfter() {
return startAfter;
}
/**
* @return The value of the {@code stopAfter} attribute
*/
@JsonProperty("stop_after")
@Override
public com.neotys.neoload.model.v3.project.scenario.@Valid StopAfter getStopAfter() {
return stopAfter;
}
/**
* Copy the current immutable object by setting a value for the {@link ConstantLoadPolicy#getUsers() users} attribute.
* A value equality check is used to prevent copying of the same value by returning {@code this}.
* @param value A new value for users
* @return A modified copy of the {@code this} object
*/
public final ImmutableConstantLoadPolicy withUsers(int value) {
if (this.users == value) return this;
return new ImmutableConstantLoadPolicy(value, this.rampup, this.duration, this.startAfter, this.stopAfter);
}
/**
* Copy the current immutable object by setting a value for the {@link ConstantLoadPolicy#getRampup() rampup} attribute.
* An equals check used to prevent copying of the same value by returning {@code this}.
* @param value A new value for rampup (can be {@code null})
* @return A modified copy of the {@code this} object
*/
public final ImmutableConstantLoadPolicy withRampup(Integer value) {
if (Objects.equals(this.rampup, value)) return this;
return new ImmutableConstantLoadPolicy(this.users, value, this.duration, this.startAfter, this.stopAfter);
}
/**
* Copy the current immutable object by setting a value for the {@link ConstantLoadPolicy#getDuration() duration} 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 duration (can be {@code null})
* @return A modified copy of the {@code this} object
*/
public final ImmutableConstantLoadPolicy withDuration(com.neotys.neoload.model.v3.project.scenario.@Valid LoadDuration value) {
if (this.duration == value) return this;
return new ImmutableConstantLoadPolicy(this.users, this.rampup, value, this.startAfter, this.stopAfter);
}
/**
* Copy the current immutable object by setting a value for the {@link ConstantLoadPolicy#getStartAfter() startAfter} 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 startAfter (can be {@code null})
* @return A modified copy of the {@code this} object
*/
public final ImmutableConstantLoadPolicy withStartAfter(com.neotys.neoload.model.v3.project.scenario.@Valid StartAfter value) {
if (this.startAfter == value) return this;
return new ImmutableConstantLoadPolicy(this.users, this.rampup, this.duration, value, this.stopAfter);
}
/**
* Copy the current immutable object by setting a value for the {@link ConstantLoadPolicy#getStopAfter() stopAfter} 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 stopAfter (can be {@code null})
* @return A modified copy of the {@code this} object
*/
public final ImmutableConstantLoadPolicy withStopAfter(com.neotys.neoload.model.v3.project.scenario.@Valid StopAfter value) {
if (this.stopAfter == value) return this;
return new ImmutableConstantLoadPolicy(this.users, this.rampup, this.duration, this.startAfter, value);
}
/**
* This instance is equal to all instances of {@code ImmutableConstantLoadPolicy} 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 ImmutableConstantLoadPolicy
&& equalTo((ImmutableConstantLoadPolicy) another);
}
private boolean equalTo(ImmutableConstantLoadPolicy another) {
return users == another.users
&& Objects.equals(rampup, another.rampup)
&& Objects.equals(duration, another.duration)
&& Objects.equals(startAfter, another.startAfter)
&& Objects.equals(stopAfter, another.stopAfter);
}
/**
* Computes a hash code from attributes: {@code users}, {@code rampup}, {@code duration}, {@code startAfter}, {@code stopAfter}.
* @return hashCode value
*/
@Override
public int hashCode() {
int h = 5381;
h += (h << 5) + users;
h += (h << 5) + Objects.hashCode(rampup);
h += (h << 5) + Objects.hashCode(duration);
h += (h << 5) + Objects.hashCode(startAfter);
h += (h << 5) + Objects.hashCode(stopAfter);
return h;
}
/**
* Prints the immutable value {@code ConstantLoadPolicy} with attribute values.
* @return A string representation of the value
*/
@Override
public String toString() {
return MoreObjects.toStringHelper("ConstantLoadPolicy")
.omitNullValues()
.add("users", users)
.add("rampup", rampup)
.add("duration", duration)
.add("startAfter", startAfter)
.add("stopAfter", stopAfter)
.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 ConstantLoadPolicy {
int users;
boolean usersIsSet;
@Nullable Integer rampup;
@Nullable com.neotys.neoload.model.v3.project.scenario.@Valid LoadDuration duration;
@Nullable com.neotys.neoload.model.v3.project.scenario.@Valid StartAfter startAfter;
@Nullable com.neotys.neoload.model.v3.project.scenario.@Valid StopAfter stopAfter;
@JsonProperty("users")
public void setUsers(int users) {
this.users = users;
this.usersIsSet = true;
}
@JsonProperty("rampup")
public void setRampup(Integer rampup) {
this.rampup = rampup;
}
@JsonProperty("duration")
public void setDuration(com.neotys.neoload.model.v3.project.scenario.@Valid LoadDuration duration) {
this.duration = duration;
}
@JsonProperty("start_after")
public void setStartAfter(com.neotys.neoload.model.v3.project.scenario.@Valid StartAfter startAfter) {
this.startAfter = startAfter;
}
@JsonProperty("stop_after")
public void setStopAfter(com.neotys.neoload.model.v3.project.scenario.@Valid StopAfter stopAfter) {
this.stopAfter = stopAfter;
}
@Override
public int getUsers() { throw new UnsupportedOperationException(); }
@Override
public Integer getRampup() { throw new UnsupportedOperationException(); }
@Override
public com.neotys.neoload.model.v3.project.scenario.@Valid LoadDuration getDuration() { throw new UnsupportedOperationException(); }
@Override
public com.neotys.neoload.model.v3.project.scenario.@Valid StartAfter getStartAfter() { throw new UnsupportedOperationException(); }
@Override
public com.neotys.neoload.model.v3.project.scenario.@Valid StopAfter getStopAfter() { 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 ImmutableConstantLoadPolicy fromJson(Json json) {
ConstantLoadPolicy.Builder builder = new ConstantLoadPolicy.Builder();
if (json.usersIsSet) {
builder.users(json.users);
}
if (json.rampup != null) {
builder.rampup(json.rampup);
}
if (json.duration != null) {
builder.duration(json.duration);
}
if (json.startAfter != null) {
builder.startAfter(json.startAfter);
}
if (json.stopAfter != null) {
builder.stopAfter(json.stopAfter);
}
return (ImmutableConstantLoadPolicy) builder.build();
}
/**
* Creates an immutable copy of a {@link ConstantLoadPolicy} 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 ConstantLoadPolicy instance
*/
public static ImmutableConstantLoadPolicy copyOf(ConstantLoadPolicy instance) {
if (instance instanceof ImmutableConstantLoadPolicy) {
return (ImmutableConstantLoadPolicy) instance;
}
return new ConstantLoadPolicy.Builder()
.from(instance)
.build();
}
/**
* Builds instances of type {@link ImmutableConstantLoadPolicy ImmutableConstantLoadPolicy}.
* 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 int users;
private @Nullable Integer rampup;
private @Nullable com.neotys.neoload.model.v3.project.scenario.@Valid LoadDuration duration;
private @Nullable com.neotys.neoload.model.v3.project.scenario.@Valid StartAfter startAfter;
private @Nullable com.neotys.neoload.model.v3.project.scenario.@Valid StopAfter stopAfter;
/**
* Creates a builder for {@link ImmutableConstantLoadPolicy ImmutableConstantLoadPolicy} instances.
*/
public Builder() {
if (!(this instanceof ConstantLoadPolicy.Builder)) {
throw new UnsupportedOperationException("Use: new ConstantLoadPolicy.Builder()");
}
}
/**
* Fill a builder with attribute values from the provided {@code com.neotys.neoload.model.v3.project.scenario.StartStopPolicy} instance.
* @param instance The instance from which to copy values
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final ConstantLoadPolicy.Builder from(StartStopPolicy instance) {
Objects.requireNonNull(instance, "instance");
from((Object) instance);
return (ConstantLoadPolicy.Builder) this;
}
/**
* Fill a builder with attribute values from the provided {@code com.neotys.neoload.model.v3.project.scenario.ConstantLoadPolicy} instance.
* @param instance The instance from which to copy values
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final ConstantLoadPolicy.Builder from(ConstantLoadPolicy instance) {
Objects.requireNonNull(instance, "instance");
from((Object) instance);
return (ConstantLoadPolicy.Builder) this;
}
/**
* Fill a builder with attribute values from the provided {@code com.neotys.neoload.model.v3.project.scenario.DurationPolicy} instance.
* @param instance The instance from which to copy values
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final ConstantLoadPolicy.Builder from(DurationPolicy instance) {
Objects.requireNonNull(instance, "instance");
from((Object) instance);
return (ConstantLoadPolicy.Builder) this;
}
private void from(Object object) {
long bits = 0;
if (object instanceof StartStopPolicy) {
StartStopPolicy instance = (StartStopPolicy) object;
com.neotys.neoload.model.v3.project.scenario.@Valid StartAfter startAfterValue = instance.getStartAfter();
if (startAfterValue != null) {
startAfter(startAfterValue);
}
com.neotys.neoload.model.v3.project.scenario.@Valid StopAfter stopAfterValue = instance.getStopAfter();
if (stopAfterValue != null) {
stopAfter(stopAfterValue);
}
if ((bits & 0x1L) == 0) {
Integer rampupValue = instance.getRampup();
if (rampupValue != null) {
rampup(rampupValue);
}
bits |= 0x1L;
}
}
if (object instanceof ConstantLoadPolicy) {
ConstantLoadPolicy instance = (ConstantLoadPolicy) object;
users(instance.getUsers());
if ((bits & 0x1L) == 0) {
Integer rampupValue = instance.getRampup();
if (rampupValue != null) {
rampup(rampupValue);
}
bits |= 0x1L;
}
}
if (object instanceof DurationPolicy) {
DurationPolicy instance = (DurationPolicy) object;
com.neotys.neoload.model.v3.project.scenario.@Valid LoadDuration durationValue = instance.getDuration();
if (durationValue != null) {
duration(durationValue);
}
}
}
/**
* Initializes the value for the {@link ConstantLoadPolicy#getUsers() users} attribute.
* @param users The value for users
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("users")
public final ConstantLoadPolicy.Builder users(int users) {
this.users = users;
return (ConstantLoadPolicy.Builder) this;
}
/**
* Initializes the value for the {@link ConstantLoadPolicy#getRampup() rampup} attribute.
* @param rampup The value for rampup (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("rampup")
public final ConstantLoadPolicy.Builder rampup(Integer rampup) {
this.rampup = rampup;
return (ConstantLoadPolicy.Builder) this;
}
/**
* Initializes the value for the {@link ConstantLoadPolicy#getDuration() duration} attribute.
* @param duration The value for duration (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("duration")
public final ConstantLoadPolicy.Builder duration(com.neotys.neoload.model.v3.project.scenario.@Valid LoadDuration duration) {
this.duration = duration;
return (ConstantLoadPolicy.Builder) this;
}
/**
* Initializes the value for the {@link ConstantLoadPolicy#getStartAfter() startAfter} attribute.
* @param startAfter The value for startAfter (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("start_after")
public final ConstantLoadPolicy.Builder startAfter(com.neotys.neoload.model.v3.project.scenario.@Valid StartAfter startAfter) {
this.startAfter = startAfter;
return (ConstantLoadPolicy.Builder) this;
}
/**
* Initializes the value for the {@link ConstantLoadPolicy#getStopAfter() stopAfter} attribute.
* @param stopAfter The value for stopAfter (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("stop_after")
public final ConstantLoadPolicy.Builder stopAfter(com.neotys.neoload.model.v3.project.scenario.@Valid StopAfter stopAfter) {
this.stopAfter = stopAfter;
return (ConstantLoadPolicy.Builder) this;
}
/**
* Builds a new {@link ImmutableConstantLoadPolicy ImmutableConstantLoadPolicy}.
* @return An immutable instance of ConstantLoadPolicy
* @throws java.lang.IllegalStateException if any required attributes are missing
*/
public ImmutableConstantLoadPolicy build() {
return new ImmutableConstantLoadPolicy(users, rampup, duration, startAfter, stopAfter);
}
}
}