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

com.arakelian.elastic.model.ImmutableNormalizerSettings 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.Generated;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import javax.annotation.concurrent.Immutable;
import javax.annotation.concurrent.NotThreadSafe;

/**
 * Immutable implementation of {@link IndexSettings.NormalizerSettings}.
 * 

* Use the builder to create immutable instances: * {@code ImmutableNormalizerSettings.builder()}. */ @SuppressWarnings({"all"}) @ParametersAreNonnullByDefault @Generated("org.immutables.processor.ProxyProcessor") @Immutable @CheckReturnValue public final class ImmutableNormalizerSettings implements IndexSettings.NormalizerSettings { private final ImmutableMap normalizers; private ImmutableNormalizerSettings(ImmutableNormalizerSettings.Builder builder) { this.normalizers = builder.normalizersIsSet() ? builder.normalizers.build() : ImmutableMap.copyOf(IndexSettings.NormalizerSettings.super.getNormalizers()); } /** * @return The value of the {@code normalizers} attribute */ @JsonProperty("normalizers") @JsonAnyGetter @Override public ImmutableMap getNormalizers() { return normalizers; } /** * This instance is equal to all instances of {@code ImmutableNormalizerSettings} 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 ImmutableNormalizerSettings && equalTo((ImmutableNormalizerSettings) another); } private boolean equalTo(ImmutableNormalizerSettings another) { return normalizers.equals(another.normalizers); } /** * Computes a hash code from attributes: {@code normalizers}. * @return hashCode value */ @Override public int hashCode() { @Var int h = 5381; h += (h << 5) + normalizers.hashCode(); return h; } /** * Prints the immutable value {@code NormalizerSettings} with attribute values. * @return A string representation of the value */ @Override public String toString() { return MoreObjects.toStringHelper("NormalizerSettings") .omitNullValues() .add("normalizers", normalizers) .toString(); } /** * Creates a builder for {@link ImmutableNormalizerSettings ImmutableNormalizerSettings}. * @return A new ImmutableNormalizerSettings builder */ public static ImmutableNormalizerSettings.Builder builder() { return new ImmutableNormalizerSettings.Builder(); } /** * Builds instances of type {@link ImmutableNormalizerSettings ImmutableNormalizerSettings}. * 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 OPT_BIT_NORMALIZERS = 0x1L; private long optBits; private ImmutableMap.Builder normalizers = ImmutableMap.builder(); private Builder() { } /** * Fill a builder with attribute values from the provided {@code NormalizerSettings} 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.NormalizerSettings instance) { Objects.requireNonNull(instance, "instance"); putAllNormalizers(instance.getNormalizers()); return this; } /** * Put one entry to the {@link IndexSettings.NormalizerSettings#getNormalizers() normalizers} map. * @param key The key in the normalizers map * @param value The associated value in the normalizers map * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonAnySetter public final Builder putNormalizer(String key, IndexSettings.NamedNormalizer value) { this.normalizers.put(key, value); optBits |= OPT_BIT_NORMALIZERS; return this; } /** * Put one entry to the {@link IndexSettings.NormalizerSettings#getNormalizers() normalizers} 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 putNormalizer(Map.Entry entry) { this.normalizers.put(entry); optBits |= OPT_BIT_NORMALIZERS; return this; } /** * Sets or replaces all mappings from the specified map as entries for the {@link IndexSettings.NormalizerSettings#getNormalizers() normalizers} map. Nulls are not permitted * @param entries The entries that will be added to the normalizers map * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("normalizers") public final Builder normalizers(Map entries) { this.normalizers = ImmutableMap.builder(); optBits |= OPT_BIT_NORMALIZERS; return putAllNormalizers(entries); } /** * Put all mappings from the specified map as entries to {@link IndexSettings.NormalizerSettings#getNormalizers() normalizers} map. Nulls are not permitted * @param entries The entries that will be added to the normalizers map * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder putAllNormalizers(Map entries) { this.normalizers.putAll(entries); optBits |= OPT_BIT_NORMALIZERS; return this; } /** * Builds a new {@link ImmutableNormalizerSettings ImmutableNormalizerSettings}. * @return An immutable instance of NormalizerSettings * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableNormalizerSettings build() { return new ImmutableNormalizerSettings(this); } private boolean normalizersIsSet() { return (optBits & OPT_BIT_NORMALIZERS) != 0; } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy