Interface Class

All Superinterfaces:
AbstractModifiable, AccessModifiable, Annotationable<TypeElement>, ApiHolder, Declared, ElementBacked<TypeElement>, FinalModifiable, MirrorBacked<DeclaredType>, Modifiable, QualifiedNameable<TypeElement>, Sealable, Shadow<DeclaredType>, StaticModifiable, StrictfpModifiable
All Known Implementing Classes:
ClassImpl

  • Method Details

    • getSuperClass

      Class getSuperClass()
      reruns the super class of this class. calling getSuperClass()) on Integer will return Number. For Object null will be returned
    • getPermittedSubClasses

      List<Class> getPermittedSubClasses()
    • getProperties

      List<Property> getProperties()
    • getMutableProperties

      List<MutableProperty> getMutableProperties()
    • getImmutableProperties

      List<ImmutableProperty> getImmutableProperties()
    • isAssignableFrom

      boolean isAssignableFrom(Shadow<? extends TypeMirror> shadow)
      Equivalent to Declared.isSubtypeOf(Shadow) except for primitives. if one is a primitive and the other is not it tries to convert them
    • getOuterType

      Optional<Declared> getOuterType()
      returns the outer type for not static classes
    • withGenerics

      Class withGenerics(Shadow<? extends TypeMirror>... generics)
      shadowApi.getDeclaredOrThrow("java.util.List") represents List shadowApi.getDeclaredOrThrow("java.util.List").withGenerics(shadowApi.getDeclaredOrThrow("java.lang.String")) represents List<String>
    • withGenerics

      Class withGenerics(String... qualifiedGenerics)
    • getGenerics

      List<Shadow<TypeMirror>> getGenerics()
      List<String>
    • getFormalGenerics

      List<Generic> getFormalGenerics()
      List<T>
    • interpolateGenerics

      Class interpolateGenerics()
      Used when constructing types to compare to at compile time that contain multiple, on each other depended, generics.

      it answers the question: given public class MyClass<A extends Comparable<B>, B extends Comparable<A>> {} and A being String what can B be by returning the "simplest" possible answer. in this case String

      The code for the example

      
             Class declared = shadowApi.getClassOrThrow("io.determann.shadow.example.processed.MyClass")
                                       .withGenerics(shadowApi.getDeclaredOrThrow("java.lang.String"),
                                                        shadowApi.getConstants().getUnboundWildcard());
             Class capture = declared.interpolateGenerics();
      
             Shadow<TypeMirror> stringRep = convert(capture.getGenerics().get(1))
                                                            .toGeneric()
                                                            .map(Generic::getExtends)
                                                            .map(shadowApi::convert)
                                                            .flatMap(ShadowConverter::toClassOrThrow)
                                                            .map(Class::getGenerics)
                                                            .map(shadows -> shadows.get(0))
                                                            .orElseThrow();
      
             System.out.println(stringRep.representsSameType(shadowApi.getDeclaredOrThrow("java.lang.String")));
       
      Note the use of the unboundWildcardConstant witch gets replaced by calling capture() with the result
    • erasure

      Class erasure()
      Information regarding generics is lost after the compilation. For Example List<String> becomes List. This method Does the same. This can be useful if you want to check if a shadow implements for example Collection shadowToTest.erasure().isSubtypeOf(shadowApi.getDeclaredOrThrow("java.util.Collection").erasure())

      for Classs this means for example class MyClass<T>{} -> class MyClass{}

    • asUnboxed

      Primitive asUnboxed()
      Integer -> int
      Long -> long etc...
    • equals

      boolean equals(Object obj)
      be careful using this equals
      Specified by:
      equals in interface Declared
      Specified by:
      equals in interface Shadow<DeclaredType>
      Overrides:
      equals in class Object
      See Also: