|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.claritysys.util.MapComparator
public final class MapComparator
Compare two maps, returning a third map describing the state of all elements.
Used to determine the exact differences between two sets of items. For example, map a contains an older list of String employee names, and map b contains the newer list. The result of compare (a, b) will be a map of MapComparator.Entry items with the union (a + b), where each item is marked as ADDED, CHANGED, UNCHANGED, or REMOVED with respect to a.
The prune(Map) method will remove unchanged items, so only differences are left.
This could be used to generate a visual diff of source files, for example, if each item was keyed by line number.
Nested Class Summary | |
---|---|
static class |
MapComparator.Entry
Adds a 'change flag' to the key-value relationship of Map.Entry. |
Constructor Summary | |
---|---|
MapComparator()
|
Method Summary | |
---|---|
static java.util.Map |
compare(java.util.Map mapA,
java.util.Map mapB)
Return a Map of MapComparator.Entry objects based on a comparison of the elements in the two given maps. |
static void |
dump(java.util.Map map)
Dump the given map of Map.Entry objects to System.out. |
static void |
prune(java.util.Map map)
Remove any MapComparator.Entry.UNCHANGED entries from the given map. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public MapComparator()
Method Detail |
---|
public static void prune(java.util.Map map)
The passed Map is modified directly, no copy is made.
map
- The map to prune.public static java.util.Map compare(java.util.Map mapA, java.util.Map mapB)
mapA
- The 'original' map of elements to compare.mapB
- The 'newer' map to compare mapA to.
public static void dump(java.util.Map map)
map
- The map to dump.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |