restructure and base modules for different features
[vpnservice.git] / mdsalutil / mdsalutil-api / src / main / java / org / opendaylight / vpnservice / mdsalutil / FlowEntity.java
1 /*
2  * Copyright (c) 2013 Ericsson AB.  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
10 package org.opendaylight.vpnservice.mdsalutil;
11
12 import java.math.BigInteger;
13 import java.util.List;
14
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags;
20
21 public class FlowEntity extends AbstractSwitchEntity {
22     private static final long serialVersionUID = 1L;
23
24     private short m_shTableId;
25     private String m_sFlowId;
26     private int m_nPriority;
27     private String m_sFlowName;
28     private int m_nIdleTimeOut;
29     private int m_nHardTimeOut;
30     private BigInteger m_biCookie;
31     private List<MatchInfo> m_listMatchInfo;
32     private List<InstructionInfo> m_listInstructionInfo;
33
34     private boolean m_bStrictFlag;
35     private boolean m_bSendFlowRemFlag;
36
37     private transient FlowBuilder m_flowBuilder;
38
39     public FlowEntity(long lDpnId) {
40         super(lDpnId);
41     }
42
43     @Override
44     public String toString() {
45         return "FlowEntity [m_shTableId=" + m_shTableId + ", m_sFlowId=" + m_sFlowId + ", m_nPriority=" + m_nPriority
46                 + ", m_sFlowName=" + m_sFlowName + ", m_nIdleTimeOut=" + m_nIdleTimeOut + ", m_nHardTimeOut="
47                 + m_nHardTimeOut + ", m_biCookie=" + m_biCookie + ", m_listMatchInfo=" + m_listMatchInfo
48                 + ", m_listInstructionInfo=" + m_listInstructionInfo + ", m_bStrictFlag=" + m_bStrictFlag
49                 + ", m_bSendFlowRemFlag=" + m_bSendFlowRemFlag + ", toString()=" + super.toString() + "]";
50     }
51
52     public BigInteger getCookie() {
53         return m_biCookie;
54     }
55
56     public String getFlowId() {
57         return m_sFlowId;
58     }
59
60     public String getFlowName() {
61         return m_sFlowName;
62     }
63
64     public int getHardTimeOut() {
65         return m_nHardTimeOut;
66     }
67
68     public int getIdleTimeOut() {
69         return m_nIdleTimeOut;
70     }
71
72     public List<InstructionInfo> getInstructionInfoList() {
73         return m_listInstructionInfo;
74     }
75
76     public List<MatchInfo> getMatchInfoList() {
77         return m_listMatchInfo;
78     }
79
80     public int getPriority() {
81         return m_nPriority;
82     }
83
84     public boolean getSendFlowRemFlag() {
85         return m_bSendFlowRemFlag;
86     }
87
88     public boolean getStrictFlag() {
89         return m_bStrictFlag;
90     }
91
92     public short getTableId() {
93         return m_shTableId;
94     }
95
96     public void setCookie(BigInteger biCookie) {
97         m_biCookie = biCookie;
98         m_flowBuilder = null;
99     }
100
101     public FlowBuilder getFlowBuilder() {
102         if (m_flowBuilder == null) {
103             m_flowBuilder = new FlowBuilder();
104
105             m_flowBuilder.setKey(new FlowKey(new FlowId(getFlowId())));
106
107             m_flowBuilder.setTableId(getTableId());
108             m_flowBuilder.setPriority(getPriority());
109             m_flowBuilder.setFlowName(getFlowName());
110             m_flowBuilder.setIdleTimeout(getIdleTimeOut());
111             m_flowBuilder.setHardTimeout(getHardTimeOut());
112             m_flowBuilder.setCookie(new FlowCookie(getCookie()));
113             m_flowBuilder.setMatch(MDSALUtil.buildMatches(getMatchInfoList()));
114             m_flowBuilder.setInstructions(MDSALUtil.buildInstructions(getInstructionInfoList()));
115
116             m_flowBuilder.setStrict(getStrictFlag());
117             // TODO Fix Me
118             //m_flowBuilder.setResyncFlag(getResyncFlag());
119             if (getSendFlowRemFlag()) {
120                 m_flowBuilder.setFlags(new FlowModFlags(false, false, false, false, true));
121             }
122
123             m_flowBuilder.setBarrier(false);
124             m_flowBuilder.setInstallHw(true);
125         }
126
127         return m_flowBuilder;
128     }
129
130     public void setFlowId(String sFlowId) {
131         m_sFlowId = sFlowId;
132         if (m_flowBuilder != null) {
133             m_flowBuilder.setKey(new FlowKey(new FlowId(sFlowId)));
134         }
135     }
136
137     public void setFlowName(String sFlowName) {
138         m_sFlowName = sFlowName;
139         m_flowBuilder = null;
140     }
141
142     public void setHardTimeOut(int nHardTimeOut) {
143         m_nHardTimeOut = nHardTimeOut;
144         m_flowBuilder = null;
145     }
146
147     public void setIdleTimeOut(int nIdleTimeOut) {
148         m_nIdleTimeOut = nIdleTimeOut;
149         m_flowBuilder = null;
150     }
151
152     public void setInstructionInfoList(List<InstructionInfo> listInstructionInfo) {
153         m_listInstructionInfo = listInstructionInfo;
154         m_flowBuilder = null;
155     }
156
157     public void setMatchInfoList(List<MatchInfo> listMatchInfo) {
158         m_listMatchInfo = listMatchInfo;
159         m_flowBuilder = null;
160     }
161
162     public void setPriority(int nPriority) {
163         m_nPriority = nPriority;
164         m_flowBuilder = null;
165     }
166
167     public void setSendFlowRemFlag(boolean bSendFlowRemFlag) {
168         m_bSendFlowRemFlag = bSendFlowRemFlag;
169         m_flowBuilder = null;
170     }
171
172     public void setStrictFlag(boolean bStrictFlag) {
173         m_bStrictFlag = bStrictFlag;
174         m_flowBuilder = null;
175     }
176
177     public void setTableId(short shTableId) {
178         m_shTableId = shTableId;
179         m_flowBuilder = null;
180     }
181 }