Package spoon.pattern
Class Match
java.lang.Object
spoon.pattern.Match
Represents a single match of
Pattern-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T> TgetMatchingElement(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:
Listof elements, which match to the Pattern. UsegetMatchingElement()if thePatternmatches single root element. But whenPatterncontains 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
Listtyped to `clazz` or throwsSpoonExceptionif Pattern matched different elements
-
getMatchingElement
- Returns:
- a matching element of a
PatternIt fails ifPatternis 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:
ImmutableMapwith values ofPatternparameters, which fits to current match
-
getParametersMap
-
toString
-