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

org.glowroot.storage.repo.ImmutableErrorMessageQuery Maven / Gradle / Ivy

There is a newer version: 0.9.28
Show newest version
package org.glowroot.storage.repo;

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.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 TraceRepository.ErrorMessageQuery}.
 * 

* Use builder to create immutable instances: * {@code ImmutableErrorMessageQuery.builder()}. */ @SuppressWarnings("all") @ParametersAreNonnullByDefault @Generated({"Immutables.generator", "TraceRepository.ErrorMessageQuery"}) @Immutable public final class ImmutableErrorMessageQuery implements TraceRepository.ErrorMessageQuery { private final String serverRollup; private final String transactionType; private final @Nullable String transactionName; private final long from; private final long to; private final ImmutableList includes; private final ImmutableList excludes; private final int limit; private ImmutableErrorMessageQuery( String serverRollup, String transactionType, @Nullable String transactionName, long from, long to, ImmutableList includes, ImmutableList excludes, int limit) { this.serverRollup = serverRollup; this.transactionType = transactionType; this.transactionName = transactionName; this.from = from; this.to = to; this.includes = includes; this.excludes = excludes; this.limit = limit; } /** * @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 includes} attribute */ @JsonProperty @Override public ImmutableList includes() { return includes; } /** * @return value of {@code excludes} attribute */ @JsonProperty @Override public ImmutableList excludes() { return excludes; } /** * @return value of {@code limit} attribute */ @JsonProperty @Override public int limit() { return limit; } /** * Copy current immutable object by setting value for {@link TraceRepository.ErrorMessageQuery#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 ImmutableErrorMessageQuery withServerRollup(String value) { if (this.serverRollup == value) return this; String newValue = Preconditions.checkNotNull(value); return new ImmutableErrorMessageQuery( newValue, this.transactionType, this.transactionName, this.from, this.to, this.includes, this.excludes, this.limit); } /** * Copy current immutable object by setting value for {@link TraceRepository.ErrorMessageQuery#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 ImmutableErrorMessageQuery withTransactionType(String value) { if (this.transactionType == value) return this; String newValue = Preconditions.checkNotNull(value); return new ImmutableErrorMessageQuery( this.serverRollup, newValue, this.transactionName, this.from, this.to, this.includes, this.excludes, this.limit); } /** * Copy current immutable object by setting value for {@link TraceRepository.ErrorMessageQuery#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 ImmutableErrorMessageQuery withTransactionName(@Nullable String value) { if (this.transactionName == value) return this; @Nullable String newValue = value; return new ImmutableErrorMessageQuery( this.serverRollup, this.transactionType, newValue, this.from, this.to, this.includes, this.excludes, this.limit); } /** * Copy current immutable object by setting value for {@link TraceRepository.ErrorMessageQuery#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 ImmutableErrorMessageQuery withFrom(long value) { if (this.from == value) return this; long newValue = value; return new ImmutableErrorMessageQuery( this.serverRollup, this.transactionType, this.transactionName, newValue, this.to, this.includes, this.excludes, this.limit); } /** * Copy current immutable object by setting value for {@link TraceRepository.ErrorMessageQuery#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 ImmutableErrorMessageQuery withTo(long value) { if (this.to == value) return this; long newValue = value; return new ImmutableErrorMessageQuery( this.serverRollup, this.transactionType, this.transactionName, this.from, newValue, this.includes, this.excludes, this.limit); } /** * Copy current immutable object with elements that replace content of {@link TraceRepository.ErrorMessageQuery#includes() includes}. * @param elements elements to set * @return modified copy of {@code this} object */ public final ImmutableErrorMessageQuery withIncludes(String... elements) { ImmutableList newValue = ImmutableList.copyOf(elements); return new ImmutableErrorMessageQuery( this.serverRollup, this.transactionType, this.transactionName, this.from, this.to, newValue, this.excludes, this.limit); } /** * Copy current immutable object with elements that replace content of {@link TraceRepository.ErrorMessageQuery#includes() includes}. * Shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements iterable of includes elements to set * @return modified copy of {@code this} object */ public final ImmutableErrorMessageQuery withIncludes(Iterable elements) { if (this.includes == elements) return this; ImmutableList newValue = ImmutableList.copyOf(elements); return new ImmutableErrorMessageQuery( this.serverRollup, this.transactionType, this.transactionName, this.from, this.to, newValue, this.excludes, this.limit); } /** * Copy current immutable object with elements that replace content of {@link TraceRepository.ErrorMessageQuery#excludes() excludes}. * @param elements elements to set * @return modified copy of {@code this} object */ public final ImmutableErrorMessageQuery withExcludes(String... elements) { ImmutableList newValue = ImmutableList.copyOf(elements); return new ImmutableErrorMessageQuery( this.serverRollup, this.transactionType, this.transactionName, this.from, this.to, this.includes, newValue, this.limit); } /** * Copy current immutable object with elements that replace content of {@link TraceRepository.ErrorMessageQuery#excludes() excludes}. * Shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements iterable of excludes elements to set * @return modified copy of {@code this} object */ public final ImmutableErrorMessageQuery withExcludes(Iterable elements) { if (this.excludes == elements) return this; ImmutableList newValue = ImmutableList.copyOf(elements); return new ImmutableErrorMessageQuery( this.serverRollup, this.transactionType, this.transactionName, this.from, this.to, this.includes, newValue, this.limit); } /** * Copy current immutable object by setting value for {@link TraceRepository.ErrorMessageQuery#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 ImmutableErrorMessageQuery withLimit(int value) { if (this.limit == value) return this; int newValue = value; return new ImmutableErrorMessageQuery( this.serverRollup, this.transactionType, this.transactionName, this.from, this.to, this.includes, this.excludes, newValue); } /** * This instance is equal to instances of {@code ImmutableErrorMessageQuery} 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 ImmutableErrorMessageQuery && equalTo((ImmutableErrorMessageQuery) another); } private boolean equalTo(ImmutableErrorMessageQuery another) { return serverRollup.equals(another.serverRollup) && transactionType.equals(another.transactionType) && Objects.equal(transactionName, another.transactionName) && from == another.from && to == another.to && includes.equals(another.includes) && excludes.equals(another.excludes) && limit == another.limit; } /** * Computes hash code from attributes: {@code serverRollup}, {@code transactionType}, {@code transactionName}, {@code from}, {@code to}, {@code includes}, {@code excludes}, {@code limit}. * @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 + includes.hashCode(); h = h * 17 + excludes.hashCode(); h = h * 17 + limit; return h; } /** * Prints immutable value {@code ErrorMessageQuery...} with attribute values, * excluding any non-generated and auxiliary attributes. * @return string representation of value */ @Override public String toString() { return MoreObjects.toStringHelper("ErrorMessageQuery") .add("serverRollup", serverRollup) .add("transactionType", transactionType) .add("transactionName", transactionName) .add("from", from) .add("to", to) .add("includes", includes) .add("excludes", excludes) .add("limit", limit) .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 includes; @JsonProperty @Nullable ImmutableList excludes; @JsonProperty @Nullable Integer limit; } /** * @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 ImmutableErrorMessageQuery fromJson(Json json) { ImmutableErrorMessageQuery.Builder builder = ImmutableErrorMessageQuery.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.includes != null) { builder.addAllIncludes(json.includes); } if (json.excludes != null) { builder.addAllExcludes(json.excludes); } if (json.limit != null) { builder.limit(json.limit); } return builder.build(); } /** * Creates immutable copy of {@link TraceRepository.ErrorMessageQuery}. * 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 ErrorMessageQuery instance */ public static ImmutableErrorMessageQuery copyOf(TraceRepository.ErrorMessageQuery instance) { if (instance instanceof ImmutableErrorMessageQuery) { return (ImmutableErrorMessageQuery) instance; } return ImmutableErrorMessageQuery.builder() .copyFrom(instance) .build(); } /** * Creates builder for {@link org.glowroot.storage.repo.ImmutableErrorMessageQuery ImmutableErrorMessageQuery}. * @return new ImmutableErrorMessageQuery builder */ public static ImmutableErrorMessageQuery.Builder builder() { return new ImmutableErrorMessageQuery.Builder(); } /** * Builds instances of {@link org.glowroot.storage.repo.ImmutableErrorMessageQuery ImmutableErrorMessageQuery}. * 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 public 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_LIMIT = 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 includesBuilder = ImmutableList.builder(); private ImmutableList.Builder excludesBuilder = ImmutableList.builder(); private int limit; private Builder() {} /** * Fill builder with attribute values from provided {@link TraceRepository.ErrorMessageQuery} 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(TraceRepository.ErrorMessageQuery 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()); addAllIncludes(instance.includes()); addAllExcludes(instance.excludes()); limit(instance.limit()); return this; } /** * Initializes value for {@link TraceRepository.ErrorMessageQuery#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 TraceRepository.ErrorMessageQuery#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 TraceRepository.ErrorMessageQuery#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 TraceRepository.ErrorMessageQuery#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 TraceRepository.ErrorMessageQuery#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 TraceRepository.ErrorMessageQuery#includes() includes} list. * @param element includes element * @return {@code this} builder for chained invocation */ public final Builder addIncludes(String element) { includesBuilder.add(element); return this; } /** * Adds elements to {@link TraceRepository.ErrorMessageQuery#includes() includes} list. * @param elements array of includes elements * @return {@code this} builder for chained invocation */ public final Builder addIncludes(String... elements) { includesBuilder.add(elements); return this; } /** * Sets or replaces all elements for {@link TraceRepository.ErrorMessageQuery#includes() includes} list. * @param elements iterable of includes elements * @return {@code this} builder for chained invocation */ public final Builder includes(Iterable elements) { includesBuilder = ImmutableList.builder(); return addAllIncludes(elements); } /** * Adds elements to {@link TraceRepository.ErrorMessageQuery#includes() includes} list. * @param elements iterable of includes elements * @return {@code this} builder for chained invocation */ public final Builder addAllIncludes(Iterable elements) { includesBuilder.addAll(elements); return this; } /** * Adds one element to {@link TraceRepository.ErrorMessageQuery#excludes() excludes} list. * @param element excludes element * @return {@code this} builder for chained invocation */ public final Builder addExcludes(String element) { excludesBuilder.add(element); return this; } /** * Adds elements to {@link TraceRepository.ErrorMessageQuery#excludes() excludes} list. * @param elements array of excludes elements * @return {@code this} builder for chained invocation */ public final Builder addExcludes(String... elements) { excludesBuilder.add(elements); return this; } /** * Sets or replaces all elements for {@link TraceRepository.ErrorMessageQuery#excludes() excludes} list. * @param elements iterable of excludes elements * @return {@code this} builder for chained invocation */ public final Builder excludes(Iterable elements) { excludesBuilder = ImmutableList.builder(); return addAllExcludes(elements); } /** * Adds elements to {@link TraceRepository.ErrorMessageQuery#excludes() excludes} list. * @param elements iterable of excludes elements * @return {@code this} builder for chained invocation */ public final Builder addAllExcludes(Iterable elements) { excludesBuilder.addAll(elements); return this; } /** * Initializes value for {@link TraceRepository.ErrorMessageQuery#limit() limit}. * @param limit value for limit * @return {@code this} builder for chained invocation */ public final Builder limit(int limit) { this.limit = limit; initBits &= ~INIT_BIT_LIMIT; return this; } /** * Builds new {@link org.glowroot.storage.repo.ImmutableErrorMessageQuery ImmutableErrorMessageQuery}. * @return immutable instance of ErrorMessageQuery * @throws exception {@code java.lang.IllegalStateException} if any required attributes are missing */ public ImmutableErrorMessageQuery build() throws IllegalStateException { checkRequiredAttributes(); return new ImmutableErrorMessageQuery( serverRollup, transactionType, transactionName, from, to, includesBuilder.build(), excludesBuilder.build(), limit); } 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 limitIsSet() { return (initBits & INIT_BIT_LIMIT) == 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 (!limitIsSet()) attributes.add("limit"); return "Cannot build ErrorMessageQuery, some of required attributes are not set " + attributes; } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy