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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • protectedBlock

      public boolean protectedBlock​(@NotNull @NotNull PatternRunnable block)
      Executes a proctected block during a pattern match.

      block is executed. If block executes successfully, protectedBlock returns true. If block throws a PatternMatchReject exception (by calling Pattern.reject()) then protectedBlock returns false 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 if block succeeded, false if block threw a PatternMatchReject exception