Bug 8153: Enforce check-style rules for netconf - config-netconf-connector
[netconf.git] / netconf / config-netconf-connector / src / main / java / org / opendaylight / netconf / confignetconfconnector / operations / editconfig / EditConfigXmlParser.java
index c255747bd956d2fa214d12b0bff2ed068488d5f3..ddba4ae81397a1d0695db8f58ccfbff2027f2625 100644 (file)
@@ -45,32 +45,32 @@ public class EditConfigXmlParser {
         xml.checkNamespace(XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0);
 
 
-        XmlElement targetElement = null;
-        XmlElement targetChildNode = null;
+        XmlElement targetElement;
+        XmlElement targetChildNode;
         targetElement  = xml.getOnlyChildElementWithSameNamespace(EditConfigXmlParser.TARGET_KEY);
         targetChildNode = targetElement.getOnlyChildElementWithSameNamespace();
 
-        String datastoreValue = targetChildNode.getName();
-        Datastore targetDatastore = Datastore.valueOf(datastoreValue);
+        final String datastoreValue = targetChildNode.getName();
+        final Datastore targetDatastore = Datastore.valueOf(datastoreValue);
         LOG.debug("Setting {} to '{}'", EditConfigXmlParser.TARGET_KEY, targetDatastore);
 
         // check target
-        if (targetDatastore != Datastore.candidate){
+        if (targetDatastore != Datastore.candidate) {
             throw new DocumentedException(String.format(
                     "Only %s datastore supported for edit config but was: %s",
                     Datastore.candidate,
                     targetDatastore),
-                    DocumentedException.ErrorType.application,
-                    DocumentedException.ErrorTag.invalid_value,
-                    DocumentedException.ErrorSeverity.error);
+                    DocumentedException.ErrorType.APPLICATION,
+                    DocumentedException.ErrorTag.INVALID_VALUE,
+                    DocumentedException.ErrorSeverity.ERROR);
         }
 
         // Test option
-        TestOption testOption;
-        Optional<XmlElement> testOptionElementOpt = xml
+        final TestOption testOption;
+        final Optional<XmlElement> testOptionElementOpt = xml
                 .getOnlyChildElementWithSameNamespaceOptionally(EditConfigXmlParser.TEST_OPTION_KEY);
         if (testOptionElementOpt.isPresent()) {
-            String testOptionValue = testOptionElementOpt.get().getTextContent();
+            final String testOptionValue = testOptionElementOpt.get().getTextContent();
             testOption = TestOption.getFromXmlName(testOptionValue);
         } else {
             testOption = TestOption.getDefault();
@@ -78,26 +78,26 @@ public class EditConfigXmlParser {
         LOG.debug("Setting {} to '{}'", EditConfigXmlParser.TEST_OPTION_KEY, testOption);
 
         // Error option
-        Optional<XmlElement> errorOptionElement = xml
+        final Optional<XmlElement> errorOptionElement = xml
                 .getOnlyChildElementWithSameNamespaceOptionally(EditConfigXmlParser.ERROR_OPTION_KEY);
         if (errorOptionElement.isPresent()) {
-            String errorOptionParsed = errorOptionElement.get().getTextContent();
-            if (!errorOptionParsed.equals(EditConfigXmlParser.DEFAULT_ERROR_OPTION)){
+            final String errorOptionParsed = errorOptionElement.get().getTextContent();
+            if (!errorOptionParsed.equals(EditConfigXmlParser.DEFAULT_ERROR_OPTION)) {
                 throw new UnsupportedOperationException("Only " + EditConfigXmlParser.DEFAULT_ERROR_OPTION
                         + " supported for " + EditConfigXmlParser.ERROR_OPTION_KEY + ", was " + errorOptionParsed);
             }
         }
 
         // Default op
-        Optional<XmlElement> defaultContent = xml
+        final Optional<XmlElement> defaultContent = xml
                 .getOnlyChildElementWithSameNamespaceOptionally(EditConfigXmlParser.DEFAULT_OPERATION_KEY);
         if (defaultContent.isPresent()) {
-            String mergeStrategyString = defaultContent.get().getTextContent();
+            final String mergeStrategyString = defaultContent.get().getTextContent();
             LOG.trace("Setting merge strategy to {}", mergeStrategyString);
             editStrategyType = EditStrategyType.valueOf(mergeStrategyString);
         }
 
-        XmlElement configElement = null;
+        XmlElement configElement;
         configElement = xml.getOnlyChildElementWithSameNamespace(XmlNetconfConstants.CONFIG_KEY);
 
         return new ConfigExecution(cfgMapping, configElement, testOption, editStrategyType);