diff --git a/src/main/kotlin/io/emeraldpay/dshackle/upstream/Selector.kt b/src/main/kotlin/io/emeraldpay/dshackle/upstream/Selector.kt index 76170fbe..3e7ebee0 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/upstream/Selector.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/upstream/Selector.kt @@ -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 getMatcher(type: Class): T? { + return matchers.find { type.isAssignableFrom(it.javaClass) } as T? } }