@@ -1653,6 +1653,51 @@ public WidgetDefinition deserialize(JsonParser jp, DeserializationContext ctxt)
16531653 log .log (Level .FINER , "Input data does not match schema 'TreeMapWidgetDefinition'" , e );
16541654 }
16551655
1656+ // deserialize WildcardWidgetDefinition
1657+ try {
1658+ boolean attemptParsing = true ;
1659+ // ensure that we respect type coercion as set on the client ObjectMapper
1660+ if (WildcardWidgetDefinition .class .equals (Integer .class )
1661+ || WildcardWidgetDefinition .class .equals (Long .class )
1662+ || WildcardWidgetDefinition .class .equals (Float .class )
1663+ || WildcardWidgetDefinition .class .equals (Double .class )
1664+ || WildcardWidgetDefinition .class .equals (Boolean .class )
1665+ || WildcardWidgetDefinition .class .equals (String .class )) {
1666+ attemptParsing = typeCoercion ;
1667+ if (!attemptParsing ) {
1668+ attemptParsing |=
1669+ ((WildcardWidgetDefinition .class .equals (Integer .class )
1670+ || WildcardWidgetDefinition .class .equals (Long .class ))
1671+ && token == JsonToken .VALUE_NUMBER_INT );
1672+ attemptParsing |=
1673+ ((WildcardWidgetDefinition .class .equals (Float .class )
1674+ || WildcardWidgetDefinition .class .equals (Double .class ))
1675+ && (token == JsonToken .VALUE_NUMBER_FLOAT
1676+ || token == JsonToken .VALUE_NUMBER_INT ));
1677+ attemptParsing |=
1678+ (WildcardWidgetDefinition .class .equals (Boolean .class )
1679+ && (token == JsonToken .VALUE_FALSE || token == JsonToken .VALUE_TRUE ));
1680+ attemptParsing |=
1681+ (WildcardWidgetDefinition .class .equals (String .class )
1682+ && token == JsonToken .VALUE_STRING );
1683+ }
1684+ }
1685+ if (attemptParsing ) {
1686+ tmp = tree .traverse (jp .getCodec ()).readValueAs (WildcardWidgetDefinition .class );
1687+ // TODO: there is no validation against JSON schema constraints
1688+ // (min, max, enum, pattern...), this does not perform a strict JSON
1689+ // validation, which means the 'match' count may be higher than it should be.
1690+ if (!((WildcardWidgetDefinition ) tmp ).unparsed ) {
1691+ deserialized = tmp ;
1692+ match ++;
1693+ }
1694+ log .log (Level .FINER , "Input data matches schema 'WildcardWidgetDefinition'" );
1695+ }
1696+ } catch (Exception e ) {
1697+ // deserialization failed, continue
1698+ log .log (Level .FINER , "Input data does not match schema 'WildcardWidgetDefinition'" , e );
1699+ }
1700+
16561701 WidgetDefinition ret = new WidgetDefinition ();
16571702 if (match == 1 ) {
16581703 ret .setActualInstance (deserialized );
@@ -1856,6 +1901,11 @@ public WidgetDefinition(TreeMapWidgetDefinition o) {
18561901 setActualInstance (o );
18571902 }
18581903
1904+ public WidgetDefinition (WildcardWidgetDefinition o ) {
1905+ super ("oneOf" , Boolean .FALSE );
1906+ setActualInstance (o );
1907+ }
1908+
18591909 static {
18601910 schemas .put ("AlertGraphWidgetDefinition" , new GenericType <AlertGraphWidgetDefinition >() {});
18611911 schemas .put ("AlertValueWidgetDefinition" , new GenericType <AlertValueWidgetDefinition >() {});
@@ -1895,6 +1945,7 @@ public WidgetDefinition(TreeMapWidgetDefinition o) {
18951945 schemas .put ("ToplistWidgetDefinition" , new GenericType <ToplistWidgetDefinition >() {});
18961946 schemas .put ("TopologyMapWidgetDefinition" , new GenericType <TopologyMapWidgetDefinition >() {});
18971947 schemas .put ("TreeMapWidgetDefinition" , new GenericType <TreeMapWidgetDefinition >() {});
1948+ schemas .put ("WildcardWidgetDefinition" , new GenericType <WildcardWidgetDefinition >() {});
18981949 JSON .registerDescendants (WidgetDefinition .class , Collections .unmodifiableMap (schemas ));
18991950 }
19001951
@@ -1916,7 +1967,8 @@ public Map<String, GenericType> getSchemas() {
19161967 * SLOListWidgetDefinition, SLOWidgetDefinition, ScatterPlotWidgetDefinition,
19171968 * ServiceMapWidgetDefinition, ServiceSummaryWidgetDefinition, SplitGraphWidgetDefinition,
19181969 * SunburstWidgetDefinition, TableWidgetDefinition, TimeseriesWidgetDefinition,
1919- * ToplistWidgetDefinition, TopologyMapWidgetDefinition, TreeMapWidgetDefinition
1970+ * ToplistWidgetDefinition, TopologyMapWidgetDefinition, TreeMapWidgetDefinition,
1971+ * WildcardWidgetDefinition
19201972 *
19211973 * <p>It could be an instance of the 'oneOf' schemas. The oneOf child schemas may themselves be a
19221974 * composed schema (allOf, anyOf, oneOf).
@@ -2065,6 +2117,10 @@ public void setActualInstance(Object instance) {
20652117 super .setActualInstance (instance );
20662118 return ;
20672119 }
2120+ if (JSON .isInstanceOf (WildcardWidgetDefinition .class , instance , new HashSet <Class <?>>())) {
2121+ super .setActualInstance (instance );
2122+ return ;
2123+ }
20682124
20692125 if (JSON .isInstanceOf (UnparsedObject .class , instance , new HashSet <Class <?>>())) {
20702126 super .setActualInstance (instance );
@@ -2083,7 +2139,8 @@ public void setActualInstance(Object instance) {
20832139 + " SLOWidgetDefinition, ScatterPlotWidgetDefinition, ServiceMapWidgetDefinition,"
20842140 + " ServiceSummaryWidgetDefinition, SplitGraphWidgetDefinition,"
20852141 + " SunburstWidgetDefinition, TableWidgetDefinition, TimeseriesWidgetDefinition,"
2086- + " ToplistWidgetDefinition, TopologyMapWidgetDefinition, TreeMapWidgetDefinition" );
2142+ + " ToplistWidgetDefinition, TopologyMapWidgetDefinition, TreeMapWidgetDefinition,"
2143+ + " WildcardWidgetDefinition" );
20872144 }
20882145
20892146 /**
@@ -2099,7 +2156,7 @@ public void setActualInstance(Object instance) {
20992156 * ScatterPlotWidgetDefinition, ServiceMapWidgetDefinition, ServiceSummaryWidgetDefinition,
21002157 * SplitGraphWidgetDefinition, SunburstWidgetDefinition, TableWidgetDefinition,
21012158 * TimeseriesWidgetDefinition, ToplistWidgetDefinition, TopologyMapWidgetDefinition,
2102- * TreeMapWidgetDefinition
2159+ * TreeMapWidgetDefinition, WildcardWidgetDefinition
21032160 *
21042161 * @return The actual instance (AlertGraphWidgetDefinition, AlertValueWidgetDefinition,
21052162 * BarChartWidgetDefinition, ChangeWidgetDefinition, CheckStatusWidgetDefinition,
@@ -2112,7 +2169,8 @@ public void setActualInstance(Object instance) {
21122169 * SLOListWidgetDefinition, SLOWidgetDefinition, ScatterPlotWidgetDefinition,
21132170 * ServiceMapWidgetDefinition, ServiceSummaryWidgetDefinition, SplitGraphWidgetDefinition,
21142171 * SunburstWidgetDefinition, TableWidgetDefinition, TimeseriesWidgetDefinition,
2115- * ToplistWidgetDefinition, TopologyMapWidgetDefinition, TreeMapWidgetDefinition)
2172+ * ToplistWidgetDefinition, TopologyMapWidgetDefinition, TreeMapWidgetDefinition,
2173+ * WildcardWidgetDefinition)
21162174 */
21172175 @ Override
21182176 public Object getActualInstance () {
@@ -2506,4 +2564,15 @@ public TopologyMapWidgetDefinition getTopologyMapWidgetDefinition() throws Class
25062564 public TreeMapWidgetDefinition getTreeMapWidgetDefinition () throws ClassCastException {
25072565 return (TreeMapWidgetDefinition ) super .getActualInstance ();
25082566 }
2567+
2568+ /**
2569+ * Get the actual instance of `WildcardWidgetDefinition`. If the actual instance is not
2570+ * `WildcardWidgetDefinition`, the ClassCastException will be thrown.
2571+ *
2572+ * @return The actual instance of `WildcardWidgetDefinition`
2573+ * @throws ClassCastException if the instance is not `WildcardWidgetDefinition`
2574+ */
2575+ public WildcardWidgetDefinition getWildcardWidgetDefinition () throws ClassCastException {
2576+ return (WildcardWidgetDefinition ) super .getActualInstance ();
2577+ }
25092578}
0 commit comments