Change log to warn in LocalThreePhaseCommitCohort
[controller.git] / opendaylight / md-sal / sal-binding-api / src / main / java / org / opendaylight / controller / md / sal / binding / api / DataObjectModification.java
1 /*
2  * Copyright (c) 2015 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
9 package org.opendaylight.controller.md.sal.binding.api;
10
11 import java.util.Collection;
12 import javax.annotation.Nonnull;
13 import javax.annotation.Nullable;
14 import org.opendaylight.yangtools.yang.binding.Augmentation;
15 import org.opendaylight.yangtools.yang.binding.ChildOf;
16 import org.opendaylight.yangtools.yang.binding.DataObject;
17 import org.opendaylight.yangtools.yang.binding.Identifiable;
18 import org.opendaylight.yangtools.yang.binding.Identifier;
19 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument;
20
21 /**
22  * Represents a modification of DataObject.
23  */
24 public interface DataObjectModification<T extends DataObject>
25         extends org.opendaylight.yangtools.concepts.Identifiable<PathArgument> {
26
27     enum ModificationType {
28         /**
29          * Child node (direct or indirect) was modified.
30          *
31          */
32         SUBTREE_MODIFIED,
33
34         /**
35          * Node was explicitly created / overwritten.
36          *
37          */
38
39         WRITE,
40         /**
41          * Node was deleted.
42          *
43          */
44         DELETE
45     }
46
47     @Override
48     PathArgument getIdentifier();
49
50     /**
51      * Returns type of modified object.
52      *
53      * @return type of modified object.
54      */
55     @Nonnull Class<T> getDataType();
56
57     /**
58      * Returns type of modification.
59      *
60      * @return type Type of performed modification.
61      */
62     @Nonnull ModificationType getModificationType();
63
64     /**
65      * Returns before-state of top level container. Implementations are encouraged,
66      * but not required to provide this state.
67      *
68      * @return State of object before modification. Null if subtree was not present,
69      *         or the implementation cannot provide the state.
70      */
71     @Nullable T getDataBefore();
72
73     /**
74      * Returns after-state of top level container.
75      *
76      * @return State of object after modification. Null if subtree is not present.
77      */
78     @Nullable T getDataAfter();
79
80     /**
81      * Returns unmodifiable collection of modified direct children.
82      *
83      * @return unmodifiable collection of modified direct children.
84      */
85     @Nonnull Collection<DataObjectModification<? extends DataObject>> getModifiedChildren();
86
87     /**
88      * Returns container child modification if {@code child} was modified by this modification.
89      *
90      * <p>
91      * For accessing all modified list items consider iterating over {@link #getModifiedChildren()}.
92      *
93      * @param child Type of child - must be only container
94      * @return Modification of {@code child} if {@code child} was modified, null otherwise.
95      * @throws IllegalArgumentException If supplied {@code child} class is not valid child according
96      *         to generated model.
97      */
98     @Nullable <C extends ChildOf<? super T>> DataObjectModification<C> getModifiedChildContainer(
99             @Nonnull Class<C> child);
100
101     /**
102      * Returns augmentation child modification if {@code augmentation} was modified by this modification.
103      *
104      * <p>
105      * For accessing all modified list items consider iterating over {@link #getModifiedChildren()}.
106      *
107      * @param augmentation Type of augmentation - must be only container
108      * @return Modification of {@code augmentation} if {@code augmentation} was modified, null otherwise.
109      * @throws IllegalArgumentException If supplied {@code augmentation} class is not valid augmentation
110      *         according to generated model.
111      */
112     @Nullable <C extends Augmentation<T> & DataObject> DataObjectModification<C> getModifiedAugmentation(
113             @Nonnull Class<C> augmentation);
114
115
116     /**
117      * Returns child list item modification if {@code child} was modified by this modification.
118      *
119      * @param listItem Type of list item - must be list item with key
120      * @param listKey List item key
121      * @return Modification of {@code child} if {@code child} was modified, null otherwise.
122      * @throws IllegalArgumentException If supplied {@code listItem} class is not valid child according
123      *         to generated model.
124      */
125     <C extends Identifiable<K> & ChildOf<? super T>, K extends Identifier<C>> DataObjectModification<C>
126             getModifiedChildListItem(@Nonnull Class<C> listItem,@Nonnull  K listKey);
127
128     /**
129      * Returns a child modification if a node identified by {@code childArgument} was modified by
130      * this modification.
131      *
132      * @param childArgument Path Argument of child node
133      * @return Modification of child identified by {@code childArgument} if {@code childArgument}
134      *         was modified, null otherwise.
135      * @throws IllegalArgumentException If supplied path argument is not valid child according to
136      *         generated model.
137      *
138      */
139     @Nullable DataObjectModification<? extends DataObject> getModifiedChild(PathArgument childArgument);
140 }