Feature-request: Allow optional values for nested mapping if nested attribute is null
See original GitHub issueI would like to use a nested mapping as follows:
<attribute name="something">
<value name="${some.thing}" />
</attribute>
This normally works but crashes when the nested attribute “some” is null. I would like to be able to mark this kind of nested mapping optional (maybe giving a default value if the nesting contains a null value).
Maybe like this
<attribute name="something">
<value name="${some.thing}" defaultValue="" />
</attribute>
A possible (working) workaround is:
<attribute name="something">
<value name="${some}" />
</attribute>
<conversion name="nullIsEmptySting" to="something">
return ${source} == null ? "null" : ${source}.getThing();
</conversion>
but that is annoying to write for all optional attributes.
Edit: Forgot to mention: Thanks for your work! I really enjoy using JMapper in my project!
Issue Analytics
- State:
- Created 7 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Handling Nulls in nested objects (Java) - Lalit Vatsal - Medium
Let's write our own NullableWrapper with mapper taking a default value at each map stage (We'll consider null otherwise). Let's call our object...
Read more >Terraform optional nested object variable - Stack Overflow
I've read about terraform's 0.12 null default variable values, but I am not sure there is a way to specify default value for...
Read more >Default to null on dynamic blocks - Terraform
There's any way to ignore some attributes with dynamic blocks? I have a variable file mostly looking like this: variable "buckets" { type...
Read more >How to handle deeply-nested nullable fields in JavaScript and ...
Option 1: Enter idx. I have found idx to be a safe method of accessing these nested nullable values. A naive implementation of...
Read more >faq - Dozer
Can I map one field into another field that is nested n layers deep in the ... How can I tell Dozer to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I am going to implement the functions mentioned above, after a some study, i will decide if include this features with this release or not (giving priority to default values). The next comment will be to share the release date.
Your interest is really appreciated, thank you!
Hi, i need a workaround, or elvis operation is now work?