X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=openflowplugin-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fopenflowplugin%2Fimpl%2Fregistry%2Fflow%2FFlowRegistryKeyFactory.java;h=a691b60ba2516d8e0e30129c00834f34b503cb22;hb=d1af0fd5a4053a10917f631bae42970c1960fd20;hp=aac1c3c465927236216a6c65fa9b06767c27a6de;hpb=2f0bb7b74a58dde036e69677e5dba089863d82cf;p=openflowplugin.git diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/registry/flow/FlowRegistryKeyFactory.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/registry/flow/FlowRegistryKeyFactory.java index aac1c3c465..a691b60ba2 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/registry/flow/FlowRegistryKeyFactory.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/registry/flow/FlowRegistryKeyFactory.java @@ -13,6 +13,7 @@ import com.google.common.base.Preconditions; import java.math.BigInteger; import org.opendaylight.openflowplugin.api.OFConstants; import org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowRegistryKey; +import org.opendaylight.openflowplugin.impl.util.MatchComparatorFactory; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow; 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; @@ -21,12 +22,13 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.M * Created by Martin Bobak <mbobak@cisco.com> on 8.4.2015. */ public class FlowRegistryKeyFactory { + private FlowRegistryKeyFactory() { // Hide implicit constructor } - public static FlowRegistryKey create(final Flow flow) { - return new FlowRegistryKeyDto(flow); + public static FlowRegistryKey create(final short version, final Flow flow) { + return new FlowRegistryKeyDto(version, flow); } private static final class FlowRegistryKeyDto implements FlowRegistryKey { @@ -34,14 +36,15 @@ public class FlowRegistryKeyFactory { private final int priority; private final BigInteger cookie; private final Match match; - private static final Match EMPTY_MATCH = new MatchBuilder().build(); + private final short version; - private FlowRegistryKeyDto(final Flow flow) { + private FlowRegistryKeyDto(final short version, 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(); + this.version = version; } @Override @@ -58,13 +61,15 @@ public class FlowRegistryKeyFactory { return getPriority() == that.getPriority() && getTableId() == that.getTableId() && - getMatch().equals(that.getMatch()); + getCookie().equals(that.getCookie()) && + MatchComparatorFactory.createMatch().areObjectsEqual(version, getMatch(), that.getMatch()); } @Override public int hashCode() { int result = tableId; result = 31 * result + priority; + result = 31 * result + cookie.hashCode(); result = 31 * result + match.hashCode(); return result; }