/** * Appends individual diffs to collection. */ void appendDiffs(Collection collection) { if (otherDiffs != null) { collection.addAll(otherDiffs); } collection.add(new NodeDiff(nodeId, diffId) { public void apply(GraphChangeHandler tracker) { applySimplePropertyChanges(tracker); } public void undo(GraphChangeHandler tracker) { throw new UnsupportedOperationException(); } }); }
/** * Implements a Comparable interface method to compare based on diffId * property. */ @Override public int compareTo(NodeDiff o) { return diffId - o.getDiffId(); } }
diff.setDiffId(++currentDiffId);
diff.setDiffId(++currentDiffId);
void unregisterNode(Object nodeId) { Iterator<?> it = diffs.iterator(); while (it.hasNext()) { Object next = it.next(); if (next instanceof NodeDiff) { if (nodeId.equals(((NodeDiff) next).getNodeId())) { it.remove(); } else if (next instanceof ArcCreateOperation) { if (nodeId.equals(((ArcCreateOperation) next).getTargetNodeId())) { it.remove(); } } else if (next instanceof ArcDeleteOperation) { if (nodeId.equals(((ArcDeleteOperation) next).getTargetNodeId())) { it.remove(); } } } } }
/** * Implements a Comparable interface method to compare based on diffId property. */ public int compareTo(Object o) { if (!(o instanceof NodeDiff)) { throw new IllegalArgumentException("Can't compare to " + o); } return diffId - ((NodeDiff) o).getDiffId(); } }
/** * Appends individual diffs to collection. */ void appendDiffs(Collection<NodeDiff> collection) { if (otherDiffs != null) { collection.addAll(otherDiffs); } collection.add(new NodeDiff(nodeId, diffId) { @Override public void apply(GraphChangeHandler tracker) { applySimplePropertyChanges(tracker); } @Override public void undo(GraphChangeHandler tracker) { throw new UnsupportedOperationException(); } }); }
void unregisterNode(Object nodeId) { Iterator it = diffs.iterator(); while (it.hasNext()) { Object next = it.next(); if (next instanceof NodeDiff) { if (nodeId.equals(((NodeDiff) next).getNodeId())) { it.remove(); } else if (next instanceof ArcCreateOperation) { if (nodeId.equals(((ArcCreateOperation) next).getTargetNodeId())) { it.remove(); } } else if (next instanceof ArcDeleteOperation) { if (nodeId.equals(((ArcDeleteOperation) next).getTargetNodeId())) { it.remove(); } } } } }