@Override public CollectionNodeBuilder<MapEntryNode, MapNode> withChild(final MapEntryNode child) { this.value.put(child.getIdentifier(), child); return this; }
@Override public CollectionNodeBuilder<MapEntryNode, MapNode> withChild(final MapEntryNode child) { this.value.put(child.getIdentifier(), child); return this; }
@Override public CollectionNodeBuilder<MapEntryNode, OrderedMapNode> withChild(final MapEntryNode child) { checkDirty(); this.value.put(child.getIdentifier(), child); return this; }
private Map<YangInstanceIdentifier.NodeIdentifierWithPredicates, MapEntryNode> mapEntries(MapNode mapNode) { Map<YangInstanceIdentifier.NodeIdentifierWithPredicates, MapEntryNode> mapped = Maps.newLinkedHashMap(); for (MapEntryNode mapEntryNode : mapNode.getValue()) { mapped.put(mapEntryNode.getIdentifier(), mapEntryNode); } return mapped; }
public static void check(final QName qName, final Optional<MapNode> actualNodes, final MapEntryNode listModification) throws DataModificationException { if (actualNodes.isPresent() && actualNodes.get().getChild(listModification.getIdentifier()).isPresent()) { throw new DataExistsException(qName, actualNodes.get(), listModification); } } }
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); } } }
@Override public Collection<NormalizedNodeUpdate> normalizedUpdates(@Nonnull final YangInstanceIdentifier topLevelIdentifier, @Nonnull final Map.Entry<YangInstanceIdentifier.PathArgument, DataContainerChild<? extends YangInstanceIdentifier.PathArgument, ?>> entry) { // identifier has different format : parent_node/list_node/list_node_with_key LOG.debug("Processing {} as list", topLevelIdentifier); return ((MapNode) entry.getValue()).getValue().stream() .map(mapEntryNode -> new NormalizedNodeUpdate(YangInstanceIdentifier.builder(topLevelIdentifier) .node(mapEntryNode.getNodeType()) .node(mapEntryNode.getIdentifier()).build(), mapEntryNode, null)) .collect(Collectors.toList()); } }
@Override protected NormalizedNode<?, ?> createEmptyValue(final NormalizedNode<?, ?> original) { checkArgument(original instanceof MapEntryNode); return ImmutableMapEntryNodeBuilder.create().withNodeIdentifier(((MapEntryNode) original).getIdentifier()) .build(); } }
@Override @SuppressWarnings("rawtypes") public Object getBindingChildValue(final Method method, final NormalizedNodeContainer dom) { if (dom instanceof MapEntryNode && keyGetter.equals(method)) { final NodeIdentifierWithPredicates identifier = ((MapEntryNode) dom).getIdentifier(); return codec.deserialize(identifier).getKey(); } else { return super.getBindingChildValue(method, dom); } }
@Override @SuppressWarnings("rawtypes") Object getBindingChildValue(final String methodName, final NormalizedNodeContainer dom) { if (dom instanceof MapEntryNode && IDENTIFIABLE_KEY_NAME.equals(methodName)) { NodeIdentifierWithPredicates identifier = ((MapEntryNode) dom).getIdentifier(); return codec.deserialize(identifier).getKey(); } return super.getBindingChildValue(methodName, dom); }
@Override public CollectionNodeBuilder<MapEntryNode, MapNode> withChild(final MapEntryNode child) { DataValidationException.checkLegalChild(schema.getQName().equals(child.getNodeType()), child.getIdentifier(), schema, Collections.singleton(schema.getQName())); return super.withChild(child); }
protected boolean writeMapEntryNode(final MapEntryNode node) throws IOException { if(writer instanceof NormalizedNodeStreamAttributeWriter) { ((NormalizedNodeStreamAttributeWriter) writer) .startMapEntryNode(node.getIdentifier(), childSizeHint(node.getValue()), node.getAttributes()); } else { writer.startMapEntryNode(node.getIdentifier(), childSizeHint(node.getValue())); } currentDepth++; writeMapEntryChildren(node); currentDepth--; return true; }
protected boolean writeMapEntryChildren(final MapEntryNode mapEntryNode) throws IOException { if (currentDepth < maxDepth) { writeChildren(mapEntryNode.getValue()); } else if (currentDepth == maxDepth) { writeOnlyKeys(mapEntryNode.getIdentifier().getKeyValues()); } return true; }
@Override public CollectionNodeBuilder<MapEntryNode, OrderedMapNode> withChild(final MapEntryNode child) { DataValidationException.checkLegalChild(schema.getQName().equals(child.getNodeType()), child.getIdentifier(), schema, Collections.singleton(schema.getQName())); return super.withChild(child); }
@Override public CollectionNodeBuilder<MapEntryNode, MapNode> withChild(final MapEntryNode child) { DataValidationException.checkLegalChild(schema.getQName().equals(child.getNodeType()), child.getIdentifier(), schema, Collections.singleton(schema.getQName())); return super.withChild(child); }
protected boolean writeMapEntryNode(final MapEntryNode node) throws IOException { if (writer instanceof NormalizedNodeStreamAttributeWriter) { ((NormalizedNodeStreamAttributeWriter) writer) .startMapEntryNode(node.getIdentifier(), childSizeHint(node.getValue()), node.getAttributes()); } else { writer.startMapEntryNode(node.getIdentifier(), childSizeHint(node.getValue())); } return writeChildren(node.getValue()); }
@Override public CollectionNodeBuilder<MapEntryNode, OrderedMapNode> withChild(final MapEntryNode child) { DataValidationException.checkLegalChild(schema.getQName().equals(child.getNodeType()), child.getIdentifier(), schema, Collections.singleton(schema.getQName())); return super.withChild(child); }
private boolean writeMapEntryNode(final MapEntryNode node, final SchemaNode dataSchemaNode) throws IOException { if(writer instanceof NormalizedNodeStreamAttributeWriter) { ((NormalizedNodeStreamAttributeWriter) writer) .startMapEntryNode(node.getIdentifier(), OrderedNormalizedNodeWriter.childSizeHint(node.getValue()), node.getAttributes()); } else { writer.startMapEntryNode(node.getIdentifier(), OrderedNormalizedNodeWriter.childSizeHint(node.getValue())); } return writeChildren(node.getValue(), dataSchemaNode, true); }
protected boolean writeMapEntryNode(final MapEntryNode node) throws IOException { if (writer instanceof NormalizedNodeStreamAttributeWriter) { ((NormalizedNodeStreamAttributeWriter) writer) .startMapEntryNode(node.getIdentifier(), childSizeHint(node.getValue()), node.getAttributes()); } else { writer.startMapEntryNode(node.getIdentifier(), childSizeHint(node.getValue())); } return writeChildren(node.getValue()); }
@Override protected NormalizedNode<?, ?> createEmptyValue(final NormalizedNode<?, ?> original) { if (original instanceof MapNode) { return ImmutableMapNodeBuilder.create().withNodeIdentifier(((MapNode) original).getIdentifier()).build(); } else if (original instanceof MapEntryNode) { return ImmutableMapEntryNodeBuilder.create().withNodeIdentifier( ((MapEntryNode) original).getIdentifier()).build(); } throw new IllegalArgumentException("MapModification strategy can only handle MapNode or MapEntryNode's, " + "offending node: " + original); }