Improve error message when child schema not found
[yangtools.git] / yang / yang-data-impl / src / main / java / org / opendaylight / yangtools / yang / data / impl / schema / tree / AbstractModifiedNodeBasedCandidateNode.java
index 25fb2df24078880b78bb1ad3f2ec3600899fad72..92586972e9a132aa4f5617874605a5d0de42d330 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ * Copyright (c) 2015, 2016 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,
@@ -13,6 +13,7 @@ import com.google.common.base.Verify;
 import com.google.common.collect.Collections2;
 import java.util.Collection;
 import java.util.Collections;
+import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
@@ -82,8 +83,11 @@ abstract class AbstractModifiedNodeBasedCandidateNode implements DataTreeCandida
     }
 
     @Override
+    @Nonnull
     public Collection<DataTreeCandidateNode> getChildNodes() {
         switch (mod.getModificationType()) {
+        case APPEARED:
+        case DISAPPEARED:
         case SUBTREE_MODIFIED:
             return Collections2.transform(mod.getChildren(), new Function<ModifiedNode, DataTreeCandidateNode>() {
                 @Override
@@ -114,24 +118,27 @@ abstract class AbstractModifiedNodeBasedCandidateNode implements DataTreeCandida
     }
 
     @Override
+    @Nonnull
     public ModificationType getModificationType() {
         return Verify.verifyNotNull(mod.getModificationType(), "Node %s does not have resolved modification type", mod);
     }
 
     private static Optional<NormalizedNode<?, ?>> optionalData(final TreeNode meta) {
         if (meta != null) {
-            return Optional.<NormalizedNode<?,?>>of(meta.getData());
+            return Optional.of(meta.getData());
         } else {
             return Optional.absent();
         }
     }
 
     @Override
+    @Nonnull
     public final Optional<NormalizedNode<?, ?>> getDataAfter() {
         return optionalData(newMeta);
     }
 
     @Override
+    @Nonnull
     public final Optional<NormalizedNode<?, ?>> getDataBefore() {
         return optionalData(oldMeta);
     }
@@ -139,6 +146,8 @@ abstract class AbstractModifiedNodeBasedCandidateNode implements DataTreeCandida
     @Override
     public final DataTreeCandidateNode getModifiedChild(final PathArgument identifier) {
         switch (mod.getModificationType()) {
+        case APPEARED:
+        case DISAPPEARED:
         case SUBTREE_MODIFIED:
             final Optional<ModifiedNode> childMod = mod.getChild(identifier);
             if (childMod.isPresent()) {
@@ -174,8 +183,15 @@ abstract class AbstractModifiedNodeBasedCandidateNode implements DataTreeCandida
         }
 
         @Override
+        @Nonnull
         public PathArgument getIdentifier() {
             return getMod().getIdentifier();
         }
     }
-}
\ No newline at end of file
+
+    @Override
+    public String toString() {
+        return this.getClass().getSimpleName() + "{mod = " + this.mod + ", oldMeta = " + this.oldMeta + ", newMeta = " +
+                this.newMeta + "}";
+    }
+}