BUG 2970 : Create a PruningDataTreeModification
[controller.git] / opendaylight / md-sal / sal-clustering-commons / src / main / java / org / opendaylight / controller / cluster / datastore / node / utils / transformer / NormalizedNodePruner.java
index 861f11305ef4798e766b0f5518ea6e5cc69f19a5..2c5bdf62df84468d728918902f313b66712e245b 100644 (file)
@@ -38,11 +38,13 @@ public class NormalizedNodePruner implements NormalizedNodeStreamWriter {
     private boolean sealed = false;
 
     public NormalizedNodePruner(SchemaContext schemaContext) {
-        validNamespaces = new HashSet<>(schemaContext.getModules().size());
-        for(org.opendaylight.yangtools.yang.model.api.Module module : schemaContext.getModules()){
-            validNamespaces.add(module.getNamespace());
-        }
+        this(NormalizedNodePruner.namespaces(schemaContext));
     }
+
+    public NormalizedNodePruner(Set<URI> validNamespaces) {
+        this.validNamespaces = validNamespaces;
+    }
+
     @Override
     public void leafNode(YangInstanceIdentifier.NodeIdentifier nodeIdentifier, Object o) throws IOException, IllegalArgumentException {
 
@@ -267,5 +269,11 @@ public class NormalizedNodePruner implements NormalizedNodeStreamWriter {
         return stack;
     }
 
-
+    public static Set<URI> namespaces(SchemaContext schemaContext){
+        Set<URI> namespaces = new HashSet<>(schemaContext.getModules().size());
+        for(org.opendaylight.yangtools.yang.model.api.Module module : schemaContext.getModules()){
+            namespaces.add(module.getNamespace());
+        }
+        return namespaces;
+    }
 }