Iterator<NormalizedNodeContext> iterateChildren(final DataContainerNode<?> data) { return Iterators.transform(((DataContainerNode<?>) node).getValue().iterator(), this::createChild); }
private Optional<? extends DataContainerChild<?, ?>> modifyContainerNode(final OperationStack operationStack, final N actual, final N modification, final YangInstanceIdentifier.PathArgument childToProcess, final Object schemaChild) throws DataModificationException { Optional<DataContainerChild<?, ?>> storedChildren = actual.getChild(childToProcess); Optional<DataContainerChild<?, ?>> modifiedChildren = modification.getChild(childToProcess); return NodeDispatcher.dispatchChildModification(schemaChild, storedChildren, modifiedChildren, operationStack); }
private void navigateDataContainerNode(int level, final String parentPath, final DataContainerNode<?> dataContainerNode){ visitor.visitNode(level, parentPath ,dataContainerNode); String newParentPath = parentPath + "/" + dataContainerNode.getIdentifier().toString(); final Iterable<DataContainerChild<? extends YangInstanceIdentifier.PathArgument,?>> value = dataContainerNode.getValue(); for(NormalizedNode<?,?> node : value){ if(node instanceof MixinNode && node instanceof NormalizedNodeContainer){ navigateNormalizedNodeContainerMixin(level, newParentPath, (NormalizedNodeContainer<?, ?, ?>) node); } else { navigateNormalizedNode(level, newParentPath, node); } } }
private void processChildNode(final Set<Object> values, final DataContainerNode<?> parent, final PathArgument arg, final List<QNamePredicate> nodePredicates, final Deque<QNameWithPredicate> path, final YangInstanceIdentifier current) { final Optional<DataContainerChild<?, ?>> child = parent.getChild(arg); if (!child.isPresent()) { // FIXME: YANGTOOLS-901. We have SchemaContext nearby, hence we should be able to cache how to get // to the leaf with with specified QName, without having to iterate through Choices/Augmentations. // That perhaps means we should not have QNameWithPredicates, but NodeIdentifierWithPredicates as // the path specification. for (final DataContainerChild<?, ?> mixin : parent.getValue()) { if (mixin instanceof AugmentationNode || mixin instanceof ChoiceNode) { addValues(values, mixin, nodePredicates, path, current); } } } else { addNextValues(values, child.get(), nodePredicates, path, current); } }
@Override public void prepareAttributes(final Map<QName, String> attributes, final NormalizedNodeBuilder<P, ?, N> containerBuilder) { dataTreeChangeTracker.pushPath(containerBuilder.build().getIdentifier()); final String operation = attributes.get(OPERATION_ATTRIBUTE); if (operation != null) { dataTreeChangeTracker.pushAction(ModifyAction.fromXmlValue(operation)); } else { dataTreeChangeTracker.pushAction(dataTreeChangeTracker.peekAction() != null ? dataTreeChangeTracker.peekAction() : dataTreeChangeTracker.getDefaultAction()); } } }
@Override public List<Node<?>> serialize(ListSchemaNode schema, N node) { CompositeNodeBuilder<ImmutableCompositeNode> compNodeBuilder = ImmutableCompositeNode.builder(); compNodeBuilder.setQName(node.getNodeType()); compNodeBuilder.addAll(super.serialize(schema, node)); return Collections.<Node<?>> singletonList(compNodeBuilder.toInstance()); }
private void processChildNode(final Set<Object> values, final DataContainerNode<?> parent, final PathArgument arg, final List<QNamePredicate> nodePredicates, final Deque<QNameWithPredicate> path, final YangInstanceIdentifier current) { final Optional<DataContainerChild<?, ?>> child = parent.getChild(arg); if (!child.isPresent()) { // FIXME: YANGTOOLS-901. We have SchemaContext nearby, hence we should be able to cache how to get // to the leaf with with specified QName, without having to iterate through Choices/Augmentations. // That perhaps means we should not have QNameWithPredicates, but NodeIdentifierWithPredicates as // the path specification. for (final DataContainerChild<?, ?> mixin : parent.getValue()) { if (mixin instanceof AugmentationNode || mixin instanceof ChoiceNode) { addValues(values, mixin, nodePredicates, path, current); } } } else { addNextValues(values, child.get(), nodePredicates, path, current); } }
@Override public void prepareAttributes(final Map<QName, String> attributes, final NormalizedNodeBuilder<P, ?, N> containerBuilder) { dataTreeChangeTracker.pushPath(containerBuilder.build().getIdentifier()); final String operation = attributes.get(OPERATION_ATTRIBUTE); if (operation != null) { dataTreeChangeTracker.pushAction(ModifyAction.fromXmlValue(operation)); } else { dataTreeChangeTracker.pushAction(dataTreeChangeTracker.peekAction() != null ? dataTreeChangeTracker.peekAction() : dataTreeChangeTracker.getDefaultAction()); } } }
Optional<NormalizedNodeContext> findChild(final PathArgument arg) { return node instanceof DataContainerNode ? ((DataContainerNode<?>)node).getChild(arg).map(this::createChild) : Optional.empty(); }
Iterator<NormalizedNodeContext> iterateChildren(final DataContainerNode<?> data) { return Iterators.transform(((DataContainerNode<?>) node).getValue().iterator(), this::createChild); }
private void navigateDataContainerNode(int level, final String parentPath, final DataContainerNode<?> dataContainerNode) { visitor.visitNode(level, parentPath, dataContainerNode); String newParentPath = parentPath + "/" + dataContainerNode.getIdentifier().toString(); final Iterable<DataContainerChild<? extends YangInstanceIdentifier.PathArgument, ?>> value = dataContainerNode .getValue(); for (NormalizedNode<?, ?> node : value) { if (node instanceof MixinNode && node instanceof NormalizedNodeContainer) { navigateNormalizedNodeContainerMixin(level, newParentPath, (NormalizedNodeContainer<?, ?, ?>) node); } else { navigateNormalizedNode(level, newParentPath, node); } } }
Optional<NormalizedNodeContext> findChild(final PathArgument arg) { return node instanceof DataContainerNode ? ((DataContainerNode<?>)node).getChild(arg).map(this::createChild) : Optional.empty(); }
private Set<? extends YangInstanceIdentifier.PathArgument> getChildQNames(final Optional<N> actual) { Set<YangInstanceIdentifier.PathArgument> qNames = Sets.newLinkedHashSet(); for (DataContainerChild<? extends YangInstanceIdentifier.PathArgument, ?> child : actual.get().getValue()) { qNames.add(child.getIdentifier()); } return qNames; }
@Override public Collection<NormalizedNodeUpdate> normalizedUpdates(@Nonnull final YangInstanceIdentifier topLevelIdentifier, @Nonnull final Map.Entry<YangInstanceIdentifier.PathArgument, DataContainerChild<? extends YangInstanceIdentifier.PathArgument, ?>> entry) { // just delegates to lower level checkState(entry.getValue() instanceof DataContainerNode, "Unable to extract children"); final Collection<DataContainerChild<? extends YangInstanceIdentifier.PathArgument, ?>> value = DataContainerNode.class.cast(entry.getValue()).getValue(); return value.stream() .map(DataContainerChild.class::cast) .flatMap(node -> baseRewriteProducer .normalizedUpdates(childYangId(topLevelIdentifier, entry), childMapEntry(node)).stream()) .collect(Collectors.toList()); }
private YangInstanceIdentifier getReadPointFromNode(final YangInstanceIdentifier pathArg, final NormalizedNode nNode) { final YangInstanceIdentifier path = pathArg.node(nNode.getIdentifier()); if (nNode instanceof DataContainerNode) { DataContainerNode node = (DataContainerNode) nNode; if (node.getValue().size() == 1) { return getReadPointFromNode(path, (NormalizedNode) Lists.newArrayList(node.getValue()).get(0)); } } return path; }
private static Optional<? extends NormalizedNode<?, ?>> findSchemasNode(final NormalizedNode<?, ?> result) { if(result == null) { return Optional.absent(); } final Optional<DataContainerChild<?, ?>> dataNode = ((DataContainerNode<?>) result).getChild(toId(NETCONF_DATA_QNAME)); if(dataNode.isPresent() == false) { return Optional.absent(); } final Optional<DataContainerChild<? extends YangInstanceIdentifier.PathArgument, ?>> nStateNode = ((DataContainerNode<?>) dataNode.get()).getChild(toId(NetconfState.QNAME)); if(nStateNode.isPresent() == false) { return Optional.absent(); } return ((DataContainerNode<?>) nStateNode.get()).getChild(toId(Schemas.QNAME)); }
private void processDataContainerChild( final DataContainerNode<?> node, final Integer depth, final DataContainerNodeBuilder<? extends YangInstanceIdentifier.PathArgument, ? extends DataContainerNode<?>> newBuilder) { for (DataContainerChild<? extends PathArgument, ?> nodeValue : node.getValue()) { newBuilder.withChild(pruneDataAtDepth(nodeValue, depth - 1)); } }
private static Optional<String> getSingleChildNodeValue(final DataContainerNode<?> schemaNode, final QName childNode) { final Optional<DataContainerChild<? extends YangInstanceIdentifier.PathArgument, ?>> node = schemaNode.getChild(toId(childNode)); Preconditions.checkArgument(node.isPresent(), "Child node %s not present", childNode); return getValueOfSimpleNode(node.get()); }