Class NullableTemplateModel
java.lang.Object
ch.tocco.nice2.templating.api.freemarker.templatemodel.NullableTemplateModel
- All Implemented Interfaces:
freemarker.template.TemplateHashModel
,freemarker.template.TemplateModel
- Direct Known Subclasses:
BooleanTemplateModel
,NumericTemplateModel
,StringTemplateModel
public abstract class NullableTemplateModel
extends Object
implements freemarker.template.TemplateHashModel
Base class for values which may be null. In case of the value is null,
a fallback value is provided (which can also be null, but seldom is).
Keep the public interface synced with
NullableBean
.- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionprotected final Object
protected final Object
protected final freemarker.ext.beans.BeansWrapper
Fields inherited from interface freemarker.template.TemplateModel
NOTHING
-
Constructor Summary
ModifierConstructorDescriptionprotected
NullableTemplateModel
(Object value, Object nullValue, freemarker.ext.beans.BeansWrapper wrapper) -
Method Summary
-
Field Details
-
value
-
nullValue
-
wrapper
protected final freemarker.ext.beans.BeansWrapper wrapper
-
-
Constructor Details
-
NullableTemplateModel
-
-
Method Details
-
getValueOrFallback
- Returns:
- the value. If the value is null, the fallback value is returned.
-
isEmpty
public boolean isEmpty() throws freemarker.template.TemplateModelException- Specified by:
isEmpty
in interfacefreemarker.template.TemplateHashModel
- Throws:
freemarker.template.TemplateModelException
-
get
public freemarker.template.TemplateModel get(String key) throws freemarker.template.TemplateModelException - Specified by:
get
in interfacefreemarker.template.TemplateHashModel
- Throws:
freemarker.template.TemplateModelException
-