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

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

package com.arakelian.elastic.model;

import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.google.common.base.MoreObjects;
import com.google.common.collect.ImmutableMap;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.errorprone.annotations.Var;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
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 IndexSettings.NamedTokenizer}.
 * 

* Use the builder to create immutable instances: * {@code ImmutableNamedTokenizer.builder()}. */ @Generated(from = "IndexSettings.NamedTokenizer", generator = "Immutables") @SuppressWarnings({"all"}) @ParametersAreNonnullByDefault @javax.annotation.processing.Generated("org.immutables.processor.ProxyProcessor") @Immutable @CheckReturnValue public final class ImmutableNamedTokenizer implements IndexSettings.NamedTokenizer { private final ImmutableMap properties; private final String type; private ImmutableNamedTokenizer(ImmutableNamedTokenizer.Builder builder) { this.type = builder.type; this.properties = builder.propertiesIsSet() ? builder.properties.build() : ImmutableMap.copyOf(IndexSettings.NamedTokenizer.super.getProperties()); } /** * @return The value of the {@code properties} attribute */ @JsonProperty("properties") @JsonAnyGetter @Override public ImmutableMap getProperties() { return properties; } /** * @return The value of the {@code type} attribute */ @JsonProperty("type") @Override public String getType() { return type; } /** * This instance is equal to all instances of {@code ImmutableNamedTokenizer} 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 ImmutableNamedTokenizer && equalTo((ImmutableNamedTokenizer) another); } private boolean equalTo(ImmutableNamedTokenizer another) { return properties.equals(another.properties) && type.equals(another.type); } /** * Computes a hash code from attributes: {@code properties}, {@code type}. * @return hashCode value */ @Override public int hashCode() { @Var int h = 5381; h += (h << 5) + properties.hashCode(); h += (h << 5) + type.hashCode(); return h; } /** * Prints the immutable value {@code NamedTokenizer} with attribute values. * @return A string representation of the value */ @Override public String toString() { return MoreObjects.toStringHelper("NamedTokenizer") .omitNullValues() .add("properties", properties) .add("type", type) .toString(); } /** * Creates a builder for {@link ImmutableNamedTokenizer ImmutableNamedTokenizer}. *

   * ImmutableNamedTokenizer.builder()
   *    .putProperty|putAllProperties(String => Object) // {@link IndexSettings.NamedTokenizer#getProperties() properties} mappings
   *    .type(String) // required {@link IndexSettings.NamedTokenizer#getType() type}
   *    .build();
   * 
* @return A new ImmutableNamedTokenizer builder */ public static ImmutableNamedTokenizer.Builder builder() { return new ImmutableNamedTokenizer.Builder(); } /** * Builds instances of type {@link ImmutableNamedTokenizer ImmutableNamedTokenizer}. * 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 = "IndexSettings.NamedTokenizer", generator = "Immutables") @NotThreadSafe @JsonPropertyOrder("type") public static final class Builder { private static final long INIT_BIT_TYPE = 0x1L; private static final long OPT_BIT_PROPERTIES = 0x1L; private long initBits = 0x1L; private long optBits; private ImmutableMap.Builder properties = ImmutableMap.builder(); private @Nullable String type; private Builder() { } /** * Fill a builder with attribute values from the provided {@code NamedTokenizer} 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(IndexSettings.NamedTokenizer instance) { Objects.requireNonNull(instance, "instance"); putAllProperties(instance.getProperties()); type(instance.getType()); return this; } /** * Put one entry to the {@link IndexSettings.NamedTokenizer#getProperties() properties} map. * @param key The key in the properties map * @param value The associated value in the properties map * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonAnySetter public final Builder putProperty(String key, Object value) { this.properties.put(key, value); optBits |= OPT_BIT_PROPERTIES; return this; } /** * Put one entry to the {@link IndexSettings.NamedTokenizer#getProperties() properties} map. Nulls are not permitted * @param entry The key and value entry * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder putProperty(Map.Entry entry) { this.properties.put(entry); optBits |= OPT_BIT_PROPERTIES; return this; } /** * Sets or replaces all mappings from the specified map as entries for the {@link IndexSettings.NamedTokenizer#getProperties() properties} map. Nulls are not permitted * @param entries The entries that will be added to the properties map * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("properties") public final Builder properties(Map entries) { this.properties = ImmutableMap.builder(); optBits |= OPT_BIT_PROPERTIES; return putAllProperties(entries); } /** * Put all mappings from the specified map as entries to {@link IndexSettings.NamedTokenizer#getProperties() properties} map. Nulls are not permitted * @param entries The entries that will be added to the properties map * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder putAllProperties(Map entries) { this.properties.putAll(entries); optBits |= OPT_BIT_PROPERTIES; return this; } /** * Initializes the value for the {@link IndexSettings.NamedTokenizer#getType() type} attribute. * @param type The value for type * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("type") public final Builder type(String type) { this.type = Objects.requireNonNull(type, "type"); initBits &= ~INIT_BIT_TYPE; return this; } /** * Builds a new {@link ImmutableNamedTokenizer ImmutableNamedTokenizer}. * @return An immutable instance of NamedTokenizer * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableNamedTokenizer build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return new ImmutableNamedTokenizer(this); } private boolean propertiesIsSet() { return (optBits & OPT_BIT_PROPERTIES) != 0; } private String formatRequiredAttributesMessage() { List attributes = new ArrayList<>(); if ((initBits & INIT_BIT_TYPE) != 0) attributes.add("type"); return "Cannot build NamedTokenizer, some of required attributes are not set " + attributes; } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy