com.arakelian.elastic.model.search.ImmutableGeoShapeQuery Maven / Gradle / Ivy
package com.arakelian.elastic.model.search;
import com.arakelian.core.feature.Nullable;
import com.arakelian.elastic.model.enums.ShapeRelation;
import com.arakelian.elastic.model.enums.SpatialStrategy;
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 GeoShapeQuery}.
*
* Use the builder to create immutable instances:
* {@code ImmutableGeoShapeQuery.builder()}.
*/
@Generated(from = "GeoShapeQuery", generator = "Immutables")
@SuppressWarnings({"all"})
@ParametersAreNonnullByDefault
@javax.annotation.Generated("org.immutables.processor.ProxyProcessor")
@Immutable
@CheckReturnValue
public final class ImmutableGeoShapeQuery implements GeoShapeQuery {
private final String fieldName;
private final @Nullable IndexedShape indexedShape;
private final @Nullable ShapeRelation relation;
private final @Nullable Shape shape;
private final @Nullable SpatialStrategy strategy;
private final @Nullable Float boost;
private final @Nullable String name;
private final boolean hasStandardDefaults;
private ImmutableGeoShapeQuery(ImmutableGeoShapeQuery.Builder builder) {
this.fieldName = builder.fieldName;
this.indexedShape = builder.indexedShape;
this.relation = builder.relation;
this.shape = builder.shape;
this.strategy = builder.strategy;
this.boost = builder.boost;
this.name = builder.name;
this.hasStandardDefaults = GeoShapeQuery.super.hasStandardDefaults();
}
/**
* @return The value of the {@code fieldName} attribute
*/
@JsonProperty("field")
@Override
public String getFieldName() {
return fieldName;
}
/**
* @return The value of the {@code indexedShape} attribute
*/
@JsonProperty("indexed_shape")
@Override
public @Nullable IndexedShape getIndexedShape() {
return indexedShape;
}
/**
* @return The value of the {@code relation} attribute
*/
@JsonProperty("relation")
@Override
public @Nullable ShapeRelation getRelation() {
return relation;
}
/**
* @return The value of the {@code shape} attribute
*/
@JsonProperty("shape")
@Override
public @Nullable Shape getShape() {
return shape;
}
/**
* @return The value of the {@code strategy} attribute
*/
@JsonProperty("strategy")
@Override
public @Nullable SpatialStrategy getStrategy() {
return strategy;
}
/**
* @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 ImmutableGeoShapeQuery} 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 ImmutableGeoShapeQuery
&& equalTo((ImmutableGeoShapeQuery) another);
}
private boolean equalTo(ImmutableGeoShapeQuery another) {
return fieldName.equals(another.fieldName)
&& Objects.equals(indexedShape, another.indexedShape)
&& Objects.equals(relation, another.relation)
&& Objects.equals(shape, another.shape)
&& Objects.equals(strategy, another.strategy)
&& Objects.equals(boost, another.boost)
&& Objects.equals(name, another.name);
}
/**
* Computes a hash code from attributes: {@code fieldName}, {@code indexedShape}, {@code relation}, {@code shape}, {@code strategy}, {@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(indexedShape);
h += (h << 5) + Objects.hashCode(relation);
h += (h << 5) + Objects.hashCode(shape);
h += (h << 5) + Objects.hashCode(strategy);
h += (h << 5) + Objects.hashCode(boost);
h += (h << 5) + Objects.hashCode(name);
return h;
}
/**
* Prints the immutable value {@code GeoShapeQuery} with attribute values.
* @return A string representation of the value
*/
@Override
public String toString() {
return MoreObjects.toStringHelper("GeoShapeQuery")
.omitNullValues()
.add("fieldName", fieldName)
.add("indexedShape", indexedShape)
.add("relation", relation)
.add("shape", shape)
.add("strategy", strategy)
.add("boost", boost)
.add("name", name)
.toString();
}
private static ImmutableGeoShapeQuery validate(ImmutableGeoShapeQuery instance) {
instance.checkShape();
return instance;
}
private Object readResolve() throws ObjectStreamException {
return validate(this);
}
/**
* Creates a builder for {@link ImmutableGeoShapeQuery ImmutableGeoShapeQuery}.
* @return A new ImmutableGeoShapeQuery builder
*/
public static ImmutableGeoShapeQuery.Builder builder() {
return new ImmutableGeoShapeQuery.Builder();
}
/**
* Builds instances of type {@link ImmutableGeoShapeQuery ImmutableGeoShapeQuery}.
* 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 = "GeoShapeQuery", generator = "Immutables")
@NotThreadSafe
@JsonTypeName("geo_shape")
public static final class Builder {
private static final long INIT_BIT_FIELD_NAME = 0x1L;
private long initBits = 0x1L;
private @javax.annotation.Nullable String fieldName;
private @javax.annotation.Nullable IndexedShape indexedShape;
private @javax.annotation.Nullable ShapeRelation relation;
private @javax.annotation.Nullable Shape shape;
private @javax.annotation.Nullable SpatialStrategy strategy;
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.GeoShapeQuery} 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(GeoShapeQuery 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 GeoShapeQuery) {
GeoShapeQuery instance = (GeoShapeQuery) object;
fieldName(instance.getFieldName());
IndexedShape indexedShapeValue = instance.getIndexedShape();
if (indexedShapeValue != null) {
indexedShape(indexedShapeValue);
}
Shape shapeValue = instance.getShape();
if (shapeValue != null) {
shape(shapeValue);
}
SpatialStrategy strategyValue = instance.getStrategy();
if (strategyValue != null) {
strategy(strategyValue);
}
ShapeRelation relationValue = instance.getRelation();
if (relationValue != null) {
relation(relationValue);
}
}
}
/**
* Initializes the value for the {@link GeoShapeQuery#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 GeoShapeQuery#getIndexedShape() indexedShape} attribute.
* @param indexedShape The value for indexedShape (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("indexed_shape")
public final Builder indexedShape(@Nullable IndexedShape indexedShape) {
this.indexedShape = indexedShape;
return this;
}
/**
* Initializes the value for the {@link GeoShapeQuery#getRelation() relation} attribute.
* @param relation The value for relation (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("relation")
public final Builder relation(@Nullable ShapeRelation relation) {
this.relation = relation;
return this;
}
/**
* Initializes the value for the {@link GeoShapeQuery#getShape() shape} attribute.
* @param shape The value for shape (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("shape")
public final Builder shape(@Nullable Shape shape) {
this.shape = shape;
return this;
}
/**
* Initializes the value for the {@link GeoShapeQuery#getStrategy() strategy} attribute.
* @param strategy The value for strategy (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("strategy")
public final Builder strategy(@Nullable SpatialStrategy strategy) {
this.strategy = strategy;
return this;
}
/**
* Initializes the value for the {@link GeoShapeQuery#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 GeoShapeQuery#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 ImmutableGeoShapeQuery ImmutableGeoShapeQuery}.
* @return An immutable instance of GeoShapeQuery
* @throws java.lang.IllegalStateException if any required attributes are missing
*/
public ImmutableGeoShapeQuery build() {
if (initBits != 0) {
throw new IllegalStateException(formatRequiredAttributesMessage());
}
return ImmutableGeoShapeQuery.validate(new ImmutableGeoShapeQuery(this));
}
private String formatRequiredAttributesMessage() {
List attributes = new ArrayList<>();
if ((initBits & INIT_BIT_FIELD_NAME) != 0) attributes.add("fieldName");
return "Cannot build GeoShapeQuery, some of required attributes are not set " + attributes;
}
}
}