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

edu.isi.nlp.ImmutableCompositeStringNormalizer Maven / Gradle / Ivy

The newest version!
package edu.isi.nlp;

import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.google.common.base.MoreObjects;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
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 CompositeStringNormalizer}.
 * 

* Use the builder to create immutable instances: * {@code ImmutableCompositeStringNormalizer.builder()}. * Use the static factory method to create immutable instances: * {@code ImmutableCompositeStringNormalizer.of()}. */ @SuppressWarnings({"all"}) @ParametersAreNonnullByDefault @Generated({"Immutables.generator", "CompositeStringNormalizer"}) @Immutable final class ImmutableCompositeStringNormalizer extends CompositeStringNormalizer { private final ImmutableList wordShapers; private ImmutableCompositeStringNormalizer(Iterable wordShapers) { this.wordShapers = ImmutableList.copyOf(wordShapers); } private ImmutableCompositeStringNormalizer( ImmutableCompositeStringNormalizer original, ImmutableList wordShapers) { this.wordShapers = wordShapers; } /** * @return The value of the {@code wordShapers} attribute */ @JsonProperty("wordShapers") @Override public ImmutableList wordShapers() { return wordShapers; } /** * Copy the current immutable object with elements that replace the content of {@link CompositeStringNormalizer#wordShapers() wordShapers}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final ImmutableCompositeStringNormalizer withWordShapers(StringNormalizer... elements) { ImmutableList newValue = ImmutableList.copyOf(elements); return new ImmutableCompositeStringNormalizer(this, newValue); } /** * Copy the current immutable object with elements that replace the content of {@link CompositeStringNormalizer#wordShapers() wordShapers}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of wordShapers elements to set * @return A modified copy of {@code this} object */ public final ImmutableCompositeStringNormalizer withWordShapers(Iterable elements) { if (this.wordShapers == elements) return this; ImmutableList newValue = ImmutableList.copyOf(elements); return new ImmutableCompositeStringNormalizer(this, newValue); } /** * This instance is equal to all instances of {@code ImmutableCompositeStringNormalizer} 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 ImmutableCompositeStringNormalizer && equalTo((ImmutableCompositeStringNormalizer) another); } private boolean equalTo(ImmutableCompositeStringNormalizer another) { return wordShapers.equals(another.wordShapers); } /** * Computes a hash code from attributes: {@code wordShapers}. * @return hashCode value */ @Override public int hashCode() { int h = 31; h = h * 17 + wordShapers.hashCode(); return h; } /** * Prints the immutable value {@code CompositeStringNormalizer} with attribute values. * @return A string representation of the value */ @Override public String toString() { return MoreObjects.toStringHelper("CompositeStringNormalizer") .omitNullValues() .add("wordShapers", wordShapers) .toString(); } /** * Utility type used to correctly read immutable object from JSON representation. * @deprecated Do not use this type directly, it exists only for the Jackson-binding infrastructure */ @Deprecated @JsonDeserialize @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE) static final class Json extends CompositeStringNormalizer { ImmutableList wordShapers = ImmutableList.of(); @JsonProperty("wordShapers") public void setWordShapers(ImmutableList wordShapers) { this.wordShapers = wordShapers; } @Override public ImmutableList wordShapers() { throw new UnsupportedOperationException(); } } /** * @param json A JSON-bindable data structure * @return An immutable value type * @deprecated Do not use this method directly, it exists only for the Jackson-binding infrastructure */ @Deprecated @JsonCreator static ImmutableCompositeStringNormalizer fromJson(Json json) { ImmutableCompositeStringNormalizer.Builder builder = ImmutableCompositeStringNormalizer.builder(); if (json.wordShapers != null) { builder.addAllWordShapers(json.wordShapers); } return (ImmutableCompositeStringNormalizer) builder.build(); } /** * Construct a new immutable {@code CompositeStringNormalizer} instance. * @param wordShapers The value for the {@code wordShapers} attribute * @return An immutable CompositeStringNormalizer instance */ public static CompositeStringNormalizer of(ImmutableList wordShapers) { return of((Iterable) wordShapers); } /** * Construct a new immutable {@code CompositeStringNormalizer} instance. * @param wordShapers The value for the {@code wordShapers} attribute * @return An immutable CompositeStringNormalizer instance */ public static CompositeStringNormalizer of(Iterable wordShapers) { return new ImmutableCompositeStringNormalizer(wordShapers); } /** * Creates an immutable copy of a {@link CompositeStringNormalizer} value. * Uses accessors to get values to initialize the new immutable instance. * If an instance is already immutable, it is returned as is. * @param instance The instance to copy * @return A copied immutable CompositeStringNormalizer instance */ public static CompositeStringNormalizer copyOf(CompositeStringNormalizer instance) { if (instance instanceof ImmutableCompositeStringNormalizer) { return (ImmutableCompositeStringNormalizer) instance; } return ImmutableCompositeStringNormalizer.builder() .from(instance) .build(); } /** * Creates a builder for {@link CompositeStringNormalizer CompositeStringNormalizer}. * @return A new CompositeStringNormalizer builder */ public static ImmutableCompositeStringNormalizer.Builder builder() { return new ImmutableCompositeStringNormalizer.Builder(); } /** * Builds instances of type {@link CompositeStringNormalizer CompositeStringNormalizer}. * 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 static final class Builder { private ImmutableList.Builder wordShapers = ImmutableList.builder(); private Builder() { } /** * Fill a builder with attribute values from the provided {@code CompositeStringNormalizer} 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 */ public final Builder from(CompositeStringNormalizer instance) { Preconditions.checkNotNull(instance, "instance"); addAllWordShapers(instance.wordShapers()); return this; } /** * Adds one element to {@link CompositeStringNormalizer#wordShapers() wordShapers} list. * @param element A wordShapers element * @return {@code this} builder for use in a chained invocation */ public final Builder addWordShapers(StringNormalizer element) { this.wordShapers.add(element); return this; } /** * Adds elements to {@link CompositeStringNormalizer#wordShapers() wordShapers} list. * @param elements An array of wordShapers elements * @return {@code this} builder for use in a chained invocation */ public final Builder addWordShapers(StringNormalizer... elements) { this.wordShapers.add(elements); return this; } /** * Sets or replaces all elements for {@link CompositeStringNormalizer#wordShapers() wordShapers} list. * @param elements An iterable of wordShapers elements * @return {@code this} builder for use in a chained invocation */ public final Builder wordShapers(Iterable elements) { this.wordShapers = ImmutableList.builder(); return addAllWordShapers(elements); } /** * Adds elements to {@link CompositeStringNormalizer#wordShapers() wordShapers} list. * @param elements An iterable of wordShapers elements * @return {@code this} builder for use in a chained invocation */ public final Builder addAllWordShapers(Iterable elements) { this.wordShapers.addAll(elements); return this; } /** * Builds a new {@link CompositeStringNormalizer CompositeStringNormalizer}. * @return An immutable instance of CompositeStringNormalizer * @throws java.lang.IllegalStateException if any required attributes are missing */ public CompositeStringNormalizer build() { return new ImmutableCompositeStringNormalizer(null, wordShapers.build()); } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy