开发者

How to detect difference between absent/empty data after filling the model?

开发者 https://www.devze.com 2023-03-11 12:47 出处:网络
At the moment we have a model consisting of simple pojos.Now a new requirement makes that we have to fill this model from another messagetype.The data in this message can be there/absent/empty.But how

At the moment we have a model consisting of simple pojos. Now a new requirement makes that we have to fill this model from another messagetype. The data in this message can be there/absent/empty. But how can we make clear on our model that the data was empty not absent or the other way around? I'd think we need some kind of dirty objects handling framework. However we do not necessarily persist these objects! And how do we incorporate this into our services without restricting them to just this me开发者_如何学Gossagetype? Any suggestions on how to solve this problem?


Don't know what type of fields you have in your pojos, but one convention that I've seen (in JAXB I think?) is to have a boolean "was empty" for each field.

Another approach is to use a certain value to indicate empty (e.g. empty string for strings), and null for missing.

0

精彩评论

暂无评论...
验证码 换一张
取 消