Class MethodInfo

  • All Implemented Interfaces:
    java.lang.Comparable<MethodInfo>

    public class MethodInfo
    extends java.lang.Object
    implements java.lang.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.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int compareTo​(MethodInfo other)
      Sort in order of class name, method name, then type descriptor.
      boolean equals​(java.lang.Object obj)
      Test class name, method name and type descriptor for equals().
      AnnotationInfoList getAnnotationInfo()
      Get a list of annotations on this method, along with any annotation parameter values.
      AnnotationInfo getAnnotationInfo​(java.lang.String annotationName)
      Get a the named annotation on this method, or null if the method does not have the named annotation.
      ClassInfo getClassInfo()  
      protected java.lang.String getClassName()
      Returns the declaring class name, so that super.getClassInfo() returns the ClassInfo object for the declaring class.
      int getModifiers()
      Returns the modifier bits for the method.
      java.lang.String getModifiersStr()
      Get the method modifiers as a String, e.g.
      java.lang.String getName()
      Returns the name of the method.
      MethodParameterInfo[] getParameterInfo()
      Get the available information on method parameters.
      protected void getReferencedClassNames​(java.util.Set<java.lang.String> classNames)
      Get the names of any classes in the type descriptor or type signature.
      MethodTypeSignature getTypeDescriptor()
      Returns the parsed type descriptor for the method, which will not include type parameters.
      MethodTypeSignature getTypeSignature()
      Returns the parsed type signature for the method, possibly including type parameters.
      MethodTypeSignature getTypeSignatureOrTypeDescriptor()
      Returns the parsed type signature for the method, possibly including type parameters.
      boolean hasAnnotation​(java.lang.String annotationName)  
      boolean hasBody()
      Returns true if this method has a body (i.e.
      int hashCode()
      Use hash code of class name, method name and type descriptor.
      boolean hasParameterAnnotation​(java.lang.String annotationName)  
      boolean isBridge()
      Returns true if this method is a bridge method.
      boolean isConstructor()
      Returns true if this method is a constructor.
      boolean isDefault()
      Returns true if this is a default method (i.e.
      boolean isFinal()
      Returns true if this method is final.
      boolean isNative()
      Returns true if this method is a native method.
      boolean isPublic()
      Returns true if this method is public.
      boolean isStatic()
      Returns true if this method is static.
      boolean isSynchronized()
      Returns true if this method is synchronized.
      boolean isVarArgs()
      Returns true if this method is a varargs method.
      java.lang.reflect.Method loadClassAndGetMethod()
      Load the class this method is associated with, and get the Method reference for this method.
      java.lang.String toString()
      Get a string representation of the method.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • scanResult

        protected transient ScanResult scanResult
    • Method Detail

      • getName

        public java.lang.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 java.lang.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​(java.lang.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​(java.lang.String annotationName)
        Parameters:
        annotationName - The name of an annotation.
        Returns:
        true if this method has the named annotation.
      • hasParameterAnnotation

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

        public java.lang.reflect.Method loadClassAndGetMethod()
                                                       throws java.lang.IllegalArgumentException
        Load the class this method is associated with, and get the Method reference for this method.
        Returns:
        The Method reference for this field.
        Throws:
        java.lang.IllegalArgumentException - if the method does not exist.
      • getClassName

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

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

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

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

        public int compareTo​(MethodInfo other)
        Sort in order of class name, method name, then type descriptor.
        Specified by:
        compareTo in interface java.lang.Comparable<MethodInfo>
      • toString

        public java.lang.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 java.lang.Object