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

com.arakelian.elastic.model.aggs.bucket.ImmutableDateHistogramAggregation 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.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 DateHistogramAggregation}.
 * 

* Use the builder to create immutable instances: * {@code ImmutableDateHistogramAggregation.builder()}. */ @Generated(from = "DateHistogramAggregation", generator = "Immutables") @SuppressWarnings({"all"}) @ParametersAreNonnullByDefault @javax.annotation.processing.Generated("org.immutables.processor.ProxyProcessor") @Immutable @CheckReturnValue public final class ImmutableDateHistogramAggregation implements DateHistogramAggregation { 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 Long extendedBoundsMax; private final @Nullable Long extendedBoundsMin; private final @Nullable String interval; private final @Nullable Long minDocCount; private final @Nullable Long offset; private final ImmutableList order; private final @Nullable Boolean keyed; private ImmutableDateHistogramAggregation(ImmutableDateHistogramAggregation.Builder builder) { this.name = builder.name; this.field = builder.field; this.format = builder.format; this.missing = builder.missing; this.timeZone = builder.timeZone; this.extendedBoundsMax = builder.extendedBoundsMax; this.extendedBoundsMin = builder.extendedBoundsMin; this.interval = builder.interval; this.minDocCount = builder.minDocCount; this.offset = builder.offset; this.keyed = builder.keyed; if (builder.subAggregationsIsSet()) { initShim.subAggregations(builder.subAggregations.build()); } if (builder.orderIsSet()) { initShim.order(builder.order.build()); } this.subAggregations = initShim.getSubAggregations(); this.empty = initShim.isEmpty(); 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 = "DateHistogramAggregation", 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 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 (orderBuildStage == STAGE_INITIALIZING) attributes.add("order"); return "Cannot build DateHistogramAggregation, attribute initializers form cycle " + attributes; } } private List getSubAggregationsInitialize() { return DateHistogramAggregation.super.getSubAggregations(); } private boolean isEmptyInitialize() { return DateHistogramAggregation.super.isEmpty(); } private List getOrderInitialize() { return DateHistogramAggregation.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 extendedBoundsMax} attribute */ @JsonProperty("extendedBoundsMax") @Override public @Nullable Long getExtendedBoundsMax() { return extendedBoundsMax; } /** * @return The value of the {@code extendedBoundsMin} attribute */ @JsonProperty("extendedBoundsMin") @Override public @Nullable Long getExtendedBoundsMin() { return extendedBoundsMin; } /** * @return The value of the {@code interval} attribute */ @JsonProperty("interval") @Override public @Nullable String getInterval() { return interval; } /** * 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; } /** * @return The value of the {@code offset} attribute */ @JsonProperty("offset") @Override public @Nullable Long getOffset() { return offset; } /** * 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; } /** * @return The value of the {@code keyed} attribute */ @JsonProperty("keyed") @Override public @Nullable Boolean isKeyed() { return keyed; } /** * This instance is equal to all instances of {@code ImmutableDateHistogramAggregation} 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 ImmutableDateHistogramAggregation && equalTo((ImmutableDateHistogramAggregation) another); } private boolean equalTo(ImmutableDateHistogramAggregation 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(extendedBoundsMax, another.extendedBoundsMax) && Objects.equals(extendedBoundsMin, another.extendedBoundsMin) && Objects.equals(interval, another.interval) && Objects.equals(minDocCount, another.minDocCount) && Objects.equals(offset, another.offset) && order.equals(another.order) && Objects.equals(keyed, another.keyed); } /** * Computes a hash code from attributes: {@code name}, {@code subAggregations}, {@code field}, {@code format}, {@code missing}, {@code timeZone}, {@code extendedBoundsMax}, {@code extendedBoundsMin}, {@code interval}, {@code minDocCount}, {@code offset}, {@code order}, {@code keyed}. * @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(extendedBoundsMax); h += (h << 5) + Objects.hashCode(extendedBoundsMin); h += (h << 5) + Objects.hashCode(interval); h += (h << 5) + Objects.hashCode(minDocCount); h += (h << 5) + Objects.hashCode(offset); h += (h << 5) + order.hashCode(); h += (h << 5) + Objects.hashCode(keyed); return h; } /** * Prints the immutable value {@code DateHistogramAggregation} with attribute values. * @return A string representation of the value */ @Override public String toString() { return MoreObjects.toStringHelper("DateHistogramAggregation") .omitNullValues() .add("name", name) .add("subAggregations", subAggregations) .add("field", field) .add("format", format) .add("missing", missing) .add("timeZone", timeZone) .add("extendedBoundsMax", extendedBoundsMax) .add("extendedBoundsMin", extendedBoundsMin) .add("interval", interval) .add("minDocCount", minDocCount) .add("offset", offset) .add("order", order) .add("keyed", keyed) .toString(); } /** * Creates a builder for {@link ImmutableDateHistogramAggregation ImmutableDateHistogramAggregation}. *

   * ImmutableDateHistogramAggregation.builder()
   *    .name(String) // required {@link DateHistogramAggregation#getName() name}
   *    .addSubAggregation|addAllSubAggregations(com.arakelian.elastic.model.aggs.Aggregation) // {@link DateHistogramAggregation#getSubAggregations() subAggregations} elements
   *    .field(String) // required {@link DateHistogramAggregation#getField() field}
   *    .format(String | null) // nullable {@link DateHistogramAggregation#getFormat() format}
   *    .missing(Object | null) // nullable {@link DateHistogramAggregation#getMissing() missing}
   *    .timeZone(String | null) // nullable {@link DateHistogramAggregation#getTimeZone() timeZone}
   *    .extendedBoundsMax(Long | null) // nullable {@link DateHistogramAggregation#getExtendedBoundsMax() extendedBoundsMax}
   *    .extendedBoundsMin(Long | null) // nullable {@link DateHistogramAggregation#getExtendedBoundsMin() extendedBoundsMin}
   *    .interval(String | null) // nullable {@link DateHistogramAggregation#getInterval() interval}
   *    .minDocCount(Long | null) // nullable {@link DateHistogramAggregation#getMinDocCount() minDocCount}
   *    .offset(Long | null) // nullable {@link DateHistogramAggregation#getOffset() offset}
   *    .addOrder|addAllOrder(com.arakelian.elastic.model.aggs.bucket.BucketOrder) // {@link DateHistogramAggregation#getOrder() order} elements
   *    .keyed(Boolean | null) // nullable {@link DateHistogramAggregation#isKeyed() keyed}
   *    .build();
   * 
* @return A new ImmutableDateHistogramAggregation builder */ public static ImmutableDateHistogramAggregation.Builder builder() { return new ImmutableDateHistogramAggregation.Builder(); } /** * Builds instances of type {@link ImmutableDateHistogramAggregation ImmutableDateHistogramAggregation}. * 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 = "DateHistogramAggregation", generator = "Immutables") @NotThreadSafe @JsonTypeName("date_histogram") 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_ORDER = 0x2L; 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 Long extendedBoundsMax; private @javax.annotation.Nullable Long extendedBoundsMin; private @javax.annotation.Nullable String interval; private @javax.annotation.Nullable Long minDocCount; private @javax.annotation.Nullable Long offset; private ImmutableList.Builder order = ImmutableList.builder(); private @javax.annotation.Nullable Boolean keyed; private Builder() { } /** * Fill a builder with attribute values from the provided {@code com.arakelian.elastic.model.aggs.bucket.DateHistogramAggregation} 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(DateHistogramAggregation 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.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.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 DateHistogramAggregation) { DateHistogramAggregation instance = (DateHistogramAggregation) object; Long offsetValue = instance.getOffset(); if (offsetValue != null) { offset(offsetValue); } Long minDocCountValue = instance.getMinDocCount(); if (minDocCountValue != null) { minDocCount(minDocCountValue); } String intervalValue = instance.getInterval(); if (intervalValue != null) { interval(intervalValue); } Boolean keyedValue = instance.isKeyed(); if (keyedValue != null) { keyed(keyedValue); } Long extendedBoundsMinValue = instance.getExtendedBoundsMin(); if (extendedBoundsMinValue != null) { extendedBoundsMin(extendedBoundsMinValue); } Long extendedBoundsMaxValue = instance.getExtendedBoundsMax(); if (extendedBoundsMaxValue != null) { extendedBoundsMax(extendedBoundsMaxValue); } addAllOrder(instance.getOrder()); } if (object instanceof Aggregation) { Aggregation instance = (Aggregation) object; name(instance.getName()); addAllSubAggregations(instance.getSubAggregations()); } 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 DateHistogramAggregation#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 DateHistogramAggregation#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 DateHistogramAggregation#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 DateHistogramAggregation#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 DateHistogramAggregation#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 DateHistogramAggregation#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 DateHistogramAggregation#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 DateHistogramAggregation#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 DateHistogramAggregation#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 DateHistogramAggregation#getExtendedBoundsMax() extendedBoundsMax} attribute. * @param extendedBoundsMax The value for extendedBoundsMax (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("extendedBoundsMax") public final Builder extendedBoundsMax(@Nullable Long extendedBoundsMax) { this.extendedBoundsMax = extendedBoundsMax; return this; } /** * Initializes the value for the {@link DateHistogramAggregation#getExtendedBoundsMin() extendedBoundsMin} attribute. * @param extendedBoundsMin The value for extendedBoundsMin (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("extendedBoundsMin") public final Builder extendedBoundsMin(@Nullable Long extendedBoundsMin) { this.extendedBoundsMin = extendedBoundsMin; return this; } /** * Initializes the value for the {@link DateHistogramAggregation#getInterval() interval} attribute. * @param interval The value for interval (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("interval") public final Builder interval(@Nullable String interval) { this.interval = interval; return this; } /** * Initializes the value for the {@link DateHistogramAggregation#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; } /** * Initializes the value for the {@link DateHistogramAggregation#getOffset() offset} attribute. * @param offset The value for offset (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("offset") public final Builder offset(@Nullable Long offset) { this.offset = offset; return this; } /** * Adds one element to {@link DateHistogramAggregation#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 DateHistogramAggregation#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 DateHistogramAggregation#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 DateHistogramAggregation#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 DateHistogramAggregation#isKeyed() keyed} attribute. * @param keyed The value for keyed (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("keyed") public final Builder keyed(@Nullable Boolean keyed) { this.keyed = keyed; return this; } /** * Builds a new {@link ImmutableDateHistogramAggregation ImmutableDateHistogramAggregation}. * @return An immutable instance of DateHistogramAggregation * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableDateHistogramAggregation build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return new ImmutableDateHistogramAggregation(this); } private boolean subAggregationsIsSet() { return (optBits & OPT_BIT_SUB_AGGREGATIONS) != 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 DateHistogramAggregation, some of required attributes are not set " + attributes; } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy