Package spoon.pattern.internal.node
Class SwitchNode
java.lang.Object
spoon.pattern.internal.node.AbstractNode
spoon.pattern.internal.node.SwitchNode
- All Implemented Interfaces:
Matchers,InlineNode,RootNode
List of conditional cases
{code}
if (a) {
... someStatements if a == true..
} else if (b) {
... someStatements if b == true..
} else {
... someStatements in other cases ...
}
-
Field Summary
Fields inherited from interface spoon.pattern.internal.node.RootNode
MATCH_ALL, MATCH_PART -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCase(PrimitiveMatcher vrOfExpression, RootNode statement)Adds another case into this switch statementvoidforEachParameterInfo(BiConsumer<ParameterInfo,RootNode> consumer)Calls consumer for each pair of parameter definition (ParameterInfo) andRootNode, which uses it<T> voidgenerateInlineTargets(DefaultGenerator generator, ResultHolder<T> result, ImmutableMap parameters)Generates inline statements of this inlineRootNode.<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`matchTargets(TobeMatched targets, Matchers nextMatchers)booleanreplaceNode(RootNode oldNode, RootNode newNode)Call it to modify Pattern structure.Methods inherited from class spoon.pattern.internal.node.AbstractNode
isSimplifyGenerated, setSimplifyGenerated, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface spoon.pattern.internal.node.RootNode
isSimplifyGenerated, matchAllWith, setSimplifyGenerated
-
Constructor Details
-
SwitchNode
public SwitchNode()
-
-
Method Details
-
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?- Specified by:
replaceNodein interfaceRootNode- Parameters:
oldNode- oldRootNodenewNode- newRootNode- Returns:
- a true if `oldNode` was found in this
RootNodeor it's children and replaced by `newNode` false if `oldNode` was not found
-
addCase
Adds another case into this switch statement- Parameters:
vrOfExpression- if value of this parameter is true then statement has to be used. If vrOfExpression is null, then statement is always usedstatement- optional statement
-
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`- Specified by:
generateTargetsin interfaceRootNode- Parameters:
generator-Generatorwhich drives generation processresult- holder for the generated objectsparameters- aImmutableMapholding parameters
-
forEachParameterInfo
Description copied from interface:RootNodeCalls consumer for each pair of parameter definition (ParameterInfo) andRootNode, which uses it- Specified by:
forEachParameterInfoin interfaceRootNode- Parameters:
consumer- the receiver of pairs ofParameterInfoandRootNode
-
matchTargets
- Specified by:
matchTargetsin interfaceRootNode- 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
-
generateInlineTargets
public <T> void generateInlineTargets(DefaultGenerator generator, ResultHolder<T> result, ImmutableMap parameters)Description copied from interface:InlineNodeGenerates inline statements of this inlineRootNode. This method is used when sources of pattern have to be printed- Specified by:
generateInlineTargetsin interfaceInlineNode- Parameters:
generator- a to be usedGeneratorresult- holder of the resultparameters- aImmutableMapwith current parameters
-