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

com.arakelian.elastic.model.ImmutableHttp Maven / Gradle / Ivy

package com.arakelian.elastic.model;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.google.common.base.MoreObjects;
import com.google.common.collect.ImmutableList;
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.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import javax.annotation.concurrent.Immutable;
import javax.annotation.concurrent.NotThreadSafe;
import org.immutables.value.Generated;

/**
 * Immutable implementation of {@link Nodes.NodeInfo.Http}.
 * 

* Use the builder to create immutable instances: * {@code ImmutableHttp.builder()}. */ @Generated(from = "Nodes.NodeInfo.Http", generator = "Immutables") @SuppressWarnings({"all"}) @ParametersAreNonnullByDefault @javax.annotation.processing.Generated("org.immutables.processor.ProxyProcessor") @Immutable @CheckReturnValue public final class ImmutableHttp implements Nodes.NodeInfo.Http { private final ImmutableList boundAddresses; private final int maxContentLengthInBytes; private final String publishAddress; private ImmutableHttp(ImmutableHttp.Builder builder) { this.maxContentLengthInBytes = builder.maxContentLengthInBytes; this.publishAddress = builder.publishAddress; this.boundAddresses = builder.boundAddressesIsSet() ? builder.boundAddresses.build() : ImmutableList.copyOf(Nodes.NodeInfo.Http.super.getBoundAddresses()); } /** * @return The value of the {@code boundAddresses} attribute */ @JsonProperty("bound_address") @Override public ImmutableList getBoundAddresses() { return boundAddresses; } /** * @return The value of the {@code maxContentLengthInBytes} attribute */ @JsonProperty("max_content_length_in_bytes") @Override public int getMaxContentLengthInBytes() { return maxContentLengthInBytes; } /** * @return The value of the {@code publishAddress} attribute */ @JsonProperty("publish_address") @Override public String getPublishAddress() { return publishAddress; } /** * This instance is equal to all instances of {@code ImmutableHttp} that have equal attribute values. * @return {@code true} if {@code this} is equal to {@code another} instance */ @Override public boolean equals(@Nullable Object another) { if (this == another) return true; return another instanceof ImmutableHttp && equalTo((ImmutableHttp) another); } private boolean equalTo(ImmutableHttp another) { return boundAddresses.equals(another.boundAddresses) && maxContentLengthInBytes == another.maxContentLengthInBytes && publishAddress.equals(another.publishAddress); } /** * Computes a hash code from attributes: {@code boundAddresses}, {@code maxContentLengthInBytes}, {@code publishAddress}. * @return hashCode value */ @Override public int hashCode() { @Var int h = 5381; h += (h << 5) + boundAddresses.hashCode(); h += (h << 5) + maxContentLengthInBytes; h += (h << 5) + publishAddress.hashCode(); return h; } /** * Prints the immutable value {@code Http} with attribute values. * @return A string representation of the value */ @Override public String toString() { return MoreObjects.toStringHelper("Http") .omitNullValues() .add("boundAddresses", boundAddresses) .add("maxContentLengthInBytes", maxContentLengthInBytes) .add("publishAddress", publishAddress) .toString(); } /** * Creates a builder for {@link ImmutableHttp ImmutableHttp}. *

   * ImmutableHttp.builder()
   *    .addBoundAddress|addAllBoundAddresses(String) // {@link Nodes.NodeInfo.Http#getBoundAddresses() boundAddresses} elements
   *    .maxContentLengthInBytes(int) // required {@link Nodes.NodeInfo.Http#getMaxContentLengthInBytes() maxContentLengthInBytes}
   *    .publishAddress(String) // required {@link Nodes.NodeInfo.Http#getPublishAddress() publishAddress}
   *    .build();
   * 
* @return A new ImmutableHttp builder */ public static ImmutableHttp.Builder builder() { return new ImmutableHttp.Builder(); } /** * Builds instances of type {@link ImmutableHttp ImmutableHttp}. * 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 = "Nodes.NodeInfo.Http", generator = "Immutables") @NotThreadSafe @JsonPropertyOrder({"bound_address", "publish_address", "max_content_length_in_bytes"}) public static final class Builder { private static final long INIT_BIT_MAX_CONTENT_LENGTH_IN_BYTES = 0x1L; private static final long INIT_BIT_PUBLISH_ADDRESS = 0x2L; private static final long OPT_BIT_BOUND_ADDRESSES = 0x1L; private long initBits = 0x3L; private long optBits; private ImmutableList.Builder boundAddresses = ImmutableList.builder(); private int maxContentLengthInBytes; private @Nullable String publishAddress; private Builder() { } /** * Fill a builder with attribute values from the provided {@code Http} 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(Nodes.NodeInfo.Http instance) { Objects.requireNonNull(instance, "instance"); addAllBoundAddresses(instance.getBoundAddresses()); maxContentLengthInBytes(instance.getMaxContentLengthInBytes()); publishAddress(instance.getPublishAddress()); return this; } /** * Adds one element to {@link Nodes.NodeInfo.Http#getBoundAddresses() boundAddresses} list. * @param element A boundAddresses element * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addBoundAddress(String element) { this.boundAddresses.add(element); optBits |= OPT_BIT_BOUND_ADDRESSES; return this; } /** * Adds elements to {@link Nodes.NodeInfo.Http#getBoundAddresses() boundAddresses} list. * @param elements An array of boundAddresses elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addBoundAddresses(String... elements) { this.boundAddresses.add(elements); optBits |= OPT_BIT_BOUND_ADDRESSES; return this; } /** * Sets or replaces all elements for {@link Nodes.NodeInfo.Http#getBoundAddresses() boundAddresses} list. * @param elements An iterable of boundAddresses elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("bound_address") public final Builder boundAddresses(Iterable elements) { this.boundAddresses = ImmutableList.builder(); return addAllBoundAddresses(elements); } /** * Adds elements to {@link Nodes.NodeInfo.Http#getBoundAddresses() boundAddresses} list. * @param elements An iterable of boundAddresses elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAllBoundAddresses(Iterable elements) { this.boundAddresses.addAll(elements); optBits |= OPT_BIT_BOUND_ADDRESSES; return this; } /** * Initializes the value for the {@link Nodes.NodeInfo.Http#getMaxContentLengthInBytes() maxContentLengthInBytes} attribute. * @param maxContentLengthInBytes The value for maxContentLengthInBytes * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("max_content_length_in_bytes") public final Builder maxContentLengthInBytes(int maxContentLengthInBytes) { this.maxContentLengthInBytes = maxContentLengthInBytes; initBits &= ~INIT_BIT_MAX_CONTENT_LENGTH_IN_BYTES; return this; } /** * Initializes the value for the {@link Nodes.NodeInfo.Http#getPublishAddress() publishAddress} attribute. * @param publishAddress The value for publishAddress * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("publish_address") public final Builder publishAddress(String publishAddress) { this.publishAddress = Objects.requireNonNull(publishAddress, "publishAddress"); initBits &= ~INIT_BIT_PUBLISH_ADDRESS; return this; } /** * Builds a new {@link ImmutableHttp ImmutableHttp}. * @return An immutable instance of Http * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableHttp build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return new ImmutableHttp(this); } private boolean boundAddressesIsSet() { return (optBits & OPT_BIT_BOUND_ADDRESSES) != 0; } private String formatRequiredAttributesMessage() { List attributes = new ArrayList<>(); if ((initBits & INIT_BIT_MAX_CONTENT_LENGTH_IN_BYTES) != 0) attributes.add("maxContentLengthInBytes"); if ((initBits & INIT_BIT_PUBLISH_ADDRESS) != 0) attributes.add("publishAddress"); return "Cannot build Http, some of required attributes are not set " + attributes; } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy