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

com.arakelian.elastic.model.aggs.bucket.ImmutableTermsAggregation Maven / Gradle / Ivy

package com.arakelian.elastic.model.aggs.bucket;

import com.arakelian.core.feature.Nullable;
import com.arakelian.elastic.model.aggs.Aggregation;
import com.arakelian.elastic.model.aggs.ValuesSourceAggregation;
import com.arakelian.elastic.model.enums.CollectMode;
import com.arakelian.elastic.model.enums.ExecutionHint;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeName;
import com.google.common.base.MoreObjects;
import com.google.common.collect.ImmutableList;
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.ParametersAreNonnullByDefault;
import javax.annotation.concurrent.Immutable;
import javax.annotation.concurrent.NotThreadSafe;
import org.immutables.value.Generated;

/**
 * Immutable implementation of {@link TermsAggregation}.
 * 

* Use the builder to create immutable instances: * {@code ImmutableTermsAggregation.builder()}. */ @Generated(from = "TermsAggregation", generator = "Immutables") @SuppressWarnings({"all"}) @ParametersAreNonnullByDefault @javax.annotation.processing.Generated("org.immutables.processor.ProxyProcessor") @Immutable @CheckReturnValue public final class ImmutableTermsAggregation implements TermsAggregation { private final String name; private final ImmutableList subAggregations; private final boolean empty; private final String field; private final @Nullable String format; private final @Nullable Object missing; private final @Nullable String timeZone; private final @Nullable CollectMode collectMode; private final @Nullable String exclude; private final ImmutableList excludeValues; private final @Nullable ExecutionHint executionHint; private final @Nullable String include; private final ImmutableList includeValues; private final @Nullable Long minDocCount; private final ImmutableList order; private final @Nullable Long shardMinDocCount; private final @Nullable Long shardSize; private final @Nullable Integer size; private final @Nullable Boolean showTermDocCountError; private ImmutableTermsAggregation(ImmutableTermsAggregation.Builder builder) { this.name = builder.name; this.field = builder.field; this.format = builder.format; this.missing = builder.missing; this.timeZone = builder.timeZone; this.collectMode = builder.collectMode; this.exclude = builder.exclude; this.executionHint = builder.executionHint; this.include = builder.include; this.minDocCount = builder.minDocCount; this.shardMinDocCount = builder.shardMinDocCount; this.shardSize = builder.shardSize; this.size = builder.size; this.showTermDocCountError = builder.showTermDocCountError; if (builder.subAggregationsIsSet()) { initShim.subAggregations(builder.subAggregations.build()); } if (builder.excludeValuesIsSet()) { initShim.excludeValues(builder.excludeValues.build()); } if (builder.includeValuesIsSet()) { initShim.includeValues(builder.includeValues.build()); } if (builder.orderIsSet()) { initShim.order(builder.order.build()); } this.subAggregations = initShim.getSubAggregations(); this.empty = initShim.isEmpty(); this.excludeValues = initShim.getExcludeValues(); this.includeValues = initShim.getIncludeValues(); this.order = initShim.getOrder(); this.initShim = null; } private static final byte STAGE_INITIALIZING = -1; private static final byte STAGE_UNINITIALIZED = 0; private static final byte STAGE_INITIALIZED = 1; @SuppressWarnings("Immutable") private transient volatile InitShim initShim = new InitShim(); @Generated(from = "TermsAggregation", generator = "Immutables") private final class InitShim { private byte subAggregationsBuildStage = STAGE_UNINITIALIZED; private ImmutableList subAggregations; ImmutableList getSubAggregations() { if (subAggregationsBuildStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage()); if (subAggregationsBuildStage == STAGE_UNINITIALIZED) { subAggregationsBuildStage = STAGE_INITIALIZING; this.subAggregations = ImmutableList.copyOf(getSubAggregationsInitialize()); subAggregationsBuildStage = STAGE_INITIALIZED; } return this.subAggregations; } void subAggregations(ImmutableList subAggregations) { this.subAggregations = subAggregations; subAggregationsBuildStage = STAGE_INITIALIZED; } private byte emptyBuildStage = STAGE_UNINITIALIZED; private boolean empty; boolean isEmpty() { if (emptyBuildStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage()); if (emptyBuildStage == STAGE_UNINITIALIZED) { emptyBuildStage = STAGE_INITIALIZING; this.empty = isEmptyInitialize(); emptyBuildStage = STAGE_INITIALIZED; } return this.empty; } private byte excludeValuesBuildStage = STAGE_UNINITIALIZED; private ImmutableList excludeValues; ImmutableList getExcludeValues() { if (excludeValuesBuildStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage()); if (excludeValuesBuildStage == STAGE_UNINITIALIZED) { excludeValuesBuildStage = STAGE_INITIALIZING; this.excludeValues = ImmutableList.copyOf(getExcludeValuesInitialize()); excludeValuesBuildStage = STAGE_INITIALIZED; } return this.excludeValues; } void excludeValues(ImmutableList excludeValues) { this.excludeValues = excludeValues; excludeValuesBuildStage = STAGE_INITIALIZED; } private byte includeValuesBuildStage = STAGE_UNINITIALIZED; private ImmutableList includeValues; ImmutableList getIncludeValues() { if (includeValuesBuildStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage()); if (includeValuesBuildStage == STAGE_UNINITIALIZED) { includeValuesBuildStage = STAGE_INITIALIZING; this.includeValues = ImmutableList.copyOf(getIncludeValuesInitialize()); includeValuesBuildStage = STAGE_INITIALIZED; } return this.includeValues; } void includeValues(ImmutableList includeValues) { this.includeValues = includeValues; includeValuesBuildStage = STAGE_INITIALIZED; } private byte orderBuildStage = STAGE_UNINITIALIZED; private ImmutableList order; ImmutableList getOrder() { if (orderBuildStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage()); if (orderBuildStage == STAGE_UNINITIALIZED) { orderBuildStage = STAGE_INITIALIZING; this.order = ImmutableList.copyOf(getOrderInitialize()); orderBuildStage = STAGE_INITIALIZED; } return this.order; } void order(ImmutableList order) { this.order = order; orderBuildStage = STAGE_INITIALIZED; } private String formatInitCycleMessage() { List attributes = new ArrayList<>(); if (subAggregationsBuildStage == STAGE_INITIALIZING) attributes.add("subAggregations"); if (emptyBuildStage == STAGE_INITIALIZING) attributes.add("empty"); if (excludeValuesBuildStage == STAGE_INITIALIZING) attributes.add("excludeValues"); if (includeValuesBuildStage == STAGE_INITIALIZING) attributes.add("includeValues"); if (orderBuildStage == STAGE_INITIALIZING) attributes.add("order"); return "Cannot build TermsAggregation, attribute initializers form cycle " + attributes; } } private List getSubAggregationsInitialize() { return TermsAggregation.super.getSubAggregations(); } private boolean isEmptyInitialize() { return TermsAggregation.super.isEmpty(); } private List getExcludeValuesInitialize() { return TermsAggregation.super.getExcludeValues(); } private List getIncludeValuesInitialize() { return TermsAggregation.super.getIncludeValues(); } private List getOrderInitialize() { return TermsAggregation.super.getOrder(); } /** * Returns the name of the aggregation * @return name of the aggregation */ @JsonProperty("name") @Override public String getName() { return name; } /** * @return The value of the {@code subAggregations} attribute */ @JsonProperty("subAggregations") @Override public ImmutableList getSubAggregations() { InitShim shim = this.initShim; return shim != null ? shim.getSubAggregations() : this.subAggregations; } /** * @return The computed-at-construction value of the {@code empty} attribute */ @JsonProperty("empty") @JsonIgnore @Override public boolean isEmpty() { InitShim shim = this.initShim; return shim != null ? shim.isEmpty() : this.empty; } /** * @return The value of the {@code field} attribute */ @JsonProperty("field") @Override public String getField() { return field; } /** * @return The value of the {@code format} attribute */ @JsonProperty("format") @Override public @Nullable String getFormat() { return format; } /** * @return The value of the {@code missing} attribute */ @JsonProperty("missing") @Override public @Nullable Object getMissing() { return missing; } /** * @return The value of the {@code timeZone} attribute */ @JsonProperty("timeZone") @Override public @Nullable String getTimeZone() { return timeZone; } /** * @return The value of the {@code collectMode} attribute */ @JsonProperty("collectMode") @Override public @Nullable CollectMode getCollectMode() { return collectMode; } /** * @return The value of the {@code exclude} attribute */ @JsonProperty("exclude") @Override public @Nullable String getExclude() { return exclude; } /** * @return The value of the {@code excludeValues} attribute */ @JsonProperty("excludeValues") @Override public ImmutableList getExcludeValues() { InitShim shim = this.initShim; return shim != null ? shim.getExcludeValues() : this.excludeValues; } /** * Returns the mechanism by which terms aggregation is executed. * @return the mechanism by which terms aggregation is executed. */ @JsonProperty("executionHint") @Override public @Nullable ExecutionHint getExecutionHint() { return executionHint; } /** * @return The value of the {@code include} attribute */ @JsonProperty("include") @Override public @Nullable String getInclude() { return include; } /** * @return The value of the {@code includeValues} attribute */ @JsonProperty("includeValues") @Override public ImmutableList getIncludeValues() { InitShim shim = this.initShim; return shim != null ? shim.getIncludeValues() : this.includeValues; } /** * Returns the minimum number of hits required before returning a term. * @return the minimum number of hits required before returning a term. */ @JsonProperty("minDocCount") @Override public @Nullable Long getMinDocCount() { return minDocCount; } /** * Returns the bucket order. * @return the bucket order * @see InternalOrder.java */ @JsonProperty("order") @Override public ImmutableList getOrder() { InitShim shim = this.initShim; return shim != null ? shim.getOrder() : this.order; } /** * Returns the minimum number of hits required on a local shard before a term is returned. * @return the minimum number of hits required on a local shard before a term is returned. */ @JsonProperty("shardMinDocCount") @Override public @Nullable Long getShardMinDocCount() { return shardMinDocCount; } /** * Returns how many terms the coordinating node will request from each shard. Once all the * shards responded, the coordinating node will then reduce them to a final result which will be * based on the size parameter - this way, one can increase the accuracy of the returned terms * and avoid the overhead of streaming a big list of buckets back to the client. * @return the number of terms the coordinating node will request from each shard. */ @JsonProperty("shardSize") @Override public @Nullable Long getShardSize() { return shardSize; } /** * Returns how many term buckets should be returned out of the overall terms list. By default, * the node coordinating the search process will request each shard to provide its own top size * term buckets and once all shards respond, it will reduce the results to the final list that * will then be returned to the client. * @return how many term buckets should be returned out of the overall terms list. */ @JsonProperty("size") @Override public @Nullable Integer getSize() { return size; } /** * @return The value of the {@code showTermDocCountError} attribute */ @JsonProperty("showTermDocCountError") @Override public @Nullable Boolean isShowTermDocCountError() { return showTermDocCountError; } /** * This instance is equal to all instances of {@code ImmutableTermsAggregation} that have equal attribute values. * @return {@code true} if {@code this} is equal to {@code another} instance */ @Override public boolean equals(@javax.annotation.Nullable Object another) { if (this == another) return true; return another instanceof ImmutableTermsAggregation && equalTo((ImmutableTermsAggregation) another); } private boolean equalTo(ImmutableTermsAggregation another) { return name.equals(another.name) && subAggregations.equals(another.subAggregations) && field.equals(another.field) && Objects.equals(format, another.format) && Objects.equals(missing, another.missing) && Objects.equals(timeZone, another.timeZone) && Objects.equals(collectMode, another.collectMode) && Objects.equals(exclude, another.exclude) && excludeValues.equals(another.excludeValues) && Objects.equals(executionHint, another.executionHint) && Objects.equals(include, another.include) && includeValues.equals(another.includeValues) && Objects.equals(minDocCount, another.minDocCount) && order.equals(another.order) && Objects.equals(shardMinDocCount, another.shardMinDocCount) && Objects.equals(shardSize, another.shardSize) && Objects.equals(size, another.size) && Objects.equals(showTermDocCountError, another.showTermDocCountError); } /** * Computes a hash code from attributes: {@code name}, {@code subAggregations}, {@code field}, {@code format}, {@code missing}, {@code timeZone}, {@code collectMode}, {@code exclude}, {@code excludeValues}, {@code executionHint}, {@code include}, {@code includeValues}, {@code minDocCount}, {@code order}, {@code shardMinDocCount}, {@code shardSize}, {@code size}, {@code showTermDocCountError}. * @return hashCode value */ @Override public int hashCode() { @Var int h = 5381; h += (h << 5) + name.hashCode(); h += (h << 5) + subAggregations.hashCode(); h += (h << 5) + field.hashCode(); h += (h << 5) + Objects.hashCode(format); h += (h << 5) + Objects.hashCode(missing); h += (h << 5) + Objects.hashCode(timeZone); h += (h << 5) + Objects.hashCode(collectMode); h += (h << 5) + Objects.hashCode(exclude); h += (h << 5) + excludeValues.hashCode(); h += (h << 5) + Objects.hashCode(executionHint); h += (h << 5) + Objects.hashCode(include); h += (h << 5) + includeValues.hashCode(); h += (h << 5) + Objects.hashCode(minDocCount); h += (h << 5) + order.hashCode(); h += (h << 5) + Objects.hashCode(shardMinDocCount); h += (h << 5) + Objects.hashCode(shardSize); h += (h << 5) + Objects.hashCode(size); h += (h << 5) + Objects.hashCode(showTermDocCountError); return h; } /** * Prints the immutable value {@code TermsAggregation} with attribute values. * @return A string representation of the value */ @Override public String toString() { return MoreObjects.toStringHelper("TermsAggregation") .omitNullValues() .add("name", name) .add("subAggregations", subAggregations) .add("field", field) .add("format", format) .add("missing", missing) .add("timeZone", timeZone) .add("collectMode", collectMode) .add("exclude", exclude) .add("excludeValues", excludeValues) .add("executionHint", executionHint) .add("include", include) .add("includeValues", includeValues) .add("minDocCount", minDocCount) .add("order", order) .add("shardMinDocCount", shardMinDocCount) .add("shardSize", shardSize) .add("size", size) .add("showTermDocCountError", showTermDocCountError) .toString(); } /** * Creates a builder for {@link ImmutableTermsAggregation ImmutableTermsAggregation}. *
   * ImmutableTermsAggregation.builder()
   *    .name(String) // required {@link TermsAggregation#getName() name}
   *    .addSubAggregation|addAllSubAggregations(com.arakelian.elastic.model.aggs.Aggregation) // {@link TermsAggregation#getSubAggregations() subAggregations} elements
   *    .field(String) // required {@link TermsAggregation#getField() field}
   *    .format(String | null) // nullable {@link TermsAggregation#getFormat() format}
   *    .missing(Object | null) // nullable {@link TermsAggregation#getMissing() missing}
   *    .timeZone(String | null) // nullable {@link TermsAggregation#getTimeZone() timeZone}
   *    .collectMode(com.arakelian.elastic.model.enums.CollectMode | null) // nullable {@link TermsAggregation#getCollectMode() collectMode}
   *    .exclude(String | null) // nullable {@link TermsAggregation#getExclude() exclude}
   *    .addExcludeValue|addAllExcludeValues(Object) // {@link TermsAggregation#getExcludeValues() excludeValues} elements
   *    .executionHint(com.arakelian.elastic.model.enums.ExecutionHint | null) // nullable {@link TermsAggregation#getExecutionHint() executionHint}
   *    .include(String | null) // nullable {@link TermsAggregation#getInclude() include}
   *    .addIncludeValue|addAllIncludeValues(Object) // {@link TermsAggregation#getIncludeValues() includeValues} elements
   *    .minDocCount(Long | null) // nullable {@link TermsAggregation#getMinDocCount() minDocCount}
   *    .addOrder|addAllOrder(com.arakelian.elastic.model.aggs.bucket.BucketOrder) // {@link TermsAggregation#getOrder() order} elements
   *    .shardMinDocCount(Long | null) // nullable {@link TermsAggregation#getShardMinDocCount() shardMinDocCount}
   *    .shardSize(Long | null) // nullable {@link TermsAggregation#getShardSize() shardSize}
   *    .size(Integer | null) // nullable {@link TermsAggregation#getSize() size}
   *    .showTermDocCountError(Boolean | null) // nullable {@link TermsAggregation#isShowTermDocCountError() showTermDocCountError}
   *    .build();
   * 
* @return A new ImmutableTermsAggregation builder */ public static ImmutableTermsAggregation.Builder builder() { return new ImmutableTermsAggregation.Builder(); } /** * Builds instances of type {@link ImmutableTermsAggregation ImmutableTermsAggregation}. * 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 = "TermsAggregation", generator = "Immutables") @NotThreadSafe @JsonTypeName("terms") public static final class Builder { private static final long INIT_BIT_NAME = 0x1L; private static final long INIT_BIT_FIELD = 0x2L; private static final long OPT_BIT_SUB_AGGREGATIONS = 0x1L; private static final long OPT_BIT_EXCLUDE_VALUES = 0x2L; private static final long OPT_BIT_INCLUDE_VALUES = 0x4L; private static final long OPT_BIT_ORDER = 0x8L; private long initBits = 0x3L; private long optBits; private @javax.annotation.Nullable String name; private ImmutableList.Builder subAggregations = ImmutableList.builder(); private @javax.annotation.Nullable String field; private @javax.annotation.Nullable String format; private @javax.annotation.Nullable Object missing; private @javax.annotation.Nullable String timeZone; private @javax.annotation.Nullable CollectMode collectMode; private @javax.annotation.Nullable String exclude; private ImmutableList.Builder excludeValues = ImmutableList.builder(); private @javax.annotation.Nullable ExecutionHint executionHint; private @javax.annotation.Nullable String include; private ImmutableList.Builder includeValues = ImmutableList.builder(); private @javax.annotation.Nullable Long minDocCount; private ImmutableList.Builder order = ImmutableList.builder(); private @javax.annotation.Nullable Long shardMinDocCount; private @javax.annotation.Nullable Long shardSize; private @javax.annotation.Nullable Integer size; private @javax.annotation.Nullable Boolean showTermDocCountError; private Builder() { } /** * Fill a builder with attribute values from the provided {@code com.arakelian.elastic.model.aggs.Aggregation} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Aggregation instance) { Objects.requireNonNull(instance, "instance"); from((Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code com.arakelian.elastic.model.aggs.bucket.TermsAggregation} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(TermsAggregation instance) { Objects.requireNonNull(instance, "instance"); from((Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code com.arakelian.elastic.model.aggs.ValuesSourceAggregation} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(ValuesSourceAggregation instance) { Objects.requireNonNull(instance, "instance"); from((Object) instance); return this; } private void from(Object object) { if (object instanceof Aggregation) { Aggregation instance = (Aggregation) object; name(instance.getName()); addAllSubAggregations(instance.getSubAggregations()); } if (object instanceof TermsAggregation) { TermsAggregation instance = (TermsAggregation) object; Boolean showTermDocCountErrorValue = instance.isShowTermDocCountError(); if (showTermDocCountErrorValue != null) { showTermDocCountError(showTermDocCountErrorValue); } String includeValue = instance.getInclude(); if (includeValue != null) { include(includeValue); } addAllIncludeValues(instance.getIncludeValues()); Long shardMinDocCountValue = instance.getShardMinDocCount(); if (shardMinDocCountValue != null) { shardMinDocCount(shardMinDocCountValue); } Integer sizeValue = instance.getSize(); if (sizeValue != null) { size(sizeValue); } Long minDocCountValue = instance.getMinDocCount(); if (minDocCountValue != null) { minDocCount(minDocCountValue); } String excludeValue = instance.getExclude(); if (excludeValue != null) { exclude(excludeValue); } Long shardSizeValue = instance.getShardSize(); if (shardSizeValue != null) { shardSize(shardSizeValue); } addAllExcludeValues(instance.getExcludeValues()); CollectMode collectModeValue = instance.getCollectMode(); if (collectModeValue != null) { collectMode(collectModeValue); } ExecutionHint executionHintValue = instance.getExecutionHint(); if (executionHintValue != null) { executionHint(executionHintValue); } addAllOrder(instance.getOrder()); } if (object instanceof ValuesSourceAggregation) { ValuesSourceAggregation instance = (ValuesSourceAggregation) object; String formatValue = instance.getFormat(); if (formatValue != null) { format(formatValue); } Object missingValue = instance.getMissing(); if (missingValue != null) { missing(missingValue); } String timeZoneValue = instance.getTimeZone(); if (timeZoneValue != null) { timeZone(timeZoneValue); } field(instance.getField()); } } /** * Initializes the value for the {@link TermsAggregation#getName() name} attribute. * @param name The value for name * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("name") public final Builder name(String name) { this.name = Objects.requireNonNull(name, "name"); initBits &= ~INIT_BIT_NAME; return this; } /** * Adds one element to {@link TermsAggregation#getSubAggregations() subAggregations} list. * @param element A subAggregations element * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addSubAggregation(Aggregation element) { this.subAggregations.add(element); optBits |= OPT_BIT_SUB_AGGREGATIONS; return this; } /** * Adds elements to {@link TermsAggregation#getSubAggregations() subAggregations} list. * @param elements An array of subAggregations elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addSubAggregations(Aggregation... elements) { this.subAggregations.add(elements); optBits |= OPT_BIT_SUB_AGGREGATIONS; return this; } /** * Sets or replaces all elements for {@link TermsAggregation#getSubAggregations() subAggregations} list. * @param elements An iterable of subAggregations elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("subAggregations") public final Builder subAggregations(Iterable elements) { this.subAggregations = ImmutableList.builder(); return addAllSubAggregations(elements); } /** * Adds elements to {@link TermsAggregation#getSubAggregations() subAggregations} list. * @param elements An iterable of subAggregations elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAllSubAggregations(Iterable elements) { this.subAggregations.addAll(elements); optBits |= OPT_BIT_SUB_AGGREGATIONS; return this; } /** * Initializes the value for the {@link TermsAggregation#getField() field} attribute. * @param field The value for field * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("field") public final Builder field(String field) { this.field = Objects.requireNonNull(field, "field"); initBits &= ~INIT_BIT_FIELD; return this; } /** * Initializes the value for the {@link TermsAggregation#getFormat() format} attribute. * @param format The value for format (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("format") public final Builder format(@Nullable String format) { this.format = format; return this; } /** * Initializes the value for the {@link TermsAggregation#getMissing() missing} attribute. * @param missing The value for missing (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("missing") public final Builder missing(@Nullable Object missing) { this.missing = missing; return this; } /** * Initializes the value for the {@link TermsAggregation#getTimeZone() timeZone} attribute. * @param timeZone The value for timeZone (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("timeZone") public final Builder timeZone(@Nullable String timeZone) { this.timeZone = timeZone; return this; } /** * Initializes the value for the {@link TermsAggregation#getCollectMode() collectMode} attribute. * @param collectMode The value for collectMode (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("collectMode") public final Builder collectMode(@Nullable CollectMode collectMode) { this.collectMode = collectMode; return this; } /** * Initializes the value for the {@link TermsAggregation#getExclude() exclude} attribute. * @param exclude The value for exclude (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("exclude") public final Builder exclude(@Nullable String exclude) { this.exclude = exclude; return this; } /** * Adds one element to {@link TermsAggregation#getExcludeValues() excludeValues} list. * @param element A excludeValues element * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addExcludeValue(Object element) { this.excludeValues.add(element); optBits |= OPT_BIT_EXCLUDE_VALUES; return this; } /** * Adds elements to {@link TermsAggregation#getExcludeValues() excludeValues} list. * @param elements An array of excludeValues elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addExcludeValues(Object... elements) { this.excludeValues.add(elements); optBits |= OPT_BIT_EXCLUDE_VALUES; return this; } /** * Sets or replaces all elements for {@link TermsAggregation#getExcludeValues() excludeValues} list. * @param elements An iterable of excludeValues elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("excludeValues") public final Builder excludeValues(Iterable elements) { this.excludeValues = ImmutableList.builder(); return addAllExcludeValues(elements); } /** * Adds elements to {@link TermsAggregation#getExcludeValues() excludeValues} list. * @param elements An iterable of excludeValues elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAllExcludeValues(Iterable elements) { this.excludeValues.addAll(elements); optBits |= OPT_BIT_EXCLUDE_VALUES; return this; } /** * Initializes the value for the {@link TermsAggregation#getExecutionHint() executionHint} attribute. * @param executionHint The value for executionHint (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("executionHint") public final Builder executionHint(@Nullable ExecutionHint executionHint) { this.executionHint = executionHint; return this; } /** * Initializes the value for the {@link TermsAggregation#getInclude() include} attribute. * @param include The value for include (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("include") public final Builder include(@Nullable String include) { this.include = include; return this; } /** * Adds one element to {@link TermsAggregation#getIncludeValues() includeValues} list. * @param element A includeValues element * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addIncludeValue(Object element) { this.includeValues.add(element); optBits |= OPT_BIT_INCLUDE_VALUES; return this; } /** * Adds elements to {@link TermsAggregation#getIncludeValues() includeValues} list. * @param elements An array of includeValues elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addIncludeValues(Object... elements) { this.includeValues.add(elements); optBits |= OPT_BIT_INCLUDE_VALUES; return this; } /** * Sets or replaces all elements for {@link TermsAggregation#getIncludeValues() includeValues} list. * @param elements An iterable of includeValues elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("includeValues") public final Builder includeValues(Iterable elements) { this.includeValues = ImmutableList.builder(); return addAllIncludeValues(elements); } /** * Adds elements to {@link TermsAggregation#getIncludeValues() includeValues} list. * @param elements An iterable of includeValues elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAllIncludeValues(Iterable elements) { this.includeValues.addAll(elements); optBits |= OPT_BIT_INCLUDE_VALUES; return this; } /** * Initializes the value for the {@link TermsAggregation#getMinDocCount() minDocCount} attribute. * @param minDocCount The value for minDocCount (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("minDocCount") public final Builder minDocCount(@Nullable Long minDocCount) { this.minDocCount = minDocCount; return this; } /** * Adds one element to {@link TermsAggregation#getOrder() order} list. * @param element A order element * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addOrder(BucketOrder element) { this.order.add(element); optBits |= OPT_BIT_ORDER; return this; } /** * Adds elements to {@link TermsAggregation#getOrder() order} list. * @param elements An array of order elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addOrder(BucketOrder... elements) { this.order.add(elements); optBits |= OPT_BIT_ORDER; return this; } /** * Sets or replaces all elements for {@link TermsAggregation#getOrder() order} list. * @param elements An iterable of order elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("order") public final Builder order(Iterable elements) { this.order = ImmutableList.builder(); return addAllOrder(elements); } /** * Adds elements to {@link TermsAggregation#getOrder() order} list. * @param elements An iterable of order elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAllOrder(Iterable elements) { this.order.addAll(elements); optBits |= OPT_BIT_ORDER; return this; } /** * Initializes the value for the {@link TermsAggregation#getShardMinDocCount() shardMinDocCount} attribute. * @param shardMinDocCount The value for shardMinDocCount (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("shardMinDocCount") public final Builder shardMinDocCount(@Nullable Long shardMinDocCount) { this.shardMinDocCount = shardMinDocCount; return this; } /** * Initializes the value for the {@link TermsAggregation#getShardSize() shardSize} attribute. * @param shardSize The value for shardSize (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("shardSize") public final Builder shardSize(@Nullable Long shardSize) { this.shardSize = shardSize; return this; } /** * Initializes the value for the {@link TermsAggregation#getSize() size} attribute. * @param size The value for size (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("size") public final Builder size(@Nullable Integer size) { this.size = size; return this; } /** * Initializes the value for the {@link TermsAggregation#isShowTermDocCountError() showTermDocCountError} attribute. * @param showTermDocCountError The value for showTermDocCountError (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("showTermDocCountError") public final Builder showTermDocCountError(@Nullable Boolean showTermDocCountError) { this.showTermDocCountError = showTermDocCountError; return this; } /** * Builds a new {@link ImmutableTermsAggregation ImmutableTermsAggregation}. * @return An immutable instance of TermsAggregation * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableTermsAggregation build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return new ImmutableTermsAggregation(this); } private boolean subAggregationsIsSet() { return (optBits & OPT_BIT_SUB_AGGREGATIONS) != 0; } private boolean excludeValuesIsSet() { return (optBits & OPT_BIT_EXCLUDE_VALUES) != 0; } private boolean includeValuesIsSet() { return (optBits & OPT_BIT_INCLUDE_VALUES) != 0; } private boolean orderIsSet() { return (optBits & OPT_BIT_ORDER) != 0; } private String formatRequiredAttributesMessage() { List attributes = new ArrayList<>(); if ((initBits & INIT_BIT_NAME) != 0) attributes.add("name"); if ((initBits & INIT_BIT_FIELD) != 0) attributes.add("field"); return "Cannot build TermsAggregation, some of required attributes are not set " + attributes; } } }