Use case arrows in mergeIntoModifiedNode()
[yangtools.git] / data / yang-data-tree-ri / src / main / java / org / opendaylight / yangtools / yang / data / tree / impl / ModificationApplyOperation.java
index 79a4b8a814eab3ec2eb990cd6968e94fc3a4c8d9..e35666a1de1212f6e64e6d2f11ea1805d9725e2a 100644 (file)
@@ -9,13 +9,13 @@ package org.opendaylight.yangtools.yang.data.tree.impl;
 
 import com.google.common.base.MoreObjects;
 import com.google.common.base.MoreObjects.ToStringHelper;
-import java.util.Optional;
+import org.eclipse.jdt.annotation.Nullable;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.StoreTreeNode;
-import org.opendaylight.yangtools.yang.data.spi.tree.TreeNode;
-import org.opendaylight.yangtools.yang.data.spi.tree.Version;
 import org.opendaylight.yangtools.yang.data.tree.api.DataValidationFailedException;
+import org.opendaylight.yangtools.yang.data.tree.impl.node.TreeNode;
+import org.opendaylight.yangtools.yang.data.tree.impl.node.Version;
 
 /**
  * An operation responsible for applying {@link ModifiedNode} on tree. The operation is a hierachical composite -
@@ -26,8 +26,8 @@ import org.opendaylight.yangtools.yang.data.tree.api.DataValidationFailedExcepti
  * <b>Implementation notes</b>
  * <ul>
  *   <li>Implementations MUST expose all nested suboperations which operates on child nodes expose via
- *       {@link #findChildByArg(PathArgument)} method.</li>
- *   <li>Same suboperations SHOULD be used when invoked via {@link #apply(ModifiedNode, Optional, Version)},
+ *       {@link #childByArg(PathArgument)} method.</li>
+ *   <li>Same suboperations SHOULD be used when invoked via {@link #apply(ModifiedNode, TreeNode, Version)},
  *       if applicable.</li>
  *   <li>There are exactly two base implementations:
  *     <ul>
@@ -42,37 +42,31 @@ import org.opendaylight.yangtools.yang.data.tree.api.DataValidationFailedExcepti
  *   </li>
  * </ul>
  */
-abstract class ModificationApplyOperation implements StoreTreeNode<ModificationApplyOperation> {
+abstract sealed class ModificationApplyOperation implements StoreTreeNode<ModificationApplyOperation>
+        permits AbstractValidation, SchemaAwareApplyOperation {
     /**
      * Implementation of this operation must be stateless and must not change state of this object.
      *
-     * @param modification
-     *            NodeModification to be applied
-     * @param storeMeta
-     *            Store Metadata Node on which NodeModification should be
-     *            applied
+     * @param modification NodeModification to be applied
+     * @param currentMeta Store Metadata Node on which NodeModification should be applied
      * @param version New subtree version of parent node
-     * @return new {@link TreeNode} if operation resulted in updating
-     *         node, {@link Optional#absent()} if {@link ModifiedNode}
+     * @return new {@link TreeNode} if operation resulted in updating node, {@code null} if {@link ModifiedNode}
      *         resulted in deletion of this node.
-     * @throws IllegalArgumentException
-     *             If it is not possible to apply Operation on provided Metadata
-     *             node
+     * @throws IllegalArgumentException If it is not possible to apply Operation on provided Metadata node
      */
-    abstract Optional<? extends TreeNode> apply(ModifiedNode modification, Optional<? extends TreeNode> storeMeta,
-            Version version);
+    abstract @Nullable TreeNode apply(ModifiedNode modification, @Nullable TreeNode currentMeta, Version version);
 
     /**
      * Checks if provided node modification could be applied to current metadata node.
      *
      * @param path Path to modification
      * @param modification Modification
-     * @param current Metadata Node to which modification should be applied
+     * @param currentMeta Metadata Node to which modification should be applied
      * @param version Metadata version
      * @throws DataValidationFailedException if the modification is not applicable
      */
     abstract void checkApplicable(ModificationPath path, NodeModification modification,
-            Optional<? extends TreeNode> current, Version version) throws DataValidationFailedException;
+        @Nullable TreeNode currentMeta, Version version) throws DataValidationFailedException;
 
     /**
      * Performs a quick structural verification of NodeModification, such as written values / types uses right
@@ -104,7 +98,7 @@ abstract class ModificationApplyOperation implements StoreTreeNode<ModificationA
 
     /**
      * Stage a merge operation into a {@link ModifiedNode} such that it will be processed correctly by
-     * {@link #apply(ModifiedNode, Optional, Version)}. This method is the context which is introducing this operation,
+     * {@link #apply(ModifiedNode, TreeNode, Version)}. This method is the context which is introducing this operation,
      * and so any overheads are charged to whoever is in control of the access pattern.
      *
      * @param modification Original modification node