Interface NullableBean

All Known Implementing Classes:
AbstractDateBean, AbstractNullableBean, BinaryBean, DateTimeBean, DurationBean, LocalDateBean, LocalTimeBean, PhoneBean

public interface NullableBean
Implement this interface if the bean may contain a null value. Keep this interface synced with ch.tocco.nice2.templating.api.freemarker.templatemodel.NullableTemplateModel. See ch.tocco.nice2.templating.api.freemarker.templatemodel.NullableTemplateModel
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
     
    or(Object fallback)
    Get the value or a given fallback value, if the value is null.
    Get the value or null, if the value is null.
  • Method Details

    • isNull

      boolean isNull()
      Returns:
      true, if the bean contains a null value, else false.
    • or

      Object or(Object fallback)
      Get the value or a given fallback value, if the value is null.
      Parameters:
      fallback - the fallback value
      Returns:
      the bean itself or the given fallback, if the value is null.
    • strict

      Object strict()
      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')
      Returns:
      the value or null, if the value is null.