Package spoon.pattern.internal.node
Class StringNode
java.lang.Object
spoon.pattern.internal.node.AbstractNode
spoon.pattern.internal.node.StringNode
- All Implemented Interfaces:
Matchers,PrimitiveMatcher,RepeatableMatcher,RootNode
Delivers single String value, which is created by replacing string markers in constant String template
by String value of appropriate parameter.
-
Field Summary
Fields inherited from interface spoon.pattern.internal.node.RootNode
MATCH_ALL, MATCH_PART -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidforEachParameterInfo(BiConsumer<ParameterInfo,RootNode> consumer)Calls consumer for each pair of parameter definition (ParameterInfo) andRootNode, which uses it<T> voidgenerateTargets(DefaultGenerator generator, ResultHolder<T> result, ImmutableMap parameters)Generates zero, one or more target depending on kind of thisRootNode, expected `result` and input `parameters`If twoRepeatableMatchers in a list are matching the same element, then returnedQuantifierdefines how resolve this conflictgetParameterInfo(String replaceMarker)booleanisTryNextMatch(ImmutableMap parameters)matchAllWith(TobeMatched tobeMatched)Matches all matchers of thisMatchersinstance with `targets`matchTarget(Object target, ImmutableMap parameters)matchTargets(TobeMatched targets, Matchers next)booleanreplaceNode(RootNode oldNode, RootNode newNode)Call it to modify Pattern structure.voidsetReplaceMarker(String replaceMarker, ParameterInfo param)Defines that this Substitution request will replace all occurrences of `replaceMarker` in target string by value of `param`static StringNodesetReplaceMarker(RootNode targetNode, String replaceMarker, ParameterInfo param)Applies substring substitution to `targetNode`.toString()Methods inherited from class spoon.pattern.internal.node.AbstractNode
isSimplifyGenerated, setSimplifyGeneratedMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface spoon.pattern.internal.node.RepeatableMatcher
isMandatory, isRepeatableMethods inherited from interface spoon.pattern.internal.node.RootNode
isSimplifyGenerated, matchTargets, setSimplifyGenerated
-
Constructor Details
-
StringNode
-
-
Method Details
-
generateTargets
public <T> void generateTargets(DefaultGenerator generator, ResultHolder<T> result, ImmutableMap parameters)Description copied from interface:RootNodeGenerates zero, one or more target depending on kind of thisRootNode, expected `result` and input `parameters`- Parameters:
generator-Generatorwhich drives generation processresult- holder for the generated objectsparameters- aImmutableMapholding parameters
-
matchTarget
- Parameters:
target- - to be matched elementparameters- will receive the matching parameter values- Returns:
- true if `element` matches with pattern of this matcher
-
getParameterInfo
- Returns:
- The string whose occurrence in target string will be replaced by parameter value
-
setReplaceMarker
Defines that this Substitution request will replace all occurrences of `replaceMarker` in target string by value of `param`- Parameters:
replaceMarker- the substring whose occurrences will be substitutedparam- the declaration of to be replaced parameter
-
getReplaceMarkers
- Returns:
ParameterInfoto replace marker map
-
forEachParameterInfo
Description copied from interface:RootNodeCalls consumer for each pair of parameter definition (ParameterInfo) andRootNode, which uses it- Parameters:
consumer- the receiver of pairs ofParameterInfoandRootNode
-
replaceNode
Description copied from interface:RootNodeCall it to modify Pattern structure. It is actually called mainly by PatternBuilder. TODO: May be we can move this method into some internal interface? -
toString
- Overrides:
toStringin classAbstractNode
-
setReplaceMarker
public static StringNode setReplaceMarker(RootNode targetNode, String replaceMarker, ParameterInfo param)Applies substring substitution to `targetNode`. Converts old node toStringNodeif needed.- Parameters:
targetNode-replaceMarker-param-- Returns:
StringNodewhich contains all the data of origin `targetNode` and new replaceMarker request
-
getMatchingStrategy
Description copied from interface:RepeatableMatcherIf twoRepeatableMatchers in a list are matching the same element, then returnedQuantifierdefines how resolve this conflict- Returns:
Quantifier
-
isTryNextMatch
- 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
Description copied from interface:MatchersMatches all matchers of thisMatchersinstance with `targets`- Specified by:
matchAllWithin interfaceMatchers- Specified by:
matchAllWithin interfaceRootNode- Parameters:
tobeMatched- to be matched target nodes and input parameters- Returns:
TobeMatchedwith targets which remained after allRootNodes were matched + matched parameters
-
matchTargets
- Specified by:
matchTargetsin 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
-