Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to modify the output of Maps.difference(...,...), Google Guava API

Mahsa NouriJun 1 2012 — edited Jun 1 2012
I am comparing two maps (called map1 and map2) using the Google guava API method below:
System.out.println(Maps.difference(map1, map2));
I get "equal" or "not equal" results back from the method along with the description of differences (in the case of "not equal" of course). I would like to modify the output and print out only the "not equal" elements/values.

I had a look at the API...The method Maps.difference(map1, map2) returns a MapDifference<K,V>. I thought of using the entriesDiffering()method of the MapDifference<K,V> interface but - according to the documentation - that only returns Map<K,MapDifference.ValueDifference<V>> which is a key followed by the values of 2 different maps that correspond to that key.

Please let me know if my explanation is hard to follow and I will try to reword it.
Thanks.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 29 2012
Added on Jun 1 2012
1 comment
429 views