Class AbstractNullableBean<T>

java.lang.Object
ch.tocco.nice2.templating.spi.freemarker.bean.AbstractNullableBean<T>
All Implemented Interfaces:
NullableBean
Direct Known Subclasses:
AbstractDateBean, BinaryBean, DurationBean, PhoneBean

public abstract class AbstractNullableBean<T> extends Object implements NullableBean
Base class for beans which may contain null delegates.
  • Field Details

    • delegate

      protected final Optional<T> delegate
  • Constructor Details

    • AbstractNullableBean

      protected AbstractNullableBean(T delegate)
  • Method Details

    • isNull

      public boolean isNull()
      Specified by:
      isNull in interface NullableBean
      Returns:
      true, if the bean contains a null value, else false.
    • or

      public Object or(Object fallback)
      Description copied from interface: NullableBean
      Get the value or a given fallback value, if the value is null.
      Specified by:
      or in interface NullableBean
      Parameters:
      fallback - the fallback value
      Returns:
      the bean itself or the given fallback, if the value is null.
    • strict

      public Object strict()
      Description copied from interface: NullableBean
      Get the value or null, if the value is null. Please note, that freemarker doesn't allow null values, so you should handle them somehow if no exception should be thrown. The following expressions are equivalent: 1. user.firstname.strict()!'fallback' 2. user.firstname.or('fallback')
      Specified by:
      strict in interface NullableBean
      Returns:
      the value or null, if the value is null.
    • getDelegate

      public Optional<T> getDelegate()