From 624bbef46c8b17e52fcf235acb3f268235f18b5f Mon Sep 17 00:00:00 2001 From: "Kim, Joo Hyuk" Date: Tue, 16 May 2023 09:59:23 +0900 Subject: [PATCH] =?UTF-8?q?Add=20new=C2=A0`OptBoolean`=C2=A0valued=20prope?= =?UTF-8?q?rty=20in=C2=A0`@JsonTypeInfo`=20to=20allow=20per-type=20configu?= =?UTF-8?q?ration=20of=20strict=20type=20id=20handling=20(#223)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jackson/annotation/JsonTypeInfo.java | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/fasterxml/jackson/annotation/JsonTypeInfo.java b/src/main/java/com/fasterxml/jackson/annotation/JsonTypeInfo.java index b659aa01..8d363d2b 100644 --- a/src/main/java/com/fasterxml/jackson/annotation/JsonTypeInfo.java +++ b/src/main/java/com/fasterxml/jackson/annotation/JsonTypeInfo.java @@ -315,7 +315,7 @@ public enum As { * * @since 2.5 public boolean skipWritingDefault() default false; - /* + */ /* /********************************************************** @@ -332,5 +332,22 @@ public enum As { * if such behavior is needed; this is rarely necessary. */ @Deprecated - public abstract static class None { } + public abstract static class None {} + + /** + * 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. + *

+ * 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 + */ + public OptBoolean requireTypeIdForSubtypes() default OptBoolean.DEFAULT; }