com.arakelian.elastic.model.search.ImmutableGeoBoundingBoxQuery Maven / Gradle / Ivy
package com.arakelian.elastic.model.search;
import com.arakelian.core.feature.Nullable;
import com.arakelian.elastic.model.enums.ValidationMethod;
import com.arakelian.jackson.model.GeoPoint;
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.io.ObjectStreamException;
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 GeoBoundingBoxQuery}.
*
* Use the builder to create immutable instances:
* {@code ImmutableGeoBoundingBoxQuery.builder()}.
*/
@Generated(from = "GeoBoundingBoxQuery", generator = "Immutables")
@SuppressWarnings({"all"})
@ParametersAreNonnullByDefault
@javax.annotation.processing.Generated("org.immutables.processor.ProxyProcessor")
@Immutable
@CheckReturnValue
public final class ImmutableGeoBoundingBoxQuery
implements GeoBoundingBoxQuery {
private final @Nullable Float boost;
private final @Nullable String name;
private final boolean hasStandardDefaults;
private final @Nullable GeoPoint bottomLeft;
private final @Nullable GeoPoint bottomRight;
private final String fieldName;
private final @Nullable GeoPoint topLeft;
private final @Nullable GeoPoint topRight;
private final @Nullable GeoBoundingBoxQuery.Type type;
private final @Nullable ValidationMethod validationMethod;
private ImmutableGeoBoundingBoxQuery(ImmutableGeoBoundingBoxQuery.Builder builder) {
this.boost = builder.boost;
this.name = builder.name;
this.bottomLeft = builder.bottomLeft;
this.bottomRight = builder.bottomRight;
this.fieldName = builder.fieldName;
this.topLeft = builder.topLeft;
this.topRight = builder.topRight;
this.type = builder.type;
this.validationMethod = builder.validationMethod;
this.hasStandardDefaults = GeoBoundingBoxQuery.super.hasStandardDefaults();
}
/**
* @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;
}
/**
* @return The value of the {@code bottomLeft} attribute
*/
@JsonProperty("bottom_left")
@Override
public @Nullable GeoPoint getBottomLeft() {
return bottomLeft;
}
/**
* @return The value of the {@code bottomRight} attribute
*/
@JsonProperty("bottom_right")
@Override
public @Nullable GeoPoint getBottomRight() {
return bottomRight;
}
/**
* @return The value of the {@code fieldName} attribute
*/
@JsonProperty("field")
@Override
public String getFieldName() {
return fieldName;
}
/**
* @return The value of the {@code topLeft} attribute
*/
@JsonProperty("top_left")
@Override
public @Nullable GeoPoint getTopLeft() {
return topLeft;
}
/**
* @return The value of the {@code topRight} attribute
*/
@JsonProperty("top_right")
@Override
public @Nullable GeoPoint getTopRight() {
return topRight;
}
/**
* @return The value of the {@code type} attribute
*/
@JsonProperty("type")
@Override
public @Nullable GeoBoundingBoxQuery.Type getType() {
return type;
}
/**
* @return The value of the {@code validationMethod} attribute
*/
@JsonProperty("validation_method")
@Override
public @Nullable ValidationMethod getValidationMethod() {
return validationMethod;
}
/**
* This instance is equal to all instances of {@code ImmutableGeoBoundingBoxQuery} 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 ImmutableGeoBoundingBoxQuery
&& equalTo((ImmutableGeoBoundingBoxQuery) another);
}
private boolean equalTo(ImmutableGeoBoundingBoxQuery another) {
return Objects.equals(boost, another.boost)
&& Objects.equals(name, another.name)
&& Objects.equals(bottomLeft, another.bottomLeft)
&& Objects.equals(bottomRight, another.bottomRight)
&& fieldName.equals(another.fieldName)
&& Objects.equals(topLeft, another.topLeft)
&& Objects.equals(topRight, another.topRight)
&& Objects.equals(type, another.type)
&& Objects.equals(validationMethod, another.validationMethod);
}
/**
* Computes a hash code from attributes: {@code boost}, {@code name}, {@code bottomLeft}, {@code bottomRight}, {@code fieldName}, {@code topLeft}, {@code topRight}, {@code type}, {@code validationMethod}.
* @return hashCode value
*/
@Override
public int hashCode() {
@Var int h = 5381;
h += (h << 5) + Objects.hashCode(boost);
h += (h << 5) + Objects.hashCode(name);
h += (h << 5) + Objects.hashCode(bottomLeft);
h += (h << 5) + Objects.hashCode(bottomRight);
h += (h << 5) + fieldName.hashCode();
h += (h << 5) + Objects.hashCode(topLeft);
h += (h << 5) + Objects.hashCode(topRight);
h += (h << 5) + Objects.hashCode(type);
h += (h << 5) + Objects.hashCode(validationMethod);
return h;
}
/**
* Prints the immutable value {@code GeoBoundingBoxQuery} with attribute values.
* @return A string representation of the value
*/
@Override
public String toString() {
return MoreObjects.toStringHelper("GeoBoundingBoxQuery")
.omitNullValues()
.add("boost", boost)
.add("name", name)
.add("bottomLeft", bottomLeft)
.add("bottomRight", bottomRight)
.add("fieldName", fieldName)
.add("topLeft", topLeft)
.add("topRight", topRight)
.add("type", type)
.add("validationMethod", validationMethod)
.toString();
}
private static ImmutableGeoBoundingBoxQuery validate(ImmutableGeoBoundingBoxQuery instance) {
instance.checkPoints();
return instance;
}
private Object readResolve() throws ObjectStreamException {
return validate(this);
}
/**
* Creates a builder for {@link ImmutableGeoBoundingBoxQuery ImmutableGeoBoundingBoxQuery}.
*
* ImmutableGeoBoundingBoxQuery.builder()
* .boost(Float | null) // nullable {@link GeoBoundingBoxQuery#getBoost() boost}
* .name(String | null) // nullable {@link GeoBoundingBoxQuery#getName() name}
* .bottomLeft(com.arakelian.jackson.model.GeoPoint | null) // nullable {@link GeoBoundingBoxQuery#getBottomLeft() bottomLeft}
* .bottomRight(com.arakelian.jackson.model.GeoPoint | null) // nullable {@link GeoBoundingBoxQuery#getBottomRight() bottomRight}
* .fieldName(String) // required {@link GeoBoundingBoxQuery#getFieldName() fieldName}
* .topLeft(com.arakelian.jackson.model.GeoPoint | null) // nullable {@link GeoBoundingBoxQuery#getTopLeft() topLeft}
* .topRight(com.arakelian.jackson.model.GeoPoint | null) // nullable {@link GeoBoundingBoxQuery#getTopRight() topRight}
* .type(com.arakelian.elastic.model.search.GeoBoundingBoxQuery.Type | null) // nullable {@link GeoBoundingBoxQuery#getType() type}
* .validationMethod(com.arakelian.elastic.model.enums.ValidationMethod | null) // nullable {@link GeoBoundingBoxQuery#getValidationMethod() validationMethod}
* .build();
*
* @return A new ImmutableGeoBoundingBoxQuery builder
*/
public static ImmutableGeoBoundingBoxQuery.Builder builder() {
return new ImmutableGeoBoundingBoxQuery.Builder();
}
/**
* Builds instances of type {@link ImmutableGeoBoundingBoxQuery ImmutableGeoBoundingBoxQuery}.
* 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 = "GeoBoundingBoxQuery", generator = "Immutables")
@NotThreadSafe
@JsonTypeName("geo_bounding_box")
public static final class Builder {
private static final long INIT_BIT_FIELD_NAME = 0x1L;
private long initBits = 0x1L;
private @javax.annotation.Nullable Float boost;
private @javax.annotation.Nullable String name;
private @javax.annotation.Nullable GeoPoint bottomLeft;
private @javax.annotation.Nullable GeoPoint bottomRight;
private @javax.annotation.Nullable String fieldName;
private @javax.annotation.Nullable GeoPoint topLeft;
private @javax.annotation.Nullable GeoPoint topRight;
private @javax.annotation.Nullable GeoBoundingBoxQuery.Type type;
private @javax.annotation.Nullable ValidationMethod validationMethod;
private Builder() {
}
/**
* Fill a builder with attribute values from the provided {@code com.arakelian.elastic.model.search.GeoBoundingBoxQuery} 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(GeoBoundingBoxQuery 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 GeoBoundingBoxQuery) {
GeoBoundingBoxQuery instance = (GeoBoundingBoxQuery) object;
GeoPoint bottomLeftValue = instance.getBottomLeft();
if (bottomLeftValue != null) {
bottomLeft(bottomLeftValue);
}
fieldName(instance.getFieldName());
ValidationMethod validationMethodValue = instance.getValidationMethod();
if (validationMethodValue != null) {
validationMethod(validationMethodValue);
}
GeoPoint bottomRightValue = instance.getBottomRight();
if (bottomRightValue != null) {
bottomRight(bottomRightValue);
}
GeoPoint topLeftValue = instance.getTopLeft();
if (topLeftValue != null) {
topLeft(topLeftValue);
}
GeoPoint topRightValue = instance.getTopRight();
if (topRightValue != null) {
topRight(topRightValue);
}
GeoBoundingBoxQuery.Type typeValue = instance.getType();
if (typeValue != null) {
type(typeValue);
}
}
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 GeoBoundingBoxQuery#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 GeoBoundingBoxQuery#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;
}
/**
* Initializes the value for the {@link GeoBoundingBoxQuery#getBottomLeft() bottomLeft} attribute.
* @param bottomLeft The value for bottomLeft (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("bottom_left")
public final Builder bottomLeft(@Nullable GeoPoint bottomLeft) {
this.bottomLeft = bottomLeft;
return this;
}
/**
* Initializes the value for the {@link GeoBoundingBoxQuery#getBottomRight() bottomRight} attribute.
* @param bottomRight The value for bottomRight (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("bottom_right")
public final Builder bottomRight(@Nullable GeoPoint bottomRight) {
this.bottomRight = bottomRight;
return this;
}
/**
* Initializes the value for the {@link GeoBoundingBoxQuery#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 GeoBoundingBoxQuery#getTopLeft() topLeft} attribute.
* @param topLeft The value for topLeft (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("top_left")
public final Builder topLeft(@Nullable GeoPoint topLeft) {
this.topLeft = topLeft;
return this;
}
/**
* Initializes the value for the {@link GeoBoundingBoxQuery#getTopRight() topRight} attribute.
* @param topRight The value for topRight (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("top_right")
public final Builder topRight(@Nullable GeoPoint topRight) {
this.topRight = topRight;
return this;
}
/**
* Initializes the value for the {@link GeoBoundingBoxQuery#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 GeoBoundingBoxQuery.Type type) {
this.type = type;
return this;
}
/**
* Initializes the value for the {@link GeoBoundingBoxQuery#getValidationMethod() validationMethod} attribute.
* @param validationMethod The value for validationMethod (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("validation_method")
public final Builder validationMethod(@Nullable ValidationMethod validationMethod) {
this.validationMethod = validationMethod;
return this;
}
/**
* Builds a new {@link ImmutableGeoBoundingBoxQuery ImmutableGeoBoundingBoxQuery}.
* @return An immutable instance of GeoBoundingBoxQuery
* @throws java.lang.IllegalStateException if any required attributes are missing
*/
public ImmutableGeoBoundingBoxQuery build() {
if (initBits != 0) {
throw new IllegalStateException(formatRequiredAttributesMessage());
}
return ImmutableGeoBoundingBoxQuery.validate(new ImmutableGeoBoundingBoxQuery(this));
}
private String formatRequiredAttributesMessage() {
List attributes = new ArrayList<>();
if ((initBits & INIT_BIT_FIELD_NAME) != 0) attributes.add("fieldName");
return "Cannot build GeoBoundingBoxQuery, some of required attributes are not set " + attributes;
}
}
}