- return Collections2.transform(mod.getChildren(), new Function<ModifiedNode, DataTreeCandidateNode>() {
- @Override
- public DataTreeCandidateNode apply(final ModifiedNode input) {
- return childNode(input);
+ switch (mod.getModificationType()) {
+ case APPEARED:
+ case DISAPPEARED:
+ case SUBTREE_MODIFIED:
+ return Collections2.transform(mod.getChildren(), new Function<ModifiedNode, DataTreeCandidateNode>() {
+ @Override
+ public DataTreeCandidateNode apply(final ModifiedNode input) {
+ return childNode(input);
+ }
+ });
+ case UNMODIFIED:
+ // Unmodified node, but we still need to resolve potential children. canHaveChildren returns
+ // false if both arguments are null.
+ if (canHaveChildren(oldMeta, newMeta)) {
+ return Collections2.transform(getContainer(newMeta != null ? newMeta : oldMeta).getValue(), TO_UNMODIFIED_NODE);
+ } else {
+ return Collections.emptyList();
+ }
+ case DELETE:
+ case WRITE:
+ // This is unusual, the user is requesting we follow into an otherwise-terminal node.
+ // We need to fudge things based on before/after data to correctly fake the expectations.
+ if (canHaveChildren(oldMeta, newMeta)) {
+ return AbstractDataTreeCandidateNode.deltaChildren(getContainer(oldMeta), getContainer(newMeta));
+ } else {
+ return Collections.emptyList();