From 2e852663eb37627b53f971108438ad465ad4a98f Mon Sep 17 00:00:00 2001 From: Urs Keller Date: Thu, 18 Jan 2024 19:52:45 +0100 Subject: [PATCH] Add wrapper to builder (#806) Signed-off-by: Urs Keller Co-authored-by: Urs Keller --- CHANGELOG.md | 1 + .../opensearch/_types/query_dsl/Query.java | 27 +++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 57e5f1d4a6..9d4aa6e87f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Expose HTTP status code through `ResponseException#status` ([#756](https://github.com/opensearch-project/opensearch-java/pull/756)) - Added toBuilder method to all request model in core package & _types.query_dsl package ([#766](https://github.com/opensearch-project/opensearch-java/pull/766)) - Added toQuery method in Query and QueryVariant ([#760](https://github.com/opensearch-project/opensearch-java/pull/760) +- Added missing WrapperQuery accessors and builder methods ([#806](https://github.com/opensearch-project/opensearch-java/pull/806)) ### Dependencies - Bumps `com.diffplug.spotless` from 6.22.0 to 6.24.0 diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/Query.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/Query.java index 0890341a86..6167d02d3d 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/Query.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/Query.java @@ -1153,6 +1153,23 @@ public WildcardQuery wildcard() { return TaggedUnionUtils.get(this, Kind.Wildcard); } + /** + * Is this variant instance of kind {@code wrapper}? + */ + public boolean isWrapper() { + return this._kind == Query.Kind.Wrapper; + } + + /** + * Get the {@code wrapper} variant value. + * + * @throws IllegalStateException + * if the current variant is not of the {@code wrapper} kind. + */ + public WrapperQuery wrapper() { + return (WrapperQuery) TaggedUnionUtils.get(this, Query.Kind.Wrapper); + } + /** * Is this variant instance of kind {@code type}? */ @@ -1743,6 +1760,16 @@ public ObjectBuilder wildcard(Function wrapper(WrapperQuery v) { + this._kind = Query.Kind.Wrapper; + this._value = v; + return this; + } + + public ObjectBuilder wrapper(Function> fn) { + return this.wrapper(fn.apply(new WrapperQuery.Builder()).build()); + } + public ObjectBuilder type(TypeQuery v) { this._kind = Kind.Type; this._value = v;