X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=parser%2Fyang-parser-reactor%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fyangtools%2Fyang%2Fparser%2Fstmt%2Freactor%2FStatementContextBase.java;h=d3ce39b693393568559d8179230e902ce683ebe1;hb=fe7aa9a567521a2aac3caf3f1076a263e1cdc6b4;hp=7e4f2bca1b4b0772ce88a797fa210ca9ccc84693;hpb=166d1b0a0ad39931d8fa7bc8e9b5a586dc5d5074;p=yangtools.git diff --git a/parser/yang-parser-reactor/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/StatementContextBase.java b/parser/yang-parser-reactor/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/StatementContextBase.java index 7e4f2bca1b..d3ce39b693 100644 --- a/parser/yang-parser-reactor/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/StatementContextBase.java +++ b/parser/yang-parser-reactor/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/StatementContextBase.java @@ -13,7 +13,6 @@ import static com.google.common.base.Verify.verify; import static com.google.common.base.Verify.verifyNotNull; import static java.util.Objects.requireNonNull; -import com.google.common.base.VerifyException; import com.google.common.collect.ImmutableCollection; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMultimap; @@ -192,18 +191,12 @@ abstract class StatementContextBase, E extends } private static byte historyFlags(final CopyType copyType) { - switch (copyType) { - case ADDED_BY_AUGMENTATION: - return COPY_ADDED_BY_AUGMENTATION; - case ADDED_BY_USES: - return COPY_ADDED_BY_USES; - case ADDED_BY_USES_AUGMENTATION: - return COPY_ADDED_BY_AUGMENTATION | COPY_ADDED_BY_USES; - case ORIGINAL: - return COPY_ORIGINAL; - default: - throw new VerifyException("Unhandled type " + copyType); - } + return switch (copyType) { + case ADDED_BY_AUGMENTATION -> COPY_ADDED_BY_AUGMENTATION; + case ADDED_BY_USES -> COPY_ADDED_BY_USES; + case ADDED_BY_USES_AUGMENTATION -> COPY_ADDED_BY_AUGMENTATION | COPY_ADDED_BY_USES; + case ORIGINAL -> COPY_ORIGINAL; + }; } @Override @@ -805,20 +798,11 @@ abstract class StatementContextBase, E extends if (implicitParent.isPresent()) { result = new UndeclaredStmtCtx(this, implicitParent.orElseThrow(), original, type); - final CopyType childCopyType; - switch (type) { - case ADDED_BY_AUGMENTATION: - childCopyType = CopyType.ORIGINAL; - break; - case ADDED_BY_USES_AUGMENTATION: - childCopyType = CopyType.ADDED_BY_USES; - break; - case ADDED_BY_USES: - case ORIGINAL: - default: - childCopyType = type; - } - + final CopyType childCopyType = switch (type) { + case ADDED_BY_AUGMENTATION -> CopyType.ORIGINAL; + case ADDED_BY_USES_AUGMENTATION -> CopyType.ADDED_BY_USES; + case ADDED_BY_USES, ORIGINAL -> type; + }; copy = new InferredStatementContext<>(result, original, childCopyType, type, targetModule); result.addEffectiveSubstatement(copy); result.definition.onStatementAdded(result);