package org.opendaylight.yangtools.yang.data.impl.schema.tree;
import static com.google.common.base.Preconditions.checkArgument;
-
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import com.google.common.base.Verify;
childOp.get().verifyStructure(castedChild, verifyChildren);
} else {
throw new SchemaValidationFailedException(String.format(
- "Child %s is not valid child according to schema.", castedChild.getIdentifier()));
+ "Node %s is not a valid child of %s according to the schema.",
+ castedChild.getIdentifier(), container.getIdentifier()));
}
}
}
}
+ @Override
protected void recursivelyVerifyStructure(NormalizedNode<?, ?> value) {
final NormalizedNodeContainer container = (NormalizedNodeContainer) value;
for (final Object child : container.getValue()) {
childOp.get().recursivelyVerifyStructure(castedChild);
} else {
throw new SchemaValidationFailedException(
- String.format("Child %s is not valid child according to schema.", castedChild.getIdentifier()));
+ String.format("Node %s is not a valid child of %s according to the schema.",
+ castedChild.getIdentifier(), container.getIdentifier()));
}
}
}
final Collection<NormalizedNode<?, ?>> children = ((NormalizedNodeContainer) value).getValue();
for (NormalizedNode<?, ?> c : children) {
final PathArgument id = c.getIdentifier();
- modification.modifyChild(id, resolveChildOperation(id).getChildPolicy(), version);
+ modification.modifyChild(id, resolveChildOperation(id), version);
}
return applyTouch(modification, currentMeta, version);
}
final Collection<NormalizedNode<?, ?>> children, final Version version) {
for (NormalizedNode<?, ?> c : children) {
final ModificationApplyOperation childOp = resolveChildOperation(c.getIdentifier());
- final ModifiedNode childNode = modification.modifyChild(c.getIdentifier(), childOp.getChildPolicy(), version);
+ final ModifiedNode childNode = modification.modifyChild(c.getIdentifier(), childOp, version);
childOp.mergeIntoModifiedNode(childNode, c, version);
}
}
throw new IllegalArgumentException("Unsupported operation " + modification.getOperation());
}
- @SuppressWarnings({"rawtypes", "unchecked"})
- private NormalizedNode<?, ?> createEmptyValue(NormalizedNode<?, ?> value,
- Collection<NormalizedNode<?, ?>> children) {
- NormalizedNodeContainerBuilder builder = createBuilder(value);
- for (NormalizedNode<?, ?> child : children) {
- builder.removeChild(child.getIdentifier());
- }
- return builder.build();
- }
-
@Override
protected TreeNode applyTouch(final ModifiedNode modification, final TreeNode currentMeta, final Version version) {
/*
@Override
protected void checkTouchApplicable(final YangInstanceIdentifier path, final NodeModification modification,
- final Optional<TreeNode> current) throws DataValidationFailedException {
+ final Optional<TreeNode> current, final Version version) throws DataValidationFailedException {
if (!modification.getOriginal().isPresent() && !current.isPresent()) {
throw new ModifiedNodeDoesNotExistException(path, String.format("Node %s does not exist. Cannot apply modification to its children.", path));
}
throw new ConflictingModificationAppliedException(path, "Node was deleted by other transaction.");
}
- checkChildPreconditions(path, modification, current.get());
+ checkChildPreconditions(path, modification, current.get(), version);
}
/**
* @param modification current modification
* @param current Current data tree node.
*/
- private void checkChildPreconditions(final YangInstanceIdentifier path, final NodeModification modification, final TreeNode current) throws DataValidationFailedException {
+ private void checkChildPreconditions(final YangInstanceIdentifier path, final NodeModification modification,
+ final TreeNode current, final Version version) throws DataValidationFailedException {
for (final NodeModification childMod : modification.getChildren()) {
final YangInstanceIdentifier.PathArgument childId = childMod.getIdentifier();
final Optional<TreeNode> childMeta = current.getChild(childId);
final YangInstanceIdentifier childPath = path.node(childId);
- resolveChildOperation(childId).checkApplicable(childPath, childMod, childMeta);
+ resolveChildOperation(childId).checkApplicable(childPath, childMod, childMeta, version);
}
}
@Override
protected void checkMergeApplicable(final YangInstanceIdentifier path, final NodeModification modification,
- final Optional<TreeNode> current) throws DataValidationFailedException {
+ final Optional<TreeNode> current, final Version version) throws DataValidationFailedException {
if (current.isPresent()) {
- checkChildPreconditions(path, modification, current.get());
+ checkChildPreconditions(path, modification, current.get(), version);
}
}