Skip to content

Add optional property for @JacksonInject to allow optionally injected values #291

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

Merged

Conversation

giulong
Copy link
Contributor

@giulong giulong commented May 1, 2025

As requested in jackson-databind#3072, introducing the optional flag to @JacksonInject to avoid throwing an exception if an injected property is not found in the injectable values provided to the object reader:

@JacksonInject(optional = OptBoolean.TRUE)
public int optionalField;

@cowtowncoder
Copy link
Member

Looks pretty good -- couple of small things but that's fine.

Before merging this, one process thing: if I haven't asked for and gotten CLA, it is needed before merge:

https://github.com/FasterXML/jackson/blob/master/contributor-agreement.pdf

and the usual way is to print it, fill & sign, scan/photo, email to cla at fasterxml dot com.

This only needs to be done once and CLA is good for all future contributions.
(and some developers work for companies that have filed Corporate CLA (CCLA) as well -- if you do, just let me know).

Looking forward getting this & related PR merged!

@cowtowncoder cowtowncoder changed the title Part of databind#3072: Make @JacksonInject not fail when there's no corresponding value Add optional property for @JacksonInject to allow optionally injected values May 2, 2025
@cowtowncoder
Copy link
Member

CLA received.

*
* @since 2.20
*/
public OptBoolean optional() default OptBoolean.FALSE;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I'll change default to OptBoolean.DEFAULT.

@cowtowncoder cowtowncoder merged commit 052ef9b into FasterXML:2.x May 2, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants