25b9f693ecd8151e6dc138b3b34c2a20d947612c
[yangtools.git] / yang / yang-data-api / src / main / java / org / opendaylight / yangtools / yang / data / api / schema / tree / DataTreeCandidateNode.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.api.schema.tree;
9
10 import java.util.Collection;
11 import java.util.Optional;
12 import org.eclipse.jdt.annotation.NonNull;
13 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
14 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
15
16 /**
17  * A single node within a {@link DataTreeCandidate}. The nodes are organized in tree hierarchy, reflecting
18  * the modification from which this candidate was created. The node itself exposes the before- and after-image
19  * of the tree restricted to the modified nodes.
20  */
21 public interface DataTreeCandidateNode {
22     /**
23      * Get the node identifier.
24      *
25      * @return The node identifier.
26      */
27     @NonNull PathArgument getIdentifier();
28
29     /**
30      * Get an unmodifiable collection of modified child nodes. Note that the collection may include
31      * {@link ModificationType#UNMODIFIED} nodes, which the caller is expected to handle as if they were not present.
32      *
33      * @return Unmodifiable collection of modified child nodes.
34      */
35     @NonNull Collection<DataTreeCandidateNode> getChildNodes();
36
37     /**
38      * Returns modified child or empty. Note that this method may return an {@link ModificationType#UNMODIFIED} node
39      * when there is evidence of the node or its parent being involved in modification which has turned out not to
40      * modify the node's contents.
41      *
42      * @param childIdentifier Identifier of child node
43      * @return Modified child or empty.
44      * @throws NullPointerException if {@code childIdentifier} is null
45      */
46     @NonNull Optional<DataTreeCandidateNode> getModifiedChild(PathArgument childIdentifier);
47
48     /**
49      * Return the type of modification this node is undergoing.
50      *
51      * @return Node modification type.
52      */
53     @NonNull ModificationType getModificationType();
54
55     /**
56      * Return the after-image of data corresponding to the node.
57      *
58      * @return Node data as they will be present in the tree after
59      *         the modification is applied.
60      */
61     @NonNull Optional<NormalizedNode<?, ?>> getDataAfter();
62
63     /**
64      * Return the before-image of data corresponding to the node.
65      *
66      * @return Node data as they were present in the tree before
67      *         the modification was applied.
68      */
69     @NonNull Optional<NormalizedNode<?, ?>> getDataBefore();
70 }