Add implementation for flat L3 overlay
[groupbasedpolicy.git] / renderers / vpp / src / main / java / org / opendaylight / groupbasedpolicy / renderer / vpp / lisp / mappers / StaticRouteInfoMapper.java
1 /*
2  * Copyright (c) 2017 Cisco Systems. 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.groupbasedpolicy.renderer.vpp.lisp.mappers;
9
10 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
11
12 import java.util.HashMap;
13 import java.util.List;
14 import java.util.stream.Collectors;
15
16 /**
17  * Created by Shakib Ahmed on 5/26/17.
18  */
19 public class StaticRouteInfoMapper {
20     HashMap<Ipv4Address, Long> interfaceIpToRouteIdMapper;
21
22     public StaticRouteInfoMapper() {
23         interfaceIpToRouteIdMapper = new HashMap<>();
24     }
25
26     public void addIpRouteForInterface(Ipv4Address ip, Long routingId) {
27         interfaceIpToRouteIdMapper.put(ip, routingId);
28     }
29
30     public boolean routeWithIpExists(Ipv4Address ip) {
31         return interfaceIpToRouteIdMapper.containsKey(ip);
32     }
33
34     public Long getRouteIdForIp(Ipv4Address ip) {
35         return interfaceIpToRouteIdMapper.get(ip);
36     }
37
38     public List<Long> getAllRoutingIds() {
39         return interfaceIpToRouteIdMapper.entrySet()
40                 .stream()
41                 .map(ipv4AddressLongEntry -> ipv4AddressLongEntry.getValue())
42                 .collect(Collectors.toList());
43     }
44 }