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 @Nullable Integer skipped;
private final @Nullable Integer successful;
private final @Nullable Integer total;
private final ImmutableMap properties;
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 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;
}
/**
* @return The value of the {@code properties} attribute
*/
@JsonProperty("properties")
@JsonAnyGetter
@Override
public ImmutableMap getProperties() {
return properties;
}
/**
* 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)
&& Objects.equals(skipped, another.skipped)
&& Objects.equals(successful, another.successful)
&& Objects.equals(total, another.total)
&& properties.equals(another.properties);
}
/**
* Computes a hash code from attributes: {@code failed}, {@code skipped}, {@code successful}, {@code total}, {@code properties}.
* @return hashCode value
*/
@Override
public int hashCode() {
@Var int h = 5381;
h += (h << 5) + Objects.hashCode(failed);
h += (h << 5) + Objects.hashCode(skipped);
h += (h << 5) + Objects.hashCode(successful);
h += (h << 5) + Objects.hashCode(total);
h += (h << 5) + properties.hashCode();
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("skipped", skipped)
.add("successful", successful)
.add("total", total)
.add("properties", properties)
.toString();
}
/**
* Creates a builder for {@link ImmutableShards ImmutableShards}.
*
* ImmutableShards.builder()
* .failed(Integer | null) // nullable {@link Shards#getFailed() failed}
* .skipped(Integer | null) // nullable {@link Shards#getSkipped() skipped}
* .successful(Integer | null) // nullable {@link Shards#getSuccessful() successful}
* .total(Integer | null) // nullable {@link Shards#getTotal() total}
* .putProperty|putAllProperties(String => Object) // {@link Shards#getProperties() properties} mappings
* .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 @javax.annotation.Nullable Integer skipped;
private @javax.annotation.Nullable Integer successful;
private @javax.annotation.Nullable Integer total;
private ImmutableMap.Builder properties = ImmutableMap.builder();
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);
}
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);
}
putAllProperties(instance.getProperties());
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;
}
/**
* 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;
}
/**
* 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;
}
/**
* 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;
}
}
}