Closed djechelon closed 1 month ago
maybe on master but this would be a breaking change if applied on a 2.x branch
Unfortunately can not be done for 2.x: this is binary-incompatible change and would cause wide-spread breakage.
And in 3.0 mappers are immutable, using Builders which have full chaining support.
So not needed for master
.
However: 2.18.0 (actually probably 2.10+) already has support for Builders so you can change your code to something like:
XmlMapper mapper = XmlMapper.builder()
.configure( ... )
...
.build();
Very simple feature request.
The following code does not work with
XmlMapper
as it is written, and fluent chaining is a way to make code more readableThe reason is extremely simple: XmlMapper, as other Mappers (e.g. Yaml) extend ObjectMapper, and while they return
this
, their signature reports the superclassObjectMapper
.Now, if I want to extend the discussion to programming theories, I would suggest that JLS is changed to allow for a particular "this" return type, bla bla bla.
But, let's be realistic and currentl my suggestion is to override all methods in the extended classes that simply invoke the superclass in order to add the extended type to the return type.
E.g.
For all methods..... obviously....
I could create the PR personally if this is of interest