Merge branch 'master' of ../controller
[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 // FIXME: 5.0.0: Use @NonNullByDefault
22 public interface DataTreeCandidateNode {
23     /**
24      * Get the node identifier.
25      *
26      * @return The node identifier.
27      */
28     @NonNull PathArgument getIdentifier();
29
30     /**
31      * Get an unmodifiable collection of modified child nodes. Note that the collection may include
32      * {@link ModificationType#UNMODIFIED} nodes, which the caller is expected to handle as if they were not present.
33      *
34      * @return Unmodifiable collection of modified child nodes.
35      */
36     @NonNull Collection<DataTreeCandidateNode> getChildNodes();
37
38     /**
39      * Returns modified child or empty. Note that this method may return an {@link ModificationType#UNMODIFIED} node
40      * when there is evidence of the node or its parent being involved in modification which has turned out not to
41      * modify the node's contents.
42      *
43      * @param childIdentifier Identifier of child node
44      * @return Modified child or empty.
45      * @throws NullPointerException if {@code childIdentifier} is null
46      */
47     @NonNull Optional<DataTreeCandidateNode> getModifiedChild(PathArgument childIdentifier);
48
49     /**
50      * Return the type of modification this node is undergoing.
51      *
52      * @return Node modification type.
53      */
54     @NonNull ModificationType getModificationType();
55
56     /**
57      * Return the after-image of data corresponding to the node.
58      *
59      * @return Node data as they will be present in the tree after
60      *         the modification is applied.
61      */
62     @NonNull Optional<NormalizedNode<?, ?>> getDataAfter();
63
64     /**
65      * Return the before-image of data corresponding to the node.
66      *
67      * @return Node data as they were present in the tree before
68      *         the modification was applied.
69      */
70     @NonNull Optional<NormalizedNode<?, ?>> getDataBefore();
71 }