Comparing two objects with Groovy

Is there a simple utility with Groovy that will give me the difference in two different objects? I get a message through the equals method that they are not equal, but where can I find which properties are not matching?

+4
source share
1 answer

I found this to be easy to do because the object's .properties attribute created a map with the property name as the key and value as the value.

Once I had this, I could make the difference between the two cards, and I have the answer I was looking for.

Each of the objects has the extension .properties. This works like Python.dict.

Example

object1.properties - object2.properties

, object1 2, , ( + ), object2. 2 , .

+4

All Articles