Merge "Bug 6614: Fix NPE in AclInterfaceCacheUtil"
[netvirt.git] / vpnservice / aclservice / api / src / main / java / org / opendaylight / netvirt / aclservice / api / utils / AclInterface.java
1 /*
2  * Copyright (c) 2016 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.netvirt.aclservice.api.utils;
9
10 import java.math.BigInteger;
11 import java.util.List;
12
13 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.interfaces._interface.AllowedAddressPairs;
15
16 /**
17  * The Class AclInterface.
18  */
19 public class AclInterface {
20
21     /** The port security enabled. */
22     Boolean portSecurityEnabled;
23
24     /** The interface id. */
25     String interfaceId;
26
27     /** The l port tag. */
28     Integer lportTag;
29
30     /** The dp id. */
31     BigInteger dpId;
32
33     /** The security groups. */
34     List<Uuid> securityGroups;
35
36     /** The allowed address pairs. */
37     List<AllowedAddressPairs> allowedAddressPairs;
38
39     /** The port is marked for delete. */
40     Boolean isMarkedForDelete = false;
41
42     /**
43      * Checks if is port security enabled.
44      *
45      * @return the boolean
46      */
47     public Boolean isPortSecurityEnabled() {
48         return portSecurityEnabled;
49     }
50
51     /**
52      * Gets the port security enabled.
53      *
54      * @return the port security enabled
55      */
56     public Boolean getPortSecurityEnabled() {
57         return portSecurityEnabled;
58     }
59
60     /**
61      * Sets the port security enabled.
62      *
63      * @param portSecurityEnabled the new port security enabled
64      */
65     public void setPortSecurityEnabled(Boolean portSecurityEnabled) {
66         this.portSecurityEnabled = portSecurityEnabled;
67     }
68
69     /**
70      * Gets the interface id.
71      *
72      * @return the interface id
73      */
74     public String getInterfaceId() {
75         return interfaceId;
76     }
77
78     /**
79      * Sets the interface id.
80      *
81      * @param interfaceId the new interface id
82      */
83     public void setInterfaceId(String interfaceId) {
84         this.interfaceId = interfaceId;
85     }
86
87     /**
88      * Gets the l port tag.
89      *
90      * @return the l port tag
91      */
92     public Integer getLPortTag() {
93         return lportTag;
94     }
95
96     /**
97      * Sets the l port tag.
98      *
99      * @param lportTag the new l port tag
100      */
101     public void setLPortTag(Integer lportTag) {
102         this.lportTag = lportTag;
103     }
104
105     /**
106      * Gets the dp id.
107      *
108      * @return the dp id
109      */
110     public BigInteger getDpId() {
111         return dpId;
112     }
113
114     /**
115      * Sets the dp id.
116      *
117      * @param dpId the new dp id
118      */
119     public void setDpId(BigInteger dpId) {
120         this.dpId = dpId;
121     }
122
123     /**
124      * Gets the security groups.
125      *
126      * @return the security groups
127      */
128     public List<Uuid> getSecurityGroups() {
129         return securityGroups;
130     }
131
132     /**
133      * Sets the security groups.
134      *
135      * @param securityGroups the new security groups
136      */
137     public void setSecurityGroups(List<Uuid> securityGroups) {
138         this.securityGroups = securityGroups;
139     }
140
141     /**
142      * Gets the allowed address pairs.
143      *
144      * @return the allowed address pairs
145      */
146     public List<AllowedAddressPairs> getAllowedAddressPairs() {
147         return allowedAddressPairs;
148     }
149
150     /**
151      * Sets the allowed address pairs.
152      *
153      * @param allowedAddressPairs the new allowed address pairs
154      */
155     public void setAllowedAddressPairs(List<AllowedAddressPairs> allowedAddressPairs) {
156         this.allowedAddressPairs = allowedAddressPairs;
157     }
158
159     /**
160      * Retrieve isMarkedForDelete.
161      * @return the whether it is marked for delete
162      */
163     public Boolean isMarkedForDelete() {
164         return isMarkedForDelete;
165     }
166
167     /**
168      * Sets isMarkedForDelete.
169      * @param isMarkedForDelete boolean value
170      */
171     public void setIsMarkedForDelete(Boolean isMarkedForDelete) {
172         this.isMarkedForDelete = isMarkedForDelete;
173     }
174
175     /* (non-Javadoc)
176      * @see java.lang.Object#hashCode()
177      */
178     @Override
179     public int hashCode() {
180         final int prime = 31;
181         int result = 1;
182         result = prime * result + ((portSecurityEnabled == null) ? 0 : portSecurityEnabled.hashCode());
183         result = prime * result + ((dpId == null) ? 0 : dpId.hashCode());
184         result = prime * result + ((interfaceId == null) ? 0 : interfaceId.hashCode());
185         result = prime * result + ((lportTag == null) ? 0 : lportTag.hashCode());
186         result = prime * result + ((securityGroups == null) ? 0 : securityGroups.hashCode());
187         result = prime * result + ((allowedAddressPairs == null) ? 0 : allowedAddressPairs.hashCode());
188         result = prime * result + ((isMarkedForDelete == null) ? 0 : isMarkedForDelete.hashCode());
189         return result;
190     }
191
192     /* (non-Javadoc)
193      * @see java.lang.Object#equals(java.lang.Object)
194      */
195     @Override
196     public boolean equals(Object obj) {
197         if (this == obj) {
198             return true;
199         }
200         if (obj == null) {
201             return false;
202         }
203         if (getClass() != obj.getClass()) {
204             return false;
205         }
206         AclInterface other = (AclInterface) obj;
207         if (portSecurityEnabled == null) {
208             if (other.portSecurityEnabled != null) {
209                 return false;
210             }
211         } else if (!portSecurityEnabled.equals(other.portSecurityEnabled)) {
212             return false;
213         }
214         if (dpId == null) {
215             if (other.dpId != null) {
216                 return false;
217             }
218         } else if (!dpId.equals(other.dpId)) {
219             return false;
220         }
221         if (interfaceId == null) {
222             if (other.interfaceId != null) {
223                 return false;
224             }
225         } else if (!interfaceId.equals(other.interfaceId)) {
226             return false;
227         }
228         if (lportTag == null) {
229             if (other.lportTag != null) {
230                 return false;
231             }
232         } else if (!lportTag.equals(other.lportTag)) {
233             return false;
234         }
235         if (securityGroups == null) {
236             if (other.securityGroups != null) {
237                 return false;
238             }
239         } else if (!securityGroups.equals(other.securityGroups)) {
240             return false;
241         }
242         if (allowedAddressPairs == null) {
243             if (other.allowedAddressPairs != null) {
244                 return false;
245             }
246         } else if (!allowedAddressPairs.equals(other.allowedAddressPairs)) {
247             return false;
248         }
249         if (isMarkedForDelete == null) {
250             if (other.isMarkedForDelete != null) {
251                 return false;
252             }
253         } else if (!isMarkedForDelete.equals(other.isMarkedForDelete)) {
254             return false;
255         }
256         return true;
257     }
258
259     /* (non-Javadoc)
260      * @see java.lang.Object#toString()
261      */
262     @Override
263     public String toString() {
264         return "AclInterface [portSecurityEnabled=" + portSecurityEnabled + ", interfaceId=" + interfaceId
265                 + ", lportTag=" + lportTag + ", dpId=" + dpId + ", securityGroups=" + securityGroups
266                 + ", allowedAddressPairs=" + allowedAddressPairs + ", isMarkedForDelete=" + isMarkedForDelete + "]";
267     }
268 }