A
- the target type of the delegate patternpublic abstract class Adaptive<A> extends Pattern<A>
Modifier | Constructor and Description |
---|---|
protected |
Adaptive()
Creates a new pattern.
|
Modifier and Type | Method and Description |
---|---|
void |
clear(boolean recursively)
Disposes of all internal state related to results and
nondeterminism.
|
Pattern<A> |
clone()
Makes a matching-state copy if this pattern.
|
void |
cut(boolean recursively)
Disposes of all internal state related to nondeterminism.
|
protected abstract Pattern<? super A> |
delegate(A target) |
boolean |
match(A target)
Attempts to match this pattern against a given object.
|
boolean |
matchAgain()
Attempts to re-match this pattern against a previously matched
object.
|
all, all, all, all, all, and, andThen, andThen, any, any, aside, binds, both, clear, compareTo, compile, compileClear, compileClear, compileCut, compileCut, compileIsDeterministic, compileMatch, compileMatchAgain, compileSubPattern, compileThis, compileUpTo, cut, DEBUG, either, enPassant, eq, eqNull, equal, filter, flatten, forInstancesOf, isDeterministic, limit, main, matchOnce, matchVar, narrow, neq, neqNull, newAll, noMatch, none, or, orElse, orElse, preserves, preserves, repeat, some, some, some, some, someMatch, startCompile, test, transform, uniquely, variable, variable
public Pattern<A> clone()
Pattern
Subclasses must override this method if necessary to honour the following rules for all transitively reachable patterns:
Variable
must
be shared. This implies that Variable.clone()
must
return this
.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.this
.public boolean match(A target)
Pattern
match
in class Pattern<A>
target
- the object to match againsttrue
if the matching is successful, false
if it fails. Which Variable
s are bound by a
successful or failed match depends.Pattern.binds(Variable)
,
Pattern.preserves(Variable, boolean)
public boolean matchAgain()
Pattern
Patterns classes that do not override this method are
deterministic. Pattern classes that overwrite this method to
provide additional matches should also override Pattern.isDeterministic()
.
matchAgain
in class Pattern<A>
true
if the matching is successful, false
if it fails. Which Variable
s are bound by a
successful match depends. The default implementation
always returns false
.Pattern.binds(Variable)
,
Pattern.preserves(Variable, boolean)
public void cut(boolean recursively)
Pattern
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)
.
public void clear(boolean recursively)
Pattern
The default implementation does nothing.
see also the complete user documentation .