简体   繁体   中英

Is there an API to patch a POJO?

I have 2 instances of a class. I would like to patch one instance on to another - in restful web services sense (if a property in source POJO is not null, update its value in destination POJO else leave the property value un-touched in destination POJO). Is there an readily available API (like in Apache commons) that can do this? I would like to avoid:

  1. Traverse the object graph
  2. Do null checks for each and every property

Thanks!!!

You could try java-object-diff: https://github.com/SQiShER/java-object-diff

It looks like a pretty active and full featured library although I have not tried it personally

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM