Simplify overlay information mappers and managers
[groupbasedpolicy.git] / renderers / vpp / src / main / java / org / opendaylight / groupbasedpolicy / renderer / vpp / lisp / info / container / states / RouteState.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.info.container.states;
9
10 import java.util.ArrayList;
11 import java.util.HashMap;
12 import java.util.List;
13
14 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
15
16 /**
17  * Created by Shakib Ahmed on 7/17/17.
18  */
19 public class RouteState {
20     private HashMap<Ipv4Address, Long> ipToRouteIdMapper;
21
22     public RouteState() {
23         ipToRouteIdMapper = new HashMap<>();
24     }
25
26     public boolean ipExists(Ipv4Address ip) {
27         return ipToRouteIdMapper.containsKey(ip);
28     }
29
30     public void addIpToRouteIdInfo(Ipv4Address ip, Long routeId) {
31         ipToRouteIdMapper.put(ip, routeId);
32     }
33
34     public long getRouteId(Ipv4Address ip) {
35         return ipToRouteIdMapper.get(ip);
36     }
37
38     public void removeIp(Ipv4Address ip) {
39         ipToRouteIdMapper.remove(ip);
40     }
41
42     public boolean hasNoIpRoutes() {
43         return ipToRouteIdMapper.isEmpty();
44     }
45
46     public List<Ipv4Address> getAllIps() {
47         return new ArrayList<>(ipToRouteIdMapper.keySet());
48     }
49 }