Skip to content

Commit 624bbef

Browse files
authored
Add new OptBoolean valued property in @JsonTypeInfo to allow per-type configuration of strict type id handling (#223)
1 parent a693317 commit 624bbef

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

src/main/java/com/fasterxml/jackson/annotation/JsonTypeInfo.java

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ public enum As {
315315
*
316316
* @since 2.5
317317
public boolean skipWritingDefault() default false;
318-
/*
318+
*/
319319

320320
/*
321321
/**********************************************************
@@ -332,5 +332,22 @@ public enum As {
332332
* if such behavior is needed; this is rarely necessary.
333333
*/
334334
@Deprecated
335-
public abstract static class None { }
335+
public abstract static class None {}
336+
337+
/**
338+
* Specifies whether the type ID should be strictly required during polymorphic deserialization of its subtypes.
339+
* <p>
340+
* If set to {@link OptBoolean#TRUE}, an {@code InvalidTypeIdException} will be thrown if no type
341+
* information is provided.
342+
* If set to {@link OptBoolean#FALSE}, deserialization may proceed without type information if the
343+
* subtype is a legitimate target (non-abstract).
344+
* If set to {@link OptBoolean#DEFAULT}, the global configuration of
345+
* {@code MapperFeature#REQUIRE_TYPE_ID_FOR_SUBTYPES} is used for type ID handling.
346+
* <p>
347+
* NOTE: This setting is specific to this type and will <strong>always override</strong> the global
348+
* configuration of {@code MapperFeature#REQUIRE_TYPE_ID_FOR_SUBTYPES}.
349+
*
350+
* @since 2.16
351+
*/
352+
public OptBoolean requireTypeIdForSubtypes() default OptBoolean.DEFAULT;
336353
}

0 commit comments

Comments
 (0)