Class MethodInfo

  • All Implemented Interfaces:
    Comparable<MethodInfo>

    public class MethodInfo
    extends Object
    implements Comparable<MethodInfo>
    Holds metadata about methods of a class encountered during a scan. All values are taken directly out of the classfile for the class.
    • Field Detail

      • scanResult

        protected transient ScanResult scanResult
    • Method Detail

      • getName

        public String getName()
        Returns the name of the method. Note that constructors are named "<init>", and private static class initializer blocks are named "<clinit>".
        Returns:
        The name of the method.
      • getModifiers

        public int getModifiers()
        Returns the modifier bits for the method.
        Returns:
        The modifier bits for the method.
      • getModifiersStr

        public String getModifiersStr()
        Get the method modifiers as a String, e.g. "public static final". For the modifier bits, call getModifiers().
        Returns:
        The modifiers for the method, as a String.
      • getClassInfo

        public ClassInfo getClassInfo()
        Returns:
        The ClassInfo object for the declaring class (i.e. the class that declares this method).
      • getTypeDescriptor

        public MethodTypeSignature getTypeDescriptor()
        Returns the parsed type descriptor for the method, which will not include type parameters. If you need generic type parameters, call getTypeSignature() instead.
        Returns:
        The parsed type descriptor for the method.
      • getTypeSignature

        public MethodTypeSignature getTypeSignature()
        Returns the parsed type signature for the method, possibly including type parameters. If this returns null, indicating that no type signature information is available for this method, call getTypeDescriptor() instead.
        Returns:
        The parsed type signature for the method, or null if not available.
      • getTypeSignatureOrTypeDescriptor

        public MethodTypeSignature getTypeSignatureOrTypeDescriptor()
        Returns the parsed type signature for the method, possibly including type parameters. If the parsed type signature is null, indicating that no type signature information is available for this method, returns the parsed type descriptor instead.
        Returns:
        The parsed type signature for the method, or if not available, the parsed type descriptor for the method.
      • isConstructor

        public boolean isConstructor()
        Returns true if this method is a constructor. Constructors have the method name "<init>". This returns false for private static class initializer blocks, which are named "<clinit>".
        Returns:
        True if this method is a constructor.
      • isPublic

        public boolean isPublic()
        Returns true if this method is public.
        Returns:
        True if this method is public.
      • isStatic

        public boolean isStatic()
        Returns true if this method is static.
        Returns:
        True if this method is static.
      • isFinal

        public boolean isFinal()
        Returns true if this method is final.
        Returns:
        True if this method is final.
      • isSynchronized

        public boolean isSynchronized()
        Returns true if this method is synchronized.
        Returns:
        True if this method is synchronized.
      • isBridge

        public boolean isBridge()
        Returns true if this method is a bridge method.
        Returns:
        True if this is a bridge method.
      • isVarArgs

        public boolean isVarArgs()
        Returns true if this method is a varargs method.
        Returns:
        True if this is a varargs method.
      • isNative

        public boolean isNative()
        Returns true if this method is a native method.
        Returns:
        True if this method is native.
      • hasBody

        public boolean hasBody()
        Returns true if this method has a body (i.e. has an implementation in the containing class).
        Returns:
        True if this method has a body.
      • isDefault

        public boolean isDefault()
        Returns true if this is a default method (i.e. if this is a method in an interface and the method has a body).
        Returns:
        True if this is a default method.
      • getParameterInfo

        public MethodParameterInfo[] getParameterInfo()
        Get the available information on method parameters.
        Returns:
        The MethodParameterInfo objects for the method parameters, one per parameter.
      • getAnnotationInfo

        public AnnotationInfoList getAnnotationInfo()
        Get a list of annotations on this method, along with any annotation parameter values.
        Returns:
        a list of annotations on this method, along with any annotation parameter values, wrapped in AnnotationInfo objects, or the empty list if none.
      • getAnnotationInfo

        public AnnotationInfo getAnnotationInfo​(String annotationName)
        Get a the named annotation on this method, or null if the method does not have the named annotation.
        Parameters:
        annotationName - The annotation name.
        Returns:
        An AnnotationInfo object representing the named annotation on this method, or null if the method does not have the named annotation.
      • hasAnnotation

        public boolean hasAnnotation​(String annotationName)
        Parameters:
        annotationName - The name of an annotation.
        Returns:
        true if this method has the named annotation.
      • hasParameterAnnotation

        public boolean hasParameterAnnotation​(String annotationName)
        Parameters:
        annotationName - The name of a method parameter annotation.
        Returns:
        true if this method has a parameter with the named annotation.
      • getClassName

        protected String getClassName()
        Returns the declaring class name, so that super.getClassInfo() returns the ClassInfo object for the declaring class.
        Returns:
        The class name.
      • getClassNamesFromTypeDescriptors

        protected void getClassNamesFromTypeDescriptors​(Set<String> classNames)
        Get the names of any classes in the type descriptor or type signature.
      • equals

        public boolean equals​(Object obj)
        Test class name, method name and type descriptor for equals().
        Overrides:
        equals in class Object
      • hashCode

        public int hashCode()
        Use hash code of class name, method name and type descriptor.
        Overrides:
        hashCode in class Object
      • toString

        public String toString()
        Get a string representation of the method. Note that constructors are named "<init>", and private static class initializer blocks are named "<clinit>".
        Overrides:
        toString in class Object