I have to write a common utility class that does following:

Input: 2 objects of the same class - old and new

Output: 1 object of the same class as Inputs, with only the fields that change - delta

Not sure if there is any existing framework out there. I would prefer to use Scala, but even Java is ok.

有帮助吗?

解决方案

If the objects are beans, then you can use the java.beans API. It lets you query what the fields of the bean are, via Introspector. It would be up to you to iterate over all the fields of objA and objB, comparing values, and setting values on objRes. Also, the class type would have to have a default constructor.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top