25
25
26
26
import co .elastic .clients .json .JsonpDeserializable ;
27
27
import co .elastic .clients .json .JsonpDeserializer ;
28
+ import co .elastic .clients .json .JsonpMapper ;
28
29
import co .elastic .clients .json .ObjectBuilderDeserializer ;
29
30
import co .elastic .clients .json .ObjectDeserializer ;
31
+ import co .elastic .clients .util .ApiTypeHelper ;
30
32
import co .elastic .clients .util .ObjectBuilder ;
31
33
import jakarta .json .stream .JsonGenerator ;
34
+ import java .util .List ;
32
35
import java .util .Objects ;
33
36
import java .util .function .Function ;
37
+ import javax .annotation .Nullable ;
34
38
35
39
// typedef: _types.aggregations.TopMetricsAggregate
36
40
41
45
* specification</a>
42
46
*/
43
47
@ JsonpDeserializable
44
- public class TopMetricsAggregate extends MultiBucketAggregateBase <TopMetricsBucket > implements AggregateVariant {
48
+ public class TopMetricsAggregate extends AggregateBase implements AggregateVariant {
49
+ private final List <TopMetrics > top ;
50
+
45
51
// ---------------------------------------------------------------------------------------------
46
52
47
53
private TopMetricsAggregate (Builder builder ) {
48
54
super (builder );
49
55
56
+ this .top = ApiTypeHelper .unmodifiableRequired (builder .top , this , "top" );
57
+
50
58
}
51
59
52
60
public static TopMetricsAggregate of (Function <Builder , ObjectBuilder <TopMetricsAggregate >> fn ) {
@@ -61,15 +69,69 @@ public Aggregate.Kind _aggregateKind() {
61
69
return Aggregate .Kind .TopMetrics ;
62
70
}
63
71
72
+ /**
73
+ * Required - API name: {@code top}
74
+ */
75
+ public final List <TopMetrics > top () {
76
+ return this .top ;
77
+ }
78
+
79
+ protected void serializeInternal (JsonGenerator generator , JsonpMapper mapper ) {
80
+
81
+ super .serializeInternal (generator , mapper );
82
+ if (ApiTypeHelper .isDefined (this .top )) {
83
+ generator .writeKey ("top" );
84
+ generator .writeStartArray ();
85
+ for (TopMetrics item0 : this .top ) {
86
+ item0 .serialize (generator , mapper );
87
+
88
+ }
89
+ generator .writeEnd ();
90
+
91
+ }
92
+
93
+ }
94
+
64
95
// ---------------------------------------------------------------------------------------------
65
96
66
97
/**
67
98
* Builder for {@link TopMetricsAggregate}.
68
99
*/
69
100
70
- public static class Builder extends MultiBucketAggregateBase .AbstractBuilder <TopMetricsBucket , Builder >
101
+ public static class Builder extends AggregateBase .AbstractBuilder <Builder >
71
102
implements
72
103
ObjectBuilder <TopMetricsAggregate > {
104
+ private List <TopMetrics > top ;
105
+
106
+ /**
107
+ * Required - API name: {@code top}
108
+ * <p>
109
+ * Adds all elements of <code>list</code> to <code>top</code>.
110
+ */
111
+ public final Builder top (List <TopMetrics > list ) {
112
+ this .top = _listAddAll (this .top , list );
113
+ return this ;
114
+ }
115
+
116
+ /**
117
+ * Required - API name: {@code top}
118
+ * <p>
119
+ * Adds one or more values to <code>top</code>.
120
+ */
121
+ public final Builder top (TopMetrics value , TopMetrics ... values ) {
122
+ this .top = _listAdd (this .top , value , values );
123
+ return this ;
124
+ }
125
+
126
+ /**
127
+ * Required - API name: {@code top}
128
+ * <p>
129
+ * Adds a value to <code>top</code> using a builder lambda.
130
+ */
131
+ public final Builder top (Function <TopMetrics .Builder , ObjectBuilder <TopMetrics >> fn ) {
132
+ return top (fn .apply (new TopMetrics .Builder ()).build ());
133
+ }
134
+
73
135
@ Override
74
136
protected Builder self () {
75
137
return this ;
@@ -83,7 +145,6 @@ protected Builder self() {
83
145
*/
84
146
public TopMetricsAggregate build () {
85
147
_checkSingleUse ();
86
- super .tBucketSerializer (null );
87
148
88
149
return new TopMetricsAggregate (this );
89
150
}
@@ -98,7 +159,8 @@ public TopMetricsAggregate build() {
98
159
.lazy (Builder ::new , TopMetricsAggregate ::setupTopMetricsAggregateDeserializer );
99
160
100
161
protected static void setupTopMetricsAggregateDeserializer (ObjectDeserializer <TopMetricsAggregate .Builder > op ) {
101
- MultiBucketAggregateBase .setupMultiBucketAggregateBaseDeserializer (op , TopMetricsBucket ._DESERIALIZER );
162
+ AggregateBase .setupAggregateBaseDeserializer (op );
163
+ op .add (Builder ::top , JsonpDeserializer .arrayDeserializer (TopMetrics ._DESERIALIZER ), "top" );
102
164
103
165
}
104
166
0 commit comments