Collection<Label> removedLabels = CollectionUtils.subtract(existingLabels, newLabels);
Collection<Label> assignedLabels = CollectionUtils.subtract(newLabels, existingLabels);
for (Label removedLabel : removedLabels) {
LabelEntry entry = new LabelEntryImpl(removedLabel, node);
assignedNodeLabels.remove(entry);
removedNodeLabels.add(entry);
}
for (Label assignedLabel : assignedLabels) {
LabelEntry entry = new LabelEntryImpl(assignedLabel, node);
removedNodeLabels.remove(entry);
assignedNodeLabels.add(entry);
}
}