javax.ide.model.java.declaration
Interface TypeD
- All Superinterfaces:
- Declaration, HasNameD, HasTypeD
- All Known Subinterfaces:
- ArrayTypeD, ClassD, TypeVariableD, WildcardTypeD
public interface TypeD
- extends Declaration, HasTypeD, HasNameD
Represents a type.
Members
The order of the member listing should be determined by the type
hierarchy. If type B occurs before type A in the type hierarchy,
then all of B's declared members should occur before any of A's
declared members in the member collection. Consider the following
two classes.
class A
{
int a;
}
class B extends A
{
int b;
}
The iterator for the collection returned for the member fields of B
should always return B.b
before A.a
.
Order within the same declaring type is not defined.
Method Summary |
boolean |
equals(java.lang.Object o)
True if the other object is also a TypeD and they represent the
same type. |
ClassD |
getClass(java.lang.String name)
Gets the first matching member class, null if none. |
java.util.Collection |
getClasses()
Gets all member classes, declared and inherited. |
ClassD |
getDeclaredClass(java.lang.String name)
Gets the matching member class, null if none. |
java.util.Collection |
getDeclaredClasses()
Gets all declared member classes. |
ConstructorD |
getDeclaredConstructor(TypeD[] parameters)
Gets the matching declared constructor, null if none. |
java.util.Collection |
getDeclaredConstructors()
Gets all declared constructors. |
FieldD |
getDeclaredField(java.lang.String name)
Gets the first matching declared field, null if none. |
java.util.Collection |
getDeclaredFields()
Gets all declared fields. |
MethodD |
getDeclaredMethod(java.lang.String name,
TypeD[] parameters)
Gets the matching declared method, null if none. |
java.util.Collection |
getDeclaredMethods()
Gets all declared methods. |
java.util.Collection |
getDeclaredMethods(java.lang.String name)
Gets all matching declared methods. |
java.lang.String |
getDescriptor()
Gets the descriptor for this type, as defined by the JVMS2. |
FieldD |
getField(java.lang.String name)
Gets the matching member field, null if none. |
java.util.Collection |
getFields()
Gets all member fields, declared and inherited. |
java.util.Collection |
getHierarchy()
Recursively gets all direct supertypes. |
java.util.Collection |
getInterfaces()
Gets this type's super-interfaces. |
MethodD |
getMethod(java.lang.String name,
TypeD[] parameters)
Gets the first matching method, null if none. |
java.util.Collection |
getMethods()
Gets all member methods, declared and inherited. |
java.util.Collection |
getMethods(java.lang.String name)
Gets all matching methods. |
java.lang.String |
getQualifiedName()
Gets the fully qualified name of this type in source format. |
TypeD |
getSuperclass()
Gets this type's superclass. |
TypeD |
getType()
Gets itself as its type. |
ClassD |
getTypeErasure()
Gets the type erasure of this type. |
java.lang.String |
getTypeSignature()
Gets the type signature for this type, as defined by the
JVMS3. |
boolean |
isAnnotation()
True if this is an annotation type. |
boolean |
isArray()
True if this is an array type. |
boolean |
isAssignableFrom(TypeD subject)
True if this type is assignable from the subject type. |
boolean |
isEnum()
True if this is an enum type. |
boolean |
isInterface()
True if this is an interface. |
boolean |
isPrimitive()
True if this is a primitive type, including the special
void type. |
Methods inherited from interface javax.ide.model.java.declaration.HasNameD |
getName |
EMPTY_ARRAY
static final TypeD[] EMPTY_ARRAY
getType
TypeD getType()
- Gets itself as its type.
- Specified by:
getType
in interface HasTypeD
- Returns:
- The type of a type declaration is trivially itself.
getTypeErasure
ClassD getTypeErasure()
- Gets the type erasure of this type.
- Returns:
- The type declaration representing the type erasure of
this type.
isPrimitive
boolean isPrimitive()
- True if this is a primitive type, including the special
void
type.
- Returns:
- True if this type is a primitive type.
isArray
boolean isArray()
- True if this is an array type.
- Returns:
- True if this type is an array type.
isEnum
boolean isEnum()
- True if this is an enum type.
- Returns:
- True if this an enumeration type. False otherwise.
isAnnotation
boolean isAnnotation()
- True if this is an annotation type.
- Returns:
- True if this is an annotation type. False otherwise.
isInterface
boolean isInterface()
- True if this is an interface. This includes "interface" types and
"annotation" types.
- Returns:
- True if this is an interface type.
getQualifiedName
java.lang.String getQualifiedName()
- Gets the fully qualified name of this type in source format.
Here, "source format" means the format of a type reference in a
source compilation unit. A type's source name uniquely identifies
a type in a specific scope but not in the general scope.
An array type returns the fully qualified name of its component
type suffixed by the appropriate number of brackets.
Parameterized types return the fully qualified name of its
unparameterize type suffixed with the type parameters. A local
inner class returns only its simple name because that is how it
is referred to in a source compilation unit.
Note: Anonymous inner classes return the empty string because
they may not be referred to in a source compilation unit.
- Returns:
- The fully qualified source name for this type, empty for
anonymous classes. Examples:
java.lang.Object
,
java.util.Map<String,String>
,
java.lang.String[][]
getDescriptor
java.lang.String getDescriptor()
- Gets the descriptor for this type, as defined by the JVMS2.
For jdk < 1.5, the "FieldDescriptor" is returned (JVMS2). For
jdk >= 1.5, a type signature of the type erasure is returned.
Note: The descriptor is equivalent to the type signature of this
type's erasure.
- Returns:
- The descriptor as defined in the JVMS2. Always non-null.
e.g. "I", "Ljava/lang/Object;"
getTypeSignature
java.lang.String getTypeSignature()
- Gets the type signature for this type, as defined by the
JVMS3.
A ClassD returns its "ClassTypeSignature" (JVMS3). A ClassD is
uniquely identified by its type signature. Example value:
Ljava/util/List;
A TypeVariableD returns its "TypeVariableSignature" (JVMS3). A
TypeVariableD is uniquely identified by its owning declaration
and its type signature. Example value: TE;
.
A WildcardTypeD returns its "TypeArgument" value (JVMS3). A
WildcardTypeD is uniquely identified by its type signature.
Example values: *
+Ljava/lang/Object;
- Returns:
- The type signature as defined in the JVMS3. Always
non-null.
getSuperclass
TypeD getSuperclass()
- Gets this type's superclass. The name "getSuperclass" was chosen
to be consistent with java/lang/Class.
- Returns:
- The type declaration for this type's superclass. Behavior
should "declaration" reflection.
If this is a ClassD: Null is returned for java/lang/Object and
primitive types, non-null otherwise. Where no base class was
declared, java/lang/Object is returned, even for interfaces.
If this is a TypeVariableD: Null if no superclass was declared
AND an interface as declared.
If this is a WildcardTypeD: Always non-null. If no superclass was
declared, then the TypeD for java/lang/Object is returned.
Note: Wildcard types may have a type variable as an upper bound,
therefore, this must return a TypeD instead of a ClassD.
getInterfaces
java.util.Collection getInterfaces()
- Gets this type's super-interfaces. The name "getInterfaces" was
chosen to be consistent with java/lang/Class.
- Returns:
- The collection of type declarations for this type's
super-interfaces. May be zero-length. Will include all implicit
base interfaces, e.g. all array types implement
java/lang/Cloneable.
Collection of TypeDs.
getHierarchy
java.util.Collection getHierarchy()
- Recursively gets all direct supertypes.
For ClassDs, this means superclasses and superinterfaces. Order
is depth-first, classes before interfaces, left-to-right, no
duplicates.
For TypeVariableDs and WildcardTypeDs, this means bounds.
- Returns:
- The collection of type declarations for all direct
supertypes (including java.lang.Object).
Collection of TypeDs.
isAssignableFrom
boolean isAssignableFrom(TypeD subject)
- True if this type is assignable from the subject type. Behavior
should match reflection. Consider the following expression where
S (subject) represents another type and T (this) represents this
type.
void method( S subject )
{
T variable = subject;
}
Notice that because the parameter subject is not a
constant-value, the assignment conversion will not perform the
implicit narrowing conversion.
Reflection does not perform auto-boxing and therefore, neither
does this.
- Returns:
- True if the above assignment is allowed. False if the
answer is not known or if the answer is no.
getDeclaredFields
java.util.Collection getDeclaredFields()
- Gets all declared fields. Includes synthetic fields and enum
constants.
- Returns:
- The collection of field declarations for declared fields,
synthetic or not, including enum constants.
Collection of FieldDs.
getDeclaredField
FieldD getDeclaredField(java.lang.String name)
- Gets the first matching declared field, null if none.
- Parameters:
name
- The name to match. Require non-null.
- Returns:
- The field declaration for the first matching declared field,
null if none.
getDeclaredConstructors
java.util.Collection getDeclaredConstructors()
- Gets all declared constructors. Includes synthetic
constructors.
Note: Constructors are not inherited, so the collection of
declared constructors is the same as the collection of
constructors.
- Returns:
- The collection of constructor declarations for declared
constructors, synthetic or not.
Collection of ConstructorDs.
getDeclaredConstructor
ConstructorD getDeclaredConstructor(TypeD[] parameters)
- Gets the matching declared constructor, null if none.
- Parameters:
parameters
- The exact parameter types to match. Null
indicates an empty parameter list.
- Returns:
- The constructor declaration for the first matching
constructor, null if none.
getDeclaredMethods
java.util.Collection getDeclaredMethods()
- Gets all declared methods. Does not include the hidden
clinit
method. Does not include the various "access$"
methods that may be present in class files.
- Returns:
- The collection of method declarations for declared methods,
excluding the
clinit
method.
Collection of MethodDs.
getDeclaredMethods
java.util.Collection getDeclaredMethods(java.lang.String name)
- Gets all matching declared methods.
- Parameters:
name
- The method name to match. Require non-null.
- Returns:
- The collection of method declarations for matching declared
methods.
Collection of MethodDs.
getDeclaredMethod
MethodD getDeclaredMethod(java.lang.String name,
TypeD[] parameters)
- Gets the matching declared method, null if none.
- Parameters:
name
- The method name to match. Require non-null.parameters
- The exact parameter types to match. Null
indicates an empty parameter list.
- Returns:
- The method declaration for the first matching method, null if none.
getDeclaredClasses
java.util.Collection getDeclaredClasses()
- Gets all declared member classes. Does not include local and
anonymous inner classes.
TODO: Should this return local and anonymous inner classes? I
don't remember what reflection does.
- Returns:
- The collection of class declarations for declared member
classes. Only returns member classes that are directly enclosing
in this type. Hence, a member class of a member class would not
be listed here.
Collection of ClassDs.
getDeclaredClass
ClassD getDeclaredClass(java.lang.String name)
- Gets the matching member class, null if none.
- Returns:
- The class declaration for the matching declared member class.
getFields
java.util.Collection getFields()
- Gets all member fields, declared and inherited. The type
hierarchy dictates order. Does not filter according to
accessibility or visibility.
For more detal on members, please see the Members discussion at
TypeD
.
Note: The implicit "length" field for array types should be
suppressed because according to the JLS, it is technically not a
member variable.
- Returns:
- A collection of field declarations for all member fields,
declared and inherited.
Collection of FieldDs.
getField
FieldD getField(java.lang.String name)
- Gets the matching member field, null if none.
- Parameters:
name
- The field name to match. Require non-null.
- Returns:
- The field declaration for the first matching member field,
null if none.
getMethods
java.util.Collection getMethods()
- Gets all member methods, declared and inherited. The type
hierarchy dictates order. Does not filter according to
accessibility or visibility.
For more detal on members, please see the Members discussion at
TypeD
.
- Returns:
- A collection of method declarations for all member methods,
declared and inherited.
Collection of MethodDs.
getMethods
java.util.Collection getMethods(java.lang.String name)
- Gets all matching methods.
- Parameters:
name
- The method name to match. Require non-null.
- Returns:
- A collection of method declarations for all matching member
methods.
Collection of MethodDs.
getMethod
MethodD getMethod(java.lang.String name,
TypeD[] parameters)
- Gets the first matching method, null if none.
- Parameters:
name
- The method name to match. Require non-null.parameters
- The exact parameter types to match. Null
indicates an empty parameter list.
- Returns:
- The method declaration for the first matching method, null if
none.
getClasses
java.util.Collection getClasses()
- Gets all member classes, declared and inherited. The type
hierarchy dictates order. Does not filter according to
accessibility or visibility.
For more detal on members, please see the Members discussion at
TypeD
.
- Returns:
- A collection of class declarations for all member classes,
declared and inherited.
Collection of ClassDs.
getClass
ClassD getClass(java.lang.String name)
- Gets the first matching member class, null if none.
- Parameters:
name
- The simple class name to match. Require non-null.
- Returns:
- The class declaration for the first matching member class,
null if none.
equals
boolean equals(java.lang.Object o)
- True if the other object is also a TypeD and they represent the
same type.
ClassDs and WildcardTypeDs are uniquely identified by their type
signatures. TypeVariableDs are uniquely identified by both their
owning declaration and type signature.
- Overrides:
equals
in class java.lang.Object
- Returns:
- True if o is a TypeD and declarations the same type.
Copyright © 1997, 2013, Oracle. All rights reserved.