Package de.unruh.javapatterns
Class MatchManager
java.lang.Object
de.unruh.javapatterns.MatchManager
public final class MatchManager
extends java.lang.Object
Manages the state of captured variables in a pattern match.
This class should never be used outside of Pattern.apply(de.unruh.javapatterns.MatchManager, T)
, see there.
-
Method Summary
Modifier and Type Method Description boolean
protectedBlock(@NotNull PatternRunnable block)
Executes a proctected block during a pattern match.
-
Method Details
-
protectedBlock
Executes a proctected block during a pattern match.block
is executed. Ifblock
executes successfully,protectedBlock
returnstrue
. Ifblock
throws aPatternMatchReject
exception (by callingPattern.reject()
) thenprotectedBlock
returnsfalse
and resets all captured variables to their state at the beginning of the invocation.- Parameters:
block
- a lambda expression of the form() -> ...
. The code to be executed.- Returns:
true
ifblock
succeeded,false
ifblock
threw aPatternMatchReject
exception
-