Class Binary<A,B,C>

java.lang.Object
eu.bandm.tools.paisley.AbstractPattern<C>
eu.bandm.tools.paisley.Binary<A,B,C>
Type Parameters:
A - the target type of the left subpattern
B - the target type of the right subpattern
C - the target type of the containing pattern
All Implemented Interfaces:
Pattern<C>, Serializable, Cloneable
Direct Known Subclasses:
Both, Either

@Generated(generator="eu.bandm.tools.expander", version="", timestamp="2026-01-12T17:56:29") public abstract class Binary<A,B,C> extends AbstractPattern<C>
Abstract base class for patterns that contain two subpatterns. Subpatterns are called left and right, in the sense of the operands of a binary operator. Some methods have default implementations that delegate to the subpatterns.

Subclasses must implement the Pattern.match(A) method.

See Also:
  • Field Details

    • left

      Pattern<A> left
      The left subpattern.
  • Constructor Details

    • Binary

      protected Binary(Pattern<? super A> left, Pattern<? super B> right)
      Creates a new instance.
      Parameters:
      left - the left subpattern
      right - the right subpattern
      Throws:
      NullPointerException - if left or right is null
  • Method Details

    • getLeft

      public final Pattern<A> getLeft()
      Returns the left subpattern.
      Returns:
      the left subpattern
    • getRight

      public final Pattern<B> getRight()
      Returns the right subpattern.
      Returns:
      the right subpattern
    • cut

      public void cut(boolean recursively)
      Disposes of all temporary internal state related to nondeterminism.

      The default implementation does nothing. Subclasses that override this method should also override Pattern.clear(boolean) and ensure that it implies the effect of cut(false).

      This implementation delegates to left and right if recursively is true.

      Parameters:
      recursively - true if all subpatterns should traversed, false otherwise.
    • clear

      public void clear(boolean recursively)
      Disposes of all temporary internal state related to results and nondeterminism.

      The default implementation just invokes cut(false). Subclasses that override this method should either invoke this overridden implementation, or ensure by other means that the effect of cut(false) is implied.

      This implementation delegates to left and right if recursively is true.

      Parameters:
      recursively - true if all subpatterns should be traversed, false otherwise.
    • fork

      public Pattern<C> fork()
      Makes a copy of this pattern with independent internal state.

      Subclasses must override this method if necessary to honour the following rules for all transitively reachable patterns:

      • Subpatterns that are instances of Variable must be shared. This implies that Variable.fork() must return this.
      • Fields that do not refer to subpatterns, but to matching state (changed by invocations of Pattern.match(A), Pattern.matchAgain(), Pattern.cut() or Pattern.clear()) must be duplicated. If matching state changes are effected by modification of other objects, these must be duplicated. In summary, matching operations on this pattern and its copy must not interfere, with the exception of variable bindings.
      • Fields neither referring to subpatterns nor to matching state may be either shared or duplicated. The usage of such fields in a modifiable way (such that the distinction is relevant) is strongly deprecated.
      • Patterns whose fields need not be duplicated need not be duplicated themselves, but may return this.
      Specified by:
      fork in interface Pattern<A>
      Overrides:
      fork in class AbstractPattern<C>
      Returns:
      a copy of this pattern that has independent internal state, except for variables