Added capability to resolve Enumeration type definitions;
[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 boolean deletePending;
32
33     public FlowEntryInstall(FlowEntry original, ContainerFlow cFlow) {
34         this.original = original;
35         this.cFlow = cFlow;
36         this.install = (cFlow == null) ? original.clone() : original
37                 .mergeWith(cFlow);
38         deletePending = false;
39     }
40
41     @Override
42     public int hashCode() {
43         return HashCodeBuilder.reflectionHashCode(this);
44     }
45
46     @Override
47     public boolean equals(Object obj) {
48         return EqualsBuilder.reflectionEquals(this, obj);
49     }
50
51     public String getFlowName() {
52         return original.getFlowName();
53     }
54
55     public String getGroupName() {
56         return original.getGroupName();
57     }
58
59     public Node getNode() {
60         return original.getNode();
61     }
62
63     public boolean equalsByNodeAndName(Node node, String flowName) {
64         return original.equalsByNodeAndName(node, flowName);
65     }
66
67     public FlowEntry getOriginal() {
68         return original;
69     }
70
71     public ContainerFlow getContainerFlow() {
72         return cFlow;
73     }
74
75     public FlowEntry getInstall() {
76         return install;
77     }
78
79     public boolean isDeletePending() {
80         return deletePending;
81     }
82
83     public void toBeDeleted() {
84         this.deletePending = true;
85     }
86
87     @Override
88     public String toString() {
89         return "[Install = " + install + " Original: " + original + " cFlow: "
90                 + cFlow + "]";
91     }
92 }