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

org.glowroot.common.live.ImmutableOverviewAggregate Maven / Gradle / Ivy

There is a newer version: 0.9.24
Show newest version
package org.glowroot.common.live;

import org.glowroot.agent.shaded.fasterxml.jackson.annotation.JsonCreator;
import org.glowroot.agent.shaded.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import com.google.common.primitives.Booleans;
import com.google.common.primitives.Doubles;
import com.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 the 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 totalDurationNanos; private final long transactionCount; private final boolean asyncTransactions; private final ImmutableList mainThreadRootTimers; private final ImmutableList auxThreadRootTimers; private final ImmutableList asyncRootTimers; private final @Nullable AggregateOuterClass.Aggregate.ThreadStats mainThreadStats; private final @Nullable AggregateOuterClass.Aggregate.ThreadStats auxThreadStats; private ImmutableOverviewAggregate( long captureTime, double totalDurationNanos, long transactionCount, boolean asyncTransactions, ImmutableList mainThreadRootTimers, ImmutableList auxThreadRootTimers, ImmutableList asyncRootTimers, @Nullable AggregateOuterClass.Aggregate.ThreadStats mainThreadStats, @Nullable AggregateOuterClass.Aggregate.ThreadStats auxThreadStats) { this.captureTime = captureTime; this.totalDurationNanos = totalDurationNanos; this.transactionCount = transactionCount; this.asyncTransactions = asyncTransactions; this.mainThreadRootTimers = mainThreadRootTimers; this.auxThreadRootTimers = auxThreadRootTimers; this.asyncRootTimers = asyncRootTimers; this.mainThreadStats = mainThreadStats; this.auxThreadStats = auxThreadStats; } /** * @return The value of the {@code captureTime} attribute */ @JsonProperty @Override public long captureTime() { return captureTime; } /** * @return The value of the {@code totalDurationNanos} attribute */ @JsonProperty @Override public double totalDurationNanos() { return totalDurationNanos; } /** * @return The value of the {@code transactionCount} attribute */ @JsonProperty @Override public long transactionCount() { return transactionCount; } /** * @return The value of the {@code asyncTransactions} attribute */ @JsonProperty @Override public boolean asyncTransactions() { return asyncTransactions; } /** * @return The value of the {@code mainThreadRootTimers} attribute */ @JsonProperty @Override public ImmutableList mainThreadRootTimers() { return mainThreadRootTimers; } /** * @return The value of the {@code auxThreadRootTimers} attribute */ @JsonProperty @Override public ImmutableList auxThreadRootTimers() { return auxThreadRootTimers; } /** * @return The value of the {@code asyncRootTimers} attribute */ @JsonProperty @Override public ImmutableList asyncRootTimers() { return asyncRootTimers; } /** * @return The value of the {@code mainThreadStats} attribute */ @JsonProperty @Override public @Nullable AggregateOuterClass.Aggregate.ThreadStats mainThreadStats() { return mainThreadStats; } /** * @return The value of the {@code auxThreadStats} attribute */ @JsonProperty @Override public @Nullable AggregateOuterClass.Aggregate.ThreadStats auxThreadStats() { return auxThreadStats; } /** * Copy the current immutable object by setting a value for the {@link LiveAggregateRepository.OverviewAggregate#captureTime() captureTime} attribute. * A value equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for captureTime * @return A modified copy of the {@code this} object */ public final ImmutableOverviewAggregate withCaptureTime(long value) { if (this.captureTime == value) return this; return new ImmutableOverviewAggregate( value, this.totalDurationNanos, this.transactionCount, this.asyncTransactions, this.mainThreadRootTimers, this.auxThreadRootTimers, this.asyncRootTimers, this.mainThreadStats, this.auxThreadStats); } /** * Copy the current immutable object by setting a value for the {@link LiveAggregateRepository.OverviewAggregate#totalDurationNanos() totalDurationNanos} attribute. * A value strict bits equality used to prevent copying of the same value by returning {@code this}. * @param value A new value for totalDurationNanos * @return A modified copy of the {@code this} object */ public final ImmutableOverviewAggregate withTotalDurationNanos(double value) { if (Double.doubleToLongBits(this.totalDurationNanos) == Double.doubleToLongBits(value)) return this; return new ImmutableOverviewAggregate( this.captureTime, value, this.transactionCount, this.asyncTransactions, this.mainThreadRootTimers, this.auxThreadRootTimers, this.asyncRootTimers, this.mainThreadStats, this.auxThreadStats); } /** * Copy the current immutable object by setting a value for the {@link LiveAggregateRepository.OverviewAggregate#transactionCount() transactionCount} attribute. * A value equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for transactionCount * @return A modified copy of the {@code this} object */ public final ImmutableOverviewAggregate withTransactionCount(long value) { if (this.transactionCount == value) return this; return new ImmutableOverviewAggregate( this.captureTime, this.totalDurationNanos, value, this.asyncTransactions, this.mainThreadRootTimers, this.auxThreadRootTimers, this.asyncRootTimers, this.mainThreadStats, this.auxThreadStats); } /** * Copy the current immutable object by setting a value for the {@link LiveAggregateRepository.OverviewAggregate#asyncTransactions() asyncTransactions} attribute. * A value equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for asyncTransactions * @return A modified copy of the {@code this} object */ public final ImmutableOverviewAggregate withAsyncTransactions(boolean value) { if (this.asyncTransactions == value) return this; return new ImmutableOverviewAggregate( this.captureTime, this.totalDurationNanos, this.transactionCount, value, this.mainThreadRootTimers, this.auxThreadRootTimers, this.asyncRootTimers, this.mainThreadStats, this.auxThreadStats); } /** * Copy the current immutable object with elements that replace the content of {@link LiveAggregateRepository.OverviewAggregate#mainThreadRootTimers() mainThreadRootTimers}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final ImmutableOverviewAggregate withMainThreadRootTimers(AggregateOuterClass.Aggregate.Timer... elements) { ImmutableList newValue = ImmutableList.copyOf(elements); return new ImmutableOverviewAggregate( this.captureTime, this.totalDurationNanos, this.transactionCount, this.asyncTransactions, newValue, this.auxThreadRootTimers, this.asyncRootTimers, this.mainThreadStats, this.auxThreadStats); } /** * Copy the current immutable object with elements that replace the content of {@link LiveAggregateRepository.OverviewAggregate#mainThreadRootTimers() mainThreadRootTimers}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of mainThreadRootTimers elements to set * @return A modified copy of {@code this} object */ public final ImmutableOverviewAggregate withMainThreadRootTimers(Iterable elements) { if (this.mainThreadRootTimers == elements) return this; ImmutableList newValue = ImmutableList.copyOf(elements); return new ImmutableOverviewAggregate( this.captureTime, this.totalDurationNanos, this.transactionCount, this.asyncTransactions, newValue, this.auxThreadRootTimers, this.asyncRootTimers, this.mainThreadStats, this.auxThreadStats); } /** * Copy the current immutable object with elements that replace the content of {@link LiveAggregateRepository.OverviewAggregate#auxThreadRootTimers() auxThreadRootTimers}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final ImmutableOverviewAggregate withAuxThreadRootTimers(AggregateOuterClass.Aggregate.Timer... elements) { ImmutableList newValue = ImmutableList.copyOf(elements); return new ImmutableOverviewAggregate( this.captureTime, this.totalDurationNanos, this.transactionCount, this.asyncTransactions, this.mainThreadRootTimers, newValue, this.asyncRootTimers, this.mainThreadStats, this.auxThreadStats); } /** * Copy the current immutable object with elements that replace the content of {@link LiveAggregateRepository.OverviewAggregate#auxThreadRootTimers() auxThreadRootTimers}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of auxThreadRootTimers elements to set * @return A modified copy of {@code this} object */ public final ImmutableOverviewAggregate withAuxThreadRootTimers(Iterable elements) { if (this.auxThreadRootTimers == elements) return this; ImmutableList newValue = ImmutableList.copyOf(elements); return new ImmutableOverviewAggregate( this.captureTime, this.totalDurationNanos, this.transactionCount, this.asyncTransactions, this.mainThreadRootTimers, newValue, this.asyncRootTimers, this.mainThreadStats, this.auxThreadStats); } /** * Copy the current immutable object with elements that replace the content of {@link LiveAggregateRepository.OverviewAggregate#asyncRootTimers() asyncRootTimers}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final ImmutableOverviewAggregate withAsyncRootTimers(AggregateOuterClass.Aggregate.Timer... elements) { ImmutableList newValue = ImmutableList.copyOf(elements); return new ImmutableOverviewAggregate( this.captureTime, this.totalDurationNanos, this.transactionCount, this.asyncTransactions, this.mainThreadRootTimers, this.auxThreadRootTimers, newValue, this.mainThreadStats, this.auxThreadStats); } /** * Copy the current immutable object with elements that replace the content of {@link LiveAggregateRepository.OverviewAggregate#asyncRootTimers() asyncRootTimers}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of asyncRootTimers elements to set * @return A modified copy of {@code this} object */ public final ImmutableOverviewAggregate withAsyncRootTimers(Iterable elements) { if (this.asyncRootTimers == elements) return this; ImmutableList newValue = ImmutableList.copyOf(elements); return new ImmutableOverviewAggregate( this.captureTime, this.totalDurationNanos, this.transactionCount, this.asyncTransactions, this.mainThreadRootTimers, this.auxThreadRootTimers, newValue, this.mainThreadStats, this.auxThreadStats); } /** * Copy the current immutable object by setting a value for the {@link LiveAggregateRepository.OverviewAggregate#mainThreadStats() mainThreadStats} 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 mainThreadStats (can be {@code null}) * @return A modified copy of the {@code this} object */ public final ImmutableOverviewAggregate withMainThreadStats(@Nullable AggregateOuterClass.Aggregate.ThreadStats value) { if (this.mainThreadStats == value) return this; return new ImmutableOverviewAggregate( this.captureTime, this.totalDurationNanos, this.transactionCount, this.asyncTransactions, this.mainThreadRootTimers, this.auxThreadRootTimers, this.asyncRootTimers, value, this.auxThreadStats); } /** * Copy the current immutable object by setting a value for the {@link LiveAggregateRepository.OverviewAggregate#auxThreadStats() auxThreadStats} 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 auxThreadStats (can be {@code null}) * @return A modified copy of the {@code this} object */ public final ImmutableOverviewAggregate withAuxThreadStats(@Nullable AggregateOuterClass.Aggregate.ThreadStats value) { if (this.auxThreadStats == value) return this; return new ImmutableOverviewAggregate( this.captureTime, this.totalDurationNanos, this.transactionCount, this.asyncTransactions, this.mainThreadRootTimers, this.auxThreadRootTimers, this.asyncRootTimers, this.mainThreadStats, value); } /** * This instance is equal to all instances of {@code ImmutableOverviewAggregate} 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 ImmutableOverviewAggregate && equalTo((ImmutableOverviewAggregate) another); } private boolean equalTo(ImmutableOverviewAggregate another) { return captureTime == another.captureTime && Double.doubleToLongBits(totalDurationNanos) == Double.doubleToLongBits(another.totalDurationNanos) && transactionCount == another.transactionCount && asyncTransactions == another.asyncTransactions && mainThreadRootTimers.equals(another.mainThreadRootTimers) && auxThreadRootTimers.equals(another.auxThreadRootTimers) && asyncRootTimers.equals(another.asyncRootTimers) && Objects.equal(mainThreadStats, another.mainThreadStats) && Objects.equal(auxThreadStats, another.auxThreadStats); } /** * Computes a hash code from attributes: {@code captureTime}, {@code totalDurationNanos}, {@code transactionCount}, {@code asyncTransactions}, {@code mainThreadRootTimers}, {@code auxThreadRootTimers}, {@code asyncRootTimers}, {@code mainThreadStats}, {@code auxThreadStats}. * @return hashCode value */ @Override public int hashCode() { int h = 31; h = h * 17 + Longs.hashCode(captureTime); h = h * 17 + Doubles.hashCode(totalDurationNanos); h = h * 17 + Longs.hashCode(transactionCount); h = h * 17 + Booleans.hashCode(asyncTransactions); h = h * 17 + mainThreadRootTimers.hashCode(); h = h * 17 + auxThreadRootTimers.hashCode(); h = h * 17 + asyncRootTimers.hashCode(); h = h * 17 + Objects.hashCode(mainThreadStats); h = h * 17 + Objects.hashCode(auxThreadStats); return h; } /** * Prints the immutable value {@code OverviewAggregate...} with all non-generated * and non-auxiliary attribute values. * @return A string representation of the value */ @Override public String toString() { return MoreObjects.toStringHelper("OverviewAggregate") .add("captureTime", captureTime) .add("totalDurationNanos", totalDurationNanos) .add("transactionCount", transactionCount) .add("asyncTransactions", asyncTransactions) .add("mainThreadRootTimers", mainThreadRootTimers) .add("auxThreadRootTimers", auxThreadRootTimers) .add("asyncRootTimers", asyncRootTimers) .add("mainThreadStats", mainThreadStats) .add("auxThreadStats", auxThreadStats) .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 static final class Json implements LiveAggregateRepository.OverviewAggregate { @Nullable Long captureTime; @Nullable Double totalDurationNanos; @Nullable Long transactionCount; @Nullable Boolean asyncTransactions; List mainThreadRootTimers = ImmutableList.of(); List auxThreadRootTimers = ImmutableList.of(); List asyncRootTimers = ImmutableList.of(); @Nullable AggregateOuterClass.Aggregate.ThreadStats mainThreadStats; @Nullable AggregateOuterClass.Aggregate.ThreadStats auxThreadStats; @JsonProperty public void setCaptureTime(long captureTime) { this.captureTime = captureTime; } @JsonProperty public void setTotalDurationNanos(double totalDurationNanos) { this.totalDurationNanos = totalDurationNanos; } @JsonProperty public void setTransactionCount(long transactionCount) { this.transactionCount = transactionCount; } @JsonProperty public void setAsyncTransactions(boolean asyncTransactions) { this.asyncTransactions = asyncTransactions; } @JsonProperty public void setMainThreadRootTimers(List mainThreadRootTimers) { this.mainThreadRootTimers = mainThreadRootTimers; } @JsonProperty public void setAuxThreadRootTimers(List auxThreadRootTimers) { this.auxThreadRootTimers = auxThreadRootTimers; } @JsonProperty public void setAsyncRootTimers(List asyncRootTimers) { this.asyncRootTimers = asyncRootTimers; } @JsonProperty public void setMainThreadStats(@Nullable AggregateOuterClass.Aggregate.ThreadStats mainThreadStats) { this.mainThreadStats = mainThreadStats; } @JsonProperty public void setAuxThreadStats(@Nullable AggregateOuterClass.Aggregate.ThreadStats auxThreadStats) { this.auxThreadStats = auxThreadStats; } @Override public long captureTime() { throw new UnsupportedOperationException(); } @Override public double totalDurationNanos() { throw new UnsupportedOperationException(); } @Override public long transactionCount() { throw new UnsupportedOperationException(); } @Override public boolean asyncTransactions() { throw new UnsupportedOperationException(); } @Override public List mainThreadRootTimers() { throw new UnsupportedOperationException(); } @Override public List auxThreadRootTimers() { throw new UnsupportedOperationException(); } @Override public List asyncRootTimers() { throw new UnsupportedOperationException(); } @Override public AggregateOuterClass.Aggregate.ThreadStats mainThreadStats() { throw new UnsupportedOperationException(); } @Override public AggregateOuterClass.Aggregate.ThreadStats auxThreadStats() { 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 static ImmutableOverviewAggregate fromJson(Json json) { ImmutableOverviewAggregate.Builder builder = ImmutableOverviewAggregate.builder(); if (json.captureTime != null) { builder.captureTime(json.captureTime); } if (json.totalDurationNanos != null) { builder.totalDurationNanos(json.totalDurationNanos); } if (json.transactionCount != null) { builder.transactionCount(json.transactionCount); } if (json.asyncTransactions != null) { builder.asyncTransactions(json.asyncTransactions); } if (json.mainThreadRootTimers != null) { builder.addAllMainThreadRootTimers(json.mainThreadRootTimers); } if (json.auxThreadRootTimers != null) { builder.addAllAuxThreadRootTimers(json.auxThreadRootTimers); } if (json.asyncRootTimers != null) { builder.addAllAsyncRootTimers(json.asyncRootTimers); } if (json.mainThreadStats != null) { builder.mainThreadStats(json.mainThreadStats); } if (json.auxThreadStats != null) { builder.auxThreadStats(json.auxThreadStats); } return builder.build(); } /** * Creates an immutable copy of a {@link LiveAggregateRepository.OverviewAggregate} 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 OverviewAggregate instance */ public static ImmutableOverviewAggregate copyOf(LiveAggregateRepository.OverviewAggregate instance) { if (instance instanceof ImmutableOverviewAggregate) { return (ImmutableOverviewAggregate) instance; } return ImmutableOverviewAggregate.builder() .copyFrom(instance) .build(); } /** * Creates a builder for {@link ImmutableOverviewAggregate ImmutableOverviewAggregate}. * @return A new ImmutableOverviewAggregate builder */ public static ImmutableOverviewAggregate.Builder builder() { return new ImmutableOverviewAggregate.Builder(); } /** * Builds instances of type {@link ImmutableOverviewAggregate ImmutableOverviewAggregate}. * 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_CAPTURE_TIME = 0x1L; private static final long INIT_BIT_TOTAL_DURATION_NANOS = 0x2L; private static final long INIT_BIT_TRANSACTION_COUNT = 0x4L; private static final long INIT_BIT_ASYNC_TRANSACTIONS = 0x8L; private long initBits = 0xf; private long captureTime; private double totalDurationNanos; private long transactionCount; private boolean asyncTransactions; private ImmutableList.Builder mainThreadRootTimersBuilder = ImmutableList.builder(); private ImmutableList.Builder auxThreadRootTimersBuilder = ImmutableList.builder(); private ImmutableList.Builder asyncRootTimersBuilder = ImmutableList.builder(); private @Nullable AggregateOuterClass.Aggregate.ThreadStats mainThreadStats; private @Nullable AggregateOuterClass.Aggregate.ThreadStats auxThreadStats; private Builder() { } /** * Fill a builder with attribute values from the provided {@code OverviewAggregate} 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 */ public final Builder copyFrom(LiveAggregateRepository.OverviewAggregate instance) { Preconditions.checkNotNull(instance, "instance"); captureTime(instance.captureTime()); totalDurationNanos(instance.totalDurationNanos()); transactionCount(instance.transactionCount()); asyncTransactions(instance.asyncTransactions()); addAllMainThreadRootTimers(instance.mainThreadRootTimers()); addAllAuxThreadRootTimers(instance.auxThreadRootTimers()); addAllAsyncRootTimers(instance.asyncRootTimers()); @Nullable AggregateOuterClass.Aggregate.ThreadStats mainThreadStatsValue = instance.mainThreadStats(); if (mainThreadStatsValue != null) { mainThreadStats(mainThreadStatsValue); } @Nullable AggregateOuterClass.Aggregate.ThreadStats auxThreadStatsValue = instance.auxThreadStats(); if (auxThreadStatsValue != null) { auxThreadStats(auxThreadStatsValue); } return this; } /** * Initializes the value for the {@link LiveAggregateRepository.OverviewAggregate#captureTime() captureTime} attribute. * @param captureTime The value for captureTime * @return {@code this} builder for use in a chained invocation */ public final Builder captureTime(long captureTime) { this.captureTime = captureTime; initBits &= ~INIT_BIT_CAPTURE_TIME; return this; } /** * Initializes the value for the {@link LiveAggregateRepository.OverviewAggregate#totalDurationNanos() totalDurationNanos} attribute. * @param totalDurationNanos The value for totalDurationNanos * @return {@code this} builder for use in a chained invocation */ public final Builder totalDurationNanos(double totalDurationNanos) { this.totalDurationNanos = totalDurationNanos; initBits &= ~INIT_BIT_TOTAL_DURATION_NANOS; return this; } /** * Initializes the value for the {@link LiveAggregateRepository.OverviewAggregate#transactionCount() transactionCount} attribute. * @param transactionCount The value for transactionCount * @return {@code this} builder for use in a chained invocation */ public final Builder transactionCount(long transactionCount) { this.transactionCount = transactionCount; initBits &= ~INIT_BIT_TRANSACTION_COUNT; return this; } /** * Initializes the value for the {@link LiveAggregateRepository.OverviewAggregate#asyncTransactions() asyncTransactions} attribute. * @param asyncTransactions The value for asyncTransactions * @return {@code this} builder for use in a chained invocation */ public final Builder asyncTransactions(boolean asyncTransactions) { this.asyncTransactions = asyncTransactions; initBits &= ~INIT_BIT_ASYNC_TRANSACTIONS; return this; } /** * Adds one element to {@link LiveAggregateRepository.OverviewAggregate#mainThreadRootTimers() mainThreadRootTimers} list. * @param element A mainThreadRootTimers element * @return {@code this} builder for use in a chained invocation */ public final Builder addMainThreadRootTimers(AggregateOuterClass.Aggregate.Timer element) { mainThreadRootTimersBuilder.add(element); return this; } /** * Adds elements to {@link LiveAggregateRepository.OverviewAggregate#mainThreadRootTimers() mainThreadRootTimers} list. * @param elements An array of mainThreadRootTimers elements * @return {@code this} builder for use in a chained invocation */ public final Builder addMainThreadRootTimers(AggregateOuterClass.Aggregate.Timer... elements) { mainThreadRootTimersBuilder.add(elements); return this; } /** * Sets or replaces all elements for {@link LiveAggregateRepository.OverviewAggregate#mainThreadRootTimers() mainThreadRootTimers} list. * @param elements An iterable of mainThreadRootTimers elements * @return {@code this} builder for use in a chained invocation */ public final Builder mainThreadRootTimers(Iterable elements) { mainThreadRootTimersBuilder = ImmutableList.builder(); return addAllMainThreadRootTimers(elements); } /** * Adds elements to {@link LiveAggregateRepository.OverviewAggregate#mainThreadRootTimers() mainThreadRootTimers} list. * @param elements An iterable of mainThreadRootTimers elements * @return {@code this} builder for use in a chained invocation */ public final Builder addAllMainThreadRootTimers(Iterable elements) { mainThreadRootTimersBuilder.addAll(elements); return this; } /** * Adds one element to {@link LiveAggregateRepository.OverviewAggregate#auxThreadRootTimers() auxThreadRootTimers} list. * @param element A auxThreadRootTimers element * @return {@code this} builder for use in a chained invocation */ public final Builder addAuxThreadRootTimers(AggregateOuterClass.Aggregate.Timer element) { auxThreadRootTimersBuilder.add(element); return this; } /** * Adds elements to {@link LiveAggregateRepository.OverviewAggregate#auxThreadRootTimers() auxThreadRootTimers} list. * @param elements An array of auxThreadRootTimers elements * @return {@code this} builder for use in a chained invocation */ public final Builder addAuxThreadRootTimers(AggregateOuterClass.Aggregate.Timer... elements) { auxThreadRootTimersBuilder.add(elements); return this; } /** * Sets or replaces all elements for {@link LiveAggregateRepository.OverviewAggregate#auxThreadRootTimers() auxThreadRootTimers} list. * @param elements An iterable of auxThreadRootTimers elements * @return {@code this} builder for use in a chained invocation */ public final Builder auxThreadRootTimers(Iterable elements) { auxThreadRootTimersBuilder = ImmutableList.builder(); return addAllAuxThreadRootTimers(elements); } /** * Adds elements to {@link LiveAggregateRepository.OverviewAggregate#auxThreadRootTimers() auxThreadRootTimers} list. * @param elements An iterable of auxThreadRootTimers elements * @return {@code this} builder for use in a chained invocation */ public final Builder addAllAuxThreadRootTimers(Iterable elements) { auxThreadRootTimersBuilder.addAll(elements); return this; } /** * Adds one element to {@link LiveAggregateRepository.OverviewAggregate#asyncRootTimers() asyncRootTimers} list. * @param element A asyncRootTimers element * @return {@code this} builder for use in a chained invocation */ public final Builder addAsyncRootTimers(AggregateOuterClass.Aggregate.Timer element) { asyncRootTimersBuilder.add(element); return this; } /** * Adds elements to {@link LiveAggregateRepository.OverviewAggregate#asyncRootTimers() asyncRootTimers} list. * @param elements An array of asyncRootTimers elements * @return {@code this} builder for use in a chained invocation */ public final Builder addAsyncRootTimers(AggregateOuterClass.Aggregate.Timer... elements) { asyncRootTimersBuilder.add(elements); return this; } /** * Sets or replaces all elements for {@link LiveAggregateRepository.OverviewAggregate#asyncRootTimers() asyncRootTimers} list. * @param elements An iterable of asyncRootTimers elements * @return {@code this} builder for use in a chained invocation */ public final Builder asyncRootTimers(Iterable elements) { asyncRootTimersBuilder = ImmutableList.builder(); return addAllAsyncRootTimers(elements); } /** * Adds elements to {@link LiveAggregateRepository.OverviewAggregate#asyncRootTimers() asyncRootTimers} list. * @param elements An iterable of asyncRootTimers elements * @return {@code this} builder for use in a chained invocation */ public final Builder addAllAsyncRootTimers(Iterable elements) { asyncRootTimersBuilder.addAll(elements); return this; } /** * Initializes the value for the {@link LiveAggregateRepository.OverviewAggregate#mainThreadStats() mainThreadStats} attribute. * @param mainThreadStats The value for mainThreadStats (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ public final Builder mainThreadStats(@Nullable AggregateOuterClass.Aggregate.ThreadStats mainThreadStats) { this.mainThreadStats = mainThreadStats; return this; } /** * Initializes the value for the {@link LiveAggregateRepository.OverviewAggregate#auxThreadStats() auxThreadStats} attribute. * @param auxThreadStats The value for auxThreadStats (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ public final Builder auxThreadStats(@Nullable AggregateOuterClass.Aggregate.ThreadStats auxThreadStats) { this.auxThreadStats = auxThreadStats; return this; } /** * Builds a new {@link ImmutableOverviewAggregate ImmutableOverviewAggregate}. * @return An immutable instance of OverviewAggregate * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableOverviewAggregate build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return new ImmutableOverviewAggregate( captureTime, totalDurationNanos, transactionCount, asyncTransactions, mainThreadRootTimersBuilder.build(), auxThreadRootTimersBuilder.build(), asyncRootTimersBuilder.build(), mainThreadStats, auxThreadStats); } private String formatRequiredAttributesMessage() { List attributes = Lists.newArrayList(); if ((initBits & INIT_BIT_CAPTURE_TIME) != 0) attributes.add("captureTime"); if ((initBits & INIT_BIT_TOTAL_DURATION_NANOS) != 0) attributes.add("totalDurationNanos"); if ((initBits & INIT_BIT_TRANSACTION_COUNT) != 0) attributes.add("transactionCount"); if ((initBits & INIT_BIT_ASYNC_TRANSACTIONS) != 0) attributes.add("asyncTransactions"); return "Cannot build OverviewAggregate, some of required attributes are not set " + attributes; } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy