Use constants for Ordering objects 80/21080/1
authorRobert Varga <rovarga@cisco.com>
Tue, 26 May 2015 00:23:51 +0000 (02:23 +0200)
committerRobert Varga <rovarga@cisco.com>
Tue, 26 May 2015 00:23:51 +0000 (02:23 +0200)
These objects are used heavily, make sure we share instances.

Change-Id: I81fd8cac22d5f32643e58199ede545b909934100
Signed-off-by: Robert Varga <rovarga@cisco.com>
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/ActionConvertor.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/FlowConvertor.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/TableFeaturesConvertor.java

index 69d27ad03f30ade7ef885223a0cf2ca1af7d9353..17cf3546014d678caf701a20dae5c8e21c48c342 100644 (file)
@@ -197,6 +197,8 @@ import com.google.common.collect.Ordering;
 public final class ActionConvertor {
     private static final Logger LOG = LoggerFactory.getLogger(ActionConvertor.class);
     private static final String UNKNOWN_ACTION_TYPE_VERSION = "Unknown Action Type for the Version";
+    private static final Ordering<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> ACTION_ORDERING =
+            Ordering.from(OrderComparator.<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action>build());
 
     private ActionConvertor() {
         // NOOP
@@ -218,8 +220,7 @@ public final class ActionConvertor {
         Action ofAction;
 
         final List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> sortedActions =
-                Ordering.from(OrderComparator.<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action>build())
-                        .sortedCopy(actions);
+                ACTION_ORDERING.sortedCopy(actions);
 
         for (int actionItem = 0; actionItem < sortedActions.size(); actionItem++) {
             ofAction = null;
index f85401ae213c9e1db67979eace720d82e6e68c2b..31afbd2d363c2720d1666d081418372a58e496e6 100644 (file)
@@ -134,6 +134,9 @@ public class FlowConvertor {
      */
     public static final List<MatchEntry> DEFAULT_MATCH_ENTRIES = new ArrayList<MatchEntry>();
 
+    private static final Ordering<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction> INSTRUCTION_ORDERING =
+            Ordering.from(OrderComparator.<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction>build());
+
     private static final VlanMatch VLAN_MATCH_FALSE;
     private static final VlanMatch VLAN_MATCH_TRUE;
 
@@ -368,8 +371,7 @@ public class FlowConvertor {
 
         org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Instructions instructions = flow.getInstructions();
         List<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction> sortedInstructions =
-                Ordering.from(OrderComparator.<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction>build())
-                        .sortedCopy(instructions.getInstruction());
+                INSTRUCTION_ORDERING.sortedCopy(instructions.getInstruction());
 
         for (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction instruction : sortedInstructions) {
             org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction curInstruction = instruction
index 264accc8da77029e5fdfc5e93517d8139e36c14f..03260d628595f0eb93711d65327b355d268039c1 100644 (file)
@@ -149,6 +149,8 @@ import java.util.Map;
  */
 public class TableFeaturesConvertor {
     private static final Logger LOG = LoggerFactory.getLogger(TableFeaturesConvertor.class);
+    private static final Ordering<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeatureProperties> TABLE_FEATURE_PROPS_ORDERING =
+            Ordering.from(OrderComparator.<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeatureProperties>build());
 
     private TableFeaturesConvertor() {
         //hiding implicit construcotr
@@ -182,9 +184,7 @@ public class TableFeaturesConvertor {
         List<TableFeatureProperties> ofTablePropertiesList = new ArrayList<>();
 
         List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeatureProperties>
-                sortedTableProperties =
-                Ordering.from(OrderComparator.<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeatureProperties>build())
-                        .sortedCopy(tableProperties.getTableFeatureProperties());
+                sortedTableProperties = TABLE_FEATURE_PROPS_ORDERING.sortedCopy(tableProperties.getTableFeatureProperties());
 
         for (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeatureProperties
                 property : sortedTableProperties) {