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

org.glowroot.collector.Aggregate Maven / Gradle / Ivy

The newest version!
package org.glowroot.collector;

import org.glowroot.shaded.fasterxml.jackson.annotation.JsonCreator;
import org.glowroot.shaded.fasterxml.jackson.annotation.JsonProperty;
import org.glowroot.shaded.fasterxml.jackson.annotation.JsonRawValue;
import org.glowroot.shaded.google.common.base.MoreObjects;
import org.glowroot.shaded.google.common.base.Objects;
import org.glowroot.shaded.google.common.base.Preconditions;
import org.glowroot.shaded.google.common.collect.Lists;
import org.glowroot.shaded.google.common.primitives.Longs;
import java.util.Arrays;
import java.util.Collection;
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 AggregateBase}.
 * 

* Use builder to create immutable instances: * {@code Aggregate.builder()}. */ @SuppressWarnings("all") @ParametersAreNonnullByDefault @Generated({"Immutables.generator", "AggregateBase"}) @Immutable public final class Aggregate extends AggregateBase { private final String transactionType; private final @Nullable String transactionName; private final long captureTime; private final long totalMicros; private final long errorCount; private final long transactionCount; private final @Nullable Long totalCpuMicros; private final @Nullable Long totalBlockedMicros; private final @Nullable Long totalWaitedMicros; private final @Nullable Long totalAllocatedKBytes; private final byte[] histogram; private final String timers; private final @Nullable String queries; private final @Nullable String profile; private Aggregate( String transactionType, @Nullable String transactionName, long captureTime, long totalMicros, long errorCount, long transactionCount, @Nullable Long totalCpuMicros, @Nullable Long totalBlockedMicros, @Nullable Long totalWaitedMicros, @Nullable Long totalAllocatedKBytes, byte[] histogram, String timers, @Nullable String queries, @Nullable String profile) { this.transactionType = transactionType; this.transactionName = transactionName; this.captureTime = captureTime; this.totalMicros = totalMicros; this.errorCount = errorCount; this.transactionCount = transactionCount; this.totalCpuMicros = totalCpuMicros; this.totalBlockedMicros = totalBlockedMicros; this.totalWaitedMicros = totalWaitedMicros; this.totalAllocatedKBytes = totalAllocatedKBytes; this.histogram = histogram; this.timers = timers; this.queries = queries; this.profile = profile; } /** * {@inheritDoc} * @return value of {@code transactionType} attribute */ @JsonProperty("transactionType") @Override public String transactionType() { return transactionType; } /** * {@inheritDoc} * @return value of {@code transactionName} attribute */ @JsonProperty("transactionName") @Override public String transactionName() { return transactionName; } /** * {@inheritDoc} * @return value of {@code captureTime} attribute */ @JsonProperty("captureTime") @Override public long captureTime() { return captureTime; } /** * {@inheritDoc} * @return value of {@code totalMicros} attribute */ @JsonProperty("totalMicros") @Override public long totalMicros() { return totalMicros; } /** * {@inheritDoc} * @return value of {@code errorCount} attribute */ @JsonProperty("errorCount") @Override public long errorCount() { return errorCount; } /** * {@inheritDoc} * @return value of {@code transactionCount} attribute */ @JsonProperty("transactionCount") @Override public long transactionCount() { return transactionCount; } /** * {@inheritDoc} * @return value of {@code totalCpuMicros} attribute */ @JsonProperty("totalCpuMicros") @Override public Long totalCpuMicros() { return totalCpuMicros; } /** * {@inheritDoc} * @return value of {@code totalBlockedMicros} attribute */ @JsonProperty("totalBlockedMicros") @Override public Long totalBlockedMicros() { return totalBlockedMicros; } /** * {@inheritDoc} * @return value of {@code totalWaitedMicros} attribute */ @JsonProperty("totalWaitedMicros") @Override public Long totalWaitedMicros() { return totalWaitedMicros; } /** * {@inheritDoc} * @return value of {@code totalAllocatedKBytes} attribute */ @JsonProperty("totalAllocatedKBytes") @Override public Long totalAllocatedKBytes() { return totalAllocatedKBytes; } /** * {@inheritDoc} * @return cloned {@code histogram} array */ @JsonProperty("histogram") @Override public byte[] histogram() { return histogram.clone(); } /** * {@inheritDoc} * @return value of {@code timers} attribute */ @JsonRawValue @JsonProperty("timers") @Override public String timers() { return timers; } /** * {@inheritDoc} * @return value of {@code queries} attribute */ @JsonRawValue @JsonProperty("queries") @Override public String queries() { return queries; } /** * {@inheritDoc} * @return value of {@code profile} attribute */ @JsonRawValue @JsonProperty("profile") @Override public String profile() { return profile; } /** * Copy current immutable object by setting value for {@link AggregateBase#transactionType() transactionType}. * Shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param value new value for transactionType * @return modified copy of the {@code this} object */ public final Aggregate withTransactionType(String value) { if (this.transactionType == value) { return this; } String newValue = Preconditions.checkNotNull(value); return new Aggregate( newValue, this.transactionName, this.captureTime, this.totalMicros, this.errorCount, this.transactionCount, this.totalCpuMicros, this.totalBlockedMicros, this.totalWaitedMicros, this.totalAllocatedKBytes, this.histogram, this.timers, this.queries, this.profile); } /** * Copy current immutable object by setting value for {@link AggregateBase#transactionName() transactionName}. * Shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param value new value for transactionName, can be {@code null} * @return modified copy of the {@code this} object */ public final Aggregate withTransactionName(@Nullable String value) { if (this.transactionName == value) { return this; } @Nullable String newValue = value; return new Aggregate( this.transactionType, newValue, this.captureTime, this.totalMicros, this.errorCount, this.transactionCount, this.totalCpuMicros, this.totalBlockedMicros, this.totalWaitedMicros, this.totalAllocatedKBytes, this.histogram, this.timers, this.queries, this.profile); } /** * Copy current immutable object by setting value for {@link AggregateBase#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 Aggregate withCaptureTime(long value) { if (this.captureTime == value) { return this; } long newValue = value; return new Aggregate( this.transactionType, this.transactionName, newValue, this.totalMicros, this.errorCount, this.transactionCount, this.totalCpuMicros, this.totalBlockedMicros, this.totalWaitedMicros, this.totalAllocatedKBytes, this.histogram, this.timers, this.queries, this.profile); } /** * Copy current immutable object by setting value for {@link AggregateBase#totalMicros() totalMicros}. * Value equality check is used to prevent copying of the same value by returning {@code this}. * @param value new value for totalMicros * @return modified copy of the {@code this} object */ public final Aggregate withTotalMicros(long value) { if (this.totalMicros == value) { return this; } long newValue = value; return new Aggregate( this.transactionType, this.transactionName, this.captureTime, newValue, this.errorCount, this.transactionCount, this.totalCpuMicros, this.totalBlockedMicros, this.totalWaitedMicros, this.totalAllocatedKBytes, this.histogram, this.timers, this.queries, this.profile); } /** * Copy current immutable object by setting value for {@link AggregateBase#errorCount() errorCount}. * Value equality check is used to prevent copying of the same value by returning {@code this}. * @param value new value for errorCount * @return modified copy of the {@code this} object */ public final Aggregate withErrorCount(long value) { if (this.errorCount == value) { return this; } long newValue = value; return new Aggregate( this.transactionType, this.transactionName, this.captureTime, this.totalMicros, newValue, this.transactionCount, this.totalCpuMicros, this.totalBlockedMicros, this.totalWaitedMicros, this.totalAllocatedKBytes, this.histogram, this.timers, this.queries, this.profile); } /** * Copy current immutable object by setting value for {@link AggregateBase#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 Aggregate withTransactionCount(long value) { if (this.transactionCount == value) { return this; } long newValue = value; return new Aggregate( this.transactionType, this.transactionName, this.captureTime, this.totalMicros, this.errorCount, newValue, this.totalCpuMicros, this.totalBlockedMicros, this.totalWaitedMicros, this.totalAllocatedKBytes, this.histogram, this.timers, this.queries, this.profile); } /** * Copy current immutable object by setting value for {@link AggregateBase#totalCpuMicros() totalCpuMicros}. * Shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param value new value for totalCpuMicros, can be {@code null} * @return modified copy of the {@code this} object */ public final Aggregate withTotalCpuMicros(@Nullable Long value) { if (this.totalCpuMicros == value) { return this; } @Nullable Long newValue = value; return new Aggregate( this.transactionType, this.transactionName, this.captureTime, this.totalMicros, this.errorCount, this.transactionCount, newValue, this.totalBlockedMicros, this.totalWaitedMicros, this.totalAllocatedKBytes, this.histogram, this.timers, this.queries, this.profile); } /** * Copy current immutable object by setting value for {@link AggregateBase#totalBlockedMicros() totalBlockedMicros}. * Shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param value new value for totalBlockedMicros, can be {@code null} * @return modified copy of the {@code this} object */ public final Aggregate withTotalBlockedMicros(@Nullable Long value) { if (this.totalBlockedMicros == value) { return this; } @Nullable Long newValue = value; return new Aggregate( this.transactionType, this.transactionName, this.captureTime, this.totalMicros, this.errorCount, this.transactionCount, this.totalCpuMicros, newValue, this.totalWaitedMicros, this.totalAllocatedKBytes, this.histogram, this.timers, this.queries, this.profile); } /** * Copy current immutable object by setting value for {@link AggregateBase#totalWaitedMicros() totalWaitedMicros}. * Shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param value new value for totalWaitedMicros, can be {@code null} * @return modified copy of the {@code this} object */ public final Aggregate withTotalWaitedMicros(@Nullable Long value) { if (this.totalWaitedMicros == value) { return this; } @Nullable Long newValue = value; return new Aggregate( this.transactionType, this.transactionName, this.captureTime, this.totalMicros, this.errorCount, this.transactionCount, this.totalCpuMicros, this.totalBlockedMicros, newValue, this.totalAllocatedKBytes, this.histogram, this.timers, this.queries, this.profile); } /** * Copy current immutable object by setting value for {@link AggregateBase#totalAllocatedKBytes() totalAllocatedKBytes}. * Shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param value new value for totalAllocatedKBytes, can be {@code null} * @return modified copy of the {@code this} object */ public final Aggregate withTotalAllocatedKBytes(@Nullable Long value) { if (this.totalAllocatedKBytes == value) { return this; } @Nullable Long newValue = value; return new Aggregate( this.transactionType, this.transactionName, this.captureTime, this.totalMicros, this.errorCount, this.transactionCount, this.totalCpuMicros, this.totalBlockedMicros, this.totalWaitedMicros, newValue, this.histogram, this.timers, this.queries, this.profile); } /** * Copy current immutable object with elements that replace content of {@link AggregateBase#histogram() histogram}. * Array is cloned before saved as the attribute value. * @param elements elements for histogram, not null * @return modified copy of {@code this} object */ public final Aggregate withHistogram(byte... elements) { byte[] newValue = elements.clone(); return new Aggregate( this.transactionType, this.transactionName, this.captureTime, this.totalMicros, this.errorCount, this.transactionCount, this.totalCpuMicros, this.totalBlockedMicros, this.totalWaitedMicros, this.totalAllocatedKBytes, newValue, this.timers, this.queries, this.profile); } /** * Copy current immutable object by setting value for {@link AggregateBase#timers() timers}. * Shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param value new value for timers * @return modified copy of the {@code this} object */ public final Aggregate withTimers(String value) { if (this.timers == value) { return this; } String newValue = Preconditions.checkNotNull(value); return new Aggregate( this.transactionType, this.transactionName, this.captureTime, this.totalMicros, this.errorCount, this.transactionCount, this.totalCpuMicros, this.totalBlockedMicros, this.totalWaitedMicros, this.totalAllocatedKBytes, this.histogram, newValue, this.queries, this.profile); } /** * Copy current immutable object by setting value for {@link AggregateBase#queries() queries}. * Shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param value new value for queries, can be {@code null} * @return modified copy of the {@code this} object */ public final Aggregate withQueries(@Nullable String value) { if (this.queries == value) { return this; } @Nullable String newValue = value; return new Aggregate( this.transactionType, this.transactionName, this.captureTime, this.totalMicros, this.errorCount, this.transactionCount, this.totalCpuMicros, this.totalBlockedMicros, this.totalWaitedMicros, this.totalAllocatedKBytes, this.histogram, this.timers, newValue, this.profile); } /** * Copy current immutable object by setting value for {@link AggregateBase#profile() profile}. * Shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param value new value for profile, can be {@code null} * @return modified copy of the {@code this} object */ public final Aggregate withProfile(@Nullable String value) { if (this.profile == value) { return this; } @Nullable String newValue = value; return new Aggregate( this.transactionType, this.transactionName, this.captureTime, this.totalMicros, this.errorCount, this.transactionCount, this.totalCpuMicros, this.totalBlockedMicros, this.totalWaitedMicros, this.totalAllocatedKBytes, this.histogram, this.timers, this.queries, newValue); } /** * This instance is equal to instances of {@code Aggregate} with equal attribute values. * @return {@code true} if {@code this} is equal to {@code another} instance */ @Override public boolean equals(@Nullable Object another) { return this == another || (another instanceof Aggregate && equalTo((Aggregate) another)); } private boolean equalTo(Aggregate another) { return transactionType.equals(another.transactionType) && Objects.equal(transactionName, another.transactionName) && captureTime == another.captureTime && totalMicros == another.totalMicros && errorCount == another.errorCount && transactionCount == another.transactionCount && Objects.equal(totalCpuMicros, another.totalCpuMicros) && Objects.equal(totalBlockedMicros, another.totalBlockedMicros) && Objects.equal(totalWaitedMicros, another.totalWaitedMicros) && Objects.equal(totalAllocatedKBytes, another.totalAllocatedKBytes) && Arrays.equals(histogram, another.histogram) && timers.equals(another.timers) && Objects.equal(queries, another.queries) && Objects.equal(profile, another.profile); } /** * Computes hash code from attributes: {@code transactionType}, {@code transactionName}, {@code captureTime}, {@code totalMicros}, {@code errorCount}, {@code transactionCount}, {@code totalCpuMicros}, {@code totalBlockedMicros}, {@code totalWaitedMicros}, {@code totalAllocatedKBytes}, {@code histogram}, {@code timers}, {@code queries}, {@code profile}. * @return hashCode value */ @Override public int hashCode() { int h = 31; h = h * 17 + transactionType.hashCode(); h = h * 17 + Objects.hashCode(transactionName); h = h * 17 + Longs.hashCode(captureTime); h = h * 17 + Longs.hashCode(totalMicros); h = h * 17 + Longs.hashCode(errorCount); h = h * 17 + Longs.hashCode(transactionCount); h = h * 17 + Objects.hashCode(totalCpuMicros); h = h * 17 + Objects.hashCode(totalBlockedMicros); h = h * 17 + Objects.hashCode(totalWaitedMicros); h = h * 17 + Objects.hashCode(totalAllocatedKBytes); h = h * 17 + Arrays.hashCode(histogram); h = h * 17 + timers.hashCode(); h = h * 17 + Objects.hashCode(queries); h = h * 17 + Objects.hashCode(profile); return h; } /** * Prints immutable value {@code Aggregate{...}} with attribute values, * excluding any non-generated and auxiliary attributes. * @return string representation of value */ @Override public String toString() { return MoreObjects.toStringHelper("Aggregate") .add("transactionType", transactionType) .add("transactionName", transactionName) .add("captureTime", captureTime) .add("totalMicros", totalMicros) .add("errorCount", errorCount) .add("transactionCount", transactionCount) .add("totalCpuMicros", totalCpuMicros) .add("totalBlockedMicros", totalBlockedMicros) .add("totalWaitedMicros", totalWaitedMicros) .add("totalAllocatedKBytes", totalAllocatedKBytes) .add("histogram", Arrays.toString(histogram)) .add("timers", timers) .add("queries", queries) .add("profile", profile) .toString(); } @JsonCreator public static Aggregate fromAllAttributes( @JsonProperty("transactionType") @Nullable String transactionType, @JsonProperty("transactionName") @Nullable String transactionName, @JsonProperty("captureTime") @Nullable Long captureTime, @JsonProperty("totalMicros") @Nullable Long totalMicros, @JsonProperty("errorCount") @Nullable Long errorCount, @JsonProperty("transactionCount") @Nullable Long transactionCount, @JsonProperty("totalCpuMicros") @Nullable Long totalCpuMicros, @JsonProperty("totalBlockedMicros") @Nullable Long totalBlockedMicros, @JsonProperty("totalWaitedMicros") @Nullable Long totalWaitedMicros, @JsonProperty("totalAllocatedKBytes") @Nullable Long totalAllocatedKBytes, @JsonProperty("histogram") @Nullable byte[] histogram, @JsonProperty("timers") @Nullable String timers, @JsonProperty("queries") @Nullable String queries, @JsonProperty("profile") @Nullable String profile) { Aggregate.Builder builder = Aggregate.builder(); if (transactionType != null) { builder.transactionType(transactionType); } if (transactionName != null) { builder.transactionName(transactionName); } if (captureTime != null) { builder.captureTime(captureTime); } if (totalMicros != null) { builder.totalMicros(totalMicros); } if (errorCount != null) { builder.errorCount(errorCount); } if (transactionCount != null) { builder.transactionCount(transactionCount); } if (totalCpuMicros != null) { builder.totalCpuMicros(totalCpuMicros); } if (totalBlockedMicros != null) { builder.totalBlockedMicros(totalBlockedMicros); } if (totalWaitedMicros != null) { builder.totalWaitedMicros(totalWaitedMicros); } if (totalAllocatedKBytes != null) { builder.totalAllocatedKBytes(totalAllocatedKBytes); } if (histogram != null) { builder.histogram(histogram); } if (timers != null) { builder.timers(timers); } if (queries != null) { builder.queries(queries); } if (profile != null) { builder.profile(profile); } return builder.build(); } /** * Creates immutable copy of {@link AggregateBase}. * 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 Aggregate instance */ public static Aggregate copyOf(AggregateBase instance) { if (instance instanceof Aggregate) { return (Aggregate) instance; } return Aggregate.builder() .transactionType(instance.transactionType()) .transactionName(instance.transactionName()) .captureTime(instance.captureTime()) .totalMicros(instance.totalMicros()) .errorCount(instance.errorCount()) .transactionCount(instance.transactionCount()) .totalCpuMicros(instance.totalCpuMicros()) .totalBlockedMicros(instance.totalBlockedMicros()) .totalWaitedMicros(instance.totalWaitedMicros()) .totalAllocatedKBytes(instance.totalAllocatedKBytes()) .histogram(instance.histogram()) .timers(instance.timers()) .queries(instance.queries()) .profile(instance.profile()) .build(); } /** * Creates builder for {@link org.glowroot.collector.Aggregate}. * @return new Aggregate builder */ public static Aggregate.Builder builder() { return new Aggregate.Builder(); } /** * Builds instances of {@link org.glowroot.collector.Aggregate}. * Initialized attributes and then invoke {@link #build()} method to create * immutable instance. *

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 INITIALIZED_BITSET_ALL = 0x7f; private static final long INITIALIZED_BIT_TRANSACTION_TYPE = 0x1L; private static final long INITIALIZED_BIT_CAPTURE_TIME = 0x2L; private static final long INITIALIZED_BIT_TOTAL_MICROS = 0x4L; private static final long INITIALIZED_BIT_ERROR_COUNT = 0x8L; private static final long INITIALIZED_BIT_TRANSACTION_COUNT = 0x10L; private static final long INITIALIZED_BIT_HISTOGRAM = 0x20L; private static final long INITIALIZED_BIT_TIMERS = 0x40L; private static final long NONDEFAULT_BIT_TRANSACTION_NAME = 0x1L; private static final long NONDEFAULT_BIT_TOTAL_CPU_MICROS = 0x2L; private static final long NONDEFAULT_BIT_TOTAL_BLOCKED_MICROS = 0x4L; private static final long NONDEFAULT_BIT_TOTAL_WAITED_MICROS = 0x8L; private static final long NONDEFAULT_BIT_TOTAL_ALLOCATED_K_BYTES = 0x10L; private static final long NONDEFAULT_BIT_QUERIES = 0x20L; private static final long NONDEFAULT_BIT_PROFILE = 0x40L; private long initializedBitset; private long nondefaultBitset; private @Nullable String transactionType; private @Nullable String transactionName; private long captureTime; private long totalMicros; private long errorCount; private long transactionCount; private @Nullable Long totalCpuMicros; private @Nullable Long totalBlockedMicros; private @Nullable Long totalWaitedMicros; private @Nullable Long totalAllocatedKBytes; private @Nullable byte[] histogram; private @Nullable String timers; private @Nullable String queries; private @Nullable String profile; private Builder() {} /** * Initializes value for {@link AggregateBase#transactionType() transactionType}. * @param transactionType value for transactionType * @return {@code this} builder for chained invocation */ public final Builder transactionType(String transactionType) { checkNotIsSet(transactionTypeIsSet(), "transactionType"); this.transactionType = Preconditions.checkNotNull(transactionType); initializedBitset |= INITIALIZED_BIT_TRANSACTION_TYPE; return this; } /** * Initializes value for {@link AggregateBase#transactionName() transactionName}. * @param transactionName value for transactionName, can be {@code null} * @return {@code this} builder for chained invocation */ public final Builder transactionName(@Nullable String transactionName) { checkNotIsSet(transactionNameIsSet(), "transactionName"); this.transactionName = transactionName; nondefaultBitset |= NONDEFAULT_BIT_TRANSACTION_NAME; return this; } /** * Initializes value for {@link AggregateBase#captureTime() captureTime}. * @param captureTime value for captureTime * @return {@code this} builder for chained invocation */ public final Builder captureTime(long captureTime) { checkNotIsSet(captureTimeIsSet(), "captureTime"); this.captureTime = captureTime; initializedBitset |= INITIALIZED_BIT_CAPTURE_TIME; return this; } /** * Initializes value for {@link AggregateBase#totalMicros() totalMicros}. * @param totalMicros value for totalMicros * @return {@code this} builder for chained invocation */ public final Builder totalMicros(long totalMicros) { checkNotIsSet(totalMicrosIsSet(), "totalMicros"); this.totalMicros = totalMicros; initializedBitset |= INITIALIZED_BIT_TOTAL_MICROS; return this; } /** * Initializes value for {@link AggregateBase#errorCount() errorCount}. * @param errorCount value for errorCount * @return {@code this} builder for chained invocation */ public final Builder errorCount(long errorCount) { checkNotIsSet(errorCountIsSet(), "errorCount"); this.errorCount = errorCount; initializedBitset |= INITIALIZED_BIT_ERROR_COUNT; return this; } /** * Initializes value for {@link AggregateBase#transactionCount() transactionCount}. * @param transactionCount value for transactionCount * @return {@code this} builder for chained invocation */ public final Builder transactionCount(long transactionCount) { checkNotIsSet(transactionCountIsSet(), "transactionCount"); this.transactionCount = transactionCount; initializedBitset |= INITIALIZED_BIT_TRANSACTION_COUNT; return this; } /** * Initializes value for {@link AggregateBase#totalCpuMicros() totalCpuMicros}. * @param totalCpuMicros value for totalCpuMicros, can be {@code null} * @return {@code this} builder for chained invocation */ public final Builder totalCpuMicros(@Nullable Long totalCpuMicros) { checkNotIsSet(totalCpuMicrosIsSet(), "totalCpuMicros"); this.totalCpuMicros = totalCpuMicros; nondefaultBitset |= NONDEFAULT_BIT_TOTAL_CPU_MICROS; return this; } /** * Initializes value for {@link AggregateBase#totalBlockedMicros() totalBlockedMicros}. * @param totalBlockedMicros value for totalBlockedMicros, can be {@code null} * @return {@code this} builder for chained invocation */ public final Builder totalBlockedMicros(@Nullable Long totalBlockedMicros) { checkNotIsSet(totalBlockedMicrosIsSet(), "totalBlockedMicros"); this.totalBlockedMicros = totalBlockedMicros; nondefaultBitset |= NONDEFAULT_BIT_TOTAL_BLOCKED_MICROS; return this; } /** * Initializes value for {@link AggregateBase#totalWaitedMicros() totalWaitedMicros}. * @param totalWaitedMicros value for totalWaitedMicros, can be {@code null} * @return {@code this} builder for chained invocation */ public final Builder totalWaitedMicros(@Nullable Long totalWaitedMicros) { checkNotIsSet(totalWaitedMicrosIsSet(), "totalWaitedMicros"); this.totalWaitedMicros = totalWaitedMicros; nondefaultBitset |= NONDEFAULT_BIT_TOTAL_WAITED_MICROS; return this; } /** * Initializes value for {@link AggregateBase#totalAllocatedKBytes() totalAllocatedKBytes}. * @param totalAllocatedKBytes value for totalAllocatedKBytes, can be {@code null} * @return {@code this} builder for chained invocation */ public final Builder totalAllocatedKBytes(@Nullable Long totalAllocatedKBytes) { checkNotIsSet(totalAllocatedKBytesIsSet(), "totalAllocatedKBytes"); this.totalAllocatedKBytes = totalAllocatedKBytes; nondefaultBitset |= NONDEFAULT_BIT_TOTAL_ALLOCATED_K_BYTES; return this; } /** * Initializes value for {@link AggregateBase#histogram() histogram}. * @param elements elements for histogram * @return {@code this} builder for chained invocation */ public final Builder histogram(byte... elements) { checkNotIsSet(histogramIsSet(), "histogram"); this.histogram = elements.clone(); initializedBitset |= INITIALIZED_BIT_HISTOGRAM; return this; } /** * Initializes value for {@link AggregateBase#timers() timers}. * @param timers value for timers * @return {@code this} builder for chained invocation */ public final Builder timers(String timers) { checkNotIsSet(timersIsSet(), "timers"); this.timers = Preconditions.checkNotNull(timers); initializedBitset |= INITIALIZED_BIT_TIMERS; return this; } /** * Initializes value for {@link AggregateBase#queries() queries}. * @param queries value for queries, can be {@code null} * @return {@code this} builder for chained invocation */ public final Builder queries(@Nullable String queries) { checkNotIsSet(queriesIsSet(), "queries"); this.queries = queries; nondefaultBitset |= NONDEFAULT_BIT_QUERIES; return this; } /** * Initializes value for {@link AggregateBase#profile() profile}. * @param profile value for profile, can be {@code null} * @return {@code this} builder for chained invocation */ public final Builder profile(@Nullable String profile) { checkNotIsSet(profileIsSet(), "profile"); this.profile = profile; nondefaultBitset |= NONDEFAULT_BIT_PROFILE; return this; } /** * Builds new {@link org.glowroot.collector.Aggregate}. * @return immutable instance of Aggregate */ public Aggregate build() { checkRequiredAttributes(); return new Aggregate( transactionType, transactionName, captureTime, totalMicros, errorCount, transactionCount, totalCpuMicros, totalBlockedMicros, totalWaitedMicros, totalAllocatedKBytes, histogram, timers, queries, profile); } private boolean transactionNameIsSet() { return (nondefaultBitset & NONDEFAULT_BIT_TRANSACTION_NAME) != 0; } private boolean totalCpuMicrosIsSet() { return (nondefaultBitset & NONDEFAULT_BIT_TOTAL_CPU_MICROS) != 0; } private boolean totalBlockedMicrosIsSet() { return (nondefaultBitset & NONDEFAULT_BIT_TOTAL_BLOCKED_MICROS) != 0; } private boolean totalWaitedMicrosIsSet() { return (nondefaultBitset & NONDEFAULT_BIT_TOTAL_WAITED_MICROS) != 0; } private boolean totalAllocatedKBytesIsSet() { return (nondefaultBitset & NONDEFAULT_BIT_TOTAL_ALLOCATED_K_BYTES) != 0; } private boolean queriesIsSet() { return (nondefaultBitset & NONDEFAULT_BIT_QUERIES) != 0; } private boolean profileIsSet() { return (nondefaultBitset & NONDEFAULT_BIT_PROFILE) != 0; } private boolean transactionTypeIsSet() { return (initializedBitset & INITIALIZED_BIT_TRANSACTION_TYPE) != 0; } private boolean captureTimeIsSet() { return (initializedBitset & INITIALIZED_BIT_CAPTURE_TIME) != 0; } private boolean totalMicrosIsSet() { return (initializedBitset & INITIALIZED_BIT_TOTAL_MICROS) != 0; } private boolean errorCountIsSet() { return (initializedBitset & INITIALIZED_BIT_ERROR_COUNT) != 0; } private boolean transactionCountIsSet() { return (initializedBitset & INITIALIZED_BIT_TRANSACTION_COUNT) != 0; } private boolean histogramIsSet() { return (initializedBitset & INITIALIZED_BIT_HISTOGRAM) != 0; } private boolean timersIsSet() { return (initializedBitset & INITIALIZED_BIT_TIMERS) != 0; } private void checkNotIsSet(boolean isSet, String name) { if (isSet) { throw new IllegalStateException("Builder of Aggregate is strict, attribute is already set: ".concat(name)); } } private void checkRequiredAttributes() { if (initializedBitset != INITIALIZED_BITSET_ALL) { throw new IllegalStateException(formatRequiredAttributesMessage()); } } private String formatRequiredAttributesMessage() { Collection attributes = Lists.newArrayList(); if (!transactionTypeIsSet()) { attributes.add("transactionType"); } if (!captureTimeIsSet()) { attributes.add("captureTime"); } if (!totalMicrosIsSet()) { attributes.add("totalMicros"); } if (!errorCountIsSet()) { attributes.add("errorCount"); } if (!transactionCountIsSet()) { attributes.add("transactionCount"); } if (!histogramIsSet()) { attributes.add("histogram"); } if (!timersIsSet()) { attributes.add("timers"); } return "Cannot build Aggregate, some of required attributes are not set " + attributes; } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy