From 7a86901072b06bece1483ed416b3e94a21f44f6a Mon Sep 17 00:00:00 2001 From: joohyukkim Date: Fri, 21 Apr 2023 19:14:13 +0900 Subject: [PATCH 1/2] Add attribute to JsonTypeInfo Sqaushed followings: - Clean up pom.xml changes - Update JsonTypeInfo.java - Clean up changes - Update JsonTypeInfo.java --- .../jackson/annotation/JsonTypeInfo.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/fasterxml/jackson/annotation/JsonTypeInfo.java b/src/main/java/com/fasterxml/jackson/annotation/JsonTypeInfo.java index ea104c75..778d3d8b 100644 --- a/src/main/java/com/fasterxml/jackson/annotation/JsonTypeInfo.java +++ b/src/main/java/com/fasterxml/jackson/annotation/JsonTypeInfo.java @@ -330,5 +330,21 @@ public enum As { * if such behavior is needed; this is rarely necessary. */ @Deprecated - public abstract static class None { } + public abstract static class None {} + + /** + * Determines whether strict type ID handling should be used for this type or not. This is per-type configuration of + * {@code MapperFeature#REQUIRE_TYPE_ID_FOR_SUBTYPES} and will always + * override the global configuration. + *

+ * If set to {@link OptBoolean#TRUE}, then {@code InvalidTypeIdException} will be thrown if no type information + * is provided during polymorphic deserialization for this type; + * if set to {@link OptBoolean#FALSE}, then the deserialization may proceed without the type information assuming + * sub-type is a legitimate target (non-abstract); + * if set to {@link OptBoolean#DEFAULT}, then global configuration of + * {@code MapperFeature.REQUIRE_TYPE_ID_FOR_SUBTYPES} is used for type id handling. + * + * @since 2.16 + */ + OptBoolean requireTypeIdForSubtypes() default OptBoolean.DEFAULT; } From ae0d9f6b1c552e09b050d7789b783401efb61e0d Mon Sep 17 00:00:00 2001 From: joohyukkim Date: Mon, 24 Apr 2023 20:03:16 +0900 Subject: [PATCH 2/2] Improve JavaDoc --- .../jackson/annotation/JsonTypeInfo.java | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/fasterxml/jackson/annotation/JsonTypeInfo.java b/src/main/java/com/fasterxml/jackson/annotation/JsonTypeInfo.java index 778d3d8b..e4016a5f 100644 --- a/src/main/java/com/fasterxml/jackson/annotation/JsonTypeInfo.java +++ b/src/main/java/com/fasterxml/jackson/annotation/JsonTypeInfo.java @@ -313,7 +313,7 @@ public enum As { * * @since 2.5 public boolean skipWritingDefault() default false; - /* + */ /* /********************************************************** @@ -333,18 +333,19 @@ public enum As { public abstract static class None {} /** - * Determines whether strict type ID handling should be used for this type or not. This is per-type configuration of - * {@code MapperFeature#REQUIRE_TYPE_ID_FOR_SUBTYPES} and will always - * override the global configuration. + * Specifies whether the type ID should be strictly required during polymorphic deserialization of its subtypes. + *

+ * If set to {@link OptBoolean#TRUE}, an {@code InvalidTypeIdException} will be thrown if no type + * information is provided. + * If set to {@link OptBoolean#FALSE}, deserialization may proceed without type information if the + * subtype is a legitimate target (non-abstract). + * If set to {@link OptBoolean#DEFAULT}, the global configuration of + * {@code MapperFeature#REQUIRE_TYPE_ID_FOR_SUBTYPES} is used for type ID handling. *

- * If set to {@link OptBoolean#TRUE}, then {@code InvalidTypeIdException} will be thrown if no type information - * is provided during polymorphic deserialization for this type; - * if set to {@link OptBoolean#FALSE}, then the deserialization may proceed without the type information assuming - * sub-type is a legitimate target (non-abstract); - * if set to {@link OptBoolean#DEFAULT}, then global configuration of - * {@code MapperFeature.REQUIRE_TYPE_ID_FOR_SUBTYPES} is used for type id handling. + * NOTE: This setting is specific to this type and will always override the global + * configuration of {@code MapperFeature#REQUIRE_TYPE_ID_FOR_SUBTYPES}. * * @since 2.16 */ - OptBoolean requireTypeIdForSubtypes() default OptBoolean.DEFAULT; + public OptBoolean requireTypeIdForSubtypes() default OptBoolean.DEFAULT; }