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

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

package com.arakelian.elastic.model.search;

import com.arakelian.core.feature.Nullable;
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.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 WildcardQuery}.
 * 

* Use the builder to create immutable instances: * {@code ImmutableWildcardQuery.builder()}. */ @Generated(from = "WildcardQuery", generator = "Immutables") @SuppressWarnings({"all"}) @ParametersAreNonnullByDefault @javax.annotation.Generated("org.immutables.processor.ProxyProcessor") @Immutable @CheckReturnValue public final class ImmutableWildcardQuery implements WildcardQuery { private final String fieldName; private final @Nullable Rewrite rewrite; private final String value; private final @Nullable Float boost; private final @Nullable String name; private final boolean hasStandardDefaults; private ImmutableWildcardQuery(ImmutableWildcardQuery.Builder builder) { this.fieldName = builder.fieldName; this.rewrite = builder.rewrite; this.value = builder.value; this.boost = builder.boost; this.name = builder.name; this.hasStandardDefaults = WildcardQuery.super.hasStandardDefaults(); } /** * @return The value of the {@code fieldName} attribute */ @JsonProperty("field") @Override public String getFieldName() { return fieldName; } /** * @return The value of the {@code rewrite} attribute */ @JsonProperty("rewrite") @Override public @Nullable Rewrite getRewrite() { return rewrite; } /** * @return The value of the {@code value} attribute */ @JsonProperty("value") @Override public String getValue() { return value; } /** * @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() { return hasStandardDefaults; } /** * This instance is equal to all instances of {@code ImmutableWildcardQuery} 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 ImmutableWildcardQuery && equalTo((ImmutableWildcardQuery) another); } private boolean equalTo(ImmutableWildcardQuery another) { return fieldName.equals(another.fieldName) && Objects.equals(rewrite, another.rewrite) && value.equals(another.value) && Objects.equals(boost, another.boost) && Objects.equals(name, another.name); } /** * Computes a hash code from attributes: {@code fieldName}, {@code rewrite}, {@code value}, {@code boost}, {@code name}. * @return hashCode value */ @Override public int hashCode() { @Var int h = 5381; h += (h << 5) + fieldName.hashCode(); h += (h << 5) + Objects.hashCode(rewrite); h += (h << 5) + value.hashCode(); h += (h << 5) + Objects.hashCode(boost); h += (h << 5) + Objects.hashCode(name); return h; } /** * Prints the immutable value {@code WildcardQuery} with attribute values. * @return A string representation of the value */ @Override public String toString() { return MoreObjects.toStringHelper("WildcardQuery") .omitNullValues() .add("fieldName", fieldName) .add("rewrite", rewrite) .add("value", value) .add("boost", boost) .add("name", name) .toString(); } /** * Creates a builder for {@link ImmutableWildcardQuery ImmutableWildcardQuery}. * @return A new ImmutableWildcardQuery builder */ public static ImmutableWildcardQuery.Builder builder() { return new ImmutableWildcardQuery.Builder(); } /** * Builds instances of type {@link ImmutableWildcardQuery ImmutableWildcardQuery}. * 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 = "WildcardQuery", generator = "Immutables") @NotThreadSafe @JsonTypeName("wildcard") public static final class Builder { private static final long INIT_BIT_FIELD_NAME = 0x1L; private static final long INIT_BIT_VALUE = 0x2L; private long initBits = 0x3L; private @javax.annotation.Nullable String fieldName; private @javax.annotation.Nullable Rewrite rewrite; private @javax.annotation.Nullable String value; 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.WildcardQuery} 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(WildcardQuery 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.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; } private void from(Object object) { if (object instanceof WildcardQuery) { WildcardQuery instance = (WildcardQuery) object; value(instance.getValue()); Rewrite rewriteValue = instance.getRewrite(); if (rewriteValue != null) { rewrite(rewriteValue); } fieldName(instance.getFieldName()); } 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); } } } /** * Initializes the value for the {@link WildcardQuery#getFieldName() fieldName} attribute. * @param fieldName The value for fieldName * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("field") public final Builder fieldName(String fieldName) { this.fieldName = Objects.requireNonNull(fieldName, "fieldName"); initBits &= ~INIT_BIT_FIELD_NAME; return this; } /** * Initializes the value for the {@link WildcardQuery#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 WildcardQuery#getValue() value} attribute. * @param value The value for value * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("value") public final Builder value(String value) { this.value = Objects.requireNonNull(value, "value"); initBits &= ~INIT_BIT_VALUE; return this; } /** * Initializes the value for the {@link WildcardQuery#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 WildcardQuery#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 ImmutableWildcardQuery ImmutableWildcardQuery}. * @return An immutable instance of WildcardQuery * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableWildcardQuery build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return new ImmutableWildcardQuery(this); } private String formatRequiredAttributesMessage() { List attributes = new ArrayList<>(); if ((initBits & INIT_BIT_FIELD_NAME) != 0) attributes.add("fieldName"); if ((initBits & INIT_BIT_VALUE) != 0) attributes.add("value"); return "Cannot build WildcardQuery, some of required attributes are not set " + attributes; } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy