public class EnumBranch<A,E extends Enum<E>> extends Pattern<A>
| Constructor and Description |
|---|
EnumBranch(Class<E> cls) |
EnumBranch(EnumMap<E,? extends Pattern<? super A>> map) |
EnumBranch(Map<E,? extends Pattern<? super A>> map) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
binds(Variable<?> v)
Checks whether a variable is bound by this pattern.
|
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.
|
E |
getKey() |
boolean |
isDeterministic()
Checks whether this pattern is deterministic.
|
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.
|
boolean |
preserves(Variable<?> v)
Checks whether a variable is preserved by this pattern,
unconditionally.
|
boolean |
preserves(Variable<?> v,
boolean success)
Checks whether a variable is preserved by this pattern,
conditionally on success or failure.
|
EnumBranch<A,E> |
put(E key,
Pattern<? super A> pattern) |
all, all, all, all, all, and, andThen, andThen, any, any, aside, both, clear, compareTo, compile, compileClear, compileClear, compileCut, compileCut, compileIsDeterministic, compileMatch, compileMatchAgain, compileSubPattern, compileThis, compileUpTo, cut, DEBUG, either, enPassant, eq, eqNull, equal, filter, flatten, forInstancesOf, limit, main, matchOnce, matchVar, narrow, neq, neqNull, newAll, noMatch, none, or, orElse, orElse, repeat, some, some, some, some, someMatch, startCompile, test, transform, uniquely, variable, variablepublic E getKey()
public boolean match(A target)
Patternmatch in class Pattern<A>target - the object to match againsttrue if the matching is successful, false if it fails. Which Variables are bound by a
successful or failed match depends.Pattern.binds(Variable),
Pattern.preserves(Variable, boolean)public boolean matchAgain()
PatternPatterns 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 Variables 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)
PatternThe 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)
PatternThe default implementation does nothing.
public boolean binds(Variable<?> v)
PatternThe default implementation returns false.
public boolean preserves(Variable<?> v, boolean success)
PatternThe default implementation returns false.
public boolean preserves(Variable<?> v)
PatternThe default implementation returns false.
public boolean isDeterministic()
PatternThe default implementation returns true.
isDeterministic in class Pattern<A>true if this pattern is guaranteed to match any
object at most once, false otherwise.Pattern.matchAgain()public Pattern<A> clone()
PatternSubclasses 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.see also the complete user documentation .