-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Add new @JsonTypeInfo.requireTypeIdForSubtypes usage
#3891
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add new @JsonTypeInfo.requireTypeIdForSubtypes usage
#3891
Conversation
OptBoolean valued property in @JsonTypeInfo to allow per-type configuration of strict type id handling
de1dbc2 to
66632c3
Compare
| } | ||
| b = b.typeIdVisibility(info.visible()); | ||
| // [databind#3877]: allow configuration of per-type strict type handling | ||
| b.requireTypeIdForSubtypes(info.requireTypeIdForSubtypes().asBoolean()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The point of OptBoolean is to have "third option" of "not specified", so I think this should check that case (skip call if value is OptBoolean.DEFAULT)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh. Actually, never mind. asBoolean() returns null for the case, so I think this is fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add a comment though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3df1268 to
3b10205
Compare
| * This is per-type override of {@link com.fasterxml.jackson.databind.MapperFeature#REQUIRE_TYPE_ID_FOR_SUBTYPES}. | ||
| * Sets {@link Boolean} value provided by {@link OptBoolean#asBoolean()} of configured {@link JsonTypeInfo#requireTypeIdForSubtypes}. | ||
| * <p> | ||
| * WARNING: This method will be abstract in Jackson 3.0. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| * WARNING: This method will be abstract in Jackson 3.0. |
Will remove this line, because.... who knows 🤔🤔
a4a272c to
6968ab3
Compare
| public default void requireTypeIdForSubtypes(Boolean requireTypeId) { | ||
| // no-op | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There shouldn't be mutator here, but instead use @JsonTypeInfo.Value
| * | ||
| * @since 2.16 | ||
| */ | ||
| protected Boolean _requireTypeIdForSubtypes; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There shouldn't be mutator here, but instead use @JsonTypeInfo.Value
same
|
@JooHyukKim Is this particular PR still active, or is there a replacement wrt |
|
@cowtowncoder Ah, yes this PR is still active, originated from #2968 regarding per-type configuration of Polymorphic handling. I will update the PR message to indicate that accordingly 👍🏻 And fix conflicts 😄 |
OptBoolean valued property in @JsonTypeInfo to allow per-type configuration of strict type id handling@JsonTypeInfo. requireTypeIdForSubtypes to allow per-type configuration of strict type id handling
@JsonTypeInfo. requireTypeIdForSubtypes to allow per-type configuration of strict type id handling@JsonTypeInfo.requireTypeIdForSubtypes
This PR is ready for a review now! 👍🏻 After improvements such as #3953 and FasterXML/jackson-annotations#223, changes have been simplified alot. |
@JsonTypeInfo.requireTypeIdForSubtypes@JsonTypeInfo.requireTypeIdForSubtypes usage
(originated from #2968 regarding per-type configuration of Polymorphic handling)
Description
This PR will be un-drafted after new attribute is added to
@JsonTypeInfoby FasterXML/jackson-annotations#223. And this PR resolves #3877Notes
requireTypeIdForSubtypesto explicitly relate toMapperFeature.REQUIRE_TYPE_ID_FOR_SUBTYPES.