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

org.glowroot.agent.fat.storage.ImmutableMutableTransactionAggregate Maven / Gradle / Ivy

There is a newer version: 0.9.24
Show newest version
package org.glowroot.agent.fat.storage;

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.Lists;
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.agent.shaded.glowroot.storage.repo.MutableAggregate;

/**
 * Immutable implementation of {@link AggregateDao.MutableTransactionAggregate}.
 * 

* Use the builder to create immutable instances: * {@code ImmutableMutableTransactionAggregate.builder()}. * Use the static factory method to create immutable instances: * {@code ImmutableMutableTransactionAggregate.of()}. */ @SuppressWarnings("all") @ParametersAreNonnullByDefault @Generated({"Immutables.generator", "AggregateDao.MutableTransactionAggregate"}) @Immutable final class ImmutableMutableTransactionAggregate implements AggregateDao.MutableTransactionAggregate { private final String transactionType; private final String transactionName; private final MutableAggregate aggregate; private ImmutableMutableTransactionAggregate( String transactionType, String transactionName, MutableAggregate aggregate) { this.transactionType = Preconditions.checkNotNull(transactionType, "transactionType"); this.transactionName = Preconditions.checkNotNull(transactionName, "transactionName"); this.aggregate = Preconditions.checkNotNull(aggregate, "aggregate"); } private ImmutableMutableTransactionAggregate( ImmutableMutableTransactionAggregate original, String transactionType, String transactionName, MutableAggregate aggregate) { this.transactionType = transactionType; this.transactionName = transactionName; this.aggregate = aggregate; } /** * @return The value of the {@code transactionType} attribute */ @JsonProperty @Override public String transactionType() { return transactionType; } /** * @return The value of the {@code transactionName} attribute */ @JsonProperty @Override public String transactionName() { return transactionName; } /** * @return The value of the {@code aggregate} attribute */ @JsonProperty @Override public MutableAggregate aggregate() { return aggregate; } /** * Copy the current immutable object by setting a value for the {@link AggregateDao.MutableTransactionAggregate#transactionType() transactionType} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for transactionType * @return A modified copy of the {@code this} object */ public final ImmutableMutableTransactionAggregate withTransactionType(String value) { if (this.transactionType.equals(value)) return this; return new ImmutableMutableTransactionAggregate( this, Preconditions.checkNotNull(value, "transactionType"), this.transactionName, this.aggregate); } /** * Copy the current immutable object by setting a value for the {@link AggregateDao.MutableTransactionAggregate#transactionName() transactionName} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for transactionName * @return A modified copy of the {@code this} object */ public final ImmutableMutableTransactionAggregate withTransactionName(String value) { if (this.transactionName.equals(value)) return this; return new ImmutableMutableTransactionAggregate( this, this.transactionType, Preconditions.checkNotNull(value, "transactionName"), this.aggregate); } /** * Copy the current immutable object by setting a value for the {@link AggregateDao.MutableTransactionAggregate#aggregate() aggregate} 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 aggregate * @return A modified copy of the {@code this} object */ public final ImmutableMutableTransactionAggregate withAggregate(MutableAggregate value) { if (this.aggregate == value) return this; return new ImmutableMutableTransactionAggregate( this, this.transactionType, this.transactionName, Preconditions.checkNotNull(value, "aggregate")); } /** * This instance is equal to all instances of {@code ImmutableMutableTransactionAggregate} 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 ImmutableMutableTransactionAggregate && equalTo((ImmutableMutableTransactionAggregate) another); } private boolean equalTo(ImmutableMutableTransactionAggregate another) { return transactionType.equals(another.transactionType) && transactionName.equals(another.transactionName) && aggregate.equals(another.aggregate); } /** * Computes a hash code from attributes: {@code transactionType}, {@code transactionName}, {@code aggregate}. * @return hashCode value */ @Override public int hashCode() { int h = 31; h = h * 17 + transactionType.hashCode(); h = h * 17 + transactionName.hashCode(); h = h * 17 + aggregate.hashCode(); return h; } /** * Prints the immutable value {@code MutableTransactionAggregate...} with all non-generated * and non-auxiliary attribute values. * @return A string representation of the value */ @Override public String toString() { return MoreObjects.toStringHelper("MutableTransactionAggregate") .add("transactionType", transactionType) .add("transactionName", transactionName) .add("aggregate", aggregate) .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 AggregateDao.MutableTransactionAggregate { @Nullable String transactionType; @Nullable String transactionName; @Nullable MutableAggregate aggregate; @JsonProperty public void setTransactionType(String transactionType) { this.transactionType = transactionType; } @JsonProperty public void setTransactionName(String transactionName) { this.transactionName = transactionName; } @JsonProperty public void setAggregate(MutableAggregate aggregate) { this.aggregate = aggregate; } @Override public String transactionType() { throw new UnsupportedOperationException(); } @Override public String transactionName() { throw new UnsupportedOperationException(); } @Override public MutableAggregate aggregate() { 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 ImmutableMutableTransactionAggregate fromJson(Json json) { ImmutableMutableTransactionAggregate.Builder builder = ImmutableMutableTransactionAggregate.builder(); if (json.transactionType != null) { builder.transactionType(json.transactionType); } if (json.transactionName != null) { builder.transactionName(json.transactionName); } if (json.aggregate != null) { builder.aggregate(json.aggregate); } return builder.build(); } /** * Construct a new immutable {@code MutableTransactionAggregate} instance. * @param transactionType The value for the {@code transactionType} attribute * @param transactionName The value for the {@code transactionName} attribute * @param aggregate The value for the {@code aggregate} attribute * @return An immutable MutableTransactionAggregate instance */ public static ImmutableMutableTransactionAggregate of(String transactionType, String transactionName, MutableAggregate aggregate) { return new ImmutableMutableTransactionAggregate(transactionType, transactionName, aggregate); } /** * Creates an immutable copy of a {@link AggregateDao.MutableTransactionAggregate} 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 MutableTransactionAggregate instance */ public static ImmutableMutableTransactionAggregate copyOf(AggregateDao.MutableTransactionAggregate instance) { if (instance instanceof ImmutableMutableTransactionAggregate) { return (ImmutableMutableTransactionAggregate) instance; } return ImmutableMutableTransactionAggregate.builder() .copyFrom(instance) .build(); } /** * Creates a builder for {@link ImmutableMutableTransactionAggregate ImmutableMutableTransactionAggregate}. * @return A new ImmutableMutableTransactionAggregate builder */ public static ImmutableMutableTransactionAggregate.Builder builder() { return new ImmutableMutableTransactionAggregate.Builder(); } /** * Builds instances of type {@link ImmutableMutableTransactionAggregate ImmutableMutableTransactionAggregate}. * 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 static final class Builder { private static final long INIT_BIT_TRANSACTION_TYPE = 0x1L; private static final long INIT_BIT_TRANSACTION_NAME = 0x2L; private static final long INIT_BIT_AGGREGATE = 0x4L; private long initBits = 0x7; private @Nullable String transactionType; private @Nullable String transactionName; private @Nullable MutableAggregate aggregate; private Builder() { } /** * Fill a builder with attribute values from the provided {@code MutableTransactionAggregate} instance. * Regular attribute values will be replaced with those from the given instance. * Absent optional values will not replace present values. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ public final Builder copyFrom(AggregateDao.MutableTransactionAggregate instance) { Preconditions.checkNotNull(instance, "instance"); transactionType(instance.transactionType()); transactionName(instance.transactionName()); aggregate(instance.aggregate()); return this; } /** * Initializes the value for the {@link AggregateDao.MutableTransactionAggregate#transactionType() transactionType} attribute. * @param transactionType The value for transactionType * @return {@code this} builder for use in a chained invocation */ public final Builder transactionType(String transactionType) { this.transactionType = Preconditions.checkNotNull(transactionType, "transactionType"); initBits &= ~INIT_BIT_TRANSACTION_TYPE; return this; } /** * Initializes the value for the {@link AggregateDao.MutableTransactionAggregate#transactionName() transactionName} attribute. * @param transactionName The value for transactionName * @return {@code this} builder for use in a chained invocation */ public final Builder transactionName(String transactionName) { this.transactionName = Preconditions.checkNotNull(transactionName, "transactionName"); initBits &= ~INIT_BIT_TRANSACTION_NAME; return this; } /** * Initializes the value for the {@link AggregateDao.MutableTransactionAggregate#aggregate() aggregate} attribute. * @param aggregate The value for aggregate * @return {@code this} builder for use in a chained invocation */ public final Builder aggregate(MutableAggregate aggregate) { this.aggregate = Preconditions.checkNotNull(aggregate, "aggregate"); initBits &= ~INIT_BIT_AGGREGATE; return this; } /** * Builds a new {@link ImmutableMutableTransactionAggregate ImmutableMutableTransactionAggregate}. * @return An immutable instance of MutableTransactionAggregate * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableMutableTransactionAggregate build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return new ImmutableMutableTransactionAggregate(null, transactionType, transactionName, aggregate); } private String formatRequiredAttributesMessage() { List attributes = Lists.newArrayList(); if ((initBits & INIT_BIT_TRANSACTION_TYPE) != 0) attributes.add("transactionType"); if ((initBits & INIT_BIT_TRANSACTION_NAME) != 0) attributes.add("transactionName"); if ((initBits & INIT_BIT_AGGREGATE) != 0) attributes.add("aggregate"); return "Cannot build MutableTransactionAggregate, some of required attributes are not set " + attributes; } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy