co.elastic.clients.elasticsearch.core.ExplainResponse Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of elasticsearch-java Show documentation
Show all versions of elasticsearch-java Show documentation
Elasticsearch Java API Client
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
//----------------------------------------------------
// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST.
//----------------------------------------------------
package co.elastic.clients.elasticsearch.core;
import co.elastic.clients.elasticsearch._types.InlineGet;
import co.elastic.clients.elasticsearch.core.explain.ExplanationDetail;
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.JsonpSerializer;
import co.elastic.clients.json.NamedDeserializer;
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.Boolean;
import java.lang.String;
import java.util.Objects;
import java.util.function.Function;
import java.util.function.Supplier;
import javax.annotation.Nullable;
// typedef: _global.explain.Response
/**
*
* @see API
* specification
*/
@JsonpDeserializable
public class ExplainResponse implements JsonpSerializable {
private final String index;
private final String id;
private final boolean matched;
@Nullable
private final ExplanationDetail explanation;
@Nullable
private final InlineGet get;
@Nullable
private final JsonpSerializer tDocumentSerializer;
// ---------------------------------------------------------------------------------------------
private ExplainResponse(Builder builder) {
this.index = ApiTypeHelper.requireNonNull(builder.index, this, "index");
this.id = ApiTypeHelper.requireNonNull(builder.id, this, "id");
this.matched = ApiTypeHelper.requireNonNull(builder.matched, this, "matched");
this.explanation = builder.explanation;
this.get = builder.get;
this.tDocumentSerializer = builder.tDocumentSerializer;
}
public static ExplainResponse of(
Function, ObjectBuilder>> fn) {
return fn.apply(new Builder<>()).build();
}
/**
* Required - API name: {@code _index}
*/
public final String index() {
return this.index;
}
/**
* Required - API name: {@code _id}
*/
public final String id() {
return this.id;
}
/**
* Required - API name: {@code matched}
*/
public final boolean matched() {
return this.matched;
}
/**
* API name: {@code explanation}
*/
@Nullable
public final ExplanationDetail explanation() {
return this.explanation;
}
/**
* API name: {@code get}
*/
@Nullable
public final InlineGet get() {
return this.get;
}
/**
* 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) {
generator.writeKey("_index");
generator.write(this.index);
generator.writeKey("_id");
generator.write(this.id);
generator.writeKey("matched");
generator.write(this.matched);
if (this.explanation != null) {
generator.writeKey("explanation");
this.explanation.serialize(generator, mapper);
}
if (this.get != null) {
generator.writeKey("get");
this.get.serialize(generator, mapper);
}
}
// ---------------------------------------------------------------------------------------------
/**
* Builder for {@link ExplainResponse}.
*/
public static class Builder extends WithJsonObjectBuilderBase>
implements
ObjectBuilder> {
private String index;
private String id;
private Boolean matched;
@Nullable
private ExplanationDetail explanation;
@Nullable
private InlineGet get;
@Nullable
private JsonpSerializer tDocumentSerializer;
/**
* Required - API name: {@code _index}
*/
public final Builder index(String value) {
this.index = value;
return this;
}
/**
* Required - API name: {@code _id}
*/
public final Builder id(String value) {
this.id = value;
return this;
}
/**
* Required - API name: {@code matched}
*/
public final Builder matched(boolean value) {
this.matched = value;
return this;
}
/**
* API name: {@code explanation}
*/
public final Builder explanation(@Nullable ExplanationDetail value) {
this.explanation = value;
return this;
}
/**
* API name: {@code explanation}
*/
public final Builder explanation(
Function> fn) {
return this.explanation(fn.apply(new ExplanationDetail.Builder()).build());
}
/**
* API name: {@code get}
*/
public final Builder get(@Nullable InlineGet value) {
this.get = value;
return this;
}
/**
* API name: {@code get}
*/
public final Builder get(
Function, ObjectBuilder>> fn) {
return this.get(fn.apply(new InlineGet.Builder()).build());
}
/**
* Serializer for TDocument. If not set, an attempt will be made to find a
* serializer from the JSON context.
*/
public final Builder tDocumentSerializer(@Nullable JsonpSerializer value) {
this.tDocumentSerializer = value;
return this;
}
@Override
protected Builder self() {
return this;
}
/**
* Builds a {@link ExplainResponse}.
*
* @throws NullPointerException
* if some of the required fields are null.
*/
public ExplainResponse build() {
_checkSingleUse();
return new ExplainResponse(this);
}
}
// ---------------------------------------------------------------------------------------------
/**
* Create a JSON deserializer for ExplainResponse
*/
public static JsonpDeserializer> createExplainResponseDeserializer(
JsonpDeserializer tDocumentDeserializer) {
return ObjectBuilderDeserializer.createForObject((Supplier>) Builder::new,
op -> ExplainResponse.setupExplainResponseDeserializer(op, tDocumentDeserializer));
};
/**
* Json deserializer for {@link ExplainResponse} based on named deserializers
* provided by the calling {@code JsonMapper}.
*/
public static final JsonpDeserializer> _DESERIALIZER = JsonpDeserializer
.lazy(() -> createExplainResponseDeserializer(
new NamedDeserializer<>("co.elastic.clients:Deserializer:_global.explain.TDocument")));
protected static void setupExplainResponseDeserializer(
ObjectDeserializer> op,
JsonpDeserializer tDocumentDeserializer) {
op.add(Builder::index, JsonpDeserializer.stringDeserializer(), "_index");
op.add(Builder::id, JsonpDeserializer.stringDeserializer(), "_id");
op.add(Builder::matched, JsonpDeserializer.booleanDeserializer(), "matched");
op.add(Builder::explanation, ExplanationDetail._DESERIALIZER, "explanation");
op.add(Builder::get, InlineGet.createInlineGetDeserializer(tDocumentDeserializer), "get");
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy