On 20/03/2014 20:57, Tom Schindl wrote:
Hi,
I've just started looking into getting the controls package warning free
and/or suppress them in case not fixable.
Most of the generic warnings I've come accross in a first pass involve
StyleableProperty cast like this:
((StyleableProperty)graphicProperty()).applyStyle(origin, null);
In fact above code has 2 warnings:
a) unchecked type cast
b) usage of raw-type
the raw type in this case can be fixed with:
((StyleableProperty<Node>)graphicProperty()).applyStyle(origin, null);
leaving us with the unchecked cast so we could add:
@SuppressWarnings({ "unchecked" })
e.g. on the method but I'm uncertain this is a good idea because it
might hide unchecked warnings we have a possibility to fix.
If you are willing to expend another line of code, you could first
assign graphicProperty to a variable:
StylableProperty<Node> property = (StyleableProperty<Node>)graphicProperty();
property.applyStyle(origin, null);
You can then apply the unchecked annotation to the assignment only, so
future unchecked warnings in the same method will still be noticed.
--John
So what are other options:
a) Create a static helper in Util to make the cast and for us (we could
even add it as a static method in the StyleableProperty-interface)
b) provide a private/package-scoped method the public one delegates
Both of them work but have different problems where I think b) has the
bigger ones like blowing up class-file, modification of the field to be
of type StyleableObjectProperty.
I'd really like to get the source warning free.
Thoughts?
Tom