Package com.thoughtworks.qdox.model.impl
Class JavaMethodDelegate
java.lang.Object
com.thoughtworks.qdox.model.impl.JavaMethodDelegate
- All Implemented Interfaces:
JavaAnnotatedElement
,JavaExecutable
,JavaGenericDeclaration
,JavaMember
,JavaMethod
,JavaModel
,Serializable
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 Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
Equivalent ofAnnotatedElement.getAnnotations()
Retrieve the javadoc comment of this annotated element.getDeclarationSignature
(boolean withModifiers) Equivalent ofMember.getDeclaringClass()
Equivalent ofExecutable.getExceptionTypes()
int
The line number where this element startedEquivalent ofMember.getModifiers()
This does not follow the java-api With the Member-class, getModifiers returns anint
, which should be decoded with the Modifier.getName()
Equivalent ofMember.getName()
getNamedParameter
(String tagName, String parameterName) Convenience method forgetTagByName(String).getNamedParameter(String)
that also checks for null tag.getParameterByName
(String name) Equivalent ofExecutable.getParameterTypes()
, where a JavaParameter also contains the original name if available.Equivalent ofExecutable.getParameterTypes()
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 typesEquivalent of java.lang.reflect.Method.getReturnType()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 typeGet the original source code of the body of this method.getTagByName
(String name) Retrieve the doclettag by the specified name.getTagByName
(String name, boolean inherited) getTags()
Retrieve all defined doclet tags.getTagsByName
(String name) Retrieve all doclettags with a specific name.getTagsByName
(String name, boolean inherited) Equivalent ofGenericDeclaration.getTypeParameters()
int
hashCode()
boolean
Equivalent ofModifier.isAbstract(int)
boolean
EquivalentMethod.isDefault()
boolean
isFinal()
Equivalent ofModifier.isFinal(int)
boolean
isNative()
Equivalent ofModifier.isNative(int)
boolean
Equivalent ofModifier.isPrivate(int)
boolean
Returnstrue
if this method follows the bean convention of being an accessor.boolean
Returnstrue
if this method follows the bean convention of being an mutator.boolean
Equivalent ofModifier.isProtected(int)
boolean
isPublic()
Equivalent ofModifier.isPublic(int)
boolean
isStatic()
Equivalent ofModifier.isStatic(int)
boolean
Equivalent ofModifier.isStrict(int)
boolean
Equivalent ofModifier.isSynchronized(int)
boolean
Equivalent ofModifier.isTransient(int)
boolean
Equivalent ofExecutable.isVarArgs()
boolean
Equivalent ofModifier.isVolatile(int)
boolean
signatureMatches
(String name, List<JavaType> parameterTypes) This method is NOT varArg aware.boolean
signatureMatches
(String name, List<JavaType> parameterTypes, boolean varArg) toString()
-
Field Details
-
callingClass
-
originalMethod
-
-
Constructor Details
-
JavaMethodDelegate
-
-
Method Details
-
getReturnType
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 interfaceJavaMethod
- Parameters:
resolve
- define if generic should be resolved- Returns:
- the return type
-
getParameterTypes
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 interfaceJavaExecutable
- Parameters:
resolve
-true
if the resolved types should be returned, otherwisefalse
- Returns:
- the parameter types
-
equals
-
getAnnotations
Equivalent ofAnnotatedElement.getAnnotations()
- Specified by:
getAnnotations
in interfaceJavaAnnotatedElement
- Returns:
- a list of Annotations, never
null
-
getCallSignature
- Specified by:
getCallSignature
in interfaceJavaExecutable
- Specified by:
getCallSignature
in interfaceJavaMethod
- Returns:
- the call signature
-
getCodeBlock
- Specified by:
getCodeBlock
in interfaceJavaModel
- Returns:
- the codeblock
-
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 interfaceJavaAnnotatedElement
- Returns:
- the comment, otherwise
null
-
getDeclaringClass
Equivalent ofMember.getDeclaringClass()
- Specified by:
getDeclaringClass
in interfaceJavaExecutable
- Specified by:
getDeclaringClass
in interfaceJavaMember
- Returns:
- the declaring class
-
getDeclarationSignature
- Specified by:
getDeclarationSignature
in interfaceJavaMethod
- Parameters:
withModifiers
-true
if modifiers should be added, otherwisefalse
- Returns:
- the declaration signature
-
getExceptions
Equivalent ofExecutable.getExceptionTypes()
- Specified by:
getExceptions
in interfaceJavaExecutable
- Returns:
- a list of Exceptions, never
null
-
getExceptionTypes
- Specified by:
getExceptionTypes
in interfaceJavaExecutable
-
isDefault
public boolean isDefault()EquivalentMethod.isDefault()
- Specified by:
isDefault
in interfaceJavaMethod
- Returns:
true
if this is a default method of an interface, otherwisefalse
-
getLineNumber
public int getLineNumber()The line number where this element started- Specified by:
getLineNumber
in interfaceJavaModel
- Returns:
- the line number of this element
-
getModifiers
Equivalent ofMember.getModifiers()
This does not follow the java-api With the Member-class, getModifiers returns anint
, 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 interfaceJavaMember
- Returns:
- all modifiers is this member
-
getName
Equivalent ofMember.getName()
- Specified by:
getName
in interfaceJavaMember
- Returns:
- the name of this member
-
getNamedParameter
Convenience method forgetTagByName(String).getNamedParameter(String)
that also checks for null tag.- Specified by:
getNamedParameter
in interfaceJavaAnnotatedElement
- Parameters:
tagName
- the tag nameparameterName
- the parameter name- Returns:
- the value of the matching parameter, otherwise
null
-
getParameterByName
- Specified by:
getParameterByName
in interfaceJavaExecutable
- Parameters:
name
- the name of the parameter- Returns:
- the
JavaParameter
matching the name, otherwisenull
-
getParameters
Equivalent ofExecutable.getParameterTypes()
, where a JavaParameter also contains the original name if available.- Specified by:
getParameters
in interfaceJavaExecutable
- Returns:
- a list of JavaParameters, never
null
-
getPropertyName
- Specified by:
getPropertyName
in interfaceJavaMethod
- Returns:
- the name of the property this method represents, or
null
if this method is not a property mutator or property accessor.
-
getPropertyType
- Specified by:
getPropertyType
in interfaceJavaMethod
- Returns:
- the type of the property this method represents, or
null
if this method is not a property mutator or property accessor.
-
getReturns
- Specified by:
getReturns
in interfaceJavaMethod
- Returns:
- the return type
-
getSourceCode
Get the original source code of the body of this method.- Specified by:
getSourceCode
in interfaceJavaExecutable
- Returns:
- Code as string.
-
getTagByName
- Specified by:
getTagByName
in interfaceJavaMethod
-
getTagByName
Retrieve the doclettag by the specified name. If there are more than one tags, only return the first one.- Specified by:
getTagByName
in interfaceJavaAnnotatedElement
- Parameters:
name
- the name of the doclettag trying to retrieve- Returns:
- the first doclettag matching the name, otherwise
null
-
getTags
Retrieve all defined doclet tags.- Specified by:
getTags
in interfaceJavaAnnotatedElement
- Returns:
- a list of DocletTags, never
null
-
getTagsByName
- Specified by:
getTagsByName
in interfaceJavaMethod
-
getTagsByName
Retrieve all doclettags with a specific name.- Specified by:
getTagsByName
in interfaceJavaAnnotatedElement
- Parameters:
name
- the name of the doclet tag- Returns:
- a list of doclettags, never
null
-
getTypeParameters
Equivalent ofGenericDeclaration.getTypeParameters()
- Specified by:
getTypeParameters
in interfaceJavaGenericDeclaration
- Returns:
- a list of typeParameters, never
null
-
hashCode
public int hashCode() -
isAbstract
public boolean isAbstract()Equivalent ofModifier.isAbstract(int)
- Specified by:
isAbstract
in interfaceJavaMember
- Returns:
true
if this member isabstract
, otherwisefalse
-
isFinal
public boolean isFinal()Equivalent ofModifier.isFinal(int)
- Specified by:
isFinal
in interfaceJavaMember
- Returns:
true
is this member isfinal
, otherwisefalse
-
isNative
public boolean isNative()Equivalent ofModifier.isNative(int)
- Specified by:
isNative
in interfaceJavaMember
- Returns:
true
if this member isnative
, otherwisefalse
-
isPrivate
public boolean isPrivate()Equivalent ofModifier.isPrivate(int)
- Specified by:
isPrivate
in interfaceJavaMember
- Returns:
true
if this member isprivate
, otherwisefalse
-
isPropertyAccessor
public boolean isPropertyAccessor()Returnstrue
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 interfaceJavaMethod
- Returns:
true
if this method is a Java Bean accessor, otherwisefalse
-
isPropertyMutator
public boolean isPropertyMutator()Returnstrue
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 interfaceJavaMethod
- Returns:
true
if this method is a Java Bean mutator, otherwisefalse
-
isProtected
public boolean isProtected()Equivalent ofModifier.isProtected(int)
- Specified by:
isProtected
in interfaceJavaMember
- Returns:
true
if this member isprotected
; otherwisefalse
-
isPublic
public boolean isPublic()Equivalent ofModifier.isPublic(int)
- Specified by:
isPublic
in interfaceJavaMember
- Returns:
true
if this member ispublic
, otherwisefalse
-
isStatic
public boolean isStatic()Equivalent ofModifier.isStatic(int)
- Specified by:
isStatic
in interfaceJavaMember
- Returns:
true
if this member isstatic
, otherwisefalse
-
isStrictfp
public boolean isStrictfp()Equivalent ofModifier.isStrict(int)
- Specified by:
isStrictfp
in interfaceJavaMember
- Returns:
true
if this member isstrictfp
, otherwisefalse
-
isSynchronized
public boolean isSynchronized()Equivalent ofModifier.isSynchronized(int)
- Specified by:
isSynchronized
in interfaceJavaMember
- Returns:
true
if this member issynchronized
, otherwisefalse
-
isTransient
public boolean isTransient()Equivalent ofModifier.isTransient(int)
- Specified by:
isTransient
in interfaceJavaMember
- Returns:
true
if this member istransient
, otherwisefalse
-
isVarArgs
public boolean isVarArgs()Equivalent ofExecutable.isVarArgs()
- Specified by:
isVarArgs
in interfaceJavaExecutable
- Returns:
true
if the final parameter is a varArg, otherwisefalse
-
isVolatile
public boolean isVolatile()Equivalent ofModifier.isVolatile(int)
- Specified by:
isVolatile
in interfaceJavaMember
- Returns:
true
if this member isvolatile
, otherwisefalse
-
signatureMatches
- Specified by:
signatureMatches
in interfaceJavaMethod
- Parameters:
name
- the name of the methodparameterTypes
- the parameter types, can benull
varArg
-true
is signature should match a varArg-method, otherwisefalse
- Returns:
true
if this method matches the signature, otherwisefalse
-
signatureMatches
This method is NOT varArg aware.- Specified by:
signatureMatches
in interfaceJavaMethod
- Parameters:
name
- the name of the methodparameterTypes
- the parameter types of the method, can benull
- Returns:
true
if this method matches the signature, otherwisefalse
-
toString
-
getReturnType
Equivalent of java.lang.reflect.Method.getReturnType()- Specified by:
getReturnType
in interfaceJavaMethod
- Returns:
- the return type
-
getParameterTypes
Equivalent ofExecutable.getParameterTypes()
- Specified by:
getParameterTypes
in interfaceJavaExecutable
- Returns:
- a list of JavaParameters, never
null
-