com.arakelian.elastic.model.ImmutableShards 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.errorprone.annotations.CanIgnoreReturnValue;
import com.google.errorprone.annotations.Var;
import java.util.Objects;
import javax.annotation.CheckReturnValue;
import javax.annotation.Generated;
import javax.annotation.ParametersAreNonnullByDefault;
import javax.annotation.concurrent.Immutable;
import javax.annotation.concurrent.NotThreadSafe;
/**
* Immutable implementation of {@link Shards}.
*
* Use the builder to create immutable instances:
* {@code ImmutableShards.builder()}.
*/
@SuppressWarnings({"all"})
@ParametersAreNonnullByDefault
@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 ImmutableShards(ImmutableShards.Builder builder) {
this.failed = builder.failed;
this.skipped = builder.skipped;
this.successful = builder.successful;
this.total = builder.total;
}
/**
* @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;
}
/**
* 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);
}
/**
* Computes a hash code from attributes: {@code failed}, {@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) + 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("skipped", skipped)
.add("successful", successful)
.add("total", total)
.toString();
}
/**
* Creates a builder for {@link ImmutableShards ImmutableShards}.
* @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.
*/
@NotThreadSafe
public static final class Builder {
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 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.
* @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);
}
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;
}
/**
* 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);
}
}
}