Skip to content

Add Builder pattern for creating configured ObjectMapper instances #3

Closed
@cowtowncoder

Description

@cowtowncoder

(and make ObjectMapper truly immutable)

One of on-going challenges with Jackson has been mutability of ObjectMapper.
Although it is documented as "config-then-use", users often struggle in figuring out what kinds of changes are allowed. Fundamentally it is also unfortunate that API can not prevent relatively common mistake of trying to re-configure an instance that has already been used.

It would seem like relatively easy way to allow configurability but:

  1. Allow basic use of "just create ObjectMapper instance and go"
  2. Make ObjectMapper truly immutable

and this could be achieved by the addition of a "Builder" class.

As usual, it should be possible to both:

  1. Create builder statically (ObjectMapper.builder()? or .build()?)
  2. Create builder from an existing mapper, starting with its settings (mapper.rebuild()?)

Going forward, perhaps Builder instance should actually be java.io.Serializable?
This might even provide a way to efficiently pass central configuration in distributed systems.
Note, however, that such settings could not pass settings modules change... which actually leads to the big question: how would modules make their changes?

... I will file another RFE for module aspects, then.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions