Use switch expression in yang-parser-impl 39/101339/4
authorRobert Varga <robert.varga@pantheon.tech>
Sun, 29 May 2022 20:39:38 +0000 (22:39 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Sun, 29 May 2022 21:36:27 +0000 (23:36 +0200)
A switch is more expressive, use it for initialization of reference
factory.

Change-Id: Ic2b9d2dd890c02f2189c632c8e1909cf62326c0e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
parser/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/repo/SharedEffectiveModelContextFactory.java

index a3f70814c6998aeae6297b0560d6eaa36ddc0a4d..3dcd0ec6f0a4ae549a439fc79699d05e88361ac7 100644 (file)
@@ -60,18 +60,15 @@ final class SharedEffectiveModelContextFactory implements EffectiveModelContextF
             }
 
             String prop = System.getProperty("org.opendaylight.yangtools.yang.parser.repo.shared-refs", "weak");
-            switch (prop) {
-                case "soft":
-                    REF = SoftReference::new;
-                    break;
-                case "weak":
-                    REF = WeakReference::new;
-                    break;
-                default:
+            REF = switch (prop) {
+                case "soft" -> SoftReference::new;
+                case "weak" -> WeakReference::new;
+                default -> {
                     LOG.warn("Invalid shared-refs \"{}\", defaulting to weak references", prop);
                     prop = "weak";
-                    REF = WeakReference::new;
-            }
+                    yield WeakReference::new;
+                }
+            };
             LOG.info("Using {} references", prop);
         }
 
@@ -119,7 +116,7 @@ final class SharedEffectiveModelContextFactory implements EffectiveModelContextF
     SharedEffectiveModelContextFactory(final @NonNull SharedSchemaRepository repository,
             final @NonNull SchemaContextFactoryConfiguration config) {
         this.repository = requireNonNull(repository);
-        this.assembleSources = new AssembleSources(repository.factory(), config);
+        assembleSources = new AssembleSources(repository.factory(), config);
 
     }