@Override protected Node<?> serializeAnyXml(AnyXmlNode node) { return node.getValue(); } }
@Override public final PathArgument getIdentifier() { return data.getIdentifier(); }
/** * Recursively scan a {@link NormalizedNode} instance and its children and * produce a collection of {@link DuplicateEntry} objects. Each holds the * original definition path and a list of hard/softlinks. * * @param node Root node, may not be null. * @return List of entries */ static Map<NormalizedNode<?, ?>, DuplicateEntry> findDuplicates(final NormalizedNode<?, ?> node) { final DuplicateFinder finder = new DuplicateFinder(); finder.findDuplicates(YangInstanceIdentifier.EMPTY, node); return finder.identities; } }
@Override void enforceOnData(final NormalizedNode<?, ?> data) { for (final YangInstanceIdentifier id : mandatoryNodes) { checkArgument(NormalizedNodes.findNode(data, id).isPresent(), "Node %s is missing mandatory descendant %s", data.getIdentifier(), id); } } }
@Override public void mergeToCurrent(final NormalizedNodeContainer<?, ?, ?> data) { for (NormalizedNode<?, ?> child : data.getValue()) { delegate().merge(child.getIdentifier(), child); } }
static void check(final QName nodeQName, final Optional<MapNode> actualNodes, final MapEntryNode modificationNode) throws DataModificationException { if (!actualNodes.isPresent() || !actualNodes.get().getChild(modificationNode.getIdentifier()).isPresent()) { throw new DataMissingException(nodeQName, 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(); }
private static boolean contains(Optional<LeafSetNode<?>> actual, LeafSetEntryNode<?> leafListModification) { boolean contains = actual.isPresent(); contains &= actual.get().getChild(leafListModification.getIdentifier()).isPresent(); return contains; } }
@Override public final PathArgument getIdentifier() { return data.getIdentifier(); }
@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(); }
/** * Recursively scan a {@link NormalizedNode} instance and its children and * produce a collection of {@link DuplicateEntry} objects. Each holds the * original definition path and a list of hard/softlinks. * * @param node Root node, may not be null. * @return List of entries */ static Map<NormalizedNode<?, ?>, DuplicateEntry> findDuplicates(final NormalizedNode<?, ?> node) { final DuplicateFinder finder = new DuplicateFinder(); finder.findDuplicates(YangInstanceIdentifier.EMPTY, node); return finder.identities; } }
private static DomainIdentifier serializeDomainId(final ContainerNode descriptorsData) { final Optional<DataContainerChild<? extends PathArgument, ?>> domainId = descriptorsData.getChild(DOMAIN_NID); if (domainId.isPresent()) { return new DomainIdentifier((Long) domainId.get().getValue()); } return null; }