com.arakelian.elastic.model.ImmutableVersion Maven / Gradle / Ivy
package com.arakelian.elastic.model;
import com.arakelian.core.feature.Nullable;
import com.arakelian.elastic.Views;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonView;
import com.google.common.base.MoreObjects;
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.ParametersAreNonnullByDefault;
import javax.annotation.concurrent.Immutable;
import javax.annotation.concurrent.NotThreadSafe;
/**
* Immutable implementation of {@link About.Version}.
*
* Use the builder to create immutable instances:
* {@code ImmutableVersion.builder()}.
*/
@SuppressWarnings({"all"})
@ParametersAreNonnullByDefault
@Generated("org.immutables.processor.ProxyProcessor")
@Immutable
@CheckReturnValue
public final class ImmutableVersion implements About.Version {
private final @Nullable String buildDate;
private final @Nullable String buildFlavor;
private final String buildHash;
private final Boolean buildSnapshot;
private final @Nullable String buildTimestamp;
private final @Nullable String buildType;
private transient final VersionComponents components;
private final String luceneVersion;
private final @Nullable String minimumIndexCompatibilityVersion;
private final @Nullable String minimumWireCompatibilityVersion;
private final String number;
private ImmutableVersion(ImmutableVersion.Builder builder) {
this.buildDate = builder.buildDate;
this.buildFlavor = builder.buildFlavor;
this.buildHash = builder.buildHash;
this.buildSnapshot = builder.buildSnapshot;
this.buildTimestamp = builder.buildTimestamp;
this.buildType = builder.buildType;
this.luceneVersion = builder.luceneVersion;
this.minimumIndexCompatibilityVersion = builder.minimumIndexCompatibilityVersion;
this.minimumWireCompatibilityVersion = builder.minimumWireCompatibilityVersion;
this.number = builder.number;
this.components = Objects.requireNonNull(About.Version.super.getComponents(), "components");
}
/**
* @return The value of the {@code buildDate} attribute
*/
@JsonProperty("build_date")
@Override
public @Nullable String getBuildDate() {
return buildDate;
}
/**
* @return The value of the {@code buildFlavor} attribute
*/
@JsonProperty("build_flavor")
@JsonView(Views.Elastic.Version6.Version63.class)
@Override
public @Nullable String getBuildFlavor() {
return buildFlavor;
}
/**
* @return The value of the {@code buildHash} attribute
*/
@JsonProperty("build_hash")
@Override
public String getBuildHash() {
return buildHash;
}
/**
* @return The value of the {@code buildSnapshot} attribute
*/
@JsonProperty("build_snapshot")
@Override
public Boolean getBuildSnapshot() {
return buildSnapshot;
}
/**
* @return The value of the {@code buildTimestamp} attribute
*/
@JsonProperty("build_timestamp")
@Override
public @Nullable String getBuildTimestamp() {
return buildTimestamp;
}
/**
* @return The value of the {@code buildType} attribute
*/
@JsonProperty("build_type")
@JsonView(Views.Elastic.Version6.Version63.class)
@Override
public @Nullable String getBuildType() {
return buildType;
}
/**
* @return The computed-at-construction value of the {@code components} attribute
*/
@JsonProperty("components")
@JsonIgnore
@Override
public VersionComponents getComponents() {
return components;
}
/**
* @return The value of the {@code luceneVersion} attribute
*/
@JsonProperty("lucene_version")
@Override
public String getLuceneVersion() {
return luceneVersion;
}
/**
* Returns the minimum index compatibility version.
* @return minimum index compatibility version.
*/
@JsonProperty("minimum_index_compatibility_version")
@JsonView(Views.Elastic.Version6.class)
@Override
public @Nullable String getMinimumIndexCompatibilityVersion() {
return minimumIndexCompatibilityVersion;
}
/**
* Returns the minimum wire compatibility version.
* @since Elastic 6.0
* @return minimum wire compatibility version.
*/
@JsonProperty("minimum_wire_compatibility_version")
@JsonView(Views.Elastic.Version6.class)
@Override
public @Nullable String getMinimumWireCompatibilityVersion() {
return minimumWireCompatibilityVersion;
}
/**
* @return The value of the {@code number} attribute
*/
@JsonProperty("number")
@Override
public String getNumber() {
return number;
}
/**
* This instance is equal to all instances of {@code ImmutableVersion} 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 ImmutableVersion
&& equalTo((ImmutableVersion) another);
}
private boolean equalTo(ImmutableVersion another) {
return Objects.equals(buildDate, another.buildDate)
&& Objects.equals(buildFlavor, another.buildFlavor)
&& buildHash.equals(another.buildHash)
&& buildSnapshot.equals(another.buildSnapshot)
&& Objects.equals(buildTimestamp, another.buildTimestamp)
&& Objects.equals(buildType, another.buildType)
&& components.equals(another.components)
&& luceneVersion.equals(another.luceneVersion)
&& Objects.equals(minimumIndexCompatibilityVersion, another.minimumIndexCompatibilityVersion)
&& Objects.equals(minimumWireCompatibilityVersion, another.minimumWireCompatibilityVersion)
&& number.equals(another.number);
}
/**
* Computes a hash code from attributes: {@code buildDate}, {@code buildFlavor}, {@code buildHash}, {@code buildSnapshot}, {@code buildTimestamp}, {@code buildType}, {@code components}, {@code luceneVersion}, {@code minimumIndexCompatibilityVersion}, {@code minimumWireCompatibilityVersion}, {@code number}.
* @return hashCode value
*/
@Override
public int hashCode() {
@Var int h = 5381;
h += (h << 5) + Objects.hashCode(buildDate);
h += (h << 5) + Objects.hashCode(buildFlavor);
h += (h << 5) + buildHash.hashCode();
h += (h << 5) + buildSnapshot.hashCode();
h += (h << 5) + Objects.hashCode(buildTimestamp);
h += (h << 5) + Objects.hashCode(buildType);
h += (h << 5) + components.hashCode();
h += (h << 5) + luceneVersion.hashCode();
h += (h << 5) + Objects.hashCode(minimumIndexCompatibilityVersion);
h += (h << 5) + Objects.hashCode(minimumWireCompatibilityVersion);
h += (h << 5) + number.hashCode();
return h;
}
/**
* Prints the immutable value {@code Version} with attribute values.
* @return A string representation of the value
*/
@Override
public String toString() {
return MoreObjects.toStringHelper("Version")
.omitNullValues()
.add("buildDate", buildDate)
.add("buildFlavor", buildFlavor)
.add("buildHash", buildHash)
.add("buildSnapshot", buildSnapshot)
.add("buildTimestamp", buildTimestamp)
.add("buildType", buildType)
.add("components", components)
.add("luceneVersion", luceneVersion)
.add("minimumIndexCompatibilityVersion", minimumIndexCompatibilityVersion)
.add("minimumWireCompatibilityVersion", minimumWireCompatibilityVersion)
.add("number", number)
.toString();
}
/**
* Creates a builder for {@link ImmutableVersion ImmutableVersion}.
* @return A new ImmutableVersion builder
*/
public static ImmutableVersion.Builder builder() {
return new ImmutableVersion.Builder();
}
/**
* Builds instances of type {@link ImmutableVersion ImmutableVersion}.
* 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_BUILD_HASH = 0x1L;
private static final long INIT_BIT_BUILD_SNAPSHOT = 0x2L;
private static final long INIT_BIT_LUCENE_VERSION = 0x4L;
private static final long INIT_BIT_NUMBER = 0x8L;
private long initBits = 0xfL;
private @javax.annotation.Nullable String buildDate;
private @javax.annotation.Nullable String buildFlavor;
private @javax.annotation.Nullable String buildHash;
private @javax.annotation.Nullable Boolean buildSnapshot;
private @javax.annotation.Nullable String buildTimestamp;
private @javax.annotation.Nullable String buildType;
private @javax.annotation.Nullable String luceneVersion;
private @javax.annotation.Nullable String minimumIndexCompatibilityVersion;
private @javax.annotation.Nullable String minimumWireCompatibilityVersion;
private @javax.annotation.Nullable String number;
private Builder() {
}
/**
* Fill a builder with attribute values from the provided {@code Version} 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(About.Version instance) {
Objects.requireNonNull(instance, "instance");
String buildDateValue = instance.getBuildDate();
if (buildDateValue != null) {
buildDate(buildDateValue);
}
String buildFlavorValue = instance.getBuildFlavor();
if (buildFlavorValue != null) {
buildFlavor(buildFlavorValue);
}
buildHash(instance.getBuildHash());
buildSnapshot(instance.getBuildSnapshot());
String buildTimestampValue = instance.getBuildTimestamp();
if (buildTimestampValue != null) {
buildTimestamp(buildTimestampValue);
}
String buildTypeValue = instance.getBuildType();
if (buildTypeValue != null) {
buildType(buildTypeValue);
}
luceneVersion(instance.getLuceneVersion());
String minimumIndexCompatibilityVersionValue = instance.getMinimumIndexCompatibilityVersion();
if (minimumIndexCompatibilityVersionValue != null) {
minimumIndexCompatibilityVersion(minimumIndexCompatibilityVersionValue);
}
String minimumWireCompatibilityVersionValue = instance.getMinimumWireCompatibilityVersion();
if (minimumWireCompatibilityVersionValue != null) {
minimumWireCompatibilityVersion(minimumWireCompatibilityVersionValue);
}
number(instance.getNumber());
return this;
}
/**
* Initializes the value for the {@link About.Version#getBuildDate() buildDate} attribute.
* @param buildDate The value for buildDate (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("build_date")
public final Builder buildDate(@Nullable String buildDate) {
this.buildDate = buildDate;
return this;
}
/**
* Initializes the value for the {@link About.Version#getBuildFlavor() buildFlavor} attribute.
* @param buildFlavor The value for buildFlavor (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("build_flavor")
@JsonView(Views.Elastic.Version6.Version63.class)
public final Builder buildFlavor(@Nullable String buildFlavor) {
this.buildFlavor = buildFlavor;
return this;
}
/**
* Initializes the value for the {@link About.Version#getBuildHash() buildHash} attribute.
* @param buildHash The value for buildHash
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("build_hash")
public final Builder buildHash(String buildHash) {
this.buildHash = Objects.requireNonNull(buildHash, "buildHash");
initBits &= ~INIT_BIT_BUILD_HASH;
return this;
}
/**
* Initializes the value for the {@link About.Version#getBuildSnapshot() buildSnapshot} attribute.
* @param buildSnapshot The value for buildSnapshot
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("build_snapshot")
public final Builder buildSnapshot(Boolean buildSnapshot) {
this.buildSnapshot = Objects.requireNonNull(buildSnapshot, "buildSnapshot");
initBits &= ~INIT_BIT_BUILD_SNAPSHOT;
return this;
}
/**
* Initializes the value for the {@link About.Version#getBuildTimestamp() buildTimestamp} attribute.
* @param buildTimestamp The value for buildTimestamp (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("build_timestamp")
public final Builder buildTimestamp(@Nullable String buildTimestamp) {
this.buildTimestamp = buildTimestamp;
return this;
}
/**
* Initializes the value for the {@link About.Version#getBuildType() buildType} attribute.
* @param buildType The value for buildType (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("build_type")
@JsonView(Views.Elastic.Version6.Version63.class)
public final Builder buildType(@Nullable String buildType) {
this.buildType = buildType;
return this;
}
/**
* Initializes the value for the {@link About.Version#getLuceneVersion() luceneVersion} attribute.
* @param luceneVersion The value for luceneVersion
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("lucene_version")
public final Builder luceneVersion(String luceneVersion) {
this.luceneVersion = Objects.requireNonNull(luceneVersion, "luceneVersion");
initBits &= ~INIT_BIT_LUCENE_VERSION;
return this;
}
/**
* Initializes the value for the {@link About.Version#getMinimumIndexCompatibilityVersion() minimumIndexCompatibilityVersion} attribute.
* @param minimumIndexCompatibilityVersion The value for minimumIndexCompatibilityVersion (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("minimum_index_compatibility_version")
@JsonView(Views.Elastic.Version6.class)
public final Builder minimumIndexCompatibilityVersion(@Nullable String minimumIndexCompatibilityVersion) {
this.minimumIndexCompatibilityVersion = minimumIndexCompatibilityVersion;
return this;
}
/**
* Initializes the value for the {@link About.Version#getMinimumWireCompatibilityVersion() minimumWireCompatibilityVersion} attribute.
* @param minimumWireCompatibilityVersion The value for minimumWireCompatibilityVersion (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("minimum_wire_compatibility_version")
@JsonView(Views.Elastic.Version6.class)
public final Builder minimumWireCompatibilityVersion(@Nullable String minimumWireCompatibilityVersion) {
this.minimumWireCompatibilityVersion = minimumWireCompatibilityVersion;
return this;
}
/**
* Initializes the value for the {@link About.Version#getNumber() number} attribute.
* @param number The value for number
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("number")
public final Builder number(String number) {
this.number = Objects.requireNonNull(number, "number");
initBits &= ~INIT_BIT_NUMBER;
return this;
}
/**
* Builds a new {@link ImmutableVersion ImmutableVersion}.
* @return An immutable instance of Version
* @throws java.lang.IllegalStateException if any required attributes are missing
*/
public ImmutableVersion build() {
if (initBits != 0) {
throw new IllegalStateException(formatRequiredAttributesMessage());
}
return new ImmutableVersion(this);
}
private String formatRequiredAttributesMessage() {
List attributes = new ArrayList<>();
if ((initBits & INIT_BIT_BUILD_HASH) != 0) attributes.add("buildHash");
if ((initBits & INIT_BIT_BUILD_SNAPSHOT) != 0) attributes.add("buildSnapshot");
if ((initBits & INIT_BIT_LUCENE_VERSION) != 0) attributes.add("luceneVersion");
if ((initBits & INIT_BIT_NUMBER) != 0) attributes.add("number");
return "Cannot build Version, some of required attributes are not set " + attributes;
}
}
}