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