Package spoon.pattern.internal.node
Class ConstantNode<T>
- java.lang.Object
-
- spoon.pattern.internal.node.AbstractNode
-
- spoon.pattern.internal.node.ConstantNode<T>
-
- All Implemented Interfaces:
Matchers
,PrimitiveMatcher
,RepeatableMatcher
,RootNode
public class ConstantNode<T> extends AbstractNode
Generates/Matches a copy of single template object
-
-
Field Summary
Fields Modifier and Type Field Description protected T
template
-
Fields inherited from interface spoon.pattern.internal.node.RootNode
MATCH_ALL, MATCH_PART
-
-
Constructor Summary
Constructors Constructor Description ConstantNode(T template)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
forEachParameterInfo(BiConsumer<ParameterInfo,RootNode> consumer)
Calls consumer for each pair of parameter definition (ParameterInfo
) andRootNode
, which uses it<U> void
generateTargets(DefaultGenerator generator, ResultHolder<U> result, ImmutableMap parameters)
Generates zero, one or more target depending on kind of thisRootNode
, expected `result` and input `parameters`Quantifier
getMatchingStrategy()
If twoRepeatableMatcher
s in a list are matching the same element, then returnedQuantifier
defines how resolve this conflictT
getTemplateNode()
boolean
isTryNextMatch(ImmutableMap parameters)
TobeMatched
matchAllWith(TobeMatched tobeMatched)
Matches all matchers of thisMatchers
instance with `targets`ImmutableMap
matchTarget(Object target, ImmutableMap parameters)
TobeMatched
matchTargets(TobeMatched targets, Matchers next)
boolean
replaceNode(RootNode oldNode, RootNode newNode)
Call it to modify Pattern structure.String
toString()
-
Methods inherited from class spoon.pattern.internal.node.AbstractNode
isSimplifyGenerated, setSimplifyGenerated
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface spoon.pattern.internal.node.RepeatableMatcher
isMandatory, isRepeatable
-
Methods inherited from interface spoon.pattern.internal.node.RootNode
isSimplifyGenerated, matchTargets, setSimplifyGenerated
-
-
-
-
Field Detail
-
template
protected final T template
-
-
Constructor Detail
-
ConstantNode
public ConstantNode(T template)
-
-
Method Detail
-
getTemplateNode
public T getTemplateNode()
-
replaceNode
public boolean replaceNode(RootNode oldNode, RootNode newNode)
Description copied from interface:RootNode
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?
-
forEachParameterInfo
public void forEachParameterInfo(BiConsumer<ParameterInfo,RootNode> consumer)
Description copied from interface:RootNode
Calls consumer for each pair of parameter definition (ParameterInfo
) andRootNode
, which uses it- Parameters:
consumer
- the receiver of pairs ofParameterInfo
andRootNode
-
generateTargets
public <U> void generateTargets(DefaultGenerator generator, ResultHolder<U> result, ImmutableMap parameters)
Description copied from interface:RootNode
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
-
matchTarget
public ImmutableMap matchTarget(Object target, ImmutableMap parameters)
- Parameters:
target
- - to be matched elementparameters
- will receive the matching parameter values- Returns:
- true if `element` matches with pattern of this matcher
-
toString
public String toString()
- Overrides:
toString
in classAbstractNode
-
getMatchingStrategy
public Quantifier getMatchingStrategy()
Description copied from interface:RepeatableMatcher
If twoRepeatableMatcher
s in a list are matching the same element, then returnedQuantifier
defines how resolve this conflict- Returns:
Quantifier
-
isTryNextMatch
public boolean isTryNextMatch(ImmutableMap parameters)
- Parameters:
parameters
- matching parameters- Returns:
- true if this ValueResolver should be processed again to match next target in the state defined by current `parameters`.
-
matchAllWith
public TobeMatched matchAllWith(TobeMatched tobeMatched)
Description copied from interface:Matchers
Matches all matchers of thisMatchers
instance with `targets`- Specified by:
matchAllWith
in interfaceMatchers
- Specified by:
matchAllWith
in interfaceRootNode
- Parameters:
tobeMatched
- to be matched target nodes and input parameters- Returns:
TobeMatched
with targets which remained after allRootNode
s were matched + matched parameters
-
matchTargets
public TobeMatched matchTargets(TobeMatched targets, Matchers next)
- Specified by:
matchTargets
in interfaceRootNode
- Parameters:
targets
- to be matched target nodes and input parametersnext
- Chain of matchers which has to be processed after thisRootNode
- Returns:
- new parameters and container with remaining targets
-
-