Interface MethodInfo

All Superinterfaces:
AnnotationTarget, DeclarationInfo

public interface MethodInfo extends DeclarationInfo
A method or a constructor, declared in some class.
Since:
4.0
  • Method Details

    • name

      String name()
      Returns the name of this method. In case of constructors, returns the binary name of the declaring class.
      Returns:
      the name of this method, never null
    • parameters

      List<ParameterInfo> parameters()
      Returns a list of parameters declared or implicitly declared on this method.
      Returns:
      immutable list of parameters, never null
    • returnType

      Type returnType()
      Returns the return type of this method. In case of constructors, returns the type of the declaring class.
      Returns:
      the return type of this method, never null
    • receiverType

      Type receiverType()
      Returns the type of the receiver parameter declared by this method. Returns null if this method cannot declare a receiver parameter; that is, if this method is static or is a constructor of a top-level class or a static nested class. If this method may declare a receiver parameter but does not, returns a Type with no annotations.
      Returns:
      the type of the receiver parameter declared by this method, with or without annotations, or null if this method cannot declare a receiver parameter
    • throwsTypes

      List<Type> throwsTypes()
      Returns a list of exception types that are declared to be thrown by this method. Returns an empty list if this method does not declare any exception.
      Returns:
      immutable list of exception types, never null
    • typeParameters

      List<TypeVariable> typeParameters()
      Returns a list of type parameters declared on this method. Returns an empty list if this method is not generic and so does not declare type parameters.
      Returns:
      immutable list of type parameters, never null
    • isConstructor

      boolean isConstructor()
      Returns whether this method is, in fact, a constructor.
      Returns:
      whether this method is, in fact, a constructor
    • isStatic

      boolean isStatic()
      Returns whether this method is static.
      Returns:
      whether this method is static.
    • isAbstract

      boolean isAbstract()
      Returns whether this method is abstract.

      A static method is never abstract. An instance method declared on a plain class or an enum is abstract if declared abstract. An instance method declared on an interface is abstract unless declared default. An instance method declared on an annotation type is always abstract. An instance method declared on a record type is never abstract.

      Returns:
      whether this method is abstract.
    • isFinal

      boolean isFinal()
      Returns whether this method is final.
      Returns:
      whether this method is final.
    • modifiers

      int modifiers()
      Returns the modifiers of this method as an int. Use Modifier to inspect the value.
      Returns:
      the modifiers of this method
    • declaringClass

      ClassInfo declaringClass()
      Returns the class that declares this method.
      Returns:
      the class that declares this method, never null
    • kind

      default DeclarationInfo.Kind kind()
      Description copied from interface: DeclarationInfo
      Returns the kind of this declaration.
      Specified by:
      kind in interface DeclarationInfo
      Returns:
      the kind of this declaration
    • asMethod

      default MethodInfo asMethod()
      Description copied from interface: DeclarationInfo
      Returns this declaration as a method.
      Specified by:
      asMethod in interface DeclarationInfo
      Returns:
      this method, never null