@Override public final PathArgument getIdentifier() { return data.getIdentifier(); }
@Override public final PathArgument getIdentifier() { return data.getIdentifier(); }
@Override @Nonnull public final PathArgument getIdentifier() { return data.getIdentifier(); }
static void checkIdentifierReferencesData(final PathArgument arg, final NormalizedNode<?, ?> data) { checkArgument(arg.equals(data.getIdentifier()), "Instance identifier references %s but data identifier is %s", arg, data.getIdentifier()); }
@Override @Nonnull public final PathArgument getIdentifier() { return data.getIdentifier(); }
@Nonnull @Override public PathArgument getIdentifier() { return data.getIdentifier(); }
@Override void enforceOnData(final NormalizedNode<?, ?> data) { for (final YangInstanceIdentifier id : mandatoryNodes) { checkArgument(NormalizedNodes.findNode(data, id).isPresent(), "Node %s is missing mandatory descendant %s", data.getIdentifier(), id); } } }
private void checkChildren(final NormalizedNode<?, ?> value) { final PathArgument id = value.getIdentifier(); final int children = numOfChildrenFromValue(value); checkArgument(minElements <= children, "Node %s does not have enough elements (%s), needs at least %s", id, children, minElements); checkArgument(maxElements >= children, "Node %s has too many elements (%s), can have at most %s", id, children, maxElements); }
private void checkChildren(final NormalizedNode<?, ?> value) { final PathArgument id = value.getIdentifier(); final int children = numOfChildrenFromValue(value); checkArgument(minElements <= children, "Node %s does not have enough elements (%s), needs at least %s", id, children, minElements); checkArgument(maxElements >= children, "Node %s has too many elements (%s), can have at most %s", id, children, maxElements); }
@Override public void visitNode(int level, String parentPath, NormalizedNode<?, ?> normalizedNode) { String nodePath = parentPath + "/"+ PathUtils.toString(normalizedNode.getIdentifier()); if(nodePath.toString().equals(path)){ output = normalizedNode; } }
JaxenDocument(final SchemaContext context, final DataSchemaContextTree tree, final NormalizedNode<?, ?> root) { this.root = requireNonNull(root); this.context = requireNonNull(context); this.schema = requireNonNull(tree.getRoot().getChild(root.getIdentifier())); }
JaxenDocument(final SchemaContext context, final DataSchemaContextTree tree, final NormalizedNode<?, ?> root) { this.root = requireNonNull(root); this.context = requireNonNull(context); this.schema = requireNonNull(tree.getRoot().getChild(root.getIdentifier())); }
@Override public void visitNode(int level, String parentPath, NormalizedNode<?, ?> normalizedNode) { System.out.println(spaces((level) * 4) + normalizedNode.getClass().toString() + ":" + normalizedNode.getIdentifier()); if(normalizedNode instanceof LeafNode || normalizedNode instanceof LeafSetEntryNode){ System.out.println(spaces((level) * 4) + " parentPath = " + parentPath); System.out.println(spaces((level) * 4) + " key = " + normalizedNode.getClass().toString() + ":" + normalizedNode.getIdentifier()); System.out.println(spaces((level) * 4) + " value = " + normalizedNode.getValue()); } } }
private void mergeChildrenIntoModification(final ModifiedNode modification, final Collection<NormalizedNode<?, ?>> children, final Version version) { for (final NormalizedNode<?, ?> c : children) { final ModificationApplyOperation childOp = resolveChildOperation(c.getIdentifier()); final ModifiedNode childNode = modification.modifyChild(c.getIdentifier(), childOp, version); childOp.mergeIntoModifiedNode(childNode, c, version); } }
private void mergeChildrenIntoModification(final ModifiedNode modification, final Collection<NormalizedNode<?, ?>> children, final Version version) { for (final NormalizedNode<?, ?> c : children) { final ModificationApplyOperation childOp = resolveChildOperation(c.getIdentifier()); final ModifiedNode childNode = modification.modifyChild(c.getIdentifier(), childOp, version); childOp.mergeIntoModifiedNode(childNode, c, version); } }
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; }
@Override protected ToStringHelper addToStringAttributes(final ToStringHelper helper) { // Modified children add added by superclass. Here we filter the other children. return super.addToStringAttributes(helper).add("untouched", Collections2.filter(castData().getValue(), input -> getModifiedChild(input.getIdentifier()) == null)); } }
@Override public void mergeToCurrent(final NormalizedNodeContainer<?, ?, ?> data) { for (NormalizedNode<?, ?> child : data.getValue()) { delegate().merge(child.getIdentifier(), child); } }
private static int countNodes(final NormalizedNode<?,?> normalizedNode, final String namespaceFilter) { if (normalizedNode == null) { return 0; } final AtomicInteger count = new AtomicInteger(); new NormalizedNodeNavigator((level, parentPath, normalizedNode1) -> { if (!(normalizedNode1.getIdentifier() instanceof AugmentationIdentifier)) { if (normalizedNode1.getIdentifier().getNodeType().getNamespace().toString().contains(namespaceFilter)) { count.incrementAndGet(); } } }).navigate(YangInstanceIdentifier.EMPTY.toString(), normalizedNode); return count.get(); }
private void validateMinMaxElements(final ModificationPath path, final NormalizedNode<?, ?> value) throws DataValidationFailedException { final PathArgument id = value.getIdentifier(); final int children = numOfChildrenFromValue(value); if (minElements > children) { throw new RequiredElementCountException(path.toInstanceIdentifier(), minElements, maxElements, children, "%s does not have enough elements (%s), needs at least %s", id, children, minElements); } if (maxElements < children) { throw new RequiredElementCountException(path.toInstanceIdentifier(), minElements, maxElements, children, "%s has too many elements (%s), can have at most %s", id, children, maxElements); } }