@Override public ListNodeBuilder<T, LeafSetEntryNode<T>> withChild(final LeafSetEntryNode<T> child) { this.value.put(child.getIdentifier(), child); return this; }
@Override public ListNodeBuilder<T, LeafSetEntryNode<T>> withChild(final LeafSetEntryNode<T> child) { this.value.put(child.getIdentifier(), child); return this; }
@Override public ListNodeBuilder<T, LeafSetEntryNode<T>> withChild(final LeafSetEntryNode<T> child) { checkDirty(); this.value.put(child.getIdentifier(), child); return this; }
private static boolean contains(Optional<LeafSetNode<?>> actual, LeafSetEntryNode<?> leafListModification) { boolean contains = actual.isPresent(); contains &= actual.get().getChild(leafListModification.getIdentifier()).isPresent(); return contains; } }
@Override public ListNodeBuilder<T, LeafSetEntryNode<T>> withChild(final LeafSetEntryNode<T> child) { checkDirty(); this.value.put(child.getIdentifier(), child); return this; }
static void check(final QName nodeQName, final Optional<LeafSetNode<?>> actualNodes, final LeafSetEntryNode<?> modificationNode) throws DataExistsException { if (actualNodes.isPresent() && actualNodes.get().getChild(modificationNode.getIdentifier()).isPresent()) { throw new DataExistsException(nodeQName, actualNodes.get(), modificationNode); } }
static void check(final QName nodeQName, final Optional<LeafSetNode<?>> actualNodes, final LeafSetEntryNode<?> modificationNode) throws DataMissingException { if (!actualNodes.isPresent() || !actualNodes.get().getChild(modificationNode.getIdentifier()).isPresent()) { throw new DataMissingException(nodeQName, modificationNode); } }
@Override public ListNodeBuilder<T, LeafSetEntryNode<T>> withChild(final LeafSetEntryNode<T> child) { checkArgument(schema.getQName().equals(child.getNodeType()), "Incompatible node type, should be: %s, is: %s", schema.getQName(), child.getNodeType()); // TODO check value type using TypeProvider ? DataValidationException.checkLegalChild(schema.getQName().equals(child.getNodeType()), child.getIdentifier(), schema, Collections.singleton(schema.getQName())); return super.withChild(child); }
@Override public ListNodeBuilder<T, LeafSetEntryNode<T>> withChild(final LeafSetEntryNode<T> child) { checkArgument(schema.getQName().equals(child.getNodeType()), "Incompatible node type, should be: %s, is: %s", schema.getQName(), child.getNodeType()); // TODO check value type using TypeProvider ? DataValidationException.checkLegalChild(schema.getQName().equals(child.getNodeType()), child.getIdentifier(), schema, Collections.singleton(schema.getQName())); return super.withChild(child); }
@Override public ListNodeBuilder<T, LeafSetEntryNode<T>> withChild(final LeafSetEntryNode<T> child) { checkArgument(schema.getQName().equals(child.getNodeType()), "Incompatible node type, should be: %s, is: %s", schema.getQName(), child.getNodeType()); // TODO check value type using TypeProvider ? DataValidationException.checkLegalChild(schema.getQName().equals(child.getNodeType()), child.getIdentifier(), schema, Collections.singleton(schema.getQName())); return super.withChild(child); }
@Override public ListNodeBuilder<T, LeafSetEntryNode<T>> withChild(final LeafSetEntryNode<T> child) { checkArgument(schema.getQName().equals(child.getNodeType()), "Incompatible node type, should be: %s, is: %s", schema.getQName(), child.getNodeType()); // TODO check value type using TypeProvider ? DataValidationException.checkLegalChild(schema.getQName().equals(child.getNodeType()), child.getIdentifier(), schema, Collections.singleton(schema.getQName())); return super.withChild(child); }
@Nullable @Override public LeafSetEntryNode<?> build(final NormalizedNodeBuilder<YangInstanceIdentifier.NodeWithValue, ?, LeafSetEntryNode<?>> builder) { LeafSetEntryNode<?> node = builder.build(); String operation = (String) node.getAttributeValue(OPERATION_ATTRIBUTE); if (operation == null) { return node; } if (builder instanceof AttributesBuilder<?>) { ((AttributesBuilder<?>) builder).withAttributes(Collections.<QName, String>emptyMap()); } node = builder.build(); ModifyAction action = ModifyAction.fromXmlValue(operation); if (dataTreeChangeTracker.getDeleteOperationTracker() > 0 || dataTreeChangeTracker.getRemoveOperationTracker() > 0) { return node; } else { if (!action.equals(dataTreeChangeTracker.peekAction())) { dataTreeChangeTracker.pushPath(node.getIdentifier()); dataTreeChangeTracker.addDataTreeChange(new DataTreeChangeTracker.DataTreeChange(node, action, new ArrayList<>(dataTreeChangeTracker.getCurrentPath()))); dataTreeChangeTracker.popPath(); return null; } else { return node; } } }
@Nullable @Override public LeafSetEntryNode<?> build(final NormalizedNodeBuilder<YangInstanceIdentifier.NodeWithValue, ?, LeafSetEntryNode<?>> builder) { LeafSetEntryNode<?> node = builder.build(); String operation = (String) node.getAttributeValue(OPERATION_ATTRIBUTE); if (operation == null) { return node; } if (builder instanceof AttributesBuilder<?>) { ((AttributesBuilder<?>) builder).withAttributes(Collections.<QName, String>emptyMap()); } node = builder.build(); ModifyAction action = ModifyAction.fromXmlValue(operation); if (dataTreeChangeTracker.getDeleteOperationTracker() > 0 || dataTreeChangeTracker.getRemoveOperationTracker() > 0) { return node; } else { if (!action.equals(dataTreeChangeTracker.peekAction())) { dataTreeChangeTracker.pushPath(node.getIdentifier()); dataTreeChangeTracker.addDataTreeChange(new DataTreeChangeTracker.DataTreeChange(node, action, new ArrayList<>(dataTreeChangeTracker.getCurrentPath()))); dataTreeChangeTracker.popPath(); return null; } else { return node; } } }
protected boolean wasProcessAsSimpleNode(final NormalizedNode<?, ?> node) throws IOException { if (node instanceof LeafSetEntryNode) { final LeafSetEntryNode<?> nodeAsLeafList = (LeafSetEntryNode<?>)node; final QName name = nodeAsLeafList.getIdentifier().getNodeType(); if (writer instanceof NormalizedNodeStreamAttributeWriter) { ((NormalizedNodeStreamAttributeWriter) writer).leafSetEntryNode(name, nodeAsLeafList.getValue(), nodeAsLeafList.getAttributes()); } else { writer.leafSetEntryNode(name, nodeAsLeafList.getValue()); } return true; } else if (node instanceof LeafNode) { final LeafNode<?> nodeAsLeaf = (LeafNode<?>)node; if (writer instanceof NormalizedNodeStreamAttributeWriter) { ((NormalizedNodeStreamAttributeWriter) writer).leafNode(nodeAsLeaf.getIdentifier(), nodeAsLeaf.getValue(), nodeAsLeaf.getAttributes()); } else { writer.leafNode(nodeAsLeaf.getIdentifier(), nodeAsLeaf.getValue()); } return true; } else if (node instanceof AnyXmlNode) { final AnyXmlNode anyXmlNode = (AnyXmlNode)node; writer.anyxmlNode(anyXmlNode.getIdentifier(), anyXmlNode.getValue()); return true; } return false; }
protected boolean wasProcessAsSimpleNode(final NormalizedNode<?, ?> node) throws IOException { if (node instanceof LeafSetEntryNode) { final LeafSetEntryNode<?> nodeAsLeafList = (LeafSetEntryNode<?>)node; final QName name = nodeAsLeafList.getIdentifier().getNodeType(); if (writer instanceof NormalizedNodeStreamAttributeWriter) { ((NormalizedNodeStreamAttributeWriter) writer).leafSetEntryNode(name, nodeAsLeafList.getValue(), nodeAsLeafList.getAttributes()); } else { writer.leafSetEntryNode(name, nodeAsLeafList.getValue()); } return true; } else if (node instanceof LeafNode) { final LeafNode<?> nodeAsLeaf = (LeafNode<?>)node; if (writer instanceof NormalizedNodeStreamAttributeWriter) { ((NormalizedNodeStreamAttributeWriter) writer).leafNode(nodeAsLeaf.getIdentifier(), nodeAsLeaf.getValue(), nodeAsLeaf.getAttributes()); } else { writer.leafNode(nodeAsLeaf.getIdentifier(), nodeAsLeaf.getValue()); } return true; } else if (node instanceof AnyXmlNode) { final AnyXmlNode anyXmlNode = (AnyXmlNode)node; writer.anyxmlNode(anyXmlNode.getIdentifier(), anyXmlNode.getValue()); return true; } return false; }