xapi.ui.autoui.api.UiRenderingContext 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.
The newest version!
package xapi.ui.autoui.api;
import static xapi.collect.X_Collect.newStringMap;
import java.util.ArrayList;
import java.util.List;
import javax.inject.Provider;
import xapi.collect.api.StringTo;
import xapi.source.write.MappedTemplate;
import xapi.util.impl.ImmutableProvider;
public class UiRenderingContext {
private static final MappedTemplate DEFAULT_TEMPLATE = new MappedTemplate("");
@SuppressWarnings("rawtypes")
private static final Validator[] DEFAULT_VALIDATORS = new Validator[0];
private static final Object[] EMPTY_MESSAGES = new Object[0];
private boolean head = false;
private final Provider> renderProvider;
private UiRendererSelector selector = UiRendererSelector.ALWAYS_TRUE;
private boolean tail = false;
private MappedTemplate template = DEFAULT_TEMPLATE;
@SuppressWarnings("rawtypes")
private Validator[] validators = DEFAULT_VALIDATORS;
private boolean wrapper = false;
private BeanValueProvider valueProvider;
private String name = "";
public UiRenderingContext(Provider> renderProvider) {
this.renderProvider = renderProvider;
}
public UiRenderingContext(UiRenderer> renderer) {
this(new ImmutableProvider>(renderer));
}
public String getName() {
return name;
}
@SuppressWarnings("rawtypes")
public final UiRenderer getRenderer() {
return renderProvider.get();
}
public UiRendererSelector getSelector() {
return selector;
}
public MappedTemplate getTemplate() {
return template;
}
public String applyTemplate(String name, Object val) {
StringTo