com.neotys.neoload.model.v3.project.scenario.ImmutableDynatraceAnomalyRule 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;
/**
* Immutable implementation of {@link DynatraceAnomalyRule}.
*
* Use the builder to create immutable instances:
* {@code new DynatraceAnomalyRule.Builder()}.
*/
@SuppressWarnings({"all"})
@ParametersAreNonnullByDefault
@Generated({"Immutables.generator", "DynatraceAnomalyRule"})
@Immutable
@CheckReturnValue
public final class ImmutableDynatraceAnomalyRule
implements DynatraceAnomalyRule {
private final String metricId;
private final String operator;
private final String value;
private final String severity;
private ImmutableDynatraceAnomalyRule(
String metricId,
String operator,
String value,
String severity) {
this.metricId = metricId;
this.operator = operator;
this.value = value;
this.severity = severity;
}
/**
* @return The value of the {@code metricId} attribute
*/
@JsonProperty("metric_id")
@Override
public String getMetricId() {
return metricId;
}
/**
* @return The value of the {@code operator} attribute
*/
@JsonProperty("operator")
@Override
public String getOperator() {
return operator;
}
/**
* @return The value of the {@code value} attribute
*/
@JsonProperty("value")
@Override
public String getValue() {
return value;
}
/**
* @return The value of the {@code severity} attribute
*/
@JsonProperty("severity")
@Override
public String getSeverity() {
return severity;
}
/**
* Copy the current immutable object by setting a value for the {@link DynatraceAnomalyRule#getMetricId() metricId} attribute.
* An equals check used to prevent copying of the same value by returning {@code this}.
* @param value A new value for metricId (can be {@code null})
* @return A modified copy of the {@code this} object
*/
public final ImmutableDynatraceAnomalyRule withMetricId(String value) {
if (Objects.equals(this.metricId, value)) return this;
return new ImmutableDynatraceAnomalyRule(value, this.operator, this.value, this.severity);
}
/**
* Copy the current immutable object by setting a value for the {@link DynatraceAnomalyRule#getOperator() operator} attribute.
* An equals check used to prevent copying of the same value by returning {@code this}.
* @param value A new value for operator (can be {@code null})
* @return A modified copy of the {@code this} object
*/
public final ImmutableDynatraceAnomalyRule withOperator(String value) {
if (Objects.equals(this.operator, value)) return this;
return new ImmutableDynatraceAnomalyRule(this.metricId, value, this.value, this.severity);
}
/**
* Copy the current immutable object by setting a value for the {@link DynatraceAnomalyRule#getValue() value} attribute.
* An equals check used to prevent copying of the same value by returning {@code this}.
* @param value A new value for value (can be {@code null})
* @return A modified copy of the {@code this} object
*/
public final ImmutableDynatraceAnomalyRule withValue(String value) {
if (Objects.equals(this.value, value)) return this;
return new ImmutableDynatraceAnomalyRule(this.metricId, this.operator, value, this.severity);
}
/**
* Copy the current immutable object by setting a value for the {@link DynatraceAnomalyRule#getSeverity() severity} attribute.
* An equals check used to prevent copying of the same value by returning {@code this}.
* @param value A new value for severity (can be {@code null})
* @return A modified copy of the {@code this} object
*/
public final ImmutableDynatraceAnomalyRule withSeverity(String value) {
if (Objects.equals(this.severity, value)) return this;
return new ImmutableDynatraceAnomalyRule(this.metricId, this.operator, this.value, value);
}
/**
* This instance is equal to all instances of {@code ImmutableDynatraceAnomalyRule} 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 ImmutableDynatraceAnomalyRule
&& equalTo((ImmutableDynatraceAnomalyRule) another);
}
private boolean equalTo(ImmutableDynatraceAnomalyRule another) {
return Objects.equals(metricId, another.metricId)
&& Objects.equals(operator, another.operator)
&& Objects.equals(value, another.value)
&& Objects.equals(severity, another.severity);
}
/**
* Computes a hash code from attributes: {@code metricId}, {@code operator}, {@code value}, {@code severity}.
* @return hashCode value
*/
@Override
public int hashCode() {
int h = 5381;
h += (h << 5) + Objects.hashCode(metricId);
h += (h << 5) + Objects.hashCode(operator);
h += (h << 5) + Objects.hashCode(value);
h += (h << 5) + Objects.hashCode(severity);
return h;
}
/**
* Prints the immutable value {@code DynatraceAnomalyRule} with attribute values.
* @return A string representation of the value
*/
@Override
public String toString() {
return MoreObjects.toStringHelper("DynatraceAnomalyRule")
.omitNullValues()
.add("metricId", metricId)
.add("operator", operator)
.add("value", value)
.add("severity", severity)
.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 DynatraceAnomalyRule {
@Nullable String metricId;
@Nullable String operator;
@Nullable String value;
@Nullable String severity;
@JsonProperty("metric_id")
public void setMetricId(String metricId) {
this.metricId = metricId;
}
@JsonProperty("operator")
public void setOperator(String operator) {
this.operator = operator;
}
@JsonProperty("value")
public void setValue(String value) {
this.value = value;
}
@JsonProperty("severity")
public void setSeverity(String severity) {
this.severity = severity;
}
@Override
public String getMetricId() { throw new UnsupportedOperationException(); }
@Override
public String getOperator() { throw new UnsupportedOperationException(); }
@Override
public String getValue() { throw new UnsupportedOperationException(); }
@Override
public String getSeverity() { 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 ImmutableDynatraceAnomalyRule fromJson(Json json) {
DynatraceAnomalyRule.Builder builder = new DynatraceAnomalyRule.Builder();
if (json.metricId != null) {
builder.metricId(json.metricId);
}
if (json.operator != null) {
builder.operator(json.operator);
}
if (json.value != null) {
builder.value(json.value);
}
if (json.severity != null) {
builder.severity(json.severity);
}
return (ImmutableDynatraceAnomalyRule) builder.build();
}
/**
* Creates an immutable copy of a {@link DynatraceAnomalyRule} 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 DynatraceAnomalyRule instance
*/
public static ImmutableDynatraceAnomalyRule copyOf(DynatraceAnomalyRule instance) {
if (instance instanceof ImmutableDynatraceAnomalyRule) {
return (ImmutableDynatraceAnomalyRule) instance;
}
return new DynatraceAnomalyRule.Builder()
.from(instance)
.build();
}
/**
* Builds instances of type {@link ImmutableDynatraceAnomalyRule ImmutableDynatraceAnomalyRule}.
* 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 String metricId;
private @Nullable String operator;
private @Nullable String value;
private @Nullable String severity;
/**
* Creates a builder for {@link ImmutableDynatraceAnomalyRule ImmutableDynatraceAnomalyRule} instances.
*/
public Builder() {
if (!(this instanceof DynatraceAnomalyRule.Builder)) {
throw new UnsupportedOperationException("Use: new DynatraceAnomalyRule.Builder()");
}
}
/**
* Fill a builder with attribute values from the provided {@code DynatraceAnomalyRule} 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 DynatraceAnomalyRule.Builder from(DynatraceAnomalyRule instance) {
Objects.requireNonNull(instance, "instance");
String metricIdValue = instance.getMetricId();
if (metricIdValue != null) {
metricId(metricIdValue);
}
String operatorValue = instance.getOperator();
if (operatorValue != null) {
operator(operatorValue);
}
String valueValue = instance.getValue();
if (valueValue != null) {
value(valueValue);
}
String severityValue = instance.getSeverity();
if (severityValue != null) {
severity(severityValue);
}
return (DynatraceAnomalyRule.Builder) this;
}
/**
* Initializes the value for the {@link DynatraceAnomalyRule#getMetricId() metricId} attribute.
* @param metricId The value for metricId (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("metric_id")
public final DynatraceAnomalyRule.Builder metricId(String metricId) {
this.metricId = metricId;
return (DynatraceAnomalyRule.Builder) this;
}
/**
* Initializes the value for the {@link DynatraceAnomalyRule#getOperator() operator} attribute.
* @param operator The value for operator (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("operator")
public final DynatraceAnomalyRule.Builder operator(String operator) {
this.operator = operator;
return (DynatraceAnomalyRule.Builder) this;
}
/**
* Initializes the value for the {@link DynatraceAnomalyRule#getValue() value} attribute.
* @param value The value for value (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("value")
public final DynatraceAnomalyRule.Builder value(String value) {
this.value = value;
return (DynatraceAnomalyRule.Builder) this;
}
/**
* Initializes the value for the {@link DynatraceAnomalyRule#getSeverity() severity} attribute.
* @param severity The value for severity (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("severity")
public final DynatraceAnomalyRule.Builder severity(String severity) {
this.severity = severity;
return (DynatraceAnomalyRule.Builder) this;
}
/**
* Builds a new {@link ImmutableDynatraceAnomalyRule ImmutableDynatraceAnomalyRule}.
* @return An immutable instance of DynatraceAnomalyRule
* @throws java.lang.IllegalStateException if any required attributes are missing
*/
public ImmutableDynatraceAnomalyRule build() {
return new ImmutableDynatraceAnomalyRule(metricId, operator, value, severity);
}
}
}