Class Lazy<A>

Type Parameters:
A - the target type of objects to match against
All Implemented Interfaces:
Pattern<A>, Serializable, Cloneable

@Generated(generator="eu.bandm.tools.expander", version="1.3.1", timestamp="2026-02-01T13:13:56") public abstract class Lazy<A> extends Proxy<A>
Wrapper class for a pattern that is to be created lazily on demand.

Subclasses of this class must implement the init() method.

See Also:
  • Constructor Details

    • Lazy

      protected Lazy()
      Creates a new instance.
  • Method Details

    • getBody

      public Pattern<A> getBody()
      Returns the contained subpattern.

      This implementation initializes the wrapped subpattern lazily.

      Overrides:
      getBody in class Unary<A,A>
      Returns:
      the contained subpattern, or null if not set
      Throws:
      NullPointerException - if init() returns null.
    • isInitialized

      public boolean isInitialized()
      Checks whether the wrapped pattern has been initialized.
      Returns:
      true if the wrapped pattern has been initialized, false otherwise
    • isDeterministic

      public boolean isDeterministic()
      Checks whether this pattern is deterministic.

      The default implementation returns false. This implementation delegates to Unary.body.

      This implementation always returns false, since the wrapped subpattern is unknown.

      Specified by:
      isDeterministic in interface Pattern<A>
      Overrides:
      isDeterministic in class Unary<A,A>
      Returns:
      true if this pattern is guaranteed to match any object at most once, false otherwise.
      See Also:
    • init

      protected abstract Pattern<? super A> init()
      Creates the wrapped pattern.
      Returns:
      the wrapped pattern; must not be null
    • of

      public static <A> Lazy<A> of(Supplier<? extends Pattern<? super A>> init)
      Returns a new instance that uses the given initializer.
      Type Parameters:
      A - the target type of objects to match against
      Parameters:
      init - a supplier that constructs the subpattern to be wrapped
      Returns:
      a lazy pattern to be initialized using init
      Throws:
      NullPointerException - if init is null
    • of

      public static <A> Lazy<A> of(Function<? super Pattern<? super A>,? extends Pattern<? super A>> init)
      Returns a new instance that uses the given initializer.
      Type Parameters:
      A - the target type of objects to match against
      Parameters:
      init - a function that, given a reference to the lazy pattern under construction, constructs the subpattern to be wrapped
      Returns:
      a lazy pattern to be initialized using init
      Throws:
      NullPointerException - if init is null