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.mappers;
10 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
12 import java.util.ArrayList;
13 import java.util.HashMap;
14 import java.util.List;
17 * Created by Shakib Ahmed on 5/26/17.
19 public class InterfaceNameToRouteInfoMapper {
20 HashMap<String, StaticRouteInfoMapper> interfaceNameToStaticRouteMapper;
22 public InterfaceNameToRouteInfoMapper() {
23 interfaceNameToStaticRouteMapper = new HashMap<>();
26 public boolean routeAlreadyExists(String interfaceName, Ipv4Address ip) {
27 StaticRouteInfoMapper staticRouteInfoMapper = interfaceNameToStaticRouteMapper.get(interfaceName);
29 if (staticRouteInfoMapper == null) {
33 return staticRouteInfoMapper.routeWithIpExists(ip);
36 public void addRouteForInterface(String interfaceName, Ipv4Address ip, Long routeId) {
37 StaticRouteInfoMapper staticRouteInfoMapper = interfaceNameToStaticRouteMapper.get(interfaceName);
39 if (staticRouteInfoMapper == null) {
40 staticRouteInfoMapper = new StaticRouteInfoMapper();
41 interfaceNameToStaticRouteMapper.put(interfaceName, staticRouteInfoMapper);
44 staticRouteInfoMapper.addIpRouteForInterface(ip, routeId);
47 public List<Long> getRoutingIdsAssociatedWithInterface(String interfaceName) {
48 StaticRouteInfoMapper staticRouteInfoMapper = interfaceNameToStaticRouteMapper.get(interfaceName);
50 return staticRouteInfoMapper == null ? new ArrayList<>() : staticRouteInfoMapper.getAllRoutingIds();
53 public void clearStaticRoutesForInterface(String interfaceName) {
54 interfaceNameToStaticRouteMapper.remove(interfaceName);