Annotation Type Json.SubType

Enclosing class:
Json

@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.

invalid input: '{@code

   @Json
   @Json.SubType(type = Car.class)
   @Json.SubType(type = Truck.class, name = "TRUCK")
   public abstract class Vehicle {
    ...

 }</pre>'
  • Required Element Summary

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

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

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