Package 

Interface TypeMirror


  • 
    public interface TypeMirror
    
                        

    The common superinterface of all mirrors that represent types.

    • 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 AnnotatedType don't implement equals or hashCode, so they will equal neither each other nor this. If you need these methods pass any annotated type through Mirror.toCanonical.

      • getRaw

         abstract TypeMirror getRaw()

        The mirror representing this type without any generic specialization