com.neotys.neoload.model.v3.project.scenario.ImmutableMonitoringParameters 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.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.StringToTimeDurationConverter;
import com.neotys.neoload.model.v3.binding.converter.TimeDurationToStringConverter;
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 MonitoringParameters}.
*
* Use the builder to create immutable instances:
* {@code ImmutableMonitoringParameters.builder()}.
*/
@SuppressWarnings({"all"})
@ParametersAreNonnullByDefault
@Generated({"Immutables.generator", "MonitoringParameters"})
@Immutable
@CheckReturnValue
public final class ImmutableMonitoringParameters
implements MonitoringParameters {
private final Integer beforeFirstVu;
private final Integer afterLastVus;
private ImmutableMonitoringParameters(Integer beforeFirstVu, Integer afterLastVus) {
this.beforeFirstVu = beforeFirstVu;
this.afterLastVus = afterLastVus;
}
/**
* @return The value of the {@code beforeFirstVu} attribute
*/
@JsonProperty("before")
@JsonSerialize(converter = TimeDurationToStringConverter.class)
@JsonDeserialize(converter = StringToTimeDurationConverter.class)
@Override
public Integer getBeforeFirstVu() {
return beforeFirstVu;
}
/**
* @return The value of the {@code afterLastVus} attribute
*/
@JsonProperty("after")
@JsonSerialize(converter = TimeDurationToStringConverter.class)
@JsonDeserialize(converter = StringToTimeDurationConverter.class)
@Override
public Integer getAfterLastVus() {
return afterLastVus;
}
/**
* Copy the current immutable object by setting a value for the {@link MonitoringParameters#getBeforeFirstVu() beforeFirstVu} attribute.
* An equals check used to prevent copying of the same value by returning {@code this}.
* @param value A new value for beforeFirstVu (can be {@code null})
* @return A modified copy of the {@code this} object
*/
public final ImmutableMonitoringParameters withBeforeFirstVu(Integer value) {
if (Objects.equals(this.beforeFirstVu, value)) return this;
return new ImmutableMonitoringParameters(value, this.afterLastVus);
}
/**
* Copy the current immutable object by setting a value for the {@link MonitoringParameters#getAfterLastVus() afterLastVus} attribute.
* An equals check used to prevent copying of the same value by returning {@code this}.
* @param value A new value for afterLastVus (can be {@code null})
* @return A modified copy of the {@code this} object
*/
public final ImmutableMonitoringParameters withAfterLastVus(Integer value) {
if (Objects.equals(this.afterLastVus, value)) return this;
return new ImmutableMonitoringParameters(this.beforeFirstVu, value);
}
/**
* This instance is equal to all instances of {@code ImmutableMonitoringParameters} 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 ImmutableMonitoringParameters
&& equalTo((ImmutableMonitoringParameters) another);
}
private boolean equalTo(ImmutableMonitoringParameters another) {
return Objects.equals(beforeFirstVu, another.beforeFirstVu)
&& Objects.equals(afterLastVus, another.afterLastVus);
}
/**
* Computes a hash code from attributes: {@code beforeFirstVu}, {@code afterLastVus}.
* @return hashCode value
*/
@Override
public int hashCode() {
int h = 5381;
h += (h << 5) + Objects.hashCode(beforeFirstVu);
h += (h << 5) + Objects.hashCode(afterLastVus);
return h;
}
/**
* Prints the immutable value {@code MonitoringParameters} with attribute values.
* @return A string representation of the value
*/
@Override
public String toString() {
return MoreObjects.toStringHelper("MonitoringParameters")
.omitNullValues()
.add("beforeFirstVu", beforeFirstVu)
.add("afterLastVus", afterLastVus)
.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 MonitoringParameters {
@Nullable Integer beforeFirstVu;
@Nullable Integer afterLastVus;
@JsonProperty("before")
@JsonSerialize(converter = TimeDurationToStringConverter.class)
@JsonDeserialize(converter = StringToTimeDurationConverter.class)
public void setBeforeFirstVu(Integer beforeFirstVu) {
this.beforeFirstVu = beforeFirstVu;
}
@JsonProperty("after")
@JsonSerialize(converter = TimeDurationToStringConverter.class)
@JsonDeserialize(converter = StringToTimeDurationConverter.class)
public void setAfterLastVus(Integer afterLastVus) {
this.afterLastVus = afterLastVus;
}
@Override
public Integer getBeforeFirstVu() { throw new UnsupportedOperationException(); }
@Override
public Integer getAfterLastVus() { 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 ImmutableMonitoringParameters fromJson(Json json) {
ImmutableMonitoringParameters.Builder builder = ImmutableMonitoringParameters.builder();
if (json.beforeFirstVu != null) {
builder.beforeFirstVu(json.beforeFirstVu);
}
if (json.afterLastVus != null) {
builder.afterLastVus(json.afterLastVus);
}
return builder.build();
}
/**
* Creates an immutable copy of a {@link MonitoringParameters} 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 MonitoringParameters instance
*/
public static ImmutableMonitoringParameters copyOf(MonitoringParameters instance) {
if (instance instanceof ImmutableMonitoringParameters) {
return (ImmutableMonitoringParameters) instance;
}
return ImmutableMonitoringParameters.builder()
.from(instance)
.build();
}
/**
* Creates a builder for {@link ImmutableMonitoringParameters ImmutableMonitoringParameters}.
* @return A new ImmutableMonitoringParameters builder
*/
public static ImmutableMonitoringParameters.Builder builder() {
return new ImmutableMonitoringParameters.Builder();
}
/**
* Builds instances of type {@link ImmutableMonitoringParameters ImmutableMonitoringParameters}.
* 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 final class Builder {
private @Nullable Integer beforeFirstVu;
private @Nullable Integer afterLastVus;
private Builder() {
}
/**
* Fill a builder with attribute values from the provided {@code MonitoringParameters} 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 Builder from(MonitoringParameters instance) {
Objects.requireNonNull(instance, "instance");
Integer beforeFirstVuValue = instance.getBeforeFirstVu();
if (beforeFirstVuValue != null) {
beforeFirstVu(beforeFirstVuValue);
}
Integer afterLastVusValue = instance.getAfterLastVus();
if (afterLastVusValue != null) {
afterLastVus(afterLastVusValue);
}
return this;
}
/**
* Initializes the value for the {@link MonitoringParameters#getBeforeFirstVu() beforeFirstVu} attribute.
* @param beforeFirstVu The value for beforeFirstVu (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("before")
@JsonSerialize(converter = TimeDurationToStringConverter.class)
@JsonDeserialize(converter = StringToTimeDurationConverter.class)
public final Builder beforeFirstVu(Integer beforeFirstVu) {
this.beforeFirstVu = beforeFirstVu;
return this;
}
/**
* Initializes the value for the {@link MonitoringParameters#getAfterLastVus() afterLastVus} attribute.
* @param afterLastVus The value for afterLastVus (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("after")
@JsonSerialize(converter = TimeDurationToStringConverter.class)
@JsonDeserialize(converter = StringToTimeDurationConverter.class)
public final Builder afterLastVus(Integer afterLastVus) {
this.afterLastVus = afterLastVus;
return this;
}
/**
* Builds a new {@link ImmutableMonitoringParameters ImmutableMonitoringParameters}.
* @return An immutable instance of MonitoringParameters
* @throws java.lang.IllegalStateException if any required attributes are missing
*/
public ImmutableMonitoringParameters build() {
return new ImmutableMonitoringParameters(beforeFirstVu, afterLastVus);
}
}
}