Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,30 +36,47 @@

package org.opensearch.client.opensearch._types.aggregations;

import jakarta.json.stream.JsonGenerator;
import java.util.Map;
import java.util.Objects;
import java.util.function.Function;
import javax.annotation.Generated;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.opensearch.client.json.JsonData;
import org.opensearch.client.json.JsonpDeserializable;
import org.opensearch.client.json.JsonpDeserializer;
import org.opensearch.client.json.JsonpMapper;
import org.opensearch.client.json.ObjectBuilderDeserializer;
import org.opensearch.client.json.ObjectDeserializer;
import org.opensearch.client.json.PlainJsonSerializable;
import org.opensearch.client.util.ApiTypeHelper;
import org.opensearch.client.util.CopyableBuilder;
import org.opensearch.client.util.ObjectBuilder;
import org.opensearch.client.util.ObjectBuilderBase;
import org.opensearch.client.util.ToCopyableBuilder;

// typedef: _types.aggregations.AdjacencyMatrixAggregate

@JsonpDeserializable
@Generated("org.opensearch.client.codegen.CodeGenerator")
public class AdjacencyMatrixAggregate extends MultiBucketAggregateBase<AdjacencyMatrixBucket>
public class AdjacencyMatrixAggregate
implements
AggregateVariant,
PlainJsonSerializable,
ToCopyableBuilder<AdjacencyMatrixAggregate.Builder, AdjacencyMatrixAggregate> {

@Nonnull
private final Buckets<AdjacencyMatrixBucket> buckets;

@Nonnull
private final Map<String, JsonData> meta;

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

private AdjacencyMatrixAggregate(Builder builder) {
super(builder);
this.buckets = ApiTypeHelper.requireNonNull(builder.buckets, this, "buckets");
this.meta = ApiTypeHelper.unmodifiable(builder.meta);
}

public static AdjacencyMatrixAggregate of(Function<AdjacencyMatrixAggregate.Builder, ObjectBuilder<AdjacencyMatrixAggregate>> fn) {
Expand All @@ -74,6 +91,47 @@ public Aggregate.Kind _aggregateKind() {
return Aggregate.Kind.AdjacencyMatrix;
}

/**
* Required - API name: {@code buckets}
*/
@Nonnull
public final Buckets<AdjacencyMatrixBucket> buckets() {
return this.buckets;
}

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

/**
* 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("buckets");
this.buckets.serialize(generator, 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();
}
}

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

@Override
Expand All @@ -90,18 +148,21 @@ public static Builder builder() {
/**
* Builder for {@link AdjacencyMatrixAggregate}.
*/
public static class Builder extends MultiBucketAggregateBase.AbstractBuilder<AdjacencyMatrixBucket, Builder>
implements
CopyableBuilder<Builder, AdjacencyMatrixAggregate> {
public static class Builder extends ObjectBuilderBase implements CopyableBuilder<Builder, AdjacencyMatrixAggregate> {
private Buckets<AdjacencyMatrixBucket> buckets;
@Nullable
private Map<String, JsonData> meta;

public Builder() {}

private Builder(AdjacencyMatrixAggregate o) {
super(o);
this.buckets = o.buckets;
this.meta = _mapCopy(o.meta);
}

private Builder(Builder o) {
super(o);
this.buckets = o.buckets;
this.meta = _mapCopy(o.meta);
}

@Override
Expand All @@ -110,9 +171,46 @@ public Builder copy() {
return new Builder(this);
}

@Override
/**
* Required - API name: {@code buckets}
*/
@Nonnull
protected Builder self() {
public final Builder buckets(Buckets<AdjacencyMatrixBucket> value) {
this.buckets = value;
return this;
}

/**
* Required - API name: {@code buckets}
*/
@Nonnull
public final Builder buckets(Function<Buckets.Builder<AdjacencyMatrixBucket>, ObjectBuilder<Buckets<AdjacencyMatrixBucket>>> fn) {
return buckets(fn.apply(new Buckets.Builder<AdjacencyMatrixBucket>()).build());
}

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

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

Expand Down Expand Up @@ -141,22 +239,23 @@ public AdjacencyMatrixAggregate build() {
);

protected static void setupAdjacencyMatrixAggregateDeserializer(ObjectDeserializer<AdjacencyMatrixAggregate.Builder> op) {
setupMultiBucketAggregateBaseDeserializer(op, AdjacencyMatrixBucket._DESERIALIZER);
op.add(Builder::buckets, Buckets.createBucketsDeserializer(AdjacencyMatrixBucket._DESERIALIZER), "buckets");
op.add(Builder::meta, JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), "meta");
}

@Override
public int hashCode() {
int result = super.hashCode();
int result = 17;
result = 31 * result + this.buckets.hashCode();
result = 31 * result + Objects.hashCode(this.meta);
return result;
}

@Override
public boolean equals(Object o) {
if (!super.equals(o)) {
return false;
}
if (this == o) return true;
if (o == null || this.getClass() != o.getClass()) return false;
return true;
AdjacencyMatrixAggregate other = (AdjacencyMatrixAggregate) o;
return this.buckets.equals(other.buckets) && Objects.equals(this.meta, other.meta);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,45 +48,38 @@
import org.opensearch.client.json.JsonpMapper;
import org.opensearch.client.json.ObjectBuilderDeserializer;
import org.opensearch.client.json.ObjectDeserializer;
import org.opensearch.client.json.PlainJsonSerializable;
import org.opensearch.client.opensearch._types.query_dsl.Query;
import org.opensearch.client.util.ApiTypeHelper;
import org.opensearch.client.util.CopyableBuilder;
import org.opensearch.client.util.ObjectBuilder;
import org.opensearch.client.util.ObjectBuilderBase;
import org.opensearch.client.util.ToCopyableBuilder;

// typedef: _types.aggregations.AdjacencyMatrixAggregation
// typedef: _types.aggregations.AdjacencyMatrixAggregationFields

@JsonpDeserializable
@Generated("org.opensearch.client.codegen.CodeGenerator")
public class AdjacencyMatrixAggregation extends BucketAggregationBase
public class AdjacencyMatrixAggregationFields
implements
AggregationVariant,
ToCopyableBuilder<AdjacencyMatrixAggregation.Builder, AdjacencyMatrixAggregation> {
PlainJsonSerializable,
ToCopyableBuilder<AdjacencyMatrixAggregationFields.Builder, AdjacencyMatrixAggregationFields> {

@Nonnull
private final Map<String, Query> filters;

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

private AdjacencyMatrixAggregation(Builder builder) {
super(builder);
private AdjacencyMatrixAggregationFields(Builder builder) {
this.filters = ApiTypeHelper.unmodifiable(builder.filters);
}

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

/**
* {@link Aggregation} variant kind.
*/
@Override
public Aggregation.Kind _aggregationKind() {
return Aggregation.Kind.AdjacencyMatrix;
}

/**
* Filters used to create buckets. At least one filter is required.
* <p>
Expand All @@ -98,8 +91,17 @@ public final Map<String, Query> filters() {
return this.filters;
}

/**
* 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) {
super.serializeInternal(generator, mapper);
if (ApiTypeHelper.isDefined(this.filters)) {
generator.writeKey("filters");
generator.writeStartObject();
Expand All @@ -125,23 +127,19 @@ public static Builder builder() {
}

/**
* Builder for {@link AdjacencyMatrixAggregation}.
* Builder for {@link AdjacencyMatrixAggregationFields}.
*/
public static class Builder extends BucketAggregationBase.AbstractBuilder<Builder>
implements
CopyableBuilder<Builder, AdjacencyMatrixAggregation> {
public static class Builder extends ObjectBuilderBase implements CopyableBuilder<Builder, AdjacencyMatrixAggregationFields> {
@Nullable
private Map<String, Query> filters;

public Builder() {}

private Builder(AdjacencyMatrixAggregation o) {
super(o);
private Builder(AdjacencyMatrixAggregationFields o) {
this.filters = _mapCopy(o.filters);
}

private Builder(Builder o) {
super(o);
this.filters = _mapCopy(o.filters);
}

Expand All @@ -151,12 +149,6 @@ public Builder copy() {
return new Builder(this);
}

@Override
@Nonnull
protected Builder self() {
return this;
}

/**
* Filters used to create buckets. At least one filter is required.
* <p>
Expand Down Expand Up @@ -205,49 +197,47 @@ public final Builder filters(String key, Function<Query.Builder, ObjectBuilder<Q
}

/**
* Builds a {@link AdjacencyMatrixAggregation}.
* Builds a {@link AdjacencyMatrixAggregationFields}.
*
* @throws NullPointerException if some of the required fields are null.
*/
@Override
@Nonnull
public AdjacencyMatrixAggregation build() {
public AdjacencyMatrixAggregationFields build() {
_checkSingleUse();

return new AdjacencyMatrixAggregation(this);
return new AdjacencyMatrixAggregationFields(this);
}
}

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

/**
* Json deserializer for {@link AdjacencyMatrixAggregation}
* Json deserializer for {@link AdjacencyMatrixAggregationFields}
*/
public static final JsonpDeserializer<AdjacencyMatrixAggregation> _DESERIALIZER = ObjectBuilderDeserializer.lazy(
public static final JsonpDeserializer<AdjacencyMatrixAggregationFields> _DESERIALIZER = ObjectBuilderDeserializer.lazy(
Builder::new,
AdjacencyMatrixAggregation::setupAdjacencyMatrixAggregationDeserializer
AdjacencyMatrixAggregationFields::setupAdjacencyMatrixAggregationFieldsDeserializer
);

protected static void setupAdjacencyMatrixAggregationDeserializer(ObjectDeserializer<AdjacencyMatrixAggregation.Builder> op) {
setupBucketAggregationBaseDeserializer(op);
protected static void setupAdjacencyMatrixAggregationFieldsDeserializer(
ObjectDeserializer<AdjacencyMatrixAggregationFields.Builder> op
) {
op.add(Builder::filters, JsonpDeserializer.stringMapDeserializer(Query._DESERIALIZER), "filters");
}

@Override
public int hashCode() {
int result = super.hashCode();
int result = 17;
result = 31 * result + Objects.hashCode(this.filters);
return result;
}

@Override
public boolean equals(Object o) {
if (!super.equals(o)) {
return false;
}
if (this == o) return true;
if (o == null || this.getClass() != o.getClass()) return false;
AdjacencyMatrixAggregation other = (AdjacencyMatrixAggregation) o;
AdjacencyMatrixAggregationFields other = (AdjacencyMatrixAggregationFields) o;
return Objects.equals(this.filters, other.filters);
}
}
Loading
Loading