Class Method

java.lang.Object
com.googlecode.aviator.asm.commons.Method

public class Method extends Object
A named method descriptor.
  • Field Details

    • name

      private final String name
      The method name.
    • desc

      private final String desc
      The method descriptor.
    • DESCRIPTORS

      private static final Map<String,String> DESCRIPTORS
      Maps primitive Java type names to their descriptors.
  • Constructor Details

    • Method

      public Method(String name, String desc)
      Creates a new Method.
      Parameters:
      name - the method's name.
      desc - the method's descriptor.
    • Method

      public Method(String name, Type returnType, Type[] argumentTypes)
      Creates a new Method.
      Parameters:
      name - the method's name.
      returnType - the method's return type.
      argumentTypes - the method's argument types.
  • Method Details

    • getMethod

      public static Method getMethod(Method m)
      Creates a new Method.
      Parameters:
      m - a java.lang.reflect method descriptor
      Returns:
      a Method corresponding to the given Java method declaration.
    • getMethod

      public static Method getMethod(Constructor<?> c)
      Creates a new Method.
      Parameters:
      c - a java.lang.reflect constructor descriptor
      Returns:
      a Method corresponding to the given Java constructor declaration.
    • getMethod

      public static Method getMethod(String method) throws IllegalArgumentException
      Returns a Method corresponding to the given Java method declaration.
      Parameters:
      method - a Java method declaration, without argument names, of the form "returnType name (argumentType1, ... argumentTypeN)", where the types are in plain Java (e.g. "int", "float", "java.util.List", ...). Classes of the java.lang package can be specified by their unqualified name; all other classes names must be fully qualified.
      Returns:
      a Method corresponding to the given Java method declaration.
      Throws:
      IllegalArgumentException - if method could not get parsed.
    • getMethod

      public static Method getMethod(String method, boolean defaultPackage) throws IllegalArgumentException
      Returns a Method corresponding to the given Java method declaration.
      Parameters:
      method - a Java method declaration, without argument names, of the form "returnType name (argumentType1, ... argumentTypeN)", where the types are in plain Java (e.g. "int", "float", "java.util.List", ...). Classes of the java.lang package may be specified by their unqualified name, depending on the defaultPackage argument; all other classes names must be fully qualified.
      defaultPackage - true if unqualified class names belong to the default package, or false if they correspond to java.lang classes. For instance "Object" means "Object" if this option is true, or "java.lang.Object" otherwise.
      Returns:
      a Method corresponding to the given Java method declaration.
      Throws:
      IllegalArgumentException - if method could not get parsed.
    • map

      private static String map(String type, boolean defaultPackage)
    • getName

      public String getName()
      Returns the name of the method described by this object.
      Returns:
      the name of the method described by this object.
    • getDescriptor

      public String getDescriptor()
      Returns the descriptor of the method described by this object.
      Returns:
      the descriptor of the method described by this object.
    • getReturnType

      public Type getReturnType()
      Returns the return type of the method described by this object.
      Returns:
      the return type of the method described by this object.
    • getArgumentTypes

      public Type[] getArgumentTypes()
      Returns the argument types of the method described by this object.
      Returns:
      the argument types of the method described by this object.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object