- Optional<? extends TreeNode> apply(final ModifiedNode modification, final Optional<? extends TreeNode> storeMeta,
- final Version version) {
- Optional<? extends TreeNode> ret = modification.getValidatedNode(this, storeMeta);
- if (ret == null) {
- // Deal with the result moving on us
- ret = delegate.apply(modification, storeMeta, version);
- if (ret.isPresent()) {
- checkChildren(ret.get().getData());
- }
- }
-
- return ret;
- }
-
- @Override
- void checkApplicable(final ModificationPath path, final NodeModification modification,
- final Optional<? extends TreeNode> current, final Version version) throws DataValidationFailedException {
- delegate.checkApplicable(path, modification, current, version);
-
- if (!(modification instanceof ModifiedNode)) {
- LOG.debug("Could not validate {}, does not implement expected class {}", modification, ModifiedNode.class);
- return;
- }
- final ModifiedNode modified = (ModifiedNode) modification;
-
- // We need to actually perform the operation to deal with merge in a sane manner. We know the modification
- // is immutable, so the result of validation will probably not change. Note we should not be checking number
- final Optional<? extends TreeNode> maybeApplied = delegate.apply(modified, current, version);
- if (maybeApplied.isPresent()) {
- // We only enforce min/max on present data and rely on MandatoryLeafEnforcer to take care of the empty case
- validateMinMaxElements(path, maybeApplied.get().getData());
- }
-
- // Everything passed. We now have a snapshot of the result node, it would be too bad if we just threw it out.
- // We know what the result of an apply operation is going to be *if* the following are kept unchanged:
- // - the 'current' node
- // - the schemacontext (therefore, the fact this object is associated with the modification)
- //
- // So let's stash the result. We will pick it up during apply operation.
- modified.setValidatedNode(this, current, maybeApplied);
- }
-
- @Override
- void fullVerifyStructure(final NormalizedNode<?, ?> modification) {
- delegate.fullVerifyStructure(modification);
- checkChildren(modification);
- }
-
- @Override
- public Optional<ModificationApplyOperation> getChild(final PathArgument child) {
- return delegate.getChild(child);
- }
-
- @Override
- ChildTrackingPolicy getChildPolicy() {
- return delegate.getChildPolicy();
- }
-
- @Override
- void mergeIntoModifiedNode(final ModifiedNode node, final NormalizedNode<?, ?> value, final Version version) {
- delegate.mergeIntoModifiedNode(node, value, version);