2 * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
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
8 package org.opendaylight.netvirt.aclservice.api.utils;
10 import com.google.common.collect.ImmutableList;
11 import java.math.BigInteger;
12 import java.util.List;
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.IpPrefixOrAddress;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.interfaces._interface.AllowedAddressPairs;
18 * The Class AclInterface.
20 public final class AclInterface {
22 /** The port security enabled. */
23 private final boolean portSecurityEnabled;
25 /** The interface id. */
26 private final String interfaceId;
28 /** The l port tag. */
29 private final Integer lportTag;
32 private final BigInteger dpId;
34 /** Elan tag of the interface. */
35 private final Long elanId;
37 /** VPN Id of the interface. */
38 private final Long vpnId;
40 /** The security groups. */
41 private final List<Uuid> securityGroups;
43 /** The allowed address pairs. */
44 private final List<AllowedAddressPairs> allowedAddressPairs;
46 /** The IP broadcast CIDRs. */
47 private final List<IpPrefixOrAddress> subnetIpPrefixes;
49 /** The port is marked for delete. */
50 private volatile boolean isMarkedForDelete;
52 private AclInterface(Builder builder) {
53 this.portSecurityEnabled = builder.portSecurityEnabled;
54 this.interfaceId = builder.interfaceId;
55 this.lportTag = builder.lportTag;
56 this.dpId = builder.dpId;
57 this.elanId = builder.elanId;
58 this.vpnId = builder.vpnId;
59 this.securityGroups = builder.securityGroups;
60 this.allowedAddressPairs = builder.allowedAddressPairs;
61 this.subnetIpPrefixes = builder.subnetIpPrefixes;
62 this.isMarkedForDelete = builder.isMarkedForDelete;
66 * Checks if is port security enabled.
70 public boolean isPortSecurityEnabled() {
71 return portSecurityEnabled;
75 * Gets the interface id.
77 * @return the interface id
79 public String getInterfaceId() {
84 * Gets the l port tag.
86 * @return the l port tag
88 public Integer getLPortTag() {
97 public BigInteger getDpId() {
104 * @return elan id of the interface
106 public Long getElanId() {
113 * @return VPN Id of the interface
115 public Long getVpnId() {
120 * Gets the security groups.
122 * @return the security groups
124 public List<Uuid> getSecurityGroups() {
125 return securityGroups;
129 * Gets the allowed address pairs.
131 * @return the allowed address pairs
133 public List<AllowedAddressPairs> getAllowedAddressPairs() {
134 return allowedAddressPairs;
138 * Gets the Subnet IP Prefix.
140 * @return the Subnet IP Prefix
142 public List<IpPrefixOrAddress> getSubnetIpPrefixes() {
143 return subnetIpPrefixes;
147 * Retrieve isMarkedForDelete.
148 * @return the whether it is marked for delete
150 public boolean isMarkedForDelete() {
151 return isMarkedForDelete;
155 * Sets isMarkedForDelete.
156 * @param isMarkedForDelete boolean value
158 public void setIsMarkedForDelete(boolean isMarkedForDelete) {
159 this.isMarkedForDelete = isMarkedForDelete;
163 * @see java.lang.Object#hashCode()
166 public int hashCode() {
167 final int prime = 31;
169 result = prime * result + Boolean.hashCode(portSecurityEnabled);
170 result = prime * result + (dpId == null ? 0 : dpId.hashCode());
171 result = prime * result + (interfaceId == null ? 0 : interfaceId.hashCode());
172 result = prime * result + (lportTag == null ? 0 : lportTag.hashCode());
173 result = prime * result + (securityGroups == null ? 0 : securityGroups.hashCode());
174 result = prime * result + (allowedAddressPairs == null ? 0 : allowedAddressPairs.hashCode());
175 result = prime * result + Boolean.hashCode(isMarkedForDelete);
180 * @see java.lang.Object#equals(java.lang.Object)
183 public boolean equals(Object obj) {
190 if (getClass() != obj.getClass()) {
193 AclInterface other = (AclInterface) obj;
194 if (portSecurityEnabled != other.portSecurityEnabled) {
198 if (other.dpId != null) {
201 } else if (!dpId.equals(other.dpId)) {
204 if (interfaceId == null) {
205 if (other.interfaceId != null) {
208 } else if (!interfaceId.equals(other.interfaceId)) {
211 if (lportTag == null) {
212 if (other.lportTag != null) {
215 } else if (!lportTag.equals(other.lportTag)) {
218 if (securityGroups == null) {
219 if (other.securityGroups != null) {
222 } else if (!securityGroups.equals(other.securityGroups)) {
225 if (allowedAddressPairs == null) {
226 if (other.allowedAddressPairs != null) {
229 } else if (!allowedAddressPairs.equals(other.allowedAddressPairs)) {
232 if (isMarkedForDelete != other.isMarkedForDelete) {
240 public String toString() {
241 return "AclInterface [interfaceId=" + interfaceId + ", lportTag=" + lportTag + ", dpId=" + dpId + ", elanId="
242 + elanId + ", vpnId=" + vpnId + ", securityGroups=" + securityGroups + ", allowedAddressPairs="
243 + allowedAddressPairs + ", subnetIpPrefixes=" + subnetIpPrefixes + ", portSecurityEnabled="
244 + portSecurityEnabled + ", isMarkedForDelete=" + isMarkedForDelete + "]";
247 public static Builder builder() {
248 return new Builder();
251 public static Builder builder(AclInterface from) {
252 return new Builder(from);
255 public static final class Builder {
256 private boolean portSecurityEnabled;
257 private String interfaceId;
258 private Integer lportTag;
259 private BigInteger dpId;
262 private List<Uuid> securityGroups;
263 private List<AllowedAddressPairs> allowedAddressPairs;
264 private List<IpPrefixOrAddress> subnetIpPrefixes;
265 private boolean isMarkedForDelete;
270 private Builder(AclInterface from) {
271 this.portSecurityEnabled = from.portSecurityEnabled;
272 this.interfaceId = from.interfaceId;
273 this.lportTag = from.lportTag;
274 this.dpId = from.dpId;
275 this.elanId = from.elanId;
276 this.vpnId = from.vpnId;
277 this.securityGroups = from.securityGroups;
278 this.allowedAddressPairs = from.allowedAddressPairs;
279 this.subnetIpPrefixes = from.subnetIpPrefixes;
280 this.isMarkedForDelete = from.isMarkedForDelete;
283 public Builder portSecurityEnabled(boolean value) {
284 this.portSecurityEnabled = value;
288 public Builder interfaceId(String value) {
289 this.interfaceId = value;
293 public Builder lPortTag(Integer value) {
294 this.lportTag = value;
298 public Builder dpId(BigInteger value) {
303 public Builder elanId(Long value) {
308 public Builder vpnId(Long value) {
313 public Builder securityGroups(List<Uuid> list) {
314 this.securityGroups = list == null ? null : ImmutableList.copyOf(list);
318 public Builder allowedAddressPairs(List<AllowedAddressPairs> list) {
319 this.allowedAddressPairs = list == null ? null : ImmutableList.copyOf(list);
323 public Builder subnetIpPrefixes(List<IpPrefixOrAddress> list) {
324 this.subnetIpPrefixes = list == null ? null : ImmutableList.copyOf(list);
328 public Builder isMarkedForDelete(boolean value) {
329 this.isMarkedForDelete = value;
333 public AclInterface build() {
334 return new AclInterface(this);