JsonTypeInfo to indicate subtypes of serializable
polymorphic types, and to associate logical names used within JSON content
(which is more portable than using physical Java class names).
Note that just annotating a property or base type with this annotation does
NOT enable polymorphic type handling: in addition, JsonTypeInfo
or equivalent (such as enabling of so-called "default typing") annotation
is needed, and only in such case is subtype information used.
| Modifier and Type | Class and Description |
|---|---|
| public static @interface | JsonSubTypes.Type
Definition of a subtype, along with optional name(s). |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | failOnRepeatedNames()
Subtypes of the annotated type may have logical type name and names properties. |
| public JsonSubTypes. | value()
Subtypes of the annotated type (annotated class, or property value type associated with the annotated method). |
| failOnRepeatedNames | back to summary |
|---|---|
| public boolean failOnRepeatedNames() Subtypes of the annotated type may have logical type name and names properties. When set to true, logical type name and names are going to be checked for repeated values. Repeated values are considered a definition violation during that check.
| |
| value | back to summary |
|---|---|
| public JsonSubTypes. Subtypes of the annotated type (annotated class, or property value type associated with the annotated method). These will be checked recursively so that types can be defined by only including direct subtypes. | |
JsonTypeName
annotation; and if that is also missing or empty, a default
name will be constructed by type id mechanism.
Default name is usually based on class name.
| Modifier and Type | Method and Description |
|---|---|
| public String | name()
Logical type name used as the type identifier for the class, if defined; empty String means "not defined". |
| public String[] | names()
(optional) Logical type names used as the type identifier for the class: used if more than one type name should be associated with the same type. |
| public Class |
| name | back to summary |
|---|---|
| public String name() Logical type name used as the type identifier for the class, if defined; empty
String means "not defined". Used unless | |
| names | back to summary |
|---|---|
| public String[] names() (optional) Logical type names used as the type identifier for the class: used if more than one type name should be associated with the same type.
| |
| value | back to summary |
|---|---|
| public Class Class of the subtype | |