com.arakelian.elastic.model.ImmutableIndexCreated 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 IndexCreated}.
*
* Use the builder to create immutable instances:
* {@code ImmutableIndexCreated.builder()}.
*/
@SuppressWarnings({"all"})
@ParametersAreNonnullByDefault
@Generated("org.immutables.processor.ProxyProcessor")
@Immutable
@CheckReturnValue
public final class ImmutableIndexCreated implements IndexCreated {
private final @Nullable Boolean acknowledged;
private final @Nullable String index;
private final @Nullable Boolean shardsAcknowledged;
private ImmutableIndexCreated(ImmutableIndexCreated.Builder builder) {
this.acknowledged = builder.acknowledged;
this.index = builder.index;
this.shardsAcknowledged = builder.shardsAcknowledged;
}
/**
* @return The value of the {@code acknowledged} attribute
*/
@JsonProperty("acknowledged")
@Override
public @Nullable Boolean getAcknowledged() {
return acknowledged;
}
/**
* Returns the name of the index
* @return name of the index
*/
@JsonProperty("index")
@Override
public @Nullable String getIndex() {
return index;
}
/**
* @return The value of the {@code shardsAcknowledged} attribute
*/
@JsonProperty("shards_acknowledged")
@Override
public @Nullable Boolean getShardsAcknowledged() {
return shardsAcknowledged;
}
/**
* This instance is equal to all instances of {@code ImmutableIndexCreated} 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 ImmutableIndexCreated
&& equalTo((ImmutableIndexCreated) another);
}
private boolean equalTo(ImmutableIndexCreated another) {
return Objects.equals(acknowledged, another.acknowledged)
&& Objects.equals(index, another.index)
&& Objects.equals(shardsAcknowledged, another.shardsAcknowledged);
}
/**
* Computes a hash code from attributes: {@code acknowledged}, {@code index}, {@code shardsAcknowledged}.
* @return hashCode value
*/
@Override
public int hashCode() {
@Var int h = 5381;
h += (h << 5) + Objects.hashCode(acknowledged);
h += (h << 5) + Objects.hashCode(index);
h += (h << 5) + Objects.hashCode(shardsAcknowledged);
return h;
}
/**
* Prints the immutable value {@code IndexCreated} with attribute values.
* @return A string representation of the value
*/
@Override
public String toString() {
return MoreObjects.toStringHelper("IndexCreated")
.omitNullValues()
.add("acknowledged", acknowledged)
.add("index", index)
.add("shardsAcknowledged", shardsAcknowledged)
.toString();
}
/**
* Creates a builder for {@link ImmutableIndexCreated ImmutableIndexCreated}.
* @return A new ImmutableIndexCreated builder
*/
public static ImmutableIndexCreated.Builder builder() {
return new ImmutableIndexCreated.Builder();
}
/**
* Builds instances of type {@link ImmutableIndexCreated ImmutableIndexCreated}.
* 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 Boolean acknowledged;
private @javax.annotation.Nullable String index;
private @javax.annotation.Nullable Boolean shardsAcknowledged;
private Builder() {
}
/**
* Fill a builder with attribute values from the provided {@code IndexCreated} 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(IndexCreated instance) {
Objects.requireNonNull(instance, "instance");
Boolean acknowledgedValue = instance.getAcknowledged();
if (acknowledgedValue != null) {
acknowledged(acknowledgedValue);
}
String indexValue = instance.getIndex();
if (indexValue != null) {
index(indexValue);
}
Boolean shardsAcknowledgedValue = instance.getShardsAcknowledged();
if (shardsAcknowledgedValue != null) {
shardsAcknowledged(shardsAcknowledgedValue);
}
return this;
}
/**
* Initializes the value for the {@link IndexCreated#getAcknowledged() acknowledged} attribute.
* @param acknowledged The value for acknowledged (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("acknowledged")
public final Builder acknowledged(@Nullable Boolean acknowledged) {
this.acknowledged = acknowledged;
return this;
}
/**
* Initializes the value for the {@link IndexCreated#getIndex() index} attribute.
* @param index The value for index (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("index")
public final Builder index(@Nullable String index) {
this.index = index;
return this;
}
/**
* Initializes the value for the {@link IndexCreated#getShardsAcknowledged() shardsAcknowledged} attribute.
* @param shardsAcknowledged The value for shardsAcknowledged (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("shards_acknowledged")
public final Builder shardsAcknowledged(@Nullable Boolean shardsAcknowledged) {
this.shardsAcknowledged = shardsAcknowledged;
return this;
}
/**
* Builds a new {@link ImmutableIndexCreated ImmutableIndexCreated}.
* @return An immutable instance of IndexCreated
* @throws java.lang.IllegalStateException if any required attributes are missing
*/
public ImmutableIndexCreated build() {
return new ImmutableIndexCreated(this);
}
}
}