solution: debug utility to extract method from matcher

This commit is contained in:
Igor Artamonov
2019-09-05 00:31:10 -04:00
parent fbc6e5588b
commit ead9cb2c77

View File

@@ -59,7 +59,18 @@ class Selector {
return matcher
}
if (matcher is MultiMatcher) {
return matcher.getLabelMatcher()
return matcher.getMatcher(LabelSelectorMatcher::class.java)
}
return null
}
@JvmStatic
fun extractMethod(matcher: Matcher): MethodMatcher? {
if (matcher is MethodMatcher) {
return matcher
}
if (matcher is MultiMatcher) {
return matcher.getMatcher(MethodMatcher::class.java)
}
return null
}
@@ -94,8 +105,8 @@ class Selector {
return matchers.all { it.matches(up) }
}
fun getLabelMatcher(): LabelSelectorMatcher? {
return matchers.find { it is LabelSelectorMatcher } as LabelSelectorMatcher?
fun <T: Matcher> getMatcher(type: Class<T>): T? {
return matchers.find { type.isAssignableFrom(it.javaClass) } as T?
}
}