@@ -1698,6 +1698,51 @@ public WidgetDefinition deserialize(JsonParser jp, DeserializationContext ctxt)
16981698 log .log (Level .FINER , "Input data does not match schema 'TreeMapWidgetDefinition'" , e );
16991699 }
17001700
1701+ // deserialize WildcardWidgetDefinition
1702+ try {
1703+ boolean attemptParsing = true ;
1704+ // ensure that we respect type coercion as set on the client ObjectMapper
1705+ if (WildcardWidgetDefinition .class .equals (Integer .class )
1706+ || WildcardWidgetDefinition .class .equals (Long .class )
1707+ || WildcardWidgetDefinition .class .equals (Float .class )
1708+ || WildcardWidgetDefinition .class .equals (Double .class )
1709+ || WildcardWidgetDefinition .class .equals (Boolean .class )
1710+ || WildcardWidgetDefinition .class .equals (String .class )) {
1711+ attemptParsing = typeCoercion ;
1712+ if (!attemptParsing ) {
1713+ attemptParsing |=
1714+ ((WildcardWidgetDefinition .class .equals (Integer .class )
1715+ || WildcardWidgetDefinition .class .equals (Long .class ))
1716+ && token == JsonToken .VALUE_NUMBER_INT );
1717+ attemptParsing |=
1718+ ((WildcardWidgetDefinition .class .equals (Float .class )
1719+ || WildcardWidgetDefinition .class .equals (Double .class ))
1720+ && (token == JsonToken .VALUE_NUMBER_FLOAT
1721+ || token == JsonToken .VALUE_NUMBER_INT ));
1722+ attemptParsing |=
1723+ (WildcardWidgetDefinition .class .equals (Boolean .class )
1724+ && (token == JsonToken .VALUE_FALSE || token == JsonToken .VALUE_TRUE ));
1725+ attemptParsing |=
1726+ (WildcardWidgetDefinition .class .equals (String .class )
1727+ && token == JsonToken .VALUE_STRING );
1728+ }
1729+ }
1730+ if (attemptParsing ) {
1731+ tmp = tree .traverse (jp .getCodec ()).readValueAs (WildcardWidgetDefinition .class );
1732+ // TODO: there is no validation against JSON schema constraints
1733+ // (min, max, enum, pattern...), this does not perform a strict JSON
1734+ // validation, which means the 'match' count may be higher than it should be.
1735+ if (!((WildcardWidgetDefinition ) tmp ).unparsed ) {
1736+ deserialized = tmp ;
1737+ match ++;
1738+ }
1739+ log .log (Level .FINER , "Input data matches schema 'WildcardWidgetDefinition'" );
1740+ }
1741+ } catch (Exception e ) {
1742+ // deserialization failed, continue
1743+ log .log (Level .FINER , "Input data does not match schema 'WildcardWidgetDefinition'" , e );
1744+ }
1745+
17011746 WidgetDefinition ret = new WidgetDefinition ();
17021747 if (match == 1 ) {
17031748 ret .setActualInstance (deserialized );
@@ -1906,6 +1951,11 @@ public WidgetDefinition(TreeMapWidgetDefinition o) {
19061951 setActualInstance (o );
19071952 }
19081953
1954+ public WidgetDefinition (WildcardWidgetDefinition o ) {
1955+ super ("oneOf" , Boolean .FALSE );
1956+ setActualInstance (o );
1957+ }
1958+
19091959 static {
19101960 schemas .put ("AlertGraphWidgetDefinition" , new GenericType <AlertGraphWidgetDefinition >() {});
19111961 schemas .put ("AlertValueWidgetDefinition" , new GenericType <AlertValueWidgetDefinition >() {});
@@ -1946,6 +1996,7 @@ public WidgetDefinition(TreeMapWidgetDefinition o) {
19461996 schemas .put ("ToplistWidgetDefinition" , new GenericType <ToplistWidgetDefinition >() {});
19471997 schemas .put ("TopologyMapWidgetDefinition" , new GenericType <TopologyMapWidgetDefinition >() {});
19481998 schemas .put ("TreeMapWidgetDefinition" , new GenericType <TreeMapWidgetDefinition >() {});
1999+ schemas .put ("WildcardWidgetDefinition" , new GenericType <WildcardWidgetDefinition >() {});
19492000 JSON .registerDescendants (WidgetDefinition .class , Collections .unmodifiableMap (schemas ));
19502001 }
19512002
@@ -1968,7 +2019,7 @@ public Map<String, GenericType> getSchemas() {
19682019 * SankeyWidgetDefinition, ServiceMapWidgetDefinition, ServiceSummaryWidgetDefinition,
19692020 * SplitGraphWidgetDefinition, SunburstWidgetDefinition, TableWidgetDefinition,
19702021 * TimeseriesWidgetDefinition, ToplistWidgetDefinition, TopologyMapWidgetDefinition,
1971- * TreeMapWidgetDefinition
2022+ * TreeMapWidgetDefinition, WildcardWidgetDefinition
19722023 *
19732024 * <p>It could be an instance of the 'oneOf' schemas. The oneOf child schemas may themselves be a
19742025 * composed schema (allOf, anyOf, oneOf).
@@ -2121,6 +2172,10 @@ public void setActualInstance(Object instance) {
21212172 super .setActualInstance (instance );
21222173 return ;
21232174 }
2175+ if (JSON .isInstanceOf (WildcardWidgetDefinition .class , instance , new HashSet <Class <?>>())) {
2176+ super .setActualInstance (instance );
2177+ return ;
2178+ }
21242179
21252180 if (JSON .isInstanceOf (UnparsedObject .class , instance , new HashSet <Class <?>>())) {
21262181 super .setActualInstance (instance );
@@ -2140,7 +2195,7 @@ public void setActualInstance(Object instance) {
21402195 + " ServiceMapWidgetDefinition, ServiceSummaryWidgetDefinition,"
21412196 + " SplitGraphWidgetDefinition, SunburstWidgetDefinition, TableWidgetDefinition,"
21422197 + " TimeseriesWidgetDefinition, ToplistWidgetDefinition, TopologyMapWidgetDefinition,"
2143- + " TreeMapWidgetDefinition" );
2198+ + " TreeMapWidgetDefinition, WildcardWidgetDefinition " );
21442199 }
21452200
21462201 /**
@@ -2156,7 +2211,7 @@ public void setActualInstance(Object instance) {
21562211 * ScatterPlotWidgetDefinition, SankeyWidgetDefinition, ServiceMapWidgetDefinition,
21572212 * ServiceSummaryWidgetDefinition, SplitGraphWidgetDefinition, SunburstWidgetDefinition,
21582213 * TableWidgetDefinition, TimeseriesWidgetDefinition, ToplistWidgetDefinition,
2159- * TopologyMapWidgetDefinition, TreeMapWidgetDefinition
2214+ * TopologyMapWidgetDefinition, TreeMapWidgetDefinition, WildcardWidgetDefinition
21602215 *
21612216 * @return The actual instance (AlertGraphWidgetDefinition, AlertValueWidgetDefinition,
21622217 * BarChartWidgetDefinition, ChangeWidgetDefinition, CheckStatusWidgetDefinition,
@@ -2170,7 +2225,7 @@ public void setActualInstance(Object instance) {
21702225 * SankeyWidgetDefinition, ServiceMapWidgetDefinition, ServiceSummaryWidgetDefinition,
21712226 * SplitGraphWidgetDefinition, SunburstWidgetDefinition, TableWidgetDefinition,
21722227 * TimeseriesWidgetDefinition, ToplistWidgetDefinition, TopologyMapWidgetDefinition,
2173- * TreeMapWidgetDefinition)
2228+ * TreeMapWidgetDefinition, WildcardWidgetDefinition )
21742229 */
21752230 @ Override
21762231 public Object getActualInstance () {
@@ -2575,4 +2630,15 @@ public TopologyMapWidgetDefinition getTopologyMapWidgetDefinition() throws Class
25752630 public TreeMapWidgetDefinition getTreeMapWidgetDefinition () throws ClassCastException {
25762631 return (TreeMapWidgetDefinition ) super .getActualInstance ();
25772632 }
2633+
2634+ /**
2635+ * Get the actual instance of `WildcardWidgetDefinition`. If the actual instance is not
2636+ * `WildcardWidgetDefinition`, the ClassCastException will be thrown.
2637+ *
2638+ * @return The actual instance of `WildcardWidgetDefinition`
2639+ * @throws ClassCastException if the instance is not `WildcardWidgetDefinition`
2640+ */
2641+ public WildcardWidgetDefinition getWildcardWidgetDefinition () throws ClassCastException {
2642+ return (WildcardWidgetDefinition ) super .getActualInstance ();
2643+ }
25782644}
0 commit comments