- protected abstract void checkSubtreeModificationApplicable(YangInstanceIdentifier path, final NodeModification modification,
- final Optional<TreeNode> current) throws DataValidationFailedException;
-
- protected abstract void verifyWrittenStructure(NormalizedNode<?, ?> writtenValue);
-
- public static class UnkeyedListModificationStrategy extends SchemaAwareApplyOperation {
-
- private final Optional<ModificationApplyOperation> entryStrategy;
-
- protected UnkeyedListModificationStrategy(final ListSchemaNode schema) {
- entryStrategy = Optional.<ModificationApplyOperation> of(new DataNodeContainerModificationStrategy.UnkeyedListItemModificationStrategy(schema));
- }
-
- @Override
- boolean isOrdered() {
- return true;
- }
-
- @Override
- protected TreeNode applyMerge(final ModifiedNode modification, final TreeNode currentMeta,
- final Version version) {
- return applyWrite(modification, Optional.of(currentMeta), version);
- }
-
- @Override
- protected TreeNode applySubtreeChange(final ModifiedNode modification,
- final TreeNode currentMeta, final Version version) {
- throw new UnsupportedOperationException("UnkeyedList does not support subtree change.");
- }
-
- @Override
- protected TreeNode applyWrite(final ModifiedNode modification,
- final Optional<TreeNode> currentMeta, final Version version) {
- final NormalizedNode<?, ?> newValue = modification.getWrittenValue();
- final TreeNode newValueMeta = TreeNodeFactory.createTreeNode(newValue, version);
-
- if (Iterables.isEmpty(modification.getChildren())) {
- return newValueMeta;
- }
-
- /*
- * This is where things get interesting. The user has performed a write and
- * then she applied some more modifications to it. So we need to make sense
- * of that an apply the operations on top of the written value. We could have
- * done it during the write, but this operation is potentially expensive, so
- * we have left it out of the fast path.
- *
- * As it turns out, once we materialize the written data, we can share the
- * code path with the subtree change. So let's create an unsealed TreeNode
- * and run the common parts on it -- which end with the node being sealed.
- */
- final MutableTreeNode mutable = newValueMeta.mutable();
- mutable.setSubtreeVersion(version);
-
- @SuppressWarnings("rawtypes")
- final NormalizedNodeContainerBuilder dataBuilder = ImmutableUnkeyedListEntryNodeBuilder
- .create((UnkeyedListEntryNode) newValue);
-
- return mutateChildren(mutable, dataBuilder, version, modification.getChildren());
- }
-
- /**
- * Applies write/remove diff operation for each modification child in modification subtree.
- * Operation also sets the Data tree references for each Tree Node (Index Node) in meta (MutableTreeNode) structure.
- *
- * @param meta MutableTreeNode (IndexTreeNode)
- * @param data DataBuilder
- * @param nodeVersion Version of TreeNode
- * @param modifications modification operations to apply
- * @return Sealed immutable copy of TreeNode structure with all Data Node references set.
- */
- @SuppressWarnings({ "rawtypes", "unchecked" })
- private TreeNode mutateChildren(final MutableTreeNode meta, final NormalizedNodeContainerBuilder data,
- final Version nodeVersion, final Iterable<ModifiedNode> modifications) {
-
- for (ModifiedNode mod : modifications) {
- final PathArgument id = mod.getIdentifier();
- final Optional<TreeNode> cm = meta.getChild(id);