Package com.thoughtworks.qdox.model
Interface JavaClass
- All Superinterfaces:
JavaAnnotatedElement
,JavaGenericDeclaration
,JavaModel
,JavaType
,Serializable
- All Known Implementing Classes:
DefaultJavaClass
,DefaultJavaParameterizedType
,DefaultJavaType
,DefaultJavaTypeVariable
,DefaultJavaWildcardType
public interface JavaClass
extends JavaModel, JavaType, JavaAnnotatedElement, JavaGenericDeclaration
Equivalent of
Class
, providing the most important methods.
Where the original Class is using an Array, this model is using a List.-
Method Summary
Modifier and TypeMethodDescriptionGets bean properties without looking in superclasses or interfaces.getBeanProperties
(boolean superclasses) getBeanProperty
(String propertyName) Gets bean property without looking in superclasses or interfaces.getBeanProperty
(String propertyName, boolean superclasses) Equivalent ofClass.getComponentType()
If this type is an array, return its component typegetConstructor
(List<JavaType> parameterTypes) getConstructor
(List<JavaType> parameterTypes, boolean varArg) Equivalent ofClass.getConstructors()
Equivalent ofClass.getClasses()
Gets the known derived classes.int
Returns the depth of this array, 0 if it's not an arraygetEnumConstantByName
(String name) Based onClass.getEnumConstants()
.getFieldByName
(String name) Equivalent ofClass.getField(String)
, where this method can resolve every fieldEquivalent ofClass.getFields()
A list ifJavaInitializer
, either static or instance initializers.Equivalent ofClass.getInterfaces()
Determines the interfaces implemented by the class or interface represented by this object.This should be the signature for getMethodBySignature.getMethodBySignature
(String name, List<JavaType> parameterTypes) getMethodBySignature
(String name, List<JavaType> parameterTypes, boolean superclasses) getMethodBySignature
(String name, List<JavaType> parameterTypes, boolean superclasses, boolean varArg) Equivalent ofClass.getMethods()
getMethods
(boolean superclasses) Return declared methods and optionally the inherited methodsgetMethodsBySignature
(String name, List<JavaType> parameterTypes, boolean superclasses) getMethodsBySignature
(String name, List<JavaType> parameterTypes, boolean superclasses, boolean varArg) Equivalent ofClass.getModifiers()
This does not follow the java-api The Class.getModifiers() returns anint
, which should be decoded with theModifier
.getName()
Equivalent ofClass.getName()
.getNestedClassByName
(String name) Equivalent ofClass.getDeclaredClasses()
Equivalent ofClass.getPackage()
If this class has a package, the packagename will be returned.Equivalent ofClass.getSimpleName()
.The compilation unit, which includes the imports, the public and anonymous classesShorthand for getSuperClass().getJavaClass() with null checking.getTagsByName
(String name, boolean superclasses) boolean
boolean
boolean
(API description ofModifier.isAbstract(int)
) Returntrue
if the class includes the abstract modifier,false
otherwise.boolean
(API description ofClass.isAnnotation()
)boolean
isArray()
boolean
isEnum()
(API description ofClass.isEnum()
)boolean
isFinal()
(API description ofModifier.isFinal(int)
)boolean
isInner()
boolean
(API description ofClass.isInterface()
)boolean
Equivalent ofClass.isPrimitive()
boolean
(API description ofModifier.isPrivate(int)
)boolean
(API description ofModifier.isProtected(int)
)boolean
isPublic()
(API description ofModifier.isPublic(int)
)boolean
isStatic()
(API description ofModifier.isStatic(int)
)boolean
isVoid()
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 Details
-
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
-
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
String getCodeBlock()- Specified by:
getCodeBlock
in interfaceJavaModel
- Returns:
- the codeblock
-
getParentSource
JavaSource getParentSource() -
getPackage
JavaPackage getPackage()Equivalent ofClass.getPackage()
- Returns:
- the package
-
getPackageName
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
List<JavaMethod> getMethods()Equivalent ofClass.getMethods()
- Returns:
- the methods declared or overridden in this class
-
getConstructors
List<JavaConstructor> getConstructors()Equivalent ofClass.getConstructors()
- Returns:
- the list of constructors
- Since:
- 2.0
-
getConstructor
- Parameters:
parameterTypes
- the parameter types of the constructor, can benull
- Returns:
- the matching constructor, otherwise
null
- Since:
- 2.0
-
getConstructor
- 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
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
- Parameters:
name
- the name of the methodparameterTypes
- the parameter types of the method, can benull
.- Returns:
- the matching method, otherwise
null
-
getMethod
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
- 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(String name, 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
List<JavaMethod> getMethodsBySignature(String name, 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
List<JavaMethod> getMethodsBySignature(String name, 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
Equivalent ofClass.getFields()
- Returns:
- a list of fiels, never
null
-
getFieldByName
Equivalent ofClass.getField(String)
, where this method can resolve every field- Parameters:
name
- the name of the field- Returns:
- the field
-
getEnumConstants
Based onClass.getEnumConstants()
.- Returns:
- a List of enum constants if this class is an
enum
, otherwisenull
-
getEnumConstantByName
- Parameters:
name
- the name of the enum constant- Returns:
- the enumConstant matching the
name
, otherwisenull
-
getNestedClasses
Equivalent ofClass.getDeclaredClasses()
- Returns:
- a list of declared classes, never
null
- Since:
- 1.3
-
getNestedClassByName
-
isA
- Parameters:
fullyQualifiedName
- the FQN to match with- Returns:
true
if this is of type FQN, otherwisefalse
- Since:
- 1.3
-
isA
- 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
List<BeanProperty> getBeanProperties()Gets bean properties without looking in superclasses or interfaces.- Returns:
- the bean properties
- Since:
- 1.3
-
getBeanProperties
- Parameters:
superclasses
- to define if superclasses should be included as well- Returns:
- the bean properties
- Since:
- 1.3
-
getBeanProperty
Gets bean property without looking in superclasses or interfaces.- Parameters:
propertyName
- the name of the property- Returns:
- the bean property
- Since:
- 1.3
-
getBeanProperty
- Parameters:
propertyName
- the name of the propertysuperclasses
- to define if superclasses should be included as well- Returns:
- the bean property
- Since:
- 1.3
-
getDerivedClasses
Equivalent ofClass.getClasses()
Gets the known derived classes. That is, subclasses or implementing classes.- Returns:
- the derived classes
-
getTagsByName
-
getJavaClassLibrary
ClassLibrary getJavaClassLibrary() -
getInitializers
List<JavaInitializer> getInitializers()A list ifJavaInitializer
, either static or instance initializers.- Returns:
- a List of initializers
-
getName
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
String getSimpleName()Equivalent ofClass.getSimpleName()
.- Returns:
- the simple name of the underlying class as given in the source code.
- Since:
- 2.0
-
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
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".
-