Use switch expressions where appropriate 29/102829/2
authorRobert Varga <robert.varga@pantheon.tech>
Fri, 21 Oct 2022 12:36:59 +0000 (14:36 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Fri, 21 Oct 2022 12:44:51 +0000 (14:44 +0200)
We have Java 17, we can simplify things a bit.

Change-Id: I2134fb21e02024d570bebb0e141de3990a7950df
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
bundles-test-lib/src/main/java/org/opendaylight/odlparent/bundlestest/lib/BundleDiagInfosImpl.java
karaf-util/src/main/java/org/opendaylight/odlparent/karafutil/CustomBundleUrlStreamHandlerFactory.java

index 48f5c2ea1675254f5428e750f909bd728b9bf17c..eb3e1df0d2d316febda9d79979206f5ec95800a9 100644 (file)
@@ -123,22 +123,15 @@ final class BundleDiagInfosImpl implements BundleDiagInfos {
     }
 
     private static String bundleStateToText(int state) {
-        switch (state) {
-            case Bundle.INSTALLED:
-                return "Installed";
-            case Bundle.RESOLVED:
-                return "Resolved";
-            case Bundle.STARTING:
-                return "Starting";
-            case Bundle.ACTIVE:
-                return "Active";
-            case Bundle.STOPPING:
-                return "Stopping";
-            case Bundle.UNINSTALLED:
-                return "Uninstalled";
-            default:
-                return state + "???";
-        }
+        return switch (state) {
+            case Bundle.INSTALLED -> "Installed";
+            case Bundle.RESOLVED -> "Resolved";
+            case Bundle.STARTING -> "Starting";
+            case Bundle.ACTIVE -> "Active";
+            case Bundle.STOPPING -> "Stopping";
+            case Bundle.UNINSTALLED -> "Uninstalled";
+            default -> state + "???";
+        };
     }
 
     @Override
index 7c359b989534da1a1bb450f6b70284000a482c08..643922fab23df474d032cb98c1dbe6a1fe4ee43e 100644 (file)
@@ -33,17 +33,12 @@ public class CustomBundleUrlStreamHandlerFactory implements URLStreamHandlerFact
 
     @Override
     public URLStreamHandler createURLStreamHandler(String protocol) {
-        switch (protocol) {
-            case MVN_URI_PREFIX:
-                return new org.ops4j.pax.url.mvn.Handler();
-            case WRAP_URI_PREFIX:
-                return new org.ops4j.pax.url.wrap.Handler();
-            case FEATURE_URI_PREFIX:
-                return new FeatureURLHandler();
-            case BLUEPRINT_URI_PREFIX:
-                return new BlueprintURLHandler();
-            default:
-                return null;
-        }
+        return switch (protocol) {
+            case MVN_URI_PREFIX -> new org.ops4j.pax.url.mvn.Handler();
+            case WRAP_URI_PREFIX -> new org.ops4j.pax.url.wrap.Handler();
+            case FEATURE_URI_PREFIX -> new FeatureURLHandler();
+            case BLUEPRINT_URI_PREFIX -> new BlueprintURLHandler();
+            default -> null;
+        };
     }
 }