Skip to content

Commit

Permalink
fixes from api-spec pr 2485 (#776)
Browse files Browse the repository at this point in the history
  • Loading branch information
l-trotta authored Apr 5, 2024
1 parent 5f277ee commit 4eb0276
Show file tree
Hide file tree
Showing 59 changed files with 2,076 additions and 1,027 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ public abstract class WriteResponseBase implements JsonpSerializable {

private final String index;

private final long primaryTerm;
@Nullable
private final Long primaryTerm;

private final Result result;

Expand All @@ -84,7 +85,7 @@ protected WriteResponseBase(AbstractBuilder<?> builder) {

this.id = ApiTypeHelper.requireNonNull(builder.id, this, "id");
this.index = ApiTypeHelper.requireNonNull(builder.index, this, "index");
this.primaryTerm = ApiTypeHelper.requireNonNull(builder.primaryTerm, this, "primaryTerm");
this.primaryTerm = builder.primaryTerm;
this.result = ApiTypeHelper.requireNonNull(builder.result, this, "result");
this.seqNo = ApiTypeHelper.requireNonNull(builder.seqNo, this, "seqNo");
this.shards = ApiTypeHelper.requireNonNull(builder.shards, this, "shards");
Expand All @@ -108,9 +109,10 @@ public final String index() {
}

/**
* Required - API name: {@code _primary_term}
* API name: {@code _primary_term}
*/
public final long primaryTerm() {
@Nullable
public final Long primaryTerm() {
return this.primaryTerm;
}

Expand Down Expand Up @@ -167,9 +169,11 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
generator.writeKey("_index");
generator.write(this.index);

generator.writeKey("_primary_term");
generator.write(this.primaryTerm);
if (this.primaryTerm != null) {
generator.writeKey("_primary_term");
generator.write(this.primaryTerm);

}
generator.writeKey("result");
this.result.serialize(generator, mapper);
generator.writeKey("_seq_no");
Expand Down Expand Up @@ -201,6 +205,7 @@ public abstract static class AbstractBuilder<BuilderT extends AbstractBuilder<Bu

private String index;

@Nullable
private Long primaryTerm;

private Result result;
Expand Down Expand Up @@ -231,9 +236,9 @@ public final BuilderT index(String value) {
}

/**
* Required - API name: {@code _primary_term}
* API name: {@code _primary_term}
*/
public final BuilderT primaryTerm(long value) {
public final BuilderT primaryTerm(@Nullable Long value) {
this.primaryTerm = value;
return self();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import co.elastic.clients.json.JsonpDeserializable;
import co.elastic.clients.json.JsonpDeserializer;
import co.elastic.clients.json.JsonpMapper;
import co.elastic.clients.json.JsonpSerializable;
import co.elastic.clients.json.JsonpUtils;
import co.elastic.clients.json.ObjectBuilderDeserializer;
import co.elastic.clients.json.ObjectDeserializer;
import co.elastic.clients.util.ApiTypeHelper;
Expand Down Expand Up @@ -58,13 +60,12 @@
* specification</a>
*/
@JsonpDeserializable
public class AdjacencyMatrixAggregation extends BucketAggregationBase implements AggregationVariant {
public class AdjacencyMatrixAggregation extends BucketAggregationBase implements AggregationVariant, JsonpSerializable {
private final Map<String, Query> filters;

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

private AdjacencyMatrixAggregation(Builder builder) {
super(builder);

this.filters = ApiTypeHelper.unmodifiable(builder.filters);

Expand All @@ -91,9 +92,17 @@ public final Map<String, Query> filters() {
return this.filters;
}

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

protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {

super.serializeInternal(generator, mapper);
if (ApiTypeHelper.isDefined(this.filters)) {
generator.writeKey("filters");
generator.writeStartObject();
Expand All @@ -108,6 +117,11 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {

}

@Override
public String toString() {
return JsonpUtils.toString(this);
}

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

/**
Expand Down Expand Up @@ -183,7 +197,7 @@ public AdjacencyMatrixAggregation build() {

protected static void setupAdjacencyMatrixAggregationDeserializer(
ObjectDeserializer<AdjacencyMatrixAggregation.Builder> op) {
BucketAggregationBase.setupBucketAggregationBaseDeserializer(op);

op.add(Builder::filters, JsonpDeserializer.stringMapDeserializer(Query._DESERIALIZER), "filters");

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,14 @@

package co.elastic.clients.elasticsearch._types.aggregations;

import co.elastic.clients.json.JsonData;
import co.elastic.clients.json.JsonpDeserializable;
import co.elastic.clients.json.JsonpDeserializer;
import co.elastic.clients.json.JsonpMapper;
import co.elastic.clients.json.JsonpSerializable;
import co.elastic.clients.json.JsonpUtils;
import co.elastic.clients.json.ObjectBuilderDeserializer;
import co.elastic.clients.json.ObjectDeserializer;
import co.elastic.clients.util.ApiTypeHelper;
import co.elastic.clients.util.ObjectBuilder;
import co.elastic.clients.util.WithJsonObjectBuilderBase;
import jakarta.json.stream.JsonGenerator;
import java.lang.String;
import java.util.Map;
import java.util.Objects;
import javax.annotation.Nullable;

//----------------------------------------------------------------
// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST.
Expand All @@ -60,119 +52,15 @@
* specification</a>
*/

public abstract class AggregationBase implements JsonpSerializable {
private final Map<String, JsonData> meta;

@Nullable
private final String name;

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

protected AggregationBase(AbstractBuilder<?> builder) {

this.meta = ApiTypeHelper.unmodifiable(builder.meta);
this.name = builder.name;

}

/**
* API name: {@code meta}
*/
public final Map<String, JsonData> meta() {
return this.meta;
}

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

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

protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {

if (ApiTypeHelper.isDefined(this.meta)) {
generator.writeKey("meta");
generator.writeStartObject();
for (Map.Entry<String, JsonData> item0 : this.meta.entrySet()) {
generator.writeKey(item0.getKey());
item0.getValue().serialize(generator, mapper);

}
generator.writeEnd();

}
if (this.name != null) {
generator.writeKey("name");
generator.write(this.name);

}

}

@Override
public String toString() {
return JsonpUtils.toString(this);
public abstract class AggregationBase {
public AggregationBase() {
}

public abstract static class AbstractBuilder<BuilderT extends AbstractBuilder<BuilderT>>
extends
WithJsonObjectBuilderBase<BuilderT> {
@Nullable
private Map<String, JsonData> meta;

@Nullable
private String name;

/**
* API name: {@code meta}
* <p>
* Adds all entries of <code>map</code> to <code>meta</code>.
*/
public final BuilderT meta(Map<String, JsonData> map) {
this.meta = _mapPutAll(this.meta, map);
return self();
}

/**
* API name: {@code meta}
* <p>
* Adds an entry to <code>meta</code>.
*/
public final BuilderT meta(String key, JsonData value) {
this.meta = _mapPut(this.meta, key, value);
return self();
}

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

protected abstract BuilderT self();

}

// ---------------------------------------------------------------------------------------------
protected static <BuilderT extends AbstractBuilder<BuilderT>> void setupAggregationBaseDeserializer(
ObjectDeserializer<BuilderT> op) {

op.add(AbstractBuilder::meta, JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), "meta");
op.add(AbstractBuilder::name, JsonpDeserializer.stringDeserializer(), "name");

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import co.elastic.clients.json.JsonpDeserializable;
import co.elastic.clients.json.JsonpDeserializer;
import co.elastic.clients.json.JsonpMapper;
import co.elastic.clients.json.JsonpSerializable;
import co.elastic.clients.json.JsonpUtils;
import co.elastic.clients.json.ObjectBuilderDeserializer;
import co.elastic.clients.json.ObjectDeserializer;
import co.elastic.clients.util.ApiTypeHelper;
Expand Down Expand Up @@ -61,7 +63,10 @@
* specification</a>
*/
@JsonpDeserializable
public class AutoDateHistogramAggregation extends BucketAggregationBase implements AggregationVariant {
public class AutoDateHistogramAggregation extends BucketAggregationBase
implements
AggregationVariant,
JsonpSerializable {
@Nullable
private final Integer buckets;

Expand Down Expand Up @@ -91,7 +96,6 @@ public class AutoDateHistogramAggregation extends BucketAggregationBase implemen
// ---------------------------------------------------------------------------------------------

private AutoDateHistogramAggregation(Builder builder) {
super(builder);

this.buckets = builder.buckets;
this.field = builder.field;
Expand Down Expand Up @@ -207,9 +211,17 @@ public final String timeZone() {
return this.timeZone;
}

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

protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {

super.serializeInternal(generator, mapper);
if (this.buckets != null) {
generator.writeKey("buckets");
generator.write(this.buckets);
Expand Down Expand Up @@ -262,6 +274,11 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {

}

@Override
public String toString() {
return JsonpUtils.toString(this);
}

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

/**
Expand Down Expand Up @@ -436,7 +453,7 @@ public AutoDateHistogramAggregation build() {

protected static void setupAutoDateHistogramAggregationDeserializer(
ObjectDeserializer<AutoDateHistogramAggregation.Builder> op) {
BucketAggregationBase.setupBucketAggregationBaseDeserializer(op);

op.add(Builder::buckets, JsonpDeserializer.integerDeserializer(), "buckets");
op.add(Builder::field, JsonpDeserializer.stringDeserializer(), "field");
op.add(Builder::format, JsonpDeserializer.stringDeserializer(), "format");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,22 +55,13 @@
*/

public abstract class BucketAggregationBase extends AggregationBase {
// ---------------------------------------------------------------------------------------------

protected BucketAggregationBase(AbstractBuilder<?> builder) {
super(builder);

public BucketAggregationBase() {
}

public abstract static class AbstractBuilder<BuilderT extends AbstractBuilder<BuilderT>>
extends
AggregationBase.AbstractBuilder<BuilderT> {
}

// ---------------------------------------------------------------------------------------------
protected static <BuilderT extends AbstractBuilder<BuilderT>> void setupBucketAggregationBaseDeserializer(
ObjectDeserializer<BuilderT> op) {
AggregationBase.setupAggregationBaseDeserializer(op);
protected abstract BuilderT self();

}

Expand Down
Loading

0 comments on commit 4eb0276

Please sign in to comment.