com.arakelian.elastic.model.search.ImmutableHighlight Maven / Gradle / Ivy
package com.arakelian.elastic.model.search;
import com.arakelian.core.feature.Nullable;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.base.MoreObjects;
import com.google.common.collect.ImmutableList;
import com.google.common.primitives.Booleans;
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.Highlight}.
*
* Use the builder to create immutable instances:
* {@code ImmutableHighlight.builder()}.
*/
@Generated(from = "Highlighter.Highlight", generator = "Immutables")
@SuppressWarnings({"all"})
@ParametersAreNonnullByDefault
@javax.annotation.Generated("org.immutables.processor.ProxyProcessor")
@Immutable
@CheckReturnValue
public final class ImmutableHighlight implements Highlighter.Highlight {
private final ImmutableList fields;
private final boolean useExplicitFieldOrder;
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 ImmutableHighlight(ImmutableHighlight.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;
if (builder.fieldsIsSet()) {
initShim.fields(builder.fields.build());
}
if (builder.useExplicitFieldOrderIsSet()) {
initShim.useExplicitFieldOrder(builder.useExplicitFieldOrder);
}
if (builder.postTagsIsSet()) {
initShim.postTags(builder.postTags.build());
}
if (builder.preTagsIsSet()) {
initShim.preTags(builder.preTags.build());
}
this.fields = initShim.getFields();
this.useExplicitFieldOrder = initShim.isUseExplicitFieldOrder();
this.postTags = initShim.getPostTags();
this.preTags = initShim.getPreTags();
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.Highlight", generator = "Immutables")
private final class InitShim {
private byte fieldsBuildStage = STAGE_UNINITIALIZED;
private ImmutableList fields;
ImmutableList getFields() {
if (fieldsBuildStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage());
if (fieldsBuildStage == STAGE_UNINITIALIZED) {
fieldsBuildStage = STAGE_INITIALIZING;
this.fields = ImmutableList.copyOf(getFieldsInitialize());
fieldsBuildStage = STAGE_INITIALIZED;
}
return this.fields;
}
void fields(ImmutableList fields) {
this.fields = fields;
fieldsBuildStage = STAGE_INITIALIZED;
}
private byte useExplicitFieldOrderBuildStage = STAGE_UNINITIALIZED;
private boolean useExplicitFieldOrder;
boolean isUseExplicitFieldOrder() {
if (useExplicitFieldOrderBuildStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage());
if (useExplicitFieldOrderBuildStage == STAGE_UNINITIALIZED) {
useExplicitFieldOrderBuildStage = STAGE_INITIALIZING;
this.useExplicitFieldOrder = isUseExplicitFieldOrderInitialize();
useExplicitFieldOrderBuildStage = STAGE_INITIALIZED;
}
return this.useExplicitFieldOrder;
}
void useExplicitFieldOrder(boolean useExplicitFieldOrder) {
this.useExplicitFieldOrder = useExplicitFieldOrder;
useExplicitFieldOrderBuildStage = STAGE_INITIALIZED;
}
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 String formatInitCycleMessage() {
List attributes = new ArrayList<>();
if (fieldsBuildStage == STAGE_INITIALIZING) attributes.add("fields");
if (useExplicitFieldOrderBuildStage == STAGE_INITIALIZING) attributes.add("useExplicitFieldOrder");
if (postTagsBuildStage == STAGE_INITIALIZING) attributes.add("postTags");
if (preTagsBuildStage == STAGE_INITIALIZING) attributes.add("preTags");
return "Cannot build Highlight, attribute initializers form cycle " + attributes;
}
}
private List getFieldsInitialize() {
return Highlighter.Highlight.super.getFields();
}
private boolean isUseExplicitFieldOrderInitialize() {
return Highlighter.Highlight.super.isUseExplicitFieldOrder();
}
private List getPostTagsInitialize() {
return Highlighter.Highlight.super.getPostTags();
}
private List getPreTagsInitialize() {
return Highlighter.Highlight.super.getPreTags();
}
/**
* @return The value of the {@code fields} attribute
*/
@JsonProperty("fields")
@Override
public ImmutableList getFields() {
InitShim shim = this.initShim;
return shim != null
? shim.getFields()
: this.fields;
}
/**
* @return The value of the {@code useExplicitFieldOrder} attribute
*/
@JsonProperty("useExplicitFieldOrder")
@Override
public boolean isUseExplicitFieldOrder() {
InitShim shim = this.initShim;
return shim != null
? shim.isUseExplicitFieldOrder()
: this.useExplicitFieldOrder;
}
/**
* 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;
}
/**
* This instance is equal to all instances of {@code ImmutableHighlight} 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 ImmutableHighlight
&& equalTo((ImmutableHighlight) another);
}
private boolean equalTo(ImmutableHighlight another) {
return fields.equals(another.fields)
&& useExplicitFieldOrder == another.useExplicitFieldOrder
&& 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);
}
/**
* Computes a hash code from attributes: {@code fields}, {@code useExplicitFieldOrder}, {@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}.
* @return hashCode value
*/
@Override
public int hashCode() {
@Var int h = 5381;
h += (h << 5) + fields.hashCode();
h += (h << 5) + Booleans.hashCode(useExplicitFieldOrder);
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);
return h;
}
/**
* Prints the immutable value {@code Highlight} with attribute values.
* @return A string representation of the value
*/
@Override
public String toString() {
return MoreObjects.toStringHelper("Highlight")
.omitNullValues()
.add("fields", fields)
.add("useExplicitFieldOrder", useExplicitFieldOrder)
.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)
.toString();
}
/**
* Creates a builder for {@link ImmutableHighlight ImmutableHighlight}.
* @return A new ImmutableHighlight builder
*/
public static ImmutableHighlight.Builder builder() {
return new ImmutableHighlight.Builder();
}
/**
* Builds instances of type {@link ImmutableHighlight ImmutableHighlight}.
* 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.Highlight", generator = "Immutables")
@NotThreadSafe
public static final class Builder {
private static final long OPT_BIT_FIELDS = 0x1L;
private static final long OPT_BIT_USE_EXPLICIT_FIELD_ORDER = 0x2L;
private static final long OPT_BIT_POST_TAGS = 0x4L;
private static final long OPT_BIT_PRE_TAGS = 0x8L;
private long optBits;
private ImmutableList.Builder fields = ImmutableList.builder();
private boolean useExplicitFieldOrder;
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 Builder() {
}
/**
* Fill a builder with attribute values from the provided {@code com.arakelian.elastic.model.search.Highlighter.Highlight} 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.Highlight 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} 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;
}
private void from(Object object) {
if (object instanceof Highlighter.Highlight) {
Highlighter.Highlight instance = (Highlighter.Highlight) object;
addAllFields(instance.getFields());
useExplicitFieldOrder(instance.isUseExplicitFieldOrder());
}
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);
}
}
}
/**
* Adds one element to {@link Highlighter.Highlight#getFields() fields} list.
* @param element A fields element
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder addField(Highlighter.Field element) {
this.fields.add(element);
optBits |= OPT_BIT_FIELDS;
return this;
}
/**
* Adds elements to {@link Highlighter.Highlight#getFields() fields} list.
* @param elements An array of fields elements
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder addFields(Highlighter.Field... elements) {
this.fields.add(elements);
optBits |= OPT_BIT_FIELDS;
return this;
}
/**
* Sets or replaces all elements for {@link Highlighter.Highlight#getFields() fields} list.
* @param elements An iterable of fields elements
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("fields")
public final Builder fields(Iterable extends Highlighter.Field> elements) {
this.fields = ImmutableList.builder();
return addAllFields(elements);
}
/**
* Adds elements to {@link Highlighter.Highlight#getFields() fields} list.
* @param elements An iterable of fields elements
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder addAllFields(Iterable extends Highlighter.Field> elements) {
this.fields.addAll(elements);
optBits |= OPT_BIT_FIELDS;
return this;
}
/**
* Initializes the value for the {@link Highlighter.Highlight#isUseExplicitFieldOrder() useExplicitFieldOrder} attribute.
* If not set, this attribute will have a default value as returned by the initializer of {@link Highlighter.Highlight#isUseExplicitFieldOrder() useExplicitFieldOrder}.
* @param useExplicitFieldOrder The value for useExplicitFieldOrder
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("useExplicitFieldOrder")
public final Builder useExplicitFieldOrder(boolean useExplicitFieldOrder) {
this.useExplicitFieldOrder = useExplicitFieldOrder;
optBits |= OPT_BIT_USE_EXPLICIT_FIELD_ORDER;
return this;
}
/**
* Initializes the value for the {@link Highlighter.Highlight#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.Highlight#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.Highlight#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.Highlight#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.Highlight#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.Highlight#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.Highlight#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.Highlight#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.Highlight#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.Highlight#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.Highlight#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.Highlight#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.Highlight#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.Highlight#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.Highlight#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.Highlight#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.Highlight#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.Highlight#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.Highlight#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.Highlight#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.Highlight#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.Highlight#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.Highlight#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.Highlight#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.Highlight#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;
}
/**
* Builds a new {@link ImmutableHighlight ImmutableHighlight}.
* @return An immutable instance of Highlight
* @throws java.lang.IllegalStateException if any required attributes are missing
*/
public ImmutableHighlight build() {
return new ImmutableHighlight(this);
}
private boolean fieldsIsSet() {
return (optBits & OPT_BIT_FIELDS) != 0;
}
private boolean useExplicitFieldOrderIsSet() {
return (optBits & OPT_BIT_USE_EXPLICIT_FIELD_ORDER) != 0;
}
private boolean postTagsIsSet() {
return (optBits & OPT_BIT_POST_TAGS) != 0;
}
private boolean preTagsIsSet() {
return (optBits & OPT_BIT_PRE_TAGS) != 0;
}
}
}