-
public interface TypeMirrorThe common superinterface of all mirrors that represent types.
-
-
Method Summary
Modifier and Type Method Description abstract BooleanisAssignableFrom(TypeMirror other)Determines if this mirror represents a logical supertype of the passed mirror, i.e. abstract TypeMirrorwithTypeAnnotations(List<Annotation> annotations)Creates a copy of this type mirror that has been specialized to have the passed Type Annotations. abstract ClassMirrorasClassMirror()Casts this TypeMirror to ClassMirror. abstract ArrayMirrorasArrayMirror()Casts this TypeMirror to ArrayMirror. abstract StringtoString()Returns a string approximating the appearance of this type when used in Java source code. abstract StringtoJavaString()Returns a string approximating the appearance of this type when used in Java source code. abstract StringtoKotlinString()Returns a string approximating the appearance of this type when used in Kotlin source code. abstract TypegetCoreType()The Java Core Reflection type this mirror represents abstract AnnotatedTypegetCoreAnnotatedType()The Java Core Reflection annotated type this mirror represents. abstract Class<?>getErasure()The JVM erasure of this type. abstract TypeMirrorgetRaw()The mirror representing this type without any generic specialization abstract AnnotationListgetTypeAnnotations()The type annotations present on this type. -
-
Method Detail
-
isAssignableFrom
abstract Boolean isAssignableFrom(TypeMirror other)
Determines if this mirror represents a logical supertype of the passed mirror, i.e. whether a value of type other could be "cast" to the type represented by this mirror, including generic type arguments.
-
withTypeAnnotations
abstract TypeMirror withTypeAnnotations(List<Annotation> annotations)
Creates a copy of this type mirror that has been specialized to have the passed Type Annotations. Type annotations on this mirror will not carry over to the resulting mirror.
Note that are not the annotations present on the class declaration, they are the annotations present on the use of the type.
-
asClassMirror
abstract ClassMirror asClassMirror()
Casts this TypeMirror to ClassMirror. Designed to avoid the nested casts from hell:
((ClassMirror) ((ClassMirror) ((ClassMirror) Mirror.reflect(SomeType.class).findField("name").getType()).getTypeParameters()[0]).findField("name2").getType()).getSimpleName() // vs. Mirror.reflect(SomeType.class).findField("name") .getType().asClassMirror() .getTypeParameters()[0].asClassMirror() .findField("name").getType().asClassMirror().getSimpleName()
-
asArrayMirror
abstract ArrayMirror asArrayMirror()
Casts this TypeMirror to ArrayMirror. Designed to avoid the nested casts from hell:
((ClassMirror) ((ArrayMirror) ((ArrayMirror) ((ArrayMirror) Mirror.reflect(String[][][].class)).getComponent()).getComponent()).getComponent()) // vs. Mirror.reflect(String[][][].class).asArrayMirror() .getComponent().asArrayMirror() .getComponent().asArrayMirror() .getComponent().asClassMirror()
-
toString
abstract String toString()
Returns a string approximating the appearance of this type when used in Java source code.
-
toJavaString
abstract String toJavaString()
Returns a string approximating the appearance of this type when used in Java source code.
-
toKotlinString
abstract String toKotlinString()
Returns a string approximating the appearance of this type when used in Kotlin source code.
-
getCoreType
abstract Type getCoreType()
The Java Core Reflection type this mirror represents
-
getCoreAnnotatedType
abstract AnnotatedType getCoreAnnotatedType()
The Java Core Reflection annotated type this mirror represents.
!!NOTE!! The JVM implementations of
AnnotatedTypedon't implementequalsorhashCode, so they will equal neither each other nor this. If you need these methods pass any annotated type through Mirror.toCanonical.
-
getErasure
abstract Class<?> getErasure()
The JVM erasure of this type.
-
getRaw
abstract TypeMirror getRaw()
The mirror representing this type without any generic specialization
-
getTypeAnnotations
abstract AnnotationList getTypeAnnotations()
The type annotations present on this type. These are not the annotations present on the declaration, they are the annotations present on the use of the type.
-
-
-
-