Package spoon.pattern.internal.matcher
Class TobeMatched
java.lang.Object
spoon.pattern.internal.matcher.TobeMatched
Describes what next has to be matched.
It consists of current `parameters` represented by
ImmutableMap
and by a to be matched target elements.
See children of TobeMatched
for supported collections of target elements.-
Method Summary
Modifier and TypeMethodDescriptioncopyAndSetParams(ImmutableMap newParams)
Makes a copy of this match context with the same targets, but with new `parameters`static TobeMatched
create(ImmutableMap parameters, ContainerKind containerKind, Object target)
static @Nullable ImmutableMap
getMatchedParameters(TobeMatched remainingMatch)
List<?>
getMatchedTargets(TobeMatched tobeMatchedTargets)
List<?>
boolean
@Nullable TobeMatched
matchNext(BiFunction<Object,ImmutableMap,ImmutableMap> matcher)
Calls matcher algorithm to match target itemremoveTarget(int idxOfTobeRemovedTarget)
removeTarget(ImmutableMap parameters, int idxOfTobeRemovedTarget)
toString()
-
Method Details
-
create
public static TobeMatched create(ImmutableMap parameters, ContainerKind containerKind, Object target)- Parameters:
parameters
- to be matched parameterscontainerKind
- the type of container in `target` valuetarget
- the to be matched target data. List, Set, Map or single value- Returns:
- new instance of
TobeMatched
, which contains `parameters` and `target` mapped using containerKind
-
getParameters
- Returns:
- parameters of last successful match.
-
getTargets
- Returns:
List
of to be matched targets, which A) have to be matched by current matching step B) remained after matching of all template nodes
-
getMatchedTargets
- Parameters:
tobeMatchedTargets
-TobeMatched
with targets, which didn't matched yet. These which has to be matched next.- Returns:
- matched targets. It means these targets, which are not contained in `notMatchedTargets`
-
hasTargets
public boolean hasTargets()- Returns:
- true if there is anything to match.
-
copyAndSetParams
Makes a copy of this match context with the same targets, but with new `parameters`- Parameters:
newParams
- to be used parameters- Returns:
- copy of
TobeMatched
with new parameters
-
matchNext
Calls matcher algorithm to match target item- Parameters:
matcher
- a matching algorithm- Returns:
TobeMatched
with List of remaining (to be matched) targets or null if there is no match
-
getMatchedParameters
- Parameters:
remainingMatch
- theTobeMatched
whose parameters has to be returned- Returns:
- parameters from `remainingMatch`, if it exists. Else returns null
-
removeTarget
- Parameters:
idxOfTobeRemovedTarget
- index of to be removed target- Returns:
- new
TobeMatched
without the target on the index `idxOfTobeRemovedTarget`
-
removeTarget
-
toString
-