Report ExactDataObjectStep from DataObjectModification
[mdsal.git] / binding / mdsal-binding-dom-adapter / src / main / java / org / opendaylight / mdsal / binding / dom / adapter / LazyAugmentationModification.java
index 9b1d1e4ecc0624f20c9a19dc65d508f878ac7384..a19c4e60bf4723679959674707c4cc4a240adebf 100644 (file)
@@ -17,6 +17,7 @@ import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.Nullable;
 import org.opendaylight.mdsal.binding.dom.codec.api.BindingAugmentationCodecTreeNode;
 import org.opendaylight.yangtools.yang.binding.Augmentation;
+import org.opendaylight.yangtools.yang.binding.ExactDataObjectStep;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidateNode;
@@ -31,7 +32,7 @@ final class LazyAugmentationModification<A extends Augmentation<?>>
 
     private LazyAugmentationModification(final BindingAugmentationCodecTreeNode<A> codec,
             final DataTreeCandidateNode parent, final ImmutableList<DataTreeCandidateNode> domChildNodes) {
-        super(parent, codec, codec.deserializePathArgument(null));
+        super(parent, codec, (ExactDataObjectStep<A>) codec.deserializePathArgument(null));
         this.domChildNodes = requireNonNull(domChildNodes);
     }
 
@@ -40,7 +41,7 @@ final class LazyAugmentationModification<A extends Augmentation<?>>
             final Collection<DataTreeCandidateNode> children) {
         // Filter out any unmodified children first
         final var domChildren = children.stream()
-            .filter(childMod -> childMod.getModificationType() != UNMODIFIED)
+            .filter(childMod -> childMod.modificationType() != UNMODIFIED)
             .collect(ImmutableList.toImmutableList());
         // Only return a modification if there is something left
         return domChildren.isEmpty() ? null : new LazyAugmentationModification<>(codec, parent, domChildren);
@@ -50,7 +51,10 @@ final class LazyAugmentationModification<A extends Augmentation<?>>
             final BindingAugmentationCodecTreeNode<A> codec, final DataTreeCandidateNode parent) {
         final var builder = ImmutableList.<DataTreeCandidateNode>builder();
         for (var pathArg : codec.childPathArguments()) {
-            parent.getModifiedChild(pathArg).ifPresent(builder::add);
+            final var child = parent.modifiedChild(pathArg);
+            if (child != null) {
+                builder.add(child);
+            }
         }
         final var domChildren = builder.build();
         return domChildren.isEmpty() ? null : new LazyAugmentationModification<>(codec, parent, domChildren);
@@ -63,8 +67,8 @@ final class LazyAugmentationModification<A extends Augmentation<?>>
 
     @Override
     org.opendaylight.yangtools.yang.data.tree.api.ModificationType domModificationType() {
-        final var before = getDataBefore();
-        final var after = getDataAfter();
+        final var before = dataBefore();
+        final var after = dataAfter();
         if (before == null) {
             return after == null ? org.opendaylight.yangtools.yang.data.tree.api.ModificationType.UNMODIFIED
                 :  org.opendaylight.yangtools.yang.data.tree.api.ModificationType.APPEARED;
@@ -83,7 +87,7 @@ final class LazyAugmentationModification<A extends Augmentation<?>>
     DataTreeCandidateNode firstModifiedChild(final PathArgument arg) {
         // Not entirely efficient linear search, but otherwise we'd have to index, which is even slower
         return domChildNodes.stream()
-            .filter(child -> arg.equals(child.getIdentifier()))
+            .filter(child -> arg.equals(child.name()))
             .findFirst()
             .orElse(null);
     }
@@ -91,7 +95,7 @@ final class LazyAugmentationModification<A extends Augmentation<?>>
     @Override
     ToStringHelper addToStringAttributes(final ToStringHelper helper) {
         return super.addToStringAttributes(helper)
-            .add("domType", domData.getModificationType())
+            .add("domType", domData.modificationType())
             .add("domChildren", domChildNodes);
     }
 }