Package com.thoughtworks.qdox.model.impl
Class DefaultJavaClass
- All Implemented Interfaces:
JavaAnnotatedElement,JavaClass,JavaGenericDeclaration,JavaModel,JavaType,Serializable
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanprivate booleanprivate booleanprivate List<JavaConstructor>private List<JavaInitializer>private JavaPackageprivate List<JavaMethod>private JavaTypeprivate List<DefaultJavaTypeVariable<JavaClass>> -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedDefaultJavaClass(JavaSource source) DefaultJavaClass(String name) -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidaddConstructor(JavaConstructor constructor) voidvoidaddInitializer(JavaInitializer initializer) voidaddMethod(JavaMethod meth) booleanGets 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) private Map<String,BeanProperty> getBeanPropertyMap(boolean superclasses) The class or interface must be named by its binary name, which must meet the following constraints: The binary name of a top level type is its canonical name. The binary name of a member type consists of the binary name of its immediately enclosing type, followed by $, followed by the simple name of the member.Equivalent of (@linkClass.getCanonicalName().Equivalent ofClass.getComponentType()If this type is an array, return its component typegetConstructor(List<JavaType> parameterTypes) getConstructor(List<JavaType> parameterTypes, boolean varArgs) 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 fieldEquivalent ofClass.getFields()Every primitive type, named package, top level class, and top level interface has a fully qualified name: The fully qualified name of a primitive type is the keyword for that primitive type, namely byte, short, char, int, long, float, double, or boolean. The fully qualified name of a named package that is not a subpackage of a named package is its simple name. The fully qualified name of a named package that is a subpackage of another named package consists of the fully qualified name of the containing package, followed by ".", followed by the simple (member) name of the subpackage. The fully qualified name of a top level class or top level interface that is declared in an unnamed package is the simple name of the class or interface. The fully qualified name of a top level class or top level interface that is declared in a named package consists of the fully qualified name of the package, followed by ".", followed by the simple name of the class or interface. Each member class, member interface, and array type may have a fully qualified name: A member class or member interface M of another class or interface C has a fully qualified name if and only if C has a fully qualified name. In that case, the fully qualified name of M consists of the fully qualified name of C, followed by ".", followed by the simple name of M. An array type has a fully qualified name if and only if its element type has a fully qualified name. In that case, the fully qualified name of an array type consists of the fully qualified name of the component type of the array type followed by "[]". Some examples how names will be translatedThe canonical name with generic information.The fully qualified name with generic information.A java5+ representation of the class.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) private static Map<String,JavaMethod> getMethodsFromSuperclassAndInterfaces(JavaClass rootClass, JavaClass callingClazz) getNestedClassByName(String name) Equivalent ofClass.getDeclaredClasses()private DefaultBeanPropertygetOrCreateProperty(Map<String, DefaultBeanProperty> beanPropertyMap, String propertyName) 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) getTagsRecursive(JavaClass javaClass, String name, boolean superclasses) Equivalent ofGenericDeclaration.getTypeParameters()getValue()If there's a reference to this class, use the value used in the code.inthashCode()booleanbooleanboolean(API description ofClass.isAnnotation())booleanisArray()booleanisEnum()(API description ofClass.isEnum())booleanisInner()boolean(API description ofClass.isInterface())booleanEquivalent ofClass.isPrimitive()booleanisVoid()voidsetAnnotation(boolean anAnnotation) voidsetEnum(boolean anEnum) voidsetImplementz(List<JavaClass> implementz) voidsetInterface(boolean anInterface) voidsetJavaPackage(JavaPackage javaPackage) Only used when constructing the model by hand / without sourcevoidsetSuperClass(JavaType type) voidsetTypeParameters(List<DefaultJavaTypeVariable<JavaClass>> typeParameters) toString()(API description ofClass.toString()) Converts the object to a string.Methods inherited from class com.thoughtworks.qdox.model.impl.AbstractInheritableJavaEntity
getTagByNameMethods inherited from class com.thoughtworks.qdox.model.impl.AbstractJavaEntity
getDeclaringClass, getModifiers, getName, isAbstract, isFinal, isNative, isPrivate, isProtected, isPublic, isStatic, isStrictfp, isSynchronized, isTransient, isVolatile, setDeclaringClass, setModifiers, setNameMethods inherited from class com.thoughtworks.qdox.model.impl.AbstractBaseJavaEntity
getAnnotations, getComment, getNamedParameter, getTagByName, getTags, getTagsByName, setAnnotations, setComment, setSource, setTagsMethods inherited from class com.thoughtworks.qdox.model.impl.AbstractJavaModel
getLineNumber, getModelWriter, setLineNumber, setModelWriterFactoryMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface com.thoughtworks.qdox.model.JavaAnnotatedElement
getAnnotations, getComment, getNamedParameter, getTagByName, getTags, getTagsByNameMethods inherited from interface com.thoughtworks.qdox.model.JavaClass
getDeclaringClass, getModifiers, getName, isAbstract, isFinal, isPrivate, isProtected, isPublic, isStaticMethods inherited from interface com.thoughtworks.qdox.model.JavaModel
getLineNumber
-
Field Details
-
constructors
-
methods
-
fields
-
classes
-
anInterface
private boolean anInterface -
anEnum
private boolean anEnum -
anAnnotation
private boolean anAnnotation -
superClass
-
implementz
-
initializers
-
typeParameters
-
javaPackage
-
-
Constructor Details
-
DefaultJavaClass
protected DefaultJavaClass() -
DefaultJavaClass
-
DefaultJavaClass
-
-
Method Details
-
isInterface
public boolean isInterface()(API description ofClass.isInterface())Determines if the specified
Classobject represents an interface type.- Specified by:
isInterfacein interfaceJavaClass- Returns:
trueif this object represents an interface, otherwisefalse
-
isPrimitive
public boolean isPrimitive()Equivalent ofClass.isPrimitive()- Specified by:
isPrimitivein interfaceJavaClass- Returns:
trueif this class represents a primitive, otherwisefalse
-
isVoid
public boolean isVoid() -
isEnum
public boolean isEnum()(API description ofClass.isEnum())Returns
trueif and only if this class was declared as an enum in the source code. -
isAnnotation
public boolean isAnnotation()(API description ofClass.isAnnotation())Returns true if this
Classobject represents an annotation type. Note that if this method returns true,JavaClass.isInterface()would also return true, as all annotation types are also interfaces.- Specified by:
isAnnotationin interfaceJavaClass- Returns:
trueif this object represents an annotation, otherwisefalse
-
isArray
public boolean isArray() -
getComponentType
Equivalent ofClass.getComponentType()If this type is an array, return its component type- Specified by:
getComponentTypein interfaceJavaClass- Returns:
- the type of array if it's one, otherwise
null
-
getDimensions
public int getDimensions()Returns the depth of this array, 0 if it's not an array- Specified by:
getDimensionsin interfaceJavaClass- Returns:
- The depth of this array, at least
0
-
getSuperClass
- Specified by:
getSuperClassin interfaceJavaClass
-
getSuperJavaClass
Shorthand for getSuperClass().getJavaClass() with null checking.- Specified by:
getSuperJavaClassin interfaceJavaClass- Returns:
- the super class as
JavaClass
-
getImplements
- Specified by:
getImplementsin interfaceJavaClass
-
getInterfaces
Equivalent ofClass.getInterfaces()Determines the interfaces implemented by the class or interface represented by this object.- Specified by:
getInterfacesin interfaceJavaClass- Returns:
- a list of interfaces, never
null
-
getCodeBlock
- Specified by:
getCodeBlockin interfaceJavaClass- Specified by:
getCodeBlockin interfaceJavaModel- Returns:
- the codeblock
-
setInterface
public void setInterface(boolean anInterface) -
setEnum
public void setEnum(boolean anEnum) -
setAnnotation
public void setAnnotation(boolean anAnnotation) -
addConstructor
-
addMethod
-
setSuperClass
-
setImplementz
-
getTypeParameters
Equivalent ofGenericDeclaration.getTypeParameters()- Specified by:
getTypeParametersin interfaceJavaGenericDeclaration- Returns:
- a list of typeParameters, never
null
-
setTypeParameters
-
addField
-
setJavaPackage
Only used when constructing the model by hand / without source- Parameters:
javaPackage- the package
-
getParentSource
- Specified by:
getParentSourcein interfaceJavaClass
-
getSource
The compilation unit, which includes the imports, the public and anonymous classes- Specified by:
getSourcein interfaceJavaClass- Overrides:
getSourcein classAbstractBaseJavaEntity- Returns:
- the
JavaSourceof this element
-
getPackage
Equivalent ofClass.getPackage()- Specified by:
getPackagein interfaceJavaClass- Returns:
- the package
-
getPackageName
If this class has a package, the packagename will be returned. Otherwise an empty String.- Specified by:
getPackageNamein interfaceJavaClass- Returns:
- the name of the package, otherwise an empty String
-
getSimpleName
Equivalent ofClass.getSimpleName().- Specified by:
getSimpleNamein interfaceJavaClass- Returns:
- the simple name of the underlying class as given in the source code.
-
getBinaryName
The class or interface must be named by its binary name, which must meet the following constraints:
- The binary name of a top level type is its canonical name.
- The binary name of a member type consists of the binary name of its immediately enclosing type, followed by $, followed by the simple name of the member.
- Specified by:
getBinaryNamein interfaceJavaType- Returns:
- the binary name
- See Also:
-
getFullyQualifiedName
Every primitive type, named package, top level class, and top level interface has a fully qualified name:
Some examples how names will be translated- The fully qualified name of a primitive type is the keyword for that primitive type, namely byte, short, char, int, long, float, double, or boolean.
- The fully qualified name of a named package that is not a subpackage of a named package is its simple name.
- The fully qualified name of a named package that is a subpackage of another named package consists of the fully qualified name of the containing package, followed by ".", followed by the simple (member) name of the subpackage.
- The fully qualified name of a top level class or top level interface that is declared in an unnamed package is the simple name of the class or interface.
- The fully qualified name of a top level class or top level interface that is declared in a named package consists of the fully qualified name of the package, followed by ".", followed by the simple name of the class or interface.
- A member class or member interface M of another class or interface C has a fully qualified name if and only if C has a fully qualified name.
- In that case, the fully qualified name of M consists of the fully qualified name of C, followed by ".", followed by the simple name of M.
- An array type has a fully qualified name if and only if its element type has a fully qualified name.
- In that case, the fully qualified name of an array type consists of the fully qualified name of the component type of the array type followed by "[]".
Object > java.lang.Object java.util.List > java.util.List ? > ? T > T anypackage.Outer.Inner > anypackage.Outer.Inner String[][] > java.lang.String[][]
- Specified by:
getFullyQualifiedNamein interfaceJavaType- Returns:
- the fully qualified name, never
null - See Also:
-
getGenericFullyQualifiedName
The fully qualified name with generic information.- Specified by:
getGenericFullyQualifiedNamein interfaceJavaType- Returns:
- the generic fully qualified name
-
getCanonicalName
Equivalent of (@linkClass.getCanonicalName().- Specified by:
getCanonicalNamein interfaceJavaType- Returns:
- the canonical name of this class
-
getGenericCanonicalName
The canonical name with generic information.- Specified by:
getGenericCanonicalNamein interfaceJavaType- Returns:
- the generic canonical name
-
getValue
If there's a reference to this class, use the value used in the code. Otherwise return the simple name. When including all imports, you should be safe to use this method. This won't return generics, so it's java1.4 safe. Examples:private String fieldA; // getValue() will return "String" private java.lang.String fieldA; // getValue() will return "java.lang.String" private List>String> aList; // getValue() will return "List"
-
getGenericValue
A java5+ representation of the class. When including all imports, you should be safe to use this method. Examples:private String fieldA; // getValue() will return "String" private java.lang.String fieldA; // getValue() will return "java.lang.String" private List>String> aList; // getValue() will return "List>String>"
- Specified by:
getGenericValuein interfaceJavaType- Returns:
- the generic name of the class as used in the source
-
isInner
public boolean isInner() -
getInitializers
A list ifJavaInitializer, either static or instance initializers.- Specified by:
getInitializersin interfaceJavaClass- Returns:
- a List of initializers
-
getConstructors
Equivalent ofClass.getConstructors()- Specified by:
getConstructorsin interfaceJavaClass- Returns:
- the list of constructors
-
getConstructor
- Specified by:
getConstructorin interfaceJavaClass- Parameters:
parameterTypes- the parameter types of the constructor, can benull- Returns:
- the matching constructor, otherwise
null
-
getConstructor
- Specified by:
getConstructorin interfaceJavaClass- Parameters:
parameterTypes- the parameter types of the constructor, can benullvarArgs- define is the constructor has varArgs- Returns:
- the matching constructor, otherwise
null
-
getMethods
Equivalent ofClass.getMethods()- Specified by:
getMethodsin interfaceJavaClass- Returns:
- the methods declared or overridden in this class
-
getMethods
Return declared methods and optionally the inherited methods- Specified by:
getMethodsin interfaceJavaClass- Parameters:
superclasses-trueif inherited methods should be returned as well- Returns:
- all methods
-
getMethodsFromSuperclassAndInterfaces
private static Map<String,JavaMethod> getMethodsFromSuperclassAndInterfaces(JavaClass rootClass, JavaClass callingClazz) -
getMethodBySignature
- Specified by:
getMethodBySignaturein interfaceJavaClass- 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. -
getMethodBySignature
public JavaMethod getMethodBySignature(String name, List<JavaType> parameterTypes, boolean superclasses) - Specified by:
getMethodBySignaturein interfaceJavaClass- Parameters:
name- the name of the methodparameterTypes- the parameter types of the method, can benullsuperclasses- to define if superclasses should be included as well- Returns:
- the matching method, otherwise
null
-
getMethodBySignature
public JavaMethod getMethodBySignature(String name, List<JavaType> parameterTypes, boolean superclasses, boolean varArg) - Specified by:
getMethodBySignaturein interfaceJavaClass- Parameters:
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- Returns:
- the matching method, otherwise
null
-
getMethodsBySignature
public List<JavaMethod> getMethodsBySignature(String name, List<JavaType> parameterTypes, boolean superclasses) - Specified by:
getMethodsBySignaturein interfaceJavaClass- Parameters:
name- the name of the methodparameterTypes- the parameter types of the method, can benullsuperclasses-trueif inherited methods should be matched as well- Returns:
- the matching methods, otherwise
null
-
getMethodsBySignature
public List<JavaMethod> getMethodsBySignature(String name, List<JavaType> parameterTypes, boolean superclasses, boolean varArg) - Specified by:
getMethodsBySignaturein interfaceJavaClass- Parameters:
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- Returns:
- the matching methods, otherwise
null
-
getFields
Equivalent ofClass.getFields() -
getFieldByName
Equivalent ofClass.getField(String), where this method can resolve every field- Specified by:
getFieldByNamein interfaceJavaClass- Parameters:
name- the name of the field- Returns:
- the field
-
getEnumConstants
Based onClass.getEnumConstants().- Specified by:
getEnumConstantsin interfaceJavaClass- Returns:
- a List of enum constants if this class is an
enum, otherwisenull
-
getEnumConstantByName
- Specified by:
getEnumConstantByNamein interfaceJavaClass- Parameters:
name- the name of the enum constant- Returns:
- the enumConstant matching the
name, otherwisenull
-
addInitializer
-
addClass
-
getNestedClasses
Equivalent ofClass.getDeclaredClasses()- Specified by:
getNestedClassesin interfaceJavaClass- Returns:
- a list of declared classes, never
null
-
getNestedClassByName
- Specified by:
getNestedClassByNamein interfaceJavaClass
-
isA
-
isA
-
getBeanProperties
Gets bean properties without looking in superclasses or interfaces.- Specified by:
getBeanPropertiesin interfaceJavaClass- Returns:
- the bean properties
-
getBeanProperties
- Specified by:
getBeanPropertiesin interfaceJavaClass- Parameters:
superclasses- to define if superclasses should be included as well- Returns:
- the bean properties
-
getBeanPropertyMap
-
getOrCreateProperty
private DefaultBeanProperty getOrCreateProperty(Map<String, DefaultBeanProperty> beanPropertyMap, String propertyName) -
getBeanProperty
Gets bean property without looking in superclasses or interfaces.- Specified by:
getBeanPropertyin interfaceJavaClass- Parameters:
propertyName- the name of the property- Returns:
- the bean property
-
getBeanProperty
- Specified by:
getBeanPropertyin interfaceJavaClass- Parameters:
propertyName- the name of the propertysuperclasses- to define if superclasses should be included as well- Returns:
- the bean property
-
getDerivedClasses
Equivalent ofClass.getClasses()Gets the known derived classes. That is, subclasses or implementing classes.- Specified by:
getDerivedClassesin interfaceJavaClass- Returns:
- the derived classes
-
getTagsByName
- Specified by:
getTagsByNamein interfaceJavaClass- Specified by:
getTagsByNamein classAbstractInheritableJavaEntity
-
getTagsRecursive
-
toString
Description copied from interface:JavaClass(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". -
toGenericString
- Specified by:
toGenericStringin interfaceJavaType
-
hashCode
public int hashCode() -
equals
-
getJavaClassLibrary
- Specified by:
getJavaClassLibraryin interfaceJavaClass
-