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

co.elastic.clients.elasticsearch.eql.HitsSequence 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.eql;

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.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.util.List;
import java.util.Objects;
import java.util.function.Function;
import java.util.function.Supplier;
import javax.annotation.Nullable;

// typedef: eql._types.HitsSequence

/**
 *
 * @see API
 *      specification
 */
@JsonpDeserializable
public class HitsSequence implements JsonpSerializable {
	private final List> events;

	private final List joinKeys;

	@Nullable
	private final JsonpSerializer tEventSerializer;

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

	private HitsSequence(Builder builder) {

		this.events = ApiTypeHelper.unmodifiableRequired(builder.events, this, "events");
		this.joinKeys = ApiTypeHelper.unmodifiableRequired(builder.joinKeys, this, "joinKeys");
		this.tEventSerializer = builder.tEventSerializer;

	}

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

	/**
	 * Required - Contains events matching the query. Each object represents a
	 * matching event.
	 * 

* API name: {@code events} */ public final List> events() { return this.events; } /** * Required - Shared field values used to constrain matches in the sequence. * These are defined using the by keyword in the EQL query syntax. *

* API name: {@code join_keys} */ public final List joinKeys() { return this.joinKeys; } /** * 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.events)) { generator.writeKey("events"); generator.writeStartArray(); for (HitsEvent item0 : this.events) { item0.serialize(generator, mapper); } generator.writeEnd(); } if (ApiTypeHelper.isDefined(this.joinKeys)) { generator.writeKey("join_keys"); generator.writeStartArray(); for (JsonData item0 : this.joinKeys) { item0.serialize(generator, mapper); } generator.writeEnd(); } } // --------------------------------------------------------------------------------------------- /** * Builder for {@link HitsSequence}. */ public static class Builder extends WithJsonObjectBuilderBase> implements ObjectBuilder> { private List> events; private List joinKeys; @Nullable private JsonpSerializer tEventSerializer; /** * Required - Contains events matching the query. Each object represents a * matching event. *

* API name: {@code events} *

* Adds all elements of list to events. */ public final Builder events(List> list) { this.events = _listAddAll(this.events, list); return this; } /** * Required - Contains events matching the query. Each object represents a * matching event. *

* API name: {@code events} *

* Adds one or more values to events. */ public final Builder events(HitsEvent value, HitsEvent... values) { this.events = _listAdd(this.events, value, values); return this; } /** * Required - Contains events matching the query. Each object represents a * matching event. *

* API name: {@code events} *

* Adds a value to events using a builder lambda. */ public final Builder events(Function, ObjectBuilder>> fn) { return events(fn.apply(new HitsEvent.Builder()).build()); } /** * Required - Shared field values used to constrain matches in the sequence. * These are defined using the by keyword in the EQL query syntax. *

* API name: {@code join_keys} *

* Adds all elements of list to joinKeys. */ public final Builder joinKeys(List list) { this.joinKeys = _listAddAll(this.joinKeys, list); return this; } /** * Required - Shared field values used to constrain matches in the sequence. * These are defined using the by keyword in the EQL query syntax. *

* API name: {@code join_keys} *

* Adds one or more values to joinKeys. */ public final Builder joinKeys(JsonData value, JsonData... values) { this.joinKeys = _listAdd(this.joinKeys, value, values); return this; } /** * Serializer for TEvent. If not set, an attempt will be made to find a * serializer from the JSON context. */ public final Builder tEventSerializer(@Nullable JsonpSerializer value) { this.tEventSerializer = value; return this; } @Override protected Builder self() { return this; } /** * Builds a {@link HitsSequence}. * * @throws NullPointerException * if some of the required fields are null. */ public HitsSequence build() { _checkSingleUse(); return new HitsSequence(this); } } // --------------------------------------------------------------------------------------------- /** * Create a JSON deserializer for HitsSequence */ public static JsonpDeserializer> createHitsSequenceDeserializer( JsonpDeserializer tEventDeserializer) { return ObjectBuilderDeserializer.createForObject((Supplier>) Builder::new, op -> HitsSequence.setupHitsSequenceDeserializer(op, tEventDeserializer)); }; /** * Json deserializer for {@link HitsSequence} based on named deserializers * provided by the calling {@code JsonMapper}. */ public static final JsonpDeserializer> _DESERIALIZER = JsonpDeserializer .lazy(() -> createHitsSequenceDeserializer( new NamedDeserializer<>("co.elastic.clients:Deserializer:eql._types.TEvent"))); protected static void setupHitsSequenceDeserializer(ObjectDeserializer> op, JsonpDeserializer tEventDeserializer) { op.add(Builder::events, JsonpDeserializer.arrayDeserializer(HitsEvent.createHitsEventDeserializer(tEventDeserializer)), "events"); op.add(Builder::joinKeys, JsonpDeserializer.arrayDeserializer(JsonData._DESERIALIZER), "join_keys"); } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy