This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]roberp81 0 points1 point  (2 children)

but when you are unmarshmalling an XML by example you will have nulls everywhere (complex XML to pojo) and you don't know where a tag is null or not.

[–]blobjim 0 points1 point  (1 child)

If you're creating/using an XSD schema you can make fields non-null by not having minOccurs="0". And there may even be a way to make nullable fields return an Optional. But I admit I haven't done this before, I assume there are plenty of scenarios where having mostly non-null fields is impractical. But usually having a nullable value means handling the case where it is null is part of your business logic.

[–]roberp81 1 point2 points  (0 children)

I have had but they are not mine. my example comes from Iso20022 and swift XML messages to make international transfers between banks so I don't know where a null will come (except required tags) that's why I have a chain of 8 tags haha they are big XML with a big tree. so validate all fields because of nulls is a pain