Package eu.bandm.tools.paisley
Class CachedTransform<A,B>
java.lang.Object
eu.bandm.tools.paisley.Pattern<A>
eu.bandm.tools.paisley.Unary<B,A>
eu.bandm.tools.paisley.Transform<A,B>
eu.bandm.tools.paisley.RestrictedTransform<A,B>
eu.bandm.tools.paisley.CachedTransform<A,B>
- Type Parameters:
A- the target type of the containing patternB- the target type of the contained subpattern
- All Implemented Interfaces:
Serializable,Cloneable
Abstract base class for patterns that delegate expensively
transformed targets to a subpattern. If a subclass of
Transform has expensive computations shared between
{ link Pattern#isApplicable{
FIXME "isApplicable" NOT FOUND SONAR-BT
and apply(A), consider subclassing CachedTransform instead.
Subclasses must implement the tryApply(A) method.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classIndicates that a target can not be transformed.Nested classes/interfaces inherited from class eu.bandm.tools.paisley.Pattern
Pattern.Either<A> -
Field Summary
Fields inherited from class eu.bandm.tools.paisley.Pattern
_left_matched, _target_save, none -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCachedTransform(Pattern<? super B> body) Creates a new pattern. -
Method Summary
Modifier and TypeMethodDescriptionTransforms a target to be matched into a target for the subpattern.voidclear(boolean recursively) Disposes of all internal state related to results and nondeterminism.final booleanfinal booleanAttempts to match this pattern against a given object.protected abstract BChecks whether a target can be transformed and transforms it.Methods inherited from class eu.bandm.tools.paisley.RestrictedTransform
compileIsDomain, compileIsRange, compileMatch, compileMatchAgain, isRange, matchAgainMethods inherited from class eu.bandm.tools.paisley.Transform
compileApplyMethods inherited from class eu.bandm.tools.paisley.Unary
binds, clone, compileClear, compileCut, cut, getBody, isDeterministic, preserves, preserves, setBody, toStringMethods inherited from class eu.bandm.tools.paisley.Pattern
all, all, all, all, all, and, andThen, andThen, any, aside, both, clear, compile, compileClear, compileCut, compileIsDeterministic, compileSubPattern, compileThis, compileUpTo, cut, DEBUG, either, enPassant, flatten, limit, main, matchOnce, matchVar, narrow, newAll, noMatch, none, of, once, or, orElse, orElse, repeat, some, some, some, some, someMatch, startCompile, uniquely, variable, variable
-
Constructor Details
-
CachedTransform
Creates a new pattern.
-
-
Method Details
-
match
Attempts to match this pattern against a given object. If the class of this pattern imposes a specific order on matches, the first one is chosen.- Overrides:
matchin classRestrictedTransform<A,B> - Parameters:
target- the object to match against- Returns:
trueif the matching is successful,falseif it fails. WhichVariables are bound by a successful or failed match depends.- See Also:
-
isDomain
This implementation calls
tryApply(A)and caches the result.- Overrides:
isDomainin classRestrictedTransform<A,B>
-
tryApply
Checks whether a target can be transformed and transforms it.- Parameters:
target- the object to be matched against.- Returns:
- a target for
Unary.bodyto be matched against. - Throws:
CachedTransform.ApplyException- if the target can not be transformed.
-
apply
Transforms a target to be matched into a target for the subpattern.This implementation returns the result cached by link Pattern#isApplicable()}. FIXME NOT FOUND SONAR-BT
-
clear
public void clear(boolean recursively) Description copied from class:UnaryDisposes of all internal state related to results and nondeterminism.The default implementation does nothing. The default implementation invokes
cut(false), and delegates toUnary.bodyifrecursivelyistrue.
-