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
- Author:
- Robert Scholte
- 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 booleanequals(java.lang.Object obj)java.util.List<JavaAnnotation>getAnnotations()Equivalent ofAnnotatedElement.getAnnotations()java.lang.StringgetCallSignature()java.lang.StringgetCodeBlock()java.lang.StringgetComment()Retrieve the javadoc comment of this annotated element.java.lang.StringgetDeclarationSignature(boolean withModifiers)JavaClassgetDeclaringClass()Equivalent ofMember.getDeclaringClass()java.util.List<JavaClass>getExceptions()Equivalent ofExecutable.getExceptionTypes()java.util.List<JavaType>getExceptionTypes()intgetLineNumber()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.StringgetName()Equivalent ofMember.getName()java.lang.StringgetNamedParameter(java.lang.String tagName, java.lang.String parameterName)Convenience method forgetTagByName(String).getNamedParameter(String)that also checks for null tag.JavaParametergetParameterByName(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.StringgetPropertyName()JavaTypegetPropertyType()JavaClassgetReturns()JavaTypegetReturnType()Equivalent of java.lang.reflect.Method.getReturnType()JavaTypegetReturnType(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.StringgetSourceCode()Get the original source code of the body of this method.DocletTaggetTagByName(java.lang.String name)Retrieve the doclettag by the specified name.DocletTaggetTagByName(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()inthashCode()booleanisAbstract()Equivalent ofModifier.isAbstract(int)booleanisDefault()EquivalentMethod.isDefault()booleanisFinal()Equivalent ofModifier.isFinal(int)booleanisNative()Equivalent ofModifier.isNative(int)booleanisPrivate()Equivalent ofModifier.isPrivate(int)booleanisPropertyAccessor()Returnstrueif this method follows the bean convention of being an accessor.booleanisPropertyMutator()Returnstrueif this method follows the bean convention of being an mutator.booleanisProtected()Equivalent ofModifier.isProtected(int)booleanisPublic()Equivalent ofModifier.isPublic(int)booleanisStatic()Equivalent ofModifier.isStatic(int)booleanisStrictfp()Equivalent ofModifier.isStrict(int)booleanisSynchronized()Equivalent ofModifier.isSynchronized(int)booleanisTransient()Equivalent ofModifier.isTransient(int)booleanisVarArgs()Equivalent ofExecutable.isVarArgs()booleanisVolatile()Equivalent ofModifier.isVolatile(int)booleansignatureMatches(java.lang.String name, java.util.List<JavaType> parameterTypes)This method is NOT varArg aware.booleansignatureMatches(java.lang.String name, java.util.List<JavaType> parameterTypes, boolean varArg)java.lang.StringtoString()
-
-
-
Constructor Detail
-
JavaMethodDelegate
public JavaMethodDelegate(JavaClass callingClass, JavaMethod originalMethod)
-
-
Method Detail
-
getReturnType
public JavaType getReturnType(boolean resolve)
Description copied from interface:JavaMethodIf a class inherits this method from a generic class or interface, you can use this method to get the resolved return type- Specified by:
getReturnTypein 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:
getParameterTypesin interfaceJavaExecutable- Parameters:
resolve-trueif the resolved types should be returned, otherwisefalse- Returns:
- the parameter types
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
getAnnotations
public java.util.List<JavaAnnotation> getAnnotations()
Equivalent ofAnnotatedElement.getAnnotations()- Specified by:
getAnnotationsin interfaceJavaAnnotatedElement- Returns:
- a list of Annotations, never
null
-
getCallSignature
public java.lang.String getCallSignature()
- Specified by:
getCallSignaturein interfaceJavaExecutable- Specified by:
getCallSignaturein interfaceJavaMethod- Returns:
- the call signature
-
getCodeBlock
public java.lang.String getCodeBlock()
- Specified by:
getCodeBlockin interfaceJavaModel- Returns:
- the codeblock
-
getComment
public java.lang.String getComment()
Retrieve the javadoc comment of this annotated element. This is the part between/**and*/, but without the Standard doclet block tags. It may still contain Standard doclet inline tags, though.- Specified by:
getCommentin interfaceJavaAnnotatedElement- Returns:
- the comment, otherwise
null
-
getDeclaringClass
public JavaClass getDeclaringClass()
Equivalent ofMember.getDeclaringClass()- Specified by:
getDeclaringClassin interfaceJavaExecutable- Specified by:
getDeclaringClassin interfaceJavaMember- Returns:
- the declaring class
-
getDeclarationSignature
public java.lang.String getDeclarationSignature(boolean withModifiers)
- Specified by:
getDeclarationSignaturein interfaceJavaMethod- Parameters:
withModifiers-trueif modifiers should be added, otherwisefalse- Returns:
- the declaration signature
-
getExceptions
public java.util.List<JavaClass> getExceptions()
Equivalent ofExecutable.getExceptionTypes()- Specified by:
getExceptionsin interfaceJavaExecutable- Returns:
- a list of Exceptions, never
null
-
getExceptionTypes
public java.util.List<JavaType> getExceptionTypes()
- Specified by:
getExceptionTypesin interfaceJavaExecutable
-
isDefault
public boolean isDefault()
EquivalentMethod.isDefault()- Specified by:
isDefaultin interfaceJavaMethod- Returns:
trueif this is a default method of an interface, otherwisefalse
-
getLineNumber
public int getLineNumber()
The line number where this element started- Specified by:
getLineNumberin 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:
getModifiersin interfaceJavaMember- Returns:
- all modifiers is this member
-
getName
public java.lang.String getName()
Equivalent ofMember.getName()- Specified by:
getNamein 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:
getNamedParameterin 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:
getParameterByNamein interfaceJavaExecutable- Parameters:
name- the name of the parameter- Returns:
- the
JavaParametermatching 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:
getParametersin interfaceJavaExecutable- Returns:
- a list of JavaParameters, never
null
-
getPropertyName
public java.lang.String getPropertyName()
- Specified by:
getPropertyNamein interfaceJavaMethod- Returns:
- the name of the property this method represents, or
nullif this method is not a property mutator or property accessor.
-
getPropertyType
public JavaType getPropertyType()
- Specified by:
getPropertyTypein interfaceJavaMethod- Returns:
- the type of the property this method represents, or
nullif this method is not a property mutator or property accessor.
-
getReturns
public JavaClass getReturns()
- Specified by:
getReturnsin interfaceJavaMethod- Returns:
- the return type
-
getSourceCode
public java.lang.String getSourceCode()
Get the original source code of the body of this method.- Specified by:
getSourceCodein interfaceJavaExecutable- Returns:
- Code as string.
-
getTagByName
public DocletTag getTagByName(java.lang.String name, boolean inherited)
- Specified by:
getTagByNamein 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:
getTagByNamein 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:
getTagsin interfaceJavaAnnotatedElement- Returns:
- a list of DocletTags, never
null
-
getTagsByName
public java.util.List<DocletTag> getTagsByName(java.lang.String name, boolean inherited)
- Specified by:
getTagsByNamein interfaceJavaMethod
-
getTagsByName
public java.util.List<DocletTag> getTagsByName(java.lang.String name)
Retrieve all doclettags with a specific name.- Specified by:
getTagsByNamein 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:
getTypeParametersin interfaceJavaGenericDeclaration- Returns:
- a list of typeParameters, never
null
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
isAbstract
public boolean isAbstract()
Equivalent ofModifier.isAbstract(int)- Specified by:
isAbstractin interfaceJavaMember- Returns:
trueif this member isabstract, otherwisefalse
-
isFinal
public boolean isFinal()
Equivalent ofModifier.isFinal(int)- Specified by:
isFinalin interfaceJavaMember- Returns:
trueis this member isfinal, otherwisefalse
-
isNative
public boolean isNative()
Equivalent ofModifier.isNative(int)- Specified by:
isNativein interfaceJavaMember- Returns:
trueif this member isnative, otherwisefalse
-
isPrivate
public boolean isPrivate()
Equivalent ofModifier.isPrivate(int)- Specified by:
isPrivatein interfaceJavaMember- Returns:
trueif this member isprivate, otherwisefalse
-
isPropertyAccessor
public boolean isPropertyAccessor()
Returnstrueif 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:
isPropertyAccessorin interfaceJavaMethod- Returns:
trueif this method is a Java Bean accessor, otherwisefalse
-
isPropertyMutator
public boolean isPropertyMutator()
Returnstrueif 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:
isPropertyMutatorin interfaceJavaMethod- Returns:
trueif this method is a Java Bean mutator, otherwisefalse
-
isProtected
public boolean isProtected()
Equivalent ofModifier.isProtected(int)- Specified by:
isProtectedin interfaceJavaMember- Returns:
trueif this member isprotected; otherwisefalse
-
isPublic
public boolean isPublic()
Equivalent ofModifier.isPublic(int)- Specified by:
isPublicin interfaceJavaMember- Returns:
trueif this member ispublic, otherwisefalse
-
isStatic
public boolean isStatic()
Equivalent ofModifier.isStatic(int)- Specified by:
isStaticin interfaceJavaMember- Returns:
trueif this member isstatic, otherwisefalse
-
isStrictfp
public boolean isStrictfp()
Equivalent ofModifier.isStrict(int)- Specified by:
isStrictfpin interfaceJavaMember- Returns:
trueif this member isstrictfp, otherwisefalse
-
isSynchronized
public boolean isSynchronized()
Equivalent ofModifier.isSynchronized(int)- Specified by:
isSynchronizedin interfaceJavaMember- Returns:
trueif this member issynchronized, otherwisefalse
-
isTransient
public boolean isTransient()
Equivalent ofModifier.isTransient(int)- Specified by:
isTransientin interfaceJavaMember- Returns:
trueif this member istransient, otherwisefalse
-
isVarArgs
public boolean isVarArgs()
Equivalent ofExecutable.isVarArgs()- Specified by:
isVarArgsin interfaceJavaExecutable- Returns:
trueif the final parameter is a varArg, otherwisefalse
-
isVolatile
public boolean isVolatile()
Equivalent ofModifier.isVolatile(int)- Specified by:
isVolatilein interfaceJavaMember- Returns:
trueif this member isvolatile, otherwisefalse
-
signatureMatches
public boolean signatureMatches(java.lang.String name, java.util.List<JavaType> parameterTypes, boolean varArg)- Specified by:
signatureMatchesin interfaceJavaMethod- Parameters:
name- the name of the methodparameterTypes- the parameter types, can benullvarArg-trueis signature should match a varArg-method, otherwisefalse- Returns:
trueif 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:
signatureMatchesin interfaceJavaMethod- Parameters:
name- the name of the methodparameterTypes- the parameter types of the method, can benull- Returns:
trueif this method matches the signature, otherwisefalse
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
getReturnType
public JavaType getReturnType()
Equivalent of java.lang.reflect.Method.getReturnType()- Specified by:
getReturnTypein interfaceJavaMethod- Returns:
- the return type
-
getParameterTypes
public java.util.List<JavaType> getParameterTypes()
Equivalent ofExecutable.getParameterTypes()- Specified by:
getParameterTypesin interfaceJavaExecutable- Returns:
- a list of JavaParameters, never
null
-
-