/** Build map entry node identifier from schema, and provided children */ private NodeIdentifierWithPredicates constructNodeIdentifier() { Collection<QName> keys = schema.getKeyDefinition(); if (keys.isEmpty()) { keys = childrenQNamesToPaths.keySet(); } final Map<QName, Object> keysToValues = new LinkedHashMap<>(); for (QName key : keys) { final DataContainerChild<?, ?> valueForKey = getChild(childrenQNamesToPaths.get(key)); DataValidationException.checkListKey( valueForKey, key, new NodeIdentifierWithPredicates(schema.getQName(), keysToValues)); keysToValues.put(key, valueForKey.getValue()); } return new NodeIdentifierWithPredicates(schema.getQName(), keysToValues); }
@Override public MapEntryNode build() { for (final Entry<QName, Object> key : getNodeIdentifier().getKeyValues().entrySet()) { final DataContainerChild<?, ?> childNode = getChild(childrenQNamesToPaths.get(key.getKey())); // We have enough information to fill-in missing leaf nodes, so let's do that if (childNode == null) { LeafNode<Object> leaf = ImmutableNodes.leafNode(key.getKey(), key.getValue()); LOG.debug("Adding leaf {} implied by key {}", leaf, key); withChild(leaf); } else { DataValidationException.checkListKey( getNodeIdentifier(), key.getKey(), key.getValue(), childNode.getValue()); } } return new ImmutableMapEntryNode(getNodeIdentifier(), buildValue(), getAttributes()); }