문제

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