Use a switch expression 72/101272/1
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 24 May 2022 12:20:43 +0000 (14:20 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Tue, 24 May 2022 12:20:43 +0000 (14:20 +0200)
This is just an auto-conversion to use a switch expression to initialize
initial index.

Change-Id: Ic7ed21aef2cf6a4c20733f0400163bfbf25c3a9e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
common/yang-common/src/main/java/org/opendaylight/yangtools/yang/common/Decimal64.java

index d6b891ae0ff968cb81e9b13fb72a25c3e34211c6..bbf66fd22cc6b54e49653cd14c426a90d7f0692f 100644 (file)
@@ -48,21 +48,20 @@ public class Decimal64 extends Number implements CanonicalValue<Decimal64> {
 
             // Deal with optional sign
             final boolean negative;
-            int idx;
-            switch (str.charAt(0)) {
-                case '-':
+            int idx = switch (str.charAt(0)) {
+                case '-' -> {
                     negative = true;
-                    idx = 1;
-                    break;
-                case '+':
+                    yield 1;
+                }
+                case '+' -> {
                     negative = false;
-                    idx = 1;
-                    break;
-                default:
+                    yield 1;
+                }
+                default -> {
                     negative = false;
-                    idx = 0;
-            }
-
+                    yield 0;
+                }
+            };
             // Sanity check length
             if (idx == str.length()) {
                 return CanonicalValueViolation.variantOf("Missing digits after sign");