Class AgentElementMatchers


  • public final class AgentElementMatchers
    extends Object
    This class provides some custom ByteBuddy element matchers to use when applying instrumentation.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static net.bytebuddy.matcher.ElementMatcher.Junction<net.bytebuddy.description.type.TypeDescription> extendsClass​(net.bytebuddy.matcher.ElementMatcher<net.bytebuddy.description.type.TypeDescription> matcher)  
      static <T> net.bytebuddy.matcher.ElementMatcher.Junction<T> failSafe​(net.bytebuddy.matcher.ElementMatcher<? super T> matcher, String description)
      Wraps another matcher to assure that an element is not matched in case that the matching causes an Exception.
      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> implementsInterface​(net.bytebuddy.matcher.ElementMatcher<net.bytebuddy.description.type.TypeDescription> matcher)  
      static <T extends net.bytebuddy.description.method.MethodDescription>
      net.bytebuddy.matcher.ElementMatcher.Junction<T>
      methodIsDeclaredByType​(net.bytebuddy.matcher.ElementMatcher<net.bytebuddy.description.type.TypeDescription> matcher)
      Matches method's declaring class against a given type matcher.
      static net.bytebuddy.matcher.ElementMatcher.Junction<net.bytebuddy.description.type.TypeDescription> safeHasSuperType​(net.bytebuddy.matcher.ElementMatcher<net.bytebuddy.description.type.TypeDescription> matcher)  
    • Method Detail

      • extendsClass

        public static net.bytebuddy.matcher.ElementMatcher.Junction<net.bytebuddy.description.type.TypeDescription> extendsClass​(net.bytebuddy.matcher.ElementMatcher<net.bytebuddy.description.type.TypeDescription> matcher)
      • implementsInterface

        public static net.bytebuddy.matcher.ElementMatcher.Junction<net.bytebuddy.description.type.TypeDescription> implementsInterface​(net.bytebuddy.matcher.ElementMatcher<net.bytebuddy.description.type.TypeDescription> matcher)
      • safeHasSuperType

        public static net.bytebuddy.matcher.ElementMatcher.Junction<net.bytebuddy.description.type.TypeDescription> safeHasSuperType​(net.bytebuddy.matcher.ElementMatcher<net.bytebuddy.description.type.TypeDescription> matcher)
      • methodIsDeclaredByType

        public static <T extends net.bytebuddy.description.method.MethodDescription> net.bytebuddy.matcher.ElementMatcher.Junction<T> methodIsDeclaredByType​(net.bytebuddy.matcher.ElementMatcher<net.bytebuddy.description.type.TypeDescription> matcher)
        Matches method's declaring class against a given type matcher.
        Type Parameters:
        T - Type of the matched object
        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.
        Type Parameters:
        T - Type of the matched object
        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.
      • failSafe

        public static <T> net.bytebuddy.matcher.ElementMatcher.Junction<T> failSafe​(net.bytebuddy.matcher.ElementMatcher<? super T> matcher,
                                                                                    String description)
        Wraps another matcher to assure that an element is not matched in case that the matching causes an Exception. Logs exception if it happens.
        Type Parameters:
        T - The type of the matched object.
        Parameters:
        matcher - The element matcher that potentially throws an exception.
        Returns:
        A matcher that returns false in case that the given matcher throws an exception.