Move empty match constant into OFConstants 54/42454/1
authorAndrej Leitner <anleitne@cisco.com>
Mon, 25 Jul 2016 09:43:22 +0000 (11:43 +0200)
committerAndrej Leitner <anleitne@cisco.com>
Mon, 25 Jul 2016 09:43:22 +0000 (11:43 +0200)
Change-Id: Iee2666f3b2b92e371b9f085849502ec5f22c5650
Signed-off-by: Andrej Leitner <anleitne@cisco.com>
openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/OFConstants.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/registry/flow/FlowRegistryKeyFactory.java

index dce622964b81d15152f15dca1e181da17659d17f..fce41bd0c98011ed9f8ac7e43f14bbef3f929c03 100644 (file)
@@ -9,6 +9,8 @@ package org.opendaylight.openflowplugin.api;
 
 import java.math.BigInteger;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
 
 /**
  * OFP related constants
@@ -26,7 +28,6 @@ public final class OFConstants {
     /** enum ofp_port_no, reserved port: local openflow port  */
     public static final short OFPP_LOCAL = ((short)0xfffe);
 
-
     /** openflow protocol 1.0 - version identifier */
     public static final short OFP_VERSION_1_0 = 0x01;
     /** openflow protocol 1.3 - version identifier */
@@ -54,6 +55,8 @@ public final class OFConstants {
     public static final BigInteger DEFAULT_COOKIE_MASK = BigInteger.ZERO;
     public static final FlowCookie DEFAULT_FLOW_COOKIE = new FlowCookie(DEFAULT_COOKIE);
     public static final Integer DEFAULT_FLOW_PRIORITY = 0x8000;
+    /** Empty flow match */
+    public static final Match EMPTY_MATCH = new MatchBuilder().build();
 
     /** indicates that no buffering should be applied and the whole packet is to be
      *  sent to the controller. */
@@ -62,7 +65,6 @@ public final class OFConstants {
      *  sent to the controller. */
     public static final Integer OFPCML_NO_BUFFER = 0xffff;
 
-
     public static final int MAC_ADDRESS_LENGTH = 6;
     public static final int SIZE_OF_LONG_IN_BYTES = 8;
     public static final int SIGNUM_UNSIGNED = 1;
index 4130bb35ccd9732cc1cea6c40696773a5ea65ee2..2edb12abfcdcc043b1c3901222ec87faddd23ba1 100644 (file)
@@ -36,13 +36,12 @@ public class FlowRegistryKeyFactory {
         private final int priority;
         private final BigInteger cookie;
         private final Match match;
-        private static final Match EMPTY_MATCH = new MatchBuilder().build();
 
         public FlowRegistryKeyDto(final Flow flow) {
             //TODO: mandatory flow input values (or default values) should be specified via yang model
             tableId = Preconditions.checkNotNull(flow.getTableId(), "flow tableId must not be null");
             priority = MoreObjects.firstNonNull(flow.getPriority(), OFConstants.DEFAULT_FLOW_PRIORITY);
-            match = flow.getMatch()==null ? EMPTY_MATCH : flow.getMatch();
+            match = MoreObjects.firstNonNull(flow.getMatch(), OFConstants.EMPTY_MATCH);
             cookie = MoreObjects.firstNonNull(flow.getCookie(), OFConstants.DEFAULT_FLOW_COOKIE).getValue();
         }