Package spoon.pattern.internal.node
Interface RootNode
- All Superinterfaces:
Matchers
- All Known Subinterfaces:
InlineNode
,PrimitiveMatcher
,RepeatableMatcher
- All Known Implementing Classes:
AbstractNode
,ConstantNode
,ElementNode
,ForEachNode
,ListOfNodes
,MapEntryNode
,ParameterNode
,StringNode
,SwitchNode
Represents a parameterized Pattern ValueResolver, which can be used
- to generate a zero, one or more copies of model using provided parameters
- to match zero, one or more instances of model and deliver a matching parameters
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
forEachParameterInfo(BiConsumer<ParameterInfo,RootNode> consumer)
Calls consumer for each pair of parameter definition (ParameterInfo
) andRootNode
, which uses it<T> void
generateTargets(DefaultGenerator generator, ResultHolder<T> result, ImmutableMap parameters)
Generates zero, one or more target depending on kind of thisRootNode
, expected `result` and input `parameters`boolean
default TobeMatched
matchAllWith(TobeMatched targets)
Matches all matchers of thisMatchers
instance with `targets`matchTargets(TobeMatched targets, Matchers nextMatchers)
boolean
replaceNode(RootNode oldNode, RootNode newNode)
Call it to modify Pattern structure.void
setSimplifyGenerated(boolean simplifyGenerated)
-
Field Details
-
MATCH_ALL
-
MATCH_PART
-
-
Method Details
-
forEachParameterInfo
Calls consumer for each pair of parameter definition (ParameterInfo
) andRootNode
, which uses it- Parameters:
consumer
- the receiver of pairs ofParameterInfo
andRootNode
-
generateTargets
<T> void generateTargets(DefaultGenerator generator, ResultHolder<T> result, ImmutableMap parameters)Generates zero, one or more target depending on kind of thisRootNode
, expected `result` and input `parameters`- Parameters:
generator
-Generator
which drives generation processresult
- holder for the generated objectsparameters
- aImmutableMap
holding parameters
-
isSimplifyGenerated
boolean isSimplifyGenerated()- Returns:
- true if generated result has to be evaluated to apply simplifications. e.g. ("a" + "b") id simplified to "ab"
-
setSimplifyGenerated
void setSimplifyGenerated(boolean simplifyGenerated)- Parameters:
simplifyGenerated
- true if generated result of thisRootNode
has to be evaluated to apply simplifications.
-
matchTargets
- Parameters:
targets
- to be matched target nodes and input parametersnextMatchers
- Chain of matchers which has to be processed after thisRootNode
- Returns:
- new parameters and container with remaining targets
-
matchAllWith
Description copied from interface:Matchers
Matches all matchers of thisMatchers
instance with `targets`- Specified by:
matchAllWith
in interfaceMatchers
- Parameters:
targets
- to be matched target nodes and input parameters- Returns:
TobeMatched
with targets which remained after allRootNode
s were matched + matched parameters
-
replaceNode
Call it to modify Pattern structure. It is actually called mainly by PatternBuilder. TODO: May be we can move this method into some internal interface?
-