NodePath itemPath = NodePath.startBuilding().mapKey("item").build() Īssert diff.getChild(itemPath).getState() = Each node contains information about how the associated object has changed between the two given objects: assert diff.hasChanges() In this case this means they represent the entries of the maps. This represents the root of the object graph and contains other DiffNode instances, which represent the next level in the graph. We created a new ObjectDiffer and invoked its compare method, passing it two objects as arguments. Map base = Collections.singletonMap("item", "bar") ĭiffNode diff = ObjectDifferBuilder.buildDefault().compare(working, base) Map working = Collections.singletonMap("item", "foo") Now let's start with a very easy scenario: Comparing two maps. However, in more complex scenarios it is flexible enough to let you tailor it to your needs. It can handle a wide variety of object structures without the need for any configuration. Java-object-diff provides a very simple API and tries to make everything as self-explanatory as possible.
0 Comments
Leave a Reply. |