- @Override
- public void validate(final DataTreeModification modification) throws DataValidationFailedException {
- Preconditions.checkArgument(modification instanceof InMemoryDataTreeModification, "Invalid modification class %s", modification.getClass());
- final InMemoryDataTreeModification m = (InMemoryDataTreeModification)modification;
-
- m.getStrategy().checkApplicable(PUBLIC_ROOT_PATH, m.getRootModification(), Optional.<TreeNode>of(state.getRoot()));
- }
-
- @Override
- public DataTreeCandidate prepare(final DataTreeModification modification) {
- Preconditions.checkArgument(modification instanceof InMemoryDataTreeModification, "Invalid modification class %s", modification.getClass());
-
- final InMemoryDataTreeModification m = (InMemoryDataTreeModification)modification;
- final ModifiedNode root = m.getRootModification();
-
- if (root.getType() == ModificationType.UNMODIFIED) {
- return new NoopDataTreeCandidate(PUBLIC_ROOT_PATH, root);
- }
-
- final TreeNode currentRoot = state.getRoot();
- final Optional<TreeNode> newRoot = m.getStrategy().apply(m.getRootModification(),
- Optional.<TreeNode>of(currentRoot), m.getVersion());
- Preconditions.checkState(newRoot.isPresent(), "Apply strategy failed to produce root node");
- return new InMemoryDataTreeCandidate(PUBLIC_ROOT_PATH, root, currentRoot, newRoot.get());
- }
-