public class DefaultJavaType extends Object implements JavaClass, JavaType, Serializable
Modifier and Type | Field and Description |
---|---|
protected String |
fullName |
protected String |
name |
static DefaultJavaType |
VOID |
Constructor and Description |
---|
DefaultJavaType(String fullName)
Should only be used by primitives, since they don't have a classloader.
|
DefaultJavaType(String fullName,
int dimensions) |
DefaultJavaType(String fullName,
int dimensions,
JavaClassParent context) |
DefaultJavaType(String name,
JavaClassParent context) |
DefaultJavaType(String fullName,
String name,
int dimensions,
JavaClassParent context) |
Modifier and Type | Method and Description |
---|---|
JavaType |
asType() |
static DefaultJavaType |
createUnresolved(String name,
int dimensions,
JavaClassParent context) |
boolean |
equals(Object obj) |
List<JavaAnnotation> |
getAnnotations()
Equivalent of
AnnotatedElement.getAnnotations() |
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() |
String |
getClassNamePrefix()
If this class has a package, it will return the package name, followed by a "."(dot).
|
String |
getCodeBlock() |
String |
getComment()
Retrieve the javadoc comment of this annotated element.
|
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 varArg) |
List<JavaConstructor> |
getConstructors()
Equivalent of
Class.getConstructors() |
JavaClass |
getDeclaringClass() |
List<JavaClass> |
getDerivedClasses()
Equivalent of
Class.getClasses()
Gets the known derived classes. |
int |
getDimensions()
Returns the depth of this array, 0 if it's not an array
|
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()
The FQN representation of an Object for code usage
This implementation ignores generics
Some examples how Objects will be translated
|
protected static <D extends JavaGenericDeclaration> |
getGenericValue(JavaType base,
List<JavaTypeVariable<D>> typeVariableList) |
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. |
JavaClass |
getJavaClass()
Deprecated.
Type already has the JavaClass interface
|
ClassLibrary |
getJavaClassLibrary() |
JavaClassParent |
getJavaClassParent() |
int |
getLineNumber()
The line number where this element started
|
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) |
List<String> |
getModifiers()
Equivalent of
Class.getModifiers()
This does not follow the java-api
The Class.getModifiers() returns an int , which should be decoded with the Modifier . |
String |
getName()
Equivalent of
Class.getName() . |
String |
getNamedParameter(String tagName,
String parameterName)
Convenience method for
getTagByName(String).getNamedParameter(String)
that also checks for null tag. |
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() |
protected static <D extends JavaGenericDeclaration> |
getResolvedFullyQualifiedName(JavaType base,
List<JavaTypeVariable<D>> typeParameters) |
protected static <D extends JavaGenericDeclaration> |
getResolvedGenericFullyQualifiedName(JavaType base,
List<JavaTypeVariable<D>> typeParameters) |
protected static <D extends JavaGenericDeclaration> |
getResolvedGenericValue(JavaType base,
List<JavaTypeVariable<D>> typeParameters) |
protected static <D extends JavaGenericDeclaration> |
getResolvedValue(JavaType base,
List<JavaTypeVariable<D>> typeParameters) |
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.
|
DocletTag |
getTagByName(String name)
Retrieve the doclettag by the specified name.
|
List<DocletTag> |
getTags()
Retrieve all defined doclet tags.
|
List<DocletTag> |
getTagsByName(String name)
Retrieve all doclettags with a specific name.
|
List<DocletTag> |
getTagsByName(String name,
boolean superclasses) |
<D extends JavaGenericDeclaration> |
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(JavaType type) |
boolean |
isA(String fullClassName) |
boolean |
isAbstract()
(API description of
Modifier.isAbstract(int) )
Return true if the class includes the abstract modifier, false otherwise. |
boolean |
isAnnotation()
(API description of
Class.isAnnotation() ) |
boolean |
isArray()
Returns true if this Type is an array
|
boolean |
isEnum()
(API description of
Class.isEnum() ) |
boolean |
isFinal()
(API description of
Modifier.isFinal(int) ) |
boolean |
isInner() |
boolean |
isInterface()
(API description of
Class.isInterface() ) |
boolean |
isPrimitive()
Equivalent of
Class.isPrimitive() |
boolean |
isPrivate()
(API description of
Modifier.isPrivate(int) ) |
boolean |
isProtected()
(API description of
Modifier.isProtected(int) ) |
boolean |
isPublic()
(API description of
Modifier.isPublic(int) ) |
protected boolean |
isResolved() |
boolean |
isStatic()
(API description of
Modifier.isStatic(int) ) |
boolean |
isVoid() |
protected static JavaType |
resolve(JavaType base,
JavaClass declaringClass,
JavaClass callingClass)
Consider the following example
|
protected static <D extends JavaGenericDeclaration> |
resolve(JavaType base,
List<JavaTypeVariable<D>> typeParameters) |
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 name)
Resolve a type-name within the context of this source or class.
|
String |
toGenericString()
Returns getGenericValue() extended with the array information
|
String |
toString()
Equivalent of
Class.toString() . |
public static final DefaultJavaType VOID
protected final String name
protected String fullName
public DefaultJavaType(String name, JavaClassParent context)
public DefaultJavaType(String fullName, String name, int dimensions, JavaClassParent context)
public DefaultJavaType(String fullName, int dimensions, JavaClassParent context)
public DefaultJavaType(String fullName, int dimensions)
public DefaultJavaType(String fullName)
fullName
- the name of the primitivepublic static DefaultJavaType createUnresolved(String name, int dimensions, JavaClassParent context)
public 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 JavaType
null
#getComponentType()
public JavaClass getComponentType()
Class.getComponentType()
If this type is an array, return its component typegetComponentType
in interface JavaClass
null
public 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()
Object > java.lang.object java.util.List> java.util.List ? > ? T > T anypackage.Outer.Inner > anypackage.Outer.Inner
getGenericValue
in interface JavaType
protected static <D extends JavaGenericDeclaration> String getGenericValue(JavaType base, List<JavaTypeVariable<D>> typeVariableList)
protected static <D extends JavaGenericDeclaration> String getResolvedValue(JavaType base, List<JavaTypeVariable<D>> typeParameters)
protected static <D extends JavaGenericDeclaration> JavaTypeVariable<D> resolve(JavaType base, List<JavaTypeVariable<D>> typeParameters)
protected boolean isResolved()
public boolean isArray()
public int getDimensions()
getDimensions
in interface JavaClass
0
public String toString()
Class.toString()
.
Converts the object to a string.toString
in interface JavaClass
toString
in class Object
Class.toString()
public String toGenericString()
Object > java.lang.Object Object[] > java.lang.Object[] List<Object> > java.lang.ListOuter.Inner > Outer$Inner Outer.Inner<Object>[][] > Outer$Inner [][]
toGenericString
in interface JavaType
public JavaClass getJavaClass()
public boolean isA(JavaType type)
public boolean isPrimitive()
JavaClass
Class.isPrimitive()
isPrimitive
in interface JavaClass
true
if this class represents a primitive, otherwise false
public boolean isVoid()
protected static JavaType resolve(JavaType base, JavaClass declaringClass, JavaClass callingClass)
public abstract class AbstractClass<T> { private T value; public AbstractClass( T value ) { this.value = value; } public T getValue() { return value; } } public class ConcreteClass extends AbstractClass<String> { public ConcreteClass( String s ) { super( s ); } }
We want to know the resolved returnType when calling ConcreteClass.getValue()
.
The expected type is String.
this
would be TdeclaringClass
would be AbstractClass, since that's where T is usedcallingClass
would be ConcreteClassdeclaringClass
- callingClass
- public String getGenericFullyQualifiedName()
getGenericFullyQualifiedName
in interface JavaType
public String getGenericCanonicalName()
getGenericCanonicalName
in interface JavaType
protected static <D extends JavaGenericDeclaration> String getResolvedGenericValue(JavaType base, List<JavaTypeVariable<D>> typeParameters)
protected static <D extends JavaGenericDeclaration> String getResolvedGenericFullyQualifiedName(JavaType base, List<JavaTypeVariable<D>> typeParameters)
protected static <D extends JavaGenericDeclaration> String getResolvedFullyQualifiedName(JavaType base, List<JavaTypeVariable<D>> typeParameters)
public JavaSource getSource()
getSource
in interface JavaModel
JavaSource
of this elementpublic int getLineNumber()
getLineNumber
in interface JavaModel
public boolean isInterface()
Class.isInterface()
)
Determines if the specified Class
object represents an interface type.
isInterface
in interface JavaClass
true
if this object represents an interface, otherwise false
public List<JavaAnnotation> getAnnotations()
AnnotatedElement.getAnnotations()
getAnnotations
in interface JavaAnnotatedElement
null
public boolean isEnum()
Class.isEnum()
)
Returns true
if and only if this class was declared as an enum in the source code.
public String getComment()
getComment
in interface JavaAnnotatedElement
null
public List<DocletTag> getTags()
getTags
in interface JavaAnnotatedElement
null
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 JavaClass
true
if this object represents an annotation, otherwise false
public List<DocletTag> getTagsByName(String name)
getTagsByName
in interface JavaAnnotatedElement
name
- the name of the doclet tagnull
public DocletTag getTagByName(String name)
getTagByName
in interface JavaAnnotatedElement
name
- the name of the doclettag trying to retrievenull
public JavaType getSuperClass()
getSuperClass
in interface JavaClass
public JavaClass getSuperJavaClass()
getSuperJavaClass
in interface JavaClass
public List<JavaType> getImplements()
getImplements
in interface JavaClass
public List<JavaClass> getImplementedInterfaces()
getImplementedInterfaces
in interface JavaClass
public List<JavaClass> getInterfaces()
Class.getInterfaces()
Determines the interfaces implemented by the class or interface represented by this object. *getInterfaces
in interface JavaClass
null
public String getNamedParameter(String tagName, String parameterName)
getTagByName(String).getNamedParameter(String)
that also checks for null tag.getNamedParameter
in interface JavaAnnotatedElement
tagName
- the tag nameparameterName
- the parameter namenull
public String getCodeBlock()
getCodeBlock
in interface JavaClass
getCodeBlock
in interface JavaModel
public <D extends JavaGenericDeclaration> List<JavaTypeVariable<D>> getTypeParameters()
GenericDeclaration.getTypeParameters()
getTypeParameters
in interface JavaGenericDeclaration
null
public JavaSource getParentSource()
getParentSource
in interface JavaClassParent
getParentSource
in interface JavaClass
public JavaPackage getPackage()
Class.getPackage()
getPackage
in interface JavaClass
public String getPackageName()
getPackageName
in interface JavaClass
public boolean isInner()
public String resolveCanonicalName(String name)
resolveCanonicalName
in interface JavaClassParent
resolveCanonicalName
in interface JavaClass
name
- the name to resolvenull
public String resolveFullyQualifiedName(String name)
resolveFullyQualifiedName
in interface JavaClassParent
resolveFullyQualifiedName
in interface JavaClass
name
- the name to resolvenull
public String getClassNamePrefix()
getClassNamePrefix
in interface JavaClass
public List<JavaInitializer> getInitializers()
JavaInitializer
, either static or instance initializers.getInitializers
in interface JavaClass
public List<JavaMethod> getMethods()
Class.getMethods()
getMethods
in interface JavaClass
public List<JavaConstructor> getConstructors()
Class.getConstructors()
getConstructors
in interface JavaClass
public JavaConstructor getConstructor(List<JavaType> parameterTypes)
getConstructor
in interface JavaClass
parameterTypes
- the parameter types of the constructor, can be null
null
public JavaConstructor getConstructor(List<JavaType> parameterTypes, boolean varArg)
getConstructor
in interface JavaClass
parameterTypes
- the parameter types of the constructor, can be null
varArg
- define is the constructor has varArgsnull
public List<JavaMethod> getMethods(boolean superclasses)
getMethods
in interface JavaClass
public JavaMethod getMethodBySignature(String name, List<JavaType> parameterTypes)
getMethodBySignature
in interface JavaClass
name
- the name of the methodparameterTypes
- the parameter types of the method, can be null
.null
public JavaMethod getMethod(String name, List<JavaType> parameterTypes, boolean varArgs)
public JavaMethod getMethodBySignature(String name, List<JavaType> parameterTypes, boolean superclasses)
getMethodBySignature
in interface JavaClass
name
- the name of the methodparameterTypes
- the parameter types of the method, can be null
superclasses
- to define if superclasses should be included as wellnull
public JavaMethod getMethodBySignature(String name, List<JavaType> parameterTypes, boolean superclasses, boolean varArg)
getMethodBySignature
in interface JavaClass
name
- the name of the methodparameterTypes
- the parameter types of the method, can be null
varArg
- define if the method has varArgsnull
public List<JavaMethod> getMethodsBySignature(String name, List<JavaType> parameterTypes, boolean superclasses)
getMethodsBySignature
in interface JavaClass
name
- the name of the methodparameterTypes
- the parameter types of the method, can be null
superclasses
- to define if superclasses should be included as wellnull
public List<JavaMethod> getMethodsBySignature(String name, List<JavaType> parameterTypes, boolean superclasses, boolean varArg)
getMethodsBySignature
in interface JavaClass
name
- the name of the methodparameterTypes
- the parameter types of the method, can be null
superclasses
- to define if superclasses should be included as wellvarArg
- define if the method has varArgsnull
public List<JavaField> getFields()
Class.getFields()
public JavaField getFieldByName(String name)
Class.getField(String)
, where this method can resolve every fieldgetFieldByName
in interface JavaClass
public List<JavaField> getEnumConstants()
Class.getEnumConstants()
.getEnumConstants
in interface JavaClass
enum
, otherwise null
public JavaField getEnumConstantByName(String name)
getEnumConstantByName
in interface JavaClass
name
, otherwise null
public List<JavaClass> getNestedClasses()
Class.getDeclaredClasses()
getNestedClasses
in interface JavaClass
null
public JavaClass getNestedClassByName(String name)
getNestedClassByName
in interface JavaClassParent
getNestedClassByName
in interface JavaClass
public List<BeanProperty> getBeanProperties()
getBeanProperties
in interface JavaClass
public List<BeanProperty> getBeanProperties(boolean superclasses)
getBeanProperties
in interface JavaClass
superclasses
- to define if superclasses should be included as wellpublic BeanProperty getBeanProperty(String propertyName)
getBeanProperty
in interface JavaClass
propertyName
- the name of the propertypublic BeanProperty getBeanProperty(String propertyName, boolean superclasses)
getBeanProperty
in interface JavaClass
propertyName
- 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 JavaClass
public List<DocletTag> getTagsByName(String name, boolean superclasses)
getTagsByName
in interface JavaClass
public ClassLibrary getJavaClassLibrary()
getJavaClassLibrary
in interface JavaClassParent
getJavaClassLibrary
in interface JavaClass
public String getName()
Class.getName()
.public String getCanonicalName()
Class.getCanonicalName()
.getCanonicalName
in interface JavaType
public List<String> getModifiers()
Class.getModifiers()
This does not follow the java-api
The Class.getModifiers() returns an int
, which should be decoded with the Modifier
.
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.getModifiers
in interface JavaClass
public boolean isPublic()
Modifier.isPublic(int)
)
Return true
if the class includes the public modifier, false
otherwise.
public boolean isProtected()
Modifier.isProtected(int)
)
Return true
if the class includes the protected modifier, false
otherwise.
isProtected
in interface JavaClass
true
if class has the protected modifier, otherwise false
public boolean isPrivate()
Modifier.isPrivate(int)
)
Return true
if the class includes the private modifier, false
otherwise.
public boolean isFinal()
Modifier.isFinal(int)
)
Return true
if the class includes the final modifier, false
otherwise.
public boolean isStatic()
Modifier.isStatic(int)
)
Return true
if the class includes the static modifier, false
otherwise.
public boolean isAbstract()
Modifier.isAbstract(int)
)
Return true
if the class includes the abstract modifier, false
otherwise.isAbstract
in interface JavaClass
true
if class has the abstract modifier, otherwise false
public JavaClass getDeclaringClass()
getDeclaringClass
in interface JavaClass
public List<JavaClass> getClasses()
getClasses
in interface JavaClass
public JavaClass getInnerClassByName(String name)
getInnerClassByName
in interface JavaClass
public List<JavaClass> getInnerClasses()
getInnerClasses
in interface JavaClass
public JavaClassParent getParent()
public String resolveType(String name)
JavaClassParent
resolveType
in interface JavaClassParent
resolveType
in interface JavaClass
name
- name of a typepublic JavaClassParent getJavaClassParent()
Copyright © 2002–2014. All rights reserved.