Package com.thoughtworks.qdox.model
Interface JavaClass
-
- All Superinterfaces:
JavaAnnotatedElement
,JavaGenericDeclaration
,JavaModel
,JavaType
,java.io.Serializable
- All Known Implementing Classes:
DefaultJavaClass
,DefaultJavaParameterizedType
,DefaultJavaType
,DefaultJavaTypeVariable
,DefaultJavaWildcardType
public interface JavaClass extends JavaModel, JavaType, JavaAnnotatedElement, JavaGenericDeclaration
Equivalent ofClass
, providing the most important methods. Where the original Class is using an Array, this model is using a List.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.util.List<BeanProperty>
getBeanProperties()
Gets bean properties without looking in superclasses or interfaces.java.util.List<BeanProperty>
getBeanProperties(boolean superclasses)
BeanProperty
getBeanProperty(java.lang.String propertyName)
Gets bean property without looking in superclasses or interfaces.BeanProperty
getBeanProperty(java.lang.String propertyName, boolean superclasses)
java.lang.String
getCodeBlock()
JavaClass
getComponentType()
Equivalent ofClass.getComponentType()
If this type is an array, return its component typeJavaConstructor
getConstructor(java.util.List<JavaType> parameterTypes)
JavaConstructor
getConstructor(java.util.List<JavaType> parameterTypes, boolean varArg)
java.util.List<JavaConstructor>
getConstructors()
Equivalent ofClass.getConstructors()
JavaClass
getDeclaringClass()
java.util.List<JavaClass>
getDerivedClasses()
Equivalent ofClass.getClasses()
Gets the known derived classes.int
getDimensions()
Returns the depth of this array, 0 if it's not an arrayJavaField
getEnumConstantByName(java.lang.String name)
java.util.List<JavaField>
getEnumConstants()
Based onClass.getEnumConstants()
.JavaField
getFieldByName(java.lang.String name)
Equivalent ofClass.getField(String)
, where this method can resolve every fieldjava.util.List<JavaField>
getFields()
Equivalent ofClass.getFields()
java.util.List<JavaType>
getImplements()
java.util.List<JavaInitializer>
getInitializers()
A list ifJavaInitializer
, either static or instance initializers.java.util.List<JavaClass>
getInterfaces()
Equivalent ofClass.getInterfaces()
Determines the interfaces implemented by the class or interface represented by this object.ClassLibrary
getJavaClassLibrary()
JavaMethod
getMethod(java.lang.String name, java.util.List<JavaType> parameterTypes, boolean varArgs)
This should be the signature for getMethodBySignature.JavaMethod
getMethodBySignature(java.lang.String name, java.util.List<JavaType> parameterTypes)
JavaMethod
getMethodBySignature(java.lang.String name, java.util.List<JavaType> parameterTypes, boolean superclasses)
JavaMethod
getMethodBySignature(java.lang.String name, java.util.List<JavaType> parameterTypes, boolean superclasses, boolean varArg)
java.util.List<JavaMethod>
getMethods()
Equivalent ofClass.getMethods()
java.util.List<JavaMethod>
getMethods(boolean superclasses)
Return declared methods and optionally the inherited methodsjava.util.List<JavaMethod>
getMethodsBySignature(java.lang.String name, java.util.List<JavaType> parameterTypes, boolean superclasses)
java.util.List<JavaMethod>
getMethodsBySignature(java.lang.String name, java.util.List<JavaType> parameterTypes, boolean superclasses, boolean varArg)
java.util.List<java.lang.String>
getModifiers()
Equivalent ofClass.getModifiers()
This does not follow the java-api The Class.getModifiers() returns anint
, which should be decoded with theModifier
.java.lang.String
getName()
Equivalent ofClass.getName()
.JavaClass
getNestedClassByName(java.lang.String name)
java.util.List<JavaClass>
getNestedClasses()
Equivalent ofClass.getDeclaredClasses()
JavaPackage
getPackage()
Equivalent ofClass.getPackage()
java.lang.String
getPackageName()
If this class has a package, the packagename will be returned.JavaSource
getParentSource()
java.lang.String
getSimpleName()
Equivalent ofClass.getSimpleName()
.JavaSource
getSource()
The compilation unit, which includes the imports, the public and anonymous classesJavaType
getSuperClass()
JavaClass
getSuperJavaClass()
Shorthand for getSuperClass().getJavaClass() with null checking.java.util.List<DocletTag>
getTagsByName(java.lang.String name, boolean superclasses)
boolean
isA(JavaClass javaClass)
boolean
isA(java.lang.String fullyQualifiedName)
boolean
isAbstract()
(API description ofModifier.isAbstract(int)
) Returntrue
if the class includes the abstract modifier,false
otherwise.boolean
isAnnotation()
(API description ofClass.isAnnotation()
)boolean
isArray()
boolean
isEnum()
(API description ofClass.isEnum()
)boolean
isFinal()
(API description ofModifier.isFinal(int)
)boolean
isInner()
boolean
isInterface()
(API description ofClass.isInterface()
)boolean
isPrimitive()
Equivalent ofClass.isPrimitive()
boolean
isPrivate()
(API description ofModifier.isPrivate(int)
)boolean
isProtected()
(API description ofModifier.isProtected(int)
)boolean
isPublic()
(API description ofModifier.isPublic(int)
)boolean
isStatic()
(API description ofModifier.isStatic(int)
)boolean
isVoid()
java.lang.String
toString()
(API description ofClass.toString()
) Converts the object to a string.-
Methods inherited from interface com.thoughtworks.qdox.model.JavaAnnotatedElement
getAnnotations, getComment, getNamedParameter, getTagByName, getTags, getTagsByName
-
Methods inherited from interface com.thoughtworks.qdox.model.JavaGenericDeclaration
getTypeParameters
-
Methods inherited from interface com.thoughtworks.qdox.model.JavaModel
getLineNumber
-
Methods inherited from interface com.thoughtworks.qdox.model.JavaType
getBinaryName, getCanonicalName, getFullyQualifiedName, getGenericCanonicalName, getGenericFullyQualifiedName, getGenericValue, getValue, toGenericString
-
-
-
-
Method Detail
-
getSource
JavaSource getSource()
The compilation unit, which includes the imports, the public and anonymous classes- Returns:
- the
JavaSource
of this element
-
isInterface
boolean isInterface()
(API description ofClass.isInterface()
)Determines if the specified
Class
object represents an interface type.- Returns:
true
if this object represents an interface, otherwisefalse
-
isEnum
boolean isEnum()
(API description ofClass.isEnum()
)Returns
true
if and only if this class was declared as an enum in the source code.- Returns:
true
if this object represents an enum, otherwisefalse
-
isAnnotation
boolean isAnnotation()
(API description ofClass.isAnnotation()
)Returns true if this
Class
object represents an annotation type. Note that if this method returns true,isInterface()
would also return true, as all annotation types are also interfaces.- Returns:
true
if this object represents an annotation, otherwisefalse
- Since:
- 2.0
-
getDeclaringClass
JavaClass getDeclaringClass()
-
getSuperClass
JavaType getSuperClass()
-
getSuperJavaClass
JavaClass getSuperJavaClass()
Shorthand for getSuperClass().getJavaClass() with null checking.- Returns:
- the super class as
JavaClass
-
getImplements
java.util.List<JavaType> getImplements()
-
getInterfaces
java.util.List<JavaClass> getInterfaces()
Equivalent ofClass.getInterfaces()
Determines the interfaces implemented by the class or interface represented by this object.- Returns:
- a list of interfaces, never
null
- Since:
- 2.0
-
getCodeBlock
java.lang.String getCodeBlock()
- Specified by:
getCodeBlock
in interfaceJavaModel
- Returns:
- the codeblock
-
getParentSource
JavaSource getParentSource()
-
getPackage
JavaPackage getPackage()
Equivalent ofClass.getPackage()
- Returns:
- the package
-
getPackageName
java.lang.String getPackageName()
If this class has a package, the packagename will be returned. Otherwise an empty String.- Returns:
- the name of the package, otherwise an empty String
-
isInner
boolean isInner()
- Returns:
true
if this class is an inner class, otherwisefalse
- Since:
- 1.3
-
getMethods
java.util.List<JavaMethod> getMethods()
Equivalent ofClass.getMethods()
- Returns:
- the methods declared or overridden in this class
-
getConstructors
java.util.List<JavaConstructor> getConstructors()
Equivalent ofClass.getConstructors()
- Returns:
- the list of constructors
- Since:
- 2.0
-
getConstructor
JavaConstructor getConstructor(java.util.List<JavaType> parameterTypes)
- Parameters:
parameterTypes
- the parameter types of the constructor, can benull
- Returns:
- the matching constructor, otherwise
null
- Since:
- 2.0
-
getConstructor
JavaConstructor getConstructor(java.util.List<JavaType> parameterTypes, boolean varArg)
- Parameters:
parameterTypes
- the parameter types of the constructor, can benull
varArg
- define is the constructor has varArgs- Returns:
- the matching constructor, otherwise
null
- Since:
- 2.0
-
getMethods
java.util.List<JavaMethod> getMethods(boolean superclasses)
Return declared methods and optionally the inherited methods- Parameters:
superclasses
-true
if inherited methods should be returned as well- Returns:
- all methods
- Since:
- 1.3
-
getMethodBySignature
JavaMethod getMethodBySignature(java.lang.String name, java.util.List<JavaType> parameterTypes)
- Parameters:
name
- the name of the methodparameterTypes
- the parameter types of the method, can benull
.- Returns:
- the matching method, otherwise
null
-
getMethod
JavaMethod getMethod(java.lang.String name, java.util.List<JavaType> parameterTypes, boolean varArgs)
This should be the signature for getMethodBySignature.- Parameters:
name
- the name of the methodparameterTypes
- the parameter types of the method, can benull
varArgs
- define if the method has varArgs- Returns:
- the matching method, otherwise
null
-
getMethodBySignature
JavaMethod getMethodBySignature(java.lang.String name, java.util.List<JavaType> parameterTypes, boolean superclasses)
- Parameters:
name
- the name of the methodparameterTypes
- the parameter types of the method, can benull
superclasses
- to define if superclasses should be included as well- Returns:
- the matching method, otherwise
null
-
getMethodBySignature
JavaMethod getMethodBySignature(java.lang.String name, java.util.List<JavaType> parameterTypes, boolean superclasses, boolean varArg)
- Parameters:
name
- the name of the methodparameterTypes
- the parameter types of the method, can benull
superclasses
-true
if inherited methods should be matched as wellvarArg
- define if the method has varArgs- Returns:
- the matching method, otherwise
null
-
getMethodsBySignature
java.util.List<JavaMethod> getMethodsBySignature(java.lang.String name, java.util.List<JavaType> parameterTypes, boolean superclasses)
- Parameters:
name
- the name of the methodparameterTypes
- the parameter types of the method, can benull
superclasses
-true
if inherited methods should be matched as well- Returns:
- the matching methods, otherwise
null
-
getMethodsBySignature
java.util.List<JavaMethod> getMethodsBySignature(java.lang.String name, java.util.List<JavaType> parameterTypes, boolean superclasses, boolean varArg)
- Parameters:
name
- the name of the methodparameterTypes
- the parameter types of the method, can benull
superclasses
-true
if inherited methods should be matched as wellvarArg
- define if the method has varArgs- Returns:
- the matching methods, otherwise
null
-
getFields
java.util.List<JavaField> getFields()
Equivalent ofClass.getFields()
- Returns:
- a list of fiels, never
null
-
getFieldByName
JavaField getFieldByName(java.lang.String name)
Equivalent ofClass.getField(String)
, where this method can resolve every field- Parameters:
name
- the name of the field- Returns:
- the field
-
getEnumConstants
java.util.List<JavaField> getEnumConstants()
Based onClass.getEnumConstants()
.- Returns:
- a List of enum constants if this class is an
enum
, otherwisenull
-
getEnumConstantByName
JavaField getEnumConstantByName(java.lang.String name)
- Parameters:
name
- the name of the enum constant- Returns:
- the enumConstant matching the
name
, otherwisenull
-
getNestedClasses
java.util.List<JavaClass> getNestedClasses()
Equivalent ofClass.getDeclaredClasses()
- Returns:
- a list of declared classes, never
null
- Since:
- 1.3
-
getNestedClassByName
JavaClass getNestedClassByName(java.lang.String name)
-
isA
boolean isA(java.lang.String fullyQualifiedName)
- Parameters:
fullyQualifiedName
- the FQN to match with- Returns:
true
if this is of type FQN, otherwisefalse
- Since:
- 1.3
-
isA
boolean isA(JavaClass javaClass)
- Parameters:
javaClass
- the JavaClass to match with- Returns:
true
if this is of type javaClass, otherwisefalse
- Since:
- 1.3
-
getDimensions
int getDimensions()
Returns the depth of this array, 0 if it's not an array- Returns:
- The depth of this array, at least
0
- Since:
- 2.0
-
isArray
boolean isArray()
- Returns:
true
if this JavaClass is an array, otherwisefalse
- Since:
- 2.0
-
isVoid
boolean isVoid()
- Returns:
true
if this JavaClass is a void, otherwisefalse
- Since:
- 2.0 (was part of Type since 1.6)
-
getComponentType
JavaClass getComponentType()
Equivalent ofClass.getComponentType()
If this type is an array, return its component type- Returns:
- the type of array if it's one, otherwise
null
-
getBeanProperties
java.util.List<BeanProperty> getBeanProperties()
Gets bean properties without looking in superclasses or interfaces.- Returns:
- the bean properties
- Since:
- 1.3
-
getBeanProperties
java.util.List<BeanProperty> getBeanProperties(boolean superclasses)
- Parameters:
superclasses
- to define if superclasses should be included as well- Returns:
- the bean properties
- Since:
- 1.3
-
getBeanProperty
BeanProperty getBeanProperty(java.lang.String propertyName)
Gets bean property without looking in superclasses or interfaces.- Parameters:
propertyName
- the name of the property- Returns:
- the bean property
- Since:
- 1.3
-
getBeanProperty
BeanProperty getBeanProperty(java.lang.String propertyName, boolean superclasses)
- Parameters:
propertyName
- the name of the propertysuperclasses
- to define if superclasses should be included as well- Returns:
- the bean property
- Since:
- 1.3
-
getDerivedClasses
java.util.List<JavaClass> getDerivedClasses()
Equivalent ofClass.getClasses()
Gets the known derived classes. That is, subclasses or implementing classes.- Returns:
- the derived classes
-
getTagsByName
java.util.List<DocletTag> getTagsByName(java.lang.String name, boolean superclasses)
-
getJavaClassLibrary
ClassLibrary getJavaClassLibrary()
-
getInitializers
java.util.List<JavaInitializer> getInitializers()
A list ifJavaInitializer
, either static or instance initializers.- Returns:
- a List of initializers
-
getName
java.lang.String getName()
Equivalent ofClass.getName()
.- Returns:
- the name of the entity (class, interface, array class, primitive type, or void) represented by this Class object, as a String.
-
getSimpleName
java.lang.String getSimpleName()
Equivalent ofClass.getSimpleName()
.- Returns:
- the simple name of the underlying class as given in the source code.
- Since:
- 2.0
-
getModifiers
java.util.List<java.lang.String> getModifiers()
Equivalent ofClass.getModifiers()
This does not follow the java-api The Class.getModifiers() returns anint
, which should be decoded with theModifier
. This method will return a list of strings representing the modifiers. 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.- Returns:
- all modifiers is this member
-
isPublic
boolean isPublic()
(API description ofModifier.isPublic(int)
)Return
true
if the class includes the public modifier,false
otherwise.- Returns:
true
if class has the public modifier, otherwisefalse
-
isProtected
boolean isProtected()
(API description ofModifier.isProtected(int)
)Return
true
if the class includes the protected modifier,false
otherwise.- Returns:
true
if class has the protected modifier, otherwisefalse
-
isPrivate
boolean isPrivate()
(API description ofModifier.isPrivate(int)
)Return
true
if the class includes the private modifier,false
otherwise.- Returns:
true
if class has the private modifier, otherwisefalse
-
isFinal
boolean isFinal()
(API description ofModifier.isFinal(int)
)Return
true
if the class includes the final modifier,false
otherwise.- Returns:
true
if class has the final modifier, otherwisefalse
-
isStatic
boolean isStatic()
(API description ofModifier.isStatic(int)
)Return
true
if the class includes the static modifier,false
otherwise.- Returns:
true
if class the static modifier, otherwisefalse
-
isAbstract
boolean isAbstract()
(API description ofModifier.isAbstract(int)
) Returntrue
if the class includes the abstract modifier,false
otherwise.- Returns:
true
if class has the abstract modifier, otherwisefalse
-
isPrimitive
boolean isPrimitive()
Equivalent ofClass.isPrimitive()
- Returns:
true
if this class represents a primitive, otherwisefalse
-
toString
java.lang.String toString()
(API description ofClass.toString()
) Converts the object to a string. The string representation is the string "class" or "interface", followed by a space, and then by the fully qualified name of the class in the format returned bygetName
. If thisClass
object represents a primitive type, this method returns the name of the primitive type. If thisClass
object represents void this method returns "void".- Overrides:
toString
in classjava.lang.Object
- Returns:
- a string representation of this class object.
-
-