Package org.apache.groovy.macrolib

# Class MacroLibGroovyMethods

java.lang.Object
org.apache.groovy.macrolib.MacroLibGroovyMethods

public final class MacroLibGroovyMethods extends Object
Macro library helpers for string and named-value expansion.

Since:
  4.0.0

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static Object`
  `DO(Object self, Object... args)`
  Runtime stub for `DO(MacroContext, Expression...)`.
  `static Expression`
  `DO(MacroContext ctx, Expression... exps)`
  Monadic comprehension macro (`DO`).
  `static <T> NamedValue<T>`
  `NV(Object self, T arg)`
  Runtime stub for `NV(MacroContext, Expression)`.
  `static Expression`
  `NV(MacroContext ctx, Expression exp)`
  Builds a `NamedValue` expression from the supplied expression.
  `static <T> List<NamedValue<T>>`
  `NVL(Object self, T... args)`
  Runtime stub for `NVL(MacroContext, Expression...)`.
  `static Expression`
  `NVL(MacroContext ctx, Expression... exps)`
  Builds a list of `NamedValue` expressions from the supplied expressions.
  `static GString`
  `SV(Object self, Object... args)`
  Runtime stub for `SV(MacroContext, Expression...)`.
  `static Expression`
  `SV(MacroContext ctx, Expression... exps)`
  Builds a GString expression that labels each supplied expression with its source text.
  `static GString`
  `SVD(Object self, Object... args)`
  Runtime stub for `SVD(MacroContext, Expression...)`.
  `static Expression`
  `SVD(MacroContext ctx, Expression... exps)`
  Builds a GString expression that labels each supplied expression with its dumped value.
  `static GString`
  `SVI(Object self, Object... args)`
  Runtime stub for `SVI(MacroContext, Expression...)`.
  `static Expression`
  `SVI(MacroContext ctx, Expression... exps)`
  Builds a GString expression that labels each supplied expression with its inspected value.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Method Details

  - ### SV

    public static Expression SV(MacroContext ctx, Expression... exps)
    Builds a GString expression that labels each supplied expression with its source text.
    Parameters:
      `ctx` - the current macro context
      `exps` - the expressions to interpolate
    Returns:
      the labeled GString expression

  - ### SV

    public static GString SV(Object self, Object... args)
    Runtime stub for `SV(MacroContext, Expression...)`.
    Parameters:
      `self` - the receiver
      `args` - the interpolated values
    Returns:
      never returns normally

  - ### SVI

    public static Expression SVI(MacroContext ctx, Expression... exps)
    Builds a GString expression that labels each supplied expression with its inspected value.
    Parameters:
      `ctx` - the current macro context
      `exps` - the expressions to inspect
    Returns:
      the labeled GString expression

  - ### SVI

    public static GString SVI(Object self, Object... args)
    Runtime stub for `SVI(MacroContext, Expression...)`.
    Parameters:
      `self` - the receiver
      `args` - the interpolated values
    Returns:
      never returns normally

  - ### SVD

    public static Expression SVD(MacroContext ctx, Expression... exps)
    Builds a GString expression that labels each supplied expression with its dumped value.
    Parameters:
      `ctx` - the current macro context
      `exps` - the expressions to dump
    Returns:
      the labeled GString expression

  - ### SVD

    public static GString SVD(Object self, Object... args)
    Runtime stub for `SVD(MacroContext, Expression...)`.
    Parameters:
      `self` - the receiver
      `args` - the interpolated values
    Returns:
      never returns normally

  - ### NV

    public static Expression NV(MacroContext ctx, Expression exp)
    Builds a `NamedValue` expression from the supplied expression.
    Parameters:
      `ctx` - the current macro context
      `exp` - the expression to wrap
    Returns:
      the named-value expression

  - ### NV

    public static <T> NamedValue<T> NV(Object self, T arg)
    Runtime stub for `NV(MacroContext, Expression)`.
    Type Parameters:
      `T` - the value type
    Parameters:
      `self` - the receiver
      `arg` - the runtime value
    Returns:
      never returns normally

  - ### NVL

    public static Expression NVL(MacroContext ctx, Expression... exps)
    Builds a list of `NamedValue` expressions from the supplied expressions.
    Parameters:
      `ctx` - the current macro context
      `exps` - the expressions to wrap
    Returns:
      the list expression

  - ### NVL

    public static <T> List<NamedValue<T>> NVL(Object self, T... args)
    Runtime stub for `NVL(MacroContext, Expression...)`.
    Type Parameters:
      `T` - the value type
    Parameters:
      `self` - the receiver
      `args` - the runtime values
    Returns:
      never returns normally

  - ### DO

    public static Expression DO(MacroContext ctx, Expression... exps)
    Monadic comprehension macro (`DO`). Rewrites a comma-separated list of `name in expression` generators followed by a body closure into a nested chain of `Comprehensions.bind(java.lang.Object, groovy.lang.Closure<?>)` calls — the do-notation desugaring:

           DO(x in m1, y in f(x)) { body }
           ==>
           Comprehensions.bind(m1) { x -> Comprehensions.bind(f(x)) { y -> body } }

    Every generator becomes a bind; the body is the innermost closure body and must itself yield a carrier value (the do-notation rule — no implicit lifting). Carrier-specific bind dispatch is deferred to runtime (`Comprehensions`) because macros expand before type checking.
    Parameters:
      `ctx` - the current macro context
      `exps` - the generators (each `name in expression`) followed by the body closure
    Returns:
      the nested bind-chain expression
    Since:
      6.0.0

  - ### DO

    public static Object DO(Object self, Object... args)
    Runtime stub for `DO(MacroContext, Expression...)`.
    Parameters:
      `self` - the receiver
      `args` - the runtime values
    Returns:
      never returns normally
    Since:
      6.0.0