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
- Author:
- Robert Scholte
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanEquivalent ofAnnotatedElement.getAnnotations()Retrieve the javadoc comment of this annotated element.getDeclarationSignature(boolean withModifiers) Equivalent ofMember.getDeclaringClass()Equivalent ofExecutable.getExceptionTypes()intThe 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()inthashCode()booleanEquivalent ofModifier.isAbstract(int)booleanEquivalentMethod.isDefault()booleanisFinal()Equivalent ofModifier.isFinal(int)booleanisNative()Equivalent ofModifier.isNative(int)booleanEquivalent ofModifier.isPrivate(int)booleanReturnstrueif this method follows the bean convention of being an accessor.booleanReturnstrueif this method follows the bean convention of being an mutator.booleanEquivalent ofModifier.isProtected(int)booleanisPublic()Equivalent ofModifier.isPublic(int)booleanisStatic()Equivalent ofModifier.isStatic(int)booleanEquivalent ofModifier.isStrict(int)booleanEquivalent ofModifier.isSynchronized(int)booleanEquivalent ofModifier.isTransient(int)booleanEquivalent ofExecutable.isVarArgs()booleanEquivalent ofModifier.isVolatile(int)booleansignatureMatches(String name, List<JavaType> parameterTypes) This method is NOT varArg aware.booleansignatureMatches(String name, List<JavaType> parameterTypes, boolean varArg) toString()
-
Constructor Details
-
JavaMethodDelegate
-
-
Method Details
-
getReturnType
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
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
-
getAnnotations
Equivalent ofAnnotatedElement.getAnnotations()- Specified by:
getAnnotationsin interfaceJavaAnnotatedElement- Returns:
- a list of Annotations, never
null
-
getCallSignature
- Specified by:
getCallSignaturein interfaceJavaExecutable- Specified by:
getCallSignaturein interfaceJavaMethod- Returns:
- the call signature
-
getCodeBlock
- Specified by:
getCodeBlockin interfaceJavaModel- Returns:
- the codeblock
-
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
Equivalent ofMember.getDeclaringClass()- Specified by:
getDeclaringClassin interfaceJavaExecutable- Specified by:
getDeclaringClassin interfaceJavaMember- Returns:
- the declaring class
-
getDeclarationSignature
- Specified by:
getDeclarationSignaturein interfaceJavaMethod- Parameters:
withModifiers-trueif modifiers should be added, otherwisefalse- Returns:
- the declaration signature
-
getExceptions
Equivalent ofExecutable.getExceptionTypes()- Specified by:
getExceptionsin interfaceJavaExecutable- Returns:
- a list of Exceptions, never
null
-
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
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
Equivalent ofMember.getName()- Specified by:
getNamein interfaceJavaMember- Returns:
- the name of this member
-
getNamedParameter
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
- Specified by:
getParameterByNamein interfaceJavaExecutable- Parameters:
name- the name of the parameter- Returns:
- the
JavaParametermatching the name, otherwisenull
-
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
- 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
- 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
- Specified by:
getReturnsin interfaceJavaMethod- Returns:
- the return type
-
getSourceCode
Get the original source code of the body of this method.- Specified by:
getSourceCodein interfaceJavaExecutable- Returns:
- Code as string.
-
getTagByName
- Specified by:
getTagByNamein interfaceJavaMethod
-
getTagByName
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
Retrieve all defined doclet tags.- Specified by:
getTagsin interfaceJavaAnnotatedElement- Returns:
- a list of DocletTags, never
null
-
getTagsByName
- Specified by:
getTagsByNamein interfaceJavaMethod
-
getTagsByName
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
Equivalent ofGenericDeclaration.getTypeParameters()- Specified by:
getTypeParametersin interfaceJavaGenericDeclaration- Returns:
- a list of typeParameters, never
null
-
hashCode
-
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
- 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
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
-
getReturnType
Equivalent of java.lang.reflect.Method.getReturnType()- Specified by:
getReturnTypein interfaceJavaMethod- Returns:
- the return type
-
getParameterTypes
Equivalent ofExecutable.getParameterTypes()- Specified by:
getParameterTypesin interfaceJavaExecutable- Returns:
- a list of JavaParameters, never
null
-