This utility library will let you take the difference of any two lists in the form of a series of incremental changes.
For instance:
final List<Change<Character, Item<Character>>> changes;
final List<Item<Character>> source = Item.asList("hello", "world!");
final List<Item<Character>> source = Item.asList("hello", "myself!");
changes = usingConfiguration(configuration).compare(source, target);
might lead to changes being equal to the two following actions:
- Delete item at index
1
- Insert
"myself!"
at index1
which when applied sequentially to the source list will yield the target list:
list = source;
for (Change<Character, Item<Character>> change : changes) {
list = change.apply(list);
}
For more on how to use the framework and what things it can do, refer to the usage documentation.