| |||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Types
Utility methods for operating on types.
Compatibility Note: Methods may be added to this interface in future releases of the platform.
Method Summary | |
---|---|
Element |
Returns the element corresponding to a type. |
TypeMirror |
asMemberOf(DeclaredType containing, Element element) Returns the type of an element when that element is viewed as a member of, or otherwise directly contained by, a given type. |
TypeElement |
Returns the class of a boxed value of a given primitive type. |
TypeMirror |
Applies capture conversion to a type. |
boolean |
contains(TypeMirror t1, TypeMirror t2) Tests whether one type argument contains another. |
List |
Returns the direct supertypes of a type. |
TypeMirror |
Returns the erasure of a type. |
ArrayType |
getArrayType(TypeMirror componentType) Returns an array type with the specified component type. |
DeclaredType |
getDeclaredType(DeclaredType containing, TypeElement typeElem, TypeMirror[] typeArgs) Returns the type corresponding to a type element and actual type arguments, given a javax.lang.model.type.DeclaredType.getEnclosingType of which it is a member. |
DeclaredType |
getDeclaredType(TypeElement typeElem, TypeMirror[] typeArgs) Returns the type corresponding to a type element and actual type arguments. |
NoType |
Returns a pseudo-type used where no actual type is appropriate. |
NullType |
Returns the null type. |
PrimitiveType |
getPrimitiveType(TypeKind kind) Returns a primitive type. |
WildcardType |
getWildcardType(TypeMirror extendsBound, TypeMirror superBound) Returns a new wildcard type argument. |
boolean |
isAssignable(TypeMirror t1, TypeMirror t2) Tests whether one type is assignable to another. |
boolean |
isSameType(TypeMirror t1, TypeMirror t2) Tests whether two objects represent the same type. |
boolean |
Tests whether the signature of one method is a subsignature of another. |
boolean |
isSubtype(TypeMirror t1, TypeMirror t2) Tests whether one type is a subtype of another. |
PrimitiveType |
Returns the type (a primitive type) of unboxed values of a given type. |
Method Detail |
---|
public Element asElement(TypeMirror t)
t
public TypeMirror asMemberOf(DeclaredType containing, Element element)
containing
- the containing typeelement
- the elementpublic TypeElement boxedClass(PrimitiveType p)
p
- the primitive type to be convertedpublic TypeMirror capture(TypeMirror t)
t
- the type to be convertedpublic boolean contains(TypeMirror t1, TypeMirror t2)
t1
- the first typet2
- the second typepublic List directSupertypes(TypeMirror t)
t
- the type being examinedpublic TypeMirror erasure(TypeMirror t)
t
- the type to be erasedpublic ArrayType getArrayType(TypeMirror componentType)
componentType
- the component typepublic DeclaredType getDeclaredType(DeclaredType containing, TypeElement typeElem, TypeMirror[] typeArgs)
If the containing type is a parameterized type, the number of type arguments must equal the number of {@code typeElem}'s formal type parameters. If it is not parameterized or if it is {@code null}, this method is equivalent to {@code getDeclaredType(typeElem, typeArgs)}.
containing
- the containing type, or {@code null} if nonetypeElem
- the type elementtypeArgs
- the actual type argumentspublic DeclaredType getDeclaredType(TypeElement typeElem, TypeMirror[] typeArgs)
The number of type arguments must either equal the number of the type element's formal type parameters, or must be zero. If zero, and if the type element is generic, then the type element's raw type is returned.
If a parameterized type is being returned, its type element
must not be contained within a generic outer class.
The parameterized type {@code Outer
typeElem
- the type elementtypeArgs
- the actual type arguments
public NoType getNoType(TypeKind kind)
kind
- the kind of type to returnpublic NullType getNullType()
public PrimitiveType getPrimitiveType(TypeKind kind)
kind
- the kind of primitive type to returnpublic WildcardType getWildcardType(TypeMirror extendsBound, TypeMirror superBound)
extendsBound
- the extends (upper) bound, or {@code null} if nonesuperBound
- the super (lower) bound, or {@code null} if nonepublic boolean isAssignable(TypeMirror t1, TypeMirror t2)
t1
- the first typet2
- the second typepublic boolean isSameType(TypeMirror t1, TypeMirror t2)
Caveat: if either of the arguments to this method represents a wildcard, this method will return false. As a consequence, a wildcard is not the same type as itself. This might be surprising at first, but makes sense once you consider that an example like this must be rejected by the compiler:
{@code List> list = new ArrayList
t1
- the first typet2
- the second typepublic boolean isSubsignature(ExecutableType m1, ExecutableType m2)
m1
- the first methodm2
- the second methodpublic boolean isSubtype(TypeMirror t1, TypeMirror t2)
t1
- the first typet2
- the second typepublic PrimitiveType unboxedType(TypeMirror t)
t
- the type to be unboxed
| |||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |