Returns the element corresponding to a type.
The type may be a {@code DeclaredType} or {@code TypeVariable}.
Returns {@code null} if the type is not one with a
corresponding element.
Returns the type of an element when that element is viewed as
a member of, or otherwise directly contained by, a given type.
For example,
when viewed as a member of the parameterized type {@code Set},
the {@code Set.add} method is an {@code ExecutableType}
whose parameter is of type {@code String}.
param
containing the containing type
param
element the element
return
the type of the element as viewed from the containing type
throws
IllegalArgumentException if the element is not a valid one
for the given type
Returns the type corresponding to a type element and
actual type arguments.
Given the type element for {@code Set} and the type mirror
for {@code String},
for example, this method may be used to get the
parameterized type {@code Set}.
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.Inner},
for example, may be constructed by first using this
method to get the type {@code Outer}, and then invoking
{@link #getDeclaredType(DeclaredType, TypeElement, TypeMirror...)}.
param
typeElem the type element
param
typeArgs the actual type arguments
return
the type corresponding to the type element and
actual type arguments
throws
IllegalArgumentException if too many or too few
type arguments are given, or if an inappropriate type
argument or type element is provided
Returns the type corresponding to a type element
and actual type arguments, given a
{@linkplain DeclaredType#getEnclosingType() containing type}
of which it is a member.
The parameterized type {@code Outer.Inner},
for example, may be constructed by first using
{@link #getDeclaredType(TypeElement, TypeMirror...)}
to get the type {@code Outer}, and then invoking
this method.
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)}.
param
containing the containing type, or {@code null} if none
param
typeElem the type element
param
typeArgs the actual type arguments
return
the type corresponding to the type element and
actual type arguments, contained within the given type
throws
IllegalArgumentException if too many or too few
type arguments are given, or if an inappropriate type
argument, type element, or containing type is provided
Returns a pseudo-type used where no actual type is appropriate.
The kind of type to return may be either
{@link TypeKind#VOID VOID} or {@link TypeKind#NONE NONE}.
For packages, use
{@link Elements#getPackageElement(CharSequence)}{@code .asType()}
instead.
param
kind the kind of type to return
return
a pseudo-type of kind {@code VOID} or {@code NONE}
throws
IllegalArgumentException if {@code kind} is not valid
Tests whether two {@code TypeMirror} objects represent the same type.
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
param
t1 the first type
param
t2 the second type
return
{@code true} if and only if the two types are the same