Annotation Interface PolymorphicTypes


@Target(TYPE) @Retention(RUNTIME) public @interface PolymorphicTypes
Indicates the subtypes of Polymorphic types. This annotation can be used to provide type aliases for subtypes which are then used instead of Java class names.
 
 @Polymorphic
 @PolymorphicTypes( {
         @PolymorphicTypes.Type(type = Impl1.class, alias = "IMPL_1"),
         @PolymorphicTypes.Type(type = Impl2.class, alias = "IMPL_2")
 })

 interface A { ... }

 record Impl1(...) implements A { ... }
 record Impl2(...) implements A { ... }

 List<A> as = List.of(new Impl1(...), new Impl2(...), ...);
 
 
See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static @interface 
    Indicates a subtype of a Polymorphic type.
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    Returns (possibly only a subset of) the subtypes of the annotated type.
  • Element Details

    • value

      Returns (possibly only a subset of) the subtypes of the annotated type.
      Returns:
      subtypes of the annotated type