21
21
// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST.
22
22
//----------------------------------------------------
23
23
24
- package co .elastic .clients .elasticsearch .indices . rollover ;
24
+ package co .elastic .clients .elasticsearch ._types ;
25
25
26
- import co .elastic .clients .elasticsearch ._types .mapping .TypeMapping ;
27
26
import co .elastic .clients .json .JsonpDeserializable ;
28
27
import co .elastic .clients .json .JsonpDeserializer ;
29
28
import co .elastic .clients .json .JsonpMapper ;
36
35
import co .elastic .clients .util .TaggedUnion ;
37
36
import co .elastic .clients .util .TaggedUnionUtils ;
38
37
import jakarta .json .stream .JsonGenerator ;
38
+ import java .lang .Long ;
39
39
import java .lang .Object ;
40
40
import java .lang .String ;
41
- import java .util .Map ;
42
41
import java .util .Objects ;
43
42
import java .util .function .Function ;
44
43
import javax .annotation .Nullable ;
45
44
46
- // typedef: indices.rollover.IndexRolloverMapping
45
+ // typedef: _types.DateOrEpochMillis
47
46
48
47
/**
49
48
*
50
- * @see <a href=
51
- * "../../doc-files/api-spec.html#indices.rollover.IndexRolloverMapping">API
49
+ * @see <a href="../doc-files/api-spec.html#_types.DateOrEpochMillis">API
52
50
* specification</a>
53
51
*/
54
52
@ JsonpDeserializable
55
- public class IndexRolloverMapping implements TaggedUnion <IndexRolloverMapping .Kind , Object >, JsonpSerializable {
53
+ public class DateOrEpochMillis implements TaggedUnion <DateOrEpochMillis .Kind , Object >, JsonpSerializable {
56
54
57
55
public enum Kind {
58
- ByType , Single
56
+ Date , Millis
59
57
60
58
}
61
59
@@ -72,54 +70,66 @@ public final Object _get() {
72
70
return _value ;
73
71
}
74
72
75
- private IndexRolloverMapping (Kind kind , Object value ) {
73
+ private DateOrEpochMillis (Kind kind , Object value ) {
76
74
this ._kind = kind ;
77
75
this ._value = value ;
78
76
}
79
77
80
- private IndexRolloverMapping (Builder builder ) {
78
+ public String _toJsonString () {
79
+ switch (_kind ) {
80
+ case Date :
81
+ return this .date ();
82
+ case Millis :
83
+ return String .valueOf (this .millis ());
84
+
85
+ default :
86
+ throw new IllegalStateException ("Unknown kind " + _kind );
87
+ }
88
+ }
89
+
90
+ private DateOrEpochMillis (Builder builder ) {
81
91
82
92
this ._kind = ApiTypeHelper .requireNonNull (builder ._kind , builder , "<variant kind>" );
83
93
this ._value = ApiTypeHelper .requireNonNull (builder ._value , builder , "<variant value>" );
84
94
85
95
}
86
96
87
- public static IndexRolloverMapping of (Function <Builder , ObjectBuilder <IndexRolloverMapping >> fn ) {
97
+ public static DateOrEpochMillis of (Function <Builder , ObjectBuilder <DateOrEpochMillis >> fn ) {
88
98
return fn .apply (new Builder ()).build ();
89
99
}
90
100
91
101
/**
92
- * Is this variant instance of kind {@code by_type }?
102
+ * Is this variant instance of kind {@code date }?
93
103
*/
94
- public boolean isByType () {
95
- return _kind == Kind .ByType ;
104
+ public boolean isDate () {
105
+ return _kind == Kind .Date ;
96
106
}
97
107
98
108
/**
99
- * Get the {@code by_type } variant value.
109
+ * Get the {@code date } variant value.
100
110
*
101
111
* @throws IllegalStateException
102
- * if the current variant is not of the {@code by_type } kind.
112
+ * if the current variant is not of the {@code date } kind.
103
113
*/
104
- public Map < String , TypeMapping > byType () {
105
- return TaggedUnionUtils .get (this , Kind .ByType );
114
+ public String date () {
115
+ return TaggedUnionUtils .get (this , Kind .Date );
106
116
}
107
117
108
118
/**
109
- * Is this variant instance of kind {@code single }?
119
+ * Is this variant instance of kind {@code millis }?
110
120
*/
111
- public boolean isSingle () {
112
- return _kind == Kind .Single ;
121
+ public boolean isMillis () {
122
+ return _kind == Kind .Millis ;
113
123
}
114
124
115
125
/**
116
- * Get the {@code single } variant value.
126
+ * Get the {@code millis } variant value.
117
127
*
118
128
* @throws IllegalStateException
119
- * if the current variant is not of the {@code single } kind.
129
+ * if the current variant is not of the {@code millis } kind.
120
130
*/
121
- public TypeMapping single () {
122
- return TaggedUnionUtils .get (this , Kind .Single );
131
+ public Long millis () {
132
+ return TaggedUnionUtils .get (this , Kind .Millis );
123
133
}
124
134
125
135
@ Override
@@ -128,55 +138,48 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) {
128
138
((JsonpSerializable ) _value ).serialize (generator , mapper );
129
139
} else {
130
140
switch (_kind ) {
131
- case ByType :
132
- generator .writeStartObject ();
133
- for (Map .Entry <String , TypeMapping > item0 : ((Map <String , TypeMapping >) this ._value ).entrySet ()) {
134
- generator .writeKey (item0 .getKey ());
135
- item0 .getValue ().serialize (generator , mapper );
141
+ case Date :
142
+ generator .write (((String ) this ._value ));
136
143
137
- }
138
- generator .writeEnd ();
144
+ break ;
145
+ case Millis :
146
+ generator .write (((Long ) this ._value ));
139
147
140
148
break ;
141
149
}
142
150
}
143
151
144
152
}
145
153
146
- public static class Builder extends ObjectBuilderBase implements ObjectBuilder <IndexRolloverMapping > {
154
+ public static class Builder extends ObjectBuilderBase implements ObjectBuilder <DateOrEpochMillis > {
147
155
private Kind _kind ;
148
156
private Object _value ;
149
157
150
- public ObjectBuilder <IndexRolloverMapping > byType ( Map < String , TypeMapping > v ) {
151
- this ._kind = Kind .ByType ;
158
+ public ObjectBuilder <DateOrEpochMillis > date ( String v ) {
159
+ this ._kind = Kind .Date ;
152
160
this ._value = v ;
153
161
return this ;
154
162
}
155
163
156
- public ObjectBuilder <IndexRolloverMapping > single ( TypeMapping v ) {
157
- this ._kind = Kind .Single ;
164
+ public ObjectBuilder <DateOrEpochMillis > millis ( Long v ) {
165
+ this ._kind = Kind .Millis ;
158
166
this ._value = v ;
159
167
return this ;
160
168
}
161
169
162
- public ObjectBuilder <IndexRolloverMapping > single (
163
- Function <TypeMapping .Builder , ObjectBuilder <TypeMapping >> fn ) {
164
- return this .single (fn .apply (new TypeMapping .Builder ()).build ());
165
- }
166
-
167
- public IndexRolloverMapping build () {
170
+ public DateOrEpochMillis build () {
168
171
_checkSingleUse ();
169
- return new IndexRolloverMapping (this );
172
+ return new DateOrEpochMillis (this );
170
173
}
171
174
172
175
}
173
176
174
- private static JsonpDeserializer <IndexRolloverMapping > buildIndexRolloverMappingDeserializer () {
175
- return new UnionDeserializer .Builder <IndexRolloverMapping , Kind , Object >(IndexRolloverMapping ::new , false )
176
- .addMember (Kind .ByType , JsonpDeserializer .stringMapDeserializer ( TypeMapping . _DESERIALIZER ))
177
- .addMember (Kind .Single , TypeMapping . _DESERIALIZER ).build ();
177
+ private static JsonpDeserializer <DateOrEpochMillis > buildDateOrEpochMillisDeserializer () {
178
+ return new UnionDeserializer .Builder <DateOrEpochMillis , Kind , Object >(DateOrEpochMillis ::new , false )
179
+ .addMember (Kind .Date , JsonpDeserializer .stringDeserializer ( ))
180
+ .addMember (Kind .Millis , JsonpDeserializer . longDeserializer () ).build ();
178
181
}
179
182
180
- public static final JsonpDeserializer <IndexRolloverMapping > _DESERIALIZER = JsonpDeserializer
181
- .lazy (IndexRolloverMapping :: buildIndexRolloverMappingDeserializer );
183
+ public static final JsonpDeserializer <DateOrEpochMillis > _DESERIALIZER = JsonpDeserializer
184
+ .lazy (DateOrEpochMillis :: buildDateOrEpochMillisDeserializer );
182
185
}
0 commit comments