2 * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
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
9 package org.opendaylight.mdsal.binding.api;
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.ChoiceIn;
17 import org.opendaylight.yangtools.yang.binding.DataObject;
18 import org.opendaylight.yangtools.yang.binding.Identifiable;
19 import org.opendaylight.yangtools.yang.binding.Identifier;
20 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument;
23 * Modified Data Object. Represents a modification of DataObject, which has a few kinds as indicated by
24 * {@link #getModificationType()}.
26 * @param <T> Type of modified object
28 public interface DataObjectModification<T extends DataObject> extends
29 org.opendaylight.yangtools.concepts.Identifiable<PathArgument> {
32 * Represents type of modification which has occurred.
34 enum ModificationType {
36 * Child node (direct or indirect) was modified.
40 * Node was explicitly created / overwritten.
50 PathArgument getIdentifier();
53 * Returns type of modified object.
55 * @return type of modified object.
57 @Nonnull Class<T> getDataType();
60 * Returns type of modification.
62 * @return type Type of performed modification.
64 @Nonnull ModificationType getModificationType();
67 * Returns before-state of top level container. Implementations are encouraged, but not required
68 * to provide this state.
70 * @return State of object before modification. Null if subtree was not present, or the
71 * implementation cannot provide the state.
73 @Nullable T getDataBefore();
76 * Returns after-state of top level container.
78 * @return State of object after modification. Null if subtree is not present.
80 @Nullable T getDataAfter();
83 * Returns unmodifiable collection of modified direct children.
85 * @return unmodifiable collection of modified direct children.
87 @Nonnull Collection<? extends DataObjectModification<? extends DataObject>> getModifiedChildren();
90 * Returns child list item modification if {@code child} was modified by this modification.
92 * @param childType Type of list item - must be list item with key
93 * @return Modification of {@code child} if {@code child} was modified, null otherwise.
94 * @throws IllegalArgumentException If supplied {@code childType} class is not valid child according
97 <C extends ChildOf<? super T>> Collection<DataObjectModification<C>> getModifiedChildren(
98 @Nonnull Class<C> childType);
101 * Returns child list item modification if {@code child} was modified by this modification. This method should be
102 * used if the child is defined in a grouping brought into a case inside this object.
104 * @param caseType Case type class
105 * @param childType Type of list item - must be list item with key
106 * @return Modification of {@code child} if {@code child} was modified, null otherwise.
107 * @throws IllegalArgumentException If supplied {@code childType} class is not valid child according
108 * to generated model.
110 <H extends ChoiceIn<? super T> & DataObject, C extends ChildOf<? super H>> Collection<DataObjectModification<C>>
111 getModifiedChildren(@Nonnull Class<H> caseType, @Nonnull Class<C> childType);
114 * Returns container child modification if {@code child} was modified by this modification. This method should be
115 * used if the child is defined in a grouping brought into a case inside this object.
118 * For accessing all modified list items consider iterating over {@link #getModifiedChildren()}.
120 * @param caseType Case type class
121 * @param child Type of child - must be only container
122 * @return Modification of {@code child} if {@code child} was modified, null otherwise.
123 * @throws IllegalArgumentException If supplied {@code child} class is not valid child according
124 * to generated model.
126 @Nullable <H extends ChoiceIn<? super T> & DataObject, C extends ChildOf<? super H>> DataObjectModification<C>
127 getModifiedChildContainer(@Nonnull Class<H> caseType, @Nonnull Class<C> child);
130 * Returns container child modification if {@code child} was modified by this
134 * For accessing all modified list items consider iterating over {@link #getModifiedChildren()}.
136 * @param child Type of child - must be only container
137 * @return Modification of {@code child} if {@code child} was modified, null otherwise.
138 * @throws IllegalArgumentException If supplied {@code child} class is not valid child according
139 * to generated model.
141 @Nullable <C extends ChildOf<? super T>> DataObjectModification<C> getModifiedChildContainer(
142 @Nonnull Class<C> child);
145 * Returns augmentation child modification if {@code augmentation} was modified by this modification.
148 * For accessing all modified list items consider iterating over {@link #getModifiedChildren()}.
150 * @param augmentation Type of augmentation - must be only container
151 * @return Modification of {@code augmentation} if {@code augmentation} was modified, null otherwise.
152 * @throws IllegalArgumentException If supplied {@code augmentation} class is not valid augmentation
153 * according to generated model.
155 @Nullable <C extends Augmentation<T> & DataObject> DataObjectModification<C> getModifiedAugmentation(
156 @Nonnull Class<C> augmentation);
159 * Returns child list item modification if {@code child} was modified by this modification.
161 * @param listItem Type of list item - must be list item with key
162 * @param listKey List item key
163 * @return Modification of {@code child} if {@code child} was modified, null otherwise.
164 * @throws IllegalArgumentException If supplied {@code listItem} class is not valid child according
165 * to generated model.
167 <N extends Identifiable<K> & ChildOf<? super T>, K extends Identifier<N>> DataObjectModification<N>
168 getModifiedChildListItem(@Nonnull Class<N> listItem, @Nonnull K listKey);
171 * Returns child list item modification if {@code child} was modified by this modification.
173 * @param listItem Type of list item - must be list item with key
174 * @param listKey List item key
175 * @return Modification of {@code child} if {@code child} was modified, null otherwise.
176 * @throws IllegalArgumentException If supplied {@code listItem} class is not valid child according
177 * to generated model.
179 <H extends ChoiceIn<? super T> & DataObject, C extends Identifiable<K> & ChildOf<? super H>,
180 K extends Identifier<C>> DataObjectModification<C> getModifiedChildListItem(@Nonnull Class<H> caseType,
181 @Nonnull Class<C> listItem, @Nonnull K listKey);
184 * Returns a child modification if a node identified by {@code childArgument} was modified by this modification.
186 * @param childArgument Path Argument of child node
187 * @return Modification of child identified by {@code childArgument} if {@code childArgument}
188 * was modified, null otherwise.
189 * @throws IllegalArgumentException If supplied path argument is not valid child according to
192 @Nullable DataObjectModification<? extends DataObject> getModifiedChild(PathArgument childArgument);