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 com.google.common.collect.ImmutableSortedSet;
12 import java.math.BigInteger;
13 import java.util.List;
14 import java.util.SortedSet;
15 import org.eclipse.jdt.annotation.Nullable;
16 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.interfaces._interface.AllowedAddressPairs;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.interfaces._interface.SubnetInfo;
21 * The Class AclInterface.
23 public final class AclInterface {
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 /** The port security enabled. */
38 private final boolean portSecurityEnabled;
40 /** The security groups. */
41 private final List<Uuid> securityGroups;
43 /** The allowed address pairs. */
44 private final List<AllowedAddressPairs> allowedAddressPairs;
46 /** List to contain subnet IP CIDRs along with subnet gateway IP. */
47 List<SubnetInfo> subnetInfo;
49 /** The ingress remote acl tags. */
50 private final SortedSet<Integer> ingressRemoteAclTags;
52 /** The egress remote acl tags. */
53 private final SortedSet<Integer> egressRemoteAclTags;
55 /** The port is marked for delete. */
56 private volatile boolean isMarkedForDelete;
58 private AclInterface(Builder builder) {
59 this.interfaceId = builder.interfaceId;
60 this.lportTag = builder.lportTag;
61 this.dpId = builder.dpId;
62 this.elanId = builder.elanId;
63 this.portSecurityEnabled = builder.portSecurityEnabled;
64 this.securityGroups = builder.securityGroups;
65 this.allowedAddressPairs = builder.allowedAddressPairs;
66 this.subnetInfo = builder.subnetInfo;
67 this.ingressRemoteAclTags = builder.ingressRemoteAclTags;
68 this.egressRemoteAclTags = builder.egressRemoteAclTags;
69 this.isMarkedForDelete = builder.isMarkedForDelete;
73 * Checks if is port security enabled.
77 public boolean isPortSecurityEnabled() {
78 return portSecurityEnabled;
82 * Gets the interface id.
84 * @return the interface id
86 public String getInterfaceId() {
91 * Gets the l port tag.
93 * @return the l port tag
95 public Integer getLPortTag() {
104 public BigInteger getDpId() {
111 * @return elan id of the interface
113 public Long getElanId() {
118 * Gets the security groups.
120 * @return the security groups
122 public List<Uuid> getSecurityGroups() {
123 return securityGroups;
127 * Gets the allowed address pairs.
129 * @return the allowed address pairs
131 public List<AllowedAddressPairs> getAllowedAddressPairs() {
132 return allowedAddressPairs;
136 * Gets the Subnet info.
138 * @return the Subnet info
140 public List<SubnetInfo> getSubnetInfo() {
145 * Gets the egress remote acl tags.
147 * @return the egress remote acl tags
149 public SortedSet<Integer> getEgressRemoteAclTags() {
150 return egressRemoteAclTags;
154 * Gets the ingress remote acl tags.
156 * @return the ingress remote acl tags
158 public SortedSet<Integer> getIngressRemoteAclTags() {
159 return ingressRemoteAclTags;
163 * Retrieve isMarkedForDelete.
164 * @return the whether it is marked for delete
166 public boolean isMarkedForDelete() {
167 return isMarkedForDelete;
171 * Sets isMarkedForDelete.
172 * @param isMarkedForDelete boolean value
174 public void setIsMarkedForDelete(boolean isMarkedForDelete) {
175 this.isMarkedForDelete = isMarkedForDelete;
179 * @see java.lang.Object#hashCode()
182 public int hashCode() {
183 final int prime = 31;
185 result = prime * result + Boolean.hashCode(portSecurityEnabled);
186 result = prime * result + (dpId == null ? 0 : dpId.hashCode());
187 result = prime * result + (interfaceId == null ? 0 : interfaceId.hashCode());
188 result = prime * result + (lportTag == null ? 0 : lportTag.hashCode());
189 result = prime * result + (securityGroups == null ? 0 : securityGroups.hashCode());
190 result = prime * result + (allowedAddressPairs == null ? 0 : allowedAddressPairs.hashCode());
191 result = prime * result + Boolean.hashCode(isMarkedForDelete);
196 * @see java.lang.Object#equals(java.lang.Object)
199 public boolean equals(Object obj) {
206 if (getClass() != obj.getClass()) {
209 AclInterface other = (AclInterface) obj;
210 if (portSecurityEnabled != other.portSecurityEnabled) {
214 if (other.dpId != null) {
217 } else if (!dpId.equals(other.dpId)) {
220 if (interfaceId == null) {
221 if (other.interfaceId != null) {
224 } else if (!interfaceId.equals(other.interfaceId)) {
227 if (lportTag == null) {
228 if (other.lportTag != null) {
231 } else if (!lportTag.equals(other.lportTag)) {
234 if (securityGroups == null) {
235 if (other.securityGroups != null) {
238 } else if (!securityGroups.equals(other.securityGroups)) {
241 if (allowedAddressPairs == null) {
242 if (other.allowedAddressPairs != null) {
245 } else if (!allowedAddressPairs.equals(other.allowedAddressPairs)) {
248 if (isMarkedForDelete != other.isMarkedForDelete) {
255 public String toString() {
256 return "AclInterface [interfaceId=" + interfaceId + ", lportTag=" + lportTag + ", dpId=" + dpId + ", elanId="
257 + elanId + ", portSecurityEnabled=" + portSecurityEnabled + ", securityGroups=" + securityGroups
258 + ", allowedAddressPairs=" + allowedAddressPairs + ", subnetInfo=" + subnetInfo
259 + ", ingressRemoteAclTags=" + ingressRemoteAclTags + ", egressRemoteAclTags=" + egressRemoteAclTags
260 + ", isMarkedForDelete=" + isMarkedForDelete + "]";
263 public static Builder builder() {
264 return new Builder();
267 public static Builder builder(AclInterface from) {
268 return new Builder(from);
271 public static final class Builder {
272 private String interfaceId;
273 private Integer lportTag;
274 private BigInteger dpId;
276 private boolean portSecurityEnabled;
277 private @Nullable List<Uuid> securityGroups;
278 private @Nullable List<AllowedAddressPairs> allowedAddressPairs;
279 private @Nullable List<SubnetInfo> subnetInfo;
280 private @Nullable SortedSet<Integer> ingressRemoteAclTags;
281 private @Nullable SortedSet<Integer> egressRemoteAclTags;
282 private boolean isMarkedForDelete;
287 private Builder(AclInterface from) {
288 this.interfaceId = from.interfaceId;
289 this.lportTag = from.lportTag;
290 this.dpId = from.dpId;
291 this.elanId = from.elanId;
292 this.portSecurityEnabled = from.portSecurityEnabled;
293 this.securityGroups = from.securityGroups;
294 this.allowedAddressPairs = from.allowedAddressPairs;
295 this.subnetInfo = from.subnetInfo;
296 this.ingressRemoteAclTags = from.ingressRemoteAclTags;
297 this.egressRemoteAclTags = from.egressRemoteAclTags;
298 this.isMarkedForDelete = from.isMarkedForDelete;
301 public Builder portSecurityEnabled(boolean value) {
302 this.portSecurityEnabled = value;
306 public Builder interfaceId(String value) {
307 this.interfaceId = value;
311 public Builder lPortTag(Integer value) {
312 this.lportTag = value;
316 public Builder dpId(BigInteger value) {
321 public Builder elanId(Long value) {
326 public Builder securityGroups(@Nullable List<Uuid> list) {
327 this.securityGroups = list == null ? null : ImmutableList.copyOf(list);
331 public Builder allowedAddressPairs(@Nullable List<AllowedAddressPairs> list) {
332 this.allowedAddressPairs = list == null ? null : ImmutableList.copyOf(list);
336 public Builder subnetInfo(@Nullable List<SubnetInfo> list) {
337 this.subnetInfo = list == null ? null : ImmutableList.copyOf(list);
341 public Builder ingressRemoteAclTags(@Nullable SortedSet<Integer> list) {
342 this.ingressRemoteAclTags = list == null ? null : ImmutableSortedSet.copyOf(list);
346 public Builder egressRemoteAclTags(@Nullable SortedSet<Integer> list) {
347 this.egressRemoteAclTags = list == null ? null : ImmutableSortedSet.copyOf(list);
351 public Builder isMarkedForDelete(boolean value) {
352 this.isMarkedForDelete = value;
356 public AclInterface build() {
357 return new AclInterface(this);