public final class TypeUtilities extends Object
TypeMirror
s.Types
Modifier and Type | Class and Description |
---|---|
static class |
TypeUtilities.TypeNameOptions
|
Modifier and Type | Method and Description |
---|---|
TypeMirror |
getDenotableType(TypeMirror type)
Returns a TypeMirror which can be represented in a source as a type declarator.
|
ExecutableType |
getDescriptorType(DeclaredType origin)
Find the type of the method descriptor associated to the functional interface.
|
CharSequence |
getTypeName(TypeMirror type,
TypeUtilities.TypeNameOptions... options)
Get textual representation of the given type.
|
boolean |
isCastable(TypeMirror t1,
TypeMirror t2)
Check if type t1 can be cast to t2.
|
TypeMirror |
substitute(TypeMirror type,
List<? extends TypeMirror> from,
List<? extends TypeMirror> to)
Substitute all occurrences of a type in 'from' with the corresponding type
in 'to' in 'type'.
|
public boolean isCastable(TypeMirror t1, TypeMirror t2)
t1
- cast from typet2
- cast to typeIllegalArgumentException
- if the 't1' is of EXACUTABLE
,
PACKAGE
, NONE
, or OTHER
kindpublic TypeMirror substitute(TypeMirror type, List<? extends TypeMirror> from, List<? extends TypeMirror> to)
type
- in which the types should be substitutedfrom
- types to substituteto
- substitute to typesIllegalArgumentException
- if the 'from' and 'to' lists are not of the same lengthpublic ExecutableType getDescriptorType(DeclaredType origin)
origin
- functional interface typenull
if the origin
is not a functional interface.@NonNull @CheckReturnValue public CharSequence getTypeName(@NullAllowed TypeMirror type, @NonNull TypeUtilities.TypeNameOptions... options)
type
- to printoptions
- allows to specify various adjustments to the output textpublic TypeMirror getDenotableType(TypeMirror type)
TypeKind.ERROR
.type
- the type to be polished