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

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

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

   * ImmutableTokenizerSettings.builder()
   *    .putTokenizer|putAllTokenizers(String => com.arakelian.elastic.model.IndexSettings.NamedTokenizer) // {@link IndexSettings.TokenizerSettings#getTokenizers() tokenizers} mappings
   *    .build();
   * 
* @return A new ImmutableTokenizerSettings builder */ public static ImmutableTokenizerSettings.Builder builder() { return new ImmutableTokenizerSettings.Builder(); } /** * Builds instances of type {@link ImmutableTokenizerSettings ImmutableTokenizerSettings}. * 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.TokenizerSettings", generator = "Immutables") @NotThreadSafe public static final class Builder { private static final long OPT_BIT_TOKENIZERS = 0x1L; private long optBits; private ImmutableMap.Builder tokenizers = ImmutableMap.builder(); private Builder() { } /** * Fill a builder with attribute values from the provided {@code TokenizerSettings} 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.TokenizerSettings instance) { Objects.requireNonNull(instance, "instance"); putAllTokenizers(instance.getTokenizers()); return this; } /** * Put one entry to the {@link IndexSettings.TokenizerSettings#getTokenizers() tokenizers} map. * @param key The key in the tokenizers map * @param value The associated value in the tokenizers map * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonAnySetter public final Builder putTokenizer(String key, IndexSettings.NamedTokenizer value) { this.tokenizers.put(key, value); optBits |= OPT_BIT_TOKENIZERS; return this; } /** * Put one entry to the {@link IndexSettings.TokenizerSettings#getTokenizers() tokenizers} 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 putTokenizer(Map.Entry entry) { this.tokenizers.put(entry); optBits |= OPT_BIT_TOKENIZERS; return this; } /** * Sets or replaces all mappings from the specified map as entries for the {@link IndexSettings.TokenizerSettings#getTokenizers() tokenizers} map. Nulls are not permitted * @param entries The entries that will be added to the tokenizers map * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("tokenizers") public final Builder tokenizers(Map entries) { this.tokenizers = ImmutableMap.builder(); optBits |= OPT_BIT_TOKENIZERS; return putAllTokenizers(entries); } /** * Put all mappings from the specified map as entries to {@link IndexSettings.TokenizerSettings#getTokenizers() tokenizers} map. Nulls are not permitted * @param entries The entries that will be added to the tokenizers map * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder putAllTokenizers(Map entries) { this.tokenizers.putAll(entries); optBits |= OPT_BIT_TOKENIZERS; return this; } /** * Builds a new {@link ImmutableTokenizerSettings ImmutableTokenizerSettings}. * @return An immutable instance of TokenizerSettings * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableTokenizerSettings build() { return new ImmutableTokenizerSettings(this); } private boolean tokenizersIsSet() { return (optBits & OPT_BIT_TOKENIZERS) != 0; } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy