From e2c3a86fa648550439f34329f0068a1d546949d6 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Tue, 26 May 2015 02:23:51 +0200 Subject: [PATCH] Use constants for Ordering objects These objects are used heavily, make sure we share instances. Change-Id: I81fd8cac22d5f32643e58199ede545b909934100 Signed-off-by: Robert Varga --- .../openflow/md/core/sal/convertor/ActionConvertor.java | 5 +++-- .../openflow/md/core/sal/convertor/FlowConvertor.java | 6 ++++-- .../md/core/sal/convertor/TableFeaturesConvertor.java | 6 +++--- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/ActionConvertor.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/ActionConvertor.java index 69d27ad03f..17cf354601 100644 --- a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/ActionConvertor.java +++ b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/ActionConvertor.java @@ -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 ACTION_ORDERING = + Ordering.from(OrderComparator.build()); private ActionConvertor() { // NOOP @@ -218,8 +220,7 @@ public final class ActionConvertor { Action ofAction; final List sortedActions = - Ordering.from(OrderComparator.build()) - .sortedCopy(actions); + ACTION_ORDERING.sortedCopy(actions); for (int actionItem = 0; actionItem < sortedActions.size(); actionItem++) { ofAction = null; diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/FlowConvertor.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/FlowConvertor.java index f85401ae21..31afbd2d36 100644 --- a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/FlowConvertor.java +++ b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/FlowConvertor.java @@ -134,6 +134,9 @@ public class FlowConvertor { */ public static final List DEFAULT_MATCH_ENTRIES = new ArrayList(); + private static final Ordering INSTRUCTION_ORDERING = + Ordering.from(OrderComparator.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 sortedInstructions = - Ordering.from(OrderComparator.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 diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/TableFeaturesConvertor.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/TableFeaturesConvertor.java index 264accc8da..03260d6285 100644 --- a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/TableFeaturesConvertor.java +++ b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/TableFeaturesConvertor.java @@ -149,6 +149,8 @@ import java.util.Map; */ public class TableFeaturesConvertor { private static final Logger LOG = LoggerFactory.getLogger(TableFeaturesConvertor.class); + private static final Ordering TABLE_FEATURE_PROPS_ORDERING = + Ordering.from(OrderComparator.build()); private TableFeaturesConvertor() { //hiding implicit construcotr @@ -182,9 +184,7 @@ public class TableFeaturesConvertor { List ofTablePropertiesList = new ArrayList<>(); List - sortedTableProperties = - Ordering.from(OrderComparator.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) { -- 2.36.6