Class Binary<A,B,C>

java.lang.Object
eu.bandm.tools.paisley.Pattern<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:
Serializable, Cloneable
Direct Known Subclasses:
Pattern.Either

public abstract class Binary<A,B,C> extends Pattern<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

  • Method Details

    • getLeft

      public final Pattern<A> getLeft()
    • getRight

      public final Pattern<B> getRight()
    • cut

      public void cut(boolean recursively)
      Description copied from class: Pattern
      Disposes of all 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).

      Overrides:
      cut in class Pattern<C>
      Parameters:
      recursively - true if all subpatterns should be deactivated, false otherwise.
    • clear

      public void clear(boolean recursively)
      Description copied from class: Pattern
      Disposes of all internal state related to results and nondeterminism.

      The default implementation does nothing.

      Overrides:
      clear in class Pattern<C>
      Parameters:
      recursively - true if all subpatterns should be deactivated, false otherwise.
    • clone

      public Pattern<C> clone()
      Description copied from class: Pattern
      Makes a matching-state copy if this pattern.

      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.clone() 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.
      Overrides:
      clone in class Pattern<C>
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toStringOperator

      protected String toStringOperator()
    • compileMatch

      protected void compileMatch(CompilationContext context)
      Overrides:
      compileMatch in class Pattern<C>
    • compileMatchAgain

      protected void compileMatchAgain(CompilationContext context)
      Overrides:
      compileMatchAgain in class Pattern<C>
    • compileCut

      protected void compileCut(CompilationContext context, boolean recursively)
      Overrides:
      compileCut in class Pattern<C>
    • compileClear

      protected void compileClear(CompilationContext context, boolean recursively)
      Overrides:
      compileClear in class Pattern<C>