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

org.glowroot.local.ui.TransactionDataRequest Maven / Gradle / Ivy

The newest version!
package org.glowroot.local.ui;

import org.glowroot.shaded.fasterxml.jackson.annotation.JsonCreator;
import org.glowroot.shaded.fasterxml.jackson.annotation.JsonProperty;
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.ImmutableList;
import org.glowroot.shaded.google.common.collect.Lists;
import org.glowroot.shaded.google.common.primitives.Doubles;
import org.glowroot.shaded.google.common.primitives.Longs;
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 TransactionJsonService.TransactionDataRequestBase}.
 * 

* Use builder to create immutable instances: * {@code TransactionDataRequest.builder()}. */ @SuppressWarnings("all") @ParametersAreNonnullByDefault @Generated({"Immutables.generator", "TransactionJsonService.TransactionDataRequestBase"}) @Immutable final class TransactionDataRequest extends TransactionJsonService.TransactionDataRequestBase { private final long from; private final long to; private final String transactionType; private final @Nullable String transactionName; private final ImmutableList percentile; private TransactionDataRequest( long from, long to, String transactionType, @Nullable String transactionName, ImmutableList percentile) { this.from = from; this.to = to; this.transactionType = transactionType; this.transactionName = transactionName; this.percentile = percentile; } /** * {@inheritDoc} * @return value of {@code from} attribute */ @JsonProperty("from") @Override public long from() { return from; } /** * {@inheritDoc} * @return value of {@code to} attribute */ @JsonProperty("to") @Override public long to() { return to; } /** * {@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 percentile} attribute */ @JsonProperty("percentile") @Override public ImmutableList percentile() { return percentile; } /** * Copy current immutable object by setting value for {@link TransactionJsonService.TransactionDataRequestBase#from() from}. * Value equality check is used to prevent copying of the same value by returning {@code this}. * @param value new value for from * @return modified copy of the {@code this} object */ public final TransactionDataRequest withFrom(long value) { if (this.from == value) { return this; } long newValue = value; return new TransactionDataRequest(newValue, this.to, this.transactionType, this.transactionName, this.percentile); } /** * Copy current immutable object by setting value for {@link TransactionJsonService.TransactionDataRequestBase#to() to}. * Value equality check is used to prevent copying of the same value by returning {@code this}. * @param value new value for to * @return modified copy of the {@code this} object */ public final TransactionDataRequest withTo(long value) { if (this.to == value) { return this; } long newValue = value; return new TransactionDataRequest(this.from, newValue, this.transactionType, this.transactionName, this.percentile); } /** * Copy current immutable object by setting value for {@link TransactionJsonService.TransactionDataRequestBase#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 TransactionDataRequest withTransactionType(String value) { if (this.transactionType == value) { return this; } String newValue = Preconditions.checkNotNull(value); return new TransactionDataRequest(this.from, this.to, newValue, this.transactionName, this.percentile); } /** * Copy current immutable object by setting value for {@link TransactionJsonService.TransactionDataRequestBase#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 TransactionDataRequest withTransactionName(@Nullable String value) { if (this.transactionName == value) { return this; } @Nullable String newValue = value; return new TransactionDataRequest(this.from, this.to, this.transactionType, newValue, this.percentile); } /** * Copy current immutable object with elements that replace content of {@link TransactionJsonService.TransactionDataRequestBase#percentile() percentile}. * @param elements elements to set * @return modified copy of {@code this} object */ public final TransactionDataRequest withPercentile(double... elements) { ImmutableList newValue = ImmutableList.copyOf(Doubles.asList(elements)); return new TransactionDataRequest(this.from, this.to, this.transactionType, this.transactionName, newValue); } /** * Copy current immutable object with elements that replace content of {@link TransactionJsonService.TransactionDataRequestBase#percentile() percentile}. * Shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements iterable of percentile elements to set * @return modified copy of {@code this} object */ public final TransactionDataRequest withPercentile(Iterable elements) { if (this.percentile == elements) { return this; } ImmutableList newValue = ImmutableList.copyOf(elements); return new TransactionDataRequest(this.from, this.to, this.transactionType, this.transactionName, newValue); } /** * This instance is equal to instances of {@code TransactionDataRequest} 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 TransactionDataRequest && equalTo((TransactionDataRequest) another)); } private boolean equalTo(TransactionDataRequest another) { return from == another.from && to == another.to && transactionType.equals(another.transactionType) && Objects.equal(transactionName, another.transactionName) && percentile.equals(another.percentile); } /** * Computes hash code from attributes: {@code from}, {@code to}, {@code transactionType}, {@code transactionName}, {@code percentile}. * @return hashCode value */ @Override public int hashCode() { int h = 31; h = h * 17 + Longs.hashCode(from); h = h * 17 + Longs.hashCode(to); h = h * 17 + transactionType.hashCode(); h = h * 17 + Objects.hashCode(transactionName); h = h * 17 + percentile.hashCode(); return h; } /** * Prints immutable value {@code TransactionDataRequest{...}} with attribute values, * excluding any non-generated and auxiliary attributes. * @return string representation of value */ @Override public String toString() { return MoreObjects.toStringHelper("TransactionDataRequest") .add("from", from) .add("to", to) .add("transactionType", transactionType) .add("transactionName", transactionName) .add("percentile", percentile) .toString(); } @JsonCreator public static TransactionDataRequest fromAllAttributes( @JsonProperty("from") @Nullable Long from, @JsonProperty("to") @Nullable Long to, @JsonProperty("transactionType") @Nullable String transactionType, @JsonProperty("transactionName") @Nullable String transactionName, @JsonProperty("percentile") @Nullable ImmutableList percentile) { TransactionDataRequest.Builder builder = TransactionDataRequest.builder(); if (from != null) { builder.from(from); } if (to != null) { builder.to(to); } if (transactionType != null) { builder.transactionType(transactionType); } if (transactionName != null) { builder.transactionName(transactionName); } if (percentile != null) { builder.addAllPercentile(percentile); } return builder.build(); } /** * Creates immutable copy of {@link TransactionJsonService.TransactionDataRequestBase}. * 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 TransactionDataRequest instance */ static TransactionDataRequest copyOf(TransactionJsonService.TransactionDataRequestBase instance) { if (instance instanceof TransactionDataRequest) { return (TransactionDataRequest) instance; } return TransactionDataRequest.builder() .from(instance.from()) .to(instance.to()) .transactionType(instance.transactionType()) .transactionName(instance.transactionName()) .addAllPercentile(instance.percentile()) .build(); } /** * Creates builder for {@link org.glowroot.local.ui.TransactionDataRequest}. * @return new TransactionDataRequest builder */ static TransactionDataRequest.Builder builder() { return new TransactionDataRequest.Builder(); } /** * Builds instances of {@link org.glowroot.local.ui.TransactionDataRequest}. * 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 static final class Builder { private static final long INITIALIZED_BITSET_ALL = 0x7; private static final long INITIALIZED_BIT_FROM = 0x1L; private static final long INITIALIZED_BIT_TO = 0x2L; private static final long INITIALIZED_BIT_TRANSACTION_TYPE = 0x4L; private static final long NONDEFAULT_BIT_TRANSACTION_NAME = 0x1L; private long initializedBitset; private long nondefaultBitset; private long from; private long to; private @Nullable String transactionType; private @Nullable String transactionName; private ImmutableList.Builder percentileBuilder = ImmutableList.builder(); private Builder() {} /** * Initializes value for {@link TransactionJsonService.TransactionDataRequestBase#from() from}. * @param from value for from * @return {@code this} builder for chained invocation */ public final Builder from(long from) { checkNotIsSet(fromIsSet(), "from"); this.from = from; initializedBitset |= INITIALIZED_BIT_FROM; return this; } /** * Initializes value for {@link TransactionJsonService.TransactionDataRequestBase#to() to}. * @param to value for to * @return {@code this} builder for chained invocation */ public final Builder to(long to) { checkNotIsSet(toIsSet(), "to"); this.to = to; initializedBitset |= INITIALIZED_BIT_TO; return this; } /** * Initializes value for {@link TransactionJsonService.TransactionDataRequestBase#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 TransactionJsonService.TransactionDataRequestBase#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; } /** * Adds one element to {@link TransactionJsonService.TransactionDataRequestBase#percentile() percentile} list. * @param element percentile element * @return {@code this} builder for chained invocation */ public final Builder addPercentile(double element) { percentileBuilder.add(element); return this; } /** * Adds elements to {@link TransactionJsonService.TransactionDataRequestBase#percentile() percentile} list. * @param elements array of percentile elements * @return {@code this} builder for chained invocation */ public final Builder addPercentile(double... elements) { percentileBuilder.addAll(Doubles.asList(elements)); return this; } /** * Adds elements to {@link TransactionJsonService.TransactionDataRequestBase#percentile() percentile} list. * @param elements iterable of percentile elements * @return {@code this} builder for chained invocation */ public final Builder addAllPercentile(Iterable elements) { percentileBuilder.addAll(elements); return this; } /** * Builds new {@link org.glowroot.local.ui.TransactionDataRequest}. * @return immutable instance of TransactionDataRequest */ public org.glowroot.local.ui.TransactionDataRequest build() { checkRequiredAttributes(); return new TransactionDataRequest(from, to, transactionType, transactionName, percentileBuilder.build()); } private boolean transactionNameIsSet() { return (nondefaultBitset & NONDEFAULT_BIT_TRANSACTION_NAME) != 0; } private boolean fromIsSet() { return (initializedBitset & INITIALIZED_BIT_FROM) != 0; } private boolean toIsSet() { return (initializedBitset & INITIALIZED_BIT_TO) != 0; } private boolean transactionTypeIsSet() { return (initializedBitset & INITIALIZED_BIT_TRANSACTION_TYPE) != 0; } private void checkNotIsSet(boolean isSet, String name) { if (isSet) { throw new IllegalStateException("Builder of TransactionDataRequest 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 (!fromIsSet()) { attributes.add("from"); } if (!toIsSet()) { attributes.add("to"); } if (!transactionTypeIsSet()) { attributes.add("transactionType"); } return "Cannot build TransactionDataRequest, some of required attributes are not set " + attributes; } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy