Class AgentElementMatchers
java.lang.Object
io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers
This class is a supplement to ByteBuddy's
ElementMatchers
- it
provides some custom matcher implementations that might be useful for instrumentation purposes.-
Method Summary
Modifier and TypeMethodDescriptionstatic net.bytebuddy.matcher.ElementMatcher.Junction<net.bytebuddy.description.type.TypeDescription>
extendsClass
(net.bytebuddy.matcher.ElementMatcher<net.bytebuddy.description.type.TypeDescription> matcher) Matches a type that extends a class (directly or indirectly) that matches the providedmatcher
.static net.bytebuddy.matcher.ElementMatcher.Junction<ClassLoader>
hasClassesNamed
(String... classNames) Matches a class loader that contains all classes that are passed as theclassNames
parameter.static <T extends net.bytebuddy.description.method.MethodDescription>
net.bytebuddy.matcher.ElementMatcher.Junction<T>hasSuperMethod
(net.bytebuddy.matcher.ElementMatcher<? super net.bytebuddy.description.method.MethodDescription> matcher) Matches a method and all its declarations up the class hierarchy including interfaces using provided matcher.static net.bytebuddy.matcher.ElementMatcher.Junction<net.bytebuddy.description.type.TypeDescription>
hasSuperType
(net.bytebuddy.matcher.ElementMatcher<net.bytebuddy.description.type.TypeDescription> matcher) Matches a type that extends or implements a type (directly or indirectly) that matches the providedmatcher
.static net.bytebuddy.matcher.ElementMatcher.Junction<net.bytebuddy.description.type.TypeDescription>
implementsInterface
(net.bytebuddy.matcher.ElementMatcher<net.bytebuddy.description.type.TypeDescription> matcher) Matches a type that implements an interface (directly or indirectly) that matches the providedmatcher
.static <T extends net.bytebuddy.description.method.MethodDescription>
net.bytebuddy.matcher.ElementMatcher.Junction<T>methodIsDeclaredByType
(net.bytebuddy.matcher.ElementMatcher<? super net.bytebuddy.description.type.TypeDescription> matcher) Matches method's declaring class against a given type matcher.
-
Method Details
-
extendsClass
public static net.bytebuddy.matcher.ElementMatcher.Junction<net.bytebuddy.description.type.TypeDescription> extendsClass(net.bytebuddy.matcher.ElementMatcher<net.bytebuddy.description.type.TypeDescription> matcher) Matches a type that extends a class (directly or indirectly) that matches the providedmatcher
.The returned matcher will not throw anything when walking the type hierarchy fails; instead it will return
false
for the passed type description. -
implementsInterface
public static net.bytebuddy.matcher.ElementMatcher.Junction<net.bytebuddy.description.type.TypeDescription> implementsInterface(net.bytebuddy.matcher.ElementMatcher<net.bytebuddy.description.type.TypeDescription> matcher) Matches a type that implements an interface (directly or indirectly) that matches the providedmatcher
.The returned matcher will not throw anything when walking the type hierarchy fails; instead it will return
false
for the passed type description. -
hasSuperType
public static net.bytebuddy.matcher.ElementMatcher.Junction<net.bytebuddy.description.type.TypeDescription> hasSuperType(net.bytebuddy.matcher.ElementMatcher<net.bytebuddy.description.type.TypeDescription> matcher) Matches a type that extends or implements a type (directly or indirectly) that matches the providedmatcher
.The returned matcher will not throw anything when walking the type hierarchy fails; instead it will return
false
for the passed type description. -
methodIsDeclaredByType
public static <T extends net.bytebuddy.description.method.MethodDescription> net.bytebuddy.matcher.ElementMatcher.Junction<T> methodIsDeclaredByType(net.bytebuddy.matcher.ElementMatcher<? super net.bytebuddy.description.type.TypeDescription> matcher) Matches method's declaring class against a given type matcher.- Parameters:
matcher
- type matcher to match method's declaring type against.- Returns:
- a matcher that matches method's declaring class against a given type matcher.
-
hasSuperMethod
public static <T extends net.bytebuddy.description.method.MethodDescription> net.bytebuddy.matcher.ElementMatcher.Junction<T> hasSuperMethod(net.bytebuddy.matcher.ElementMatcher<? super net.bytebuddy.description.method.MethodDescription> matcher) Matches a method and all its declarations up the class hierarchy including interfaces using provided matcher.- Parameters:
matcher
- method matcher to apply to method declarations up the hierarchy.- Returns:
- A matcher that matches a method and all its declarations up the class hierarchy including interfaces.
-
hasClassesNamed
public static net.bytebuddy.matcher.ElementMatcher.Junction<ClassLoader> hasClassesNamed(String... classNames) Matches a class loader that contains all classes that are passed as theclassNames
parameter. Does not match the bootstrap classpath. Don't use this matcher with classes expected to be on the bootstrap.In the event no class names are passed at all, the matcher will always return
true
.- Parameters:
classNames
- list of class names to match.
-