Clean up CompactTokenFactory.create() 14/103414/1
authorRobert Varga <robert.varga@pantheon.tech>
Sat, 26 Nov 2022 10:01:56 +0000 (11:01 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Sat, 26 Nov 2022 10:01:56 +0000 (11:01 +0100)
Sonar is pointing out mergeable if statements, let's do that.

Change-Id: I6f4ca5b8da3a406f693ff246a9eb1f2bd73af33c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
parser/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/antlr/CompactTokenFactory.java

index 598be06ee8d4719a6a42d28a0037f6245f0c0138..67324bf4fd0f9c18e0e57e2ccff9380add8addda 100644 (file)
@@ -36,18 +36,15 @@ final class CompactTokenFactory implements TokenFactory<Token> {
         }
 
         // Can we fit token type into a single byte? This should always be true
-        if (type >= Byte.MIN_VALUE && type <= Byte.MAX_VALUE) {
+        if (type >= Byte.MIN_VALUE && type <= Byte.MAX_VALUE
             // Can we fit line in an unsigned short? This is usually be true
-            if (line >= 0 && line <= 65535) {
-                // Can we fit position in line into an unsigned byte? This is usually true
-                if (charPositionInLine >= 0 && charPositionInLine <= 255) {
-                    // Can we fit start/stop into an an unsigned short?
-                    if (start >= 0 && start <= 65535 && stop >= 0 && stop <= 65535) {
-                        return new Token12122(source, type, line, charPositionInLine, start, stop);
-                    }
-                    return new Token12144(source, type, line, charPositionInLine, start, stop);
-                }
-            }
+             && line >= 0 && line <= 65535
+             // Can we fit position in line into an unsigned byte? This is usually true
+             && charPositionInLine >= 0 && charPositionInLine <= 255) {
+            // Can we fit start/stop into an an unsigned short?
+            return start >= 0 && start <= 65535 && stop >= 0 && stop <= 65535
+                ? new Token12122(source, type, line, charPositionInLine, start, stop)
+                    : new Token12144(source, type, line, charPositionInLine, start, stop);
         }
 
         return new Token44444(source, type, line, charPositionInLine, start, stop);