BUG-6647 Increase code coverage and clean up II
[bgpcep.git] / concepts / src / main / java / org / opendaylight / protocol / concepts / KeyMapping.java
1 /*
2  * Copyright (c) 2016 AT&T Services, Inc. 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.protocol.concepts;
9
10 import static com.google.common.base.Strings.isNullOrEmpty;
11
12 import java.net.InetAddress;
13 import java.nio.charset.StandardCharsets;
14 import java.util.HashMap;
15 import javax.annotation.Nonnull;
16 import javax.annotation.Nullable;
17
18 public final class KeyMapping extends HashMap<InetAddress, byte[]> {
19     private static final long serialVersionUID = 1L;
20
21     private KeyMapping() {
22         super();
23     }
24
25     public static KeyMapping getKeyMapping(@Nonnull final InetAddress inetAddress, @Nullable final String password){
26         if (!isNullOrEmpty(password)) {
27             final KeyMapping keyMapping = new KeyMapping();
28             keyMapping.put(inetAddress, password.getBytes(StandardCharsets.US_ASCII));
29             return keyMapping;
30         }
31         return null;
32     }
33
34     public static KeyMapping getKeyMapping(){
35         final KeyMapping keyMapping = new KeyMapping();
36         return keyMapping;
37     }
38 }