com.arakelian.elastic.model.search.ImmutableQueryStringQuery Maven / Gradle / Ivy
package com.arakelian.elastic.model.search;
import com.arakelian.core.feature.Nullable;
import com.arakelian.elastic.model.enums.MultiMatchType;
import com.arakelian.elastic.model.enums.Operator;
import com.arakelian.elastic.model.enums.Rewrite;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeName;
import com.google.common.base.MoreObjects;
import com.google.common.collect.ImmutableSortedSet;
import com.google.common.collect.Ordering;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.errorprone.annotations.Var;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.SortedSet;
import javax.annotation.CheckReturnValue;
import javax.annotation.Generated;
import javax.annotation.ParametersAreNonnullByDefault;
import javax.annotation.concurrent.Immutable;
import javax.annotation.concurrent.NotThreadSafe;
/**
* Immutable implementation of {@link QueryStringQuery}.
*
* Use the builder to create immutable instances:
* {@code ImmutableQueryStringQuery.builder()}.
*/
@SuppressWarnings({"all"})
@ParametersAreNonnullByDefault
@Generated("org.immutables.processor.ProxyProcessor")
@Immutable
@CheckReturnValue
public final class ImmutableQueryStringQuery implements QueryStringQuery {
private final @Nullable String fuzzyRewrite;
private final @Nullable String analyzer;
private final @Nullable String defaultField;
private final @Nullable Operator defaultOperator;
private final ImmutableSortedSet fields;
private final @Nullable String fuzziness;
private final @Nullable Integer fuzzyMaxExpansions;
private final @Nullable Integer fuzzyPrefixLength;
private final @Nullable Integer maxDeterminizedStates;
private final @Nullable String minimumShouldMatch;
private final @Nullable MultiMatchType multiMatchType;
private final @Nullable Integer phraseSlop;
private final String queryString;
private final @Nullable String quoteAnalyzer;
private final @Nullable String quoteFieldSuffix;
private final @Nullable Rewrite rewrite;
private final @Nullable Float tieBreaker;
private final @Nullable String timeZone;
private final @Nullable Boolean allowLeadingWildcard;
private final @Nullable Boolean analyzeWildcard;
private final @Nullable Boolean autoGenerateSynonymsPhraseQuery;
private final @Nullable Boolean enablePositionIncrements;
private final @Nullable Boolean escape;
private final @Nullable Boolean fuzzyTranspositions;
private final @Nullable Boolean lenient;
private final @Nullable Float boost;
private final @Nullable String name;
private final boolean hasStandardDefaults;
private ImmutableQueryStringQuery(ImmutableQueryStringQuery.Builder builder) {
this.fuzzyRewrite = builder.fuzzyRewrite;
this.analyzer = builder.analyzer;
this.defaultField = builder.defaultField;
this.defaultOperator = builder.defaultOperator;
this.fuzziness = builder.fuzziness;
this.fuzzyMaxExpansions = builder.fuzzyMaxExpansions;
this.fuzzyPrefixLength = builder.fuzzyPrefixLength;
this.maxDeterminizedStates = builder.maxDeterminizedStates;
this.minimumShouldMatch = builder.minimumShouldMatch;
this.multiMatchType = builder.multiMatchType;
this.phraseSlop = builder.phraseSlop;
this.queryString = builder.queryString;
this.quoteAnalyzer = builder.quoteAnalyzer;
this.quoteFieldSuffix = builder.quoteFieldSuffix;
this.rewrite = builder.rewrite;
this.tieBreaker = builder.tieBreaker;
this.timeZone = builder.timeZone;
this.allowLeadingWildcard = builder.allowLeadingWildcard;
this.analyzeWildcard = builder.analyzeWildcard;
this.autoGenerateSynonymsPhraseQuery = builder.autoGenerateSynonymsPhraseQuery;
this.enablePositionIncrements = builder.enablePositionIncrements;
this.escape = builder.escape;
this.fuzzyTranspositions = builder.fuzzyTranspositions;
this.lenient = builder.lenient;
this.boost = builder.boost;
this.name = builder.name;
if (builder.fieldsIsSet()) {
initShim.fields(builder.fields.build());
}
this.fields = initShim.getFields();
this.hasStandardDefaults = initShim.hasStandardDefaults();
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();
private final class InitShim {
private byte fieldsBuildStage = STAGE_UNINITIALIZED;
private ImmutableSortedSet fields;
ImmutableSortedSet getFields() {
if (fieldsBuildStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage());
if (fieldsBuildStage == STAGE_UNINITIALIZED) {
fieldsBuildStage = STAGE_INITIALIZING;
this.fields = ImmutableSortedSet.copyOf(
Ordering.natural(),
getFieldsInitialize());
fieldsBuildStage = STAGE_INITIALIZED;
}
return this.fields;
}
void fields(ImmutableSortedSet fields) {
this.fields = fields;
fieldsBuildStage = STAGE_INITIALIZED;
}
private byte hasStandardDefaultsBuildStage = STAGE_UNINITIALIZED;
private boolean hasStandardDefaults;
boolean hasStandardDefaults() {
if (hasStandardDefaultsBuildStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage());
if (hasStandardDefaultsBuildStage == STAGE_UNINITIALIZED) {
hasStandardDefaultsBuildStage = STAGE_INITIALIZING;
this.hasStandardDefaults = hasStandardDefaultsInitialize();
hasStandardDefaultsBuildStage = STAGE_INITIALIZED;
}
return this.hasStandardDefaults;
}
private String formatInitCycleMessage() {
List attributes = new ArrayList<>();
if (fieldsBuildStage == STAGE_INITIALIZING) attributes.add("fields");
if (hasStandardDefaultsBuildStage == STAGE_INITIALIZING) attributes.add("hasStandardDefaults");
return "Cannot build QueryStringQuery, attribute initializers form cycle " + attributes;
}
}
private SortedSet getFieldsInitialize() {
return QueryStringQuery.super.getFields();
}
private boolean hasStandardDefaultsInitialize() {
return QueryStringQuery.super.hasStandardDefaults();
}
/**
* @return The value of the {@code fuzzyRewrite} attribute
*/
@JsonProperty("fuzzyRewrite")
@Override
public @Nullable String fuzzyRewrite() {
return fuzzyRewrite;
}
/**
* @return The value of the {@code analyzer} attribute
*/
@JsonProperty("analyzer")
@Override
public @Nullable String getAnalyzer() {
return analyzer;
}
/**
* @return The value of the {@code defaultField} attribute
*/
@JsonProperty("defaultField")
@Override
public @Nullable String getDefaultField() {
return defaultField;
}
/**
* @return The value of the {@code defaultOperator} attribute
*/
@JsonProperty("defaultOperator")
@Override
public @Nullable Operator getDefaultOperator() {
return defaultOperator;
}
/**
* @return The value of the {@code fields} attribute
*/
@JsonProperty("fields")
@Override
public ImmutableSortedSet getFields() {
InitShim shim = this.initShim;
return shim != null
? shim.getFields()
: this.fields;
}
/**
* @return The value of the {@code fuzziness} attribute
*/
@JsonProperty("fuzziness")
@Override
public @Nullable String getFuzziness() {
return fuzziness;
}
/**
* @return The value of the {@code fuzzyMaxExpansions} attribute
*/
@JsonProperty("fuzzyMaxExpansions")
@Override
public @Nullable Integer getFuzzyMaxExpansions() {
return fuzzyMaxExpansions;
}
/**
* @return The value of the {@code fuzzyPrefixLength} attribute
*/
@JsonProperty("fuzzyPrefixLength")
@Override
public @Nullable Integer getFuzzyPrefixLength() {
return fuzzyPrefixLength;
}
/**
* @return The value of the {@code maxDeterminizedStates} attribute
*/
@JsonProperty("maxDeterminizedStates")
@Override
public @Nullable Integer getMaxDeterminizedStates() {
return maxDeterminizedStates;
}
/**
* @return The value of the {@code minimumShouldMatch} attribute
*/
@JsonProperty("minimumShouldMatch")
@Override
public @Nullable String getMinimumShouldMatch() {
return minimumShouldMatch;
}
/**
* @return The value of the {@code multiMatchType} attribute
*/
@JsonProperty("multiMatchType")
@Override
public @Nullable MultiMatchType getMultiMatchType() {
return multiMatchType;
}
/**
* @return The value of the {@code phraseSlop} attribute
*/
@JsonProperty("phraseSlop")
@Override
public @Nullable Integer getPhraseSlop() {
return phraseSlop;
}
/**
* @return The value of the {@code queryString} attribute
*/
@JsonProperty("queryString")
@Override
public String getQueryString() {
return queryString;
}
/**
* @return The value of the {@code quoteAnalyzer} attribute
*/
@JsonProperty("quoteAnalyzer")
@Override
public @Nullable String getQuoteAnalyzer() {
return quoteAnalyzer;
}
/**
* @return The value of the {@code quoteFieldSuffix} attribute
*/
@JsonProperty("quoteFieldSuffix")
@Override
public @Nullable String getQuoteFieldSuffix() {
return quoteFieldSuffix;
}
/**
* @return The value of the {@code rewrite} attribute
*/
@JsonProperty("rewrite")
@Override
public @Nullable Rewrite getRewrite() {
return rewrite;
}
/**
* @return The value of the {@code tieBreaker} attribute
*/
@JsonProperty("tieBreaker")
@Override
public @Nullable Float getTieBreaker() {
return tieBreaker;
}
/**
* @return The value of the {@code timeZone} attribute
*/
@JsonProperty("timeZone")
@Override
public @Nullable String getTimeZone() {
return timeZone;
}
/**
* @return The value of the {@code allowLeadingWildcard} attribute
*/
@JsonProperty("allowLeadingWildcard")
@Override
public @Nullable Boolean isAllowLeadingWildcard() {
return allowLeadingWildcard;
}
/**
* @return The value of the {@code analyzeWildcard} attribute
*/
@JsonProperty("analyzeWildcard")
@Override
public @Nullable Boolean isAnalyzeWildcard() {
return analyzeWildcard;
}
/**
* @return The value of the {@code autoGenerateSynonymsPhraseQuery} attribute
*/
@JsonProperty("autoGenerateSynonymsPhraseQuery")
@Override
public @Nullable Boolean isAutoGenerateSynonymsPhraseQuery() {
return autoGenerateSynonymsPhraseQuery;
}
/**
* @return The value of the {@code enablePositionIncrements} attribute
*/
@JsonProperty("enablePositionIncrements")
@Override
public @Nullable Boolean isEnablePositionIncrements() {
return enablePositionIncrements;
}
/**
* @return The value of the {@code escape} attribute
*/
@JsonProperty("escape")
@Override
public @Nullable Boolean isEscape() {
return escape;
}
/**
* @return The value of the {@code fuzzyTranspositions} attribute
*/
@JsonProperty("fuzzyTranspositions")
@Override
public @Nullable Boolean isFuzzyTranspositions() {
return fuzzyTranspositions;
}
/**
* @return The value of the {@code lenient} attribute
*/
@JsonProperty("lenient")
@Override
public @Nullable Boolean isLenient() {
return lenient;
}
/**
* @return The value of the {@code boost} attribute
*/
@JsonProperty("boost")
@Override
public @Nullable Float getBoost() {
return boost;
}
/**
* Returns the name of the query
* @return name of the query
* @see Named
* Queries
*/
@JsonProperty("_name")
@Override
public @Nullable String getName() {
return name;
}
/**
* @return The computed-at-construction value of the {@code hasStandardDefaults} attribute
*/
@JsonProperty("hasStandardDefaults")
@JsonIgnore
@Override
public boolean hasStandardDefaults() {
InitShim shim = this.initShim;
return shim != null
? shim.hasStandardDefaults()
: this.hasStandardDefaults;
}
/**
* This instance is equal to all instances of {@code ImmutableQueryStringQuery} 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 ImmutableQueryStringQuery
&& equalTo((ImmutableQueryStringQuery) another);
}
private boolean equalTo(ImmutableQueryStringQuery another) {
return Objects.equals(fuzzyRewrite, another.fuzzyRewrite)
&& Objects.equals(analyzer, another.analyzer)
&& Objects.equals(defaultField, another.defaultField)
&& Objects.equals(defaultOperator, another.defaultOperator)
&& fields.equals(another.fields)
&& Objects.equals(fuzziness, another.fuzziness)
&& Objects.equals(fuzzyMaxExpansions, another.fuzzyMaxExpansions)
&& Objects.equals(fuzzyPrefixLength, another.fuzzyPrefixLength)
&& Objects.equals(maxDeterminizedStates, another.maxDeterminizedStates)
&& Objects.equals(minimumShouldMatch, another.minimumShouldMatch)
&& Objects.equals(multiMatchType, another.multiMatchType)
&& Objects.equals(phraseSlop, another.phraseSlop)
&& queryString.equals(another.queryString)
&& Objects.equals(quoteAnalyzer, another.quoteAnalyzer)
&& Objects.equals(quoteFieldSuffix, another.quoteFieldSuffix)
&& Objects.equals(rewrite, another.rewrite)
&& Objects.equals(tieBreaker, another.tieBreaker)
&& Objects.equals(timeZone, another.timeZone)
&& Objects.equals(allowLeadingWildcard, another.allowLeadingWildcard)
&& Objects.equals(analyzeWildcard, another.analyzeWildcard)
&& Objects.equals(autoGenerateSynonymsPhraseQuery, another.autoGenerateSynonymsPhraseQuery)
&& Objects.equals(enablePositionIncrements, another.enablePositionIncrements)
&& Objects.equals(escape, another.escape)
&& Objects.equals(fuzzyTranspositions, another.fuzzyTranspositions)
&& Objects.equals(lenient, another.lenient)
&& Objects.equals(boost, another.boost)
&& Objects.equals(name, another.name);
}
/**
* Computes a hash code from attributes: {@code fuzzyRewrite}, {@code analyzer}, {@code defaultField}, {@code defaultOperator}, {@code fields}, {@code fuzziness}, {@code fuzzyMaxExpansions}, {@code fuzzyPrefixLength}, {@code maxDeterminizedStates}, {@code minimumShouldMatch}, {@code multiMatchType}, {@code phraseSlop}, {@code queryString}, {@code quoteAnalyzer}, {@code quoteFieldSuffix}, {@code rewrite}, {@code tieBreaker}, {@code timeZone}, {@code allowLeadingWildcard}, {@code analyzeWildcard}, {@code autoGenerateSynonymsPhraseQuery}, {@code enablePositionIncrements}, {@code escape}, {@code fuzzyTranspositions}, {@code lenient}, {@code boost}, {@code name}.
* @return hashCode value
*/
@Override
public int hashCode() {
@Var int h = 5381;
h += (h << 5) + Objects.hashCode(fuzzyRewrite);
h += (h << 5) + Objects.hashCode(analyzer);
h += (h << 5) + Objects.hashCode(defaultField);
h += (h << 5) + Objects.hashCode(defaultOperator);
h += (h << 5) + fields.hashCode();
h += (h << 5) + Objects.hashCode(fuzziness);
h += (h << 5) + Objects.hashCode(fuzzyMaxExpansions);
h += (h << 5) + Objects.hashCode(fuzzyPrefixLength);
h += (h << 5) + Objects.hashCode(maxDeterminizedStates);
h += (h << 5) + Objects.hashCode(minimumShouldMatch);
h += (h << 5) + Objects.hashCode(multiMatchType);
h += (h << 5) + Objects.hashCode(phraseSlop);
h += (h << 5) + queryString.hashCode();
h += (h << 5) + Objects.hashCode(quoteAnalyzer);
h += (h << 5) + Objects.hashCode(quoteFieldSuffix);
h += (h << 5) + Objects.hashCode(rewrite);
h += (h << 5) + Objects.hashCode(tieBreaker);
h += (h << 5) + Objects.hashCode(timeZone);
h += (h << 5) + Objects.hashCode(allowLeadingWildcard);
h += (h << 5) + Objects.hashCode(analyzeWildcard);
h += (h << 5) + Objects.hashCode(autoGenerateSynonymsPhraseQuery);
h += (h << 5) + Objects.hashCode(enablePositionIncrements);
h += (h << 5) + Objects.hashCode(escape);
h += (h << 5) + Objects.hashCode(fuzzyTranspositions);
h += (h << 5) + Objects.hashCode(lenient);
h += (h << 5) + Objects.hashCode(boost);
h += (h << 5) + Objects.hashCode(name);
return h;
}
/**
* Prints the immutable value {@code QueryStringQuery} with attribute values.
* @return A string representation of the value
*/
@Override
public String toString() {
return MoreObjects.toStringHelper("QueryStringQuery")
.omitNullValues()
.add("fuzzyRewrite", fuzzyRewrite)
.add("analyzer", analyzer)
.add("defaultField", defaultField)
.add("defaultOperator", defaultOperator)
.add("fields", fields)
.add("fuzziness", fuzziness)
.add("fuzzyMaxExpansions", fuzzyMaxExpansions)
.add("fuzzyPrefixLength", fuzzyPrefixLength)
.add("maxDeterminizedStates", maxDeterminizedStates)
.add("minimumShouldMatch", minimumShouldMatch)
.add("multiMatchType", multiMatchType)
.add("phraseSlop", phraseSlop)
.add("queryString", queryString)
.add("quoteAnalyzer", quoteAnalyzer)
.add("quoteFieldSuffix", quoteFieldSuffix)
.add("rewrite", rewrite)
.add("tieBreaker", tieBreaker)
.add("timeZone", timeZone)
.add("allowLeadingWildcard", allowLeadingWildcard)
.add("analyzeWildcard", analyzeWildcard)
.add("autoGenerateSynonymsPhraseQuery", autoGenerateSynonymsPhraseQuery)
.add("enablePositionIncrements", enablePositionIncrements)
.add("escape", escape)
.add("fuzzyTranspositions", fuzzyTranspositions)
.add("lenient", lenient)
.add("boost", boost)
.add("name", name)
.toString();
}
/**
* Creates a builder for {@link ImmutableQueryStringQuery ImmutableQueryStringQuery}.
* @return A new ImmutableQueryStringQuery builder
*/
public static ImmutableQueryStringQuery.Builder builder() {
return new ImmutableQueryStringQuery.Builder();
}
/**
* Builds instances of type {@link ImmutableQueryStringQuery ImmutableQueryStringQuery}.
* 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
@JsonTypeName("query_string")
public static final class Builder {
private static final long INIT_BIT_QUERY_STRING = 0x1L;
private static final long OPT_BIT_FIELDS = 0x1L;
private long initBits = 0x1L;
private long optBits;
private @javax.annotation.Nullable String fuzzyRewrite;
private @javax.annotation.Nullable String analyzer;
private @javax.annotation.Nullable String defaultField;
private @javax.annotation.Nullable Operator defaultOperator;
private ImmutableSortedSet.Builder fields = ImmutableSortedSet.naturalOrder();
private @javax.annotation.Nullable String fuzziness;
private @javax.annotation.Nullable Integer fuzzyMaxExpansions;
private @javax.annotation.Nullable Integer fuzzyPrefixLength;
private @javax.annotation.Nullable Integer maxDeterminizedStates;
private @javax.annotation.Nullable String minimumShouldMatch;
private @javax.annotation.Nullable MultiMatchType multiMatchType;
private @javax.annotation.Nullable Integer phraseSlop;
private @javax.annotation.Nullable String queryString;
private @javax.annotation.Nullable String quoteAnalyzer;
private @javax.annotation.Nullable String quoteFieldSuffix;
private @javax.annotation.Nullable Rewrite rewrite;
private @javax.annotation.Nullable Float tieBreaker;
private @javax.annotation.Nullable String timeZone;
private @javax.annotation.Nullable Boolean allowLeadingWildcard;
private @javax.annotation.Nullable Boolean analyzeWildcard;
private @javax.annotation.Nullable Boolean autoGenerateSynonymsPhraseQuery;
private @javax.annotation.Nullable Boolean enablePositionIncrements;
private @javax.annotation.Nullable Boolean escape;
private @javax.annotation.Nullable Boolean fuzzyTranspositions;
private @javax.annotation.Nullable Boolean lenient;
private @javax.annotation.Nullable Float boost;
private @javax.annotation.Nullable String name;
private Builder() {
}
/**
* Fill a builder with attribute values from the provided {@code com.arakelian.elastic.model.search.StandardQuery} 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(StandardQuery 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.QueryStringQuery} 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(QueryStringQuery instance) {
Objects.requireNonNull(instance, "instance");
from((Object) instance);
return this;
}
private void from(Object object) {
if (object instanceof StandardQuery) {
StandardQuery instance = (StandardQuery) object;
String nameValue = instance.getName();
if (nameValue != null) {
name(nameValue);
}
Float boostValue = instance.getBoost();
if (boostValue != null) {
boost(boostValue);
}
}
if (object instanceof QueryStringQuery) {
QueryStringQuery instance = (QueryStringQuery) object;
String fuzzinessValue = instance.getFuzziness();
if (fuzzinessValue != null) {
fuzziness(fuzzinessValue);
}
Boolean allowLeadingWildcardValue = instance.isAllowLeadingWildcard();
if (allowLeadingWildcardValue != null) {
allowLeadingWildcard(allowLeadingWildcardValue);
}
Boolean fuzzyTranspositionsValue = instance.isFuzzyTranspositions();
if (fuzzyTranspositionsValue != null) {
fuzzyTranspositions(fuzzyTranspositionsValue);
}
String quoteAnalyzerValue = instance.getQuoteAnalyzer();
if (quoteAnalyzerValue != null) {
quoteAnalyzer(quoteAnalyzerValue);
}
Operator defaultOperatorValue = instance.getDefaultOperator();
if (defaultOperatorValue != null) {
defaultOperator(defaultOperatorValue);
}
Boolean analyzeWildcardValue = instance.isAnalyzeWildcard();
if (analyzeWildcardValue != null) {
analyzeWildcard(analyzeWildcardValue);
}
Boolean lenientValue = instance.isLenient();
if (lenientValue != null) {
lenient(lenientValue);
}
String minimumShouldMatchValue = instance.getMinimumShouldMatch();
if (minimumShouldMatchValue != null) {
minimumShouldMatch(minimumShouldMatchValue);
}
Boolean autoGenerateSynonymsPhraseQueryValue = instance.isAutoGenerateSynonymsPhraseQuery();
if (autoGenerateSynonymsPhraseQueryValue != null) {
autoGenerateSynonymsPhraseQuery(autoGenerateSynonymsPhraseQueryValue);
}
String fuzzyRewriteValue = instance.fuzzyRewrite();
if (fuzzyRewriteValue != null) {
fuzzyRewrite(fuzzyRewriteValue);
}
String analyzerValue = instance.getAnalyzer();
if (analyzerValue != null) {
analyzer(analyzerValue);
}
Integer fuzzyMaxExpansionsValue = instance.getFuzzyMaxExpansions();
if (fuzzyMaxExpansionsValue != null) {
fuzzyMaxExpansions(fuzzyMaxExpansionsValue);
}
Boolean escapeValue = instance.isEscape();
if (escapeValue != null) {
escape(escapeValue);
}
Integer fuzzyPrefixLengthValue = instance.getFuzzyPrefixLength();
if (fuzzyPrefixLengthValue != null) {
fuzzyPrefixLength(fuzzyPrefixLengthValue);
}
String defaultFieldValue = instance.getDefaultField();
if (defaultFieldValue != null) {
defaultField(defaultFieldValue);
}
MultiMatchType multiMatchTypeValue = instance.getMultiMatchType();
if (multiMatchTypeValue != null) {
multiMatchType(multiMatchTypeValue);
}
String timeZoneValue = instance.getTimeZone();
if (timeZoneValue != null) {
timeZone(timeZoneValue);
}
Integer maxDeterminizedStatesValue = instance.getMaxDeterminizedStates();
if (maxDeterminizedStatesValue != null) {
maxDeterminizedStates(maxDeterminizedStatesValue);
}
queryString(instance.getQueryString());
String quoteFieldSuffixValue = instance.getQuoteFieldSuffix();
if (quoteFieldSuffixValue != null) {
quoteFieldSuffix(quoteFieldSuffixValue);
}
Float tieBreakerValue = instance.getTieBreaker();
if (tieBreakerValue != null) {
tieBreaker(tieBreakerValue);
}
Rewrite rewriteValue = instance.getRewrite();
if (rewriteValue != null) {
rewrite(rewriteValue);
}
Integer phraseSlopValue = instance.getPhraseSlop();
if (phraseSlopValue != null) {
phraseSlop(phraseSlopValue);
}
addAllFields(instance.getFields());
Boolean enablePositionIncrementsValue = instance.isEnablePositionIncrements();
if (enablePositionIncrementsValue != null) {
enablePositionIncrements(enablePositionIncrementsValue);
}
}
}
/**
* Initializes the value for the {@link QueryStringQuery#fuzzyRewrite() fuzzyRewrite} attribute.
* @param fuzzyRewrite The value for fuzzyRewrite (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("fuzzyRewrite")
public final Builder fuzzyRewrite(@Nullable String fuzzyRewrite) {
this.fuzzyRewrite = fuzzyRewrite;
return this;
}
/**
* Initializes the value for the {@link QueryStringQuery#getAnalyzer() analyzer} attribute.
* @param analyzer The value for analyzer (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("analyzer")
public final Builder analyzer(@Nullable String analyzer) {
this.analyzer = analyzer;
return this;
}
/**
* Initializes the value for the {@link QueryStringQuery#getDefaultField() defaultField} attribute.
* @param defaultField The value for defaultField (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("defaultField")
public final Builder defaultField(@Nullable String defaultField) {
this.defaultField = defaultField;
return this;
}
/**
* Initializes the value for the {@link QueryStringQuery#getDefaultOperator() defaultOperator} attribute.
* @param defaultOperator The value for defaultOperator (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("defaultOperator")
public final Builder defaultOperator(@Nullable Operator defaultOperator) {
this.defaultOperator = defaultOperator;
return this;
}
/**
* Adds one element to {@link QueryStringQuery#getFields() fields} sortedSet.
* @param element A fields element
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder addField(String element) {
this.fields.add(element);
optBits |= OPT_BIT_FIELDS;
return this;
}
/**
* Adds elements to {@link QueryStringQuery#getFields() fields} sortedSet.
* @param elements An array of fields elements
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder addFields(String... elements) {
this.fields.addAll(Arrays.asList(elements));
optBits |= OPT_BIT_FIELDS;
return this;
}
/**
* Sets or replaces all elements for {@link QueryStringQuery#getFields() fields} sortedSet.
* @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 elements) {
this.fields = ImmutableSortedSet.naturalOrder();
return addAllFields(elements);
}
/**
* Adds elements to {@link QueryStringQuery#getFields() fields} sortedSet.
* @param elements An iterable of fields elements
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder addAllFields(Iterable elements) {
this.fields.addAll(elements);
optBits |= OPT_BIT_FIELDS;
return this;
}
/**
* Initializes the value for the {@link QueryStringQuery#getFuzziness() fuzziness} attribute.
* @param fuzziness The value for fuzziness (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("fuzziness")
public final Builder fuzziness(@Nullable String fuzziness) {
this.fuzziness = fuzziness;
return this;
}
/**
* Initializes the value for the {@link QueryStringQuery#getFuzzyMaxExpansions() fuzzyMaxExpansions} attribute.
* @param fuzzyMaxExpansions The value for fuzzyMaxExpansions (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("fuzzyMaxExpansions")
public final Builder fuzzyMaxExpansions(@Nullable Integer fuzzyMaxExpansions) {
this.fuzzyMaxExpansions = fuzzyMaxExpansions;
return this;
}
/**
* Initializes the value for the {@link QueryStringQuery#getFuzzyPrefixLength() fuzzyPrefixLength} attribute.
* @param fuzzyPrefixLength The value for fuzzyPrefixLength (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("fuzzyPrefixLength")
public final Builder fuzzyPrefixLength(@Nullable Integer fuzzyPrefixLength) {
this.fuzzyPrefixLength = fuzzyPrefixLength;
return this;
}
/**
* Initializes the value for the {@link QueryStringQuery#getMaxDeterminizedStates() maxDeterminizedStates} attribute.
* @param maxDeterminizedStates The value for maxDeterminizedStates (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("maxDeterminizedStates")
public final Builder maxDeterminizedStates(@Nullable Integer maxDeterminizedStates) {
this.maxDeterminizedStates = maxDeterminizedStates;
return this;
}
/**
* Initializes the value for the {@link QueryStringQuery#getMinimumShouldMatch() minimumShouldMatch} attribute.
* @param minimumShouldMatch The value for minimumShouldMatch (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("minimumShouldMatch")
public final Builder minimumShouldMatch(@Nullable String minimumShouldMatch) {
this.minimumShouldMatch = minimumShouldMatch;
return this;
}
/**
* Initializes the value for the {@link QueryStringQuery#getMultiMatchType() multiMatchType} attribute.
* @param multiMatchType The value for multiMatchType (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("multiMatchType")
public final Builder multiMatchType(@Nullable MultiMatchType multiMatchType) {
this.multiMatchType = multiMatchType;
return this;
}
/**
* Initializes the value for the {@link QueryStringQuery#getPhraseSlop() phraseSlop} attribute.
* @param phraseSlop The value for phraseSlop (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("phraseSlop")
public final Builder phraseSlop(@Nullable Integer phraseSlop) {
this.phraseSlop = phraseSlop;
return this;
}
/**
* Initializes the value for the {@link QueryStringQuery#getQueryString() queryString} attribute.
* @param queryString The value for queryString
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("queryString")
public final Builder queryString(String queryString) {
this.queryString = Objects.requireNonNull(queryString, "queryString");
initBits &= ~INIT_BIT_QUERY_STRING;
return this;
}
/**
* Initializes the value for the {@link QueryStringQuery#getQuoteAnalyzer() quoteAnalyzer} attribute.
* @param quoteAnalyzer The value for quoteAnalyzer (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("quoteAnalyzer")
public final Builder quoteAnalyzer(@Nullable String quoteAnalyzer) {
this.quoteAnalyzer = quoteAnalyzer;
return this;
}
/**
* Initializes the value for the {@link QueryStringQuery#getQuoteFieldSuffix() quoteFieldSuffix} attribute.
* @param quoteFieldSuffix The value for quoteFieldSuffix (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("quoteFieldSuffix")
public final Builder quoteFieldSuffix(@Nullable String quoteFieldSuffix) {
this.quoteFieldSuffix = quoteFieldSuffix;
return this;
}
/**
* Initializes the value for the {@link QueryStringQuery#getRewrite() rewrite} attribute.
* @param rewrite The value for rewrite (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("rewrite")
public final Builder rewrite(@Nullable Rewrite rewrite) {
this.rewrite = rewrite;
return this;
}
/**
* Initializes the value for the {@link QueryStringQuery#getTieBreaker() tieBreaker} attribute.
* @param tieBreaker The value for tieBreaker (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("tieBreaker")
public final Builder tieBreaker(@Nullable Float tieBreaker) {
this.tieBreaker = tieBreaker;
return this;
}
/**
* Initializes the value for the {@link QueryStringQuery#getTimeZone() timeZone} attribute.
* @param timeZone The value for timeZone (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("timeZone")
public final Builder timeZone(@Nullable String timeZone) {
this.timeZone = timeZone;
return this;
}
/**
* Initializes the value for the {@link QueryStringQuery#isAllowLeadingWildcard() allowLeadingWildcard} attribute.
* @param allowLeadingWildcard The value for allowLeadingWildcard (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("allowLeadingWildcard")
public final Builder allowLeadingWildcard(@Nullable Boolean allowLeadingWildcard) {
this.allowLeadingWildcard = allowLeadingWildcard;
return this;
}
/**
* Initializes the value for the {@link QueryStringQuery#isAnalyzeWildcard() analyzeWildcard} attribute.
* @param analyzeWildcard The value for analyzeWildcard (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("analyzeWildcard")
public final Builder analyzeWildcard(@Nullable Boolean analyzeWildcard) {
this.analyzeWildcard = analyzeWildcard;
return this;
}
/**
* Initializes the value for the {@link QueryStringQuery#isAutoGenerateSynonymsPhraseQuery() autoGenerateSynonymsPhraseQuery} attribute.
* @param autoGenerateSynonymsPhraseQuery The value for autoGenerateSynonymsPhraseQuery (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("autoGenerateSynonymsPhraseQuery")
public final Builder autoGenerateSynonymsPhraseQuery(@Nullable Boolean autoGenerateSynonymsPhraseQuery) {
this.autoGenerateSynonymsPhraseQuery = autoGenerateSynonymsPhraseQuery;
return this;
}
/**
* Initializes the value for the {@link QueryStringQuery#isEnablePositionIncrements() enablePositionIncrements} attribute.
* @param enablePositionIncrements The value for enablePositionIncrements (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("enablePositionIncrements")
public final Builder enablePositionIncrements(@Nullable Boolean enablePositionIncrements) {
this.enablePositionIncrements = enablePositionIncrements;
return this;
}
/**
* Initializes the value for the {@link QueryStringQuery#isEscape() escape} attribute.
* @param escape The value for escape (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("escape")
public final Builder escape(@Nullable Boolean escape) {
this.escape = escape;
return this;
}
/**
* Initializes the value for the {@link QueryStringQuery#isFuzzyTranspositions() fuzzyTranspositions} attribute.
* @param fuzzyTranspositions The value for fuzzyTranspositions (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("fuzzyTranspositions")
public final Builder fuzzyTranspositions(@Nullable Boolean fuzzyTranspositions) {
this.fuzzyTranspositions = fuzzyTranspositions;
return this;
}
/**
* Initializes the value for the {@link QueryStringQuery#isLenient() lenient} attribute.
* @param lenient The value for lenient (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("lenient")
public final Builder lenient(@Nullable Boolean lenient) {
this.lenient = lenient;
return this;
}
/**
* Initializes the value for the {@link QueryStringQuery#getBoost() boost} attribute.
* @param boost The value for boost (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("boost")
public final Builder boost(@Nullable Float boost) {
this.boost = boost;
return this;
}
/**
* Initializes the value for the {@link QueryStringQuery#getName() name} attribute.
* @param name The value for name (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("_name")
public final Builder name(@Nullable String name) {
this.name = name;
return this;
}
/**
* Builds a new {@link ImmutableQueryStringQuery ImmutableQueryStringQuery}.
* @return An immutable instance of QueryStringQuery
* @throws java.lang.IllegalStateException if any required attributes are missing
*/
public ImmutableQueryStringQuery build() {
if (initBits != 0) {
throw new IllegalStateException(formatRequiredAttributesMessage());
}
return new ImmutableQueryStringQuery(this);
}
private boolean fieldsIsSet() {
return (optBits & OPT_BIT_FIELDS) != 0;
}
private String formatRequiredAttributesMessage() {
List attributes = new ArrayList<>();
if ((initBits & INIT_BIT_QUERY_STRING) != 0) attributes.add("queryString");
return "Cannot build QueryStringQuery, some of required attributes are not set " + attributes;
}
}
}