Class MethodScope

  • All Implemented Interfaces:
    Scope

    public final class MethodScope
    extends Object
    implements Scope
    Scope limited to methods matching a pattern or signature.
    • Constructor Detail

      • MethodScope

        public MethodScope​(String pattern,
                           boolean isRegex)
        Creates a method scope.
        Parameters:
        pattern - the method signature or regex to match
        isRegex - whether pattern is a regular expression
    • Method Detail

      • pattern

        public String pattern()
        Returns:
        the method signature or regex pattern
      • isRegex

        public boolean isRegex()
        Returns:
        whether the pattern is a regular expression
      • exact

        public static MethodScope exact​(String signature)
        Creates a scope matching one exact method signature.
        Parameters:
        signature - the method signature to match
        Returns:
        the exact-signature scope
      • regex

        public static MethodScope regex​(String pattern)
        Creates a scope matching method signatures against a regex.
        Parameters:
        pattern - the regular expression signatures must match
        Returns:
        the regex scope
      • matches

        public boolean matches​(String methodSignature)
        Tests a method signature against this scope.
        Parameters:
        methodSignature - the signature to test
        Returns:
        true if the signature matches the pattern
      • accept

        public <T> T accept​(ScopeVisitor<T> visitor)
        Description copied from interface: Scope
        Dispatches to the visitor hook for this scope variant.
        Specified by:
        accept in interface Scope
        Type Parameters:
        T - the visitor's result type
        Parameters:
        visitor - the visitor to dispatch to
        Returns:
        whatever the visitor returns for this variant
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object