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
FieldsModifier and TypeFieldDescriptionprotected final Objectprotected final Objectprotected final freemarker.ext.beans.BeansWrapperFields inherited from interface freemarker.template.TemplateModel
NOTHING -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedNullableTemplateModel(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:
isEmptyin interfacefreemarker.template.TemplateHashModel- Throws:
freemarker.template.TemplateModelException
-
get
public freemarker.template.TemplateModel get(String key) throws freemarker.template.TemplateModelException - Specified by:
getin interfacefreemarker.template.TemplateHashModel- Throws:
freemarker.template.TemplateModelException
-