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 -
* <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>
* </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
/**
* 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