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 Details

    • value

      protected final Object value
    • nullValue

      protected final Object nullValue
    • wrapper

      protected final freemarker.ext.beans.BeansWrapper wrapper
  • Constructor Details

    • NullableTemplateModel

      protected NullableTemplateModel(Object value, Object nullValue, freemarker.ext.beans.BeansWrapper wrapper)
  • Method Details

    • getValueOrFallback

      protected Object 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 interface freemarker.template.TemplateHashModel
      Throws:
      freemarker.template.TemplateModelException
    • get

      public freemarker.template.TemplateModel get(String key) throws freemarker.template.TemplateModelException
      Specified by:
      get in interface freemarker.template.TemplateHashModel
      Throws:
      freemarker.template.TemplateModelException