Skip to content

GraphComparator could not find the new member of ArrayList #46

Open
@ihsanhaikalz

Description

@ihsanhaikalz

I am having a problem while using your great library as I want to compare two ArrayLists for differences using GraphComparator. I deleted an element of one of the lists and when I compared the old list and new list it shows that there is OBJECT_ORPHAN command. But when I reversed it by comparing the new list and the old list, it should show that there is a new object but somehow it could not detect.

My code is like this:

List<UnifiedBucket> ubs= new ArrayList<>(); // Assume I already put elements in the list 
List<UnifiedBucket> ubsCopy = cloner.deepClone(ubs);
ubsCopy.remove(25);
ubsCopy.get(14).setRawPolicy(null);
List<GraphComparator.Delta> deltas = GraphComparator.compare(ubs, ubsCopy, getIdFetcher()); //This works fine as I could find the OBJECT_ORPHAN

for (GraphComparator.Delta delta : deltas) {
	if (delta.getCmd() != GraphComparator.Delta.Command.LIST_SET_ELEMENT) {
		System.out.println(delta);
	}
}

List<GraphComparator.Delta> deltas2 = GraphComparator.compare(ubsCopy, ubs, getIdFetcher()); //This does not work fine as I could not find the new element that is not deleted in the ubs list

for (GraphComparator.Delta delta : deltas2) {
	if (delta.getCmd() != GraphComparator.Delta.Command.LIST_SET_ELEMENT) {
		System.out.println(delta);
	}
}

Any reason why?

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