Merge "bug 1888 - FRM Flow Listener registration fail"
[controller.git] / opendaylight / netconf / config-netconf-connector / src / main / java / org / opendaylight / controller / netconf / confignetconfconnector / mapping / attributes / fromxml / ObjectNameAttributeReadingStrategy.java
index bf9eee7f267fd5ded0f73f431443eecb9fa76183..1d12292edb2624ee12b7d1c469c44102ab617dfc 100644 (file)
@@ -8,20 +8,19 @@
 package org.opendaylight.controller.netconf.confignetconfconnector.mapping.attributes.fromxml;
 
 import com.google.common.base.Preconditions;
-import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
-import org.opendaylight.controller.netconf.confignetconfconnector.mapping.attributes.mapping.ObjectNameAttributeMappingStrategy;
-import org.opendaylight.controller.netconf.util.xml.XmlElement;
-import org.opendaylight.controller.netconf.util.xml.XmlNetconfConstants;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
+import com.google.common.base.Strings;
 import java.util.List;
 import java.util.Map;
 
+import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
+import org.opendaylight.controller.netconf.api.xml.XmlNetconfConstants;
+import org.opendaylight.controller.netconf.confignetconfconnector.mapping.attributes.mapping.ObjectNameAttributeMappingStrategy;
+import org.opendaylight.controller.netconf.util.xml.XmlElement;
+
 public class ObjectNameAttributeReadingStrategy extends AbstractAttributeReadingStrategy {
 
     private static final Object PREFIX_SEPARATOR = ":";
-    private static final Logger logger = LoggerFactory.getLogger(ObjectNameAttributeReadingStrategy.class);
 
     public ObjectNameAttributeReadingStrategy(String nullableDefault) {
         super(nullableDefault);
@@ -39,8 +38,7 @@ public class ObjectNameAttributeReadingStrategy extends AbstractAttributeReading
     }
 
     private ObjectNameAttributeMappingStrategy.MappedDependency resolve(XmlElement firstChild) throws NetconfDocumentedException{
-        XmlElement typeElement = null;
-        typeElement = firstChild.getOnlyChildElementWithSameNamespace(XmlNetconfConstants.TYPE_KEY);
+        XmlElement typeElement = firstChild.getOnlyChildElementWithSameNamespace(XmlNetconfConstants.TYPE_KEY);
         Map.Entry<String, String> prefixNamespace = typeElement.findNamespaceOfTextContent();
 
         String serviceName = checkPrefixAndExtractServiceName(typeElement, prefixNamespace);
@@ -54,8 +52,8 @@ public class ObjectNameAttributeReadingStrategy extends AbstractAttributeReading
 
     public static String checkPrefixAndExtractServiceName(XmlElement typeElement, Map.Entry<String, String> prefixNamespace) throws NetconfDocumentedException {
         String serviceName = typeElement.getTextContent();
-
-        Preconditions.checkState(!prefixNamespace.equals(""), "Service %s value not prefixed with namespace",
+        // FIXME: comparing Entry with String:
+        Preconditions.checkState(!Strings.isNullOrEmpty(prefixNamespace.getKey()), "Service %s value not prefixed with namespace",
                 XmlNetconfConstants.TYPE_KEY);
         String prefix = prefixNamespace.getKey() + PREFIX_SEPARATOR;
         Preconditions.checkState(serviceName.startsWith(prefix),