In my project I use mvvmFX framework for JavaFX.
I need to download custom fxml component with fx:root via FluentViewLoader.fxmlView(Class...)
There is example at mvvmFX github repository how to do it:
link
And it's working, but:
I want to create static method in another class like this:
public static void downloadCustomComponent(
Class<? extends FxmlView<? extends ViewModel>> clazz,
FxmlView<? extends ViewModel> view){
FluentViewLoader.fxmlView(clazz).root(view).codeBehind(view).load();
}
But IDEA showing us error:
'codeBehind(capture<? extends de.saxsys.mvvmfx.FxmlView<? extends de.saxsys.mvvmfx.ViewModel>>)' in 'de.saxsys.mvvmfx.FluentViewLoader.FxmlViewStep' cannot be applied to '(de.saxsys.mvvmfx.FxmlView<capture<? extends de.saxsys.mvvmfx.ViewModel>>)'
Or, how can I do it?
I tried to change wildcards at Class parameter, but changing doesn't help. If I remove generic like this:
public static void downloadCustomComponent(Class clazz, FxmlView<? extends ViewModel> view){
FluentViewLoader.fxmlView(clazz).root(view).codeBehind(view).load();
}
It's working, but I think it's bad to use raw parametrized class.
What you can recommend me?
I have found a solution to my problem! I needed to create method like this:
public static <T extends FxmlView<? extends ViewModel>> void downloadCustomComponent(T view, Class<T> clazz){
FluentViewLoader.fxmlView(clazz).root(view).codeBehind(view).load();
}
And it's working!