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;
*/
public class FlowRegistryKeyFactory {
-
- public 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 {
-
private final short tableId;
private final int priority;
private final BigInteger cookie;
private final Match match;
+ private final short version;
- public 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? new MatchBuilder().build(): flow.getMatch();
+ match = MoreObjects.firstNonNull(flow.getMatch(), OFConstants.EMPTY_MATCH);
cookie = MoreObjects.firstNonNull(flow.getCookie(), OFConstants.DEFAULT_FLOW_COOKIE).getValue();
+ this.version = version;
}
@Override
return getPriority() == that.getPriority() &&
getTableId() == that.getTableId() &&
getCookie().equals(that.getCookie()) &&
- getMatch().equals(that.getMatch());
+ MatchComparatorFactory.createMatch().areObjectsEqual(version, getMatch(), that.getMatch());
}
@Override