Package eu.bandm.tools.paisley
Class CachedTransform<A,B>
java.lang.Object
eu.bandm.tools.paisley.Pattern<B>
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
Modifier and TypeClassDescriptionstatic class
Indicates 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
ModifierConstructorDescriptionprotected
CachedTransform
(Pattern<? super B> body) Creates a new pattern. -
Method Summary
Modifier and TypeMethodDescriptionTransforms a target to be matched into a target for the subpattern.void
clear
(boolean recursively) Disposes of all internal state related to results and nondeterminism.final boolean
final boolean
Attempts to match this pattern against a given object.protected abstract B
Checks whether a target can be transformed and transforms it.Methods inherited from class eu.bandm.tools.paisley.RestrictedTransform
compileIsDomain, compileIsRange, compileMatch, compileMatchAgain, isRange, matchAgain
Methods inherited from class eu.bandm.tools.paisley.Transform
compileApply
Methods inherited from class eu.bandm.tools.paisley.Unary
binds, clone, compileClear, compileCut, cut, getBody, isDeterministic, preserves, preserves, setBody, toString
Methods 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, 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:
match
in classRestrictedTransform<A,
B> - Parameters:
target
- the object to match against- Returns:
true
if the matching is successful,false
if it fails. WhichVariable
s are bound by a successful or failed match depends.- See Also:
-
isDomain
This implementation calls
tryApply(A)
and caches the result.- Overrides:
isDomain
in 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.body
to 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:Pattern
Disposes of all internal state related to results and nondeterminism.The default implementation does nothing.
-