- 所有已知实现类:
DefaultJavaClass,DefaultJavaParameterizedType,DefaultJavaType,DefaultJavaTypeVariable,DefaultJavaWildcardType
Class, providing the most important methods.
Where the original Class is using an Array, this model is using a List.- 作者:
- Robert Scholte
-
方法概要
修饰符和类型方法说明Gets 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.intReturns 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 fieldgetFieldByName(String name, boolean publicOnly, boolean supperClass) Equivalent ofClass.getFields()getFields(boolean publicOnly, boolean supperClass) 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) booleanbooleanboolean(API description ofModifier.isAbstract(int)) Returntrueif the class includes the abstract modifier,falseotherwise.boolean(API description ofClass.isAnnotation())booleanisArray()booleanisEnum()(API description ofClass.isEnum())booleanisFinal()(API description ofModifier.isFinal(int))booleanisInner()boolean(API description ofClass.isInterface())booleanEquivalent ofClass.isPrimitive()boolean(API description ofModifier.isPrivate(int))boolean(API description ofModifier.isProtected(int))booleanisPublic()(API description ofModifier.isPublic(int))booleanisRecord()(API description ofClass.isRecord())booleanisStatic()(API description ofModifier.isStatic(int))booleanisVoid()toString()(API description ofClass.toString()) Converts the object to a string.从接口继承的方法 com.thoughtworks.qdox.model.JavaAnnotatedElement
getAnnotations, getComment, getNamedParameter, getTagByName, getTags, getTagsByName从接口继承的方法 com.thoughtworks.qdox.model.JavaGenericDeclaration
getTypeParameters从接口继承的方法 com.thoughtworks.qdox.model.JavaModel
getLineNumber从接口继承的方法 com.thoughtworks.qdox.model.JavaType
getBinaryName, getCanonicalName, getFullyQualifiedName, getGenericCanonicalName, getGenericFullyQualifiedName, getGenericValue, getValue, toGenericString
-
方法详细资料
-
getSource
JavaSource getSource()The compilation unit, which includes the imports, the public and anonymous classes- 返回:
- the
JavaSourceof this element
-
isInterface
boolean isInterface()(API description ofClass.isInterface())Determines if the specified
Classobject represents an interface type.- 返回:
trueif this object represents an interface, otherwisefalse
-
isEnum
boolean isEnum()(API description ofClass.isEnum())Returns
trueif and only if this class was declared as an enum in the source code.- 返回:
trueif this object represents an enum, otherwisefalse
-
isRecord
boolean isRecord()(API description ofClass.isRecord())Returns
trueif and only if this class was declared as a record in the source code.- 返回:
trueif this object represents a record, otherwisefalse
-
isAnnotation
boolean isAnnotation()(API description ofClass.isAnnotation())Returns true if this
Classobject represents an annotation type. Note that if this method returns true,isInterface()would also return true, as all annotation types are also interfaces.- 返回:
trueif this object represents an annotation, otherwisefalse- 从以下版本开始:
- 2.0
-
getDeclaringClass
JavaClass getDeclaringClass() -
getSuperClass
JavaType getSuperClass() -
getSuperJavaClass
JavaClass getSuperJavaClass()Shorthand for getSuperClass().getJavaClass() with null checking.- 返回:
- the super class as
JavaClass
-
getImplements
-
getInterfaces
Equivalent ofClass.getInterfaces()Determines the interfaces implemented by the class or interface represented by this object.- 返回:
- a list of interfaces, never
null - 从以下版本开始:
- 2.0
-
getCodeBlock
String getCodeBlock()- 指定者:
getCodeBlock在接口中JavaModel- 返回:
- the codeblock
-
getParentSource
JavaSource getParentSource() -
getPackage
JavaPackage getPackage()Equivalent ofClass.getPackage()- 返回:
- the package
-
getPackageName
String getPackageName()If this class has a package, the packagename will be returned. Otherwise an empty String.- 返回:
- the name of the package, otherwise an empty String
-
isInner
boolean isInner()- 返回:
trueif this class is an inner class, otherwisefalse- 从以下版本开始:
- 1.3
-
getMethods
List<JavaMethod> getMethods()Equivalent ofClass.getMethods()- 返回:
- the methods declared or overridden in this class
-
getConstructors
List<JavaConstructor> getConstructors()Equivalent ofClass.getConstructors()- 返回:
- the list of constructors
- 从以下版本开始:
- 2.0
-
getConstructor
- 参数:
parameterTypes- the parameter types of the constructor, can benull- 返回:
- the matching constructor, otherwise
null - 从以下版本开始:
- 2.0
-
getConstructor
- 参数:
parameterTypes- the parameter types of the constructor, can benullvarArg- define is the constructor has varArgs- 返回:
- the matching constructor, otherwise
null - 从以下版本开始:
- 2.0
-
getMethods
Return declared methods and optionally the inherited methods- 参数:
superclasses-trueif inherited methods should be returned as well- 返回:
- all methods
- 从以下版本开始:
- 1.3
-
getMethodBySignature
- 参数:
name- the name of the methodparameterTypes- the parameter types of the method, can benull.- 返回:
- the matching method, otherwise
null
-
getMethod
This should be the signature for getMethodBySignature.- 参数:
name- the name of the methodparameterTypes- the parameter types of the method, can benullvarArgs- define if the method has varArgs- 返回:
- the matching method, otherwise
null
-
getMethodBySignature
- 参数:
name- the name of the methodparameterTypes- the parameter types of the method, can benullsuperclasses- to define if superclasses should be included as well- 返回:
- the matching method, otherwise
null
-
getMethodBySignature
JavaMethod getMethodBySignature(String name, List<JavaType> parameterTypes, boolean superclasses, boolean varArg) - 参数:
name- the name of the methodparameterTypes- the parameter types of the method, can benullsuperclasses-trueif inherited methods should be matched as wellvarArg- define if the method has varArgs- 返回:
- the matching method, otherwise
null
-
getMethodsBySignature
List<JavaMethod> getMethodsBySignature(String name, List<JavaType> parameterTypes, boolean superclasses) - 参数:
name- the name of the methodparameterTypes- the parameter types of the method, can benullsuperclasses-trueif inherited methods should be matched as well- 返回:
- the matching methods, otherwise
null
-
getMethodsBySignature
List<JavaMethod> getMethodsBySignature(String name, List<JavaType> parameterTypes, boolean superclasses, boolean varArg) - 参数:
name- the name of the methodparameterTypes- the parameter types of the method, can benullsuperclasses-trueif inherited methods should be matched as wellvarArg- define if the method has varArgs- 返回:
- the matching methods, otherwise
null
-
getFields
Equivalent ofClass.getFields()- 返回:
- a list of fiels, never
null
-
getFieldByName
Equivalent ofClass.getField(String), where this method can resolve every field- 参数:
name- the name of the field- 返回:
- the field
-
getFields
-
getFieldByName
-
getEnumConstants
Based onClass.getEnumConstants().- 返回:
- a List of enum constants if this class is an
enum, otherwisenull
-
getEnumConstantByName
- 参数:
name- the name of the enum constant- 返回:
- the enumConstant matching the
name, otherwisenull
-
getNestedClasses
Equivalent ofClass.getDeclaredClasses()- 返回:
- a list of declared classes, never
null - 从以下版本开始:
- 1.3
-
getNestedClassByName
-
isA
- 参数:
fullyQualifiedName- the FQN to match with- 返回:
trueif this is of type FQN, otherwisefalse- 从以下版本开始:
- 1.3
-
isA
- 参数:
javaClass- the JavaClass to match with- 返回:
trueif this is of type javaClass, otherwisefalse- 从以下版本开始:
- 1.3
-
getDimensions
int getDimensions()Returns the depth of this array, 0 if it's not an array- 返回:
- The depth of this array, at least
0 - 从以下版本开始:
- 2.0
-
isArray
boolean isArray()- 返回:
trueif this JavaClass is an array, otherwisefalse- 从以下版本开始:
- 2.0
-
isVoid
boolean isVoid()- 返回:
trueif this JavaClass is a void, otherwisefalse- 从以下版本开始:
- 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- 返回:
- the type of array if it's one, otherwise
null
-
getBeanProperties
List<BeanProperty> getBeanProperties()Gets bean properties without looking in superclasses or interfaces.- 返回:
- the bean properties
- 从以下版本开始:
- 1.3
-
getBeanProperties
- 参数:
superclasses- to define if superclasses should be included as well- 返回:
- the bean properties
- 从以下版本开始:
- 1.3
-
getBeanProperty
Gets bean property without looking in superclasses or interfaces.- 参数:
propertyName- the name of the property- 返回:
- the bean property
- 从以下版本开始:
- 1.3
-
getBeanProperty
- 参数:
propertyName- the name of the propertysuperclasses- to define if superclasses should be included as well- 返回:
- the bean property
- 从以下版本开始:
- 1.3
-
getDerivedClasses
Equivalent ofClass.getClasses()Gets the known derived classes. That is, subclasses or implementing classes.- 返回:
- the derived classes
-
getTagsByName
-
getJavaClassLibrary
ClassLibrary getJavaClassLibrary() -
getInitializers
List<JavaInitializer> getInitializers()A list ifJavaInitializer, either static or instance initializers.- 返回:
- a List of initializers
-
getName
String getName()Equivalent ofClass.getName().- 返回:
- 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().- 返回:
- the simple name of the underlying class as given in the source code.
- 从以下版本开始:
- 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.- 返回:
- all modifiers is this member
-
isPublic
boolean isPublic()(API description ofModifier.isPublic(int))Return
trueif the class includes the public modifier,falseotherwise.- 返回:
trueif class has the public modifier, otherwisefalse
-
isProtected
boolean isProtected()(API description ofModifier.isProtected(int))Return
trueif the class includes the protected modifier,falseotherwise.- 返回:
trueif class has the protected modifier, otherwisefalse
-
isPrivate
boolean isPrivate()(API description ofModifier.isPrivate(int))Return
trueif the class includes the private modifier,falseotherwise.- 返回:
trueif class has the private modifier, otherwisefalse
-
isFinal
boolean isFinal()(API description ofModifier.isFinal(int))Return
trueif the class includes the final modifier,falseotherwise.- 返回:
trueif class has the final modifier, otherwisefalse
-
isStatic
boolean isStatic()(API description ofModifier.isStatic(int))Return
trueif the class includes the static modifier,falseotherwise.- 返回:
trueif class the static modifier, otherwisefalse
-
isAbstract
boolean isAbstract()(API description ofModifier.isAbstract(int)) Returntrueif the class includes the abstract modifier,falseotherwise.- 返回:
trueif class has the abstract modifier, otherwisefalse
-
isPrimitive
boolean isPrimitive()Equivalent ofClass.isPrimitive()- 返回:
trueif 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 thisClassobject represents a primitive type, this method returns the name of the primitive type. If thisClassobject represents void this method returns "void".
-