All Downloads are FREE. Search and download functionalities are using the official Maven repository.

co.elastic.clients.elasticsearch.graph.ExploreResponse Maven / Gradle / Ivy

There is a newer version: 8.17.0
Show newest version
/*
 * 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.graph;

import co.elastic.clients.elasticsearch._types.ShardFailure;
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.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.Long;
import java.util.List;
import java.util.Objects;
import java.util.function.Function;
import javax.annotation.Nullable;

// typedef: graph.explore.Response

/**
 *
 * @see API
 *      specification
 */
@JsonpDeserializable
public class ExploreResponse implements JsonpSerializable {
	private final List connections;

	private final List failures;

	private final boolean timedOut;

	private final long took;

	private final List vertices;

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

	private ExploreResponse(Builder builder) {

		this.connections = ApiTypeHelper.unmodifiableRequired(builder.connections, this, "connections");
		this.failures = ApiTypeHelper.unmodifiableRequired(builder.failures, this, "failures");
		this.timedOut = ApiTypeHelper.requireNonNull(builder.timedOut, this, "timedOut");
		this.took = ApiTypeHelper.requireNonNull(builder.took, this, "took");
		this.vertices = ApiTypeHelper.unmodifiableRequired(builder.vertices, this, "vertices");

	}

	public static ExploreResponse of(Function> fn) {
		return fn.apply(new Builder()).build();
	}

	/**
	 * Required - API name: {@code connections}
	 */
	public final List connections() {
		return this.connections;
	}

	/**
	 * Required - API name: {@code failures}
	 */
	public final List failures() {
		return this.failures;
	}

	/**
	 * Required - API name: {@code timed_out}
	 */
	public final boolean timedOut() {
		return this.timedOut;
	}

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

	/**
	 * Required - API name: {@code vertices}
	 */
	public final List vertices() {
		return this.vertices;
	}

	/**
	 * 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.connections)) {
			generator.writeKey("connections");
			generator.writeStartArray();
			for (Connection item0 : this.connections) {
				item0.serialize(generator, mapper);

			}
			generator.writeEnd();

		}
		if (ApiTypeHelper.isDefined(this.failures)) {
			generator.writeKey("failures");
			generator.writeStartArray();
			for (ShardFailure item0 : this.failures) {
				item0.serialize(generator, mapper);

			}
			generator.writeEnd();

		}
		generator.writeKey("timed_out");
		generator.write(this.timedOut);

		generator.writeKey("took");
		generator.write(this.took);

		if (ApiTypeHelper.isDefined(this.vertices)) {
			generator.writeKey("vertices");
			generator.writeStartArray();
			for (Vertex item0 : this.vertices) {
				item0.serialize(generator, mapper);

			}
			generator.writeEnd();

		}

	}

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

	/**
	 * Builder for {@link ExploreResponse}.
	 */

	public static class Builder extends WithJsonObjectBuilderBase implements ObjectBuilder {
		private List connections;

		private List failures;

		private Boolean timedOut;

		private Long took;

		private List vertices;

		/**
		 * Required - API name: {@code connections}
		 * 

* Adds all elements of list to connections. */ public final Builder connections(List list) { this.connections = _listAddAll(this.connections, list); return this; } /** * Required - API name: {@code connections} *

* Adds one or more values to connections. */ public final Builder connections(Connection value, Connection... values) { this.connections = _listAdd(this.connections, value, values); return this; } /** * Required - API name: {@code connections} *

* Adds a value to connections using a builder lambda. */ public final Builder connections(Function> fn) { return connections(fn.apply(new Connection.Builder()).build()); } /** * Required - API name: {@code failures} *

* Adds all elements of list to failures. */ public final Builder failures(List list) { this.failures = _listAddAll(this.failures, list); return this; } /** * Required - API name: {@code failures} *

* Adds one or more values to failures. */ public final Builder failures(ShardFailure value, ShardFailure... values) { this.failures = _listAdd(this.failures, value, values); return this; } /** * Required - API name: {@code failures} *

* Adds a value to failures using a builder lambda. */ public final Builder failures(Function> fn) { return failures(fn.apply(new ShardFailure.Builder()).build()); } /** * Required - API name: {@code timed_out} */ public final Builder timedOut(boolean value) { this.timedOut = value; return this; } /** * Required - API name: {@code took} */ public final Builder took(long value) { this.took = value; return this; } /** * Required - API name: {@code vertices} *

* Adds all elements of list to vertices. */ public final Builder vertices(List list) { this.vertices = _listAddAll(this.vertices, list); return this; } /** * Required - API name: {@code vertices} *

* Adds one or more values to vertices. */ public final Builder vertices(Vertex value, Vertex... values) { this.vertices = _listAdd(this.vertices, value, values); return this; } /** * Required - API name: {@code vertices} *

* Adds a value to vertices using a builder lambda. */ public final Builder vertices(Function> fn) { return vertices(fn.apply(new Vertex.Builder()).build()); } @Override protected Builder self() { return this; } /** * Builds a {@link ExploreResponse}. * * @throws NullPointerException * if some of the required fields are null. */ public ExploreResponse build() { _checkSingleUse(); return new ExploreResponse(this); } } // --------------------------------------------------------------------------------------------- /** * Json deserializer for {@link ExploreResponse} */ public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, ExploreResponse::setupExploreResponseDeserializer); protected static void setupExploreResponseDeserializer(ObjectDeserializer op) { op.add(Builder::connections, JsonpDeserializer.arrayDeserializer(Connection._DESERIALIZER), "connections"); op.add(Builder::failures, JsonpDeserializer.arrayDeserializer(ShardFailure._DESERIALIZER), "failures"); op.add(Builder::timedOut, JsonpDeserializer.booleanDeserializer(), "timed_out"); op.add(Builder::took, JsonpDeserializer.longDeserializer(), "took"); op.add(Builder::vertices, JsonpDeserializer.arrayDeserializer(Vertex._DESERIALIZER), "vertices"); } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy