All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.glowroot.central.repo.ImmutableRollupParams Maven / Gradle / Ivy

There is a newer version: 0.14.0-beta.3
Show newest version
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.common.collect.Lists;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.util.List;
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 AggregateDaoImpl.RollupParams}.
 * 

* Use the builder to create immutable instances: * {@code ImmutableRollupParams.builder()}. */ @SuppressWarnings({"all"}) @ParametersAreNonnullByDefault @Generated({"Immutables.generator", "AggregateDaoImpl.RollupParams"}) @Immutable @CheckReturnValue final class ImmutableRollupParams implements AggregateDaoImpl.RollupParams { private final String agentRollupId; private final int rollupLevel; private final AggregateDaoImpl.TTL adjustedTTL; private final int maxAggregateQueriesPerType; private final int maxAggregateServiceCallsPerType; private ImmutableRollupParams( String agentRollupId, int rollupLevel, AggregateDaoImpl.TTL adjustedTTL, int maxAggregateQueriesPerType, int maxAggregateServiceCallsPerType) { this.agentRollupId = agentRollupId; this.rollupLevel = rollupLevel; this.adjustedTTL = adjustedTTL; this.maxAggregateQueriesPerType = maxAggregateQueriesPerType; this.maxAggregateServiceCallsPerType = maxAggregateServiceCallsPerType; } /** * @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 maxAggregateQueriesPerType} attribute */ @JsonProperty("maxAggregateQueriesPerType") @Override public int maxAggregateQueriesPerType() { return maxAggregateQueriesPerType; } /** * @return The value of the {@code maxAggregateServiceCallsPerType} attribute */ @JsonProperty("maxAggregateServiceCallsPerType") @Override public int maxAggregateServiceCallsPerType() { return maxAggregateServiceCallsPerType; } /** * 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) { if (this.agentRollupId.equals(value)) return this; String newValue = Objects.requireNonNull(value, "agentRollupId"); return new ImmutableRollupParams( newValue, this.rollupLevel, this.adjustedTTL, this.maxAggregateQueriesPerType, this.maxAggregateServiceCallsPerType); } /** * 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.maxAggregateQueriesPerType, this.maxAggregateServiceCallsPerType); } /** * 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.maxAggregateQueriesPerType, this.maxAggregateServiceCallsPerType); } /** * Copy the current immutable object by setting a value for the {@link AggregateDaoImpl.RollupParams#maxAggregateQueriesPerType() maxAggregateQueriesPerType} attribute. * A value equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for maxAggregateQueriesPerType * @return A modified copy of the {@code this} object */ public final ImmutableRollupParams withMaxAggregateQueriesPerType(int value) { if (this.maxAggregateQueriesPerType == value) return this; return new ImmutableRollupParams( this.agentRollupId, this.rollupLevel, this.adjustedTTL, value, this.maxAggregateServiceCallsPerType); } /** * Copy the current immutable object by setting a value for the {@link AggregateDaoImpl.RollupParams#maxAggregateServiceCallsPerType() maxAggregateServiceCallsPerType} attribute. * A value equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for maxAggregateServiceCallsPerType * @return A modified copy of the {@code this} object */ public final ImmutableRollupParams withMaxAggregateServiceCallsPerType(int value) { if (this.maxAggregateServiceCallsPerType == value) return this; return new ImmutableRollupParams(this.agentRollupId, this.rollupLevel, this.adjustedTTL, this.maxAggregateQueriesPerType, 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) && maxAggregateQueriesPerType == another.maxAggregateQueriesPerType && maxAggregateServiceCallsPerType == another.maxAggregateServiceCallsPerType; } /** * Computes a hash code from attributes: {@code agentRollupId}, {@code rollupLevel}, {@code adjustedTTL}, {@code maxAggregateQueriesPerType}, {@code maxAggregateServiceCallsPerType}. * @return hashCode value */ @Override public int hashCode() { int h = 5381; h += (h << 5) + agentRollupId.hashCode(); h += (h << 5) + rollupLevel; h += (h << 5) + adjustedTTL.hashCode(); h += (h << 5) + maxAggregateQueriesPerType; h += (h << 5) + maxAggregateServiceCallsPerType; 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("maxAggregateQueriesPerType", maxAggregateQueriesPerType) .add("maxAggregateServiceCallsPerType", maxAggregateServiceCallsPerType) .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 @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE) static final class Json implements AggregateDaoImpl.RollupParams { @Nullable String agentRollupId; int rollupLevel; boolean rollupLevelIsSet; @Nullable AggregateDaoImpl.TTL adjustedTTL; int maxAggregateQueriesPerType; boolean maxAggregateQueriesPerTypeIsSet; int maxAggregateServiceCallsPerType; boolean maxAggregateServiceCallsPerTypeIsSet; @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("maxAggregateQueriesPerType") public void setMaxAggregateQueriesPerType(int maxAggregateQueriesPerType) { this.maxAggregateQueriesPerType = maxAggregateQueriesPerType; this.maxAggregateQueriesPerTypeIsSet = true; } @JsonProperty("maxAggregateServiceCallsPerType") public void setMaxAggregateServiceCallsPerType(int maxAggregateServiceCallsPerType) { this.maxAggregateServiceCallsPerType = maxAggregateServiceCallsPerType; this.maxAggregateServiceCallsPerTypeIsSet = 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 maxAggregateQueriesPerType() { throw new UnsupportedOperationException(); } @Override public int maxAggregateServiceCallsPerType() { 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.maxAggregateQueriesPerTypeIsSet) { builder.maxAggregateQueriesPerType(json.maxAggregateQueriesPerType); } if (json.maxAggregateServiceCallsPerTypeIsSet) { builder.maxAggregateServiceCallsPerType(json.maxAggregateServiceCallsPerType); } 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}. * @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. */ @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_AGGREGATE_QUERIES_PER_TYPE = 0x8L; private static final long INIT_BIT_MAX_AGGREGATE_SERVICE_CALLS_PER_TYPE = 0x10L; private long initBits = 0x1fL; private @Nullable String agentRollupId; private int rollupLevel; private @Nullable AggregateDaoImpl.TTL adjustedTTL; private int maxAggregateQueriesPerType; private int maxAggregateServiceCallsPerType; 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()); maxAggregateQueriesPerType(instance.maxAggregateQueriesPerType()); maxAggregateServiceCallsPerType(instance.maxAggregateServiceCallsPerType()); 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#maxAggregateQueriesPerType() maxAggregateQueriesPerType} attribute. * @param maxAggregateQueriesPerType The value for maxAggregateQueriesPerType * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder maxAggregateQueriesPerType(int maxAggregateQueriesPerType) { this.maxAggregateQueriesPerType = maxAggregateQueriesPerType; initBits &= ~INIT_BIT_MAX_AGGREGATE_QUERIES_PER_TYPE; return this; } /** * Initializes the value for the {@link AggregateDaoImpl.RollupParams#maxAggregateServiceCallsPerType() maxAggregateServiceCallsPerType} attribute. * @param maxAggregateServiceCallsPerType The value for maxAggregateServiceCallsPerType * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder maxAggregateServiceCallsPerType(int maxAggregateServiceCallsPerType) { this.maxAggregateServiceCallsPerType = maxAggregateServiceCallsPerType; initBits &= ~INIT_BIT_MAX_AGGREGATE_SERVICE_CALLS_PER_TYPE; 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, maxAggregateQueriesPerType, maxAggregateServiceCallsPerType); } private String formatRequiredAttributesMessage() { List attributes = Lists.newArrayList(); 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_AGGREGATE_QUERIES_PER_TYPE) != 0) attributes.add("maxAggregateQueriesPerType"); if ((initBits & INIT_BIT_MAX_AGGREGATE_SERVICE_CALLS_PER_TYPE) != 0) attributes.add("maxAggregateServiceCallsPerType"); return "Cannot build RollupParams, some of required attributes are not set " + attributes; } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy