com.neotys.neoload.model.scenario.ImmutablePeaksLoadPolicy Maven / Gradle / Ivy
package com.neotys.neoload.model.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.google.errorprone.annotations.Var;
import java.util.Objects;
import javax.annotation.CheckReturnValue;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import javax.annotation.concurrent.Immutable;
import javax.annotation.concurrent.NotThreadSafe;
import org.immutables.value.Generated;
/**
* Immutable implementation of {@link PeaksLoadPolicy}.
*
* Use the builder to create immutable instances:
* {@code new PeaksLoadPolicy.Builder()}.
*/
@Generated(from = "PeaksLoadPolicy", generator = "Immutables")
@SuppressWarnings({"all"})
@ParametersAreNonnullByDefault
@javax.annotation.processing.Generated("org.immutables.processor.ProxyProcessor")
@Deprecated
@Immutable
@CheckReturnValue
public final class ImmutablePeaksLoadPolicy implements PeaksLoadPolicy {
private final Duration duration;
private final StartAfter startAfter;
private final StopAfter stopAfter;
private final PeakLoadPolicy minimum;
private final PeakLoadPolicy maximum;
private final PeaksLoadPolicy.Peak start;
private final Integer rampup;
private ImmutablePeaksLoadPolicy(
Duration duration,
StartAfter startAfter,
StopAfter stopAfter,
PeakLoadPolicy minimum,
PeakLoadPolicy maximum,
PeaksLoadPolicy.Peak start,
Integer rampup) {
this.duration = duration;
this.startAfter = startAfter;
this.stopAfter = stopAfter;
this.minimum = minimum;
this.maximum = maximum;
this.start = start;
this.rampup = rampup;
}
/**
* @return The value of the {@code duration} attribute
*/
@JsonProperty("duration")
@Override
public Duration getDuration() {
return duration;
}
/**
* @return The value of the {@code startAfter} attribute
*/
@JsonProperty("start_after")
@Override
public StartAfter getStartAfter() {
return startAfter;
}
/**
* @return The value of the {@code stopAfter} attribute
*/
@JsonProperty("stop_after")
@Override
public StopAfter getStopAfter() {
return stopAfter;
}
/**
* @return The value of the {@code minimum} attribute
*/
@JsonProperty("minimum")
@Override
public PeakLoadPolicy getMinimum() {
return minimum;
}
/**
* @return The value of the {@code maximum} attribute
*/
@JsonProperty("maximum")
@Override
public PeakLoadPolicy getMaximum() {
return maximum;
}
/**
* @return The value of the {@code start} attribute
*/
@JsonProperty("start")
@Override
public PeaksLoadPolicy.Peak getStart() {
return start;
}
/**
* @return The value of the {@code rampup} attribute
*/
@JsonProperty("step_rampup")
@Override
public Integer getRampup() {
return rampup;
}
/**
* Copy the current immutable object by setting a value for the {@link PeaksLoadPolicy#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 ImmutablePeaksLoadPolicy withDuration(Duration value) {
if (this.duration == value) return this;
return new ImmutablePeaksLoadPolicy(value, this.startAfter, this.stopAfter, this.minimum, this.maximum, this.start, this.rampup);
}
/**
* Copy the current immutable object by setting a value for the {@link PeaksLoadPolicy#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 ImmutablePeaksLoadPolicy withStartAfter(StartAfter value) {
if (this.startAfter == value) return this;
return new ImmutablePeaksLoadPolicy(this.duration, value, this.stopAfter, this.minimum, this.maximum, this.start, this.rampup);
}
/**
* Copy the current immutable object by setting a value for the {@link PeaksLoadPolicy#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 ImmutablePeaksLoadPolicy withStopAfter(StopAfter value) {
if (this.stopAfter == value) return this;
return new ImmutablePeaksLoadPolicy(this.duration, this.startAfter, value, this.minimum, this.maximum, this.start, this.rampup);
}
/**
* Copy the current immutable object by setting a value for the {@link PeaksLoadPolicy#getMinimum() minimum} 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 minimum (can be {@code null})
* @return A modified copy of the {@code this} object
*/
public final ImmutablePeaksLoadPolicy withMinimum(PeakLoadPolicy value) {
if (this.minimum == value) return this;
return new ImmutablePeaksLoadPolicy(this.duration, this.startAfter, this.stopAfter, value, this.maximum, this.start, this.rampup);
}
/**
* Copy the current immutable object by setting a value for the {@link PeaksLoadPolicy#getMaximum() maximum} 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 maximum (can be {@code null})
* @return A modified copy of the {@code this} object
*/
public final ImmutablePeaksLoadPolicy withMaximum(PeakLoadPolicy value) {
if (this.maximum == value) return this;
return new ImmutablePeaksLoadPolicy(this.duration, this.startAfter, this.stopAfter, this.minimum, value, this.start, this.rampup);
}
/**
* Copy the current immutable object by setting a value for the {@link PeaksLoadPolicy#getStart() start} attribute.
* A value equality check is used to prevent copying of the same value by returning {@code this}.
* @param value A new value for start (can be {@code null})
* @return A modified copy of the {@code this} object
*/
public final ImmutablePeaksLoadPolicy withStart(PeaksLoadPolicy.Peak value) {
if (this.start == value) return this;
return new ImmutablePeaksLoadPolicy(this.duration, this.startAfter, this.stopAfter, this.minimum, this.maximum, value, this.rampup);
}
/**
* Copy the current immutable object by setting a value for the {@link PeaksLoadPolicy#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 ImmutablePeaksLoadPolicy withRampup(Integer value) {
if (Objects.equals(this.rampup, value)) return this;
return new ImmutablePeaksLoadPolicy(this.duration, this.startAfter, this.stopAfter, this.minimum, this.maximum, this.start, value);
}
/**
* This instance is equal to all instances of {@code ImmutablePeaksLoadPolicy} 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 ImmutablePeaksLoadPolicy
&& equalTo(0, (ImmutablePeaksLoadPolicy) another);
}
private boolean equalTo(int synthetic, ImmutablePeaksLoadPolicy another) {
return Objects.equals(duration, another.duration)
&& Objects.equals(startAfter, another.startAfter)
&& Objects.equals(stopAfter, another.stopAfter)
&& Objects.equals(minimum, another.minimum)
&& Objects.equals(maximum, another.maximum)
&& Objects.equals(start, another.start)
&& Objects.equals(rampup, another.rampup);
}
/**
* Computes a hash code from attributes: {@code duration}, {@code startAfter}, {@code stopAfter}, {@code minimum}, {@code maximum}, {@code start}, {@code rampup}.
* @return hashCode value
*/
@Override
public int hashCode() {
@Var int h = 5381;
h += (h << 5) + Objects.hashCode(duration);
h += (h << 5) + Objects.hashCode(startAfter);
h += (h << 5) + Objects.hashCode(stopAfter);
h += (h << 5) + Objects.hashCode(minimum);
h += (h << 5) + Objects.hashCode(maximum);
h += (h << 5) + Objects.hashCode(start);
h += (h << 5) + Objects.hashCode(rampup);
return h;
}
/**
* Prints the immutable value {@code PeaksLoadPolicy} with attribute values.
* @return A string representation of the value
*/
@Override
public String toString() {
return MoreObjects.toStringHelper("PeaksLoadPolicy")
.omitNullValues()
.add("duration", duration)
.add("startAfter", startAfter)
.add("stopAfter", stopAfter)
.add("minimum", minimum)
.add("maximum", maximum)
.add("start", start)
.add("rampup", rampup)
.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
*/
@Generated(from = "PeaksLoadPolicy", generator = "Immutables")
@Deprecated
@SuppressWarnings("Immutable")
@JsonDeserialize
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE)
static final class Json implements PeaksLoadPolicy {
@Nullable Duration duration;
@Nullable StartAfter startAfter;
@Nullable StopAfter stopAfter;
@Nullable PeakLoadPolicy minimum;
@Nullable PeakLoadPolicy maximum;
@Nullable PeaksLoadPolicy.Peak start;
@Nullable Integer rampup;
@JsonProperty("duration")
public void setDuration(Duration duration) {
this.duration = duration;
}
@JsonProperty("start_after")
public void setStartAfter(StartAfter startAfter) {
this.startAfter = startAfter;
}
@JsonProperty("stop_after")
public void setStopAfter(StopAfter stopAfter) {
this.stopAfter = stopAfter;
}
@JsonProperty("minimum")
public void setMinimum(PeakLoadPolicy minimum) {
this.minimum = minimum;
}
@JsonProperty("maximum")
public void setMaximum(PeakLoadPolicy maximum) {
this.maximum = maximum;
}
@JsonProperty("start")
public void setStart(PeaksLoadPolicy.Peak start) {
this.start = start;
}
@JsonProperty("step_rampup")
public void setRampup(Integer rampup) {
this.rampup = rampup;
}
@Override
public Duration getDuration() { throw new UnsupportedOperationException(); }
@Override
public StartAfter getStartAfter() { throw new UnsupportedOperationException(); }
@Override
public StopAfter getStopAfter() { throw new UnsupportedOperationException(); }
@Override
public PeakLoadPolicy getMinimum() { throw new UnsupportedOperationException(); }
@Override
public PeakLoadPolicy getMaximum() { throw new UnsupportedOperationException(); }
@Override
public PeaksLoadPolicy.Peak getStart() { throw new UnsupportedOperationException(); }
@Override
public Integer getRampup() { 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 ImmutablePeaksLoadPolicy fromJson(Json json) {
PeaksLoadPolicy.Builder builder = new PeaksLoadPolicy.Builder();
if (json.duration != null) {
builder.duration(json.duration);
}
if (json.startAfter != null) {
builder.startAfter(json.startAfter);
}
if (json.stopAfter != null) {
builder.stopAfter(json.stopAfter);
}
if (json.minimum != null) {
builder.minimum(json.minimum);
}
if (json.maximum != null) {
builder.maximum(json.maximum);
}
if (json.start != null) {
builder.start(json.start);
}
if (json.rampup != null) {
builder.rampup(json.rampup);
}
return (ImmutablePeaksLoadPolicy) builder.build();
}
/**
* Creates an immutable copy of a {@link PeaksLoadPolicy} 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 PeaksLoadPolicy instance
*/
public static ImmutablePeaksLoadPolicy copyOf(PeaksLoadPolicy instance) {
if (instance instanceof ImmutablePeaksLoadPolicy) {
return (ImmutablePeaksLoadPolicy) instance;
}
return new PeaksLoadPolicy.Builder()
.from(instance)
.build();
}
/**
* Builds instances of type {@link ImmutablePeaksLoadPolicy ImmutablePeaksLoadPolicy}.
* 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.
*/
@Generated(from = "PeaksLoadPolicy", generator = "Immutables")
@NotThreadSafe
public static class Builder {
private @Nullable Duration duration;
private @Nullable StartAfter startAfter;
private @Nullable StopAfter stopAfter;
private @Nullable PeakLoadPolicy minimum;
private @Nullable PeakLoadPolicy maximum;
private @Nullable PeaksLoadPolicy.Peak start;
private @Nullable Integer rampup;
/**
* Creates a builder for {@link ImmutablePeaksLoadPolicy ImmutablePeaksLoadPolicy} instances.
*
* new PeaksLoadPolicy.Builder()
* .duration(com.neotys.neoload.model.scenario.Duration | null) // nullable {@link PeaksLoadPolicy#getDuration() duration}
* .startAfter(com.neotys.neoload.model.scenario.StartAfter | null) // nullable {@link PeaksLoadPolicy#getStartAfter() startAfter}
* .stopAfter(com.neotys.neoload.model.scenario.StopAfter | null) // nullable {@link PeaksLoadPolicy#getStopAfter() stopAfter}
* .minimum(com.neotys.neoload.model.scenario.PeakLoadPolicy | null) // nullable {@link PeaksLoadPolicy#getMinimum() minimum}
* .maximum(com.neotys.neoload.model.scenario.PeakLoadPolicy | null) // nullable {@link PeaksLoadPolicy#getMaximum() maximum}
* .start(com.neotys.neoload.model.scenario.PeaksLoadPolicy.Peak | null) // nullable {@link PeaksLoadPolicy#getStart() start}
* .rampup(Integer | null) // nullable {@link PeaksLoadPolicy#getRampup() rampup}
* .build();
*
*/
public Builder() {
if (!(this instanceof PeaksLoadPolicy.Builder)) {
throw new UnsupportedOperationException("Use: new PeaksLoadPolicy.Builder()");
}
}
/**
* Fill a builder with attribute values from the provided {@code com.neotys.neoload.model.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 PeaksLoadPolicy.Builder from(StartStopPolicy instance) {
Objects.requireNonNull(instance, "instance");
from((Object) instance);
return (PeaksLoadPolicy.Builder) this;
}
/**
* Fill a builder with attribute values from the provided {@code com.neotys.neoload.model.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 PeaksLoadPolicy.Builder from(DurationPolicy instance) {
Objects.requireNonNull(instance, "instance");
from((Object) instance);
return (PeaksLoadPolicy.Builder) this;
}
/**
* Fill a builder with attribute values from the provided {@code com.neotys.neoload.model.scenario.LoadPolicy} instance.
* @param instance The instance from which to copy values
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final PeaksLoadPolicy.Builder from(LoadPolicy instance) {
Objects.requireNonNull(instance, "instance");
from((Object) instance);
return (PeaksLoadPolicy.Builder) this;
}
/**
* Fill a builder with attribute values from the provided {@code com.neotys.neoload.model.scenario.PeaksLoadPolicy} instance.
* @param instance The instance from which to copy values
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final PeaksLoadPolicy.Builder from(PeaksLoadPolicy instance) {
Objects.requireNonNull(instance, "instance");
from((Object) instance);
return (PeaksLoadPolicy.Builder) this;
}
private void from(Object object) {
@Var long bits = 0;
if (object instanceof StartStopPolicy) {
StartStopPolicy instance = (StartStopPolicy) object;
if ((bits & 0x2L) == 0) {
StartAfter startAfterValue = instance.getStartAfter();
if (startAfterValue != null) {
startAfter(startAfterValue);
}
bits |= 0x2L;
}
if ((bits & 0x4L) == 0) {
StopAfter stopAfterValue = instance.getStopAfter();
if (stopAfterValue != null) {
stopAfter(stopAfterValue);
}
bits |= 0x4L;
}
if ((bits & 0x8L) == 0) {
Integer rampupValue = instance.getRampup();
if (rampupValue != null) {
rampup(rampupValue);
}
bits |= 0x8L;
}
}
if (object instanceof DurationPolicy) {
DurationPolicy instance = (DurationPolicy) object;
if ((bits & 0x1L) == 0) {
Duration durationValue = instance.getDuration();
if (durationValue != null) {
duration(durationValue);
}
bits |= 0x1L;
}
}
if (object instanceof LoadPolicy) {
LoadPolicy instance = (LoadPolicy) object;
if ((bits & 0x1L) == 0) {
Duration durationValue = instance.getDuration();
if (durationValue != null) {
duration(durationValue);
}
bits |= 0x1L;
}
if ((bits & 0x2L) == 0) {
StartAfter startAfterValue = instance.getStartAfter();
if (startAfterValue != null) {
startAfter(startAfterValue);
}
bits |= 0x2L;
}
if ((bits & 0x4L) == 0) {
StopAfter stopAfterValue = instance.getStopAfter();
if (stopAfterValue != null) {
stopAfter(stopAfterValue);
}
bits |= 0x4L;
}
if ((bits & 0x8L) == 0) {
Integer rampupValue = instance.getRampup();
if (rampupValue != null) {
rampup(rampupValue);
}
bits |= 0x8L;
}
}
if (object instanceof PeaksLoadPolicy) {
PeaksLoadPolicy instance = (PeaksLoadPolicy) object;
if ((bits & 0x1L) == 0) {
Duration durationValue = instance.getDuration();
if (durationValue != null) {
duration(durationValue);
}
bits |= 0x1L;
}
if ((bits & 0x2L) == 0) {
StartAfter startAfterValue = instance.getStartAfter();
if (startAfterValue != null) {
startAfter(startAfterValue);
}
bits |= 0x2L;
}
if ((bits & 0x4L) == 0) {
StopAfter stopAfterValue = instance.getStopAfter();
if (stopAfterValue != null) {
stopAfter(stopAfterValue);
}
bits |= 0x4L;
}
PeaksLoadPolicy.Peak startValue = instance.getStart();
if (startValue != null) {
start(startValue);
}
PeakLoadPolicy maximumValue = instance.getMaximum();
if (maximumValue != null) {
maximum(maximumValue);
}
PeakLoadPolicy minimumValue = instance.getMinimum();
if (minimumValue != null) {
minimum(minimumValue);
}
if ((bits & 0x8L) == 0) {
Integer rampupValue = instance.getRampup();
if (rampupValue != null) {
rampup(rampupValue);
}
bits |= 0x8L;
}
}
}
/**
* Initializes the value for the {@link PeaksLoadPolicy#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 PeaksLoadPolicy.Builder duration(Duration duration) {
this.duration = duration;
return (PeaksLoadPolicy.Builder) this;
}
/**
* Initializes the value for the {@link PeaksLoadPolicy#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 PeaksLoadPolicy.Builder startAfter(StartAfter startAfter) {
this.startAfter = startAfter;
return (PeaksLoadPolicy.Builder) this;
}
/**
* Initializes the value for the {@link PeaksLoadPolicy#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 PeaksLoadPolicy.Builder stopAfter(StopAfter stopAfter) {
this.stopAfter = stopAfter;
return (PeaksLoadPolicy.Builder) this;
}
/**
* Initializes the value for the {@link PeaksLoadPolicy#getMinimum() minimum} attribute.
* @param minimum The value for minimum (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("minimum")
public final PeaksLoadPolicy.Builder minimum(PeakLoadPolicy minimum) {
this.minimum = minimum;
return (PeaksLoadPolicy.Builder) this;
}
/**
* Initializes the value for the {@link PeaksLoadPolicy#getMaximum() maximum} attribute.
* @param maximum The value for maximum (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("maximum")
public final PeaksLoadPolicy.Builder maximum(PeakLoadPolicy maximum) {
this.maximum = maximum;
return (PeaksLoadPolicy.Builder) this;
}
/**
* Initializes the value for the {@link PeaksLoadPolicy#getStart() start} attribute.
* @param start The value for start (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("start")
public final PeaksLoadPolicy.Builder start(PeaksLoadPolicy.Peak start) {
this.start = start;
return (PeaksLoadPolicy.Builder) this;
}
/**
* Initializes the value for the {@link PeaksLoadPolicy#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("step_rampup")
public final PeaksLoadPolicy.Builder rampup(Integer rampup) {
this.rampup = rampup;
return (PeaksLoadPolicy.Builder) this;
}
/**
* Builds a new {@link ImmutablePeaksLoadPolicy ImmutablePeaksLoadPolicy}.
* @return An immutable instance of PeaksLoadPolicy
* @throws java.lang.IllegalStateException if any required attributes are missing
*/
public ImmutablePeaksLoadPolicy build() {
return new ImmutablePeaksLoadPolicy(duration, startAfter, stopAfter, minimum, maximum, start, rampup);
}
}
}