Split out yang-data-tree-{api,spi}
[yangtools.git] / data / yang-data-tree-api / src / main / java / org / opendaylight / yangtools / yang / data / tree / api / DataTreeModification.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.yangtools.yang.data.tree.api;
9
10 import org.eclipse.jdt.annotation.NonNull;
11 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
12 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
13
14 /**
15  * Class encapsulation of set of modifications to a base tree. This tree is backed by a read-only snapshot and tracks
16  * modifications on top of that. The modification has the ability to rebase itself to a new snapshot.
17  */
18 public interface DataTreeModification extends DataTreeSnapshot {
19     /**
20      * Delete the node at specified path.
21      *
22      * @param path Node path
23      */
24     void delete(YangInstanceIdentifier path);
25
26     /**
27      * Merge the specified data with the currently-present data at specified path.
28      *
29      * @param path Node path
30      * @param data Data to be merged
31      */
32     void merge(YangInstanceIdentifier path, NormalizedNode data);
33
34     /**
35      * Replace the data at specified path with supplied data.
36      *
37      * @param path Node path
38      * @param data New node data
39      */
40     void write(YangInstanceIdentifier path, NormalizedNode data);
41
42     /**
43      * Finish creation of a modification, making it ready for application to the data tree. Any calls to this object's
44      * methods except {@link #applyToCursor(DataTreeModificationCursor)} will result in undefined behavior, possibly
45      * with an {@link IllegalStateException} being thrown.
46      */
47     void ready();
48
49     /**
50      * Apply the contents of this modification to a cursor. This can be used to replicate this modification onto another
51      * one. The cursor's position must match the root of this modification, otherwise performing this operation will
52      * result in undefined behavior.
53      *
54      * @param cursor cursor to which this modification
55      */
56     void applyToCursor(@NonNull DataTreeModificationCursor cursor);
57 }