ac0a4cccd41601af4b7f7994d681088c8d863c20
[controller.git] / opendaylight / forwardingrulesmanager / src / main / java / org / opendaylight / controller / forwardingrulesmanager / FlowEntryInstall.java
1
2 /*
3  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
4  *
5  * This program and the accompanying materials are made available under the
6  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
7  * and is available at http://www.eclipse.org/legal/epl-v10.html
8  */
9
10 package org.opendaylight.controller.forwardingrulesmanager;
11
12 import org.apache.commons.lang3.builder.EqualsBuilder;
13 import org.apache.commons.lang3.builder.HashCodeBuilder;
14 import org.opendaylight.controller.sal.core.ContainerFlow;
15 import org.opendaylight.controller.sal.core.Node;
16
17 /**
18  * The flow database object representing the flow entry to install on
19  * the network node. It contains the original flow entry FRM was
20  * requested to install, the container flow with which that entry had
21  * to be merged and the resultant merged flow entry, which is the
22  * one that was eventually installed on the network node
23  *
24  * Note: If the container flow is null, the install entry will be a clone
25  * of the original entry
26  *
27  */
28 public class FlowEntryInstall {
29     private FlowEntry original;
30     private ContainerFlow cFlow;
31     private FlowEntry install;
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     }
41
42     @Override
43     public int hashCode() {
44         return HashCodeBuilder.reflectionHashCode(this);
45     }
46
47     @Override
48     public boolean equals(Object obj) {
49         return EqualsBuilder.reflectionEquals(this, obj);
50     }
51
52     public String getFlowName() {
53         return original.getFlowName();
54     }
55
56     public String getGroupName() {
57         return original.getGroupName();
58     }
59
60     public Node getNode() {
61         return original.getNode();
62     }
63
64     public boolean equalsByNodeAndName(Node node, String flowName) {
65         return original.equalsByNodeAndName(node, flowName);
66     }
67
68     public FlowEntry getOriginal() {
69         return original;
70     }
71
72     public ContainerFlow getContainerFlow() {
73         return cFlow;
74     }
75
76     public FlowEntry getInstall() {
77         return install;
78     }
79
80     public boolean isDeletePending() {
81         return deletePending;
82     }
83
84     public void toBeDeleted() {
85         this.deletePending = true;
86     }
87
88     @Override
89     public String toString() {
90         return "[Install = " + install + " Original: " + original + " cFlow: "
91                 + cFlow + "]";
92     }
93 }