/* * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ package org.opendaylight.mdsal.binding.api; import java.util.Collection; import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jdt.annotation.Nullable; import org.opendaylight.yangtools.yang.binding.Augmentation; import org.opendaylight.yangtools.yang.binding.ChildOf; import org.opendaylight.yangtools.yang.binding.ChoiceIn; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument; import org.opendaylight.yangtools.yang.binding.Key; import org.opendaylight.yangtools.yang.binding.KeyAware; /** * Modified Data Object. Represents a modification of DataObject, which has a few kinds as indicated by * {@link #getModificationType()}. * * @param Type of modified object */ public interface DataObjectModification extends org.opendaylight.yangtools.concepts.Identifiable { /** * Represents type of modification which has occurred. */ enum ModificationType { /** * Child node (direct or indirect) was modified. */ SUBTREE_MODIFIED, /** * Node was explicitly created / overwritten. */ WRITE, /** * Node was deleted. */ DELETE } @Override PathArgument getIdentifier(); /** * Returns type of modified object. * * @return type of modified object. */ @NonNull Class getDataType(); /** * Returns type of modification. * * @return type Type of performed modification. */ @NonNull ModificationType getModificationType(); /** * 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. */ @Nullable T getDataBefore(); /** * Returns after-state of top level container. * * @return State of object after modification. Null if subtree is not present. */ @Nullable T getDataAfter(); /** * Returns unmodifiable collection of modified direct children. * * @return unmodifiable collection of modified direct children. */ @NonNull Collection> 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. */ > Collection> getModifiedChildren( @NonNull Class childType); /** * Returns child list item modification if {@code child} was modified by this modification. This method should be * used if the child is defined in a grouping brought into a case inside this object. * * @param caseType Case type class * @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. */ & DataObject, C extends ChildOf> Collection> getModifiedChildren(@NonNull Class caseType, @NonNull Class childType); /** * Returns container child modification if {@code child} was modified by this modification. This method should be * used if the child is defined in a grouping brought into a case inside this object. * *

* For accessing all modified list items consider iterating over {@link #getModifiedChildren()}. * * @param caseType Case type class * @param child Type of child - must be only container * @return Modification of {@code child} if {@code child} was modified, null otherwise. * @throws IllegalArgumentException If supplied {@code child} class is not valid child according * to generated model. */ & DataObject, C extends ChildOf> @Nullable DataObjectModification getModifiedChildContainer(@NonNull Class caseType, @NonNull Class child); /** * Returns container child modification if {@code child} was modified by this * modification. * *

* For accessing all modified list items consider iterating over {@link #getModifiedChildren()}. * * @param child Type of child - must be only container * @return Modification of {@code child} if {@code child} was modified, null otherwise. * @throws IllegalArgumentException If supplied {@code child} class is not valid child according * to generated model. */ > @Nullable DataObjectModification getModifiedChildContainer( @NonNull Class child); /** * Returns augmentation child modification if {@code augmentation} was modified by this modification. * *

* For accessing all modified list items consider iterating over {@link #getModifiedChildren()}. * * @param augmentation Type of augmentation - must be only container * @return Modification of {@code augmentation} if {@code augmentation} was modified, null otherwise. * @throws IllegalArgumentException If supplied {@code augmentation} class is not valid augmentation * according to generated model. */ & DataObject> @Nullable DataObjectModification getModifiedAugmentation( @NonNull Class augmentation); /** * Returns child list item modification if {@code child} was modified by this modification. * * @param listItem Type of list item - must be list item with key * @param listKey List item key * @return Modification of {@code child} if {@code child} was modified, null otherwise. * @throws IllegalArgumentException If supplied {@code listItem} class is not valid child according * to generated model. */ & ChildOf, K extends Key> @Nullable DataObjectModification getModifiedChildListItem(@NonNull Class listItem, @NonNull K listKey); /** * Returns child list item modification if {@code child} was modified by this modification. * * @param listItem Type of list item - must be list item with key * @param listKey List item key * @return Modification of {@code child} if {@code child} was modified, null otherwise. * @throws IllegalArgumentException If supplied {@code listItem} class is not valid child according * to generated model. */ & DataObject, C extends KeyAware & ChildOf, K extends Key> @Nullable DataObjectModification getModifiedChildListItem( @NonNull Class caseType, @NonNull Class listItem, @NonNull K listKey); /** * Returns a child modification if a node identified by {@code childArgument} was modified by this modification. * * @param childArgument Path Argument of child node * @return Modification of child identified by {@code childArgument} if {@code childArgument} * was modified, null otherwise. * @throws IllegalArgumentException If supplied path argument is not valid child according to * generated model. */ @Nullable DataObjectModification getModifiedChild(PathArgument childArgument); }