KeyMapping is immutable
[bgpcep.git] / bmp / bmp-impl / src / main / java / org / opendaylight / protocol / bmp / impl / app / KeyConstructorUtil.java
diff --git a/bmp/bmp-impl/src/main/java/org/opendaylight/protocol/bmp/impl/app/KeyConstructorUtil.java b/bmp/bmp-impl/src/main/java/org/opendaylight/protocol/bmp/impl/app/KeyConstructorUtil.java
deleted file mode 100644 (file)
index 44c0b05..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (c) 2017 Pantheon Technologies s.r.o. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.protocol.bmp.impl.app;
-
-import java.nio.charset.StandardCharsets;
-import java.util.Collection;
-import java.util.Objects;
-import org.opendaylight.protocol.concepts.KeyMapping;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IetfInetUtil;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.config.rev200120.odl.bmp.monitors.bmp.monitor.config.MonitoredRouter;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.rfc2385.cfg.rev160324.Rfc2385Key;
-
-public final class KeyConstructorUtil {
-    private KeyConstructorUtil() {
-        // Hidden on purpose
-    }
-
-    public static KeyMapping constructKeys(final Collection<MonitoredRouter> mrs) {
-        final KeyMapping ret = KeyMapping.getKeyMapping();
-        if (mrs != null) {
-            mrs.stream().filter(Objects::nonNull).filter(KeyConstructorUtil::isNotNullorEmpty)
-                .forEach(mr -> {
-                    final Rfc2385Key rfc2385KeyPassword = mr.getPassword();
-                    ret.put(IetfInetUtil.INSTANCE.inetAddressForNoZone(mr.getAddress()),
-                        rfc2385KeyPassword.getValue().getBytes(StandardCharsets.US_ASCII));
-                });
-        }
-
-        return ret;
-    }
-
-    private static boolean isNotNullorEmpty(final MonitoredRouter mr) {
-        final Rfc2385Key password = mr.getPassword();
-        return password != null && !password.getValue().isEmpty();
-    }
-}