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
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
defaultMethod
private JavaClass
returns
private java.util.List<JavaTypeVariable<JavaMethod>>
typeParameters
-
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 boolean
equals(java.lang.Object obj)
java.lang.String
getCodeBlock()
java.lang.String
getDeclarationSignature(boolean withModifiers)
java.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.util.List<JavaTypeVariable<JavaMethod>>
getTypeParameters()
Equivalent ofGenericDeclaration.getTypeParameters()
int
hashCode()
boolean
isDefault()
EquivalentMethod.isDefault()
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.void
setDefault(boolean defaultMethod)
void
setReturns(JavaClass returns)
Define the return type of this methodvoid
setTypeParameters(java.util.List<JavaTypeVariable<JavaMethod>> typeParameters)
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()
-
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
-
-
-
-
Field Detail
-
defaultMethod
private boolean defaultMethod
-
returns
private JavaClass returns
-
typeParameters
private java.util.List<JavaTypeVariable<JavaMethod>> typeParameters
-
-
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:
isDefault
in interfaceJavaMethod
- Returns:
true
if this is a default method of an interface, otherwisefalse
-
setDefault
public void setDefault(boolean defaultMethod)
-
getReturns
public JavaClass getReturns()
- Specified by:
getReturns
in interfaceJavaMethod
- Overrides:
getReturns
in 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:
getTypeParameters
in interfaceJavaGenericDeclaration
- Returns:
- a list of typeParameters, never
null
-
getCodeBlock
public java.lang.String getCodeBlock()
- Specified by:
getCodeBlock
in interfaceJavaModel
- Returns:
- the codeblock
-
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
-
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:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
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
-
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.
-
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.
-
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
-
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:
getReturnType
in 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:
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
-
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
-
-