Skip to content

Commit

Permalink
fix: add a missing key propery to the RangeBucket (opensearch-project…
Browse files Browse the repository at this point in the history
…#369)

Signed-off-by: Dominik Szczepanczyk <[email protected]>
  • Loading branch information
szczepanczykd committed Feb 20, 2023
1 parent d63a589 commit e60774f
Showing 1 changed file with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@

@JsonpDeserializable
public class RangeBucket extends MultiBucketBase {

@Nullable
private final String key;
@Nullable
private final Double from;

Expand All @@ -68,6 +71,7 @@ public class RangeBucket extends MultiBucketBase {
private RangeBucket(Builder builder) {
super(builder);

this.key = builder.key;
this.from = builder.from;
this.to = builder.to;
this.fromAsString = builder.fromAsString;
Expand All @@ -79,6 +83,14 @@ public static RangeBucket of(Function<Builder, ObjectBuilder<RangeBucket>> fn) {
return fn.apply(new Builder()).build();
}

/**
* API name: {@code key}
*/
@Nullable
public final String key() {
return this.key;
}

/**
* API name: {@code from}
*/
Expand Down Expand Up @@ -114,6 +126,11 @@ public final String toAsString() {
protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {

super.serializeInternal(generator, mapper);
if (this.key != null) {
generator.writeKey("key");
generator.write(this.key);

}
if (this.from != null) {
generator.writeKey("from");
generator.write(this.from);
Expand Down Expand Up @@ -144,6 +161,9 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
*/

public static class Builder extends MultiBucketBase.AbstractBuilder<Builder> implements ObjectBuilder<RangeBucket> {

@Nullable
private String key;
@Nullable
private Double from;

Expand All @@ -156,6 +176,14 @@ public static class Builder extends MultiBucketBase.AbstractBuilder<Builder> imp
@Nullable
private String toAsString;

/**
* API name: {@code key}
*/
public final Builder key(String value) {
this.key = value;
return this;
}

/**
* API name: {@code from}
*/
Expand Down Expand Up @@ -216,6 +244,7 @@ public RangeBucket build() {

protected static void setupRangeBucketDeserializer(ObjectDeserializer<RangeBucket.Builder> op) {
setupMultiBucketBaseDeserializer(op);
op.add(Builder::key, JsonpDeserializer.stringDeserializer(), "key");
op.add(Builder::from, JsonpDeserializer.doubleDeserializer(), "from");
op.add(Builder::to, JsonpDeserializer.doubleDeserializer(), "to");
op.add(Builder::fromAsString, JsonpDeserializer.stringDeserializer(), "from_as_string");
Expand Down

0 comments on commit e60774f

Please sign in to comment.