public class DefaultJavaClass extends AbstractInheritableJavaEntity implements JavaClass
| Modifier | Constructor and Description |
|---|---|
protected |
DefaultJavaClass() |
|
DefaultJavaClass(JavaSource source) |
|
DefaultJavaClass(String name) |
| Modifier and Type | Method and Description |
|---|---|
void |
addClass(JavaClass cls) |
void |
addConstructor(JavaConstructor constructor) |
void |
addField(JavaField javaField) |
void |
addInitializer(JavaInitializer initializer) |
void |
addMethod(JavaMethod meth) |
JavaType |
asType() |
boolean |
equals(Object obj) |
List<BeanProperty> |
getBeanProperties()
Gets bean properties without looking in superclasses or interfaces.
|
List<BeanProperty> |
getBeanProperties(boolean superclasses) |
BeanProperty |
getBeanProperty(String propertyName)
Gets bean property without looking in superclasses or interfaces.
|
BeanProperty |
getBeanProperty(String propertyName,
boolean superclasses) |
String |
getCanonicalName()
Equivalent of (@link
Class.getCanonicalName(). |
List<JavaClass> |
getClasses()
Deprecated.
Use
getNestedClasses() instead. |
String |
getClassNamePrefix()
If this class has a package, it will return the package name, followed by a "."(dot).
|
String |
getCodeBlock() |
JavaClass |
getComponentType()
Equivalent of
Class.getComponentType()
If this type is an array, return its component type |
JavaConstructor |
getConstructor(List<JavaType> parameterTypes) |
JavaConstructor |
getConstructor(List<JavaType> parameterTypes,
boolean varArgs) |
List<JavaConstructor> |
getConstructors()
Equivalent of
Class.getConstructors() |
JavaClass |
getDeclaringClass() |
List<JavaClass> |
getDerivedClasses()
Equivalent of
Class.getClasses()
Gets the known derived classes. |
int |
getDimensions() |
JavaField |
getEnumConstantByName(String name) |
List<JavaField> |
getEnumConstants()
Based on
Class.getEnumConstants(). |
JavaField |
getFieldByName(String name)
Equivalent of
Class.getField(String), where this method can resolve every field |
List<JavaField> |
getFields()
Equivalent of
Class.getFields() |
String |
getFullyQualifiedName()
Returns the FQN of an Object or the handler of a Type.
|
String |
getGenericCanonicalName()
The canonical name with generic information.
|
String |
getGenericFullyQualifiedName()
The fully qualified nate with generic information.
|
String |
getGenericValue()
A java5+ representation of the class.
|
List<JavaClass> |
getImplementedInterfaces() |
List<JavaType> |
getImplements() |
List<JavaInitializer> |
getInitializers()
A list if
JavaInitializer, either static or instance initializers. |
JavaClass |
getInnerClassByName(String name) |
List<JavaClass> |
getInnerClasses() |
List<JavaClass> |
getInterfaces()
Equivalent of
Class.getInterfaces()
Determines the interfaces implemented by the class or interface represented by this object. |
ClassLibrary |
getJavaClassLibrary() |
JavaMethod |
getMethod(String name,
List<JavaType> parameterTypes,
boolean varArgs)
This should be the signature for getMethodBySignature.
|
JavaMethod |
getMethodBySignature(String name,
List<JavaType> parameterTypes) |
JavaMethod |
getMethodBySignature(String name,
List<JavaType> parameterTypes,
boolean superclasses) |
JavaMethod |
getMethodBySignature(String name,
List<JavaType> parameterTypes,
boolean superclasses,
boolean varArg) |
List<JavaMethod> |
getMethods()
Equivalent of
Class.getMethods() |
List<JavaMethod> |
getMethods(boolean superclasses) |
List<JavaMethod> |
getMethodsBySignature(String name,
List<JavaType> parameterTypes,
boolean superclasses) |
List<JavaMethod> |
getMethodsBySignature(String name,
List<JavaType> parameterTypes,
boolean superclasses,
boolean varArg) |
JavaClass |
getNestedClassByName(String name) |
List<JavaClass> |
getNestedClasses()
Equivalent of
Class.getDeclaredClasses() |
JavaPackage |
getPackage()
Equivalent of
Class.getPackage() |
String |
getPackageName()
If this class has a package, the packagename will be returned.
|
JavaClassParent |
getParent() |
JavaSource |
getParentSource() |
JavaSource |
getSource()
The compilation unit, which includes the imports, the public and anonymous classes
|
JavaType |
getSuperClass() |
JavaClass |
getSuperJavaClass()
Shorthand for getSuperClass().getJavaClass() with null checking.
|
List<DocletTag> |
getTagsByName(String name,
boolean superclasses) |
List<DefaultJavaTypeVariable<JavaClass>> |
getTypeParameters()
Equivalent of
GenericDeclaration.getTypeParameters() |
String |
getValue()
If there's a reference to this class, use the value used in the code.
|
int |
hashCode() |
boolean |
isA(JavaClass javaClass) |
boolean |
isA(String fullClassName) |
boolean |
isAnnotation()
(API description of
Class.isAnnotation()) |
boolean |
isArray() |
boolean |
isEnum()
(API description of
Class.isEnum()) |
boolean |
isInner() |
boolean |
isInterface()
(API description of
Class.isInterface()) |
boolean |
isPrimitive()
Equivalent of
Class.isPrimitive() |
boolean |
isVoid() |
String |
resolveCanonicalName(String name)
The name can be both absolute (including the package) or relative (matching a subclass or an import).
|
String |
resolveFullyQualifiedName(String name)
The name can be both absolute (including the package) or relative (matching a subclass or an import).
|
String |
resolveType(String typeName)
Resolve a type-name within the context of this source or class.
|
void |
setAnnotation(boolean anAnnotation) |
void |
setEnum(boolean anEnum) |
void |
setImplementz(List<JavaClass> implementz) |
void |
setInterface(boolean anInterface) |
void |
setJavaPackage(JavaPackage javaPackage)
Only used when constructing the model by hand / without source
|
void |
setSuperClass(JavaType type) |
void |
setTypeParameters(List<DefaultJavaTypeVariable<JavaClass>> typeParameters) |
String |
toGenericString() |
String |
toString()
(API description of
Class.toString())
Converts the object to a string. |
getTagByNamegetModifiers, getName, getParentClass, isAbstract, isFinal, isNative, isPrivate, isProtected, isPublic, isStatic, isStrictfp, isSynchronized, isTransient, isVolatile, setModifiers, setName, setParentClassgetAnnotations, getComment, getNamedParameter, getTagByName, getTags, getTagsByName, setAnnotations, setComment, setTagsgetLineNumber, getModelWriter, setLineNumber, setModelWriterFactory, setSourceclone, finalize, getClass, notify, notifyAll, wait, wait, waitgetModifiers, getName, isAbstract, isFinal, isPrivate, isProtected, isPublic, isStaticgetLineNumbergetAnnotations, getComment, getNamedParameter, getTagByName, getTags, getTagsByNameprotected DefaultJavaClass()
public DefaultJavaClass(String name)
public DefaultJavaClass(JavaSource source)
public boolean isInterface()
Class.isInterface())
Determines if the specified Class object represents an interface type.
isInterface in interface JavaClasstrue if this object represents an interface, otherwise falsepublic boolean isPrimitive()
Class.isPrimitive()isPrimitive in interface JavaClasstrue if this class represents a primitive, otherwise falsepublic boolean isVoid()
public boolean isEnum()
Class.isEnum())
Returns true if and only if this class was declared as an enum in the source code.
public boolean isAnnotation()
Class.isAnnotation())
Returns true if this Class object represents an annotation type.
Note that if this method returns true, JavaClass.isInterface() would also return true, as all annotation types are also interfaces.
isAnnotation in interface JavaClasstrue if this object represents an annotation, otherwise falsepublic boolean isArray()
public JavaClass getComponentType()
Class.getComponentType()
If this type is an array, return its component typegetComponentType in interface JavaClassnullpublic int getDimensions()
getDimensions in interface JavaClasspublic JavaType getSuperClass()
getSuperClass in interface JavaClasspublic JavaClass getSuperJavaClass()
getSuperJavaClass in interface JavaClasspublic List<JavaType> getImplements()
getImplements in interface JavaClasspublic List<JavaClass> getImplementedInterfaces()
getImplementedInterfaces in interface JavaClasspublic List<JavaClass> getInterfaces()
Class.getInterfaces()
Determines the interfaces implemented by the class or interface represented by this object. *getInterfaces in interface JavaClassnullpublic String getCodeBlock()
getCodeBlock in interface JavaClassgetCodeBlock in interface JavaModelpublic void setInterface(boolean anInterface)
public void setEnum(boolean anEnum)
public void setAnnotation(boolean anAnnotation)
public void addConstructor(JavaConstructor constructor)
public void addMethod(JavaMethod meth)
public void setSuperClass(JavaType type)
public List<DefaultJavaTypeVariable<JavaClass>> getTypeParameters()
GenericDeclaration.getTypeParameters()getTypeParameters in interface JavaGenericDeclarationnullpublic void setTypeParameters(List<DefaultJavaTypeVariable<JavaClass>> typeParameters)
public void addField(JavaField javaField)
public void setJavaPackage(JavaPackage javaPackage)
javaPackage - public JavaSource getParentSource()
getParentSource in interface JavaClassParentgetParentSource in interface JavaClasspublic JavaSource getSource()
getSource in interface JavaModelgetSource in class AbstractJavaModelJavaSource of this elementpublic JavaPackage getPackage()
Class.getPackage()getPackage in interface JavaClasspublic JavaClassParent getParent()
public String getPackageName()
getPackageName in interface JavaClasspublic String getFullyQualifiedName()
#getComponentType().
Some examples how names will be translated
Object > java.lang.Object java.util.List > java.util.List ? > ? T > T anypackage.Outer.Inner > anypackage.Outer$Inner String[][] > java.lang.String[][]
getFullyQualifiedName in interface JavaTypenull#getComponentType()public String getGenericFullyQualifiedName()
getGenericFullyQualifiedName in interface JavaTypepublic String getCanonicalName()
Class.getCanonicalName().getCanonicalName in interface JavaTypepublic String getGenericCanonicalName()
getGenericCanonicalName in interface JavaTypepublic String getValue()
private String fieldA; // getValue() will return "String" private java.lang.String fieldA; // getValue() will return "java.lang.String" private ListaList; // getValue() will return "List"
public String getGenericValue()
private String fieldA; // getValue() will return "String" private java.lang.String fieldA; // getValue() will return "java.lang.String" private ListaList; // getValue() will return "List "
getGenericValue in interface JavaTypepublic boolean isInner()
public String resolveType(String typeName)
resolveType in interface JavaClassParentresolveType in interface JavaClasstypeName - name of a typepublic String resolveCanonicalName(String name)
resolveCanonicalName in interface JavaClassParentresolveCanonicalName in interface JavaClassname - the name to resolvenullpublic String resolveFullyQualifiedName(String name)
resolveFullyQualifiedName in interface JavaClassParentresolveFullyQualifiedName in interface JavaClassname - the name to resolvenullpublic String getClassNamePrefix()
getClassNamePrefix in interface JavaClasspublic List<JavaInitializer> getInitializers()
JavaInitializer, either static or instance initializers.getInitializers in interface JavaClasspublic List<JavaConstructor> getConstructors()
Class.getConstructors()getConstructors in interface JavaClasspublic JavaConstructor getConstructor(List<JavaType> parameterTypes)
getConstructor in interface JavaClassparameterTypes - the parameter types of the constructor, can be nullnullpublic JavaConstructor getConstructor(List<JavaType> parameterTypes, boolean varArgs)
getConstructor in interface JavaClassparameterTypes - the parameter types of the constructor, can be nullvarArgs - define is the constructor has varArgsnullpublic List<JavaMethod> getMethods()
Class.getMethods()getMethods in interface JavaClasspublic List<JavaMethod> getMethods(boolean superclasses)
getMethods in interface JavaClasspublic JavaMethod getMethodBySignature(String name, List<JavaType> parameterTypes)
getMethodBySignature in interface JavaClassname - the name of the methodparameterTypes - the parameter types of the method, can be null.nullpublic JavaMethod getMethod(String name, List<JavaType> parameterTypes, boolean varArgs)
public JavaMethod getMethodBySignature(String name, List<JavaType> parameterTypes, boolean superclasses)
getMethodBySignature in interface JavaClassname - the name of the methodparameterTypes - the parameter types of the method, can be nullsuperclasses - to define if superclasses should be included as wellnullpublic JavaMethod getMethodBySignature(String name, List<JavaType> parameterTypes, boolean superclasses, boolean varArg)
getMethodBySignature in interface JavaClassname - the name of the methodparameterTypes - the parameter types of the method, can be nullvarArg - define if the method has varArgsnullpublic List<JavaMethod> getMethodsBySignature(String name, List<JavaType> parameterTypes, boolean superclasses)
getMethodsBySignature in interface JavaClassname - the name of the methodparameterTypes - the parameter types of the method, can be nullsuperclasses - to define if superclasses should be included as wellnullpublic List<JavaMethod> getMethodsBySignature(String name, List<JavaType> parameterTypes, boolean superclasses, boolean varArg)
getMethodsBySignature in interface JavaClassname - the name of the methodparameterTypes - the parameter types of the method, can be nullsuperclasses - to define if superclasses should be included as wellvarArg - define if the method has varArgsnullpublic List<JavaField> getFields()
Class.getFields()public JavaField getFieldByName(String name)
Class.getField(String), where this method can resolve every fieldgetFieldByName in interface JavaClasspublic List<JavaField> getEnumConstants()
Class.getEnumConstants().getEnumConstants in interface JavaClassenum, otherwise nullpublic JavaField getEnumConstantByName(String name)
getEnumConstantByName in interface JavaClassname, otherwise nullpublic void addInitializer(JavaInitializer initializer)
public void addClass(JavaClass cls)
public List<JavaClass> getClasses()
getNestedClasses() instead.getClasses in interface JavaClasspublic List<JavaClass> getNestedClasses()
Class.getDeclaredClasses()getNestedClasses in interface JavaClassnullpublic JavaClass getInnerClassByName(String name)
getInnerClassByName in interface JavaClasspublic List<JavaClass> getInnerClasses()
getInnerClasses in interface JavaClasspublic JavaClass getNestedClassByName(String name)
getNestedClassByName in interface JavaClassParentgetNestedClassByName in interface JavaClasspublic List<BeanProperty> getBeanProperties()
getBeanProperties in interface JavaClasspublic List<BeanProperty> getBeanProperties(boolean superclasses)
getBeanProperties in interface JavaClasssuperclasses - to define if superclasses should be included as wellpublic BeanProperty getBeanProperty(String propertyName)
getBeanProperty in interface JavaClasspropertyName - the name of the propertypublic BeanProperty getBeanProperty(String propertyName, boolean superclasses)
getBeanProperty in interface JavaClasspropertyName - the name of the propertysuperclasses - to define if superclasses should be included as wellpublic List<JavaClass> getDerivedClasses()
Class.getClasses()
Gets the known derived classes. That is, subclasses or implementing classes.getDerivedClasses in interface JavaClasspublic JavaClass getDeclaringClass()
getDeclaringClass in interface JavaClasspublic List<DocletTag> getTagsByName(String name, boolean superclasses)
getTagsByName in interface JavaClassgetTagsByName in class AbstractInheritableJavaEntitypublic String toString()
JavaClassClass.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 by getName.
If this Class object represents a primitive type, this method returns the name of the primitive type.
If this Class object represents void this method returns "void".toString in interface JavaClasstoString in class ObjectClass.toString()public String toGenericString()
toGenericString in interface JavaTypepublic ClassLibrary getJavaClassLibrary()
getJavaClassLibrary in interface JavaClassParentgetJavaClassLibrary in interface JavaClassCopyright © 2002–2016. All rights reserved.