Skip to content
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

Make JsonGenerator.writeXxx() methods chainable #785

Closed
cowtowncoder opened this issue Jun 29, 2022 · 1 comment
Closed

Make JsonGenerator.writeXxx() methods chainable #785

cowtowncoder opened this issue Jun 29, 2022 · 1 comment
Labels

Comments

@cowtowncoder
Copy link
Member

Currently Jackson 2.x has void as return type for write methods, like:

public abstract void writeStartArray() throws IOException;

which prevents chaining of write calls. It would be nice to instead have these return JsonGenerator, but change of return type is bytecode-/binary-incompatible change and as such absolutely no-go for 2.x.
But for 3.x this would be doable. It

One possible open question here is that format-specific subtypes' overriding of write methods; should they change return type to proper "this" type? I don't want to make JsonGenerator (... misnomer at this point, but it is what it is) type-parameterized.
I guess this is not a problem for most usage but should probably decide on recommended approach.

@anbusampath
Copy link

which prevents chaining of write calls.

Chainable calls are nice features.

@cowtowncoder cowtowncoder changed the title For Jackson 3.x make JsonGenerator.writeXxx() methods chainable Make JsonGenerator.writeXxx() methods chainable Jul 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants