@Override NormalizedNode<?, ?> newDefaultNode(DataSchemaNode dataSchema) { // We assume there's only one key for the list. List<QName> keys = ((ListSchemaNode)dataSchema).getKeyDefinition(); Preconditions.checkArgument(keys.size() == 1, "Expected only 1 key for list %s", appConfigBindingClass); QName listKeyQName = keys.iterator().next(); return ImmutableNodes.mapEntryBuilder(bindingQName, listKeyQName, appConfigListKeyValue).build(); }
@Override public NormalizedNode<?, ?> newDefaultNode(final DataSchemaNode dataSchema) { // We assume there's only one key for the list. List<QName> keys = ((ListSchemaNode)dataSchema).getKeyDefinition(); Preconditions.checkArgument(keys.size() == 1, "Expected only 1 key for list %s", appConfigBindingClass); QName listKeyQName = keys.get(0); return ImmutableNodes.mapEntryBuilder(bindingQName, listKeyQName, appConfigListKeyValue).build(); } }
private static NormalizedNode<?,?>[] initOuterListItems(final int outerListItemsCount, final MapNode innerList) { return Arrays.stream(OUTER_LIST_IDS).limit(outerListItemsCount) .map(id -> ImmutableNodes.mapEntryBuilder().withNodeIdentifier(id).withChild(innerList).build()) .collect(Collectors.toList()).toArray(new NormalizedNode[0]); }
private Optional<N> build(final S schema, final List<? extends DataContainerChild<?, ?>> result) { DataContainerNodeBuilder<?, N> b = getBuilder(schema); // TODO skip empty container nodes ? e.g. if container looses all its child nodes // if(result.isEmpty()) { // return Optional.absent(); // } for (DataContainerChild<?, ?> dataContainerChild : result) { b.withChild(dataContainerChild); } return Optional.of(b.build()); }
@Override protected NormalizedNode<?, ?> createEmptyValue(final NormalizedNode<?, ?> original) { checkArgument(original instanceof ChoiceNode); return ImmutableChoiceNodeBuilder.create().withNodeIdentifier(((ChoiceNode) original).getIdentifier()).build(); } }
@Override protected NormalizedNode<?, ?> createEmptyValue(final NormalizedNode<?, ?> original) { checkArgument(original instanceof AugmentationNode); return ImmutableAugmentationNodeBuilder.create() .withNodeIdentifier(((AugmentationNode) original).getIdentifier()).build(); } }
@Override protected NormalizedNode<?, ?> createEmptyValue(final NormalizedNode<?, ?> original) { checkArgument(original instanceof ChoiceNode); return ImmutableChoiceNodeBuilder.create().withNodeIdentifier(((ChoiceNode) original).getIdentifier()).build(); } }
@Override public NormalizedNode<?, ?> createDefault(final PathArgument currentArg) { return Builders.choiceBuilder().withNodeIdentifier(getIdentifier()).build(); } }
/** * Create an immutable choice node. * * @param name QName which will be used as node identifier * @return A choice node */ public static ChoiceNode choiceNode(final QName name) { return ImmutableChoiceNodeBuilder.create().withNodeIdentifier(NodeIdentifier.create(name)).build(); }
/** * Create an immutable choice node. * * @param name QName which will be used as node identifier * @return A choice node */ public static ChoiceNode choiceNode(final QName name) { return ImmutableChoiceNodeBuilder.create().withNodeIdentifier(NodeIdentifier.create(name)).build(); }
private NormalizedNode<?, ?> buildDataContainer(final DataContainerNodeBuilder<?, ?> builder, final NormalizedNodeMessages.Node node){ for(NormalizedNodeMessages.Node child : node.getChildList()){ builder.withChild((DataContainerChild<?, ?>) deSerialize(child)); } //TODO : Also handle attributes return builder.build(); }
private DataContainerChild<?, ?> processChoiceNode(final NormalizedNode<?, ?> node, final Integer depth) { final ChoiceNode choiceNode = (ChoiceNode) node; DataContainerNodeBuilder<NodeIdentifier, ChoiceNode> newChoiceBuilder = Builders.choiceBuilder() .withNodeIdentifier(choiceNode.getIdentifier()); processDataContainerChild((DataContainerNode<?>) node, depth, newChoiceBuilder); return newChoiceBuilder.build(); }
public static List<MapEntryNode> buildOuterList(final int outerElements, final int innerElements) { List<MapEntryNode> outerList = new ArrayList<>(outerElements); for (int j = 0; j < outerElements; j++) { outerList.add(ImmutableNodes.mapEntryBuilder() .withNodeIdentifier(new NodeIdentifierWithPredicates(OuterList.QNAME, OL_ID, j)) .withChild(ImmutableNodes.leafNode(OL_ID, j)) .withChild(buildInnerList(j, innerElements)) .build()); } return outerList; }
private DataContainerChild<?, ?> processAugmentationNode(final NormalizedNode<?, ?> node, final Integer depth) { final AugmentationNode augmentationNode = (AugmentationNode) node; DataContainerNodeBuilder<AugmentationIdentifier, ? extends DataContainerChild<?, ?>> newAugmentationBuilder = Builders .augmentationBuilder().withNodeIdentifier(augmentationNode.getIdentifier()); processDataContainerChild((DataContainerNode<?>) node, depth, newAugmentationBuilder); return newAugmentationBuilder.build(); }
static public List<MapEntryNode> buildOuterList(int outerElements, int innerElements) { List<MapEntryNode> outerList = new ArrayList<MapEntryNode>(outerElements); for (int j = 0; j < outerElements; j++) { outerList.add(ImmutableNodes.mapEntryBuilder() .withNodeIdentifier(new NodeIdentifierWithPredicates(OuterList.QNAME, OL_ID, j)) .withChild(ImmutableNodes.leafNode(OL_ID, j)) .withChild(buildInnerList(j, innerElements)) .build()); } return outerList; }
AugmentationModificationStrategy(final AugmentationSchemaNode schema, final DataNodeContainer resolved, final DataTreeConfiguration treeConfig) { super(EffectiveAugmentationSchema.create(schema, resolved), AugmentationNode.class, treeConfig); emptyNode = Builders.augmentationBuilder() .withNodeIdentifier(DataSchemaContextNode.augmentationIdentifierFrom(schema)) .build(); }
AugmentationModificationStrategy(final AugmentationSchemaNode schema, final DataNodeContainer resolved, final DataTreeConfiguration treeConfig) { super(EffectiveAugmentationSchema.create(schema, resolved), AugmentationNode.class, treeConfig); emptyNode = Builders.augmentationBuilder() .withNodeIdentifier(DataSchemaContextNode.augmentationIdentifierFrom(schema)) .build(); }
public static DataContainerChild<?, ?> getSourceNode(final QName datastore) { return Builders.containerBuilder().withNodeIdentifier(toId(NETCONF_SOURCE_QNAME)) .withChild( Builders.choiceBuilder().withNodeIdentifier(toId(ConfigSource.QNAME)).withChild( Builders.leafBuilder().withNodeIdentifier(toId(datastore)).build()).build() ).build(); }
public static DataContainerChild<?, ?> getTargetNode(final QName datastore) { return Builders.containerBuilder().withNodeIdentifier(toId(NETCONF_TARGET_QNAME)) .withChild( Builders.choiceBuilder().withNodeIdentifier(toId(ConfigTarget.QNAME)).withChild( Builders.leafBuilder().withNodeIdentifier(toId(datastore)).build()).build() ).build(); }
@Test public void testInnerListNodeWithFullPathNotPruned() throws IOException { YangInstanceIdentifier path = YangInstanceIdentifier.builder().node(TestModel.TEST_QNAME) .node(TestModel.OUTER_LIST_QNAME).nodeWithKey(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 1) .node(TestModel.INNER_LIST_QNAME).build(); NormalizedNodePruner pruner = prunerFullSchema(path); MapNode input = mapNodeBuilder(TestModel.INNER_LIST_QNAME).withChild(mapEntryBuilder( TestModel.INNER_LIST_QNAME, TestModel.NAME_QNAME, "one").withChild( ImmutableNodes.containerNode(TestModel.INNER_CONTAINER_QNAME)).build()).build(); NormalizedNodeWriter.forStreamWriter(pruner).write(input); NormalizedNode<?, ?> actual = pruner.normalizedNode(); assertEquals("normalizedNode", input, actual); }