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

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

package com.arakelian.elastic.model;

import com.google.common.base.MoreObjects;
import com.google.common.primitives.Longs;
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.Generated;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import javax.annotation.concurrent.Immutable;
import javax.annotation.concurrent.NotThreadSafe;

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

* Use the builder to create immutable instances: * {@code ImmutableBulkIndexerStats.builder()}. */ @SuppressWarnings({"all"}) @ParametersAreNonnullByDefault @Generated("org.immutables.processor.ProxyProcessor") @Immutable @CheckReturnValue public final class ImmutableBulkIndexerStats implements BulkIndexerStats { private final long failed; private final long retries; private final long submitted; private final long successful; private transient final long total; private final long totalBytes; private final long versionConflicts; private ImmutableBulkIndexerStats(ImmutableBulkIndexerStats.Builder builder) { this.failed = builder.failed; this.retries = builder.retries; this.submitted = builder.submitted; this.successful = builder.successful; this.totalBytes = builder.totalBytes; this.versionConflicts = builder.versionConflicts; this.total = BulkIndexerStats.super.getTotal(); } /** * @return The value of the {@code failed} attribute */ @Override public long getFailed() { return failed; } /** * @return The value of the {@code retries} attribute */ @Override public long getRetries() { return retries; } /** * @return The value of the {@code submitted} attribute */ @Override public long getSubmitted() { return submitted; } /** * @return The value of the {@code successful} attribute */ @Override public long getSuccessful() { return successful; } /** * @return The computed-at-construction value of the {@code total} attribute */ @Override public long getTotal() { return total; } /** * @return The value of the {@code totalBytes} attribute */ @Override public long getTotalBytes() { return totalBytes; } /** * @return The value of the {@code versionConflicts} attribute */ @Override public long getVersionConflicts() { return versionConflicts; } /** * This instance is equal to all instances of {@code ImmutableBulkIndexerStats} 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 ImmutableBulkIndexerStats && equalTo((ImmutableBulkIndexerStats) another); } private boolean equalTo(ImmutableBulkIndexerStats another) { return failed == another.failed && retries == another.retries && submitted == another.submitted && successful == another.successful && total == another.total && totalBytes == another.totalBytes && versionConflicts == another.versionConflicts; } /** * Computes a hash code from attributes: {@code failed}, {@code retries}, {@code submitted}, {@code successful}, {@code total}, {@code totalBytes}, {@code versionConflicts}. * @return hashCode value */ @Override public int hashCode() { @Var int h = 5381; h += (h << 5) + Longs.hashCode(failed); h += (h << 5) + Longs.hashCode(retries); h += (h << 5) + Longs.hashCode(submitted); h += (h << 5) + Longs.hashCode(successful); h += (h << 5) + Longs.hashCode(total); h += (h << 5) + Longs.hashCode(totalBytes); h += (h << 5) + Longs.hashCode(versionConflicts); return h; } /** * Prints the immutable value {@code BulkIndexerStats} with attribute values. * @return A string representation of the value */ @Override public String toString() { return MoreObjects.toStringHelper("BulkIndexerStats") .omitNullValues() .add("failed", failed) .add("retries", retries) .add("submitted", submitted) .add("successful", successful) .add("total", total) .add("totalBytes", totalBytes) .add("versionConflicts", versionConflicts) .toString(); } /** * Creates a builder for {@link ImmutableBulkIndexerStats ImmutableBulkIndexerStats}. * @return A new ImmutableBulkIndexerStats builder */ public static ImmutableBulkIndexerStats.Builder builder() { return new ImmutableBulkIndexerStats.Builder(); } /** * Builds instances of type {@link ImmutableBulkIndexerStats ImmutableBulkIndexerStats}. * 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. */ @NotThreadSafe public static final class Builder { private static final long INIT_BIT_FAILED = 0x1L; private static final long INIT_BIT_RETRIES = 0x2L; private static final long INIT_BIT_SUBMITTED = 0x4L; private static final long INIT_BIT_SUCCESSFUL = 0x8L; private static final long INIT_BIT_TOTAL_BYTES = 0x10L; private static final long INIT_BIT_VERSION_CONFLICTS = 0x20L; private long initBits = 0x3fL; private long failed; private long retries; private long submitted; private long successful; private long totalBytes; private long versionConflicts; private Builder() { } /** * Fill a builder with attribute values from the provided {@code BulkIndexerStats} instance. * Regular attribute values will be replaced with those from the given instance. * Absent optional values will not replace present values. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(BulkIndexerStats instance) { Objects.requireNonNull(instance, "instance"); failed(instance.getFailed()); retries(instance.getRetries()); submitted(instance.getSubmitted()); successful(instance.getSuccessful()); totalBytes(instance.getTotalBytes()); versionConflicts(instance.getVersionConflicts()); return this; } /** * Initializes the value for the {@link BulkIndexerStats#getFailed() failed} attribute. * @param failed The value for failed * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder failed(long failed) { this.failed = failed; initBits &= ~INIT_BIT_FAILED; return this; } /** * Initializes the value for the {@link BulkIndexerStats#getRetries() retries} attribute. * @param retries The value for retries * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder retries(long retries) { this.retries = retries; initBits &= ~INIT_BIT_RETRIES; return this; } /** * Initializes the value for the {@link BulkIndexerStats#getSubmitted() submitted} attribute. * @param submitted The value for submitted * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder submitted(long submitted) { this.submitted = submitted; initBits &= ~INIT_BIT_SUBMITTED; return this; } /** * Initializes the value for the {@link BulkIndexerStats#getSuccessful() successful} attribute. * @param successful The value for successful * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder successful(long successful) { this.successful = successful; initBits &= ~INIT_BIT_SUCCESSFUL; return this; } /** * Initializes the value for the {@link BulkIndexerStats#getTotalBytes() totalBytes} attribute. * @param totalBytes The value for totalBytes * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder totalBytes(long totalBytes) { this.totalBytes = totalBytes; initBits &= ~INIT_BIT_TOTAL_BYTES; return this; } /** * Initializes the value for the {@link BulkIndexerStats#getVersionConflicts() versionConflicts} attribute. * @param versionConflicts The value for versionConflicts * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder versionConflicts(long versionConflicts) { this.versionConflicts = versionConflicts; initBits &= ~INIT_BIT_VERSION_CONFLICTS; return this; } /** * Builds a new {@link ImmutableBulkIndexerStats ImmutableBulkIndexerStats}. * @return An immutable instance of BulkIndexerStats * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableBulkIndexerStats build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return new ImmutableBulkIndexerStats(this); } private String formatRequiredAttributesMessage() { List attributes = new ArrayList<>(); if ((initBits & INIT_BIT_FAILED) != 0) attributes.add("failed"); if ((initBits & INIT_BIT_RETRIES) != 0) attributes.add("retries"); if ((initBits & INIT_BIT_SUBMITTED) != 0) attributes.add("submitted"); if ((initBits & INIT_BIT_SUCCESSFUL) != 0) attributes.add("successful"); if ((initBits & INIT_BIT_TOTAL_BYTES) != 0) attributes.add("totalBytes"); if ((initBits & INIT_BIT_VERSION_CONFLICTS) != 0) attributes.add("versionConflicts"); return "Cannot build BulkIndexerStats, some of required attributes are not set " + attributes; } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy