Class JavaMethodDelegate

java.lang.Object
com.thoughtworks.qdox.model.impl.JavaMethodDelegate
All Implemented Interfaces:
JavaAnnotatedElement, JavaExecutable, JavaGenericDeclaration, JavaMember, JavaMethod, JavaModel, Serializable

public class JavaMethodDelegate extends Object implements JavaMethod
This class can be used to access overridden methods while keeping a reference to the original class. This is especially useful when trying to resolve generics
Since:
1.12
See Also:
  • Field Details

    • callingClass

      private JavaClass callingClass
    • originalMethod

      private JavaMethod originalMethod
  • Constructor Details

    • JavaMethodDelegate

      public JavaMethodDelegate(JavaClass callingClass, JavaMethod originalMethod)
  • Method Details

    • getReturnType

      public JavaType getReturnType(boolean resolve)
      Description copied from interface: JavaMethod
      If a class inherits this method from a generic class or interface, you can use this method to get the resolved return type
      Specified by:
      getReturnType in interface JavaMethod
      Parameters:
      resolve - define if generic should be resolved
      Returns:
      the return type
    • getParameterTypes

      public List<JavaType> 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
      Specified by:
      getParameterTypes in interface JavaExecutable
      Parameters:
      resolve - true if the resolved types should be returned, otherwise false
      Returns:
      the parameter types
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • getAnnotations

      public List<JavaAnnotation> getAnnotations()
      Specified by:
      getAnnotations in interface JavaAnnotatedElement
      Returns:
      a list of Annotations, never null
    • getCallSignature

      public String getCallSignature()
      Specified by:
      getCallSignature in interface JavaExecutable
      Specified by:
      getCallSignature in interface JavaMethod
      Returns:
      the call signature
    • getCodeBlock

      public String getCodeBlock()
      Specified by:
      getCodeBlock in interface JavaModel
      Returns:
      the codeblock
    • getComment

      public String getComment()
      Retrieve the javadoc comment of this annotated element. This is the part between /** and the */, but without the doclet tags
      Specified by:
      getComment in interface JavaAnnotatedElement
      Returns:
      the comment, otherwise null
    • getDeclaringClass

      public JavaClass getDeclaringClass()
      Specified by:
      getDeclaringClass in interface JavaExecutable
      Specified by:
      getDeclaringClass in interface JavaMember
      Returns:
      the declaring class
    • getDeclarationSignature

      public String getDeclarationSignature(boolean withModifiers)
      Specified by:
      getDeclarationSignature in interface JavaMethod
      Parameters:
      withModifiers - true if modifiers should be added, otherwise false
      Returns:
      the declaration signature
    • getExceptions

      public List<JavaClass> getExceptions()
      Specified by:
      getExceptions in interface JavaExecutable
      Returns:
      a list of Exceptions, never null
    • getExceptionTypes

      public List<JavaType> getExceptionTypes()
      Specified by:
      getExceptionTypes in interface JavaExecutable
    • isDefault

      public boolean isDefault()
      Specified by:
      isDefault in interface JavaMethod
      Returns:
      true if this is a default method of an interface, otherwise false
    • getLineNumber

      public int getLineNumber()
      The line number where this element started
      Specified by:
      getLineNumber in interface JavaModel
      Returns:
      the line number of this element
    • getModifiers

      public List<String> getModifiers()
      Equivalent of Member.getModifiers() This does not follow the java-api With the Member-class, getModifiers returns an int, which should be decoded with the Modifier. If this member was extracted from a source, it will keep its order. Otherwise if will be in the preferred order of the java-api.
      Specified by:
      getModifiers in interface JavaMember
      Returns:
      all modifiers is this member
    • getName

      public String getName()
      Equivalent of Member.getName()
      Specified by:
      getName in interface JavaMember
      Returns:
      the name of this member
    • getNamedParameter

      public String getNamedParameter(String tagName, String parameterName)
      Convenience method for getTagByName(String).getNamedParameter(String) that also checks for null tag.
      Specified by:
      getNamedParameter in interface JavaAnnotatedElement
      Parameters:
      tagName - the tag name
      parameterName - the parameter name
      Returns:
      the value of the matching parameter, otherwise null
    • getParameterByName

      public JavaParameter getParameterByName(String name)
      Specified by:
      getParameterByName in interface JavaExecutable
      Parameters:
      name - the name of the parameter
      Returns:
      the JavaParameter matching the name, otherwise null
    • getParameters

      public List<JavaParameter> getParameters()
      Equivalent of Executable.getParameterTypes(), where a JavaParameter also contains the original name if available.
      Specified by:
      getParameters in interface JavaExecutable
      Returns:
      a list of JavaParameters, never null
    • getPropertyName

      public String getPropertyName()
      Specified by:
      getPropertyName in interface JavaMethod
      Returns:
      the name of the property this method represents, or null if this method is not a property mutator or property accessor.
    • getPropertyType

      public JavaType getPropertyType()
      Specified by:
      getPropertyType in interface JavaMethod
      Returns:
      the type of the property this method represents, or null if this method is not a property mutator or property accessor.
    • getReturns

      public JavaClass getReturns()
      Specified by:
      getReturns in interface JavaMethod
      Returns:
      the return type
    • getSourceCode

      public String getSourceCode()
      Get the original source code of the body of this method.
      Specified by:
      getSourceCode in interface JavaExecutable
      Returns:
      Code as string.
    • getTagByName

      public DocletTag getTagByName(String name, boolean inherited)
      Specified by:
      getTagByName in interface JavaMethod
    • getTagByName

      public DocletTag getTagByName(String name)
      Retrieve the doclettag by the specified name. If there are more than one tags, only return the first one.
      Specified by:
      getTagByName in interface JavaAnnotatedElement
      Parameters:
      name - the name of the doclettag trying to retrieve
      Returns:
      the first doclettag matching the name, otherwise null
    • getTags

      public List<DocletTag> getTags()
      Retrieve all defined doclet tags.
      Specified by:
      getTags in interface JavaAnnotatedElement
      Returns:
      a list of DocletTags, never null
    • getTagsByName

      public List<DocletTag> getTagsByName(String name, boolean inherited)
      Specified by:
      getTagsByName in interface JavaMethod
    • getTagsByName

      public List<DocletTag> getTagsByName(String name)
      Retrieve all doclettags with a specific name.
      Specified by:
      getTagsByName in interface JavaAnnotatedElement
      Parameters:
      name - the name of the doclet tag
      Returns:
      a list of doclettags, never null
    • getTypeParameters

      public List<JavaTypeVariable<JavaMethod>> getTypeParameters()
      Specified by:
      getTypeParameters in interface JavaGenericDeclaration
      Returns:
      a list of typeParameters, never null
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • isAbstract

      public boolean isAbstract()
      Specified by:
      isAbstract in interface JavaMember
      Returns:
      true if this member is abstract, otherwise false
    • isFinal

      public boolean isFinal()
      Equivalent of Modifier.isFinal(int)
      Specified by:
      isFinal in interface JavaMember
      Returns:
      true is this member is final, otherwise false
    • isNative

      public boolean isNative()
      Specified by:
      isNative in interface JavaMember
      Returns:
      true if this member is native, otherwise false
    • isPrivate

      public boolean isPrivate()
      Specified by:
      isPrivate in interface JavaMember
      Returns:
      true if this member is private, otherwise false
    • isPropertyAccessor

      public boolean isPropertyAccessor()
      Returns true if this method follows the bean convention of being an accessor.
         public String getName();             // true
         public boolean isValid()             // true
         public String getName( String def ); // false, it has a parameter
         public String gettingUp();           // false, 'get' is not followed by an uppercase character
         public boolean isolate();            // false, 'is' is not followed by an uppercase character
         public static String getName();      // false, it is static
       
      Specified by:
      isPropertyAccessor in interface JavaMethod
      Returns:
      true if this method is a Java Bean accessor, otherwise false
    • isPropertyMutator

      public boolean isPropertyMutator()
      Returns true if this method follows the bean convention of being an mutator.
        public void setName(String name);        // true
        public void setUp();                     // false, it has no parameter
        public void settingUp(String def);       // false, 'set' is not followed by an uppercase character
        public static void setName(String name); // false, it is static
       
      Specified by:
      isPropertyMutator in interface JavaMethod
      Returns:
      true if this method is a Java Bean mutator, otherwise false
    • isProtected

      public boolean isProtected()
      Specified by:
      isProtected in interface JavaMember
      Returns:
      true if this member is protected; otherwise false
    • isPublic

      public boolean isPublic()
      Specified by:
      isPublic in interface JavaMember
      Returns:
      true if this member is public, otherwise false
    • isStatic

      public boolean isStatic()
      Specified by:
      isStatic in interface JavaMember
      Returns:
      true if this member is static, otherwise false
    • isStrictfp

      public boolean isStrictfp()
      Specified by:
      isStrictfp in interface JavaMember
      Returns:
      true if this member is strictfp, otherwise false
    • isSynchronized

      public boolean isSynchronized()
      Specified by:
      isSynchronized in interface JavaMember
      Returns:
      true if this member is synchronized, otherwise false
    • isTransient

      public boolean isTransient()
      Specified by:
      isTransient in interface JavaMember
      Returns:
      true if this member is transient, otherwise false
    • isVarArgs

      public boolean isVarArgs()
      Specified by:
      isVarArgs in interface JavaExecutable
      Returns:
      true if the final parameter is a varArg, otherwise false
    • isVolatile

      public boolean isVolatile()
      Specified by:
      isVolatile in interface JavaMember
      Returns:
      true if this member is volatile, otherwise false
    • signatureMatches

      public boolean signatureMatches(String name, List<JavaType> parameterTypes, boolean varArg)
      Specified by:
      signatureMatches in interface JavaMethod
      Parameters:
      name - the name of the method
      parameterTypes - the parameter types, can be null
      varArg - true is signature should match a varArg-method, otherwise false
      Returns:
      true if this method matches the signature, otherwise false
    • signatureMatches

      public boolean signatureMatches(String name, List<JavaType> parameterTypes)
      This method is NOT varArg aware.
      Specified by:
      signatureMatches in interface JavaMethod
      Parameters:
      name - the name of the method
      parameterTypes - the parameter types of the method, can be null
      Returns:
      true if this method matches the signature, otherwise false
    • toString

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

      public JavaType getReturnType()
      Equivalent of java.lang.reflect.Method.getReturnType()
      Specified by:
      getReturnType in interface JavaMethod
      Returns:
      the return type
    • getParameterTypes

      public List<JavaType> getParameterTypes()
      Specified by:
      getParameterTypes in interface JavaExecutable
      Returns:
      a list of JavaParameters, never null