Package eu.bandm.tools.paisley
Class Lazy<A>
java.lang.Object
eu.bandm.tools.paisley.AbstractPattern<A>
eu.bandm.tools.paisley.Unary<A,A>
eu.bandm.tools.paisley.Proxy<A>
eu.bandm.tools.paisley.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:
-
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetBody()Returns the contained subpattern.init()Creates the wrapped pattern.booleanChecks whether this pattern is deterministic.booleanChecks whether the wrapped pattern has been initialized.static <A> Lazy<A> Returns a new instance that uses the given initializer.static <A> Lazy<A> Returns a new instance that uses the given initializer.Methods inherited from class eu.bandm.tools.paisley.Unary
binds, clear, cut, fork, matchAgain, preserves, preserves, setBodyMethods inherited from class eu.bandm.tools.paisley.AbstractPattern
clone
-
Constructor Details
-
Lazy
protected Lazy()Creates a new instance.
-
-
Method Details
-
getBody
Returns the contained subpattern.This implementation initializes the wrapped subpattern lazily.
-
isInitialized
public boolean isInitialized()Checks whether the wrapped pattern has been initialized.- Returns:
trueif the wrapped pattern has been initialized,falseotherwise
-
isDeterministic
public boolean isDeterministic()Checks whether this pattern is deterministic.The default implementation returns
false. This implementation delegates toUnary.body.This implementation always returns
false, since the wrapped subpattern is unknown.- Specified by:
isDeterministicin interfacePattern<A>- Overrides:
isDeterministicin classUnary<A,A> - Returns:
trueif this pattern is guaranteed to match any object at most once,falseotherwise.- See Also:
-
init
Creates the wrapped pattern.- Returns:
- the wrapped pattern; must not be null
-
of
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- ifinitis 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- ifinitis null
-