From c1289a7ebed4c08e19a0e8397fe200b84cc56d3e Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Fri, 27 Nov 2020 05:05:37 +0100 Subject: [PATCH] Fix StmtContext.produces{Declared,Effective} signatures We have bad signatures here, one of which is needlessly verbose, the other one is actually plain wrong as it confuses X,Y for A,D. Fix them up, which removes the need to go throw raw access to make them work. Change-Id: I6bfd995c8b4064b99eb673fa30c4ab8f3d52dd5c Signed-off-by: Robert Varga --- .../yangtools/yang/parser/spi/meta/StmtContext.java | 5 ++--- .../yang/parser/spi/meta/StmtContextDefaults.java | 7 +++---- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/yang/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/StmtContext.java b/yang/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/StmtContext.java index 337a5fba1a..0d3001fb56 100644 --- a/yang/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/StmtContext.java +++ b/yang/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/StmtContext.java @@ -108,12 +108,11 @@ public interface StmtContext, E extends Effect return verifyNotNull(getStatementArgument(), "Statement context %s does not have an argument", this); } - default > boolean producesDeclared(final Class type) { + default > boolean producesDeclared(final Class type) { return type.isAssignableFrom(getPublicDefinition().getDeclaredRepresentationClass()); } - default , Z extends EffectiveStatement> boolean producesEffective( - final Class type) { + default > boolean producesEffective(final Class type) { return type.isAssignableFrom(getPublicDefinition().getEffectiveRepresentationClass()); } diff --git a/yang/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/StmtContextDefaults.java b/yang/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/StmtContextDefaults.java index 59fb76f71c..0dbf3fee27 100644 --- a/yang/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/StmtContextDefaults.java +++ b/yang/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/StmtContextDefaults.java @@ -29,11 +29,11 @@ public final class StmtContextDefaults { * @param type Effective statement representation being look up * @return Effective statement argument, if found */ - @SuppressWarnings({ "rawtypes", "unchecked" }) + @SuppressWarnings("unchecked") public static > @NonNull Optional findSubstatementArgument( final @NonNull StmtContext stmt, final @NonNull Class type) { return stmt.allSubstatementsStream() - .filter(ctx -> ctx.isSupportedToBuildEffective() && ((StmtContext) ctx).producesEffective(type)) + .filter(ctx -> ctx.isSupportedToBuildEffective() && ctx.producesEffective(type)) .findAny() .map(ctx -> (A) ctx.coerceStatementArgument()); } @@ -45,10 +45,9 @@ public final class StmtContextDefaults { * @param type Effective statement representation being look up * @return True if a match is found, false otherwise */ - @SuppressWarnings({ "rawtypes", "unchecked" }) public static boolean hasSubstatement(final @NonNull StmtContext stmt, final @NonNull Class> type) { return stmt.allSubstatementsStream() - .anyMatch(ctx -> ctx.isSupportedToBuildEffective() && ((StmtContext) ctx).producesEffective(type)); + .anyMatch(ctx -> ctx.isSupportedToBuildEffective() && ctx.producesEffective(type)); } } -- 2.36.6