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

org.glowroot.local.store.TransactionSummaryQuery Maven / Gradle / Ivy

The newest version!
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.TransactionSummaryQueryBase}.
 * 

* Use builder to create immutable instances: * {@code TransactionSummaryQuery.builder()}. */ @SuppressWarnings("all") @ParametersAreNonnullByDefault @Generated({"Immutables.generator", "AggregateDao.TransactionSummaryQueryBase"}) @Immutable public final class TransactionSummaryQuery extends AggregateDao.TransactionSummaryQueryBase { private final String transactionType; private final long from; private final long to; private final AggregateDao.TransactionSummarySortOrder sortOrder; private final int limit; private TransactionSummaryQuery( String transactionType, long from, long to, AggregateDao.TransactionSummarySortOrder 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.TransactionSummarySortOrder 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.TransactionSummaryQueryBase#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 TransactionSummaryQuery withTransactionType(String value) { if (this.transactionType == value) { return this; } String newValue = Preconditions.checkNotNull(value); return new TransactionSummaryQuery(newValue, this.from, this.to, this.sortOrder, this.limit); } /** * Copy current immutable object by setting value for {@link AggregateDao.TransactionSummaryQueryBase#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 TransactionSummaryQuery withFrom(long value) { if (this.from == value) { return this; } long newValue = value; return new TransactionSummaryQuery(this.transactionType, newValue, this.to, this.sortOrder, this.limit); } /** * Copy current immutable object by setting value for {@link AggregateDao.TransactionSummaryQueryBase#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 TransactionSummaryQuery withTo(long value) { if (this.to == value) { return this; } long newValue = value; return new TransactionSummaryQuery(this.transactionType, this.from, newValue, this.sortOrder, this.limit); } /** * Copy current immutable object by setting value for {@link AggregateDao.TransactionSummaryQueryBase#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 TransactionSummaryQuery withSortOrder(AggregateDao.TransactionSummarySortOrder value) { if (this.sortOrder == value) { return this; } AggregateDao.TransactionSummarySortOrder newValue = Preconditions.checkNotNull(value); return new TransactionSummaryQuery(this.transactionType, this.from, this.to, newValue, this.limit); } /** * Copy current immutable object by setting value for {@link AggregateDao.TransactionSummaryQueryBase#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 TransactionSummaryQuery withLimit(int value) { if (this.limit == value) { return this; } int newValue = value; return new TransactionSummaryQuery(this.transactionType, this.from, this.to, this.sortOrder, newValue); } /** * This instance is equal to instances of {@code TransactionSummaryQuery} 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 TransactionSummaryQuery && equalTo((TransactionSummaryQuery) another)); } private boolean equalTo(TransactionSummaryQuery 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 TransactionSummaryQuery{...}} with attribute values, * excluding any non-generated and auxiliary attributes. * @return string representation of value */ @Override public String toString() { return MoreObjects.toStringHelper("TransactionSummaryQuery") .add("transactionType", transactionType) .add("from", from) .add("to", to) .add("sortOrder", sortOrder) .add("limit", limit) .toString(); } @JsonCreator public static TransactionSummaryQuery fromAllAttributes( @JsonProperty("transactionType") @Nullable String transactionType, @JsonProperty("from") @Nullable Long from, @JsonProperty("to") @Nullable Long to, @JsonProperty("sortOrder") @Nullable AggregateDao.TransactionSummarySortOrder sortOrder, @JsonProperty("limit") @Nullable Integer limit) { TransactionSummaryQuery.Builder builder = TransactionSummaryQuery.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.TransactionSummaryQueryBase}. * 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 TransactionSummaryQuery instance */ public static TransactionSummaryQuery copyOf(AggregateDao.TransactionSummaryQueryBase instance) { if (instance instanceof TransactionSummaryQuery) { return (TransactionSummaryQuery) instance; } return TransactionSummaryQuery.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.TransactionSummaryQuery}. * @return new TransactionSummaryQuery builder */ public static TransactionSummaryQuery.Builder builder() { return new TransactionSummaryQuery.Builder(); } /** * Builds instances of {@link org.glowroot.local.store.TransactionSummaryQuery}. * 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.TransactionSummarySortOrder sortOrder; private int limit; private Builder() {} /** * Initializes value for {@link AggregateDao.TransactionSummaryQueryBase#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.TransactionSummaryQueryBase#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.TransactionSummaryQueryBase#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.TransactionSummaryQueryBase#sortOrder() sortOrder}. * @param sortOrder value for sortOrder * @return {@code this} builder for chained invocation */ public final Builder sortOrder(AggregateDao.TransactionSummarySortOrder sortOrder) { checkNotIsSet(sortOrderIsSet(), "sortOrder"); this.sortOrder = Preconditions.checkNotNull(sortOrder); initializedBitset |= INITIALIZED_BIT_SORT_ORDER; return this; } /** * Initializes value for {@link AggregateDao.TransactionSummaryQueryBase#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.TransactionSummaryQuery}. * @return immutable instance of TransactionSummaryQuery */ public TransactionSummaryQuery build() { checkRequiredAttributes(); return new TransactionSummaryQuery(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 TransactionSummaryQuery 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 TransactionSummaryQuery, some of required attributes are not set " + attributes; } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy