|
Mirror API | |||||||||
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.
Method Summary | |
---|---|
ArrayType |
getArrayType(TypeMirror componentType)
Returns an array type with the specified component type. |
DeclaredType |
getDeclaredType(DeclaredType containing,
TypeDeclaration decl,
TypeMirror... typeArgs)
Returns the type corresponding to a type declaration and actual arguments, given a containing type of which it is a member. |
DeclaredType |
getDeclaredType(TypeDeclaration decl,
TypeMirror... typeArgs)
Returns the type corresponding to a type declaration and actual type arguments. |
TypeMirror |
getErasure(TypeMirror t)
Returns the erasure of a type. |
PrimitiveType |
getPrimitiveType(PrimitiveType.Kind kind)
Returns a primitive type. |
TypeVariable |
getTypeVariable(TypeParameterDeclaration tparam)
Returns the type variable declared by a type parameter. |
VoidType |
getVoidType()
Returns the pseudo-type representing the type of void. |
WildcardType |
getWildcardType(Collection<ReferenceType> upperBounds,
Collection<ReferenceType> lowerBounds)
Returns a new wildcard. |
boolean |
isAssignable(TypeMirror t1,
TypeMirror t2)
Tests whether one type is assignable to another. |
boolean |
isSubtype(TypeMirror t1,
TypeMirror t2)
Tests whether one type is a subtype of the another. |
Method Detail |
---|
boolean isSubtype(TypeMirror t1, TypeMirror t2)
t1
- the first typet2
- the second type
boolean isAssignable(TypeMirror t1, TypeMirror t2)
t1
- the first typet2
- the second type
TypeMirror getErasure(TypeMirror t)
t
- the type to be erased
PrimitiveType getPrimitiveType(PrimitiveType.Kind kind)
kind
- the kind of primitive type to return
VoidType getVoidType()
ArrayType getArrayType(TypeMirror componentType)
componentType
- the component type
IllegalArgumentException
- if the component type is not valid for
an arrayTypeVariable getTypeVariable(TypeParameterDeclaration tparam)
tparam
- the type parameter
WildcardType getWildcardType(Collection<ReferenceType> upperBounds, Collection<ReferenceType> lowerBounds)
upperBounds
- the upper bounds of this wildcard,
or an empty collection if nonelowerBounds
- the lower bounds of this wildcard,
or an empty collection if none
IllegalArgumentException
- if bounds are not validDeclaredType getDeclaredType(TypeDeclaration decl, TypeMirror... typeArgs)
Set<String>
.
The number of type arguments must either equal the number of the declaration's formal type parameters, or must be zero. If zero, and if the declaration is generic, then the declaration's raw type is returned.
If a parameterized type is being returned, its declaration
must not be contained within a generic outer class.
The parameterized type Outer<String>.Inner<Number>
,
for example, may be constructed by first using this
method to get the type Outer<String>
, and then invoking
getDeclaredType(DeclaredType, TypeDeclaration, TypeMirror...)
.
decl
- the type declarationtypeArgs
- the actual type arguments
IllegalArgumentException
- if too many or too few
type arguments are given, or if an inappropriate type
argument or declaration is providedDeclaredType getDeclaredType(DeclaredType containing, TypeDeclaration decl, TypeMirror... typeArgs)
Outer<String>.Inner<Number>
,
for example, may be constructed by first using
getDeclaredType(TypeDeclaration, TypeMirror...)
to get the type Outer<String>
, and then invoking
this method.
If the containing type is a parameterized type, the number of type arguments must equal the number of the declaration's formal type parameters. If it is not parameterized or if it is null, this method is equivalent to getDeclaredType(decl, typeArgs).
containing
- the containing type, or null if nonedecl
- the type declarationtypeArgs
- the actual type arguments
IllegalArgumentException
- if too many or too few
type arguments are given, or if an inappropriate type
argument, declaration, or containing type is provided
|
Mirror API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |