JavaMethod
Date: 2017-03-29

com.thoughtworks.qdox.model

## Class JavaMethod

- java.lang.Object
- - com.thoughtworks.qdox.model.AbstractBaseJavaEntity
  - - com.thoughtworks.qdox.model.AbstractJavaEntity
    - - com.thoughtworks.qdox.model.AbstractInheritableJavaEntity
      - - com.thoughtworks.qdox.model.JavaMethod

- All Implemented Interfaces:
    Member, java.io.Serializable, java.lang.Comparable
  Direct Known Subclasses:
    JavaMethodDelegate

      public class JavaMethod
      extends AbstractInheritableJavaEntity
      implements Member

  See Also:
    Serialized Form

- - ### Field Summary

    - ### Fields inherited from class com.thoughtworks.qdox.model.AbstractJavaEntity

      `modifiers`

    - ### Fields inherited from class com.thoughtworks.qdox.model.AbstractBaseJavaEntity

      `name, parent`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `JavaMethod()` The default constructor
    `JavaMethod(java.lang.String name)` Create new method without parameters and return type
    `JavaMethod(Type returns, java.lang.String name)` Create a new method without parameters

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addParameter(JavaParameter javaParameter)`
    `int` | `compareTo(java.lang.Object o)`
    `boolean` | `equals(java.lang.Object obj)`
    `java.lang.String` | `getCallSignature()`
    `java.lang.String` | `getDeclarationSignature(boolean withModifiers)`
    `Type[]` | `getExceptions()`
    `Type` | `getGenericReturnType()` Equivalent of java.lang.reflect.Method.getGenericReturnType()
    `JavaParameter` | `getParameterByName(java.lang.String name)`
    `JavaParameter[]` | `getParameters()`
    `Type[]` | `getParameterTypes()`
    `Type[]` | `getParameterTypes(boolean resolve)` If a class inherits this method from a generic class or interface, you can use this method to get the resolved parameter types
    `protected Type[]` | `getParameterTypes(boolean resolve, JavaClass callingClass)`
    `java.lang.String` | `getPropertyName()`
    `Type` | `getPropertyType()`
    `Type` | `getReturns()` Deprecated. it is recommended to use getReturnType()
    `Type` | `getReturnType()` Equivalent of java.lang.reflect.Method.getReturnType()
    `Type` | `getReturnType(boolean resolve)` If a class inherits this method from a generic class or interface, you can use this method to get the resolved return type
    `protected Type` | `getReturnType(boolean resolve, JavaClass callingClass)`
    `java.lang.String` | `getSourceCode()` Get the original source code of the body of this method.
    `DocletTag[]` | `getTagsByName(java.lang.String name, boolean inherited)`
    `TypeVariable[]` | `getTypeParameters()`
    `int` | `hashCode()`
    `boolean` | `isConstructor()`
    `boolean` | `isPropertyAccessor()`
    `boolean` | `isPropertyMutator()`
    `boolean` | `isPublic()`
    `boolean` | `isVarArgs()`
    `void` | `setConstructor(boolean constructor)`
    `void` | `setExceptions(Type[] exceptions)`
    `void` | `setReturns(Type returns)` Define the return type of this method
    `void` | `setSourceCode(java.lang.String sourceCode)`
    `void` | `setTypeParameters(TypeVariable[] typeParameters)`
    `boolean` | `signatureMatches(java.lang.String name, Type[] parameterTypes)` Deprecated. use overloaded method
    `boolean` | `signatureMatches(java.lang.String name, Type[] parameterTypes, boolean varArg)`
    `java.lang.String` | `toString()`
    `protected void` | `writeBody(IndentBuffer result)`
    `protected void` | `writeBody(IndentBuffer result, boolean withModifiers, boolean isDeclaration, boolean isPrettyPrint)`

    - ### Methods inherited from class com.thoughtworks.qdox.model.AbstractInheritableJavaEntity

      `getTagByName`

    - ### Methods inherited from class com.thoughtworks.qdox.model.AbstractJavaEntity

      `getCodeBlock, getComment, getModifiers, getNamedParameter, getParentClass, getSource, getTagByName, getTags, getTagsByName, isAbstract, isFinal, isNative, isPrivate, isProtected, isStatic, isStrictfp, isSynchronized, isTransient, isVolatile, setComment, setModifiers, setParentClass, setTags, write, writeAccessibilityModifier, writeAllModifiers, writeNonAccessibilityModifiers`

    - ### Methods inherited from class com.thoughtworks.qdox.model.AbstractBaseJavaEntity

      `getAnnotations, getLineNumber, getName, getParent, setAnnotations, setLineNumber, setName, setParent`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### JavaMethod

          public JavaMethod()

      The default constructor

    - #### JavaMethod

          public JavaMethod(java.lang.String name)

      Create new method without parameters and return type
      Parameters:
        `name` - the name of the method

    - #### JavaMethod

          public JavaMethod(Type returns,
                    java.lang.String name)

      Create a new method without parameters
      Parameters:
        `returns` - the return type
        `name` - the name of this method

  - ### Method Detail

    - #### getReturns

          public Type getReturns()

      Deprecated. it is recommended to use getReturnType()
      Returns:
        the return type

    - #### getParameters

          public JavaParameter[] getParameters()

    - #### getParameterByName

          public JavaParameter getParameterByName(java.lang.String name)

    - #### getExceptions

          public Type[] getExceptions()

    - #### isConstructor

          public boolean isConstructor()

      Returns:
        true is this method is a constructor

    - #### isVarArgs

          public boolean isVarArgs()

      Returns:
        true is this method conains varArgs

    - #### writeBody

          protected void writeBody(IndentBuffer result)

      Specified by:
        `writeBody` in class `AbstractJavaEntity`

    - #### writeBody

          protected void writeBody(IndentBuffer result,
                       boolean withModifiers,
                       boolean isDeclaration,
                       boolean isPrettyPrint)

      Since:
        1.3

    - #### getDeclarationSignature

          public java.lang.String getDeclarationSignature(boolean withModifiers)

      Specified by:
        `getDeclarationSignature` in interface `Member`
      Since:
        1.3

    - #### getCallSignature

          public java.lang.String getCallSignature()

      Specified by:
        `getCallSignature` in interface `Member`
      Since:
        1.3

    - #### setReturns

          public void setReturns(Type returns)

      Define the return type of this method
      Parameters:
        `returns` - the return type

    - #### addParameter

          public void addParameter(JavaParameter javaParameter)

    - #### setExceptions

          public void setExceptions(Type[] exceptions)

    - #### setConstructor

          public void setConstructor(boolean constructor)

    - #### equals

          public boolean equals(java.lang.Object obj)

      Overrides:
        `equals` in class `java.lang.Object`

    - #### signatureMatches

          public boolean signatureMatches(java.lang.String name,
                                 Type[] parameterTypes)

      Deprecated. use overloaded method
      This method is NOT varArg aware. The overloaded method is.
      Parameters:
        `name` -
        `parameterTypes` -
      Returns:

    - #### signatureMatches

          public boolean signatureMatches(java.lang.String name,
                                 Type[] parameterTypes,
                                 boolean varArg)

      Parameters:
        `name` - method name
        `parameterTypes` - parameter types or null if there are no parameters.
      Returns:
        true if the signature and parameters match.

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `java.lang.Object`

    - #### isPublic

          public boolean isPublic()

      Overrides:
        `isPublic` in class `AbstractJavaEntity`

    - #### isPropertyAccessor

          public boolean isPropertyAccessor()

      Returns:
        true if this method is a Java Bean accessor
      Since:
        1.3

    - #### isPropertyMutator

          public boolean isPropertyMutator()

      Returns:
        true if this method is a Java Bean accessor
      Since:
        1.3

    - #### getPropertyType

          public Type getPropertyType()

      Returns:
        the type of the property this method represents, or null if this method is not a property mutator or property accessor.
      Since:
        1.3

    - #### getPropertyName

          public java.lang.String getPropertyName()

      Returns:
        the name of the property this method represents, or null if this method is not a property mutator or property accessor.
      Since:
        1.3

    - #### getTagsByName

          public DocletTag[] getTagsByName(java.lang.String name,
                                  boolean inherited)

      Specified by:
        `getTagsByName` in class `AbstractInheritableJavaEntity`

    - #### compareTo

          public int compareTo(java.lang.Object o)

      Specified by:
        `compareTo` in interface `java.lang.Comparable`

    - #### getSourceCode

          public java.lang.String getSourceCode()

      Get the original source code of the body of this method.
      Returns:
        Code as string.

    - #### setSourceCode

          public void setSourceCode(java.lang.String sourceCode)

    - #### setTypeParameters

          public void setTypeParameters(TypeVariable[] typeParameters)

    - #### getTypeParameters

          public TypeVariable[] getTypeParameters()

    - #### toString

          public java.lang.String toString()

      Overrides:
        `toString` in class `java.lang.Object`

    - #### getGenericReturnType

          public Type getGenericReturnType()

      Equivalent of java.lang.reflect.Method.getGenericReturnType()
      Returns:
        the generic returntype
      Since:
        1.12

    - #### getReturnType

          public Type getReturnType()

      Equivalent of java.lang.reflect.Method.getReturnType()
      Returns:
      Since:
        1.12

    - #### getReturnType

          public Type getReturnType(boolean resolve)

      If a class inherits this method from a generic class or interface, you can use this method to get the resolved return type
      Parameters:
        `resolve` -
      Returns:
      Since:
        1.12

    - #### getReturnType

          protected Type getReturnType(boolean resolve,
                           JavaClass callingClass)

      Parameters:
        `resolve` -
        `callingClass` -
      Returns:
      Since:
        1.12

    - #### getParameterTypes

          public Type[] getParameterTypes()

      Returns:
        the parameter types as array
      Since:
        1.12

    - #### getParameterTypes

          public Type[] getParameterTypes(boolean resolve)

      If a class inherits this method from a generic class or interface, you can use this method to get the resolved parameter types
      Parameters:
        `resolve` -
      Returns:
        the parameter types as array
      Since:
        1.12

    - #### getParameterTypes

          protected Type[] getParameterTypes(boolean resolve,
                                 JavaClass callingClass)