@@ -213,6 +213,52 @@ public RoutingRuleAction deserialize(JsonParser jp, DeserializationContext ctxt)
213213 Level .FINER , "Input data does not match schema 'TriggerWorkflowAutomationAction'" , e );
214214 }
215215
216+ // deserialize RoutingRuleEscalationPolicyAction
217+ try {
218+ boolean attemptParsing = true ;
219+ // ensure that we respect type coercion as set on the client ObjectMapper
220+ if (RoutingRuleEscalationPolicyAction .class .equals (Integer .class )
221+ || RoutingRuleEscalationPolicyAction .class .equals (Long .class )
222+ || RoutingRuleEscalationPolicyAction .class .equals (Float .class )
223+ || RoutingRuleEscalationPolicyAction .class .equals (Double .class )
224+ || RoutingRuleEscalationPolicyAction .class .equals (Boolean .class )
225+ || RoutingRuleEscalationPolicyAction .class .equals (String .class )) {
226+ attemptParsing = typeCoercion ;
227+ if (!attemptParsing ) {
228+ attemptParsing |=
229+ ((RoutingRuleEscalationPolicyAction .class .equals (Integer .class )
230+ || RoutingRuleEscalationPolicyAction .class .equals (Long .class ))
231+ && token == JsonToken .VALUE_NUMBER_INT );
232+ attemptParsing |=
233+ ((RoutingRuleEscalationPolicyAction .class .equals (Float .class )
234+ || RoutingRuleEscalationPolicyAction .class .equals (Double .class ))
235+ && (token == JsonToken .VALUE_NUMBER_FLOAT
236+ || token == JsonToken .VALUE_NUMBER_INT ));
237+ attemptParsing |=
238+ (RoutingRuleEscalationPolicyAction .class .equals (Boolean .class )
239+ && (token == JsonToken .VALUE_FALSE || token == JsonToken .VALUE_TRUE ));
240+ attemptParsing |=
241+ (RoutingRuleEscalationPolicyAction .class .equals (String .class )
242+ && token == JsonToken .VALUE_STRING );
243+ }
244+ }
245+ if (attemptParsing ) {
246+ tmp = tree .traverse (jp .getCodec ()).readValueAs (RoutingRuleEscalationPolicyAction .class );
247+ // TODO: there is no validation against JSON schema constraints
248+ // (min, max, enum, pattern...), this does not perform a strict JSON
249+ // validation, which means the 'match' count may be higher than it should be.
250+ if (!((RoutingRuleEscalationPolicyAction ) tmp ).unparsed ) {
251+ deserialized = tmp ;
252+ match ++;
253+ }
254+ log .log (Level .FINER , "Input data matches schema 'RoutingRuleEscalationPolicyAction'" );
255+ }
256+ } catch (Exception e ) {
257+ // deserialization failed, continue
258+ log .log (
259+ Level .FINER , "Input data does not match schema 'RoutingRuleEscalationPolicyAction'" , e );
260+ }
261+
216262 RoutingRuleAction ret = new RoutingRuleAction ();
217263 if (match == 1 ) {
218264 ret .setActualInstance (deserialized );
@@ -256,11 +302,19 @@ public RoutingRuleAction(TriggerWorkflowAutomationAction o) {
256302 setActualInstance (o );
257303 }
258304
305+ public RoutingRuleAction (RoutingRuleEscalationPolicyAction o ) {
306+ super ("oneOf" , Boolean .FALSE );
307+ setActualInstance (o );
308+ }
309+
259310 static {
260311 schemas .put ("SendSlackMessageAction" , new GenericType <SendSlackMessageAction >() {});
261312 schemas .put ("SendTeamsMessageAction" , new GenericType <SendTeamsMessageAction >() {});
262313 schemas .put (
263314 "TriggerWorkflowAutomationAction" , new GenericType <TriggerWorkflowAutomationAction >() {});
315+ schemas .put (
316+ "RoutingRuleEscalationPolicyAction" ,
317+ new GenericType <RoutingRuleEscalationPolicyAction >() {});
264318 JSON .registerDescendants (RoutingRuleAction .class , Collections .unmodifiableMap (schemas ));
265319 }
266320
@@ -272,7 +326,7 @@ public Map<String, GenericType> getSchemas() {
272326 /**
273327 * Set the instance that matches the oneOf child schema, check the instance parameter is valid
274328 * against the oneOf child schemas: SendSlackMessageAction, SendTeamsMessageAction,
275- * TriggerWorkflowAutomationAction
329+ * TriggerWorkflowAutomationAction, RoutingRuleEscalationPolicyAction
276330 *
277331 * <p>It could be an instance of the 'oneOf' schemas. The oneOf child schemas may themselves be a
278332 * composed schema (allOf, anyOf, oneOf).
@@ -292,22 +346,27 @@ public void setActualInstance(Object instance) {
292346 super .setActualInstance (instance );
293347 return ;
294348 }
349+ if (JSON .isInstanceOf (
350+ RoutingRuleEscalationPolicyAction .class , instance , new HashSet <Class <?>>())) {
351+ super .setActualInstance (instance );
352+ return ;
353+ }
295354
296355 if (JSON .isInstanceOf (UnparsedObject .class , instance , new HashSet <Class <?>>())) {
297356 super .setActualInstance (instance );
298357 return ;
299358 }
300359 throw new RuntimeException (
301360 "Invalid instance type. Must be SendSlackMessageAction, SendTeamsMessageAction,"
302- + " TriggerWorkflowAutomationAction" );
361+ + " TriggerWorkflowAutomationAction, RoutingRuleEscalationPolicyAction " );
303362 }
304363
305364 /**
306365 * Get the actual instance, which can be the following: SendSlackMessageAction,
307- * SendTeamsMessageAction, TriggerWorkflowAutomationAction
366+ * SendTeamsMessageAction, TriggerWorkflowAutomationAction, RoutingRuleEscalationPolicyAction
308367 *
309368 * @return The actual instance (SendSlackMessageAction, SendTeamsMessageAction,
310- * TriggerWorkflowAutomationAction)
369+ * TriggerWorkflowAutomationAction, RoutingRuleEscalationPolicyAction )
311370 */
312371 @ Override
313372 public Object getActualInstance () {
@@ -347,4 +406,16 @@ public TriggerWorkflowAutomationAction getTriggerWorkflowAutomationAction()
347406 throws ClassCastException {
348407 return (TriggerWorkflowAutomationAction ) super .getActualInstance ();
349408 }
409+
410+ /**
411+ * Get the actual instance of `RoutingRuleEscalationPolicyAction`. If the actual instance is not
412+ * `RoutingRuleEscalationPolicyAction`, the ClassCastException will be thrown.
413+ *
414+ * @return The actual instance of `RoutingRuleEscalationPolicyAction`
415+ * @throws ClassCastException if the instance is not `RoutingRuleEscalationPolicyAction`
416+ */
417+ public RoutingRuleEscalationPolicyAction getRoutingRuleEscalationPolicyAction ()
418+ throws ClassCastException {
419+ return (RoutingRuleEscalationPolicyAction ) super .getActualInstance ();
420+ }
350421}
0 commit comments