Interface ILazyContextVariable<T>

Type Parameters:
T - the type of the value being returned by this variable
All Known Implementing Classes:
LazyContextVariable

public interface ILazyContextVariable<T>

Interface to be implemented by context variables that need to be loaded lazily.

Variables implementing this interface have the opportunity to not be completely resolved at context build time, but instead wait until the variable is actually used in an expression executed from the template. This can importantly reduce the amount of memory required to store context variables per template in scenarios when many variables are made available to the templates in a generic manner (e.g. in frameworks that allow users to create their own templates), but templates might afterwards choose not to use some or many of these variables.

Note this lazy resolution can only be performed when the lazy variable is added to the context as a first-level variable. i.e. ${lazy} will work, but ${container.lazy} will not.

The LazyContextVariable abstract class contains a sensible implementation of this interface, best suited to be used for extension than the bare interface, in most cases.

Since:
3.0.0
Author:
Daniel Fernández
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the variable value.
  • Method Details

    • getValue

      T getValue()

      Returns the variable value. This method is meant to be internally called, and will normally perform some kind of initialization for the variable before returning (e.g. database calls, complex computations...)

      Returns:
      the variable value