2 * Copyright (c) 2017 Cisco Systems. 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.groupbasedpolicy.renderer.vpp.lisp.info.container.states;
10 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
11 import org.slf4j.Logger;
12 import org.slf4j.LoggerFactory;
14 import java.util.HashSet;
18 * Created by Shakib Ahmed on 7/17/17.
20 public class SubnetState {
21 private String gwInterfaceName;
22 private Set<Ipv4Address> ipsInSubnet;
24 private static final Logger LOG = LoggerFactory.getLogger(SubnetState.class);
27 public SubnetState() {
28 ipsInSubnet = new HashSet<>();
31 public boolean isGwConfigured() {
32 return gwInterfaceName != null && !gwInterfaceName.isEmpty();
35 public String getGwInterfaceName() {
36 return gwInterfaceName;
39 public void setGwInterfaceName(String gwInterfaceName) {
40 this.gwInterfaceName = gwInterfaceName;
43 public boolean hasIpsInSubnet() {
44 return !ipsInSubnet.isEmpty();
47 public void addNewIp(Ipv4Address portIp) {
48 ipsInSubnet.add(portIp);
49 LOG.trace("SubnetState -> added IP: {} to SubnetState: {}", portIp, this);
52 public boolean isIpPresent(Ipv4Address portIp) {
53 return ipsInSubnet.contains(portIp);
56 public void removeIp(Ipv4Address portIp) {
57 ipsInSubnet.remove(portIp);
58 LOG.trace("SubnetState -> removed IP: {} from SubnetState: {}", portIp, this);
61 public Set<Ipv4Address> getIpsInSubnet() {
65 @Override public String toString() {
66 return "SubnetState{" + "gwInterfaceName='" + gwInterfaceName + '\'' + ", ipsInSubnet=" + ipsInSubnet + '}';