2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.controller.md.sal.dom.store.impl.tree.data;
10 import org.opendaylight.controller.md.sal.dom.store.impl.tree.DataPreconditionFailedException;
11 import org.opendaylight.controller.md.sal.dom.store.impl.tree.StoreTreeNode;
12 import org.opendaylight.controller.md.sal.dom.store.impl.tree.spi.TreeNode;
13 import org.opendaylight.controller.md.sal.dom.store.impl.tree.spi.Version;
14 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
15 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument;
17 import com.google.common.base.Optional;
21 * Operation responsible for applying {@link ModifiedNode} on tree.
23 * Operation is composite - operation on top level node consists of
24 * suboperations on child nodes. This allows to walk operation hierarchy and
25 * invoke suboperations independently.
27 * <b>Implementation notes</b>
30 * Implementations MUST expose all nested suboperations which operates on child
31 * nodes expose via {@link #getChild(PathArgument)} method.
32 * <li>Same suboperations SHOULD be used when invoked via
33 * {@link #apply(ModifiedNode, Optional)} if applicable.
36 * Hierarchical composite operation which is responsible for applying
37 * modification on particular subtree and creating updated subtree
41 interface ModificationApplyOperation extends StoreTreeNode<ModificationApplyOperation> {
45 * Implementation of this operation must be stateless and must not change
46 * state of this object.
49 * NodeModification to be applied
51 * Store Metadata Node on which NodeModification should be
53 * @param subtreeVersion New subtree version of parent node
54 * @throws IllegalArgumentException
55 * If it is not possible to apply Operation on provided Metadata
57 * @return new {@link StoreMetadataNode} if operation resulted in updating
58 * node, {@link Optional#absent()} if {@link ModifiedNode}
59 * resulted in deletion of this node.
61 Optional<TreeNode> apply(ModifiedNode modification, Optional<TreeNode> storeMeta, Version subtreeVersion);
65 * Performs structural verification of NodeModification, such as writen values / types
66 * uses right structural elements.
68 * @param modification to be verified.
69 * @throws IllegalArgumentException If provided NodeModification does not adhere to the structure.
71 void verifyStructure(ModifiedNode modification) throws IllegalArgumentException;
74 * Returns a suboperation for specified tree node
76 * @return Reference to suboperation for specified tree node, {@link Optional#absent()}
77 * if suboperation is not supported for specified tree node.
80 Optional<ModificationApplyOperation> getChild(PathArgument child);
84 * Checks if provided node modification could be applied to current metadata node.
86 * @param modification Modification
87 * @param current Metadata Node to which modification should be applied
88 * @return true if modification is applicable
89 * false if modification is no applicable
90 * @throws DataPreconditionFailedException
92 void checkApplicable(InstanceIdentifier path, NodeModification modification, Optional<TreeNode> current) throws DataPreconditionFailedException;