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.groupbasedpolicy.renderer.vpp.lisp.InterfaceInfo;
11 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
13 import java.util.HashMap;
16 * Created by Shakib Ahmed on 6/23/17.
18 public class HostIdToInterfaceInfoMapper {
20 public enum InterfaceType {
24 HashMap<String, HashMap<InterfaceType, InterfaceInfo>> hostIdToInterfaceInfoMapper;
26 private HostIdToInterfaceInfoMapper() {
27 hostIdToInterfaceInfoMapper = new HashMap<>();
30 private static final HostIdToInterfaceInfoMapper INSTANCE = new HostIdToInterfaceInfoMapper();
32 public static HostIdToInterfaceInfoMapper getInstance() {
36 public void addInterfaceInfo(String hostId,
37 InterfaceType interfaceType,
39 IpAddress interfaceIp) {
40 HashMap<InterfaceType, InterfaceInfo> typeToInterfaceInfoMapper =
41 hostIdToInterfaceInfoMapper.computeIfAbsent(hostId, id -> new HashMap<>());
43 typeToInterfaceInfoMapper.put(interfaceType, new InterfaceInfo(interfaceName, interfaceIp));
46 public InterfaceInfo getInterfaceInfo(String hostId, InterfaceType interfaceType) {
48 if (!hostIdToInterfaceInfoMapper.containsKey(hostId)) {
52 return hostIdToInterfaceInfoMapper.get(hostId).get(interfaceType);