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
8 package org.opendaylight.mdsal.binding.api;
10 import java.util.Collection;
11 import org.eclipse.jdt.annotation.NonNull;
12 import org.eclipse.jdt.annotation.Nullable;
13 import org.opendaylight.yangtools.yang.binding.Augmentation;
14 import org.opendaylight.yangtools.yang.binding.ChildOf;
15 import org.opendaylight.yangtools.yang.binding.ChoiceIn;
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;
22 * Modified Data Object. Represents a modification of DataObject, which has a few kinds as indicated by
23 * {@link #getModificationType()}.
25 * @param <T> Type of modified object
27 public interface DataObjectModification<T extends DataObject> extends
28 org.opendaylight.yangtools.concepts.Identifiable<PathArgument> {
31 * Represents type of modification which has occurred.
33 enum ModificationType {
35 * Child node (direct or indirect) was modified.
39 * Node was explicitly created / overwritten.
49 PathArgument getIdentifier();
52 * Returns type of modified object.
54 * @return type of modified object.
56 @NonNull Class<T> getDataType();
59 * Returns type of modification.
61 * @return type Type of performed modification.
63 @NonNull ModificationType getModificationType();
66 * Returns before-state of top level container. Implementations are encouraged, but not required
67 * to provide this state.
69 * @return State of object before modification. Null if subtree was not present, or the
70 * implementation cannot provide the state.
72 @Nullable T getDataBefore();
75 * Returns after-state of top level container.
77 * @return State of object after modification. Null if subtree is not present.
79 @Nullable T getDataAfter();
82 * Returns unmodifiable collection of modified direct children.
84 * @return unmodifiable collection of modified direct children.
86 @NonNull Collection<? extends DataObjectModification<? extends DataObject>> getModifiedChildren();
89 * Returns child list item modification if {@code child} was modified by this modification.
91 * @param childType Type of list item - must be list item with key
92 * @return Modification of {@code child} if {@code child} was modified, null otherwise.
93 * @throws IllegalArgumentException If supplied {@code childType} class is not valid child according
96 <C extends ChildOf<? super T>> Collection<DataObjectModification<C>> getModifiedChildren(
97 @NonNull Class<C> childType);
100 * Returns child list item modification if {@code child} was modified by this modification. This method should be
101 * used if the child is defined in a grouping brought into a case inside this object.
103 * @param caseType Case type class
104 * @param childType Type of list item - must be list item with key
105 * @return Modification of {@code child} if {@code child} was modified, null otherwise.
106 * @throws IllegalArgumentException If supplied {@code childType} class is not valid child according
107 * to generated model.
109 <H extends ChoiceIn<? super T> & DataObject, C extends ChildOf<? super H>> Collection<DataObjectModification<C>>
110 getModifiedChildren(@NonNull Class<H> caseType, @NonNull Class<C> childType);
113 * Returns container child modification if {@code child} was modified by this modification. This method should be
114 * used if the child is defined in a grouping brought into a case inside this object.
117 * For accessing all modified list items consider iterating over {@link #getModifiedChildren()}.
119 * @param caseType Case type class
120 * @param child Type of child - must be only container
121 * @return Modification of {@code child} if {@code child} was modified, null otherwise.
122 * @throws IllegalArgumentException If supplied {@code child} class is not valid child according
123 * to generated model.
125 <H extends ChoiceIn<? super T> & DataObject, C extends ChildOf<? super H>> @Nullable DataObjectModification<C>
126 getModifiedChildContainer(@NonNull Class<H> caseType, @NonNull Class<C> child);
129 * Returns container child modification if {@code child} was modified by this
133 * For accessing all modified list items consider iterating over {@link #getModifiedChildren()}.
135 * @param child Type of child - must be only container
136 * @return Modification of {@code child} if {@code child} was modified, null otherwise.
137 * @throws IllegalArgumentException If supplied {@code child} class is not valid child according
138 * to generated model.
140 <C extends ChildOf<? super T>> @Nullable DataObjectModification<C> getModifiedChildContainer(
141 @NonNull Class<C> child);
144 * Returns augmentation child modification if {@code augmentation} was modified by this modification.
147 * For accessing all modified list items consider iterating over {@link #getModifiedChildren()}.
149 * @param augmentation Type of augmentation - must be only container
150 * @return Modification of {@code augmentation} if {@code augmentation} was modified, null otherwise.
151 * @throws IllegalArgumentException If supplied {@code augmentation} class is not valid augmentation
152 * according to generated model.
154 <C extends Augmentation<T> & DataObject> @Nullable DataObjectModification<C> getModifiedAugmentation(
155 @NonNull Class<C> augmentation);
158 * Returns child list item modification if {@code child} was modified by this modification.
160 * @param listItem Type of list item - must be list item with key
161 * @param listKey List item key
162 * @return Modification of {@code child} if {@code child} was modified, null otherwise.
163 * @throws IllegalArgumentException If supplied {@code listItem} class is not valid child according
164 * to generated model.
166 <N extends Identifiable<K> & ChildOf<? super T>, K extends Identifier<N>> @Nullable DataObjectModification<N>
167 getModifiedChildListItem(@NonNull Class<N> listItem, @NonNull K listKey);
170 * Returns child list item modification if {@code child} was modified by this modification.
172 * @param listItem Type of list item - must be list item with key
173 * @param listKey List item key
174 * @return Modification of {@code child} if {@code child} was modified, null otherwise.
175 * @throws IllegalArgumentException If supplied {@code listItem} class is not valid child according
176 * to generated model.
178 <H extends ChoiceIn<? super T> & DataObject, C extends Identifiable<K> & ChildOf<? super H>,
179 K extends Identifier<C>> @Nullable DataObjectModification<C> getModifiedChildListItem(
180 @NonNull Class<H> caseType, @NonNull Class<C> listItem, @NonNull K listKey);
183 * Returns a child modification if a node identified by {@code childArgument} was modified by this modification.
185 * @param childArgument Path Argument of child node
186 * @return Modification of child identified by {@code childArgument} if {@code childArgument}
187 * was modified, null otherwise.
188 * @throws IllegalArgumentException If supplied path argument is not valid child according to
191 @Nullable DataObjectModification<? extends DataObject> getModifiedChild(PathArgument childArgument);