Merge "ForwardingRulesManager to expose async flow api"
[controller.git] / opendaylight / forwardingrulesmanager / api / src / main / java / org / opendaylight / controller / forwardingrulesmanager / FlowEntryInstall.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. 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.controller.forwardingrulesmanager;
10
11 import org.apache.commons.lang3.builder.EqualsBuilder;
12 import org.apache.commons.lang3.builder.HashCodeBuilder;
13 import org.opendaylight.controller.sal.core.ContainerFlow;
14 import org.opendaylight.controller.sal.core.Node;
15
16 /**
17  * The flow database object representing the flow entry to install on the
18  * network node. It contains the original flow entry FRM was requested to
19  * install, the container flow with which that entry had to be merged and the
20  * resultant merged flow entry, which is the one that was eventually installed
21  * on the network node
22  * 
23  * Note: If the container flow is null, the install entry will be a clone of the
24  * original entry
25  * 
26  */
27 public class FlowEntryInstall {
28     private FlowEntry original;
29     private ContainerFlow cFlow;
30     private FlowEntry install;
31     transient private long requestId; // async request id
32     transient private boolean deletePending;
33
34     public FlowEntryInstall(FlowEntry original, ContainerFlow cFlow) {
35         this.original = original;
36         this.cFlow = cFlow;
37         this.install = (cFlow == null) ? original.clone() : original
38                 .mergeWith(cFlow);
39         deletePending = false;
40         requestId = 0;
41     }
42
43     @Override
44     public int hashCode() {
45         return HashCodeBuilder.reflectionHashCode(this);
46     }
47
48     @Override
49     public boolean equals(Object obj) {
50         return EqualsBuilder.reflectionEquals(this, obj);
51     }
52
53     public String getFlowName() {
54         return original.getFlowName();
55     }
56
57     public String getGroupName() {
58         return original.getGroupName();
59     }
60
61     public Node getNode() {
62         return original.getNode();
63     }
64
65     public boolean equalsByNodeAndName(Node node, String flowName) {
66         return original.equalsByNodeAndName(node, flowName);
67     }
68
69     public FlowEntry getOriginal() {
70         return original;
71     }
72
73     public ContainerFlow getContainerFlow() {
74         return cFlow;
75     }
76
77     public FlowEntry getInstall() {
78         return install;
79     }
80
81     public boolean isDeletePending() {
82         return deletePending;
83     }
84
85     public void toBeDeleted() {
86         this.deletePending = true;
87     }
88
89     public void setRequestId(long rid) {
90         this.requestId = rid;
91     }
92     
93     public long getRequestId() {
94         return requestId;
95     }
96
97     @Override
98     public String toString() {
99         return "[Install = " + install + " Original = " + original + " cFlow = "
100                 + cFlow + " rid = " + requestId + "]";
101     }
102 }