Skip to content
Merged
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,11 +36,15 @@

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

import jakarta.json.stream.JsonGenerator;
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.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.util.CopyableBuilder;
Expand All @@ -56,10 +60,14 @@ public class MaxAggregation extends FormatMetricAggregationBase
AggregationVariant,
ToCopyableBuilder<MaxAggregation.Builder, MaxAggregation> {

@Nullable
private final ValueType valueType;

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

private MaxAggregation(Builder builder) {
super(builder);
this.valueType = builder.valueType;
}

public static MaxAggregation of(Function<MaxAggregation.Builder, ObjectBuilder<MaxAggregation>> fn) {
Expand All @@ -74,6 +82,22 @@ public Aggregation.Kind _aggregationKind() {
return Aggregation.Kind.Max;
}

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

protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
super.serializeInternal(generator, mapper);
if (this.valueType != null) {
generator.writeKey("value_type");
this.valueType.serialize(generator, mapper);
}
}

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

@Override
Expand All @@ -93,15 +117,19 @@ public static Builder builder() {
public static class Builder extends FormatMetricAggregationBase.AbstractBuilder<Builder>
implements
CopyableBuilder<Builder, MaxAggregation> {
@Nullable
private ValueType valueType;

public Builder() {}

private Builder(MaxAggregation o) {
super(o);
this.valueType = o.valueType;
}

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

@Override
Expand All @@ -116,6 +144,15 @@ protected Builder self() {
return this;
}

/**
* API name: {@code value_type}
*/
@Nonnull
public final Builder valueType(@Nullable ValueType value) {
this.valueType = value;
return this;
}

/**
* Builds a {@link MaxAggregation}.
*
Expand All @@ -142,11 +179,13 @@ public MaxAggregation build() {

protected static void setupMaxAggregationDeserializer(ObjectDeserializer<MaxAggregation.Builder> op) {
setupFormatMetricAggregationBaseDeserializer(op);
op.add(Builder::valueType, ValueType._DESERIALIZER, "value_type");
}

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

Expand All @@ -157,6 +196,7 @@ public boolean equals(Object o) {
}
if (this == o) return true;
if (o == null || this.getClass() != o.getClass()) return false;
return true;
MaxAggregation other = (MaxAggregation) o;
return Objects.equals(this.valueType, other.valueType);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,38 +37,50 @@
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.JsonpDeserializer;
import org.opensearch.client.json.JsonpMapper;
import org.opensearch.client.json.ObjectDeserializer;
import org.opensearch.client.json.PlainJsonSerializable;
import org.opensearch.client.opensearch._types.FieldValue;
import org.opensearch.client.opensearch._types.Script;
import org.opensearch.client.util.ApiTypeHelper;
import org.opensearch.client.util.ObjectBuilder;
import org.opensearch.client.util.ObjectBuilderBase;

// typedef: _types.aggregations.MetricAggregationBase

@Generated("org.opensearch.client.codegen.CodeGenerator")
public abstract class MetricAggregationBase extends AggregationBase {
public abstract class MetricAggregationBase implements PlainJsonSerializable {

@Nullable
private final String field;

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

@Nullable
private final FieldValue missing;

@Nullable
private final String name;

@Nullable
private final Script script;

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

protected MetricAggregationBase(AbstractBuilder<?> builder) {
super(builder);
this.field = builder.field;
this.meta = ApiTypeHelper.unmodifiable(builder.meta);
this.missing = builder.missing;
this.name = builder.name;
this.script = builder.script;
}

Expand All @@ -80,6 +92,14 @@ public final String field() {
return this.field;
}

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

/**
* API name: {@code missing}
*/
Expand All @@ -88,6 +108,14 @@ public final FieldValue missing() {
return this.missing;
}

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

/**
* API name: {@code script}
*/
Expand All @@ -96,18 +124,42 @@ public final Script script() {
return this.script;
}

/**
* 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 (this.field != null) {
generator.writeKey("field");
generator.write(this.field);
}

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.missing != null) {
generator.writeKey("missing");
this.missing.serialize(generator, mapper);
}

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

if (this.script != null) {
generator.writeKey("script");
this.script.serialize(generator, mapper);
Expand All @@ -116,31 +168,39 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {

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

public abstract static class AbstractBuilder<BuilderT extends AbstractBuilder<BuilderT>> extends AggregationBase.AbstractBuilder<
BuilderT> {
public abstract static class AbstractBuilder<BuilderT extends AbstractBuilder<BuilderT>> extends ObjectBuilderBase {
@Nullable
private String field;
@Nullable
private Map<String, JsonData> meta;
@Nullable
private FieldValue missing;
@Nullable
private String name;
@Nullable
private Script script;

protected AbstractBuilder() {}

protected AbstractBuilder(MetricAggregationBase o) {
super(o);
this.field = o.field;
this.meta = _mapCopy(o.meta);
this.missing = o.missing;
this.name = o.name;
this.script = o.script;
}

protected AbstractBuilder(AbstractBuilder<BuilderT> o) {
super(o);
this.field = o.field;
this.meta = _mapCopy(o.meta);
this.missing = o.missing;
this.name = o.name;
this.script = o.script;
}

@Nonnull
protected abstract BuilderT self();

/**
* API name: {@code field}
*/
Expand All @@ -150,6 +210,32 @@ public final BuilderT field(@Nullable String value) {
return self();
}

/**
* API name: {@code meta}
*
* <p>
* Adds all elements of <code>map</code> to <code>meta</code>.
* </p>
*/
@Nonnull
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>.
* </p>
*/
@Nonnull
public final BuilderT meta(String key, JsonData value) {
this.meta = _mapPut(this.meta, key, value);
return self();
}

/**
* API name: {@code missing}
*/
Expand All @@ -167,6 +253,15 @@ public final BuilderT missing(Function<FieldValue.Builder, ObjectBuilder<FieldVa
return missing(fn.apply(new FieldValue.Builder()).build());
}

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

/**
* API name: {@code script}
*/
Expand All @@ -190,31 +285,33 @@ public final BuilderT script(Function<Script.Builder, ObjectBuilder<Script>> fn)
protected static <BuilderT extends AbstractBuilder<BuilderT>> void setupMetricAggregationBaseDeserializer(
ObjectDeserializer<BuilderT> op
) {
setupAggregationBaseDeserializer(op);
op.add(AbstractBuilder::field, JsonpDeserializer.stringDeserializer(), "field");
op.add(AbstractBuilder::meta, JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), "meta");
op.add(AbstractBuilder::missing, FieldValue._DESERIALIZER, "missing");
op.add(AbstractBuilder::name, JsonpDeserializer.stringDeserializer(), "name");
op.add(AbstractBuilder::script, Script._DESERIALIZER, "script");
}

@Override
public int hashCode() {
int result = super.hashCode();
int result = 17;
result = 31 * result + Objects.hashCode(this.field);
result = 31 * result + Objects.hashCode(this.meta);
result = 31 * result + Objects.hashCode(this.missing);
result = 31 * result + Objects.hashCode(this.name);
result = 31 * result + Objects.hashCode(this.script);
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;
MetricAggregationBase other = (MetricAggregationBase) o;
return Objects.equals(this.field, other.field)
&& Objects.equals(this.meta, other.meta)
&& Objects.equals(this.missing, other.missing)
&& Objects.equals(this.name, other.name)
&& Objects.equals(this.script, other.script);
}
}
Loading
Loading