org.glowroot.central.repo.ImmutableRollupParams Maven / Gradle / Ivy
package org.glowroot.central.repo;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.base.MoreObjects;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.errorprone.annotations.Var;
import java.util.ArrayList;
import java.util.List;
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 AggregateDaoImpl.RollupParams}.
*
* Use the builder to create immutable instances:
* {@code ImmutableRollupParams.builder()}.
*/
@Generated(from = "AggregateDaoImpl.RollupParams", generator = "Immutables")
@SuppressWarnings({"all"})
@ParametersAreNonnullByDefault
@javax.annotation.Generated("org.immutables.processor.ProxyProcessor")
@Immutable
@CheckReturnValue
final class ImmutableRollupParams implements AggregateDaoImpl.RollupParams {
private final String agentRollupId;
private final int rollupLevel;
private final AggregateDaoImpl.TTL adjustedTTL;
private final int maxQueryAggregatesPerTransactionAggregate;
private final int maxServiceCallAggregatesPerTransactionAggregate;
private ImmutableRollupParams(
String agentRollupId,
int rollupLevel,
AggregateDaoImpl.TTL adjustedTTL,
int maxQueryAggregatesPerTransactionAggregate,
int maxServiceCallAggregatesPerTransactionAggregate) {
this.agentRollupId = agentRollupId;
this.rollupLevel = rollupLevel;
this.adjustedTTL = adjustedTTL;
this.maxQueryAggregatesPerTransactionAggregate = maxQueryAggregatesPerTransactionAggregate;
this.maxServiceCallAggregatesPerTransactionAggregate = maxServiceCallAggregatesPerTransactionAggregate;
}
/**
* @return The value of the {@code agentRollupId} attribute
*/
@JsonProperty("agentRollupId")
@Override
public String agentRollupId() {
return agentRollupId;
}
/**
* @return The value of the {@code rollupLevel} attribute
*/
@JsonProperty("rollupLevel")
@Override
public int rollupLevel() {
return rollupLevel;
}
/**
* @return The value of the {@code adjustedTTL} attribute
*/
@JsonProperty("adjustedTTL")
@Override
public AggregateDaoImpl.TTL adjustedTTL() {
return adjustedTTL;
}
/**
* @return The value of the {@code maxQueryAggregatesPerTransactionAggregate} attribute
*/
@JsonProperty("maxQueryAggregatesPerTransactionAggregate")
@Override
public int maxQueryAggregatesPerTransactionAggregate() {
return maxQueryAggregatesPerTransactionAggregate;
}
/**
* @return The value of the {@code maxServiceCallAggregatesPerTransactionAggregate} attribute
*/
@JsonProperty("maxServiceCallAggregatesPerTransactionAggregate")
@Override
public int maxServiceCallAggregatesPerTransactionAggregate() {
return maxServiceCallAggregatesPerTransactionAggregate;
}
/**
* Copy the current immutable object by setting a value for the {@link AggregateDaoImpl.RollupParams#agentRollupId() agentRollupId} attribute.
* An equals check used to prevent copying of the same value by returning {@code this}.
* @param value A new value for agentRollupId
* @return A modified copy of the {@code this} object
*/
public final ImmutableRollupParams withAgentRollupId(String value) {
String newValue = Objects.requireNonNull(value, "agentRollupId");
if (this.agentRollupId.equals(newValue)) return this;
return new ImmutableRollupParams(
newValue,
this.rollupLevel,
this.adjustedTTL,
this.maxQueryAggregatesPerTransactionAggregate,
this.maxServiceCallAggregatesPerTransactionAggregate);
}
/**
* Copy the current immutable object by setting a value for the {@link AggregateDaoImpl.RollupParams#rollupLevel() rollupLevel} attribute.
* A value equality check is used to prevent copying of the same value by returning {@code this}.
* @param value A new value for rollupLevel
* @return A modified copy of the {@code this} object
*/
public final ImmutableRollupParams withRollupLevel(int value) {
if (this.rollupLevel == value) return this;
return new ImmutableRollupParams(
this.agentRollupId,
value,
this.adjustedTTL,
this.maxQueryAggregatesPerTransactionAggregate,
this.maxServiceCallAggregatesPerTransactionAggregate);
}
/**
* Copy the current immutable object by setting a value for the {@link AggregateDaoImpl.RollupParams#adjustedTTL() adjustedTTL} 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 adjustedTTL
* @return A modified copy of the {@code this} object
*/
public final ImmutableRollupParams withAdjustedTTL(AggregateDaoImpl.TTL value) {
if (this.adjustedTTL == value) return this;
AggregateDaoImpl.TTL newValue = Objects.requireNonNull(value, "adjustedTTL");
return new ImmutableRollupParams(
this.agentRollupId,
this.rollupLevel,
newValue,
this.maxQueryAggregatesPerTransactionAggregate,
this.maxServiceCallAggregatesPerTransactionAggregate);
}
/**
* Copy the current immutable object by setting a value for the {@link AggregateDaoImpl.RollupParams#maxQueryAggregatesPerTransactionAggregate() maxQueryAggregatesPerTransactionAggregate} attribute.
* A value equality check is used to prevent copying of the same value by returning {@code this}.
* @param value A new value for maxQueryAggregatesPerTransactionAggregate
* @return A modified copy of the {@code this} object
*/
public final ImmutableRollupParams withMaxQueryAggregatesPerTransactionAggregate(int value) {
if (this.maxQueryAggregatesPerTransactionAggregate == value) return this;
return new ImmutableRollupParams(
this.agentRollupId,
this.rollupLevel,
this.adjustedTTL,
value,
this.maxServiceCallAggregatesPerTransactionAggregate);
}
/**
* Copy the current immutable object by setting a value for the {@link AggregateDaoImpl.RollupParams#maxServiceCallAggregatesPerTransactionAggregate() maxServiceCallAggregatesPerTransactionAggregate} attribute.
* A value equality check is used to prevent copying of the same value by returning {@code this}.
* @param value A new value for maxServiceCallAggregatesPerTransactionAggregate
* @return A modified copy of the {@code this} object
*/
public final ImmutableRollupParams withMaxServiceCallAggregatesPerTransactionAggregate(int value) {
if (this.maxServiceCallAggregatesPerTransactionAggregate == value) return this;
return new ImmutableRollupParams(
this.agentRollupId,
this.rollupLevel,
this.adjustedTTL,
this.maxQueryAggregatesPerTransactionAggregate,
value);
}
/**
* This instance is equal to all instances of {@code ImmutableRollupParams} 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 ImmutableRollupParams
&& equalTo((ImmutableRollupParams) another);
}
private boolean equalTo(ImmutableRollupParams another) {
return agentRollupId.equals(another.agentRollupId)
&& rollupLevel == another.rollupLevel
&& adjustedTTL.equals(another.adjustedTTL)
&& maxQueryAggregatesPerTransactionAggregate == another.maxQueryAggregatesPerTransactionAggregate
&& maxServiceCallAggregatesPerTransactionAggregate == another.maxServiceCallAggregatesPerTransactionAggregate;
}
/**
* Computes a hash code from attributes: {@code agentRollupId}, {@code rollupLevel}, {@code adjustedTTL}, {@code maxQueryAggregatesPerTransactionAggregate}, {@code maxServiceCallAggregatesPerTransactionAggregate}.
* @return hashCode value
*/
@Override
public int hashCode() {
@Var int h = 5381;
h += (h << 5) + agentRollupId.hashCode();
h += (h << 5) + rollupLevel;
h += (h << 5) + adjustedTTL.hashCode();
h += (h << 5) + maxQueryAggregatesPerTransactionAggregate;
h += (h << 5) + maxServiceCallAggregatesPerTransactionAggregate;
return h;
}
/**
* Prints the immutable value {@code RollupParams} with attribute values.
* @return A string representation of the value
*/
@Override
public String toString() {
return MoreObjects.toStringHelper("RollupParams")
.omitNullValues()
.add("agentRollupId", agentRollupId)
.add("rollupLevel", rollupLevel)
.add("adjustedTTL", adjustedTTL)
.add("maxQueryAggregatesPerTransactionAggregate", maxQueryAggregatesPerTransactionAggregate)
.add("maxServiceCallAggregatesPerTransactionAggregate", maxServiceCallAggregatesPerTransactionAggregate)
.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 = "AggregateDaoImpl.RollupParams", generator = "Immutables")
@Deprecated
@SuppressWarnings("Immutable")
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE)
static final class Json implements AggregateDaoImpl.RollupParams {
@Nullable String agentRollupId;
int rollupLevel;
boolean rollupLevelIsSet;
@Nullable AggregateDaoImpl.TTL adjustedTTL;
int maxQueryAggregatesPerTransactionAggregate;
boolean maxQueryAggregatesPerTransactionAggregateIsSet;
int maxServiceCallAggregatesPerTransactionAggregate;
boolean maxServiceCallAggregatesPerTransactionAggregateIsSet;
@JsonProperty("agentRollupId")
public void setAgentRollupId(String agentRollupId) {
this.agentRollupId = agentRollupId;
}
@JsonProperty("rollupLevel")
public void setRollupLevel(int rollupLevel) {
this.rollupLevel = rollupLevel;
this.rollupLevelIsSet = true;
}
@JsonProperty("adjustedTTL")
public void setAdjustedTTL(AggregateDaoImpl.TTL adjustedTTL) {
this.adjustedTTL = adjustedTTL;
}
@JsonProperty("maxQueryAggregatesPerTransactionAggregate")
public void setMaxQueryAggregatesPerTransactionAggregate(int maxQueryAggregatesPerTransactionAggregate) {
this.maxQueryAggregatesPerTransactionAggregate = maxQueryAggregatesPerTransactionAggregate;
this.maxQueryAggregatesPerTransactionAggregateIsSet = true;
}
@JsonProperty("maxServiceCallAggregatesPerTransactionAggregate")
public void setMaxServiceCallAggregatesPerTransactionAggregate(int maxServiceCallAggregatesPerTransactionAggregate) {
this.maxServiceCallAggregatesPerTransactionAggregate = maxServiceCallAggregatesPerTransactionAggregate;
this.maxServiceCallAggregatesPerTransactionAggregateIsSet = true;
}
@Override
public String agentRollupId() { throw new UnsupportedOperationException(); }
@Override
public int rollupLevel() { throw new UnsupportedOperationException(); }
@Override
public AggregateDaoImpl.TTL adjustedTTL() { throw new UnsupportedOperationException(); }
@Override
public int maxQueryAggregatesPerTransactionAggregate() { throw new UnsupportedOperationException(); }
@Override
public int maxServiceCallAggregatesPerTransactionAggregate() { 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 ImmutableRollupParams fromJson(Json json) {
ImmutableRollupParams.Builder builder = ImmutableRollupParams.builder();
if (json.agentRollupId != null) {
builder.agentRollupId(json.agentRollupId);
}
if (json.rollupLevelIsSet) {
builder.rollupLevel(json.rollupLevel);
}
if (json.adjustedTTL != null) {
builder.adjustedTTL(json.adjustedTTL);
}
if (json.maxQueryAggregatesPerTransactionAggregateIsSet) {
builder.maxQueryAggregatesPerTransactionAggregate(json.maxQueryAggregatesPerTransactionAggregate);
}
if (json.maxServiceCallAggregatesPerTransactionAggregateIsSet) {
builder.maxServiceCallAggregatesPerTransactionAggregate(json.maxServiceCallAggregatesPerTransactionAggregate);
}
return builder.build();
}
/**
* Creates an immutable copy of a {@link AggregateDaoImpl.RollupParams} 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 RollupParams instance
*/
public static ImmutableRollupParams copyOf(AggregateDaoImpl.RollupParams instance) {
if (instance instanceof ImmutableRollupParams) {
return (ImmutableRollupParams) instance;
}
return ImmutableRollupParams.builder()
.copyFrom(instance)
.build();
}
/**
* Creates a builder for {@link ImmutableRollupParams ImmutableRollupParams}.
*
* ImmutableRollupParams.builder()
* .agentRollupId(String) // required {@link AggregateDaoImpl.RollupParams#agentRollupId() agentRollupId}
* .rollupLevel(int) // required {@link AggregateDaoImpl.RollupParams#rollupLevel() rollupLevel}
* .adjustedTTL(org.glowroot.central.repo.AggregateDaoImpl.TTL) // required {@link AggregateDaoImpl.RollupParams#adjustedTTL() adjustedTTL}
* .maxQueryAggregatesPerTransactionAggregate(int) // required {@link AggregateDaoImpl.RollupParams#maxQueryAggregatesPerTransactionAggregate() maxQueryAggregatesPerTransactionAggregate}
* .maxServiceCallAggregatesPerTransactionAggregate(int) // required {@link AggregateDaoImpl.RollupParams#maxServiceCallAggregatesPerTransactionAggregate() maxServiceCallAggregatesPerTransactionAggregate}
* .build();
*
* @return A new ImmutableRollupParams builder
*/
public static ImmutableRollupParams.Builder builder() {
return new ImmutableRollupParams.Builder();
}
/**
* Builds instances of type {@link ImmutableRollupParams ImmutableRollupParams}.
* 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 = "AggregateDaoImpl.RollupParams", generator = "Immutables")
@NotThreadSafe
public static final class Builder {
private static final long INIT_BIT_AGENT_ROLLUP_ID = 0x1L;
private static final long INIT_BIT_ROLLUP_LEVEL = 0x2L;
private static final long INIT_BIT_ADJUSTED_T_T_L = 0x4L;
private static final long INIT_BIT_MAX_QUERY_AGGREGATES_PER_TRANSACTION_AGGREGATE = 0x8L;
private static final long INIT_BIT_MAX_SERVICE_CALL_AGGREGATES_PER_TRANSACTION_AGGREGATE = 0x10L;
private long initBits = 0x1fL;
private @Nullable String agentRollupId;
private int rollupLevel;
private @Nullable AggregateDaoImpl.TTL adjustedTTL;
private int maxQueryAggregatesPerTransactionAggregate;
private int maxServiceCallAggregatesPerTransactionAggregate;
private Builder() {
}
/**
* Fill a builder with attribute values from the provided {@code RollupParams} 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 copyFrom(AggregateDaoImpl.RollupParams instance) {
Objects.requireNonNull(instance, "instance");
agentRollupId(instance.agentRollupId());
rollupLevel(instance.rollupLevel());
adjustedTTL(instance.adjustedTTL());
maxQueryAggregatesPerTransactionAggregate(instance.maxQueryAggregatesPerTransactionAggregate());
maxServiceCallAggregatesPerTransactionAggregate(instance.maxServiceCallAggregatesPerTransactionAggregate());
return this;
}
/**
* Initializes the value for the {@link AggregateDaoImpl.RollupParams#agentRollupId() agentRollupId} attribute.
* @param agentRollupId The value for agentRollupId
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder agentRollupId(String agentRollupId) {
this.agentRollupId = Objects.requireNonNull(agentRollupId, "agentRollupId");
initBits &= ~INIT_BIT_AGENT_ROLLUP_ID;
return this;
}
/**
* Initializes the value for the {@link AggregateDaoImpl.RollupParams#rollupLevel() rollupLevel} attribute.
* @param rollupLevel The value for rollupLevel
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder rollupLevel(int rollupLevel) {
this.rollupLevel = rollupLevel;
initBits &= ~INIT_BIT_ROLLUP_LEVEL;
return this;
}
/**
* Initializes the value for the {@link AggregateDaoImpl.RollupParams#adjustedTTL() adjustedTTL} attribute.
* @param adjustedTTL The value for adjustedTTL
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder adjustedTTL(AggregateDaoImpl.TTL adjustedTTL) {
this.adjustedTTL = Objects.requireNonNull(adjustedTTL, "adjustedTTL");
initBits &= ~INIT_BIT_ADJUSTED_T_T_L;
return this;
}
/**
* Initializes the value for the {@link AggregateDaoImpl.RollupParams#maxQueryAggregatesPerTransactionAggregate() maxQueryAggregatesPerTransactionAggregate} attribute.
* @param maxQueryAggregatesPerTransactionAggregate The value for maxQueryAggregatesPerTransactionAggregate
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder maxQueryAggregatesPerTransactionAggregate(int maxQueryAggregatesPerTransactionAggregate) {
this.maxQueryAggregatesPerTransactionAggregate = maxQueryAggregatesPerTransactionAggregate;
initBits &= ~INIT_BIT_MAX_QUERY_AGGREGATES_PER_TRANSACTION_AGGREGATE;
return this;
}
/**
* Initializes the value for the {@link AggregateDaoImpl.RollupParams#maxServiceCallAggregatesPerTransactionAggregate() maxServiceCallAggregatesPerTransactionAggregate} attribute.
* @param maxServiceCallAggregatesPerTransactionAggregate The value for maxServiceCallAggregatesPerTransactionAggregate
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder maxServiceCallAggregatesPerTransactionAggregate(int maxServiceCallAggregatesPerTransactionAggregate) {
this.maxServiceCallAggregatesPerTransactionAggregate = maxServiceCallAggregatesPerTransactionAggregate;
initBits &= ~INIT_BIT_MAX_SERVICE_CALL_AGGREGATES_PER_TRANSACTION_AGGREGATE;
return this;
}
/**
* Builds a new {@link ImmutableRollupParams ImmutableRollupParams}.
* @return An immutable instance of RollupParams
* @throws java.lang.IllegalStateException if any required attributes are missing
*/
public ImmutableRollupParams build() {
if (initBits != 0) {
throw new IllegalStateException(formatRequiredAttributesMessage());
}
return new ImmutableRollupParams(
agentRollupId,
rollupLevel,
adjustedTTL,
maxQueryAggregatesPerTransactionAggregate,
maxServiceCallAggregatesPerTransactionAggregate);
}
private String formatRequiredAttributesMessage() {
List attributes = new ArrayList<>();
if ((initBits & INIT_BIT_AGENT_ROLLUP_ID) != 0) attributes.add("agentRollupId");
if ((initBits & INIT_BIT_ROLLUP_LEVEL) != 0) attributes.add("rollupLevel");
if ((initBits & INIT_BIT_ADJUSTED_T_T_L) != 0) attributes.add("adjustedTTL");
if ((initBits & INIT_BIT_MAX_QUERY_AGGREGATES_PER_TRANSACTION_AGGREGATE) != 0) attributes.add("maxQueryAggregatesPerTransactionAggregate");
if ((initBits & INIT_BIT_MAX_SERVICE_CALL_AGGREGATES_PER_TRANSACTION_AGGREGATE) != 0) attributes.add("maxServiceCallAggregatesPerTransactionAggregate");
return "Cannot build RollupParams, some of required attributes are not set " + attributes;
}
}
}