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.controller.md.sal.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.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.
24 * Represents modification of Data Object.
27 public interface DataObjectModification<T extends DataObject> extends org.opendaylight.yangtools.concepts.Identifiable<PathArgument> {
29 enum ModificationType {
32 * Child node (direct or indirect) was modified.
38 * Node was explicitly created / overwritten.
51 PathArgument getIdentifier();
54 * Returns type of modified object.
56 * @return type of modified object.
58 @Nonnull Class<T> getDataType();
62 * Returns type of modification
64 * @return type Type of performed modification.
66 @Nonnull ModificationType getModificationType();
69 * Returns before-state of top level container. Implementations are encouraged,
70 * but not required to provide this state.
72 * @param root Class representing data container
73 * @return State of object before modification. Null if subtree was not present,
74 * or the implementation cannot provide the state.
76 @Nullable T getDataBefore();
79 * Returns after-state of top level container.
81 * @param root Class representing data container
82 * @return State of object after modification. Null if subtree is not present.
84 @Nullable T getDataAfter();
87 * Returns unmodifiable collection of modified direct children.
89 * @return unmodifiable collection of modified direct children.
91 @Nonnull Collection<DataObjectModification<? extends DataObject>> getModifiedChildren();
94 * Returns container child modification if {@code child} was modified by this
97 * For accessing all modified list items consider iterating over {@link #getModifiedChildren()}.
99 * @param child Type of child - must be only container
100 * @return Modification of {@code child} if {@code child} was modified, null otherwise.
101 * @throws IllegalArgumentException If supplied {@code child} class is not valid child according
102 * to generated model.
104 @Nullable <C extends ChildOf<? super T>> DataObjectModification<C> getModifiedChildContainer(@Nonnull Class<C> child);
107 * Returns augmentation child modification if {@code augmentation} was modified by this
110 * For accessing all modified list items consider iterating over {@link #getModifiedChildren()}.
112 * @param augmentation Type of augmentation - must be only container
113 * @return Modification of {@code augmentation} if {@code augmentation} was modified, null otherwise.
114 * @throws IllegalArgumentException If supplied {@code augmentation} class is not valid augmentation
115 * according to generated model.
117 @Nullable <C extends Augmentation<T> & DataObject> DataObjectModification<C> getModifiedAugmentation(@Nonnull Class<C> augmentation);
121 * Returns child list item modification if {@code child} was modified by this modification.
123 * @param listItem Type of list item - must be list item with key
124 * @param listKey List item key
125 * @return Modification of {@code child} if {@code child} was modified, null otherwise.
126 * @throws IllegalArgumentException If supplied {@code listItem} class is not valid child according
127 * to generated model.
129 <C extends Identifiable<K> & ChildOf<? super T>, K extends Identifier<C>> DataObjectModification<C> getModifiedChildListItem(
130 @Nonnull Class<C> listItem,@Nonnull K listKey);
133 * Returns a child modification if a node identified by {@code childArgument} was modified by
136 * @param childArgument Path Argument of child node
137 * @return Modification of child identified by {@code childArgument} if {@code childArgument}
138 * was modified, null otherwise.
139 * @throws IllegalArgumentException If supplied path argument is not valid child according to
143 @Nullable DataObjectModification<? extends DataObject> getModifiedChild(PathArgument childArgument);