On Mon, 18 Jul 2022 14:37:19 GMT, Kevin Rushforth <[email protected]> wrote:
>> modules/javafx.graphics/src/test/java/test/javafx/css/Node_cssStyleMap_Test.java
>> line 83:
>>
>>> 81: private void checkFoundStyle(Property<?> property,
>>> Map<StyleableProperty<?>, List<Style>> map, List<Declaration> decls) {
>>> 82:
>>> 83: List<Style> styles = map.get((StyleableProperty<?>)property);
>>
>> If the `Property` must be a `StyleableProperty` then maybe the method
>> signature should be that and the cast should be the responsibility of the
>> callers.
>
> Since this is in a unit test, I don't have a strong opinion about this. Also,
> since this is in a test, an `assertTrue(property instanceof
> StyleableProperty)` might not be a bad idea.
It cannot. Shape.fillProperty(), for example, is declared as
public final ObjectProperty<Paint> fillProperty()
ObjectProperty is not a StyleableProperty, though the actual type of the
underlying property is. Same for strokeProperty, strokeWidthProperty etc.
Also, the existing test code does the typecast later.
I do agree with Kevin's suggestion to add an assert.
-------------
PR: https://git.openjdk.org/jfx/pull/823