Merge "Updater toaster to use datastore"
[controller.git] / opendaylight / md-sal / sal-dom-broker / src / main / java / org / opendaylight / controller / md / sal / dom / store / impl / ModificationApplyOperation.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.controller.md.sal.dom.store.impl;
9
10 import org.opendaylight.controller.md.sal.dom.store.impl.tree.NodeModification;
11 import org.opendaylight.controller.md.sal.dom.store.impl.tree.StoreMetadataNode;
12 import org.opendaylight.controller.md.sal.dom.store.impl.tree.StoreTreeNode;
13 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument;
14
15 import com.google.common.base.Optional;
16
17 /**
18  *
19  * Operation responsible for applying {@link NodeModification} on tree.
20  *
21  * Operation is composite - operation on top level node consists of
22  * suboperations on child nodes. This allows to walk operation hierarchy and
23  * invoke suboperations independently.
24  *
25  * <b>Implementation notes</b>
26  * <ul>
27  * <li>
28  * Implementations MUST expose all nested suboperations which operates on child
29  * nodes expose via {@link #getChild(PathArgument)} method.
30  * <li>Same suboperations SHOULD be used when invoked via
31  * {@link #apply(NodeModification, Optional)} if applicable.
32  *
33  *
34  * Hierarchical composite operation which is responsible for applying
35  * modification on particular subtree and creating updated subtree
36  *
37  *
38  */
39 public interface ModificationApplyOperation extends StoreTreeNode<ModificationApplyOperation> {
40
41     /**
42      *
43      * Implementation of this operation must be stateless and must not change
44      * state of this object.
45      *
46      * @param modification
47      *            NodeModification to be applied
48      * @param storeMeta
49      *            Store Metadata Node on which NodeModification should be
50      *            applied
51      * @throws IllegalArgumentException
52      *             If it is not possible to apply Operation on provided Metadata
53      *             node
54      * @return new {@link StoreMetadataNode} if operation resulted in updating
55      *         node, {@link Optional#absent()} if {@link NodeModification}
56      *         resulted in deletion of this node.
57      */
58     Optional<StoreMetadataNode> apply(NodeModification modification, Optional<StoreMetadataNode> storeMeta);
59
60     /**
61      * Returns a suboperation for specified tree node
62      *
63      * @return Reference to suboperation for specified tree node, {@link Optional#absent()}
64      *    if suboperation is not supported for specified tree node.
65      */
66     @Override
67     public Optional<ModificationApplyOperation> getChild(PathArgument child);
68
69 }