Interface Record

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

public interface Record extends Declared, StaticModifiable, FinalModifiable
  • Method Details

    • getRecordComponentOrThrow

      RecordComponent getRecordComponentOrThrow(String simpleName)
    • getRecordComponents

      List<RecordComponent> getRecordComponents()
    • withGenerics

      Record withGenerics(Shadow<? extends TypeMirror>... generics)
      shadowApi.getRecordOrThrow("org.example.MyRecord") represents MyRecord shadowApi.getRecordOrThrow("org.example.MyRecord").withGenerics(shadowApi.getDeclaredOrThrow("java.lang.String")) represents MyRecord<String>
    • withGenerics

      Record withGenerics(String... qualifiedGenerics)
    • getGenerics

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

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

      Record 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

      Record 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 Records this means for example record MyRecord<T>(T t){} -> record MyRecord<java.lang.Object>(T t){}

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