Remove dependency on controller config-util
[netconf.git] / netconf / netconf-util / src / main / java / org / opendaylight / netconf / util / messages / SubtreeFilter.java
index 96e19b9378b73d4693157f3b71e3e52378953af2..3b803b6a43e16bdee112fe129cf610e30be9a37e 100644 (file)
@@ -10,10 +10,10 @@ package org.opendaylight.netconf.util.messages;
 
 import com.google.common.base.Optional;
 import java.util.Map;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
-import org.opendaylight.controller.config.util.xml.XmlElement;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
+import org.opendaylight.netconf.api.DocumentedException;
+import org.opendaylight.netconf.api.xml.XmlElement;
 import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
+import org.opendaylight.netconf.api.xml.XmlUtil;
 import org.opendaylight.netconf.util.mapping.AbstractNetconfOperation.OperationNameAndNamespace;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -25,9 +25,13 @@ import org.w3c.dom.Node;
 /**
  * See <a href="http://tools.ietf.org/html/rfc6241#section-6">rfc6241</a> for details.
  */
-public class SubtreeFilter {
+public final class SubtreeFilter {
     private static final Logger LOG = LoggerFactory.getLogger(SubtreeFilter.class);
 
+    private SubtreeFilter() {
+
+    }
+
     public static Document applyRpcSubtreeFilter(Document requestDocument,
                                                  Document rpcReply) throws DocumentedException {
         OperationNameAndNamespace operationNameAndNamespace = new OperationNameAndNamespace(requestDocument);
@@ -135,10 +139,10 @@ public class SubtreeFilter {
         MatchingResult matches = matches(src, filter);
         if (matches != MatchingResult.NO_MATCH && matches != MatchingResult.CONTENT_MISMATCH) {
             // copy srcChild to dst
-            boolean filterHasChildren = filter.getChildElements().isEmpty() == false;
+            boolean filterHasChildren = !filter.getChildElements().isEmpty();
             // copy to depth if this is leaf of filter tree
-            Element copied = (Element) document.importNode(src.getDomElement(), filterHasChildren == false);
-            boolean shouldAppend = filterHasChildren == false;
+            Element copied = (Element) document.importNode(src.getDomElement(), !filterHasChildren);
+            boolean shouldAppend = !filterHasChildren;
             if (filterHasChildren) { // this implies TAG_MATCH
                 // do the same recursively
                 int numberOfTextMatchingChildren = 0;
@@ -191,7 +195,7 @@ public class SubtreeFilter {
             if (result == null) {
                 for (Attr attr : filter.getAttributes().values()) {
                     // ignore namespace declarations
-                    if (XmlUtil.XMLNS_URI.equals(attr.getNamespaceURI()) == false) {
+                    if (!XmlUtil.XMLNS_URI.equals(attr.getNamespaceURI())) {
                         // find attr with matching localName(),  namespaceURI(),  == value() in src
                         String found = src.getAttribute(attr.getLocalName(), attr.getNamespaceURI());
                         if (attr.getValue().equals(found) && result != MatchingResult.NO_MATCH) {