static MapEntryNode entityTypeEntryWithEntityEntry(String entityType, MapEntryNode entityNode) { return ImmutableNodes.mapEntryBuilder(EntityType.QNAME, ENTITY_TYPE_QNAME, entityType).addChild(ImmutableNodes.mapNodeBuilder( ENTITY_QNAME).addChild(entityNode).build()).build(); }
static MapNode candidateEntry(String candidateName) { return ImmutableOrderedMapNodeBuilder.create().withNodeIdentifier(new NodeIdentifier(Candidate.QNAME)). addChild(candidateMapEntry(candidateName)).build(); }
private static MapNode buildInnerList(final int index, final int elements) { CollectionNodeBuilder<MapEntryNode, MapNode> innerList = ImmutableNodes.mapNodeBuilder(InnerList.QNAME); final String itemStr = "Item-" + String.valueOf(index) + "-"; for (int i = 0; i < elements; i++) { innerList.addChild(ImmutableNodes.mapEntryBuilder() .withNodeIdentifier(new NodeIdentifierWithPredicates(InnerList.QNAME, IL_NAME, i)) .withChild(ImmutableNodes.leafNode(IL_NAME, i)) .withChild(ImmutableNodes.leafNode(IL_VALUE, itemStr + String.valueOf(i))) .build()); } return innerList.build(); } }
static private MapNode buildInnerList(int index, int elements ) { CollectionNodeBuilder<MapEntryNode, MapNode> innerList = ImmutableNodes.mapNodeBuilder(InnerList.QNAME); final String itemStr = "Item-" + String.valueOf(index) + "-"; for( int i = 0; i < elements; i++ ) { innerList.addChild(ImmutableNodes.mapEntryBuilder() .withNodeIdentifier(new NodeIdentifierWithPredicates(InnerList.QNAME, IL_NAME, i)) .withChild(ImmutableNodes.leafNode(IL_NAME, i)) .withChild(ImmutableNodes.leafNode(IL_VALUE, itemStr + String.valueOf(i))) .build()); } return innerList.build(); }
static ContainerNode entityOwnersWithEntityTypeEntry(MapEntryNode entityTypeNode) { return ImmutableContainerNodeBuilder.create().withNodeIdentifier( ENTITY_OWNERS_NODE_ID).addChild(ImmutableNodes.mapNodeBuilder(EntityType.QNAME). addChild(entityTypeNode).build()).build(); }
data = ImmutableNodes.mapNodeBuilder(data.getNodeType()).addChild((MapEntryNode) data).build();
private DataContainerChild<?, ?> processUnkeyedListNode(final NormalizedNode<?, ?> node, final Integer depth) { CollectionNodeBuilder<UnkeyedListEntryNode, UnkeyedListNode> newUnkeyedListBuilder = Builders .unkeyedListBuilder(); if (depth > 1) { for (UnkeyedListEntryNode oldUnkeyedListEntry : ((UnkeyedListNode) node).getValue()) { DataContainerNodeAttrBuilder<NodeIdentifier, UnkeyedListEntryNode> newUnkeyedListEntry = Builders .unkeyedListEntryBuilder().withNodeIdentifier(oldUnkeyedListEntry.getIdentifier()); for (DataContainerChild<? extends PathArgument, ?> oldUnkeyedListEntryValue : oldUnkeyedListEntry .getValue()) { newUnkeyedListEntry.withChild(pruneDataAtDepth(oldUnkeyedListEntryValue, depth - 1)); } newUnkeyedListBuilder.addChild(newUnkeyedListEntry.build()); } } return newUnkeyedListBuilder.build(); }
private void writeNormalizedNode(XMLStreamWriter xmlWriter, SchemaPath schemaPath, InstanceIdentifierContext<?> pathContext, NormalizedNode<?, ?> data, Optional<Integer> depth) throws IOException { final RestconfNormalizedNodeWriter nnWriter; final SchemaContext schemaCtx = pathContext.getSchemaContext(); if (SchemaPath.ROOT.equals(schemaPath)) { nnWriter = createNormalizedNodeWriter(xmlWriter, schemaCtx, schemaPath, depth); writeElements(xmlWriter, nnWriter, (ContainerNode) data); } else if (pathContext.getSchemaNode() instanceof RpcDefinition) { nnWriter = createNormalizedNodeWriter(xmlWriter, schemaCtx, ((RpcDefinition) pathContext.getSchemaNode()).getOutput().getPath(), depth); writeElements(xmlWriter, nnWriter, (ContainerNode) data); } else { nnWriter = createNormalizedNodeWriter(xmlWriter, schemaCtx, schemaPath.getParent(), depth); if (data instanceof MapEntryNode) { // Restconf allows returning one list item. We need to wrap it // in map node in order to serialize it properly data = ImmutableNodes.mapNodeBuilder(data.getNodeType()).addChild((MapEntryNode) data).build(); } nnWriter.write(data); } nnWriter.flush(); }