@@ -123,7 +123,7 @@ public void write(JsonWriter out, MultiChannelAction value) throws IOException {
123123 elementAdapter .write (out , element );
124124 return ;
125125 }
126- throw new IOException ("Failed to serialize as the type doesn't match oneOf schemas: MultiChannelActionCalendarEvent, RbmActionBase, RbmActionDial, RbmActionOpenUrl, RbmActionViewLocation" );
126+ throw new IOException ("Failed to serialize as the type doesn't match anyOf schemas: MultiChannelActionCalendarEvent, RbmActionBase, RbmActionDial, RbmActionOpenUrl, RbmActionViewLocation" );
127127 }
128128
129129 @ Override
@@ -178,8 +178,9 @@ public MultiChannelAction read(JsonReader in) throws IOException {
178178 // validate the JSON object to see if any exception is thrown
179179 RbmActionBase .validateJsonElement (jsonElement );
180180 actualAdapter = adapterRbmActionBase ;
181- match ++;
182- log .log (Level .FINER , "Input data matches schema 'RbmActionBase'" );
181+ MultiChannelAction ret = new MultiChannelAction ();
182+ ret .setActualInstance (actualAdapter .fromJsonTree (jsonElement ));
183+ return ret ;
183184 } catch (Exception e ) {
184185 // deserialization failed, continue
185186 errorMessages .add (String .format (Locale .ROOT , "Deserialization for RbmActionBase failed with `%s`." , e .getMessage ()));
@@ -190,8 +191,9 @@ public MultiChannelAction read(JsonReader in) throws IOException {
190191 // validate the JSON object to see if any exception is thrown
191192 RbmActionDial .validateJsonElement (jsonElement );
192193 actualAdapter = adapterRbmActionDial ;
193- match ++;
194- log .log (Level .FINER , "Input data matches schema 'RbmActionDial'" );
194+ MultiChannelAction ret = new MultiChannelAction ();
195+ ret .setActualInstance (actualAdapter .fromJsonTree (jsonElement ));
196+ return ret ;
195197 } catch (Exception e ) {
196198 // deserialization failed, continue
197199 errorMessages .add (String .format (Locale .ROOT , "Deserialization for RbmActionDial failed with `%s`." , e .getMessage ()));
@@ -202,8 +204,9 @@ public MultiChannelAction read(JsonReader in) throws IOException {
202204 // validate the JSON object to see if any exception is thrown
203205 RbmActionViewLocation .validateJsonElement (jsonElement );
204206 actualAdapter = adapterRbmActionViewLocation ;
205- match ++;
206- log .log (Level .FINER , "Input data matches schema 'RbmActionViewLocation'" );
207+ MultiChannelAction ret = new MultiChannelAction ();
208+ ret .setActualInstance (actualAdapter .fromJsonTree (jsonElement ));
209+ return ret ;
207210 } catch (Exception e ) {
208211 // deserialization failed, continue
209212 errorMessages .add (String .format (Locale .ROOT , "Deserialization for RbmActionViewLocation failed with `%s`." , e .getMessage ()));
@@ -214,8 +217,9 @@ public MultiChannelAction read(JsonReader in) throws IOException {
214217 // validate the JSON object to see if any exception is thrown
215218 MultiChannelActionCalendarEvent .validateJsonElement (jsonElement );
216219 actualAdapter = adapterMultiChannelActionCalendarEvent ;
217- match ++;
218- log .log (Level .FINER , "Input data matches schema 'MultiChannelActionCalendarEvent'" );
220+ MultiChannelAction ret = new MultiChannelAction ();
221+ ret .setActualInstance (actualAdapter .fromJsonTree (jsonElement ));
222+ return ret ;
219223 } catch (Exception e ) {
220224 // deserialization failed, continue
221225 errorMessages .add (String .format (Locale .ROOT , "Deserialization for MultiChannelActionCalendarEvent failed with `%s`." , e .getMessage ()));
@@ -226,35 +230,30 @@ public MultiChannelAction read(JsonReader in) throws IOException {
226230 // validate the JSON object to see if any exception is thrown
227231 RbmActionOpenUrl .validateJsonElement (jsonElement );
228232 actualAdapter = adapterRbmActionOpenUrl ;
229- match ++;
230- log .log (Level .FINER , "Input data matches schema 'RbmActionOpenUrl'" );
233+ MultiChannelAction ret = new MultiChannelAction ();
234+ ret .setActualInstance (actualAdapter .fromJsonTree (jsonElement ));
235+ return ret ;
231236 } catch (Exception e ) {
232237 // deserialization failed, continue
233238 errorMessages .add (String .format (Locale .ROOT , "Deserialization for RbmActionOpenUrl failed with `%s`." , e .getMessage ()));
234239 log .log (Level .FINER , "Input data does not match schema 'RbmActionOpenUrl'" , e );
235240 }
236241
237- if (match == 1 ) {
238- MultiChannelAction ret = new MultiChannelAction ();
239- ret .setActualInstance (actualAdapter .fromJsonTree (jsonElement ));
240- return ret ;
241- }
242-
243- throw new IOException (String .format (Locale .ROOT , "Failed deserialization for MultiChannelAction: %d classes match result, expected 1. Detailed failure message for oneOf schemas: %s. JSON: %s" , match , errorMessages , jsonElement .toString ()));
242+ throw new IOException (String .format (Locale .ROOT , "Failed deserialization for MultiChannelAction: no class matches result, expected at least 1. Detailed failure message for anyOf schemas: %s. JSON: %s" , errorMessages , jsonElement .toString ()));
244243 }
245244 }.nullSafe ();
246245 }
247246 }
248247
249- // store a list of schema names defined in oneOf
248+ // store a list of schema names defined in anyOf
250249 public static final Map <String , Class <?>> schemas = new HashMap <String , Class <?>>();
251250
252251 public MultiChannelAction () {
253- super ("oneOf " , Boolean .FALSE );
252+ super ("anyOf " , Boolean .FALSE );
254253 }
255254
256255 public MultiChannelAction (Object o ) {
257- super ("oneOf " , Boolean .FALSE );
256+ super ("anyOf " , Boolean .FALSE );
258257 setActualInstance (o );
259258 }
260259
@@ -272,11 +271,11 @@ public Map<String, Class<?>> getSchemas() {
272271 }
273272
274273 /**
275- * Set the instance that matches the oneOf child schema, check
276- * the instance parameter is valid against the oneOf child schemas:
274+ * Set the instance that matches the anyOf child schema, check
275+ * the instance parameter is valid against the anyOf child schemas:
277276 * MultiChannelActionCalendarEvent, RbmActionBase, RbmActionDial, RbmActionOpenUrl, RbmActionViewLocation
278277 *
279- * It could be an instance of the 'oneOf ' schemas.
278+ * It could be an instance of the 'anyOf ' schemas.
280279 */
281280 @ Override
282281 public void setActualInstance (Object instance ) {
@@ -382,52 +381,49 @@ public RbmActionOpenUrl getRbmActionOpenUrl() throws ClassCastException {
382381 * @throws IOException if the JSON Element is invalid with respect to MultiChannelAction
383382 */
384383 public static void validateJsonElement (JsonElement jsonElement ) throws IOException {
385- // validate oneOf schemas one by one
386- int validCount = 0 ;
384+ // validate anyOf schemas one by one
387385 ArrayList <String > errorMessages = new ArrayList <>();
388386 // validate the json string with RbmActionBase
389387 try {
390388 RbmActionBase .validateJsonElement (jsonElement );
391- validCount ++ ;
389+ return ;
392390 } catch (Exception e ) {
393391 errorMessages .add (String .format (Locale .ROOT , "Deserialization for RbmActionBase failed with `%s`." , e .getMessage ()));
394392 // continue to the next one
395393 }
396394 // validate the json string with RbmActionDial
397395 try {
398396 RbmActionDial .validateJsonElement (jsonElement );
399- validCount ++ ;
397+ return ;
400398 } catch (Exception e ) {
401399 errorMessages .add (String .format (Locale .ROOT , "Deserialization for RbmActionDial failed with `%s`." , e .getMessage ()));
402400 // continue to the next one
403401 }
404402 // validate the json string with RbmActionViewLocation
405403 try {
406404 RbmActionViewLocation .validateJsonElement (jsonElement );
407- validCount ++ ;
405+ return ;
408406 } catch (Exception e ) {
409407 errorMessages .add (String .format (Locale .ROOT , "Deserialization for RbmActionViewLocation failed with `%s`." , e .getMessage ()));
410408 // continue to the next one
411409 }
412410 // validate the json string with MultiChannelActionCalendarEvent
413411 try {
414412 MultiChannelActionCalendarEvent .validateJsonElement (jsonElement );
415- validCount ++ ;
413+ return ;
416414 } catch (Exception e ) {
417415 errorMessages .add (String .format (Locale .ROOT , "Deserialization for MultiChannelActionCalendarEvent failed with `%s`." , e .getMessage ()));
418416 // continue to the next one
419417 }
420418 // validate the json string with RbmActionOpenUrl
421419 try {
422420 RbmActionOpenUrl .validateJsonElement (jsonElement );
423- validCount ++ ;
421+ return ;
424422 } catch (Exception e ) {
425423 errorMessages .add (String .format (Locale .ROOT , "Deserialization for RbmActionOpenUrl failed with `%s`." , e .getMessage ()));
426424 // continue to the next one
427425 }
428- if (validCount != 1 ) {
429- throw new IOException (String .format (Locale .ROOT , "The JSON string is invalid for MultiChannelAction with oneOf schemas: MultiChannelActionCalendarEvent, RbmActionBase, RbmActionDial, RbmActionOpenUrl, RbmActionViewLocation. %d class(es) match the result, expected 1. Detailed failure message for oneOf schemas: %s. JSON: %s" , validCount , errorMessages , jsonElement .toString ()));
430- }
426+ throw new IOException (String .format (Locale .ROOT , "The JSON string is invalid for MultiChannelAction with anyOf schemas: MultiChannelActionCalendarEvent, RbmActionBase, RbmActionDial, RbmActionOpenUrl, RbmActionViewLocation. no class match the result, expected at least 1. Detailed failure message for anyOf schemas: %s. JSON: %s" , errorMessages , jsonElement .toString ()));
431427 }
432428
433429 /**
0 commit comments