Annotation Type Json.SubType


  • @Retention(CLASS)
    @Target(TYPE)
    @Repeatable(SubTypes.class)
    public static @interface Json.SubType
    Specify the subtypes that a given type can be represented as.

    This is used on an interface type, abstract type or type with inheritance to indicate all the concrete subtypes that can represent the type.

    In the example below the abstract Vehicle type has 2 concrete subtypes of Car and Truck that can represent the type.

    {@code
    • Required Element Summary

      Required Elements 
      Modifier and Type Required Element Description
      Class<?> type
      The concrete type that extends or implements the base type.
    • Optional Element Summary

      Optional Elements 
      Modifier and Type Optional Element Description
      String name
      The name or "discriminator value" that is used to identify the type.
    • Element Detail

      • type

        Class<?> type
        The concrete type that extends or implements the base type.
      • name

        String name
        The name or "discriminator value" that is used to identify the type.

        When unspecified this is the short name of the class.

        Default:
        ""