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

com.arakelian.elastic.model.ImmutableBulkResponse Maven / Gradle / Ivy

package com.arakelian.elastic.model;

import com.arakelian.core.feature.Nullable;
import com.fasterxml.jackson.annotation.JsonProperty;
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.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 BulkResponse}.
 * 

* Use the builder to create immutable instances: * {@code ImmutableBulkResponse.builder()}. */ @Generated(from = "BulkResponse", generator = "Immutables") @SuppressWarnings({"all"}) @ParametersAreNonnullByDefault @javax.annotation.processing.Generated("org.immutables.processor.ProxyProcessor") @Immutable @CheckReturnValue public final class ImmutableBulkResponse implements BulkResponse { private final @Nullable Boolean errors; private final @Nullable ImmutableList items; private final @Nullable Integer took; private ImmutableBulkResponse(ImmutableBulkResponse.Builder builder) { this.errors = builder.errors; this.items = builder.items == null ? null : builder.items.build(); this.took = builder.took; } /** * @return The value of the {@code errors} attribute */ @JsonProperty("errors") @Override public @Nullable Boolean getErrors() { return errors; } /** * @return The value of the {@code items} attribute */ @JsonProperty("items") @Override public @Nullable ImmutableList getItems() { return items; } /** * @return The value of the {@code took} attribute */ @JsonProperty("took") @Override public @Nullable Integer getTook() { return took; } /** * This instance is equal to all instances of {@code ImmutableBulkResponse} 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 ImmutableBulkResponse && equalTo((ImmutableBulkResponse) another); } private boolean equalTo(ImmutableBulkResponse another) { return Objects.equals(errors, another.errors) && Objects.equals(items, another.items) && Objects.equals(took, another.took); } /** * Computes a hash code from attributes: {@code errors}, {@code items}, {@code took}. * @return hashCode value */ @Override public int hashCode() { @Var int h = 5381; h += (h << 5) + Objects.hashCode(errors); h += (h << 5) + Objects.hashCode(items); h += (h << 5) + Objects.hashCode(took); return h; } /** * Prints the immutable value {@code BulkResponse} with attribute values. * @return A string representation of the value */ @Override public String toString() { return MoreObjects.toStringHelper("BulkResponse") .omitNullValues() .add("errors", errors) .add("items", items) .add("took", took) .toString(); } /** * Creates a builder for {@link ImmutableBulkResponse ImmutableBulkResponse}. *

   * ImmutableBulkResponse.builder()
   *    .errors(Boolean | null) // nullable {@link BulkResponse#getErrors() errors}
   *    .items(List&lt;com.arakelian.elastic.model.BulkResponse.Item&gt; | null) // nullable {@link BulkResponse#getItems() items}
   *    .took(Integer | null) // nullable {@link BulkResponse#getTook() took}
   *    .build();
   * 
* @return A new ImmutableBulkResponse builder */ public static ImmutableBulkResponse.Builder builder() { return new ImmutableBulkResponse.Builder(); } /** * Builds instances of type {@link ImmutableBulkResponse ImmutableBulkResponse}. * 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 = "BulkResponse", generator = "Immutables") @NotThreadSafe public static final class Builder { private @javax.annotation.Nullable Boolean errors; private ImmutableList.Builder items = null; private @javax.annotation.Nullable Integer took; private Builder() { } /** * Fill a builder with attribute values from the provided {@code BulkResponse} 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 from(BulkResponse instance) { Objects.requireNonNull(instance, "instance"); Boolean errorsValue = instance.getErrors(); if (errorsValue != null) { errors(errorsValue); } List itemsValue = instance.getItems(); if (itemsValue != null) { addAllItems(itemsValue); } Integer tookValue = instance.getTook(); if (tookValue != null) { took(tookValue); } return this; } /** * Initializes the value for the {@link BulkResponse#getErrors() errors} attribute. * @param errors The value for errors (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("errors") public final Builder errors(@Nullable Boolean errors) { this.errors = errors; return this; } /** * Adds one element to {@link BulkResponse#getItems() items} list. * @param element A items element * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addItem(BulkResponse.Item element) { if (this.items == null) { this.items = ImmutableList.builder(); } this.items.add(element); return this; } /** * Adds elements to {@link BulkResponse#getItems() items} list. * @param elements An array of items elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addItems(BulkResponse.Item... elements) { if (this.items == null) { this.items = ImmutableList.builder(); } this.items.add(elements); return this; } /** * Sets or replaces all elements for {@link BulkResponse#getItems() items} list. * @param elements An iterable of items elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("items") public final Builder items(@Nullable Iterable elements) { if (elements == null) { this.items = null; return this; } this.items = ImmutableList.builder(); return addAllItems(elements); } /** * Adds elements to {@link BulkResponse#getItems() items} list. * @param elements An iterable of items elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAllItems(Iterable elements) { Objects.requireNonNull(elements, "items element"); if (this.items == null) { this.items = ImmutableList.builder(); } this.items.addAll(elements); return this; } /** * Initializes the value for the {@link BulkResponse#getTook() took} attribute. * @param took The value for took (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("took") public final Builder took(@Nullable Integer took) { this.took = took; return this; } /** * Builds a new {@link ImmutableBulkResponse ImmutableBulkResponse}. * @return An immutable instance of BulkResponse * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableBulkResponse build() { return new ImmutableBulkResponse(this); } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy