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

com.arakelian.elastic.model.search.ImmutableField Maven / Gradle / Ivy

package com.arakelian.elastic.model.search;

import com.arakelian.core.feature.Nullable;
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.ParametersAreNonnullByDefault;
import javax.annotation.concurrent.Immutable;
import javax.annotation.concurrent.NotThreadSafe;
import org.immutables.value.Generated;

/**
 * Immutable implementation of {@link Highlighter.Field}.
 * 

* Use the builder to create immutable instances: * {@code ImmutableField.builder()}. */ @Generated(from = "Highlighter.Field", generator = "Immutables") @SuppressWarnings({"all"}) @ParametersAreNonnullByDefault @javax.annotation.processing.Generated("org.immutables.processor.ProxyProcessor") @Immutable @CheckReturnValue public final class ImmutableField implements Highlighter.Field { private final @Nullable String boundaryChars; private final @Nullable Integer boundaryMaxScan; private final @Nullable Highlighter.BoundaryScanner boundaryScanner; private final @Nullable String boundaryScannerLocale; private final @Nullable Highlighter.Encoder encoder; private final @Nullable Highlighter.Fragmenter fragmenter; private final @Nullable Integer fragmentSize; private final @Nullable Query highlightQuery; private final @Nullable Integer noMatchSize; private final @Nullable Integer numberOfFragments; private final @Nullable Highlighter.Order order; private final @Nullable Integer phraseLimit; private final ImmutableList postTags; private final ImmutableList preTags; private final @Nullable Highlighter.TagsSchema tagsSchema; private final @Nullable Highlighter.Type type; private final @Nullable Boolean forceSource; private final @Nullable Boolean highlightFilter; private final @Nullable Boolean requireFieldMatch; private final @Nullable Integer fragmentOffset; private final ImmutableList matchedFields; private final String name; private ImmutableField(ImmutableField.Builder builder) { this.boundaryChars = builder.boundaryChars; this.boundaryMaxScan = builder.boundaryMaxScan; this.boundaryScanner = builder.boundaryScanner; this.boundaryScannerLocale = builder.boundaryScannerLocale; this.encoder = builder.encoder; this.fragmenter = builder.fragmenter; this.fragmentSize = builder.fragmentSize; this.highlightQuery = builder.highlightQuery; this.noMatchSize = builder.noMatchSize; this.numberOfFragments = builder.numberOfFragments; this.order = builder.order; this.phraseLimit = builder.phraseLimit; this.tagsSchema = builder.tagsSchema; this.type = builder.type; this.forceSource = builder.forceSource; this.highlightFilter = builder.highlightFilter; this.requireFieldMatch = builder.requireFieldMatch; this.fragmentOffset = builder.fragmentOffset; this.name = builder.name; if (builder.postTagsIsSet()) { initShim.postTags(builder.postTags.build()); } if (builder.preTagsIsSet()) { initShim.preTags(builder.preTags.build()); } if (builder.matchedFieldsIsSet()) { initShim.matchedFields(builder.matchedFields.build()); } this.postTags = initShim.getPostTags(); this.preTags = initShim.getPreTags(); this.matchedFields = initShim.getMatchedFields(); this.initShim = null; } private static final byte STAGE_INITIALIZING = -1; private static final byte STAGE_UNINITIALIZED = 0; private static final byte STAGE_INITIALIZED = 1; @SuppressWarnings("Immutable") private transient volatile InitShim initShim = new InitShim(); @Generated(from = "Highlighter.Field", generator = "Immutables") private final class InitShim { private byte postTagsBuildStage = STAGE_UNINITIALIZED; private ImmutableList postTags; ImmutableList getPostTags() { if (postTagsBuildStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage()); if (postTagsBuildStage == STAGE_UNINITIALIZED) { postTagsBuildStage = STAGE_INITIALIZING; this.postTags = ImmutableList.copyOf(getPostTagsInitialize()); postTagsBuildStage = STAGE_INITIALIZED; } return this.postTags; } void postTags(ImmutableList postTags) { this.postTags = postTags; postTagsBuildStage = STAGE_INITIALIZED; } private byte preTagsBuildStage = STAGE_UNINITIALIZED; private ImmutableList preTags; ImmutableList getPreTags() { if (preTagsBuildStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage()); if (preTagsBuildStage == STAGE_UNINITIALIZED) { preTagsBuildStage = STAGE_INITIALIZING; this.preTags = ImmutableList.copyOf(getPreTagsInitialize()); preTagsBuildStage = STAGE_INITIALIZED; } return this.preTags; } void preTags(ImmutableList preTags) { this.preTags = preTags; preTagsBuildStage = STAGE_INITIALIZED; } private byte matchedFieldsBuildStage = STAGE_UNINITIALIZED; private ImmutableList matchedFields; ImmutableList getMatchedFields() { if (matchedFieldsBuildStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage()); if (matchedFieldsBuildStage == STAGE_UNINITIALIZED) { matchedFieldsBuildStage = STAGE_INITIALIZING; this.matchedFields = ImmutableList.copyOf(getMatchedFieldsInitialize()); matchedFieldsBuildStage = STAGE_INITIALIZED; } return this.matchedFields; } void matchedFields(ImmutableList matchedFields) { this.matchedFields = matchedFields; matchedFieldsBuildStage = STAGE_INITIALIZED; } private String formatInitCycleMessage() { List attributes = new ArrayList<>(); if (postTagsBuildStage == STAGE_INITIALIZING) attributes.add("postTags"); if (preTagsBuildStage == STAGE_INITIALIZING) attributes.add("preTags"); if (matchedFieldsBuildStage == STAGE_INITIALIZING) attributes.add("matchedFields"); return "Cannot build Field, attribute initializers form cycle " + attributes; } } private List getPostTagsInitialize() { return Highlighter.Field.super.getPostTags(); } private List getPreTagsInitialize() { return Highlighter.Field.super.getPreTags(); } private List getMatchedFieldsInitialize() { return Highlighter.Field.super.getMatchedFields(); } /** * Returns a string that contains each boundary character. Elastic defaults this to * .,!? \t\n. * @return a string that contains each boundary character. */ @JsonProperty("boundaryChars") @Override public @Nullable String getBoundaryChars() { return boundaryChars; } /** * Returns how far to scan for boundary characters. Defaults to 20. * @return how far to scan for boundary characters */ @JsonProperty("boundaryMaxScan") @Override public @Nullable Integer getBoundaryMaxScan() { return boundaryMaxScan; } /** * Returns how to break the highlighted fragments: chars, sentence, or * word * @return how to break the highlighted fragments */ @JsonProperty("boundaryScanner") @Override public @Nullable Highlighter.BoundaryScanner getBoundaryScanner() { return boundaryScanner; } /** * Returns the locale that is used to search for sentence and word boundaries. * @return the locale that is used to search for sentence and word boundaries. */ @JsonProperty("boundaryScannerLocale") @Override public @Nullable String getBoundaryScannerLocale() { return boundaryScannerLocale; } /** * Returns if the snippet should be HTML encoded: default (no encoding) or * html (HTML-escape the snippet text and then insert the highlighting tags) * @return if the snippet should be HTML encoded */ @JsonProperty("encoder") @Override public @Nullable Highlighter.Encoder getEncoder() { return encoder; } /** * Returns how text should be broken up in highlight snippets: simple or * span. Only valid for the plain highlighter. * @return how text should be broken up in highlight snippets */ @JsonProperty("fragmenter") @Override public @Nullable Highlighter.Fragmenter getFragmenter() { return fragmenter; } /** * Returns the size of the highlighted fragment in characters. Defaults to 100. * @return the size of the highlighted fragment in characters */ @JsonProperty("fragmentSize") @Override public @Nullable Integer getFragmentSize() { return fragmentSize; } /** * @return The value of the {@code highlightQuery} attribute */ @JsonProperty("highlightQuery") @Override public @Nullable Query getHighlightQuery() { return highlightQuery; } /** * Returns the amount of text you want to return from the beginning of the field if there are no * matching fragments to highlight. Defaults to 0 (nothing is returned). * @return the amount of text you want to return from the beginning of the field if there are no * matching fragments to highlight */ @JsonProperty("noMatchSize") @Override public @Nullable Integer getNoMatchSize() { return noMatchSize; } /** * Returns the maximum number of fragments to return. *

* If the number of fragments is set to 0, no fragments are returned. Instead, the entire field * contents are highlighted and returned. This can be handy when you need to highlight short * texts such as a title or address, but fragmentation is not required. If number_of_fragments * is 0, fragment_size is ignored. Defaults to 5. *

* @return the maximum number of fragments to return. */ @JsonProperty("numberOfFragments") @Override public @Nullable Integer getNumberOfFragments() { return numberOfFragments; } /** * @return The value of the {@code order} attribute */ @JsonProperty("order") @Override public @Nullable Highlighter.Order getOrder() { return order; } /** * @return The value of the {@code phraseLimit} attribute */ @JsonProperty("phraseLimit") @Override public @Nullable Integer getPhraseLimit() { return phraseLimit; } /** * Returns a list of HTML tags to use after highlighted text. Used in conjunction with * {@link #getPreTags()}. * @return a list of HTML tags to use after highlighted text */ @JsonProperty("postTags") @Override public ImmutableList getPostTags() { InitShim shim = this.initShim; return shim != null ? shim.getPostTags() : this.postTags; } /** * Returns a list of HTML tags to use before highlighted text. Used in conjunction with * {@link #getPostTags()}. * @return a list of HTML tags to use before highlighted text */ @JsonProperty("preTags") @Override public ImmutableList getPreTags() { InitShim shim = this.initShim; return shim != null ? shim.getPreTags() : this.preTags; } /** * @return The value of the {@code tagsSchema} attribute */ @JsonProperty("tagsSchema") @Override public @Nullable Highlighter.TagsSchema getTagsSchema() { return tagsSchema; } /** * @return The value of the {@code type} attribute */ @JsonProperty("type") @Override public @Nullable Highlighter.Type getType() { return type; } /** * @return The value of the {@code forceSource} attribute */ @JsonProperty("forceSource") @Override public @Nullable Boolean isForceSource() { return forceSource; } /** * @return The value of the {@code highlightFilter} attribute */ @JsonProperty("highlightFilter") @Override public @Nullable Boolean isHighlightFilter() { return highlightFilter; } /** * Returns true if only fields that contains a query match are highlighted. Set * require_field_match to false to highlight all fields. Defaults to true. * @return true if only fields that contains a query match are highlighted */ @JsonProperty("requireFieldMatch") @Override public @Nullable Boolean isRequireFieldMatch() { return requireFieldMatch; } /** * Returns the margin from which you want to start highlighting. Only valid when using the * fvh highlighter. * @return the margin from which you want to start highlighting */ @JsonProperty("fragmentOffset") @Override public @Nullable Integer getFragmentOffset() { return fragmentOffset; } /** * Returns a list of fields whose matches are combined to highlight a single field. *

* This is most intuitive for multifields that analyze the same string in different ways. * All matched_fields must have term_vector set to * with_positions_offsets, but only the field to which the matches are combined * is loaded so only that field benefits from having store set to yes. Only valid for the * fvh highlighter. *

* @return a list of fields whose matches are combined to highlight a single field. */ @JsonProperty("matchedFields") @Override public ImmutableList getMatchedFields() { InitShim shim = this.initShim; return shim != null ? shim.getMatchedFields() : this.matchedFields; } /** * Returns the field name to retrieve highlights for. *

* You can use wildcards to specify fields. For example, you could specify comment_* to get * highlights for all text and keyword fields that start with comment_. *

* @return the field name to retrieve highlights for. */ @JsonProperty("name") @Override public String getName() { return name; } /** * This instance is equal to all instances of {@code ImmutableField} that have equal attribute values. * @return {@code true} if {@code this} is equal to {@code another} instance */ @Override public boolean equals(@javax.annotation.Nullable Object another) { if (this == another) return true; return another instanceof ImmutableField && equalTo((ImmutableField) another); } private boolean equalTo(ImmutableField another) { return Objects.equals(boundaryChars, another.boundaryChars) && Objects.equals(boundaryMaxScan, another.boundaryMaxScan) && Objects.equals(boundaryScanner, another.boundaryScanner) && Objects.equals(boundaryScannerLocale, another.boundaryScannerLocale) && Objects.equals(encoder, another.encoder) && Objects.equals(fragmenter, another.fragmenter) && Objects.equals(fragmentSize, another.fragmentSize) && Objects.equals(highlightQuery, another.highlightQuery) && Objects.equals(noMatchSize, another.noMatchSize) && Objects.equals(numberOfFragments, another.numberOfFragments) && Objects.equals(order, another.order) && Objects.equals(phraseLimit, another.phraseLimit) && postTags.equals(another.postTags) && preTags.equals(another.preTags) && Objects.equals(tagsSchema, another.tagsSchema) && Objects.equals(type, another.type) && Objects.equals(forceSource, another.forceSource) && Objects.equals(highlightFilter, another.highlightFilter) && Objects.equals(requireFieldMatch, another.requireFieldMatch) && Objects.equals(fragmentOffset, another.fragmentOffset) && matchedFields.equals(another.matchedFields) && name.equals(another.name); } /** * Computes a hash code from attributes: {@code boundaryChars}, {@code boundaryMaxScan}, {@code boundaryScanner}, {@code boundaryScannerLocale}, {@code encoder}, {@code fragmenter}, {@code fragmentSize}, {@code highlightQuery}, {@code noMatchSize}, {@code numberOfFragments}, {@code order}, {@code phraseLimit}, {@code postTags}, {@code preTags}, {@code tagsSchema}, {@code type}, {@code forceSource}, {@code highlightFilter}, {@code requireFieldMatch}, {@code fragmentOffset}, {@code matchedFields}, {@code name}. * @return hashCode value */ @Override public int hashCode() { @Var int h = 5381; h += (h << 5) + Objects.hashCode(boundaryChars); h += (h << 5) + Objects.hashCode(boundaryMaxScan); h += (h << 5) + Objects.hashCode(boundaryScanner); h += (h << 5) + Objects.hashCode(boundaryScannerLocale); h += (h << 5) + Objects.hashCode(encoder); h += (h << 5) + Objects.hashCode(fragmenter); h += (h << 5) + Objects.hashCode(fragmentSize); h += (h << 5) + Objects.hashCode(highlightQuery); h += (h << 5) + Objects.hashCode(noMatchSize); h += (h << 5) + Objects.hashCode(numberOfFragments); h += (h << 5) + Objects.hashCode(order); h += (h << 5) + Objects.hashCode(phraseLimit); h += (h << 5) + postTags.hashCode(); h += (h << 5) + preTags.hashCode(); h += (h << 5) + Objects.hashCode(tagsSchema); h += (h << 5) + Objects.hashCode(type); h += (h << 5) + Objects.hashCode(forceSource); h += (h << 5) + Objects.hashCode(highlightFilter); h += (h << 5) + Objects.hashCode(requireFieldMatch); h += (h << 5) + Objects.hashCode(fragmentOffset); h += (h << 5) + matchedFields.hashCode(); h += (h << 5) + name.hashCode(); return h; } /** * Prints the immutable value {@code Field} with attribute values. * @return A string representation of the value */ @Override public String toString() { return MoreObjects.toStringHelper("Field") .omitNullValues() .add("boundaryChars", boundaryChars) .add("boundaryMaxScan", boundaryMaxScan) .add("boundaryScanner", boundaryScanner) .add("boundaryScannerLocale", boundaryScannerLocale) .add("encoder", encoder) .add("fragmenter", fragmenter) .add("fragmentSize", fragmentSize) .add("highlightQuery", highlightQuery) .add("noMatchSize", noMatchSize) .add("numberOfFragments", numberOfFragments) .add("order", order) .add("phraseLimit", phraseLimit) .add("postTags", postTags) .add("preTags", preTags) .add("tagsSchema", tagsSchema) .add("type", type) .add("forceSource", forceSource) .add("highlightFilter", highlightFilter) .add("requireFieldMatch", requireFieldMatch) .add("fragmentOffset", fragmentOffset) .add("matchedFields", matchedFields) .add("name", name) .toString(); } /** * Creates a builder for {@link ImmutableField ImmutableField}. *
   * ImmutableField.builder()
   *    .boundaryChars(String | null) // nullable {@link Highlighter.Field#getBoundaryChars() boundaryChars}
   *    .boundaryMaxScan(Integer | null) // nullable {@link Highlighter.Field#getBoundaryMaxScan() boundaryMaxScan}
   *    .boundaryScanner(com.arakelian.elastic.model.search.Highlighter.BoundaryScanner | null) // nullable {@link Highlighter.Field#getBoundaryScanner() boundaryScanner}
   *    .boundaryScannerLocale(String | null) // nullable {@link Highlighter.Field#getBoundaryScannerLocale() boundaryScannerLocale}
   *    .encoder(com.arakelian.elastic.model.search.Highlighter.Encoder | null) // nullable {@link Highlighter.Field#getEncoder() encoder}
   *    .fragmenter(com.arakelian.elastic.model.search.Highlighter.Fragmenter | null) // nullable {@link Highlighter.Field#getFragmenter() fragmenter}
   *    .fragmentSize(Integer | null) // nullable {@link Highlighter.Field#getFragmentSize() fragmentSize}
   *    .highlightQuery(com.arakelian.elastic.model.search.Query | null) // nullable {@link Highlighter.Field#getHighlightQuery() highlightQuery}
   *    .noMatchSize(Integer | null) // nullable {@link Highlighter.Field#getNoMatchSize() noMatchSize}
   *    .numberOfFragments(Integer | null) // nullable {@link Highlighter.Field#getNumberOfFragments() numberOfFragments}
   *    .order(com.arakelian.elastic.model.search.Highlighter.Order | null) // nullable {@link Highlighter.Field#getOrder() order}
   *    .phraseLimit(Integer | null) // nullable {@link Highlighter.Field#getPhraseLimit() phraseLimit}
   *    .addPostTag|addAllPostTags(String) // {@link Highlighter.Field#getPostTags() postTags} elements
   *    .addPreTag|addAllPreTags(String) // {@link Highlighter.Field#getPreTags() preTags} elements
   *    .tagsSchema(com.arakelian.elastic.model.search.Highlighter.TagsSchema | null) // nullable {@link Highlighter.Field#getTagsSchema() tagsSchema}
   *    .type(com.arakelian.elastic.model.search.Highlighter.Type | null) // nullable {@link Highlighter.Field#getType() type}
   *    .forceSource(Boolean | null) // nullable {@link Highlighter.Field#isForceSource() forceSource}
   *    .highlightFilter(Boolean | null) // nullable {@link Highlighter.Field#isHighlightFilter() highlightFilter}
   *    .requireFieldMatch(Boolean | null) // nullable {@link Highlighter.Field#isRequireFieldMatch() requireFieldMatch}
   *    .fragmentOffset(Integer | null) // nullable {@link Highlighter.Field#getFragmentOffset() fragmentOffset}
   *    .addMatchedField|addAllMatchedFields(String) // {@link Highlighter.Field#getMatchedFields() matchedFields} elements
   *    .name(String) // required {@link Highlighter.Field#getName() name}
   *    .build();
   * 
* @return A new ImmutableField builder */ public static ImmutableField.Builder builder() { return new ImmutableField.Builder(); } /** * Builds instances of type {@link ImmutableField ImmutableField}. * 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 = "Highlighter.Field", generator = "Immutables") @NotThreadSafe @JsonPropertyOrder("name") public static final class Builder { private static final long INIT_BIT_NAME = 0x1L; private static final long OPT_BIT_POST_TAGS = 0x1L; private static final long OPT_BIT_PRE_TAGS = 0x2L; private static final long OPT_BIT_MATCHED_FIELDS = 0x4L; private long initBits = 0x1L; private long optBits; private @javax.annotation.Nullable String boundaryChars; private @javax.annotation.Nullable Integer boundaryMaxScan; private @javax.annotation.Nullable Highlighter.BoundaryScanner boundaryScanner; private @javax.annotation.Nullable String boundaryScannerLocale; private @javax.annotation.Nullable Highlighter.Encoder encoder; private @javax.annotation.Nullable Highlighter.Fragmenter fragmenter; private @javax.annotation.Nullable Integer fragmentSize; private @javax.annotation.Nullable Query highlightQuery; private @javax.annotation.Nullable Integer noMatchSize; private @javax.annotation.Nullable Integer numberOfFragments; private @javax.annotation.Nullable Highlighter.Order order; private @javax.annotation.Nullable Integer phraseLimit; private ImmutableList.Builder postTags = ImmutableList.builder(); private ImmutableList.Builder preTags = ImmutableList.builder(); private @javax.annotation.Nullable Highlighter.TagsSchema tagsSchema; private @javax.annotation.Nullable Highlighter.Type type; private @javax.annotation.Nullable Boolean forceSource; private @javax.annotation.Nullable Boolean highlightFilter; private @javax.annotation.Nullable Boolean requireFieldMatch; private @javax.annotation.Nullable Integer fragmentOffset; private ImmutableList.Builder matchedFields = ImmutableList.builder(); private @javax.annotation.Nullable String name; private Builder() { } /** * Fill a builder with attribute values from the provided {@code com.arakelian.elastic.model.search.Highlighter} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Highlighter instance) { Objects.requireNonNull(instance, "instance"); from((Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code com.arakelian.elastic.model.search.Highlighter.Field} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Highlighter.Field instance) { Objects.requireNonNull(instance, "instance"); from((Object) instance); return this; } private void from(Object object) { if (object instanceof Highlighter) { Highlighter instance = (Highlighter) object; String boundaryCharsValue = instance.getBoundaryChars(); if (boundaryCharsValue != null) { boundaryChars(boundaryCharsValue); } Integer fragmentSizeValue = instance.getFragmentSize(); if (fragmentSizeValue != null) { fragmentSize(fragmentSizeValue); } Integer noMatchSizeValue = instance.getNoMatchSize(); if (noMatchSizeValue != null) { noMatchSize(noMatchSizeValue); } Highlighter.BoundaryScanner boundaryScannerValue = instance.getBoundaryScanner(); if (boundaryScannerValue != null) { boundaryScanner(boundaryScannerValue); } addAllPreTags(instance.getPreTags()); addAllPostTags(instance.getPostTags()); Integer numberOfFragmentsValue = instance.getNumberOfFragments(); if (numberOfFragmentsValue != null) { numberOfFragments(numberOfFragmentsValue); } Boolean forceSourceValue = instance.isForceSource(); if (forceSourceValue != null) { forceSource(forceSourceValue); } Highlighter.Type typeValue = instance.getType(); if (typeValue != null) { type(typeValue); } Highlighter.Encoder encoderValue = instance.getEncoder(); if (encoderValue != null) { encoder(encoderValue); } Integer boundaryMaxScanValue = instance.getBoundaryMaxScan(); if (boundaryMaxScanValue != null) { boundaryMaxScan(boundaryMaxScanValue); } Highlighter.Fragmenter fragmenterValue = instance.getFragmenter(); if (fragmenterValue != null) { fragmenter(fragmenterValue); } Query highlightQueryValue = instance.getHighlightQuery(); if (highlightQueryValue != null) { highlightQuery(highlightQueryValue); } Integer phraseLimitValue = instance.getPhraseLimit(); if (phraseLimitValue != null) { phraseLimit(phraseLimitValue); } Boolean highlightFilterValue = instance.isHighlightFilter(); if (highlightFilterValue != null) { highlightFilter(highlightFilterValue); } Boolean requireFieldMatchValue = instance.isRequireFieldMatch(); if (requireFieldMatchValue != null) { requireFieldMatch(requireFieldMatchValue); } String boundaryScannerLocaleValue = instance.getBoundaryScannerLocale(); if (boundaryScannerLocaleValue != null) { boundaryScannerLocale(boundaryScannerLocaleValue); } Highlighter.TagsSchema tagsSchemaValue = instance.getTagsSchema(); if (tagsSchemaValue != null) { tagsSchema(tagsSchemaValue); } Highlighter.Order orderValue = instance.getOrder(); if (orderValue != null) { order(orderValue); } } if (object instanceof Highlighter.Field) { Highlighter.Field instance = (Highlighter.Field) object; name(instance.getName()); Integer fragmentOffsetValue = instance.getFragmentOffset(); if (fragmentOffsetValue != null) { fragmentOffset(fragmentOffsetValue); } addAllMatchedFields(instance.getMatchedFields()); } } /** * Initializes the value for the {@link Highlighter.Field#getBoundaryChars() boundaryChars} attribute. * @param boundaryChars The value for boundaryChars (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("boundaryChars") public final Builder boundaryChars(@Nullable String boundaryChars) { this.boundaryChars = boundaryChars; return this; } /** * Initializes the value for the {@link Highlighter.Field#getBoundaryMaxScan() boundaryMaxScan} attribute. * @param boundaryMaxScan The value for boundaryMaxScan (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("boundaryMaxScan") public final Builder boundaryMaxScan(@Nullable Integer boundaryMaxScan) { this.boundaryMaxScan = boundaryMaxScan; return this; } /** * Initializes the value for the {@link Highlighter.Field#getBoundaryScanner() boundaryScanner} attribute. * @param boundaryScanner The value for boundaryScanner (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("boundaryScanner") public final Builder boundaryScanner(@Nullable Highlighter.BoundaryScanner boundaryScanner) { this.boundaryScanner = boundaryScanner; return this; } /** * Initializes the value for the {@link Highlighter.Field#getBoundaryScannerLocale() boundaryScannerLocale} attribute. * @param boundaryScannerLocale The value for boundaryScannerLocale (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("boundaryScannerLocale") public final Builder boundaryScannerLocale(@Nullable String boundaryScannerLocale) { this.boundaryScannerLocale = boundaryScannerLocale; return this; } /** * Initializes the value for the {@link Highlighter.Field#getEncoder() encoder} attribute. * @param encoder The value for encoder (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("encoder") public final Builder encoder(@Nullable Highlighter.Encoder encoder) { this.encoder = encoder; return this; } /** * Initializes the value for the {@link Highlighter.Field#getFragmenter() fragmenter} attribute. * @param fragmenter The value for fragmenter (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("fragmenter") public final Builder fragmenter(@Nullable Highlighter.Fragmenter fragmenter) { this.fragmenter = fragmenter; return this; } /** * Initializes the value for the {@link Highlighter.Field#getFragmentSize() fragmentSize} attribute. * @param fragmentSize The value for fragmentSize (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("fragmentSize") public final Builder fragmentSize(@Nullable Integer fragmentSize) { this.fragmentSize = fragmentSize; return this; } /** * Initializes the value for the {@link Highlighter.Field#getHighlightQuery() highlightQuery} attribute. * @param highlightQuery The value for highlightQuery (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("highlightQuery") public final Builder highlightQuery(@Nullable Query highlightQuery) { this.highlightQuery = highlightQuery; return this; } /** * Initializes the value for the {@link Highlighter.Field#getNoMatchSize() noMatchSize} attribute. * @param noMatchSize The value for noMatchSize (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("noMatchSize") public final Builder noMatchSize(@Nullable Integer noMatchSize) { this.noMatchSize = noMatchSize; return this; } /** * Initializes the value for the {@link Highlighter.Field#getNumberOfFragments() numberOfFragments} attribute. * @param numberOfFragments The value for numberOfFragments (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("numberOfFragments") public final Builder numberOfFragments(@Nullable Integer numberOfFragments) { this.numberOfFragments = numberOfFragments; return this; } /** * Initializes the value for the {@link Highlighter.Field#getOrder() order} attribute. * @param order The value for order (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("order") public final Builder order(@Nullable Highlighter.Order order) { this.order = order; return this; } /** * Initializes the value for the {@link Highlighter.Field#getPhraseLimit() phraseLimit} attribute. * @param phraseLimit The value for phraseLimit (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("phraseLimit") public final Builder phraseLimit(@Nullable Integer phraseLimit) { this.phraseLimit = phraseLimit; return this; } /** * Adds one element to {@link Highlighter.Field#getPostTags() postTags} list. * @param element A postTags element * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addPostTag(String element) { this.postTags.add(element); optBits |= OPT_BIT_POST_TAGS; return this; } /** * Adds elements to {@link Highlighter.Field#getPostTags() postTags} list. * @param elements An array of postTags elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addPostTags(String... elements) { this.postTags.add(elements); optBits |= OPT_BIT_POST_TAGS; return this; } /** * Sets or replaces all elements for {@link Highlighter.Field#getPostTags() postTags} list. * @param elements An iterable of postTags elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("postTags") public final Builder postTags(Iterable elements) { this.postTags = ImmutableList.builder(); return addAllPostTags(elements); } /** * Adds elements to {@link Highlighter.Field#getPostTags() postTags} list. * @param elements An iterable of postTags elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAllPostTags(Iterable elements) { this.postTags.addAll(elements); optBits |= OPT_BIT_POST_TAGS; return this; } /** * Adds one element to {@link Highlighter.Field#getPreTags() preTags} list. * @param element A preTags element * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addPreTag(String element) { this.preTags.add(element); optBits |= OPT_BIT_PRE_TAGS; return this; } /** * Adds elements to {@link Highlighter.Field#getPreTags() preTags} list. * @param elements An array of preTags elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addPreTags(String... elements) { this.preTags.add(elements); optBits |= OPT_BIT_PRE_TAGS; return this; } /** * Sets or replaces all elements for {@link Highlighter.Field#getPreTags() preTags} list. * @param elements An iterable of preTags elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("preTags") public final Builder preTags(Iterable elements) { this.preTags = ImmutableList.builder(); return addAllPreTags(elements); } /** * Adds elements to {@link Highlighter.Field#getPreTags() preTags} list. * @param elements An iterable of preTags elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAllPreTags(Iterable elements) { this.preTags.addAll(elements); optBits |= OPT_BIT_PRE_TAGS; return this; } /** * Initializes the value for the {@link Highlighter.Field#getTagsSchema() tagsSchema} attribute. * @param tagsSchema The value for tagsSchema (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("tagsSchema") public final Builder tagsSchema(@Nullable Highlighter.TagsSchema tagsSchema) { this.tagsSchema = tagsSchema; return this; } /** * Initializes the value for the {@link Highlighter.Field#getType() type} attribute. * @param type The value for type (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("type") public final Builder type(@Nullable Highlighter.Type type) { this.type = type; return this; } /** * Initializes the value for the {@link Highlighter.Field#isForceSource() forceSource} attribute. * @param forceSource The value for forceSource (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("forceSource") public final Builder forceSource(@Nullable Boolean forceSource) { this.forceSource = forceSource; return this; } /** * Initializes the value for the {@link Highlighter.Field#isHighlightFilter() highlightFilter} attribute. * @param highlightFilter The value for highlightFilter (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("highlightFilter") public final Builder highlightFilter(@Nullable Boolean highlightFilter) { this.highlightFilter = highlightFilter; return this; } /** * Initializes the value for the {@link Highlighter.Field#isRequireFieldMatch() requireFieldMatch} attribute. * @param requireFieldMatch The value for requireFieldMatch (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("requireFieldMatch") public final Builder requireFieldMatch(@Nullable Boolean requireFieldMatch) { this.requireFieldMatch = requireFieldMatch; return this; } /** * Initializes the value for the {@link Highlighter.Field#getFragmentOffset() fragmentOffset} attribute. * @param fragmentOffset The value for fragmentOffset (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("fragmentOffset") public final Builder fragmentOffset(@Nullable Integer fragmentOffset) { this.fragmentOffset = fragmentOffset; return this; } /** * Adds one element to {@link Highlighter.Field#getMatchedFields() matchedFields} list. * @param element A matchedFields element * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addMatchedField(String element) { this.matchedFields.add(element); optBits |= OPT_BIT_MATCHED_FIELDS; return this; } /** * Adds elements to {@link Highlighter.Field#getMatchedFields() matchedFields} list. * @param elements An array of matchedFields elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addMatchedFields(String... elements) { this.matchedFields.add(elements); optBits |= OPT_BIT_MATCHED_FIELDS; return this; } /** * Sets or replaces all elements for {@link Highlighter.Field#getMatchedFields() matchedFields} list. * @param elements An iterable of matchedFields elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("matchedFields") public final Builder matchedFields(Iterable elements) { this.matchedFields = ImmutableList.builder(); return addAllMatchedFields(elements); } /** * Adds elements to {@link Highlighter.Field#getMatchedFields() matchedFields} list. * @param elements An iterable of matchedFields elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAllMatchedFields(Iterable elements) { this.matchedFields.addAll(elements); optBits |= OPT_BIT_MATCHED_FIELDS; return this; } /** * Initializes the value for the {@link Highlighter.Field#getName() name} attribute. * @param name The value for name * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("name") public final Builder name(String name) { this.name = Objects.requireNonNull(name, "name"); initBits &= ~INIT_BIT_NAME; return this; } /** * Builds a new {@link ImmutableField ImmutableField}. * @return An immutable instance of Field * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableField build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return new ImmutableField(this); } private boolean postTagsIsSet() { return (optBits & OPT_BIT_POST_TAGS) != 0; } private boolean preTagsIsSet() { return (optBits & OPT_BIT_PRE_TAGS) != 0; } private boolean matchedFieldsIsSet() { return (optBits & OPT_BIT_MATCHED_FIELDS) != 0; } private String formatRequiredAttributesMessage() { List attributes = new ArrayList<>(); if ((initBits & INIT_BIT_NAME) != 0) attributes.add("name"); return "Cannot build Field, some of required attributes are not set " + attributes; } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy