private static boolean contains(Optional<LeafSetNode<?>> actual, LeafSetEntryNode<?> leafListModification) { boolean contains = actual.isPresent(); contains &= actual.get().getChild(leafListModification.getIdentifier()).isPresent(); return contains; } }
static void check(final QName nodeQName, final Optional<LeafSetNode<?>> actualNodes, final LeafSetEntryNode<?> modificationNode) throws DataMissingException { if (!actualNodes.isPresent() || !actualNodes.get().getChild(modificationNode.getIdentifier()).isPresent()) { throw new DataMissingException(nodeQName, modificationNode); } }
static void check(final QName nodeQName, final Optional<LeafSetNode<?>> actualNodes, final LeafSetEntryNode<?> modificationNode) throws DataExistsException { if (actualNodes.isPresent() && actualNodes.get().getChild(modificationNode.getIdentifier()).isPresent()) { throw new DataExistsException(nodeQName, actualNodes.get(), modificationNode); } }
@SuppressWarnings({ "unchecked", "rawtypes" }) public static Optional<NormalizedNode<?, ?>> getDirectChild(final NormalizedNode<?, ?> node, final PathArgument pathArg) { if (node instanceof LeafNode<?> || node instanceof LeafSetEntryNode<?>) { return Optional.empty(); } else 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.empty(); }
@SuppressWarnings({ "unchecked", "rawtypes" }) public static Optional<NormalizedNode<?, ?>> getDirectChild(final NormalizedNode<?, ?> node, final PathArgument pathArg) { if (node instanceof LeafNode<?> || node instanceof LeafSetEntryNode<?>) { return Optional.empty(); } else 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.empty(); }