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
,java.io.Serializable
public class JavaMethodDelegate extends java.lang.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:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description JavaMethodDelegate(JavaClass callingClass, JavaMethod originalMethod)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object obj)
java.util.List<JavaAnnotation>
getAnnotations()
Equivalent ofAnnotatedElement.getAnnotations()
java.lang.String
getCallSignature()
java.lang.String
getCodeBlock()
java.lang.String
getComment()
Retrieve the javadoc comment of this annotated element.java.lang.String
getDeclarationSignature(boolean withModifiers)
JavaClass
getDeclaringClass()
Equivalent ofMember.getDeclaringClass()
java.util.List<JavaClass>
getExceptions()
Equivalent ofExecutable.getExceptionTypes()
java.util.List<JavaType>
getExceptionTypes()
int
getLineNumber()
The line number where this element startedjava.util.List<java.lang.String>
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.java.lang.String
getName()
Equivalent ofMember.getName()
java.lang.String
getNamedParameter(java.lang.String tagName, java.lang.String parameterName)
Convenience method forgetTagByName(String).getNamedParameter(String)
that also checks for null tag.JavaParameter
getParameterByName(java.lang.String name)
java.util.List<JavaParameter>
getParameters()
Equivalent ofExecutable.getParameterTypes()
, where a JavaParameter also contains the original name if available.java.util.List<JavaType>
getParameterTypes()
Equivalent ofExecutable.getParameterTypes()
java.util.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 typesjava.lang.String
getPropertyName()
JavaType
getPropertyType()
JavaClass
getReturns()
JavaType
getReturnType()
Equivalent of java.lang.reflect.Method.getReturnType()JavaType
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 typejava.lang.String
getSourceCode()
Get the original source code of the body of this method.DocletTag
getTagByName(java.lang.String name)
Retrieve the doclettag by the specified name.DocletTag
getTagByName(java.lang.String name, boolean inherited)
java.util.List<DocletTag>
getTags()
Retrieve all defined doclet tags.java.util.List<DocletTag>
getTagsByName(java.lang.String name)
Retrieve all doclettags with a specific name.java.util.List<DocletTag>
getTagsByName(java.lang.String name, boolean inherited)
java.util.List<JavaTypeVariable<JavaMethod>>
getTypeParameters()
Equivalent ofGenericDeclaration.getTypeParameters()
int
hashCode()
boolean
isAbstract()
Equivalent ofModifier.isAbstract(int)
boolean
isDefault()
EquivalentMethod.isDefault()
boolean
isFinal()
Equivalent ofModifier.isFinal(int)
boolean
isNative()
Equivalent ofModifier.isNative(int)
boolean
isPrivate()
Equivalent ofModifier.isPrivate(int)
boolean
isPropertyAccessor()
Returnstrue
if this method follows the bean convention of being an accessor.boolean
isPropertyMutator()
Returnstrue
if this method follows the bean convention of being an mutator.boolean
isProtected()
Equivalent ofModifier.isProtected(int)
boolean
isPublic()
Equivalent ofModifier.isPublic(int)
boolean
isStatic()
Equivalent ofModifier.isStatic(int)
boolean
isStrictfp()
Equivalent ofModifier.isStrict(int)
boolean
isSynchronized()
Equivalent ofModifier.isSynchronized(int)
boolean
isTransient()
Equivalent ofModifier.isTransient(int)
boolean
isVarArgs()
Equivalent ofExecutable.isVarArgs()
boolean
isVolatile()
Equivalent ofModifier.isVolatile(int)
boolean
signatureMatches(java.lang.String name, java.util.List<JavaType> parameterTypes)
This method is NOT varArg aware.boolean
signatureMatches(java.lang.String name, java.util.List<JavaType> parameterTypes, boolean varArg)
java.lang.String
toString()
-
-
-
Constructor Detail
-
JavaMethodDelegate
public JavaMethodDelegate(JavaClass callingClass, JavaMethod originalMethod)
-
-
Method Detail
-
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 interfaceJavaMethod
- Parameters:
resolve
- define if generic should be resolved- Returns:
- the return type
-
getParameterTypes
public java.util.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 interfaceJavaExecutable
- Parameters:
resolve
-true
if the resolved types should be returned, otherwisefalse
- Returns:
- the parameter types
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
getAnnotations
public java.util.List<JavaAnnotation> getAnnotations()
Equivalent ofAnnotatedElement.getAnnotations()
- Specified by:
getAnnotations
in interfaceJavaAnnotatedElement
- Returns:
- a list of Annotations, never
null
-
getCallSignature
public java.lang.String getCallSignature()
- Specified by:
getCallSignature
in interfaceJavaExecutable
- Specified by:
getCallSignature
in interfaceJavaMethod
- Returns:
- the call signature
-
getCodeBlock
public java.lang.String getCodeBlock()
- Specified by:
getCodeBlock
in interfaceJavaModel
- Returns:
- the codeblock
-
getComment
public java.lang.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 interfaceJavaAnnotatedElement
- Returns:
- the comment, otherwise
null
-
getDeclaringClass
public JavaClass getDeclaringClass()
Equivalent ofMember.getDeclaringClass()
- Specified by:
getDeclaringClass
in interfaceJavaExecutable
- Specified by:
getDeclaringClass
in interfaceJavaMember
- Returns:
- the declaring class
-
getDeclarationSignature
public java.lang.String getDeclarationSignature(boolean withModifiers)
- Specified by:
getDeclarationSignature
in interfaceJavaMethod
- Parameters:
withModifiers
-true
if modifiers should be added, otherwisefalse
- Returns:
- the declaration signature
-
getExceptions
public java.util.List<JavaClass> getExceptions()
Equivalent ofExecutable.getExceptionTypes()
- Specified by:
getExceptions
in interfaceJavaExecutable
- Returns:
- a list of Exceptions, never
null
-
getExceptionTypes
public java.util.List<JavaType> 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
public java.util.List<java.lang.String> 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
public java.lang.String getName()
Equivalent ofMember.getName()
- Specified by:
getName
in interfaceJavaMember
- Returns:
- the name of this member
-
getNamedParameter
public java.lang.String getNamedParameter(java.lang.String tagName, java.lang.String parameterName)
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
public JavaParameter getParameterByName(java.lang.String name)
- Specified by:
getParameterByName
in interfaceJavaExecutable
- Parameters:
name
- the name of the parameter- Returns:
- the
JavaParameter
matching the name, otherwisenull
-
getParameters
public java.util.List<JavaParameter> 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
public java.lang.String 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
public JavaType 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
public JavaClass getReturns()
- Specified by:
getReturns
in interfaceJavaMethod
- Returns:
- the return type
-
getSourceCode
public java.lang.String getSourceCode()
Get the original source code of the body of this method.- Specified by:
getSourceCode
in interfaceJavaExecutable
- Returns:
- Code as string.
-
getTagByName
public DocletTag getTagByName(java.lang.String name, boolean inherited)
- Specified by:
getTagByName
in interfaceJavaMethod
-
getTagByName
public DocletTag getTagByName(java.lang.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 interfaceJavaAnnotatedElement
- Parameters:
name
- the name of the doclettag trying to retrieve- Returns:
- the first doclettag matching the name, otherwise
null
-
getTags
public java.util.List<DocletTag> getTags()
Retrieve all defined doclet tags.- Specified by:
getTags
in interfaceJavaAnnotatedElement
- Returns:
- a list of DocletTags, never
null
-
getTagsByName
public java.util.List<DocletTag> getTagsByName(java.lang.String name, boolean inherited)
- Specified by:
getTagsByName
in interfaceJavaMethod
-
getTagsByName
public java.util.List<DocletTag> getTagsByName(java.lang.String name)
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
public java.util.List<JavaTypeVariable<JavaMethod>> getTypeParameters()
Equivalent ofGenericDeclaration.getTypeParameters()
- Specified by:
getTypeParameters
in interfaceJavaGenericDeclaration
- Returns:
- a list of typeParameters, never
null
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
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
public boolean signatureMatches(java.lang.String name, java.util.List<JavaType> parameterTypes, boolean varArg)
- 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
public boolean signatureMatches(java.lang.String name, java.util.List<JavaType> parameterTypes)
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
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getReturnType
public JavaType getReturnType()
Equivalent of java.lang.reflect.Method.getReturnType()- Specified by:
getReturnType
in interfaceJavaMethod
- Returns:
- the return type
-
getParameterTypes
public java.util.List<JavaType> getParameterTypes()
Equivalent ofExecutable.getParameterTypes()
- Specified by:
getParameterTypes
in interfaceJavaExecutable
- Returns:
- a list of JavaParameters, never
null
-
-