Merge "Bug 6633 : NXM_OF_IN_PORT support in openflowplugin"
[openflowplugin.git] / applications / forwardingrules-sync / src / main / java / org / opendaylight / openflowplugin / applications / frsync / util / FlowDescriptor.java
1 /**
2  * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.openflowplugin.applications.frsync.util;
10
11 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId;
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
13
14 /**
15  * Identifier of {@link Flow} in datastore using combination of flow-id and table-id from datastore datapath.
16  */
17 public class FlowDescriptor {
18
19     private final FlowId flowId;
20     private final Short tableId;
21
22     public FlowDescriptor(Flow flow) {
23         this.flowId = flow.getId();
24         this.tableId = flow.getTableId();
25     }
26
27     @Override
28     public boolean equals(Object o) {
29         if (this == o) {
30             return true;
31         }
32         if (o == null || getClass() != o.getClass()) {
33             return false;
34         }
35
36         FlowDescriptor that = (FlowDescriptor) o;
37         if (flowId != null ? !flowId.equals(that.flowId) : that.flowId != null) {
38             return false;
39         }
40         return tableId != null ? tableId.equals(that.tableId) : that.tableId == null;
41
42     }
43
44     @Override
45     public int hashCode() {
46         int result = flowId != null ? flowId.hashCode() : 0;
47         result = 31 * result + (tableId != null ? tableId.hashCode() : 0);
48         return result;
49     }
50
51 }