Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface Argument
One argument of a LazyScalarFunction call, not yet evaluated.

Calling value() evaluates the expression behind it; not calling it means the expression never runs. The engine hands over arguments that remember their result, so asking twice costs nothing and the function may read an argument wherever it is convenient rather than caching it by hand.

Evaluation can fail — that is the point of deferring it — and the failure surfaces from value() at the moment the function asks.

  • Method Summary

    Modifier and Type
    Method
    Description
    static Argument
    An argument that runs supplier at most once, however often it is read.
    static Argument
    of(Value value)
    An argument that is already a value.
    Evaluates this argument, or returns the value already computed for it.
  • Method Details

    • value

      Value value()
      Evaluates this argument, or returns the value already computed for it.
      Returns:
      the argument's value; never null
    • of

      static Argument of(Value value)
      An argument that is already a value.
      Parameters:
      value - the value to hand over
      Returns:
      an argument yielding value
    • memoizing

      static Argument memoizing(Supplier<Value> supplier)
      An argument that runs supplier at most once, however often it is read.

      This is the shape the engine supplies, and the reason a lazy function can read the same argument in two branches without evaluating the expression twice.

      Parameters:
      supplier - the deferred evaluation; called at most once
      Returns:
      a remembering argument over supplier