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 JavaTypenull#getComponentType()public JavaClass getComponentType()
Class.getComponentType()
If this type is an array, return its component typegetComponentType in interface JavaClassnullpublic 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 JavaTypeprotected 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 JavaClass0public String toString()
Class.toString().
Converts the object to a string.toString in interface JavaClasstoString in class ObjectClass.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 JavaTypepublic JavaClass getJavaClass()
public boolean isA(JavaType type)
public boolean isPrimitive()
JavaClassClass.isPrimitive()isPrimitive in interface JavaClasstrue if this class represents a primitive, otherwise falsepublic 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 JavaTypepublic String getGenericCanonicalName()
getGenericCanonicalName in interface JavaTypeprotected 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 JavaModelJavaSource of this elementpublic int getLineNumber()
getLineNumber in interface JavaModelpublic 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 List<JavaAnnotation> getAnnotations()
AnnotatedElement.getAnnotations()getAnnotations in interface JavaAnnotatedElementnullpublic 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 JavaAnnotatedElementnullpublic List<DocletTag> getTags()
getTags in interface JavaAnnotatedElementnullpublic 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 List<DocletTag> getTagsByName(String name)
getTagsByName in interface JavaAnnotatedElementname - the name of the doclet tagnullpublic DocletTag getTagByName(String name)
getTagByName in interface JavaAnnotatedElementname - the name of the doclettag trying to retrievenullpublic 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 getNamedParameter(String tagName, String parameterName)
getTagByName(String).getNamedParameter(String)
that also checks for null tag.getNamedParameter in interface JavaAnnotatedElementtagName - the tag nameparameterName - the parameter namenullpublic String getCodeBlock()
getCodeBlock in interface JavaClassgetCodeBlock in interface JavaModelpublic <D extends JavaGenericDeclaration> List<JavaTypeVariable<D>> getTypeParameters()
GenericDeclaration.getTypeParameters()getTypeParameters in interface JavaGenericDeclarationnullpublic JavaSource getParentSource()
getParentSource in interface JavaClassParentgetParentSource in interface JavaClasspublic JavaPackage getPackage()
Class.getPackage()getPackage in interface JavaClasspublic String getPackageName()
getPackageName in interface JavaClasspublic boolean isInner()
public 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<JavaMethod> getMethods()
Class.getMethods()getMethods 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 varArg)
getConstructor in interface JavaClassparameterTypes - the parameter types of the constructor, can be nullvarArg - define is the constructor has varArgsnullpublic 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 List<JavaClass> getNestedClasses()
Class.getDeclaredClasses()getNestedClasses in interface JavaClassnullpublic 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 List<DocletTag> getTagsByName(String name, boolean superclasses)
getTagsByName in interface JavaClasspublic ClassLibrary getJavaClassLibrary()
getJavaClassLibrary in interface JavaClassParentgetJavaClassLibrary in interface JavaClasspublic String getName()
Class.getName().public String getCanonicalName()
Class.getCanonicalName().getCanonicalName in interface JavaTypepublic 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 JavaClasspublic 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 JavaClasstrue if class has the protected modifier, otherwise falsepublic 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 JavaClasstrue if class has the abstract modifier, otherwise falsepublic JavaClass getDeclaringClass()
getDeclaringClass in interface JavaClasspublic List<JavaClass> getClasses()
getClasses in interface JavaClasspublic JavaClass getInnerClassByName(String name)
getInnerClassByName in interface JavaClasspublic List<JavaClass> getInnerClasses()
getInnerClasses in interface JavaClasspublic JavaClassParent getParent()
public String resolveType(String name)
JavaClassParentresolveType in interface JavaClassParentresolveType in interface JavaClassname - name of a typepublic JavaClassParent getJavaClassParent()
Copyright © 2002–2016. All rights reserved.