@@ -46,6 +46,9 @@ public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
46
46
gson .getDelegateAdapter (
47
47
this ,
48
48
TypeToken .get (ReverseEtlSpecificTimeScheduleConfig .class ));
49
+ final TypeAdapter <ReverseEtlCronScheduleConfig > adapterReverseEtlCronScheduleConfig =
50
+ gson .getDelegateAdapter (
51
+ this , TypeToken .get (ReverseEtlCronScheduleConfig .class ));
49
52
50
53
return (TypeAdapter <T >)
51
54
new TypeAdapter <Config >() {
@@ -78,8 +81,19 @@ public void write(JsonWriter out, Config value) throws IOException {
78
81
elementAdapter .write (out , element );
79
82
return ;
80
83
}
84
+ // check if the actual instance is of the type
85
+ // `ReverseEtlCronScheduleConfig`
86
+ if (value .getActualInstance () instanceof ReverseEtlCronScheduleConfig ) {
87
+ JsonElement element =
88
+ adapterReverseEtlCronScheduleConfig .toJsonTree (
89
+ (ReverseEtlCronScheduleConfig )
90
+ value .getActualInstance ());
91
+ elementAdapter .write (out , element );
92
+ return ;
93
+ }
81
94
throw new IOException (
82
95
"Failed to serialize as the type doesn't match anyOf schemae:"
96
+ + " ReverseEtlCronScheduleConfig,"
83
97
+ " ReverseEtlPeriodicScheduleConfig,"
84
98
+ " ReverseEtlSpecificTimeScheduleConfig" );
85
99
}
@@ -137,6 +151,27 @@ public Config read(JsonReader in) throws IOException {
137
151
+ " 'ReverseEtlSpecificTimeScheduleConfig'" ,
138
152
e );
139
153
}
154
+ // deserialize ReverseEtlCronScheduleConfig
155
+ try {
156
+ // validate the JSON object to see if any exception is thrown
157
+ ReverseEtlCronScheduleConfig .validateJsonElement (jsonElement );
158
+ actualAdapter = adapterReverseEtlCronScheduleConfig ;
159
+ Config ret = new Config ();
160
+ ret .setActualInstance (actualAdapter .fromJsonTree (jsonElement ));
161
+ return ret ;
162
+ } catch (Exception e ) {
163
+ // deserialization failed, continue
164
+ errorMessages .add (
165
+ String .format (
166
+ "Deserialization for ReverseEtlCronScheduleConfig"
167
+ + " failed with `%s`." ,
168
+ e .getMessage ()));
169
+ log .log (
170
+ Level .FINER ,
171
+ "Input data does not match schema"
172
+ + " 'ReverseEtlCronScheduleConfig'" ,
173
+ e );
174
+ }
140
175
141
176
throw new IOException (
142
177
String .format (
@@ -156,6 +191,11 @@ public Config() {
156
191
super ("anyOf" , Boolean .TRUE );
157
192
}
158
193
194
+ public Config (ReverseEtlCronScheduleConfig o ) {
195
+ super ("anyOf" , Boolean .TRUE );
196
+ setActualInstance (o );
197
+ }
198
+
159
199
public Config (ReverseEtlPeriodicScheduleConfig o ) {
160
200
super ("anyOf" , Boolean .TRUE );
161
201
setActualInstance (o );
@@ -170,6 +210,7 @@ public Config(ReverseEtlSpecificTimeScheduleConfig o) {
170
210
schemas .put ("ReverseEtlPeriodicScheduleConfig" , ReverseEtlPeriodicScheduleConfig .class );
171
211
schemas .put (
172
212
"ReverseEtlSpecificTimeScheduleConfig" , ReverseEtlSpecificTimeScheduleConfig .class );
213
+ schemas .put ("ReverseEtlCronScheduleConfig" , ReverseEtlCronScheduleConfig .class );
173
214
}
174
215
175
216
@ Override
@@ -179,8 +220,8 @@ public Map<String, Class<?>> getSchemas() {
179
220
180
221
/**
181
222
* Set the instance that matches the anyOf child schema, check the instance parameter is valid
182
- * against the anyOf child schemas: ReverseEtlPeriodicScheduleConfig ,
183
- * ReverseEtlSpecificTimeScheduleConfig
223
+ * against the anyOf child schemas: ReverseEtlCronScheduleConfig ,
224
+ * ReverseEtlPeriodicScheduleConfig, ReverseEtlSpecificTimeScheduleConfig
184
225
*
185
226
* <p>It could be an instance of the 'anyOf' schemas.
186
227
*/
@@ -201,16 +242,21 @@ public void setActualInstance(Object instance) {
201
242
return ;
202
243
}
203
244
245
+ if (instance instanceof ReverseEtlCronScheduleConfig ) {
246
+ super .setActualInstance (instance );
247
+ return ;
248
+ }
249
+
204
250
throw new RuntimeException (
205
- "Invalid instance type. Must be ReverseEtlPeriodicScheduleConfig ,"
206
- + " ReverseEtlSpecificTimeScheduleConfig" );
251
+ "Invalid instance type. Must be ReverseEtlCronScheduleConfig ,"
252
+ + " ReverseEtlPeriodicScheduleConfig, ReverseEtlSpecificTimeScheduleConfig" );
207
253
}
208
254
209
255
/**
210
- * Get the actual instance, which can be the following: ReverseEtlPeriodicScheduleConfig ,
211
- * ReverseEtlSpecificTimeScheduleConfig
256
+ * Get the actual instance, which can be the following: ReverseEtlCronScheduleConfig ,
257
+ * ReverseEtlPeriodicScheduleConfig, ReverseEtlSpecificTimeScheduleConfig
212
258
*
213
- * @return The actual instance (ReverseEtlPeriodicScheduleConfig,
259
+ * @return The actual instance (ReverseEtlCronScheduleConfig, ReverseEtlPeriodicScheduleConfig,
214
260
* ReverseEtlSpecificTimeScheduleConfig)
215
261
*/
216
262
@ Override
@@ -242,6 +288,18 @@ public ReverseEtlSpecificTimeScheduleConfig getReverseEtlSpecificTimeScheduleCon
242
288
return (ReverseEtlSpecificTimeScheduleConfig ) super .getActualInstance ();
243
289
}
244
290
291
+ /**
292
+ * Get the actual instance of `ReverseEtlCronScheduleConfig`. If the actual instance is not
293
+ * `ReverseEtlCronScheduleConfig`, the ClassCastException will be thrown.
294
+ *
295
+ * @return The actual instance of `ReverseEtlCronScheduleConfig`
296
+ * @throws ClassCastException if the instance is not `ReverseEtlCronScheduleConfig`
297
+ */
298
+ public ReverseEtlCronScheduleConfig getReverseEtlCronScheduleConfig ()
299
+ throws ClassCastException {
300
+ return (ReverseEtlCronScheduleConfig ) super .getActualInstance ();
301
+ }
302
+
245
303
/**
246
304
* Validates the JSON Element and throws an exception if issues found
247
305
*
@@ -275,10 +333,21 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti
275
333
e .getMessage ()));
276
334
// continue to the next one
277
335
}
336
+ // validate the json string with ReverseEtlCronScheduleConfig
337
+ try {
338
+ ReverseEtlCronScheduleConfig .validateJsonElement (jsonElement );
339
+ return ;
340
+ } catch (Exception e ) {
341
+ errorMessages .add (
342
+ String .format (
343
+ "Deserialization for ReverseEtlCronScheduleConfig failed with `%s`." ,
344
+ e .getMessage ()));
345
+ // continue to the next one
346
+ }
278
347
throw new IOException (
279
348
String .format (
280
349
"The JSON string is invalid for Config with anyOf schemas:"
281
- + " ReverseEtlPeriodicScheduleConfig,"
350
+ + " ReverseEtlCronScheduleConfig, ReverseEtlPeriodicScheduleConfig,"
282
351
+ " ReverseEtlSpecificTimeScheduleConfig. no class match the result,"
283
352
+ " expected at least 1. Detailed failure message for anyOf schemas:"
284
353
+ " %s. JSON: %s" ,
0 commit comments