org.glowroot.agent.impl.ImmutableSlowThresholdOverridesForUser Maven / Gradle / Ivy
Show all versions of glowroot-agent-it-harness Show documentation
package org.glowroot.agent.impl;
import org.glowroot.agent.shaded.com.fasterxml.jackson.annotation.JsonAutoDetect;
import org.glowroot.agent.shaded.com.fasterxml.jackson.annotation.JsonCreator;
import org.glowroot.agent.shaded.com.fasterxml.jackson.annotation.JsonProperty;
import org.glowroot.agent.shaded.org.glowroot.agent.it.harness.shaded.com.google.common.base.MoreObjects;
import org.glowroot.agent.shaded.org.glowroot.agent.it.harness.shaded.com.google.common.base.Objects;
import org.glowroot.agent.shaded.org.glowroot.agent.it.harness.shaded.com.google.common.base.Preconditions;
import org.glowroot.agent.shaded.org.glowroot.agent.it.harness.shaded.com.google.common.collect.ImmutableMap;
import org.glowroot.agent.shaded.org.glowroot.agent.shaded.org.glowroot.agent.it.harness.shaded.com.google.errorprone.annotations.CanIgnoreReturnValue;
import org.glowroot.agent.shaded.org.glowroot.agent.shaded.org.glowroot.agent.it.harness.shaded.com.google.errorprone.annotations.Var;
import java.util.Map;
import org.glowroot.agent.shaded.org.glowroot.agent.it.harness.shaded.javax.annotation.CheckReturnValue;
import org.glowroot.agent.shaded.org.glowroot.agent.it.harness.shaded.javax.annotation.ParametersAreNonnullByDefault;
import org.glowroot.agent.shaded.org.glowroot.agent.it.harness.shaded.javax.annotation.concurrent.Immutable;
import org.glowroot.agent.shaded.org.glowroot.agent.it.harness.shaded.javax.annotation.concurrent.NotThreadSafe;
import org.glowroot.agent.shaded.org.checkerframework.checker.nullness.qual.Nullable;
import org.immutables.value.Generated;
/**
* Immutable implementation of {@link TraceCollector.SlowThresholdOverridesForUser}.
*
* Use the builder to create immutable instances:
* {@code ImmutableSlowThresholdOverridesForUser.builder()}.
*/
@Generated(from = "TraceCollector.SlowThresholdOverridesForUser", generator = "Immutables")
@SuppressWarnings({"all"})
@ParametersAreNonnullByDefault
@org.glowroot.agent.shaded.org.glowroot.agent.it.harness.shaded.javax.annotation.Generated("org.immutables.processor.ProxyProcessor")
@Immutable
@CheckReturnValue
final class ImmutableSlowThresholdOverridesForUser
implements TraceCollector.SlowThresholdOverridesForUser {
private final @Nullable Long defaultThresholdNanos;
private final ImmutableMap thresholdNanos;
private ImmutableSlowThresholdOverridesForUser(
@Nullable Long defaultThresholdNanos,
ImmutableMap thresholdNanos) {
this.defaultThresholdNanos = defaultThresholdNanos;
this.thresholdNanos = thresholdNanos;
}
/**
* @return The value of the {@code defaultThresholdNanos} attribute
*/
@JsonProperty("defaultThresholdNanos")
@Override
public @Nullable Long defaultThresholdNanos() {
return defaultThresholdNanos;
}
/**
* @return The value of the {@code thresholdNanos} attribute
*/
@JsonProperty("thresholdNanos")
@Override
public ImmutableMap thresholdNanos() {
return thresholdNanos;
}
/**
* Copy the current immutable object by setting a value for the {@link TraceCollector.SlowThresholdOverridesForUser#defaultThresholdNanos() defaultThresholdNanos} attribute.
* An equals check used to prevent copying of the same value by returning {@code this}.
* @param value A new value for defaultThresholdNanos (can be {@code null})
* @return A modified copy of the {@code this} object
*/
public final ImmutableSlowThresholdOverridesForUser withDefaultThresholdNanos(@Nullable Long value) {
if (Objects.equal(this.defaultThresholdNanos, value)) return this;
return new ImmutableSlowThresholdOverridesForUser(value, this.thresholdNanos);
}
/**
* Copy the current immutable object by replacing the {@link TraceCollector.SlowThresholdOverridesForUser#thresholdNanos() thresholdNanos} map with the specified map.
* Nulls are not permitted as keys or values.
* A shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param entries The entries to be added to the thresholdNanos map
* @return A modified copy of {@code this} object
*/
public final ImmutableSlowThresholdOverridesForUser withThresholdNanos(Map entries) {
if (this.thresholdNanos == entries) return this;
ImmutableMap newValue = ImmutableMap.copyOf(entries);
return new ImmutableSlowThresholdOverridesForUser(this.defaultThresholdNanos, newValue);
}
/**
* This instance is equal to all instances of {@code ImmutableSlowThresholdOverridesForUser} that have equal attribute values.
* @return {@code true} if {@code this} is equal to {@code another} instance
*/
@Override
public boolean equals(@org.glowroot.agent.shaded.org.glowroot.agent.it.harness.shaded.javax.annotation.Nullable Object another) {
if (this == another) return true;
return another instanceof ImmutableSlowThresholdOverridesForUser
&& equalTo((ImmutableSlowThresholdOverridesForUser) another);
}
private boolean equalTo(ImmutableSlowThresholdOverridesForUser another) {
return Objects.equal(defaultThresholdNanos, another.defaultThresholdNanos)
&& thresholdNanos.equals(another.thresholdNanos);
}
/**
* Computes a hash code from attributes: {@code defaultThresholdNanos}, {@code thresholdNanos}.
* @return hashCode value
*/
@Override
public int hashCode() {
@Var int h = 5381;
h += (h << 5) + Objects.hashCode(defaultThresholdNanos);
h += (h << 5) + thresholdNanos.hashCode();
return h;
}
/**
* Prints the immutable value {@code SlowThresholdOverridesForUser} with attribute values.
* @return A string representation of the value
*/
@Override
public String toString() {
return MoreObjects.toStringHelper("SlowThresholdOverridesForUser")
.omitNullValues()
.add("defaultThresholdNanos", defaultThresholdNanos)
.add("thresholdNanos", thresholdNanos)
.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 = "TraceCollector.SlowThresholdOverridesForUser", generator = "Immutables")
@Deprecated
@SuppressWarnings("Immutable")
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE)
static final class Json implements TraceCollector.SlowThresholdOverridesForUser {
@org.glowroot.agent.shaded.org.glowroot.agent.it.harness.shaded.javax.annotation.Nullable Long defaultThresholdNanos;
@org.glowroot.agent.shaded.org.glowroot.agent.it.harness.shaded.javax.annotation.Nullable Map thresholdNanos = ImmutableMap.of();
@JsonProperty("defaultThresholdNanos")
public void setDefaultThresholdNanos(@Nullable Long defaultThresholdNanos) {
this.defaultThresholdNanos = defaultThresholdNanos;
}
@JsonProperty("thresholdNanos")
public void setThresholdNanos(Map thresholdNanos) {
this.thresholdNanos = thresholdNanos;
}
@Override
public Long defaultThresholdNanos() { throw new UnsupportedOperationException(); }
@Override
public Map thresholdNanos() { 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 ImmutableSlowThresholdOverridesForUser fromJson(Json json) {
ImmutableSlowThresholdOverridesForUser.Builder builder = ImmutableSlowThresholdOverridesForUser.builder();
if (json.defaultThresholdNanos != null) {
builder.defaultThresholdNanos(json.defaultThresholdNanos);
}
if (json.thresholdNanos != null) {
builder.putAllThresholdNanos(json.thresholdNanos);
}
return builder.build();
}
/**
* Creates an immutable copy of a {@link TraceCollector.SlowThresholdOverridesForUser} 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 SlowThresholdOverridesForUser instance
*/
public static ImmutableSlowThresholdOverridesForUser copyOf(TraceCollector.SlowThresholdOverridesForUser instance) {
if (instance instanceof ImmutableSlowThresholdOverridesForUser) {
return (ImmutableSlowThresholdOverridesForUser) instance;
}
return ImmutableSlowThresholdOverridesForUser.builder()
.copyFrom(instance)
.build();
}
/**
* Creates a builder for {@link ImmutableSlowThresholdOverridesForUser ImmutableSlowThresholdOverridesForUser}.
*
* ImmutableSlowThresholdOverridesForUser.builder()
* .defaultThresholdNanos(Long | null) // nullable {@link TraceCollector.SlowThresholdOverridesForUser#defaultThresholdNanos() defaultThresholdNanos}
* .putThresholdNanos|putAllThresholdNanos(String => long) // {@link TraceCollector.SlowThresholdOverridesForUser#thresholdNanos() thresholdNanos} mappings
* .build();
*
* @return A new ImmutableSlowThresholdOverridesForUser builder
*/
public static ImmutableSlowThresholdOverridesForUser.Builder builder() {
return new ImmutableSlowThresholdOverridesForUser.Builder();
}
/**
* Builds instances of type {@link ImmutableSlowThresholdOverridesForUser ImmutableSlowThresholdOverridesForUser}.
* 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 = "TraceCollector.SlowThresholdOverridesForUser", generator = "Immutables")
@NotThreadSafe
public static final class Builder {
private @org.glowroot.agent.shaded.org.glowroot.agent.it.harness.shaded.javax.annotation.Nullable Long defaultThresholdNanos;
private ImmutableMap.Builder thresholdNanos = ImmutableMap.builder();
private Builder() {
}
/**
* Fill a builder with attribute values from the provided {@code SlowThresholdOverridesForUser} instance.
* Regular attribute values will be replaced with those from the given instance.
* Absent optional values will not replace present values.
* Collection elements and entries will be added, not replaced.
* @param instance The instance from which to copy values
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder copyFrom(TraceCollector.SlowThresholdOverridesForUser instance) {
Preconditions.checkNotNull(instance, "instance");
@Nullable Long defaultThresholdNanosValue = instance.defaultThresholdNanos();
if (defaultThresholdNanosValue != null) {
defaultThresholdNanos(defaultThresholdNanosValue);
}
putAllThresholdNanos(instance.thresholdNanos());
return this;
}
/**
* Initializes the value for the {@link TraceCollector.SlowThresholdOverridesForUser#defaultThresholdNanos() defaultThresholdNanos} attribute.
* @param defaultThresholdNanos The value for defaultThresholdNanos (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder defaultThresholdNanos(@Nullable Long defaultThresholdNanos) {
this.defaultThresholdNanos = defaultThresholdNanos;
return this;
}
/**
* Put one entry to the {@link TraceCollector.SlowThresholdOverridesForUser#thresholdNanos() thresholdNanos} map.
* @param key The key in the thresholdNanos map
* @param value The associated value in the thresholdNanos map
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder putThresholdNanos(String key, long value) {
this.thresholdNanos.put(key, value);
return this;
}
/**
* Put one entry to the {@link TraceCollector.SlowThresholdOverridesForUser#thresholdNanos() thresholdNanos} map. Nulls are not permitted
* @param entry The key and value entry
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder putThresholdNanos(Map.Entry entry) {
this.thresholdNanos.put(entry);
return this;
}
/**
* Sets or replaces all mappings from the specified map as entries for the {@link TraceCollector.SlowThresholdOverridesForUser#thresholdNanos() thresholdNanos} map. Nulls are not permitted
* @param entries The entries that will be added to the thresholdNanos map
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder thresholdNanos(Map entries) {
this.thresholdNanos = ImmutableMap.builder();
return putAllThresholdNanos(entries);
}
/**
* Put all mappings from the specified map as entries to {@link TraceCollector.SlowThresholdOverridesForUser#thresholdNanos() thresholdNanos} map. Nulls are not permitted
* @param entries The entries that will be added to the thresholdNanos map
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder putAllThresholdNanos(Map entries) {
this.thresholdNanos.putAll(entries);
return this;
}
/**
* Builds a new {@link ImmutableSlowThresholdOverridesForUser ImmutableSlowThresholdOverridesForUser}.
* @return An immutable instance of SlowThresholdOverridesForUser
* @throws java.lang.IllegalStateException if any required attributes are missing
*/
public ImmutableSlowThresholdOverridesForUser build() {
return new ImmutableSlowThresholdOverridesForUser(defaultThresholdNanos, thresholdNanos.build());
}
}
}