Switch to JDT annotations for Nullable and NonNull
[netvirt.git] / dhcpservice / impl / src / main / java / org / opendaylight / netvirt / dhcpservice / DhcpPortCache.java
1 /*
2  * Copyright © 2015, 2018 Ericsson India Global Services Pvt Ltd. and others.  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.netvirt.dhcpservice;
9
10 import java.util.concurrent.ConcurrentHashMap;
11 import javax.annotation.PostConstruct;
12 import javax.inject.Singleton;
13 import org.eclipse.jdt.annotation.NonNull;
14 import org.eclipse.jdt.annotation.Nullable;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.Port;
16 import org.slf4j.Logger;
17 import org.slf4j.LoggerFactory;
18
19 @Singleton
20 public class DhcpPortCache {
21
22     private static final Logger LOG = LoggerFactory.getLogger(DhcpPortCache.class);
23     private final ConcurrentHashMap<String, Port> portMap = new ConcurrentHashMap<>();
24
25     @PostConstruct
26     public void init() {
27         LOG.trace("Initialize DhcpPortCache. ");
28     }
29
30     public  void put(@NonNull  String interfaceName, Port port) {
31         portMap.put(interfaceName, port);
32         LOG.trace("Added the interface {} to DhcpPortCache",interfaceName);
33     }
34
35     @Nullable
36     public Port get(@NonNull String interfaceName) {
37         return portMap.get(interfaceName);
38     }
39
40     public void remove(@NonNull String interfaceName) {
41         portMap.remove(interfaceName);
42     }
43 }