Fix checkstyle warnings for config-netconf-connector
[controller.git] / opendaylight / netconf / config-netconf-connector / src / main / java / org / opendaylight / controller / netconf / confignetconfconnector / mapping / attributes / fromxml / ObjectNameAttributeReadingStrategy.java
index 7a4ba31255ac08e0099dab72830fe7cdbb2a48a3..f85fe298b3cc78377ba35621494404c358ae7c29 100644 (file)
@@ -8,12 +8,13 @@
 package org.opendaylight.controller.netconf.confignetconfconnector.mapping.attributes.fromxml;
 
 import com.google.common.base.Preconditions;
-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 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 {
 
@@ -24,7 +25,7 @@ public class ObjectNameAttributeReadingStrategy extends AbstractAttributeReading
     }
 
     @Override
-    AttributeConfigElement readElementHook(List<XmlElement> configNodes) {
+    AttributeConfigElement readElementHook(List<XmlElement> configNodes) throws NetconfDocumentedException {
 
         XmlElement firstChild = configNodes.get(0);
         Preconditions.checkState(configNodes.size() == 1, "This element should be present only once " + firstChild
@@ -34,7 +35,7 @@ public class ObjectNameAttributeReadingStrategy extends AbstractAttributeReading
         return AttributeConfigElement.create(getNullableDefault(), resolve(firstChild));
     }
 
-    private ObjectNameAttributeMappingStrategy.MappedDependency resolve(XmlElement firstChild) {
+    private ObjectNameAttributeMappingStrategy.MappedDependency resolve(XmlElement firstChild) throws NetconfDocumentedException{
         XmlElement typeElement = firstChild.getOnlyChildElementWithSameNamespace(XmlNetconfConstants.TYPE_KEY);
         Map.Entry<String, String> prefixNamespace = typeElement.findNamespaceOfTextContent();
 
@@ -47,10 +48,10 @@ public class ObjectNameAttributeReadingStrategy extends AbstractAttributeReading
                 dependencyName);
     }
 
-    public static String checkPrefixAndExtractServiceName(XmlElement typeElement, Map.Entry<String, String> prefixNamespace) {
+    public static String checkPrefixAndExtractServiceName(XmlElement typeElement, Map.Entry<String, String> prefixNamespace) throws NetconfDocumentedException {
         String serviceName = typeElement.getTextContent();
-
-        Preconditions.checkState(prefixNamespace.equals("") == false, "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),