Package eu.bandm.tools.paisley
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 subpatternB- the target type of the right subpatternC- the target type of the containing pattern
- All Implemented Interfaces:
Pattern<C>,Serializable,Cloneable
@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 Summary
FieldsModifier and TypeFieldDescriptionThe left subpattern.The right subpattern. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear(boolean recursively) Disposes of all temporary internal state related to results and nondeterminism.voidcut(boolean recursively) Disposes of all temporary internal state related to nondeterminism.fork()Makes a copy of this pattern with independent internal state.getLeft()Returns the left subpattern.getRight()Returns the right subpattern.Methods inherited from class eu.bandm.tools.paisley.AbstractPattern
clone, doclone
-
Field Details
-
left
The left subpattern. -
right
The right subpattern.
-
-
Constructor Details
-
Binary
Creates a new instance.- Parameters:
left- the left subpatternright- the right subpattern- Throws:
NullPointerException- ifleftorrightis null
-
-
Method Details
-
getLeft
Returns the left subpattern.- Returns:
- the left subpattern
-
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 ofcut(false).This implementation delegates to
leftandrightifrecursivelyistrue.- Parameters:
recursively-trueif all subpatterns should traversed,falseotherwise.
-
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 ofcut(false)is implied.This implementation delegates to
leftandrightifrecursivelyistrue.- Parameters:
recursively-trueif all subpatterns should be traversed,falseotherwise.
-
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
Variablemust be shared. This implies thatVariable.fork()must returnthis. - Fields that do not refer to subpatterns, but to matching
state (changed by invocations of
Pattern.match(A),Pattern.matchAgain(),Pattern.cut()orPattern.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.
- Subpatterns that are instances of
-