
org.glowroot.ui.ImmutableTransactionProfileRequest Maven / Gradle / Ivy
package org.glowroot.ui;
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.Objects;
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;
/**
* Immutable implementation of {@link TransactionJsonService.TransactionProfileRequest}.
*
* Use builder to create immutable instances:
* {@code ImmutableTransactionProfileRequest.builder()}.
*/
@SuppressWarnings("all")
@ParametersAreNonnullByDefault
@Generated({"Immutables.generator", "TransactionJsonService.TransactionProfileRequest"})
@Immutable
final class ImmutableTransactionProfileRequest
implements TransactionJsonService.TransactionProfileRequest {
private final String serverRollup;
private final String transactionType;
private final @Nullable String transactionName;
private final long from;
private final long to;
private final ImmutableList include;
private final ImmutableList exclude;
private final double truncateBranchPercentage;
private ImmutableTransactionProfileRequest(
String serverRollup,
String transactionType,
@Nullable String transactionName,
long from,
long to,
ImmutableList include,
ImmutableList exclude,
double truncateBranchPercentage) {
this.serverRollup = serverRollup;
this.transactionType = transactionType;
this.transactionName = transactionName;
this.from = from;
this.to = to;
this.include = include;
this.exclude = exclude;
this.truncateBranchPercentage = truncateBranchPercentage;
}
/**
* @return value of {@code serverRollup} attribute
*/
@JsonProperty
@Override
public String serverRollup() {
return serverRollup;
}
/**
* @return value of {@code transactionType} attribute
*/
@JsonProperty
@Override
public String transactionType() {
return transactionType;
}
/**
* @return value of {@code transactionName} attribute
*/
@JsonProperty
@Override
public @Nullable String transactionName() {
return transactionName;
}
/**
* @return value of {@code from} attribute
*/
@JsonProperty
@Override
public long from() {
return from;
}
/**
* @return value of {@code to} attribute
*/
@JsonProperty
@Override
public long to() {
return to;
}
/**
* @return value of {@code include} attribute
*/
@JsonProperty
@Override
public ImmutableList include() {
return include;
}
/**
* @return value of {@code exclude} attribute
*/
@JsonProperty
@Override
public ImmutableList exclude() {
return exclude;
}
/**
* @return value of {@code truncateBranchPercentage} attribute
*/
@JsonProperty
@Override
public double truncateBranchPercentage() {
return truncateBranchPercentage;
}
/**
* Copy current immutable object by setting value for {@link TransactionJsonService.TransactionProfileRequest#serverRollup() serverRollup}.
* Shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param value new value for serverRollup
* @return modified copy of the {@code this} object
*/
public final ImmutableTransactionProfileRequest withServerRollup(String value) {
if (this.serverRollup == value) return this;
String newValue = Preconditions.checkNotNull(value);
return new ImmutableTransactionProfileRequest(
newValue,
this.transactionType,
this.transactionName,
this.from,
this.to,
this.include,
this.exclude,
this.truncateBranchPercentage);
}
/**
* Copy current immutable object by setting value for {@link TransactionJsonService.TransactionProfileRequest#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 ImmutableTransactionProfileRequest withTransactionType(String value) {
if (this.transactionType == value) return this;
String newValue = Preconditions.checkNotNull(value);
return new ImmutableTransactionProfileRequest(
this.serverRollup,
newValue,
this.transactionName,
this.from,
this.to,
this.include,
this.exclude,
this.truncateBranchPercentage);
}
/**
* Copy current immutable object by setting value for {@link TransactionJsonService.TransactionProfileRequest#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 ImmutableTransactionProfileRequest withTransactionName(@Nullable String value) {
if (this.transactionName == value) return this;
@Nullable String newValue = value;
return new ImmutableTransactionProfileRequest(
this.serverRollup,
this.transactionType,
newValue,
this.from,
this.to,
this.include,
this.exclude,
this.truncateBranchPercentage);
}
/**
* Copy current immutable object by setting value for {@link TransactionJsonService.TransactionProfileRequest#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 ImmutableTransactionProfileRequest withFrom(long value) {
if (this.from == value) return this;
long newValue = value;
return new ImmutableTransactionProfileRequest(
this.serverRollup,
this.transactionType,
this.transactionName,
newValue,
this.to,
this.include,
this.exclude,
this.truncateBranchPercentage);
}
/**
* Copy current immutable object by setting value for {@link TransactionJsonService.TransactionProfileRequest#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 ImmutableTransactionProfileRequest withTo(long value) {
if (this.to == value) return this;
long newValue = value;
return new ImmutableTransactionProfileRequest(
this.serverRollup,
this.transactionType,
this.transactionName,
this.from,
newValue,
this.include,
this.exclude,
this.truncateBranchPercentage);
}
/**
* Copy current immutable object with elements that replace content of {@link TransactionJsonService.TransactionProfileRequest#include() include}.
* @param elements elements to set
* @return modified copy of {@code this} object
*/
public final ImmutableTransactionProfileRequest withInclude(String... elements) {
ImmutableList newValue = ImmutableList.copyOf(elements);
return new ImmutableTransactionProfileRequest(
this.serverRollup,
this.transactionType,
this.transactionName,
this.from,
this.to,
newValue,
this.exclude,
this.truncateBranchPercentage);
}
/**
* Copy current immutable object with elements that replace content of {@link TransactionJsonService.TransactionProfileRequest#include() include}.
* Shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param elements iterable of include elements to set
* @return modified copy of {@code this} object
*/
public final ImmutableTransactionProfileRequest withInclude(Iterable elements) {
if (this.include == elements) return this;
ImmutableList newValue = ImmutableList.copyOf(elements);
return new ImmutableTransactionProfileRequest(
this.serverRollup,
this.transactionType,
this.transactionName,
this.from,
this.to,
newValue,
this.exclude,
this.truncateBranchPercentage);
}
/**
* Copy current immutable object with elements that replace content of {@link TransactionJsonService.TransactionProfileRequest#exclude() exclude}.
* @param elements elements to set
* @return modified copy of {@code this} object
*/
public final ImmutableTransactionProfileRequest withExclude(String... elements) {
ImmutableList newValue = ImmutableList.copyOf(elements);
return new ImmutableTransactionProfileRequest(
this.serverRollup,
this.transactionType,
this.transactionName,
this.from,
this.to,
this.include,
newValue,
this.truncateBranchPercentage);
}
/**
* Copy current immutable object with elements that replace content of {@link TransactionJsonService.TransactionProfileRequest#exclude() exclude}.
* Shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param elements iterable of exclude elements to set
* @return modified copy of {@code this} object
*/
public final ImmutableTransactionProfileRequest withExclude(Iterable elements) {
if (this.exclude == elements) return this;
ImmutableList newValue = ImmutableList.copyOf(elements);
return new ImmutableTransactionProfileRequest(
this.serverRollup,
this.transactionType,
this.transactionName,
this.from,
this.to,
this.include,
newValue,
this.truncateBranchPercentage);
}
/**
* Copy current immutable object by setting value for {@link TransactionJsonService.TransactionProfileRequest#truncateBranchPercentage() truncateBranchPercentage}.
* @param value new value for truncateBranchPercentage
* @return modified copy of the {@code this} object
*/
public final ImmutableTransactionProfileRequest withTruncateBranchPercentage(double value) {
double newValue = value;
return new ImmutableTransactionProfileRequest(
this.serverRollup,
this.transactionType,
this.transactionName,
this.from,
this.to,
this.include,
this.exclude,
newValue);
}
/**
* This instance is equal to instances of {@code ImmutableTransactionProfileRequest} 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 ImmutableTransactionProfileRequest
&& equalTo((ImmutableTransactionProfileRequest) another);
}
private boolean equalTo(ImmutableTransactionProfileRequest another) {
return serverRollup.equals(another.serverRollup)
&& transactionType.equals(another.transactionType)
&& Objects.equal(transactionName, another.transactionName)
&& from == another.from
&& to == another.to
&& include.equals(another.include)
&& exclude.equals(another.exclude)
&& Double.doubleToLongBits(truncateBranchPercentage) == Double.doubleToLongBits(another.truncateBranchPercentage);
}
/**
* Computes hash code from attributes: {@code serverRollup}, {@code transactionType}, {@code transactionName}, {@code from}, {@code to}, {@code include}, {@code exclude}, {@code truncateBranchPercentage}.
* @return hashCode value
*/
@Override
public int hashCode() {
int h = 31;
h = h * 17 + serverRollup.hashCode();
h = h * 17 + transactionType.hashCode();
h = h * 17 + Objects.hashCode(transactionName);
h = h * 17 + Longs.hashCode(from);
h = h * 17 + Longs.hashCode(to);
h = h * 17 + include.hashCode();
h = h * 17 + exclude.hashCode();
h = h * 17 + Doubles.hashCode(truncateBranchPercentage);
return h;
}
/**
* Prints immutable value {@code TransactionProfileRequest...} with attribute values,
* excluding any non-generated and auxiliary attributes.
* @return string representation of value
*/
@Override
public String toString() {
return MoreObjects.toStringHelper("TransactionProfileRequest")
.add("serverRollup", serverRollup)
.add("transactionType", transactionType)
.add("transactionName", transactionName)
.add("from", from)
.add("to", to)
.add("include", include)
.add("exclude", exclude)
.add("truncateBranchPercentage", truncateBranchPercentage)
.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 String serverRollup;
@JsonProperty
@Nullable String transactionType;
@JsonProperty
@Nullable String transactionName;
@JsonProperty
@Nullable Long from;
@JsonProperty
@Nullable Long to;
@JsonProperty
@Nullable ImmutableList include;
@JsonProperty
@Nullable ImmutableList exclude;
@JsonProperty
@Nullable java.lang.Double truncateBranchPercentage;
}
/**
* @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 ImmutableTransactionProfileRequest fromJson(Json json) {
ImmutableTransactionProfileRequest.Builder builder = ImmutableTransactionProfileRequest.builder();
if (json.serverRollup != null) {
builder.serverRollup(json.serverRollup);
}
if (json.transactionType != null) {
builder.transactionType(json.transactionType);
}
if (json.transactionName != null) {
builder.transactionName(json.transactionName);
}
if (json.from != null) {
builder.from(json.from);
}
if (json.to != null) {
builder.to(json.to);
}
if (json.include != null) {
builder.addAllInclude(json.include);
}
if (json.exclude != null) {
builder.addAllExclude(json.exclude);
}
if (json.truncateBranchPercentage != null) {
builder.truncateBranchPercentage(json.truncateBranchPercentage);
}
return builder.build();
}
/**
* Creates immutable copy of {@link TransactionJsonService.TransactionProfileRequest}.
* 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 TransactionProfileRequest instance
*/
static ImmutableTransactionProfileRequest copyOf(TransactionJsonService.TransactionProfileRequest instance) {
if (instance instanceof ImmutableTransactionProfileRequest) {
return (ImmutableTransactionProfileRequest) instance;
}
return ImmutableTransactionProfileRequest.builder()
.copyFrom(instance)
.build();
}
/**
* Creates builder for {@link org.glowroot.ui.ImmutableTransactionProfileRequest ImmutableTransactionProfileRequest}.
* @return new ImmutableTransactionProfileRequest builder
*/
static ImmutableTransactionProfileRequest.Builder builder() {
return new ImmutableTransactionProfileRequest.Builder();
}
/**
* Builds instances of {@link org.glowroot.ui.ImmutableTransactionProfileRequest ImmutableTransactionProfileRequest}.
* 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
static final class Builder {
private static final long INIT_BIT_SERVER_ROLLUP = 0x1L;
private static final long INIT_BIT_TRANSACTION_TYPE = 0x2L;
private static final long INIT_BIT_FROM = 0x4L;
private static final long INIT_BIT_TO = 0x8L;
private static final long INIT_BIT_TRUNCATE_BRANCH_PERCENTAGE = 0x10L;
private long initBits = 0x1f;
private @Nullable String serverRollup;
private @Nullable String transactionType;
private @Nullable String transactionName;
private long from;
private long to;
private ImmutableList.Builder includeBuilder = ImmutableList.builder();
private ImmutableList.Builder excludeBuilder = ImmutableList.builder();
private double truncateBranchPercentage;
private Builder() {}
/**
* Fill builder with attribute values from provided {@link TransactionJsonService.TransactionProfileRequest} 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(TransactionJsonService.TransactionProfileRequest instance) {
Preconditions.checkNotNull(instance);
serverRollup(instance.serverRollup());
transactionType(instance.transactionType());
@Nullable String transactionNameValue = instance.transactionName();
if (transactionNameValue != null) {
transactionName(transactionNameValue);
}
from(instance.from());
to(instance.to());
addAllInclude(instance.include());
addAllExclude(instance.exclude());
truncateBranchPercentage(instance.truncateBranchPercentage());
return this;
}
/**
* Initializes value for {@link TransactionJsonService.TransactionProfileRequest#serverRollup() serverRollup}.
* @param serverRollup value for serverRollup
* @return {@code this} builder for chained invocation
*/
public final Builder serverRollup(String serverRollup) {
this.serverRollup = Preconditions.checkNotNull(serverRollup);
initBits &= ~INIT_BIT_SERVER_ROLLUP;
return this;
}
/**
* Initializes value for {@link TransactionJsonService.TransactionProfileRequest#transactionType() transactionType}.
* @param transactionType value for transactionType
* @return {@code this} builder for chained invocation
*/
public final Builder transactionType(String transactionType) {
this.transactionType = Preconditions.checkNotNull(transactionType);
initBits &= ~INIT_BIT_TRANSACTION_TYPE;
return this;
}
/**
* Initializes value for {@link TransactionJsonService.TransactionProfileRequest#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) {
this.transactionName = transactionName;
return this;
}
/**
* Initializes value for {@link TransactionJsonService.TransactionProfileRequest#from() from}.
* @param from value for from
* @return {@code this} builder for chained invocation
*/
public final Builder from(long from) {
this.from = from;
initBits &= ~INIT_BIT_FROM;
return this;
}
/**
* Initializes value for {@link TransactionJsonService.TransactionProfileRequest#to() to}.
* @param to value for to
* @return {@code this} builder for chained invocation
*/
public final Builder to(long to) {
this.to = to;
initBits &= ~INIT_BIT_TO;
return this;
}
/**
* Adds one element to {@link TransactionJsonService.TransactionProfileRequest#include() include} list.
* @param element include element
* @return {@code this} builder for chained invocation
*/
public final Builder addInclude(String element) {
includeBuilder.add(element);
return this;
}
/**
* Adds elements to {@link TransactionJsonService.TransactionProfileRequest#include() include} list.
* @param elements array of include elements
* @return {@code this} builder for chained invocation
*/
public final Builder addInclude(String... elements) {
includeBuilder.add(elements);
return this;
}
/**
* Sets or replaces all elements for {@link TransactionJsonService.TransactionProfileRequest#include() include} list.
* @param elements iterable of include elements
* @return {@code this} builder for chained invocation
*/
public final Builder include(Iterable elements) {
includeBuilder = ImmutableList.builder();
return addAllInclude(elements);
}
/**
* Adds elements to {@link TransactionJsonService.TransactionProfileRequest#include() include} list.
* @param elements iterable of include elements
* @return {@code this} builder for chained invocation
*/
public final Builder addAllInclude(Iterable elements) {
includeBuilder.addAll(elements);
return this;
}
/**
* Adds one element to {@link TransactionJsonService.TransactionProfileRequest#exclude() exclude} list.
* @param element exclude element
* @return {@code this} builder for chained invocation
*/
public final Builder addExclude(String element) {
excludeBuilder.add(element);
return this;
}
/**
* Adds elements to {@link TransactionJsonService.TransactionProfileRequest#exclude() exclude} list.
* @param elements array of exclude elements
* @return {@code this} builder for chained invocation
*/
public final Builder addExclude(String... elements) {
excludeBuilder.add(elements);
return this;
}
/**
* Sets or replaces all elements for {@link TransactionJsonService.TransactionProfileRequest#exclude() exclude} list.
* @param elements iterable of exclude elements
* @return {@code this} builder for chained invocation
*/
public final Builder exclude(Iterable elements) {
excludeBuilder = ImmutableList.builder();
return addAllExclude(elements);
}
/**
* Adds elements to {@link TransactionJsonService.TransactionProfileRequest#exclude() exclude} list.
* @param elements iterable of exclude elements
* @return {@code this} builder for chained invocation
*/
public final Builder addAllExclude(Iterable elements) {
excludeBuilder.addAll(elements);
return this;
}
/**
* Initializes value for {@link TransactionJsonService.TransactionProfileRequest#truncateBranchPercentage() truncateBranchPercentage}.
* @param truncateBranchPercentage value for truncateBranchPercentage
* @return {@code this} builder for chained invocation
*/
public final Builder truncateBranchPercentage(double truncateBranchPercentage) {
this.truncateBranchPercentage = truncateBranchPercentage;
initBits &= ~INIT_BIT_TRUNCATE_BRANCH_PERCENTAGE;
return this;
}
/**
* Builds new {@link org.glowroot.ui.ImmutableTransactionProfileRequest ImmutableTransactionProfileRequest}.
* @return immutable instance of TransactionProfileRequest
* @throws exception {@code java.lang.IllegalStateException} if any required attributes are missing
*/
public ImmutableTransactionProfileRequest build()
throws IllegalStateException {
checkRequiredAttributes();
return new ImmutableTransactionProfileRequest(
serverRollup,
transactionType,
transactionName,
from,
to,
includeBuilder.build(),
excludeBuilder.build(),
truncateBranchPercentage);
}
private boolean serverRollupIsSet() {
return (initBits & INIT_BIT_SERVER_ROLLUP) == 0;
}
private boolean transactionTypeIsSet() {
return (initBits & INIT_BIT_TRANSACTION_TYPE) == 0;
}
private boolean fromIsSet() {
return (initBits & INIT_BIT_FROM) == 0;
}
private boolean toIsSet() {
return (initBits & INIT_BIT_TO) == 0;
}
private boolean truncateBranchPercentageIsSet() {
return (initBits & INIT_BIT_TRUNCATE_BRANCH_PERCENTAGE) == 0;
}
private void checkRequiredAttributes() throws IllegalStateException {
if (initBits != 0) {
throw new IllegalStateException(formatRequiredAttributesMessage());
}
}
private String formatRequiredAttributesMessage() {
List attributes = Lists.newArrayList();
if (!serverRollupIsSet()) attributes.add("serverRollup");
if (!transactionTypeIsSet()) attributes.add("transactionType");
if (!fromIsSet()) attributes.add("from");
if (!toIsSet()) attributes.add("to");
if (!truncateBranchPercentageIsSet()) attributes.add("truncateBranchPercentage");
return "Cannot build TransactionProfileRequest, some of required attributes are not set " + attributes;
}
}
}