root.visit(new PrintingVisitor(working, base));
}
private static void phoneBookExample()
{
final PhoneBook phoneBook = new PhoneBook("Breaking Bad");
final Contact walterWhite = new Contact("Walter", "White");
walterWhite.setPhoneNumber("Home", new PhoneNumber("1", "505", "316-7871"));
walterWhite.setPhoneNumber("Work", new PhoneNumber("1", "505", "456-3788"));
phoneBook.addContact(walterWhite);
final Contact jessePinkman = new Contact("Jesse", "Pinkman");
jessePinkman.setPhoneNumber("Home", new PhoneNumber("1", "505", "234-4628"));
phoneBook.addContact(jessePinkman);
final PhoneBook modifiedPhoneBook = PhoneBook.from(phoneBook);
modifiedPhoneBook.getContact("Jesse", "Pinkman").setMiddleName("Bruce");
modifiedPhoneBook.getContact("Walter", "White").setMiddleName("Hartwell");
final ObjectDiffer objectDiffer = ObjectDifferBuilder.buildDefault();
final DiffNode root = objectDiffer.compare(modifiedPhoneBook, phoneBook);
final DiffNode.Visitor visitor = new PrintingVisitor(modifiedPhoneBook, phoneBook);
root.visit(visitor);