org.glowroot.local.store.ErrorSummaryQuery Maven / Gradle / Ivy
package org.glowroot.local.store;
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.Preconditions;
import org.glowroot.shaded.google.common.collect.Lists;
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 AggregateDao.ErrorSummaryQueryBase}.
*
* Use builder to create immutable instances:
* {@code ErrorSummaryQuery.builder()}.
*/
@SuppressWarnings("all")
@ParametersAreNonnullByDefault
@Generated({"Immutables.generator", "AggregateDao.ErrorSummaryQueryBase"})
@Immutable
public final class ErrorSummaryQuery extends AggregateDao.ErrorSummaryQueryBase {
private final String transactionType;
private final long from;
private final long to;
private final AggregateDao.ErrorSummarySortOrder sortOrder;
private final int limit;
private ErrorSummaryQuery(
String transactionType,
long from,
long to,
AggregateDao.ErrorSummarySortOrder sortOrder,
int limit) {
this.transactionType = transactionType;
this.from = from;
this.to = to;
this.sortOrder = sortOrder;
this.limit = limit;
}
/**
* {@inheritDoc}
* @return value of {@code transactionType} attribute
*/
@JsonProperty("transactionType")
@Override
public String transactionType() {
return transactionType;
}
/**
* {@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 sortOrder} attribute
*/
@JsonProperty("sortOrder")
@Override
public AggregateDao.ErrorSummarySortOrder sortOrder() {
return sortOrder;
}
/**
* {@inheritDoc}
* @return value of {@code limit} attribute
*/
@JsonProperty("limit")
@Override
public int limit() {
return limit;
}
/**
* Copy current immutable object by setting value for {@link AggregateDao.ErrorSummaryQueryBase#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 ErrorSummaryQuery withTransactionType(String value) {
if (this.transactionType == value) {
return this;
}
String newValue = Preconditions.checkNotNull(value);
return new ErrorSummaryQuery(newValue, this.from, this.to, this.sortOrder, this.limit);
}
/**
* Copy current immutable object by setting value for {@link AggregateDao.ErrorSummaryQueryBase#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 ErrorSummaryQuery withFrom(long value) {
if (this.from == value) {
return this;
}
long newValue = value;
return new ErrorSummaryQuery(this.transactionType, newValue, this.to, this.sortOrder, this.limit);
}
/**
* Copy current immutable object by setting value for {@link AggregateDao.ErrorSummaryQueryBase#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 ErrorSummaryQuery withTo(long value) {
if (this.to == value) {
return this;
}
long newValue = value;
return new ErrorSummaryQuery(this.transactionType, this.from, newValue, this.sortOrder, this.limit);
}
/**
* Copy current immutable object by setting value for {@link AggregateDao.ErrorSummaryQueryBase#sortOrder() sortOrder}.
* Shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param value new value for sortOrder
* @return modified copy of the {@code this} object
*/
public final ErrorSummaryQuery withSortOrder(AggregateDao.ErrorSummarySortOrder value) {
if (this.sortOrder == value) {
return this;
}
AggregateDao.ErrorSummarySortOrder newValue = Preconditions.checkNotNull(value);
return new ErrorSummaryQuery(this.transactionType, this.from, this.to, newValue, this.limit);
}
/**
* Copy current immutable object by setting value for {@link AggregateDao.ErrorSummaryQueryBase#limit() limit}.
* Value equality check is used to prevent copying of the same value by returning {@code this}.
* @param value new value for limit
* @return modified copy of the {@code this} object
*/
public final ErrorSummaryQuery withLimit(int value) {
if (this.limit == value) {
return this;
}
int newValue = value;
return new ErrorSummaryQuery(this.transactionType, this.from, this.to, this.sortOrder, newValue);
}
/**
* This instance is equal to instances of {@code ErrorSummaryQuery} 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 ErrorSummaryQuery && equalTo((ErrorSummaryQuery) another));
}
private boolean equalTo(ErrorSummaryQuery another) {
return transactionType.equals(another.transactionType)
&& from == another.from
&& to == another.to
&& sortOrder.equals(another.sortOrder)
&& limit == another.limit;
}
/**
* Computes hash code from attributes: {@code transactionType}, {@code from}, {@code to}, {@code sortOrder}, {@code limit}.
* @return hashCode value
*/
@Override
public int hashCode() {
int h = 31;
h = h * 17 + transactionType.hashCode();
h = h * 17 + Longs.hashCode(from);
h = h * 17 + Longs.hashCode(to);
h = h * 17 + sortOrder.hashCode();
h = h * 17 + limit;
return h;
}
/**
* Prints immutable value {@code ErrorSummaryQuery{...}} with attribute values,
* excluding any non-generated and auxiliary attributes.
* @return string representation of value
*/
@Override
public String toString() {
return MoreObjects.toStringHelper("ErrorSummaryQuery")
.add("transactionType", transactionType)
.add("from", from)
.add("to", to)
.add("sortOrder", sortOrder)
.add("limit", limit)
.toString();
}
@JsonCreator
public static ErrorSummaryQuery fromAllAttributes(
@JsonProperty("transactionType") @Nullable String transactionType,
@JsonProperty("from") @Nullable Long from,
@JsonProperty("to") @Nullable Long to,
@JsonProperty("sortOrder") @Nullable AggregateDao.ErrorSummarySortOrder sortOrder,
@JsonProperty("limit") @Nullable Integer limit) {
ErrorSummaryQuery.Builder builder = ErrorSummaryQuery.builder();
if (transactionType != null) {
builder.transactionType(transactionType);
}
if (from != null) {
builder.from(from);
}
if (to != null) {
builder.to(to);
}
if (sortOrder != null) {
builder.sortOrder(sortOrder);
}
if (limit != null) {
builder.limit(limit);
}
return builder.build();
}
/**
* Creates immutable copy of {@link AggregateDao.ErrorSummaryQueryBase}.
* 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 ErrorSummaryQuery instance
*/
public static ErrorSummaryQuery copyOf(AggregateDao.ErrorSummaryQueryBase instance) {
if (instance instanceof ErrorSummaryQuery) {
return (ErrorSummaryQuery) instance;
}
return ErrorSummaryQuery.builder()
.transactionType(instance.transactionType())
.from(instance.from())
.to(instance.to())
.sortOrder(instance.sortOrder())
.limit(instance.limit())
.build();
}
/**
* Creates builder for {@link org.glowroot.local.store.ErrorSummaryQuery}.
* @return new ErrorSummaryQuery builder
*/
public static ErrorSummaryQuery.Builder builder() {
return new ErrorSummaryQuery.Builder();
}
/**
* Builds instances of {@link org.glowroot.local.store.ErrorSummaryQuery}.
* 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 = 0x1f;
private static final long INITIALIZED_BIT_TRANSACTION_TYPE = 0x1L;
private static final long INITIALIZED_BIT_FROM = 0x2L;
private static final long INITIALIZED_BIT_TO = 0x4L;
private static final long INITIALIZED_BIT_SORT_ORDER = 0x8L;
private static final long INITIALIZED_BIT_LIMIT = 0x10L;
private long initializedBitset;
private @Nullable String transactionType;
private long from;
private long to;
private @Nullable AggregateDao.ErrorSummarySortOrder sortOrder;
private int limit;
private Builder() {}
/**
* Initializes value for {@link AggregateDao.ErrorSummaryQueryBase#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 AggregateDao.ErrorSummaryQueryBase#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 AggregateDao.ErrorSummaryQueryBase#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 AggregateDao.ErrorSummaryQueryBase#sortOrder() sortOrder}.
* @param sortOrder value for sortOrder
* @return {@code this} builder for chained invocation
*/
public final Builder sortOrder(AggregateDao.ErrorSummarySortOrder sortOrder) {
checkNotIsSet(sortOrderIsSet(), "sortOrder");
this.sortOrder = Preconditions.checkNotNull(sortOrder);
initializedBitset |= INITIALIZED_BIT_SORT_ORDER;
return this;
}
/**
* Initializes value for {@link AggregateDao.ErrorSummaryQueryBase#limit() limit}.
* @param limit value for limit
* @return {@code this} builder for chained invocation
*/
public final Builder limit(int limit) {
checkNotIsSet(limitIsSet(), "limit");
this.limit = limit;
initializedBitset |= INITIALIZED_BIT_LIMIT;
return this;
}
/**
* Builds new {@link org.glowroot.local.store.ErrorSummaryQuery}.
* @return immutable instance of ErrorSummaryQuery
*/
public ErrorSummaryQuery build() {
checkRequiredAttributes();
return new ErrorSummaryQuery(transactionType, from, to, sortOrder, limit);
}
private boolean transactionTypeIsSet() {
return (initializedBitset & INITIALIZED_BIT_TRANSACTION_TYPE) != 0;
}
private boolean fromIsSet() {
return (initializedBitset & INITIALIZED_BIT_FROM) != 0;
}
private boolean toIsSet() {
return (initializedBitset & INITIALIZED_BIT_TO) != 0;
}
private boolean sortOrderIsSet() {
return (initializedBitset & INITIALIZED_BIT_SORT_ORDER) != 0;
}
private boolean limitIsSet() {
return (initializedBitset & INITIALIZED_BIT_LIMIT) != 0;
}
private void checkNotIsSet(boolean isSet, String name) {
if (isSet) {
throw new IllegalStateException("Builder of ErrorSummaryQuery 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 (!fromIsSet()) {
attributes.add("from");
}
if (!toIsSet()) {
attributes.add("to");
}
if (!sortOrderIsSet()) {
attributes.add("sortOrder");
}
if (!limitIsSet()) {
attributes.add("limit");
}
return "Cannot build ErrorSummaryQuery, some of required attributes are not set " + attributes;
}
}
}