Package spoon.pattern
Class Match
java.lang.Object
spoon.pattern.Match
Represents a single match of
Pattern
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescription<T> T
getMatchingElement(Class<T> clazz)
Same likegetMatchingElement()
, but checks that matching element is expected class and casts returned value to that type<T> List<T>
getMatchingElements(Class<T> clazz)
Same likegetMatchingElement()
but additionally it checks that each matching element is instance of `clazz`toString()
-
Constructor Details
-
Match
-
-
Method Details
-
getMatchingElements
- Returns:
List
of elements, which match to the Pattern. UsegetMatchingElement()
if thePattern
matches single root element. But whenPattern
contains sequence of root elements, then this is the right way how to get them all
-
getMatchingElements
Same likegetMatchingElement()
but additionally it checks that each matching element is instance of `clazz`- Parameters:
clazz
- the required type of all elements.- Returns:
- a
List
typed to `clazz` or throwsSpoonException
if Pattern matched different elements
-
getMatchingElement
- Returns:
- a matching element of a
Pattern
It fails ifPattern
is designed to match sequence of elements. In such case usegetMatchingElements()
-
getMatchingElement
Same likegetMatchingElement()
, but checks that matching element is expected class and casts returned value to that type- Parameters:
clazz
- required type- Returns:
- matched element cast to `clazz`
-
getParameters
- Returns:
ImmutableMap
with values ofPattern
parameters, which fits to current match
-
getParametersMap
-
toString
-