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

com.arakelian.elastic.model.ImmutableAbout 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.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}.
 * 

* Use the builder to create immutable instances: * {@code ImmutableAbout.builder()}. */ @SuppressWarnings({"all"}) @ParametersAreNonnullByDefault @Generated("org.immutables.processor.ProxyProcessor") @Immutable @CheckReturnValue public final class ImmutableAbout implements About { private final String clusterName; private final @Nullable String clusterUuid; private final String name; private final String tagline; private final About.Version version; private ImmutableAbout(ImmutableAbout.Builder builder) { this.clusterName = builder.clusterName; this.clusterUuid = builder.clusterUuid; this.name = builder.name; this.tagline = builder.tagline; this.version = builder.version; } /** * @return The value of the {@code clusterName} attribute */ @JsonProperty("cluster_name") @Override public String getClusterName() { return clusterName; } /** * @return The value of the {@code clusterUuid} attribute */ @JsonProperty("cluster_uuid") @Override public @Nullable String getClusterUuid() { return clusterUuid; } /** * @return The value of the {@code name} attribute */ @JsonProperty("name") @Override public String getName() { return name; } /** * @return The value of the {@code tagline} attribute */ @JsonProperty("tagline") @Override public String getTagline() { return tagline; } /** * @return The value of the {@code version} attribute */ @JsonProperty("version") @Override public About.Version getVersion() { return version; } /** * This instance is equal to all instances of {@code ImmutableAbout} 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 ImmutableAbout && equalTo((ImmutableAbout) another); } private boolean equalTo(ImmutableAbout another) { return clusterName.equals(another.clusterName) && Objects.equals(clusterUuid, another.clusterUuid) && name.equals(another.name) && tagline.equals(another.tagline) && version.equals(another.version); } /** * Computes a hash code from attributes: {@code clusterName}, {@code clusterUuid}, {@code name}, {@code tagline}, {@code version}. * @return hashCode value */ @Override public int hashCode() { @Var int h = 5381; h += (h << 5) + clusterName.hashCode(); h += (h << 5) + Objects.hashCode(clusterUuid); h += (h << 5) + name.hashCode(); h += (h << 5) + tagline.hashCode(); h += (h << 5) + version.hashCode(); return h; } /** * Prints the immutable value {@code About} with attribute values. * @return A string representation of the value */ @Override public String toString() { return MoreObjects.toStringHelper("About") .omitNullValues() .add("clusterName", clusterName) .add("clusterUuid", clusterUuid) .add("name", name) .add("tagline", tagline) .add("version", version) .toString(); } /** * Creates a builder for {@link ImmutableAbout ImmutableAbout}. * @return A new ImmutableAbout builder */ public static ImmutableAbout.Builder builder() { return new ImmutableAbout.Builder(); } /** * Builds instances of type {@link ImmutableAbout ImmutableAbout}. * 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_CLUSTER_NAME = 0x1L; private static final long INIT_BIT_NAME = 0x2L; private static final long INIT_BIT_TAGLINE = 0x4L; private static final long INIT_BIT_VERSION = 0x8L; private long initBits = 0xfL; private @javax.annotation.Nullable String clusterName; private @javax.annotation.Nullable String clusterUuid; private @javax.annotation.Nullable String name; private @javax.annotation.Nullable String tagline; private @javax.annotation.Nullable About.Version version; private Builder() { } /** * Fill a builder with attribute values from the provided {@code About} 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 instance) { Objects.requireNonNull(instance, "instance"); clusterName(instance.getClusterName()); String clusterUuidValue = instance.getClusterUuid(); if (clusterUuidValue != null) { clusterUuid(clusterUuidValue); } name(instance.getName()); tagline(instance.getTagline()); version(instance.getVersion()); return this; } /** * Initializes the value for the {@link About#getClusterName() clusterName} attribute. * @param clusterName The value for clusterName * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("cluster_name") public final Builder clusterName(String clusterName) { this.clusterName = Objects.requireNonNull(clusterName, "clusterName"); initBits &= ~INIT_BIT_CLUSTER_NAME; return this; } /** * Initializes the value for the {@link About#getClusterUuid() clusterUuid} attribute. * @param clusterUuid The value for clusterUuid (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("cluster_uuid") public final Builder clusterUuid(@Nullable String clusterUuid) { this.clusterUuid = clusterUuid; return this; } /** * Initializes the value for the {@link About#getName() name} attribute. * @param name The value for name * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("name") public final Builder name(String name) { this.name = Objects.requireNonNull(name, "name"); initBits &= ~INIT_BIT_NAME; return this; } /** * Initializes the value for the {@link About#getTagline() tagline} attribute. * @param tagline The value for tagline * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("tagline") public final Builder tagline(String tagline) { this.tagline = Objects.requireNonNull(tagline, "tagline"); initBits &= ~INIT_BIT_TAGLINE; return this; } /** * Initializes the value for the {@link About#getVersion() version} attribute. * @param version The value for version * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("version") public final Builder version(About.Version version) { this.version = Objects.requireNonNull(version, "version"); initBits &= ~INIT_BIT_VERSION; return this; } /** * Builds a new {@link ImmutableAbout ImmutableAbout}. * @return An immutable instance of About * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableAbout build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return new ImmutableAbout(this); } private String formatRequiredAttributesMessage() { List attributes = new ArrayList<>(); if ((initBits & INIT_BIT_CLUSTER_NAME) != 0) attributes.add("clusterName"); if ((initBits & INIT_BIT_NAME) != 0) attributes.add("name"); if ((initBits & INIT_BIT_TAGLINE) != 0) attributes.add("tagline"); if ((initBits & INIT_BIT_VERSION) != 0) attributes.add("version"); return "Cannot build About, some of required attributes are not set " + attributes; } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy