public boolean hasChanges() { if (isAdded() || isChanged() || isRemoved()) { return true; } final AtomicBoolean result = new AtomicBoolean(false); visitChildren(new Visitor() { public void node(final DiffNode node, final Visit visit) { if (node.hasChanges()) { result.set(true); visit.stop(); } } }); return result.get(); }
protected final void visit(final Visitor visitor, final Visit visit) { try { visitor.node(this, visit); } catch (final StopVisitationException e) { visit.stop(); } if (visit.isAllowedToGoDeeper() && hasChildren()) { visitChildren(visitor); } if (visit.isStopped()) { throw new StopVisitationException(); } }
public void node(final DiffNode node, final Visit visit) { if (node.getState() == DiffNode.State.ADDED) { node.canonicalSet(head, node.canonicalGet(modified)); } else if (node.getState() == DiffNode.State.REMOVED) { node.canonicalUnset(head); } else if (node.getState() == DiffNode.State.CHANGED) { if (node.hasChildren()) { node.visitChildren(this); visit.dontGoDeeper(); } else { node.canonicalSet(head, node.canonicalGet(modified)); } } } }
public boolean hasChanges() { if (isAdded() || isChanged() || isRemoved()) { return true; } final AtomicBoolean result = new AtomicBoolean(false); visitChildren(new Visitor() { public void node(final DiffNode node, final Visit visit) { if (node.hasChanges()) { result.set(true); visit.stop(); } } }); return result.get(); }
protected final void visit(final Visitor visitor, final Visit visit) { try { visitor.node(this, visit); } catch (final StopVisitationException e) { visit.stop(); } if (visit.isAllowedToGoDeeper() && hasChildren()) { visitChildren(visitor); } if (visit.isStopped()) { throw new StopVisitationException(); } }
public void node(final DiffNode node, final Visit visit) { if (node.getState() == DiffNode.State.ADDED) { node.canonicalSet(head, node.canonicalGet(modified)); } else if (node.getState() == DiffNode.State.REMOVED) { node.canonicalUnset(head); } else if (node.getState() == DiffNode.State.CHANGED) { if (node.hasChildren()) { node.visitChildren(this); visit.dontGoDeeper(); } else { node.canonicalSet(head, node.canonicalGet(modified)); } } } }