+
+ modificationType = localType;
+ return localType;
+ }
+
+ private ModificationType resolveSubtreeModificationType() {
+ switch (codec.getChildAddressabilitySummary()) {
+ case ADDRESSABLE:
+ // All children are addressable, it is safe to report SUBTREE_MODIFIED
+ return ModificationType.SUBTREE_MODIFIED;
+ case UNADDRESSABLE:
+ // All children are non-addressable, report WRITE
+ return ModificationType.WRITE;
+ case MIXED:
+ // This case is not completely trivial, as we may have NOT_ADDRESSABLE nodes underneath us. If that
+ // is the case, we need to turn this modification into a WRITE operation, so that the user is able
+ // to observe those nodes being introduced. This is not efficient, but unfortunately unavoidable,
+ // as we cannot accurately represent such changes.
+ for (DataTreeCandidateNode child : domData.getChildNodes()) {
+ if (BindingStructuralType.recursiveFrom(child) == BindingStructuralType.NOT_ADDRESSABLE) {
+ // We have a non-addressable child, turn this modification into a write
+ return ModificationType.WRITE;
+ }
+ }
+
+ // No unaddressable children found, proceed in addressed mode
+ return ModificationType.SUBTREE_MODIFIED;
+ default:
+ throw new IllegalStateException("Unsupported child addressability summary "
+ + codec.getChildAddressabilitySummary());
+ }