From fa06b70897623ee5f6576c2d510cf69e4f9a0a27 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Tue, 14 Feb 2023 10:15:40 +0100 Subject: [PATCH] Use a switch expression to dispatch keys This makes the code flow more obvious. Change-Id: I112da7aa2d1950e45bad8bac3e87126c47300f86 Signed-off-by: Robert Varga (cherry picked from commit 0ca412d7387be08bc904fc5f2cc96c9f2001204f) --- .../org/opendaylight/aaa/encrypt/PKIUtil.java | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/aaa-encrypt-service/api/src/main/java/org/opendaylight/aaa/encrypt/PKIUtil.java b/aaa-encrypt-service/api/src/main/java/org/opendaylight/aaa/encrypt/PKIUtil.java index 282cb4ee7..97c5b067a 100644 --- a/aaa-encrypt-service/api/src/main/java/org/opendaylight/aaa/encrypt/PKIUtil.java +++ b/aaa-encrypt-service/api/src/main/java/org/opendaylight/aaa/encrypt/PKIUtil.java @@ -104,19 +104,12 @@ public class PKIUtil { pos = 0; String type = decodeType(); - if (type.equals(KEY_TYPE_RSA)) { - return decodeAsRSA(); - } - - if (type.equals(KEY_TYPE_DSA)) { - return decodeAsDSA(); - } - - if (type.equals(KEY_TYPE_ECDSA)) { - return decodeAsECDSA(); - } - - throw new IllegalArgumentException("Unknown decode key type " + type + " in " + keyLine); + return switch (type) { + case KEY_TYPE_RSA -> decodeAsRSA(); + case KEY_TYPE_DSA -> decodeAsDSA(); + case KEY_TYPE_ECDSA -> decodeAsECDSA(); + default -> throw new IllegalArgumentException("Unknown decode key type " + type + " in " + keyLine); + }; } @SuppressWarnings("AbbreviationAsWordInName") -- 2.36.6