
org.glowroot.common.live.ImmutableOverviewAggregate Maven / Gradle / Ivy
package org.glowroot.common.live;
import org.glowroot.agent.shaded.fasterxml.jackson.annotation.JsonCreator;
import org.glowroot.agent.shaded.fasterxml.jackson.annotation.JsonProperty;
import org.glowroot.agent.shaded.google.common.base.MoreObjects;
import org.glowroot.agent.shaded.google.common.base.Preconditions;
import org.glowroot.agent.shaded.google.common.collect.ImmutableList;
import org.glowroot.agent.shaded.google.common.collect.Lists;
import org.glowroot.agent.shaded.google.common.primitives.Doubles;
import org.glowroot.agent.shaded.google.common.primitives.Longs;
import java.util.List;
import javax.annotation.Generated;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import javax.annotation.concurrent.Immutable;
import javax.annotation.concurrent.NotThreadSafe;
import org.glowroot.wire.api.model.AggregateOuterClass;
/**
* Immutable implementation of {@link LiveAggregateRepository.OverviewAggregate}.
*
* Use builder to create immutable instances:
* {@code ImmutableOverviewAggregate.builder()}.
*/
@SuppressWarnings("all")
@ParametersAreNonnullByDefault
@Generated({"Immutables.generator", "LiveAggregateRepository.OverviewAggregate"})
@Immutable
public final class ImmutableOverviewAggregate
implements LiveAggregateRepository.OverviewAggregate {
private final long captureTime;
private final double totalNanos;
private final long transactionCount;
private final double totalCpuNanos;
private final double totalBlockedNanos;
private final double totalWaitedNanos;
private final double totalAllocatedBytes;
private final ImmutableList rootTimers;
private ImmutableOverviewAggregate(
long captureTime,
double totalNanos,
long transactionCount,
double totalCpuNanos,
double totalBlockedNanos,
double totalWaitedNanos,
double totalAllocatedBytes,
ImmutableList rootTimers) {
this.captureTime = captureTime;
this.totalNanos = totalNanos;
this.transactionCount = transactionCount;
this.totalCpuNanos = totalCpuNanos;
this.totalBlockedNanos = totalBlockedNanos;
this.totalWaitedNanos = totalWaitedNanos;
this.totalAllocatedBytes = totalAllocatedBytes;
this.rootTimers = rootTimers;
}
/**
* @return value of {@code captureTime} attribute
*/
@JsonProperty
@Override
public long captureTime() {
return captureTime;
}
/**
* @return value of {@code totalNanos} attribute
*/
@JsonProperty
@Override
public double totalNanos() {
return totalNanos;
}
/**
* @return value of {@code transactionCount} attribute
*/
@JsonProperty
@Override
public long transactionCount() {
return transactionCount;
}
/**
* @return value of {@code totalCpuNanos} attribute
*/
@JsonProperty
@Override
public double totalCpuNanos() {
return totalCpuNanos;
}
/**
* @return value of {@code totalBlockedNanos} attribute
*/
@JsonProperty
@Override
public double totalBlockedNanos() {
return totalBlockedNanos;
}
/**
* @return value of {@code totalWaitedNanos} attribute
*/
@JsonProperty
@Override
public double totalWaitedNanos() {
return totalWaitedNanos;
}
/**
* @return value of {@code totalAllocatedBytes} attribute
*/
@JsonProperty
@Override
public double totalAllocatedBytes() {
return totalAllocatedBytes;
}
/**
* @return value of {@code rootTimers} attribute
*/
@JsonProperty
@Override
public ImmutableList rootTimers() {
return rootTimers;
}
/**
* Copy current immutable object by setting value for {@link LiveAggregateRepository.OverviewAggregate#captureTime() captureTime}.
* Value equality check is used to prevent copying of the same value by returning {@code this}.
* @param value new value for captureTime
* @return modified copy of the {@code this} object
*/
public final ImmutableOverviewAggregate withCaptureTime(long value) {
if (this.captureTime == value) return this;
long newValue = value;
return new ImmutableOverviewAggregate(
newValue,
this.totalNanos,
this.transactionCount,
this.totalCpuNanos,
this.totalBlockedNanos,
this.totalWaitedNanos,
this.totalAllocatedBytes,
this.rootTimers);
}
/**
* Copy current immutable object by setting value for {@link LiveAggregateRepository.OverviewAggregate#totalNanos() totalNanos}.
* @param value new value for totalNanos
* @return modified copy of the {@code this} object
*/
public final ImmutableOverviewAggregate withTotalNanos(double value) {
double newValue = value;
return new ImmutableOverviewAggregate(
this.captureTime,
newValue,
this.transactionCount,
this.totalCpuNanos,
this.totalBlockedNanos,
this.totalWaitedNanos,
this.totalAllocatedBytes,
this.rootTimers);
}
/**
* Copy current immutable object by setting value for {@link LiveAggregateRepository.OverviewAggregate#transactionCount() transactionCount}.
* Value equality check is used to prevent copying of the same value by returning {@code this}.
* @param value new value for transactionCount
* @return modified copy of the {@code this} object
*/
public final ImmutableOverviewAggregate withTransactionCount(long value) {
if (this.transactionCount == value) return this;
long newValue = value;
return new ImmutableOverviewAggregate(
this.captureTime,
this.totalNanos,
newValue,
this.totalCpuNanos,
this.totalBlockedNanos,
this.totalWaitedNanos,
this.totalAllocatedBytes,
this.rootTimers);
}
/**
* Copy current immutable object by setting value for {@link LiveAggregateRepository.OverviewAggregate#totalCpuNanos() totalCpuNanos}.
* @param value new value for totalCpuNanos
* @return modified copy of the {@code this} object
*/
public final ImmutableOverviewAggregate withTotalCpuNanos(double value) {
double newValue = value;
return new ImmutableOverviewAggregate(
this.captureTime,
this.totalNanos,
this.transactionCount,
newValue,
this.totalBlockedNanos,
this.totalWaitedNanos,
this.totalAllocatedBytes,
this.rootTimers);
}
/**
* Copy current immutable object by setting value for {@link LiveAggregateRepository.OverviewAggregate#totalBlockedNanos() totalBlockedNanos}.
* @param value new value for totalBlockedNanos
* @return modified copy of the {@code this} object
*/
public final ImmutableOverviewAggregate withTotalBlockedNanos(double value) {
double newValue = value;
return new ImmutableOverviewAggregate(
this.captureTime,
this.totalNanos,
this.transactionCount,
this.totalCpuNanos,
newValue,
this.totalWaitedNanos,
this.totalAllocatedBytes,
this.rootTimers);
}
/**
* Copy current immutable object by setting value for {@link LiveAggregateRepository.OverviewAggregate#totalWaitedNanos() totalWaitedNanos}.
* @param value new value for totalWaitedNanos
* @return modified copy of the {@code this} object
*/
public final ImmutableOverviewAggregate withTotalWaitedNanos(double value) {
double newValue = value;
return new ImmutableOverviewAggregate(
this.captureTime,
this.totalNanos,
this.transactionCount,
this.totalCpuNanos,
this.totalBlockedNanos,
newValue,
this.totalAllocatedBytes,
this.rootTimers);
}
/**
* Copy current immutable object by setting value for {@link LiveAggregateRepository.OverviewAggregate#totalAllocatedBytes() totalAllocatedBytes}.
* @param value new value for totalAllocatedBytes
* @return modified copy of the {@code this} object
*/
public final ImmutableOverviewAggregate withTotalAllocatedBytes(double value) {
double newValue = value;
return new ImmutableOverviewAggregate(
this.captureTime,
this.totalNanos,
this.transactionCount,
this.totalCpuNanos,
this.totalBlockedNanos,
this.totalWaitedNanos,
newValue,
this.rootTimers);
}
/**
* Copy current immutable object with elements that replace content of {@link LiveAggregateRepository.OverviewAggregate#rootTimers() rootTimers}.
* @param elements elements to set
* @return modified copy of {@code this} object
*/
public final ImmutableOverviewAggregate withRootTimers(AggregateOuterClass.Aggregate.Timer... elements) {
ImmutableList newValue = ImmutableList.copyOf(elements);
return new ImmutableOverviewAggregate(
this.captureTime,
this.totalNanos,
this.transactionCount,
this.totalCpuNanos,
this.totalBlockedNanos,
this.totalWaitedNanos,
this.totalAllocatedBytes,
newValue);
}
/**
* Copy current immutable object with elements that replace content of {@link LiveAggregateRepository.OverviewAggregate#rootTimers() rootTimers}.
* Shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param elements iterable of rootTimers elements to set
* @return modified copy of {@code this} object
*/
public final ImmutableOverviewAggregate withRootTimers(Iterable extends AggregateOuterClass.Aggregate.Timer> elements) {
if (this.rootTimers == elements) return this;
ImmutableList newValue = ImmutableList.copyOf(elements);
return new ImmutableOverviewAggregate(
this.captureTime,
this.totalNanos,
this.transactionCount,
this.totalCpuNanos,
this.totalBlockedNanos,
this.totalWaitedNanos,
this.totalAllocatedBytes,
newValue);
}
/**
* This instance is equal to instances of {@code ImmutableOverviewAggregate} with 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 ImmutableOverviewAggregate
&& equalTo((ImmutableOverviewAggregate) another);
}
private boolean equalTo(ImmutableOverviewAggregate another) {
return captureTime == another.captureTime
&& Double.doubleToLongBits(totalNanos) == Double.doubleToLongBits(another.totalNanos)
&& transactionCount == another.transactionCount
&& Double.doubleToLongBits(totalCpuNanos) == Double.doubleToLongBits(another.totalCpuNanos)
&& Double.doubleToLongBits(totalBlockedNanos) == Double.doubleToLongBits(another.totalBlockedNanos)
&& Double.doubleToLongBits(totalWaitedNanos) == Double.doubleToLongBits(another.totalWaitedNanos)
&& Double.doubleToLongBits(totalAllocatedBytes) == Double.doubleToLongBits(another.totalAllocatedBytes)
&& rootTimers.equals(another.rootTimers);
}
/**
* Computes hash code from attributes: {@code captureTime}, {@code totalNanos}, {@code transactionCount}, {@code totalCpuNanos}, {@code totalBlockedNanos}, {@code totalWaitedNanos}, {@code totalAllocatedBytes}, {@code rootTimers}.
* @return hashCode value
*/
@Override
public int hashCode() {
int h = 31;
h = h * 17 + Longs.hashCode(captureTime);
h = h * 17 + Doubles.hashCode(totalNanos);
h = h * 17 + Longs.hashCode(transactionCount);
h = h * 17 + Doubles.hashCode(totalCpuNanos);
h = h * 17 + Doubles.hashCode(totalBlockedNanos);
h = h * 17 + Doubles.hashCode(totalWaitedNanos);
h = h * 17 + Doubles.hashCode(totalAllocatedBytes);
h = h * 17 + rootTimers.hashCode();
return h;
}
/**
* Prints immutable value {@code OverviewAggregate...} with attribute values,
* excluding any non-generated and auxiliary attributes.
* @return string representation of value
*/
@Override
public String toString() {
return MoreObjects.toStringHelper("OverviewAggregate")
.add("captureTime", captureTime)
.add("totalNanos", totalNanos)
.add("transactionCount", transactionCount)
.add("totalCpuNanos", totalCpuNanos)
.add("totalBlockedNanos", totalBlockedNanos)
.add("totalWaitedNanos", totalWaitedNanos)
.add("totalAllocatedBytes", totalAllocatedBytes)
.add("rootTimers", rootTimers)
.toString();
}
/**
* Simple representation of this value type suitable Jackson binding
* @deprecated Do not use this type directly, it exists only for Jackson-binding infrastructure
*/
@Deprecated
static final class Json {
@JsonProperty
@Nullable Long captureTime;
@JsonProperty
@Nullable java.lang.Double totalNanos;
@JsonProperty
@Nullable Long transactionCount;
@JsonProperty
@Nullable java.lang.Double totalCpuNanos;
@JsonProperty
@Nullable java.lang.Double totalBlockedNanos;
@JsonProperty
@Nullable java.lang.Double totalWaitedNanos;
@JsonProperty
@Nullable java.lang.Double totalAllocatedBytes;
@JsonProperty
@Nullable List rootTimers;
}
/**
* @param json JSON-bindable data structure
* @return immutable value type
* @deprecated Do not use this method directly, it exists only for Jackson-binding infrastructure
*/
@Deprecated
@JsonCreator
static ImmutableOverviewAggregate fromJson(Json json) {
ImmutableOverviewAggregate.Builder builder = ImmutableOverviewAggregate.builder();
if (json.captureTime != null) {
builder.captureTime(json.captureTime);
}
if (json.totalNanos != null) {
builder.totalNanos(json.totalNanos);
}
if (json.transactionCount != null) {
builder.transactionCount(json.transactionCount);
}
if (json.totalCpuNanos != null) {
builder.totalCpuNanos(json.totalCpuNanos);
}
if (json.totalBlockedNanos != null) {
builder.totalBlockedNanos(json.totalBlockedNanos);
}
if (json.totalWaitedNanos != null) {
builder.totalWaitedNanos(json.totalWaitedNanos);
}
if (json.totalAllocatedBytes != null) {
builder.totalAllocatedBytes(json.totalAllocatedBytes);
}
if (json.rootTimers != null) {
builder.addAllRootTimers(json.rootTimers);
}
return builder.build();
}
/**
* Creates immutable copy of {@link LiveAggregateRepository.OverviewAggregate}.
* Uses accessors to get values to initialize immutable instance.
* If an instance is already immutable, it is returned as is.
* @param instance instance to copy
* @return copied immutable OverviewAggregate instance
*/
public static ImmutableOverviewAggregate copyOf(LiveAggregateRepository.OverviewAggregate instance) {
if (instance instanceof ImmutableOverviewAggregate) {
return (ImmutableOverviewAggregate) instance;
}
return ImmutableOverviewAggregate.builder()
.copyFrom(instance)
.build();
}
/**
* Creates builder for {@link org.glowroot.common.live.ImmutableOverviewAggregate ImmutableOverviewAggregate}.
* @return new ImmutableOverviewAggregate builder
*/
public static ImmutableOverviewAggregate.Builder builder() {
return new ImmutableOverviewAggregate.Builder();
}
/**
* Builds instances of {@link org.glowroot.common.live.ImmutableOverviewAggregate ImmutableOverviewAggregate}.
* Initialize attributes and then invoke {@link #build()} method to create
* immutable instance.
* {@code Builder} is not thread safe and generally should not be stored in field or collection,
* but used immediately to create instances.
*/
@NotThreadSafe
public static final class Builder {
private static final long INIT_BIT_CAPTURE_TIME = 0x1L;
private static final long INIT_BIT_TOTAL_NANOS = 0x2L;
private static final long INIT_BIT_TRANSACTION_COUNT = 0x4L;
private static final long INIT_BIT_TOTAL_CPU_NANOS = 0x8L;
private static final long INIT_BIT_TOTAL_BLOCKED_NANOS = 0x10L;
private static final long INIT_BIT_TOTAL_WAITED_NANOS = 0x20L;
private static final long INIT_BIT_TOTAL_ALLOCATED_BYTES = 0x40L;
private long initBits = 0x7f;
private long captureTime;
private double totalNanos;
private long transactionCount;
private double totalCpuNanos;
private double totalBlockedNanos;
private double totalWaitedNanos;
private double totalAllocatedBytes;
private ImmutableList.Builder rootTimersBuilder = ImmutableList.builder();
private Builder() {}
/**
* Fill builder with attribute values from provided {@link LiveAggregateRepository.OverviewAggregate} instance.
* Regular attribute values will be replaced with ones of an instance.
* Instance's absent optional values will not replace present values.
* Collection elements and entries will be added, not replaced.
* @param instance instance to copy values from
* @return {@code this} builder for chained invocation
*/
public final Builder copyFrom(LiveAggregateRepository.OverviewAggregate instance) {
Preconditions.checkNotNull(instance);
captureTime(instance.captureTime());
totalNanos(instance.totalNanos());
transactionCount(instance.transactionCount());
totalCpuNanos(instance.totalCpuNanos());
totalBlockedNanos(instance.totalBlockedNanos());
totalWaitedNanos(instance.totalWaitedNanos());
totalAllocatedBytes(instance.totalAllocatedBytes());
addAllRootTimers(instance.rootTimers());
return this;
}
/**
* Initializes value for {@link LiveAggregateRepository.OverviewAggregate#captureTime() captureTime}.
* @param captureTime value for captureTime
* @return {@code this} builder for chained invocation
*/
public final Builder captureTime(long captureTime) {
this.captureTime = captureTime;
initBits &= ~INIT_BIT_CAPTURE_TIME;
return this;
}
/**
* Initializes value for {@link LiveAggregateRepository.OverviewAggregate#totalNanos() totalNanos}.
* @param totalNanos value for totalNanos
* @return {@code this} builder for chained invocation
*/
public final Builder totalNanos(double totalNanos) {
this.totalNanos = totalNanos;
initBits &= ~INIT_BIT_TOTAL_NANOS;
return this;
}
/**
* Initializes value for {@link LiveAggregateRepository.OverviewAggregate#transactionCount() transactionCount}.
* @param transactionCount value for transactionCount
* @return {@code this} builder for chained invocation
*/
public final Builder transactionCount(long transactionCount) {
this.transactionCount = transactionCount;
initBits &= ~INIT_BIT_TRANSACTION_COUNT;
return this;
}
/**
* Initializes value for {@link LiveAggregateRepository.OverviewAggregate#totalCpuNanos() totalCpuNanos}.
* @param totalCpuNanos value for totalCpuNanos
* @return {@code this} builder for chained invocation
*/
public final Builder totalCpuNanos(double totalCpuNanos) {
this.totalCpuNanos = totalCpuNanos;
initBits &= ~INIT_BIT_TOTAL_CPU_NANOS;
return this;
}
/**
* Initializes value for {@link LiveAggregateRepository.OverviewAggregate#totalBlockedNanos() totalBlockedNanos}.
* @param totalBlockedNanos value for totalBlockedNanos
* @return {@code this} builder for chained invocation
*/
public final Builder totalBlockedNanos(double totalBlockedNanos) {
this.totalBlockedNanos = totalBlockedNanos;
initBits &= ~INIT_BIT_TOTAL_BLOCKED_NANOS;
return this;
}
/**
* Initializes value for {@link LiveAggregateRepository.OverviewAggregate#totalWaitedNanos() totalWaitedNanos}.
* @param totalWaitedNanos value for totalWaitedNanos
* @return {@code this} builder for chained invocation
*/
public final Builder totalWaitedNanos(double totalWaitedNanos) {
this.totalWaitedNanos = totalWaitedNanos;
initBits &= ~INIT_BIT_TOTAL_WAITED_NANOS;
return this;
}
/**
* Initializes value for {@link LiveAggregateRepository.OverviewAggregate#totalAllocatedBytes() totalAllocatedBytes}.
* @param totalAllocatedBytes value for totalAllocatedBytes
* @return {@code this} builder for chained invocation
*/
public final Builder totalAllocatedBytes(double totalAllocatedBytes) {
this.totalAllocatedBytes = totalAllocatedBytes;
initBits &= ~INIT_BIT_TOTAL_ALLOCATED_BYTES;
return this;
}
/**
* Adds one element to {@link LiveAggregateRepository.OverviewAggregate#rootTimers() rootTimers} list.
* @param element rootTimers element
* @return {@code this} builder for chained invocation
*/
public final Builder addRootTimers(AggregateOuterClass.Aggregate.Timer element) {
rootTimersBuilder.add(element);
return this;
}
/**
* Adds elements to {@link LiveAggregateRepository.OverviewAggregate#rootTimers() rootTimers} list.
* @param elements array of rootTimers elements
* @return {@code this} builder for chained invocation
*/
public final Builder addRootTimers(AggregateOuterClass.Aggregate.Timer... elements) {
rootTimersBuilder.add(elements);
return this;
}
/**
* Sets or replaces all elements for {@link LiveAggregateRepository.OverviewAggregate#rootTimers() rootTimers} list.
* @param elements iterable of rootTimers elements
* @return {@code this} builder for chained invocation
*/
public final Builder rootTimers(Iterable extends AggregateOuterClass.Aggregate.Timer> elements) {
rootTimersBuilder = ImmutableList.builder();
return addAllRootTimers(elements);
}
/**
* Adds elements to {@link LiveAggregateRepository.OverviewAggregate#rootTimers() rootTimers} list.
* @param elements iterable of rootTimers elements
* @return {@code this} builder for chained invocation
*/
public final Builder addAllRootTimers(Iterable extends AggregateOuterClass.Aggregate.Timer> elements) {
rootTimersBuilder.addAll(elements);
return this;
}
/**
* Builds new {@link org.glowroot.common.live.ImmutableOverviewAggregate ImmutableOverviewAggregate}.
* @return immutable instance of OverviewAggregate
* @throws exception {@code java.lang.IllegalStateException} if any required attributes are missing
*/
public ImmutableOverviewAggregate build()
throws IllegalStateException {
checkRequiredAttributes();
return new ImmutableOverviewAggregate(
captureTime,
totalNanos,
transactionCount,
totalCpuNanos,
totalBlockedNanos,
totalWaitedNanos,
totalAllocatedBytes,
rootTimersBuilder.build());
}
private boolean captureTimeIsSet() {
return (initBits & INIT_BIT_CAPTURE_TIME) == 0;
}
private boolean totalNanosIsSet() {
return (initBits & INIT_BIT_TOTAL_NANOS) == 0;
}
private boolean transactionCountIsSet() {
return (initBits & INIT_BIT_TRANSACTION_COUNT) == 0;
}
private boolean totalCpuNanosIsSet() {
return (initBits & INIT_BIT_TOTAL_CPU_NANOS) == 0;
}
private boolean totalBlockedNanosIsSet() {
return (initBits & INIT_BIT_TOTAL_BLOCKED_NANOS) == 0;
}
private boolean totalWaitedNanosIsSet() {
return (initBits & INIT_BIT_TOTAL_WAITED_NANOS) == 0;
}
private boolean totalAllocatedBytesIsSet() {
return (initBits & INIT_BIT_TOTAL_ALLOCATED_BYTES) == 0;
}
private void checkRequiredAttributes() throws IllegalStateException {
if (initBits != 0) {
throw new IllegalStateException(formatRequiredAttributesMessage());
}
}
private String formatRequiredAttributesMessage() {
List attributes = Lists.newArrayList();
if (!captureTimeIsSet()) attributes.add("captureTime");
if (!totalNanosIsSet()) attributes.add("totalNanos");
if (!transactionCountIsSet()) attributes.add("transactionCount");
if (!totalCpuNanosIsSet()) attributes.add("totalCpuNanos");
if (!totalBlockedNanosIsSet()) attributes.add("totalBlockedNanos");
if (!totalWaitedNanosIsSet()) attributes.add("totalWaitedNanos");
if (!totalAllocatedBytesIsSet()) attributes.add("totalAllocatedBytes");
return "Cannot build OverviewAggregate, some of required attributes are not set " + attributes;
}
}
}