Skip to content

Commit 31a742a

Browse files
committed
[codegen] Add lambda expression methods to builder objects
1 parent 0074c80 commit 31a742a

File tree

130 files changed

+5414
-743
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

130 files changed

+5414
-743
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Licensed to Elasticsearch B.V. under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch B.V. licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package co.elastic.clients.elasticsearch._types;
21+
22+
/**
23+
* Base interface for responses that are acknowledged by the server
24+
*/
25+
public interface AcknowledgedResponse {
26+
boolean acknowledged();
27+
}

java-client/src/main/java/co/elastic/clients/elasticsearch/_types/AcknowledgedResponseBase.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
* specification</a>
4545
*/
4646

47-
public abstract class AcknowledgedResponseBase implements JsonpSerializable {
47+
public abstract class AcknowledgedResponseBase implements AcknowledgedResponse, JsonpSerializable {
4848
private final boolean acknowledged;
4949

5050
// ---------------------------------------------------------------------------------------------

java-client/src/main/java/co/elastic/clients/elasticsearch/_types/ErrorCause.java

+1-4
Original file line numberDiff line numberDiff line change
@@ -394,10 +394,7 @@ protected static void setupErrorCauseDeserializer(ObjectDeserializer<ErrorCause.
394394
op.add(Builder::suppressed, JsonpDeserializer.arrayDeserializer(ErrorCause._DESERIALIZER), "suppressed");
395395

396396
op.setUnknownFieldHandler((builder, name, parser, mapper) -> {
397-
if (builder.metadata == null) {
398-
builder.metadata = new HashMap<>();
399-
}
400-
builder.metadata.put(name, JsonData._DESERIALIZER.deserialize(parser, mapper));
397+
builder.metadata(name, JsonData._DESERIALIZER.deserialize(parser, mapper));
401398
});
402399
op.shortcutProperty("reason");
403400

java-client/src/main/java/co/elastic/clients/elasticsearch/_types/GeoBoundsBuilders.java

+3
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323

2424
package co.elastic.clients.elasticsearch._types;
2525

26+
import co.elastic.clients.util.ObjectBuilder;
27+
import java.util.function.Function;
28+
2629
/**
2730
* Builders for {@link GeoBounds} variants.
2831
*/

java-client/src/main/java/co/elastic/clients/elasticsearch/_types/GeoHashPrecisionBuilders.java

+3
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323

2424
package co.elastic.clients.elasticsearch._types;
2525

26+
import co.elastic.clients.util.ObjectBuilder;
27+
import java.util.function.Function;
28+
2629
/**
2730
* Builders for {@link GeoHashPrecision} variants.
2831
* <p>

java-client/src/main/java/co/elastic/clients/elasticsearch/_types/GeoLocationBuilders.java

+2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@
2323

2424
package co.elastic.clients.elasticsearch._types;
2525

26+
import co.elastic.clients.util.ObjectBuilder;
2627
import java.lang.Double;
28+
import java.util.function.Function;
2729

2830
/**
2931
* Builders for {@link GeoLocation} variants.

java-client/src/main/java/co/elastic/clients/elasticsearch/_types/InlineGet.java

+1-4
Original file line numberDiff line numberDiff line change
@@ -368,10 +368,7 @@ protected static <TDocument> void setupInlineGetDeserializer(ObjectDeserializer<
368368
op.add(Builder::source, tDocumentDeserializer, "_source");
369369

370370
op.setUnknownFieldHandler((builder, name, parser, mapper) -> {
371-
if (builder.metadata == null) {
372-
builder.metadata = new HashMap<>();
373-
}
374-
builder.metadata.put(name, JsonData._DESERIALIZER.deserialize(parser, mapper));
371+
builder.metadata(name, JsonData._DESERIALIZER.deserialize(parser, mapper));
375372
});
376373

377374
}

java-client/src/main/java/co/elastic/clients/elasticsearch/_types/ScriptBuilders.java

+3
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323

2424
package co.elastic.clients.elasticsearch._types;
2525

26+
import co.elastic.clients.util.ObjectBuilder;
27+
import java.util.function.Function;
28+
2629
/**
2730
* Builders for {@link Script} variants.
2831
*/

java-client/src/main/java/co/elastic/clients/elasticsearch/_types/SortOptionsBuilders.java

+53
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323

2424
package co.elastic.clients.elasticsearch._types;
2525

26+
import co.elastic.clients.util.ObjectBuilder;
27+
import java.util.function.Function;
28+
2629
/**
2730
* Builders for {@link SortOptions} variants.
2831
*/
@@ -38,13 +41,33 @@ public static ScoreSort.Builder score() {
3841
return new ScoreSort.Builder();
3942
}
4043

44+
/**
45+
* Creates a SortOptions of the {@link ScoreSort _score} {@code SortOptions}
46+
* variant.
47+
*/
48+
public static SortOptions score(Function<ScoreSort.Builder, ObjectBuilder<ScoreSort>> fn) {
49+
SortOptions.Builder builder = new SortOptions.Builder();
50+
builder.score(fn.apply(new ScoreSort.Builder()).build());
51+
return builder.build();
52+
}
53+
4154
/**
4255
* Creates a builder for the {@link ScoreSort _doc} {@code SortOptions} variant.
4356
*/
4457
public static ScoreSort.Builder doc() {
4558
return new ScoreSort.Builder();
4659
}
4760

61+
/**
62+
* Creates a SortOptions of the {@link ScoreSort _doc} {@code SortOptions}
63+
* variant.
64+
*/
65+
public static SortOptions doc(Function<ScoreSort.Builder, ObjectBuilder<ScoreSort>> fn) {
66+
SortOptions.Builder builder = new SortOptions.Builder();
67+
builder.doc(fn.apply(new ScoreSort.Builder()).build());
68+
return builder.build();
69+
}
70+
4871
/**
4972
* Creates a builder for the {@link GeoDistanceSort _geo_distance}
5073
* {@code SortOptions} variant.
@@ -53,6 +76,16 @@ public static GeoDistanceSort.Builder geoDistance() {
5376
return new GeoDistanceSort.Builder();
5477
}
5578

79+
/**
80+
* Creates a SortOptions of the {@link GeoDistanceSort _geo_distance}
81+
* {@code SortOptions} variant.
82+
*/
83+
public static SortOptions geoDistance(Function<GeoDistanceSort.Builder, ObjectBuilder<GeoDistanceSort>> fn) {
84+
SortOptions.Builder builder = new SortOptions.Builder();
85+
builder.geoDistance(fn.apply(new GeoDistanceSort.Builder()).build());
86+
return builder.build();
87+
}
88+
5689
/**
5790
* Creates a builder for the {@link ScriptSort _script} {@code SortOptions}
5891
* variant.
@@ -61,6 +94,16 @@ public static ScriptSort.Builder script() {
6194
return new ScriptSort.Builder();
6295
}
6396

97+
/**
98+
* Creates a SortOptions of the {@link ScriptSort _script} {@code SortOptions}
99+
* variant.
100+
*/
101+
public static SortOptions script(Function<ScriptSort.Builder, ObjectBuilder<ScriptSort>> fn) {
102+
SortOptions.Builder builder = new SortOptions.Builder();
103+
builder.script(fn.apply(new ScriptSort.Builder()).build());
104+
return builder.build();
105+
}
106+
64107
/**
65108
* Creates a builder for the {@link FieldSort field} {@code SortOptions}
66109
* variant.
@@ -69,4 +112,14 @@ public static FieldSort.Builder field() {
69112
return new FieldSort.Builder();
70113
}
71114

115+
/**
116+
* Creates a SortOptions of the {@link FieldSort field} {@code SortOptions}
117+
* variant.
118+
*/
119+
public static SortOptions field(Function<FieldSort.Builder, ObjectBuilder<FieldSort>> fn) {
120+
SortOptions.Builder builder = new SortOptions.Builder();
121+
builder.field(fn.apply(new FieldSort.Builder()).build());
122+
return builder.build();
123+
}
124+
72125
}

java-client/src/main/java/co/elastic/clients/elasticsearch/_types/TimeBuilders.java

+3
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323

2424
package co.elastic.clients.elasticsearch._types;
2525

26+
import co.elastic.clients.util.ObjectBuilder;
27+
import java.util.function.Function;
28+
2629
/**
2730
* Builders for {@link Time} variants.
2831
* <p>

java-client/src/main/java/co/elastic/clients/elasticsearch/_types/TransformBuilders.java

+23
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323

2424
package co.elastic.clients.elasticsearch._types;
2525

26+
import co.elastic.clients.util.ObjectBuilder;
27+
import java.util.function.Function;
28+
2629
/**
2730
* Builders for {@link Transform} variants.
2831
* <p>
@@ -42,6 +45,16 @@ public static ScriptTransform.Builder script() {
4245
return new ScriptTransform.Builder();
4346
}
4447

48+
/**
49+
* Creates a Transform of the {@link ScriptTransform script} {@code Transform}
50+
* variant.
51+
*/
52+
public static Transform script(Function<ScriptTransform.Builder, ObjectBuilder<ScriptTransform>> fn) {
53+
Transform.Builder builder = new Transform.Builder();
54+
builder.script(fn.apply(new ScriptTransform.Builder()).build());
55+
return builder.build();
56+
}
57+
4558
/**
4659
* Creates a builder for the {@link SearchTransform search} {@code Transform}
4760
* variant.
@@ -50,4 +63,14 @@ public static SearchTransform.Builder search() {
5063
return new SearchTransform.Builder();
5164
}
5265

66+
/**
67+
* Creates a Transform of the {@link SearchTransform search} {@code Transform}
68+
* variant.
69+
*/
70+
public static Transform search(Function<SearchTransform.Builder, ObjectBuilder<SearchTransform>> fn) {
71+
Transform.Builder builder = new Transform.Builder();
72+
builder.search(fn.apply(new SearchTransform.Builder()).build());
73+
return builder.build();
74+
}
75+
5376
}

java-client/src/main/java/co/elastic/clients/elasticsearch/_types/WaitForActiveShardsBuilders.java

+3
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323

2424
package co.elastic.clients.elasticsearch._types;
2525

26+
import co.elastic.clients.util.ObjectBuilder;
27+
import java.util.function.Function;
28+
2629
/**
2730
* Builders for {@link WaitForActiveShards} variants.
2831
* <p>

0 commit comments

Comments
 (0)