Interface Interface

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

public interface Interface extends Declared, AbstractModifiable, StaticModifiable, Sealable
  • Method Details

    • isFunctional

      boolean isFunctional()
    • withGenerics

      Interface 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

      Interface withGenerics(String... qualifiedGenerics)
    • getGenerics

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

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

      Interface 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

      Interface 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 Interfaces this means for example interface MyInterface<T>{} -> interface MyInterface{}

    • 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: