Deal with positive matches first, let ValueNode be dealt with using
the default path.
Change-Id: If74b9ee05f0a4b5fb867e4b2db5f53bb06728e38
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
@SuppressWarnings({ "unchecked", "rawtypes" })
public static Optional<NormalizedNode<?, ?>> getDirectChild(final NormalizedNode<?, ?> node,
final PathArgument pathArg) {
@SuppressWarnings({ "unchecked", "rawtypes" })
public static Optional<NormalizedNode<?, ?>> getDirectChild(final NormalizedNode<?, ?> node,
final PathArgument pathArg) {
- if (node instanceof ValueNode) {
- return Optional.empty();
- } else if (node instanceof DataContainerNode) {
+ if (node instanceof DataContainerNode) {
return (Optional) ((DataContainerNode<?>) node).getChild(pathArg);
} else if (node instanceof MapNode && pathArg instanceof NodeIdentifierWithPredicates) {
return (Optional) ((MapNode) node).getChild((NodeIdentifierWithPredicates) pathArg);
} else if (node instanceof LeafSetNode && pathArg instanceof NodeWithValue) {
return (Optional) ((LeafSetNode<?>) node).getChild((NodeWithValue) pathArg);
}
return (Optional) ((DataContainerNode<?>) node).getChild(pathArg);
} else if (node instanceof MapNode && pathArg instanceof NodeIdentifierWithPredicates) {
return (Optional) ((MapNode) node).getChild((NodeIdentifierWithPredicates) pathArg);
} else if (node instanceof LeafSetNode && pathArg instanceof NodeWithValue) {
return (Optional) ((LeafSetNode<?>) node).getChild((NodeWithValue) pathArg);
}
+ // Anything else, including ValueNode
return Optional.empty();
}
return Optional.empty();
}