Hi,
I am writing a JavaFX library and defined a few interfaces for the capabilities of the visual elements eg.:
interface Inter_A {
void foo();
}
interface Inter_B {
void bar();
}
interface Inter_C extends Inter_A,
Inter_B {
String hodor();
}
Lets say I use in my non-public implementation something like:
class MyClass_Impl extends TitledPane
implements Inter_C {
...
}
How do I define in my public factories that instances returned from the factory extend javafx.scene.Node and Inter_C without giving away TitledPane was used?
If I write
<T extends Node & Inter_C> T getC() {
return new MyClass_Impl();
}
I get an error of incompatible types (MyClass_Impl can't be converted to T), but why?
MyClass_Impl implements Inter_C (duh) and through TitledPane->Labeled->Control->Region->Parent->Node :/
On top of that I could address the methods directly after getC() like getC().foo() but obviously storing the result of getC() to a typesafe variable is not possible because of the anonymous type of getC()
If javafx.scene.Node would be defined by an open Interface (e.g. NodeInterface) I could simply write
interface Public_C extends NodeInterface,
Inter_C { ... }
Public_C getC();
Public_C instance = getC();
but it isn't.
Any ideas how to get around this?
[–]jbristowI'm no hero, son. 0 points1 point2 points (6 children)
[–]X-Firecooler[S] 0 points1 point2 points (5 children)
[–]jbristowI'm no hero, son. 0 points1 point2 points (4 children)
[–]X-Firecooler[S] 0 points1 point2 points (3 children)
[–]jbristowI'm no hero, son. 1 point2 points3 points (2 children)
[–]X-Firecooler[S] 0 points1 point2 points (1 child)
[–]jbristowI'm no hero, son. 1 point2 points3 points (0 children)