Fix potential performance problems reported by findbugs
[openflowplugin.git] / openflowplugin / src / main / java / org / opendaylight / openflowplugin / openflow / md / core / sal / convertor / FlowConvertor.java
index 13e31f8af9b5e24b56367aa8bea660a1a8ad7b79..1ab6b6c34cd92c93151cbd7d4042f057791551d5 100644 (file)
@@ -40,15 +40,15 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MeterIdInstructionBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TableIdInstruction;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TableIdInstructionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.ActionsList;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.Instructions;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.InstructionsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModCommand;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MatchTypeBase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmMatchType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.MatchEntries;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInputBuilder;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -64,9 +64,9 @@ public class FlowConvertor {
     // Default values for when things are null
     private static final BigInteger DEFAULT_COOKIE = BigInteger.ZERO;
     private static final BigInteger DEFAULT_COOKIE_MASK = BigInteger.ZERO;
-    private static final TableId DEFAULT_TABLE_ID = new TableId(new Long(0));
-    private static final Integer DEFAULT_IDLE_TIMEOUT = new Integer(5 * 60);
-    private static final Integer DEFAULT_HARD_TIMEOUT = new Integer(10 * 60);
+    private static final TableId DEFAULT_TABLE_ID = new TableId(0L);
+    private static final Integer DEFAULT_IDLE_TIMEOUT = 5 * 60;
+    private static final Integer DEFAULT_HARD_TIMEOUT = 10 * 60;
     private static final Integer DEFAULT_PRIORITY = Integer.parseInt("8000", 16);
     private static final Long DEFAULT_BUFFER_ID = Long.parseLong("ffffffff", 16);
     private static final Long OFPP_ANY = Long.parseLong("ffffffff", 16);
@@ -93,13 +93,13 @@ public class FlowConvertor {
     public static FlowModInputBuilder toFlowModInput(Flow flow, short version,BigInteger datapathid) {
         FlowModInputBuilder flowMod = new FlowModInputBuilder();
         if (flow.getCookie() != null) {
-            flowMod.setCookie(flow.getCookie());
+            flowMod.setCookie(flow.getCookie().getValue());
         } else {
             flowMod.setCookie(DEFAULT_COOKIE);
         }
 
         if (flow.getCookieMask() != null) {
-            flowMod.setCookieMask(new BigInteger(flow.getCookieMask().toString()));
+            flowMod.setCookieMask(flow.getCookieMask().getValue());
         } else {
             flowMod.setCookieMask(DEFAULT_COOKIE_MASK);
         }
@@ -165,22 +165,22 @@ public class FlowConvertor {
         MatchReactor.getInstance().convert(flow.getMatch(), version, flowMod,datapathid);
 
         if (flow.getInstructions() != null) {
-            flowMod.setInstructions(toInstructions(flow.getInstructions(), version,datapathid));
-            flowMod.setActionsList(getActionsList(flow.getInstructions(), version,datapathid));
+            flowMod.setInstruction(toInstructions(flow.getInstructions(), version,datapathid));
+            flowMod.setAction(getActions(flow.getInstructions(), version,datapathid));
         }
         flowMod.setVersion(version);
         
         return flowMod;
     }
 
-    private static List<Instructions> toInstructions(
+    private static List<Instruction> toInstructions(
             org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Instructions instructions,
             short version,BigInteger datapathid) {
-        List<Instructions> instructionsList = new ArrayList<>();
+        List<Instruction> instructionsList = new ArrayList<>();
 
         for (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction instruction : instructions
                 .getInstruction()) {
-            InstructionsBuilder instructionBuilder = new InstructionsBuilder();
+            InstructionBuilder instructionBuilder = new InstructionBuilder();
             org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction curInstruction = instruction
                     .getInstruction();
             if (curInstruction instanceof GoToTableCase) {
@@ -215,7 +215,7 @@ public class FlowConvertor {
                 instructionBuilder
                         .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteActions.class);
                 ActionsInstructionBuilder actionsInstructionBuilder = new ActionsInstructionBuilder();
-                actionsInstructionBuilder.setActionsList(ActionConvertor.getActionList(writeActions.getAction(),
+                actionsInstructionBuilder.setAction(ActionConvertor.getActions(writeActions.getAction(),
                         version,datapathid));
                 instructionBuilder.addAugmentation(ActionsInstruction.class, actionsInstructionBuilder.build());
                 instructionsList.add(instructionBuilder.build());
@@ -227,7 +227,7 @@ public class FlowConvertor {
                 instructionBuilder
                         .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ApplyActions.class);
                 ActionsInstructionBuilder actionsInstructionBuilder = new ActionsInstructionBuilder();
-                actionsInstructionBuilder.setActionsList(ActionConvertor.getActionList(applyActions.getAction(),
+                actionsInstructionBuilder.setAction(ActionConvertor.getActions(applyActions.getAction(),
                         version,datapathid));
                 instructionBuilder.addAugmentation(ActionsInstruction.class, actionsInstructionBuilder.build());
                 instructionsList.add(instructionBuilder.build());
@@ -238,10 +238,6 @@ public class FlowConvertor {
                 ClearActions clearActions = clearActionscase.getClearActions();
                 instructionBuilder
                         .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ClearActions.class);
-                ActionsInstructionBuilder actionsInstructionBuilder = new ActionsInstructionBuilder();
-                actionsInstructionBuilder.setActionsList(ActionConvertor.getActionList(clearActions.getAction(),
-                        version,datapathid));
-                instructionBuilder.addAugmentation(ActionsInstruction.class, actionsInstructionBuilder.build());
                 instructionsList.add(instructionBuilder.build());
             }
 
@@ -260,7 +256,7 @@ public class FlowConvertor {
         return instructionsList;
     }
     
-    private static List<ActionsList> getActionsList(
+    private static List<Action> getActions(
             org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Instructions instructions,
             short version,BigInteger datapathid) {
 
@@ -272,10 +268,10 @@ public class FlowConvertor {
             if (curInstruction instanceof ApplyActionsCase) {
                 ApplyActionsCase applyActionscase = (ApplyActionsCase) curInstruction;
                 ApplyActions applyActions = applyActionscase.getApplyActions();
-                return ActionConvertor.getActionList(applyActions.getAction(), version,datapathid);
+                return ActionConvertor.getActions(applyActions.getAction(), version,datapathid);
             }
 
         }
         return null;
     }
-}
\ No newline at end of file
+}