xapi.ui.autoui.X_AutoUi Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of xapi-core-ui-autoui Show documentation
Show all versions of xapi-core-ui-autoui Show documentation
The core API for generating user interfaces from data models.
package xapi.ui.autoui;
import xapi.inject.X_Inject;
import xapi.ui.autoui.api.UserInterface;
import xapi.ui.autoui.api.UserInterfaceFactory;
public class X_AutoUi {
private X_AutoUi(){}
@SuppressWarnings("unchecked")
public static > U makeUi(T model, Class extends T> uiOptions, Class uiType) {
if (uiOptions == null) {
assert model != null : "You must provide either a model object, or a model class";
uiOptions = (Class extends T>) model.getClass();
}
U ui = instantiate(uiOptions, uiType);
try {
return ui;
} finally {
if (model != null) {
ui.renderUi(model);
}
}
}
public static > U instantiate(Class extends T> cls, Class uiType) {
return X_Inject
.instance(UserInterfaceFactory.class)
.createUi(cls, uiType);
}
}