@@ -246,6 +246,58 @@ public DistributionWidgetHistogramRequestQuery deserialize(
246246 e );
247247 }
248248
249+ // deserialize FormulaAndFunctionApmMetricsQueryDefinition
250+ try {
251+ boolean attemptParsing = true ;
252+ // ensure that we respect type coercion as set on the client ObjectMapper
253+ if (FormulaAndFunctionApmMetricsQueryDefinition .class .equals (Integer .class )
254+ || FormulaAndFunctionApmMetricsQueryDefinition .class .equals (Long .class )
255+ || FormulaAndFunctionApmMetricsQueryDefinition .class .equals (Float .class )
256+ || FormulaAndFunctionApmMetricsQueryDefinition .class .equals (Double .class )
257+ || FormulaAndFunctionApmMetricsQueryDefinition .class .equals (Boolean .class )
258+ || FormulaAndFunctionApmMetricsQueryDefinition .class .equals (String .class )) {
259+ attemptParsing = typeCoercion ;
260+ if (!attemptParsing ) {
261+ attemptParsing |=
262+ ((FormulaAndFunctionApmMetricsQueryDefinition .class .equals (Integer .class )
263+ || FormulaAndFunctionApmMetricsQueryDefinition .class .equals (Long .class ))
264+ && token == JsonToken .VALUE_NUMBER_INT );
265+ attemptParsing |=
266+ ((FormulaAndFunctionApmMetricsQueryDefinition .class .equals (Float .class )
267+ || FormulaAndFunctionApmMetricsQueryDefinition .class .equals (Double .class ))
268+ && (token == JsonToken .VALUE_NUMBER_FLOAT
269+ || token == JsonToken .VALUE_NUMBER_INT ));
270+ attemptParsing |=
271+ (FormulaAndFunctionApmMetricsQueryDefinition .class .equals (Boolean .class )
272+ && (token == JsonToken .VALUE_FALSE || token == JsonToken .VALUE_TRUE ));
273+ attemptParsing |=
274+ (FormulaAndFunctionApmMetricsQueryDefinition .class .equals (String .class )
275+ && token == JsonToken .VALUE_STRING );
276+ }
277+ }
278+ if (attemptParsing ) {
279+ tmp =
280+ tree .traverse (jp .getCodec ())
281+ .readValueAs (FormulaAndFunctionApmMetricsQueryDefinition .class );
282+ // TODO: there is no validation against JSON schema constraints
283+ // (min, max, enum, pattern...), this does not perform a strict JSON
284+ // validation, which means the 'match' count may be higher than it should be.
285+ if (!((FormulaAndFunctionApmMetricsQueryDefinition ) tmp ).unparsed ) {
286+ deserialized = tmp ;
287+ match ++;
288+ }
289+ log .log (
290+ Level .FINER ,
291+ "Input data matches schema 'FormulaAndFunctionApmMetricsQueryDefinition'" );
292+ }
293+ } catch (Exception e ) {
294+ // deserialization failed, continue
295+ log .log (
296+ Level .FINER ,
297+ "Input data does not match schema 'FormulaAndFunctionApmMetricsQueryDefinition'" ,
298+ e );
299+ }
300+
249301 DistributionWidgetHistogramRequestQuery ret = new DistributionWidgetHistogramRequestQuery ();
250302 if (match == 1 ) {
251303 ret .setActualInstance (deserialized );
@@ -292,6 +344,11 @@ public DistributionWidgetHistogramRequestQuery(
292344 setActualInstance (o );
293345 }
294346
347+ public DistributionWidgetHistogramRequestQuery (FormulaAndFunctionApmMetricsQueryDefinition o ) {
348+ super ("oneOf" , Boolean .FALSE );
349+ setActualInstance (o );
350+ }
351+
295352 static {
296353 schemas .put (
297354 "FormulaAndFunctionMetricQueryDefinition" ,
@@ -302,6 +359,9 @@ public DistributionWidgetHistogramRequestQuery(
302359 schemas .put (
303360 "FormulaAndFunctionApmResourceStatsQueryDefinition" ,
304361 new GenericType <FormulaAndFunctionApmResourceStatsQueryDefinition >() {});
362+ schemas .put (
363+ "FormulaAndFunctionApmMetricsQueryDefinition" ,
364+ new GenericType <FormulaAndFunctionApmMetricsQueryDefinition >() {});
305365 JSON .registerDescendants (
306366 DistributionWidgetHistogramRequestQuery .class , Collections .unmodifiableMap (schemas ));
307367 }
@@ -314,7 +374,8 @@ public Map<String, GenericType> getSchemas() {
314374 /**
315375 * Set the instance that matches the oneOf child schema, check the instance parameter is valid
316376 * against the oneOf child schemas: FormulaAndFunctionMetricQueryDefinition,
317- * FormulaAndFunctionEventQueryDefinition, FormulaAndFunctionApmResourceStatsQueryDefinition
377+ * FormulaAndFunctionEventQueryDefinition, FormulaAndFunctionApmResourceStatsQueryDefinition,
378+ * FormulaAndFunctionApmMetricsQueryDefinition
318379 *
319380 * <p>It could be an instance of the 'oneOf' schemas. The oneOf child schemas may themselves be a
320381 * composed schema (allOf, anyOf, oneOf).
@@ -338,6 +399,11 @@ public void setActualInstance(Object instance) {
338399 super .setActualInstance (instance );
339400 return ;
340401 }
402+ if (JSON .isInstanceOf (
403+ FormulaAndFunctionApmMetricsQueryDefinition .class , instance , new HashSet <Class <?>>())) {
404+ super .setActualInstance (instance );
405+ return ;
406+ }
341407
342408 if (JSON .isInstanceOf (UnparsedObject .class , instance , new HashSet <Class <?>>())) {
343409 super .setActualInstance (instance );
@@ -346,15 +412,18 @@ public void setActualInstance(Object instance) {
346412 throw new RuntimeException (
347413 "Invalid instance type. Must be FormulaAndFunctionMetricQueryDefinition,"
348414 + " FormulaAndFunctionEventQueryDefinition,"
349- + " FormulaAndFunctionApmResourceStatsQueryDefinition" );
415+ + " FormulaAndFunctionApmResourceStatsQueryDefinition,"
416+ + " FormulaAndFunctionApmMetricsQueryDefinition" );
350417 }
351418
352419 /**
353420 * Get the actual instance, which can be the following: FormulaAndFunctionMetricQueryDefinition,
354- * FormulaAndFunctionEventQueryDefinition, FormulaAndFunctionApmResourceStatsQueryDefinition
421+ * FormulaAndFunctionEventQueryDefinition, FormulaAndFunctionApmResourceStatsQueryDefinition,
422+ * FormulaAndFunctionApmMetricsQueryDefinition
355423 *
356424 * @return The actual instance (FormulaAndFunctionMetricQueryDefinition,
357- * FormulaAndFunctionEventQueryDefinition, FormulaAndFunctionApmResourceStatsQueryDefinition)
425+ * FormulaAndFunctionEventQueryDefinition, FormulaAndFunctionApmResourceStatsQueryDefinition,
426+ * FormulaAndFunctionApmMetricsQueryDefinition)
358427 */
359428 @ Override
360429 public Object getActualInstance () {
@@ -398,4 +467,17 @@ public FormulaAndFunctionEventQueryDefinition getFormulaAndFunctionEventQueryDef
398467 getFormulaAndFunctionApmResourceStatsQueryDefinition () throws ClassCastException {
399468 return (FormulaAndFunctionApmResourceStatsQueryDefinition ) super .getActualInstance ();
400469 }
470+
471+ /**
472+ * Get the actual instance of `FormulaAndFunctionApmMetricsQueryDefinition`. If the actual
473+ * instance is not `FormulaAndFunctionApmMetricsQueryDefinition`, the ClassCastException will be
474+ * thrown.
475+ *
476+ * @return The actual instance of `FormulaAndFunctionApmMetricsQueryDefinition`
477+ * @throws ClassCastException if the instance is not `FormulaAndFunctionApmMetricsQueryDefinition`
478+ */
479+ public FormulaAndFunctionApmMetricsQueryDefinition
480+ getFormulaAndFunctionApmMetricsQueryDefinition () throws ClassCastException {
481+ return (FormulaAndFunctionApmMetricsQueryDefinition ) super .getActualInstance ();
482+ }
401483}
0 commit comments