Skip to content

BeanDeserializerBuilder Protected Factory Method for Extension #2487

@vjkoskela

Description

@vjkoskela

In #1870 we were able to switch from creating custom builder deserializers using encapsulation to using inheritance. This greatly simplified our code and allowed it to move from com.fasterxml into our package (since we no longer required access to package private methods). (Thank you!)

The next step in allowing builder deserializers to be customized would be to simplify their creation in BeanDeserializerBuilder.java#L442.

Our custom builder deserializer has a corresponding builder deserializer builder, but currently we need to override the entire buildBuilderBased method in our class when all we want to change is the type of builder deserializer created. Since our builder deserializer is a subclass of BeanDeserializerBuilder it has a constructor which accepts at least the same arguments as BeanDeserializerBuilder.

For our use case at least, delegating the construction of BeanDeserializerBuilder to a separate protected ("factory") method would decouple the logic in buildBuilderBased from the type of builder deserializer created.

Further generalizations would be possible by registering the type of builder to be created although I am unclear on the ROI of such a change and how it fits architecturally with the project.

Let me know what you think! I can definitely submit a patch for the simple refactoring of BeanDeserializerBuilder, but I'm curious if you have some insight into how to make this more flexible.

Jackson Version: 2.10.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions