Fix checkstyle API.
[openflowplugin.git] / openflowplugin / src / main / java / org / opendaylight / openflowplugin / openflow / md / core / extension / ActionExtensionHelper.java
index f6a54166eb66db6b79d3611502f84cea8bcabe35..80afdd46dc6e2df500309f182ef5383007be94b4 100644 (file)
@@ -7,11 +7,13 @@
  */
 package org.opendaylight.openflowplugin.openflow.md.core.extension;
 
+import java.util.Objects;
 import org.opendaylight.openflowjava.protocol.api.keys.ActionSerializerKey;
 import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterActionSerializerKey;
 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
 import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
 import org.opendaylight.openflowplugin.extension.api.ConvertorActionFromOFJava;
+import org.opendaylight.openflowplugin.extension.api.core.extension.ExtensionConverterProvider;
 import org.opendaylight.openflowplugin.extension.api.path.ActionPath;
 import org.opendaylight.openflowplugin.openflow.md.core.session.OFSessionUtil;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.action.container.action.choice.ExperimenterIdCase;
@@ -32,15 +34,21 @@ public final class ActionExtensionHelper {
     }
 
     /**
-     * @param action
-     * @param ofVersion
-     * @param actionPath
+     * @param action openflow action
+     * @param ofVersion openflow version
+     * @param actionPath openflow action path
      * @return augmentation wrapper containing augmentation depending on matchPath
      */
     public static org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action
     processAlienAction(final Action action, final OpenflowVersion ofVersion, final ActionPath actionPath) {
         ConvertorActionFromOFJava<Action, ActionPath> convertor = null;
         org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action alienAction = null;
+        final ExtensionConverterProvider extensionConvertorProvider = OFSessionUtil.getExtensionConvertorProvider();
+
+        if (Objects.isNull(extensionConvertorProvider)) {
+            return null;
+        }
+
         if(action.getActionChoice() instanceof ExperimenterIdCase) {
             ExperimenterIdCase actionCase = (ExperimenterIdCase) action.getActionChoice();
             /** TODO: EXTENSION PROPOSAL (action, OFJava to MD-SAL) */
@@ -48,15 +56,16 @@ public final class ActionExtensionHelper {
                     ofVersion.getVersion(),
                     actionCase.getExperimenter().getExperimenter().getValue(),
                     actionCase.getExperimenter().getSubType());
-            convertor = OFSessionUtil.getExtensionConvertorProvider().getActionConverter(key);
+            convertor = extensionConvertorProvider.getActionConverter(key);
         } else if (action.getActionChoice() != null){
             ActionSerializerKey<?> key = new ActionSerializerKey(EncodeConstants.OF13_VERSION_ID, action.getActionChoice().getImplementedInterface(), null);
-            convertor = OFSessionUtil.getExtensionConvertorProvider().getActionConverter(key);
+            convertor = extensionConvertorProvider.getActionConverter(key);
         }
+
         if (convertor != null) {
-            alienAction = convertor.convert(
-                    action, actionPath);
+            alienAction = convertor.convert(action, actionPath);
         }
+
         return alienAction;
     }
 }