I'm struggling to understand what I need to do to not loose type information when building a JavaBeanObjectProperty for generic type T. One interesting detail is that I don't get this warning from IntelliJ for the ReadOnlyJavaBeanObjectProperty.
public class FooWrapper<T> {
/**
* Decorates a Foo instance with javafx stuff
*/
private final Foo foo;
private final JavaBeanObjectProperty<T> value;
private final ReadOnlyJavaBeanObjectProperty<T> type;
public ParameterWrapper(Foo toWrap) {
this.foo = toWrap;
try {
this.value = new JavaBeanObjectPropertyBuilder<T>()
.bean(this.foo)
.name("value")
.build();
this.type = new ReadOnlyJavaBeanObjectPropertyBuilder<T>()
.bean(this.foo)
.name("type")
.build();
} catch (NoSuchMethodException e) {
throw new RuntimeException(e);
}
}
}
I have read Java unchecked operation cast to generic and Java Generics, how to avoid unchecked assignment warning when using class hierarchy? and am none the wiser.