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

org.glowroot.central.repo.ImmutableTable Maven / Gradle / Ivy

The newest version!
package org.glowroot.central.repo;

import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.base.MoreObjects;
import com.google.common.collect.ImmutableList;
import com.google.common.primitives.Booleans;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.errorprone.annotations.Var;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import javax.annotation.CheckReturnValue;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import javax.annotation.concurrent.Immutable;
import javax.annotation.concurrent.NotThreadSafe;
import org.immutables.value.Generated;

/**
 * Immutable implementation of {@link AggregateDaoImpl.Table}.
 * 

* Use the builder to create immutable instances: * {@code ImmutableTable.builder()}. */ @Generated(from = "AggregateDaoImpl.Table", generator = "Immutables") @SuppressWarnings({"all"}) @ParametersAreNonnullByDefault @javax.annotation.Generated("org.immutables.processor.ProxyProcessor") @Immutable @CheckReturnValue final class ImmutableTable implements AggregateDaoImpl.Table { private final String partialName; private final ImmutableList columns; private final ImmutableList clusterKey; private final boolean summary; private final boolean fromInclusive; private ImmutableTable( String partialName, ImmutableList columns, ImmutableList clusterKey, boolean summary, boolean fromInclusive) { this.partialName = partialName; this.columns = columns; this.clusterKey = clusterKey; this.summary = summary; this.fromInclusive = fromInclusive; } /** * @return The value of the {@code partialName} attribute */ @JsonProperty("partialName") @Override public String partialName() { return partialName; } /** * @return The value of the {@code columns} attribute */ @JsonProperty("columns") @Override public ImmutableList columns() { return columns; } /** * @return The value of the {@code clusterKey} attribute */ @JsonProperty("clusterKey") @Override public ImmutableList clusterKey() { return clusterKey; } /** * @return The value of the {@code summary} attribute */ @JsonProperty("summary") @Override public boolean summary() { return summary; } /** * @return The value of the {@code fromInclusive} attribute */ @JsonProperty("fromInclusive") @Override public boolean fromInclusive() { return fromInclusive; } /** * Copy the current immutable object by setting a value for the {@link AggregateDaoImpl.Table#partialName() partialName} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for partialName * @return A modified copy of the {@code this} object */ public final ImmutableTable withPartialName(String value) { String newValue = Objects.requireNonNull(value, "partialName"); if (this.partialName.equals(newValue)) return this; return new ImmutableTable(newValue, this.columns, this.clusterKey, this.summary, this.fromInclusive); } /** * Copy the current immutable object with elements that replace the content of {@link AggregateDaoImpl.Table#columns() columns}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final ImmutableTable withColumns(AggregateDaoImpl.Column... elements) { ImmutableList newValue = ImmutableList.copyOf(elements); return new ImmutableTable(this.partialName, newValue, this.clusterKey, this.summary, this.fromInclusive); } /** * Copy the current immutable object with elements that replace the content of {@link AggregateDaoImpl.Table#columns() columns}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of columns elements to set * @return A modified copy of {@code this} object */ public final ImmutableTable withColumns(Iterable elements) { if (this.columns == elements) return this; ImmutableList newValue = ImmutableList.copyOf(elements); return new ImmutableTable(this.partialName, newValue, this.clusterKey, this.summary, this.fromInclusive); } /** * Copy the current immutable object with elements that replace the content of {@link AggregateDaoImpl.Table#clusterKey() clusterKey}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final ImmutableTable withClusterKey(String... elements) { ImmutableList newValue = ImmutableList.copyOf(elements); return new ImmutableTable(this.partialName, this.columns, newValue, this.summary, this.fromInclusive); } /** * Copy the current immutable object with elements that replace the content of {@link AggregateDaoImpl.Table#clusterKey() clusterKey}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of clusterKey elements to set * @return A modified copy of {@code this} object */ public final ImmutableTable withClusterKey(Iterable elements) { if (this.clusterKey == elements) return this; ImmutableList newValue = ImmutableList.copyOf(elements); return new ImmutableTable(this.partialName, this.columns, newValue, this.summary, this.fromInclusive); } /** * Copy the current immutable object by setting a value for the {@link AggregateDaoImpl.Table#summary() summary} attribute. * A value equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for summary * @return A modified copy of the {@code this} object */ public final ImmutableTable withSummary(boolean value) { if (this.summary == value) return this; return new ImmutableTable(this.partialName, this.columns, this.clusterKey, value, this.fromInclusive); } /** * Copy the current immutable object by setting a value for the {@link AggregateDaoImpl.Table#fromInclusive() fromInclusive} attribute. * A value equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for fromInclusive * @return A modified copy of the {@code this} object */ public final ImmutableTable withFromInclusive(boolean value) { if (this.fromInclusive == value) return this; return new ImmutableTable(this.partialName, this.columns, this.clusterKey, this.summary, value); } /** * This instance is equal to all instances of {@code ImmutableTable} that have 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 ImmutableTable && equalTo((ImmutableTable) another); } private boolean equalTo(ImmutableTable another) { return partialName.equals(another.partialName) && columns.equals(another.columns) && clusterKey.equals(another.clusterKey) && summary == another.summary && fromInclusive == another.fromInclusive; } /** * Computes a hash code from attributes: {@code partialName}, {@code columns}, {@code clusterKey}, {@code summary}, {@code fromInclusive}. * @return hashCode value */ @Override public int hashCode() { @Var int h = 5381; h += (h << 5) + partialName.hashCode(); h += (h << 5) + columns.hashCode(); h += (h << 5) + clusterKey.hashCode(); h += (h << 5) + Booleans.hashCode(summary); h += (h << 5) + Booleans.hashCode(fromInclusive); return h; } /** * Prints the immutable value {@code Table} with attribute values. * @return A string representation of the value */ @Override public String toString() { return MoreObjects.toStringHelper("Table") .omitNullValues() .add("partialName", partialName) .add("columns", columns) .add("clusterKey", clusterKey) .add("summary", summary) .add("fromInclusive", fromInclusive) .toString(); } /** * Utility type used to correctly read immutable object from JSON representation. * @deprecated Do not use this type directly, it exists only for the Jackson-binding infrastructure */ @Generated(from = "AggregateDaoImpl.Table", generator = "Immutables") @Deprecated @SuppressWarnings("Immutable") @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE) static final class Json implements AggregateDaoImpl.Table { @Nullable String partialName; @Nullable List columns = ImmutableList.of(); @Nullable List clusterKey = ImmutableList.of(); boolean summary; boolean summaryIsSet; boolean fromInclusive; boolean fromInclusiveIsSet; @JsonProperty("partialName") public void setPartialName(String partialName) { this.partialName = partialName; } @JsonProperty("columns") public void setColumns(List columns) { this.columns = columns; } @JsonProperty("clusterKey") public void setClusterKey(List clusterKey) { this.clusterKey = clusterKey; } @JsonProperty("summary") public void setSummary(boolean summary) { this.summary = summary; this.summaryIsSet = true; } @JsonProperty("fromInclusive") public void setFromInclusive(boolean fromInclusive) { this.fromInclusive = fromInclusive; this.fromInclusiveIsSet = true; } @Override public String partialName() { throw new UnsupportedOperationException(); } @Override public List columns() { throw new UnsupportedOperationException(); } @Override public List clusterKey() { throw new UnsupportedOperationException(); } @Override public boolean summary() { throw new UnsupportedOperationException(); } @Override public boolean fromInclusive() { throw new UnsupportedOperationException(); } } /** * @param json A JSON-bindable data structure * @return An immutable value type * @deprecated Do not use this method directly, it exists only for the Jackson-binding infrastructure */ @Deprecated @JsonCreator(mode = JsonCreator.Mode.DELEGATING) static ImmutableTable fromJson(Json json) { ImmutableTable.Builder builder = ImmutableTable.builder(); if (json.partialName != null) { builder.partialName(json.partialName); } if (json.columns != null) { builder.addAllColumns(json.columns); } if (json.clusterKey != null) { builder.addAllClusterKey(json.clusterKey); } if (json.summaryIsSet) { builder.summary(json.summary); } if (json.fromInclusiveIsSet) { builder.fromInclusive(json.fromInclusive); } return builder.build(); } /** * Creates an immutable copy of a {@link AggregateDaoImpl.Table} value. * Uses accessors to get values to initialize the new immutable instance. * If an instance is already immutable, it is returned as is. * @param instance The instance to copy * @return A copied immutable Table instance */ public static ImmutableTable copyOf(AggregateDaoImpl.Table instance) { if (instance instanceof ImmutableTable) { return (ImmutableTable) instance; } return ImmutableTable.builder() .copyFrom(instance) .build(); } /** * Creates a builder for {@link ImmutableTable ImmutableTable}. *

   * ImmutableTable.builder()
   *    .partialName(String) // required {@link AggregateDaoImpl.Table#partialName() partialName}
   *    .addColumns|addAllColumns(org.glowroot.central.repo.AggregateDaoImpl.Column) // {@link AggregateDaoImpl.Table#columns() columns} elements
   *    .addClusterKey|addAllClusterKey(String) // {@link AggregateDaoImpl.Table#clusterKey() clusterKey} elements
   *    .summary(boolean) // required {@link AggregateDaoImpl.Table#summary() summary}
   *    .fromInclusive(boolean) // required {@link AggregateDaoImpl.Table#fromInclusive() fromInclusive}
   *    .build();
   * 
* @return A new ImmutableTable builder */ public static ImmutableTable.Builder builder() { return new ImmutableTable.Builder(); } /** * Builds instances of type {@link ImmutableTable ImmutableTable}. * Initialize attributes and then invoke the {@link #build()} method to create an * immutable instance. *

{@code Builder} is not thread-safe and generally should not be stored in a field or collection, * but instead used immediately to create instances. */ @Generated(from = "AggregateDaoImpl.Table", generator = "Immutables") @NotThreadSafe public static final class Builder { private static final long INIT_BIT_PARTIAL_NAME = 0x1L; private static final long INIT_BIT_SUMMARY = 0x2L; private static final long INIT_BIT_FROM_INCLUSIVE = 0x4L; private long initBits = 0x7L; private @Nullable String partialName; private ImmutableList.Builder columns = ImmutableList.builder(); private ImmutableList.Builder clusterKey = ImmutableList.builder(); private boolean summary; private boolean fromInclusive; private Builder() { } /** * Fill a builder with attribute values from the provided {@code Table} instance. * Regular attribute values will be replaced with those from the given instance. * Absent optional values will not replace present values. * Collection elements and entries will be added, not replaced. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder copyFrom(AggregateDaoImpl.Table instance) { Objects.requireNonNull(instance, "instance"); partialName(instance.partialName()); addAllColumns(instance.columns()); addAllClusterKey(instance.clusterKey()); summary(instance.summary()); fromInclusive(instance.fromInclusive()); return this; } /** * Initializes the value for the {@link AggregateDaoImpl.Table#partialName() partialName} attribute. * @param partialName The value for partialName * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder partialName(String partialName) { this.partialName = Objects.requireNonNull(partialName, "partialName"); initBits &= ~INIT_BIT_PARTIAL_NAME; return this; } /** * Adds one element to {@link AggregateDaoImpl.Table#columns() columns} list. * @param element A columns element * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addColumns(AggregateDaoImpl.Column element) { this.columns.add(element); return this; } /** * Adds elements to {@link AggregateDaoImpl.Table#columns() columns} list. * @param elements An array of columns elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addColumns(AggregateDaoImpl.Column... elements) { this.columns.add(elements); return this; } /** * Sets or replaces all elements for {@link AggregateDaoImpl.Table#columns() columns} list. * @param elements An iterable of columns elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder columns(Iterable elements) { this.columns = ImmutableList.builder(); return addAllColumns(elements); } /** * Adds elements to {@link AggregateDaoImpl.Table#columns() columns} list. * @param elements An iterable of columns elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAllColumns(Iterable elements) { this.columns.addAll(elements); return this; } /** * Adds one element to {@link AggregateDaoImpl.Table#clusterKey() clusterKey} list. * @param element A clusterKey element * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addClusterKey(String element) { this.clusterKey.add(element); return this; } /** * Adds elements to {@link AggregateDaoImpl.Table#clusterKey() clusterKey} list. * @param elements An array of clusterKey elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addClusterKey(String... elements) { this.clusterKey.add(elements); return this; } /** * Sets or replaces all elements for {@link AggregateDaoImpl.Table#clusterKey() clusterKey} list. * @param elements An iterable of clusterKey elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder clusterKey(Iterable elements) { this.clusterKey = ImmutableList.builder(); return addAllClusterKey(elements); } /** * Adds elements to {@link AggregateDaoImpl.Table#clusterKey() clusterKey} list. * @param elements An iterable of clusterKey elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAllClusterKey(Iterable elements) { this.clusterKey.addAll(elements); return this; } /** * Initializes the value for the {@link AggregateDaoImpl.Table#summary() summary} attribute. * @param summary The value for summary * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder summary(boolean summary) { this.summary = summary; initBits &= ~INIT_BIT_SUMMARY; return this; } /** * Initializes the value for the {@link AggregateDaoImpl.Table#fromInclusive() fromInclusive} attribute. * @param fromInclusive The value for fromInclusive * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder fromInclusive(boolean fromInclusive) { this.fromInclusive = fromInclusive; initBits &= ~INIT_BIT_FROM_INCLUSIVE; return this; } /** * Builds a new {@link ImmutableTable ImmutableTable}. * @return An immutable instance of Table * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableTable build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return new ImmutableTable(partialName, columns.build(), clusterKey.build(), summary, fromInclusive); } private String formatRequiredAttributesMessage() { List attributes = new ArrayList<>(); if ((initBits & INIT_BIT_PARTIAL_NAME) != 0) attributes.add("partialName"); if ((initBits & INIT_BIT_SUMMARY) != 0) attributes.add("summary"); if ((initBits & INIT_BIT_FROM_INCLUSIVE) != 0) attributes.add("fromInclusive"); return "Cannot build Table, some of required attributes are not set " + attributes; } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy