Skip to content

Commit

Permalink
Generate GeoBounds
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Farr <[email protected]>
  • Loading branch information
Xtansia committed Oct 2, 2024
1 parent ff2d6c5 commit b85fd19
Show file tree
Hide file tree
Showing 9 changed files with 266 additions and 141 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,15 @@
* GitHub history for details.
*/

//----------------------------------------------------
// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST.
//----------------------------------------------------

package org.opensearch.client.opensearch._types;

import jakarta.json.stream.JsonGenerator;
import java.util.function.Function;
import javax.annotation.Generated;
import org.opensearch.client.json.JsonpDeserializable;
import org.opensearch.client.json.JsonpDeserializer;
import org.opensearch.client.json.JsonpMapper;
Expand All @@ -47,37 +52,30 @@
// typedef: _types.CoordsGeoBounds

@JsonpDeserializable
@Generated("org.opensearch.client.codegen.CodeGenerator")
public class CoordsGeoBounds implements PlainJsonSerializable {
private final double top;

private final double bottom;

private final double left;

private final double right;

private final double top;

// ---------------------------------------------------------------------------------------------

private CoordsGeoBounds(Builder builder) {

this.top = ApiTypeHelper.requireNonNull(builder.top, this, "top");
this.bottom = ApiTypeHelper.requireNonNull(builder.bottom, this, "bottom");
this.left = ApiTypeHelper.requireNonNull(builder.left, this, "left");
this.right = ApiTypeHelper.requireNonNull(builder.right, this, "right");

this.top = ApiTypeHelper.requireNonNull(builder.top, this, "top");
}

public static CoordsGeoBounds of(Function<Builder, ObjectBuilder<CoordsGeoBounds>> fn) {
public static CoordsGeoBounds of(Function<CoordsGeoBounds.Builder, ObjectBuilder<CoordsGeoBounds>> fn) {
return fn.apply(new Builder()).build();
}

/**
* Required - API name: {@code top}
*/
public final double top() {
return this.top;
}

/**
* Required - API name: {@code bottom}
*/
Expand All @@ -99,20 +97,24 @@ public final double right() {
return this.right;
}

/**
* Required - API name: {@code top}
*/
public final double top() {
return this.top;
}

/**
* Serialize this object to JSON.
*/
@Override
public void serialize(JsonGenerator generator, JsonpMapper mapper) {
generator.writeStartObject();
serializeInternal(generator, mapper);
generator.writeEnd();
}

protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {

generator.writeKey("top");
generator.write(this.top);

generator.writeKey("bottom");
generator.write(this.bottom);

Expand All @@ -122,30 +124,20 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
generator.writeKey("right");
generator.write(this.right);

generator.writeKey("top");
generator.write(this.top);
}

// ---------------------------------------------------------------------------------------------

/**
* Builder for {@link CoordsGeoBounds}.
*/

public static class Builder extends ObjectBuilderBase implements ObjectBuilder<CoordsGeoBounds> {
private Double top;

private Double bottom;

private Double left;

private Double right;

/**
* Required - API name: {@code top}
*/
public final Builder top(double value) {
this.top = value;
return this;
}
private Double top;

/**
* Required - API name: {@code bottom}
Expand All @@ -171,11 +163,18 @@ public final Builder right(double value) {
return this;
}

/**
* Required - API name: {@code top}
*/
public final Builder top(double value) {
this.top = value;
return this;
}

/**
* Builds a {@link CoordsGeoBounds}.
*
* @throws NullPointerException
* if some of the required fields are null.
* @throws NullPointerException if some of the required fields are null.
*/
public CoordsGeoBounds build() {
_checkSingleUse();
Expand All @@ -195,12 +194,25 @@ public CoordsGeoBounds build() {
);

protected static void setupCoordsGeoBoundsDeserializer(ObjectDeserializer<CoordsGeoBounds.Builder> op) {

op.add(Builder::top, JsonpDeserializer.doubleDeserializer(), "top");
op.add(Builder::bottom, JsonpDeserializer.doubleDeserializer(), "bottom");
op.add(Builder::left, JsonpDeserializer.doubleDeserializer(), "left");
op.add(Builder::right, JsonpDeserializer.doubleDeserializer(), "right");
op.add(Builder::top, JsonpDeserializer.doubleDeserializer(), "top");
}

public int hashCode() {
int result = 17;
result = 31 * result + Double.hashCode(this.bottom);
result = 31 * result + Double.hashCode(this.left);
result = 31 * result + Double.hashCode(this.right);
result = 31 * result + Double.hashCode(this.top);
return result;
}

public boolean equals(Object o) {
if (this == o) return true;
if (o == null || this.getClass() != o.getClass()) return false;
CoordsGeoBounds other = (CoordsGeoBounds) o;
return this.bottom == other.bottom && this.left == other.left && this.right == other.right && this.top == other.top;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,21 @@
* GitHub history for details.
*/

//----------------------------------------------------
// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST.
//----------------------------------------------------

package org.opensearch.client.opensearch._types;

import jakarta.json.stream.JsonGenerator;
import java.util.Objects;
import java.util.function.Function;
import javax.annotation.Generated;
import org.opensearch.client.json.JsonpDeserializable;
import org.opensearch.client.json.JsonpDeserializer;
import org.opensearch.client.json.JsonpMapper;
import org.opensearch.client.json.JsonpSerializable;
import org.opensearch.client.json.PlainJsonSerializable;
import org.opensearch.client.json.UnionDeserializer;
import org.opensearch.client.util.ApiTypeHelper;
import org.opensearch.client.util.ObjectBuilder;
Expand All @@ -48,24 +55,27 @@
// typedef: _types.GeoBounds

/**
* <p>
* A geo bounding box. It can be represented in various ways:
* </p>
* <ul>
* <li>as 4 top/bottom/left/right coordinates</li>
* <li>as 2 top_left / bottom_right points</li>
* <li>as 2 top_right / bottom_left points</li>
* <li>as a WKT bounding box</li>
* <li>as a WKT bounding box.</li>
* </ul>
*
*/
@JsonpDeserializable
public class GeoBounds implements TaggedUnion<GeoBounds.Kind, Object>, JsonpSerializable {

@Generated("org.opensearch.client.codegen.CodeGenerator")
public class GeoBounds implements TaggedUnion<GeoBounds.Kind, Object>, PlainJsonSerializable {
/**
* {@link GeoBounds} variant kinds.
*/
public enum Kind {
Coords,
Tlbr,
Trbl,
Wkt

}

private final Kind _kind;
Expand All @@ -87,13 +97,11 @@ private GeoBounds(Kind kind, Object value) {
}

private GeoBounds(Builder builder) {

this._kind = ApiTypeHelper.requireNonNull(builder._kind, builder, "<variant kind>");
this._value = ApiTypeHelper.requireNonNull(builder._value, builder, "<variant value>");

}

public static GeoBounds of(Function<Builder, ObjectBuilder<GeoBounds>> fn) {
public static GeoBounds of(Function<GeoBounds.Builder, ObjectBuilder<GeoBounds>> fn) {
return fn.apply(new Builder()).build();
}

Expand All @@ -107,8 +115,7 @@ public boolean isCoords() {
/**
* Get the {@code coords} variant value.
*
* @throws IllegalStateException
* if the current variant is not of the {@code coords} kind.
* @throws IllegalStateException if the current variant is not the {@code coords} kind.
*/
public CoordsGeoBounds coords() {
return TaggedUnionUtils.get(this, Kind.Coords);
Expand All @@ -124,8 +131,7 @@ public boolean isTlbr() {
/**
* Get the {@code tlbr} variant value.
*
* @throws IllegalStateException
* if the current variant is not of the {@code tlbr} kind.
* @throws IllegalStateException if the current variant is not the {@code tlbr} kind.
*/
public TopLeftBottomRightGeoBounds tlbr() {
return TaggedUnionUtils.get(this, Kind.Tlbr);
Expand All @@ -141,8 +147,7 @@ public boolean isTrbl() {
/**
* Get the {@code trbl} variant value.
*
* @throws IllegalStateException
* if the current variant is not of the {@code trbl} kind.
* @throws IllegalStateException if the current variant is not the {@code trbl} kind.
*/
public TopRightBottomLeftGeoBounds trbl() {
return TaggedUnionUtils.get(this, Kind.Trbl);
Expand All @@ -158,8 +163,7 @@ public boolean isWkt() {
/**
* Get the {@code wkt} variant value.
*
* @throws IllegalStateException
* if the current variant is not of the {@code wkt} kind.
* @throws IllegalStateException if the current variant is not the {@code wkt} kind.
*/
public WktGeoBounds wkt() {
return TaggedUnionUtils.get(this, Kind.Wkt);
Expand All @@ -170,7 +174,6 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) {
if (_value instanceof JsonpSerializable) {
((JsonpSerializable) _value).serialize(generator, mapper);
}

}

public static class Builder extends ObjectBuilderBase implements ObjectBuilder<GeoBounds> {
Expand Down Expand Up @@ -217,11 +220,11 @@ public ObjectBuilder<GeoBounds> wkt(Function<WktGeoBounds.Builder, ObjectBuilder
return this.wkt(fn.apply(new WktGeoBounds.Builder()).build());
}

@Override
public GeoBounds build() {
_checkSingleUse();
return new GeoBounds(this);
}

}

private static JsonpDeserializer<GeoBounds> buildGeoBoundsDeserializer() {
Expand All @@ -236,4 +239,18 @@ private static JsonpDeserializer<GeoBounds> buildGeoBoundsDeserializer() {
}

public static final JsonpDeserializer<GeoBounds> _DESERIALIZER = JsonpDeserializer.lazy(GeoBounds::buildGeoBoundsDeserializer);

public int hashCode() {
int result = 17;
result = 31 * result + Objects.hashCode(this._kind);
result = 31 * result + Objects.hashCode(this._value);
return result;
}

public boolean equals(Object o) {
if (this == o) return true;
if (o == null || this.getClass() != o.getClass()) return false;
GeoBounds other = (GeoBounds) o;
return Objects.equals(this._kind, other._kind) && Objects.equals(this._value, other._value);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,33 +30,37 @@
* GitHub history for details.
*/

//----------------------------------------------------
// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST.
//----------------------------------------------------

package org.opensearch.client.opensearch._types;

import javax.annotation.Generated;

/**
* Builders for {@link GeoBounds} variants.
*/
@Generated("org.opensearch.client.codegen.CodeGenerator")
public class GeoBoundsBuilders {
private GeoBoundsBuilders() {}

/**
* Creates a builder for the {@link CoordsGeoBounds coords} {@code GeoBounds}
* variant.
* Creates a builder for the {@link CoordsGeoBounds coords} {@code GeoBounds} variant.
*/
public static CoordsGeoBounds.Builder coords() {
return new CoordsGeoBounds.Builder();
}

/**
* Creates a builder for the {@link TopLeftBottomRightGeoBounds tlbr}
* {@code GeoBounds} variant.
* Creates a builder for the {@link TopLeftBottomRightGeoBounds tlbr} {@code GeoBounds} variant.
*/
public static TopLeftBottomRightGeoBounds.Builder tlbr() {
return new TopLeftBottomRightGeoBounds.Builder();
}

/**
* Creates a builder for the {@link TopRightBottomLeftGeoBounds trbl}
* {@code GeoBounds} variant.
* Creates a builder for the {@link TopRightBottomLeftGeoBounds trbl} {@code GeoBounds} variant.
*/
public static TopRightBottomLeftGeoBounds.Builder trbl() {
return new TopRightBottomLeftGeoBounds.Builder();
Expand All @@ -68,5 +72,4 @@ public static TopRightBottomLeftGeoBounds.Builder trbl() {
public static WktGeoBounds.Builder wkt() {
return new WktGeoBounds.Builder();
}

}
Loading

0 comments on commit b85fd19

Please sign in to comment.