Change-Id: I0489a1dd41c825f74f9fc1f9c8af38ab8c5d8830
Signed-off-by: Tony Tkacik <ttkacik@cisco.com>
/**
* Modified Data Object.
*
/**
* Modified Data Object.
*
- * Represents modification of Data Object.
+ * Represents modification of Data Object
+ * .
+ * @param <T> Type of modified object
*
*/
public interface DataObjectModification<T extends DataObject> extends org.opendaylight.yangtools.concepts.Identifiable<PathArgument> {
*
*/
public interface DataObjectModification<T extends DataObject> extends org.opendaylight.yangtools.concepts.Identifiable<PathArgument> {
+ /**
+ * Represents type of modification which has occured.
+ *
+ */
enum ModificationType {
/**
*
enum ModificationType {
/**
*
* Returns before-state of top level container. Implementations are encouraged, but not required
* to provide this state.
*
* Returns before-state of top level container. Implementations are encouraged, but not required
* to provide this state.
*
* @return State of object before modification. Null if subtree was not present, or the
* implementation cannot provide the state.
*/
* @return State of object before modification. Null if subtree was not present, or the
* implementation cannot provide the state.
*/
*/
@Nonnull Collection<DataObjectModification<? extends DataObject>> getModifiedChildren();
*/
@Nonnull Collection<DataObjectModification<? extends DataObject>> getModifiedChildren();
+ /**
+ * Returns child list item modification if {@code child} was modified by this modification.
+ *
+ * @param childType Type of list item - must be list item with key
+ * @return Modification of {@code child} if {@code child} was modified, null otherwise.
+ * @throws IllegalArgumentException If supplied {@code childType} class is not valid child according
+ * to generated model.
+ */
+ <C extends ChildOf<? super T>> Collection<DataObjectModification<C>> getModifiedChildren(@Nonnull Class<C> childType);
+
/**
* Returns container child modification if {@code child} was modified by this
* modification.
/**
* Returns container child modification if {@code child} was modified by this
* modification.
*/
package org.opendaylight.mdsal.binding.dom.adapter;
*/
package org.opendaylight.mdsal.binding.dom.adapter;
-import org.opendaylight.mdsal.binding.api.DataObjectModification;
-
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
+import org.opendaylight.mdsal.binding.api.DataObjectModification;
import org.opendaylight.yangtools.binding.data.codec.api.BindingCodecTreeNode;
import org.opendaylight.yangtools.yang.binding.Augmentation;
import org.opendaylight.yangtools.yang.binding.ChildOf;
import org.opendaylight.yangtools.binding.data.codec.api.BindingCodecTreeNode;
import org.opendaylight.yangtools.yang.binding.Augmentation;
import org.opendaylight.yangtools.yang.binding.ChildOf;
return childNodesCache;
}
return childNodesCache;
}
+ @SuppressWarnings("unchecked")
+ @Override
+ public <C extends ChildOf<? super T>> Collection<DataObjectModification<C>> getModifiedChildren(Class<C> childType) {
+ List<DataObjectModification<C>> children = new ArrayList<>();
+ for (DataObjectModification<? extends DataObject> potential : getModifiedChildren()) {
+ if (childType.isAssignableFrom(potential.getDataType())) {
+ children.add((DataObjectModification<C>) potential);
+ }
+ }
+ return children;
+ }
+
@Override
public DataObjectModification<? extends DataObject> getModifiedChild(final PathArgument arg) {
final List<YangInstanceIdentifier.PathArgument> domArgumentList = new ArrayList<>();
@Override
public DataObjectModification<? extends DataObject> getModifiedChild(final PathArgument arg) {
final List<YangInstanceIdentifier.PathArgument> domArgumentList = new ArrayList<>();