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

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

package com.arakelian.elastic.model;

import com.arakelian.core.feature.Nullable;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.base.MoreObjects;
import com.google.common.collect.ImmutableMap;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.errorprone.annotations.Var;
import java.util.Map;
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 Shards}.
 * 

* Use the builder to create immutable instances: * {@code ImmutableShards.builder()}. */ @Generated(from = "Shards", generator = "Immutables") @SuppressWarnings({"all"}) @ParametersAreNonnullByDefault @javax.annotation.processing.Generated("org.immutables.processor.ProxyProcessor") @Immutable @CheckReturnValue public final class ImmutableShards implements Shards { private final @Nullable Integer failed; private final ImmutableMap properties; private final @Nullable Integer skipped; private final @Nullable Integer successful; private final @Nullable Integer total; private ImmutableShards(ImmutableShards.Builder builder) { this.failed = builder.failed; this.skipped = builder.skipped; this.successful = builder.successful; this.total = builder.total; this.properties = builder.propertiesIsSet() ? builder.properties.build() : ImmutableMap.copyOf(Shards.super.getProperties()); } /** * @return The value of the {@code failed} attribute */ @JsonProperty("failed") @Override public @Nullable Integer getFailed() { return failed; } /** * @return The value of the {@code properties} attribute */ @JsonProperty("properties") @JsonAnyGetter @Override public ImmutableMap getProperties() { return properties; } /** * @return The value of the {@code skipped} attribute */ @JsonProperty("skipped") @Override public @Nullable Integer getSkipped() { return skipped; } /** * @return The value of the {@code successful} attribute */ @JsonProperty("successful") @Override public @Nullable Integer getSuccessful() { return successful; } /** * @return The value of the {@code total} attribute */ @JsonProperty("total") @Override public @Nullable Integer getTotal() { return total; } /** * This instance is equal to all instances of {@code ImmutableShards} 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 ImmutableShards && equalTo((ImmutableShards) another); } private boolean equalTo(ImmutableShards another) { return Objects.equals(failed, another.failed) && properties.equals(another.properties) && Objects.equals(skipped, another.skipped) && Objects.equals(successful, another.successful) && Objects.equals(total, another.total); } /** * Computes a hash code from attributes: {@code failed}, {@code properties}, {@code skipped}, {@code successful}, {@code total}. * @return hashCode value */ @Override public int hashCode() { @Var int h = 5381; h += (h << 5) + Objects.hashCode(failed); h += (h << 5) + properties.hashCode(); h += (h << 5) + Objects.hashCode(skipped); h += (h << 5) + Objects.hashCode(successful); h += (h << 5) + Objects.hashCode(total); return h; } /** * Prints the immutable value {@code Shards} with attribute values. * @return A string representation of the value */ @Override public String toString() { return MoreObjects.toStringHelper("Shards") .omitNullValues() .add("failed", failed) .add("properties", properties) .add("skipped", skipped) .add("successful", successful) .add("total", total) .toString(); } /** * Creates a builder for {@link ImmutableShards ImmutableShards}. *

   * ImmutableShards.builder()
   *    .failed(Integer | null) // nullable {@link Shards#getFailed() failed}
   *    .putProperty|putAllProperties(String => Object) // {@link Shards#getProperties() properties} mappings
   *    .skipped(Integer | null) // nullable {@link Shards#getSkipped() skipped}
   *    .successful(Integer | null) // nullable {@link Shards#getSuccessful() successful}
   *    .total(Integer | null) // nullable {@link Shards#getTotal() total}
   *    .build();
   * 
* @return A new ImmutableShards builder */ public static ImmutableShards.Builder builder() { return new ImmutableShards.Builder(); } /** * Builds instances of type {@link ImmutableShards ImmutableShards}. * 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 = "Shards", generator = "Immutables") @NotThreadSafe public static final class Builder { private static final long OPT_BIT_PROPERTIES = 0x1L; private long optBits; private @javax.annotation.Nullable Integer failed; private ImmutableMap.Builder properties = ImmutableMap.builder(); private @javax.annotation.Nullable Integer skipped; private @javax.annotation.Nullable Integer successful; private @javax.annotation.Nullable Integer total; private Builder() { } /** * Fill a builder with attribute values from the provided {@code Shards} 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(Shards instance) { Objects.requireNonNull(instance, "instance"); Integer failedValue = instance.getFailed(); if (failedValue != null) { failed(failedValue); } putAllProperties(instance.getProperties()); Integer skippedValue = instance.getSkipped(); if (skippedValue != null) { skipped(skippedValue); } Integer successfulValue = instance.getSuccessful(); if (successfulValue != null) { successful(successfulValue); } Integer totalValue = instance.getTotal(); if (totalValue != null) { total(totalValue); } return this; } /** * Initializes the value for the {@link Shards#getFailed() failed} attribute. * @param failed The value for failed (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("failed") public final Builder failed(@Nullable Integer failed) { this.failed = failed; return this; } /** * Put one entry to the {@link Shards#getProperties() properties} map. * @param key The key in the properties map * @param value The associated value in the properties map * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonAnySetter public final Builder putProperty(String key, Object value) { this.properties.put(key, value); optBits |= OPT_BIT_PROPERTIES; return this; } /** * Put one entry to the {@link Shards#getProperties() properties} map. Nulls are not permitted * @param entry The key and value entry * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder putProperty(Map.Entry entry) { this.properties.put(entry); optBits |= OPT_BIT_PROPERTIES; return this; } /** * Sets or replaces all mappings from the specified map as entries for the {@link Shards#getProperties() properties} map. Nulls are not permitted * @param entries The entries that will be added to the properties map * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("properties") public final Builder properties(Map entries) { this.properties = ImmutableMap.builder(); optBits |= OPT_BIT_PROPERTIES; return putAllProperties(entries); } /** * Put all mappings from the specified map as entries to {@link Shards#getProperties() properties} map. Nulls are not permitted * @param entries The entries that will be added to the properties map * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder putAllProperties(Map entries) { this.properties.putAll(entries); optBits |= OPT_BIT_PROPERTIES; return this; } /** * Initializes the value for the {@link Shards#getSkipped() skipped} attribute. * @param skipped The value for skipped (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("skipped") public final Builder skipped(@Nullable Integer skipped) { this.skipped = skipped; return this; } /** * Initializes the value for the {@link Shards#getSuccessful() successful} attribute. * @param successful The value for successful (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("successful") public final Builder successful(@Nullable Integer successful) { this.successful = successful; return this; } /** * Initializes the value for the {@link Shards#getTotal() total} attribute. * @param total The value for total (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("total") public final Builder total(@Nullable Integer total) { this.total = total; return this; } /** * Builds a new {@link ImmutableShards ImmutableShards}. * @return An immutable instance of Shards * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableShards build() { return new ImmutableShards(this); } private boolean propertiesIsSet() { return (optBits & OPT_BIT_PROPERTIES) != 0; } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy