Package com.thoughtworks.qdox.model.impl
Class DefaultJavaMethod
- java.lang.Object
-
- All Implemented Interfaces:
JavaAnnotatedElement,JavaExecutable,JavaGenericDeclaration,JavaMember,JavaMethod,JavaModel,java.io.Serializable
public class DefaultJavaMethod extends DefaultJavaExecutable implements JavaMethod
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description DefaultJavaMethod()The default constructorDefaultJavaMethod(JavaClass returns, java.lang.String name)Create a new method without parametersDefaultJavaMethod(java.lang.String name)Create new method without parameters and return type
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object obj)java.lang.StringgetCodeBlock()java.lang.StringgetDeclarationSignature(boolean withModifiers)java.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.util.List<JavaTypeVariable<JavaMethod>>getTypeParameters()Equivalent ofGenericDeclaration.getTypeParameters()inthashCode()booleanisDefault()EquivalentMethod.isDefault()booleanisPropertyAccessor()Returnstrueif this method follows the bean convention of being an accessor.booleanisPropertyMutator()Returnstrueif this method follows the bean convention of being an mutator.voidsetDefault(boolean defaultMethod)voidsetReturns(JavaClass returns)Define the return type of this methodvoidsetTypeParameters(java.util.List<JavaTypeVariable<JavaMethod>> typeParameters)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()-
Methods inherited from class com.thoughtworks.qdox.model.impl.DefaultJavaExecutable
getCallSignature, getExceptions, getExceptionTypes, getParameterByName, getParameters, getParameterTypes, getParameterTypes, getSignature, getSourceCode, getTagsByName, isPublic, isVarArgs, setExceptions, setParameters, setSourceCode, signatureMatches
-
Methods inherited from class com.thoughtworks.qdox.model.impl.AbstractInheritableJavaEntity
getTagByName
-
Methods inherited from class com.thoughtworks.qdox.model.impl.AbstractJavaEntity
getDeclaringClass, getModifiers, getName, isAbstract, isFinal, isNative, isPrivate, isProtected, isStatic, isStrictfp, isSynchronized, isTransient, isVolatile, setDeclaringClass, setModifiers, setName
-
Methods inherited from class com.thoughtworks.qdox.model.impl.AbstractBaseJavaEntity
getAnnotations, getComment, getNamedParameter, getSource, getTagByName, getTags, getTagsByName, setAnnotations, setComment, setSource, setTags
-
Methods inherited from class com.thoughtworks.qdox.model.impl.AbstractJavaModel
getLineNumber, getModelWriter, setLineNumber, setModelWriterFactory
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.thoughtworks.qdox.model.JavaAnnotatedElement
getAnnotations, getComment, getNamedParameter, getTagByName, getTags, getTagsByName
-
Methods inherited from interface com.thoughtworks.qdox.model.JavaExecutable
getDeclaringClass, getExceptions, getExceptionTypes, getParameterByName, getParameters, getParameterTypes, getParameterTypes, getSourceCode, isVarArgs
-
Methods inherited from interface com.thoughtworks.qdox.model.JavaMember
getModifiers, getName, isAbstract, isFinal, isNative, isPrivate, isProtected, isPublic, isStatic, isStrictfp, isSynchronized, isTransient, isVolatile
-
Methods inherited from interface com.thoughtworks.qdox.model.JavaMethod
getCallSignature, getTagByName, getTagsByName
-
Methods inherited from interface com.thoughtworks.qdox.model.JavaModel
getLineNumber
-
-
-
-
Constructor Detail
-
DefaultJavaMethod
public DefaultJavaMethod()
The default constructor
-
DefaultJavaMethod
public DefaultJavaMethod(java.lang.String name)
Create new method without parameters and return type- Parameters:
name- the name of the method
-
DefaultJavaMethod
public DefaultJavaMethod(JavaClass returns, java.lang.String name)
Create a new method without parameters- Parameters:
returns- the return typename- the name of this method
-
-
Method Detail
-
isDefault
public boolean isDefault()
EquivalentMethod.isDefault()- Specified by:
isDefaultin interfaceJavaMethod- Returns:
trueif this is a default method of an interface, otherwisefalse
-
setDefault
public void setDefault(boolean defaultMethod)
-
getReturns
public JavaClass getReturns()
- Specified by:
getReturnsin interfaceJavaMethod- Overrides:
getReturnsin classDefaultJavaExecutable- Returns:
- the return type
-
setTypeParameters
public void setTypeParameters(java.util.List<JavaTypeVariable<JavaMethod>> typeParameters)
-
getTypeParameters
public java.util.List<JavaTypeVariable<JavaMethod>> getTypeParameters()
Equivalent ofGenericDeclaration.getTypeParameters()- Specified by:
getTypeParametersin interfaceJavaGenericDeclaration- Returns:
- a list of typeParameters, never
null
-
getCodeBlock
public java.lang.String getCodeBlock()
- Specified by:
getCodeBlockin interfaceJavaModel- Returns:
- the codeblock
-
getDeclarationSignature
public java.lang.String getDeclarationSignature(boolean withModifiers)
- Specified by:
getDeclarationSignaturein interfaceJavaMethod- Parameters:
withModifiers-trueif modifiers should be added, otherwisefalse- Returns:
- the declaration signature
-
setReturns
public void setReturns(JavaClass returns)
Define the return type of this method- Parameters:
returns- the return type
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
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
-
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.
-
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.
-
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
-
getReturnType
public 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 type- Specified by:
getReturnTypein interfaceJavaMethod- Parameters:
resolve- define if generic should be resolved- Returns:
- the return type
-
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
-
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
-
-