Skip to content

Not printing all the changes. #195

Open

Description

@manojp1988

In the below class, java-object-diff is just printing. How to iterate all the changes.?

Property at path '/name' has changed from [ Tommy C. Smart ] to [
Tommy Smart ]

public class DiffTest {
    public static void main(String... args) {
        House h1 = new House("TN");
        House h2 = new House("KA");
        House h3 = new House("CLT");
        House h4 = new House("MUM");

        List<House> oldHouses = new ArrayList<House>();
        oldHouses.add(h1);

        List<House> newHouses = new ArrayList<House>();
        newHouses.add(h2);
        newHouses.add(h3);
        newHouses.add(h1);

        List<String> specializations = Arrays.asList("Maths", "Science");
        List<String> specializations1 = Arrays.asList("Science", "Geography");

        Address address = new Address("Bangalore");
        Address address2 = new Address("Charlotte");

        final Person tommyOld = new Person("tommy", "Tommy Smart", address, specializations);
        final Person tommyNew = new Person("tommy", "Tommy C. Smart", address2, specializations1);

        tommyOld.setMinor(true);
        tommyNew.setMinor(false);

        tommyNew.setWife("Amy");

        tommyOld.setHouses(oldHouses);
        tommyNew.setHouses(newHouses);


        final ObjectDiffer objectDiffer = ObjectDifferBuilder.buildDefault();
        final DiffNode root = objectDiffer.compare(tommyOld, tommyNew);
        final DiffNode.Visitor visitor = new PrintingVisitor(tommyOld, tommyNew);
        root.visit(visitor);
    }
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions