Bug 6868: If-feature argument may be boolean expression 14/49714/8
authorPeter Kajsa <pkajsa@cisco.com>
Wed, 21 Dec 2016 18:16:07 +0000 (19:16 +0100)
committerRobert Varga <nite@hq.sk>
Tue, 24 Jan 2017 10:07:03 +0000 (10:07 +0000)
Since Yang 1.1, "if-feature" argument may be a boolean expression over
feature names. In this expression, a feature name evaluates to "true"
if and only if the feature is supported by the server.

Change-Id: Id68d9a101641a7775d8b2a049986431e9cb27662
Signed-off-by: Peter Kajsa <pkajsa@cisco.com>
24 files changed:
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/stmt/IfFeatureStatement.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/repo/api/IfFeaturePredicates.java [deleted file]
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/repo/api/SchemaContextFactory.java
yang/yang-parser-impl/src/main/antlr/IfFeatureExpressionLexer.g4 [new file with mode: 0644]
yang/yang-parser-impl/src/main/antlr/IfFeatureExpressionParser.g4 [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/repo/SharedSchemaContextFactory.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/StmtContextUtils.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/spi/source/SupportedFeaturesNamespace.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/BuildGlobalContext.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/CrossSourceStatementReactor.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/IfFeatureStatementImpl.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/IfFeatureEffectiveStatementImpl.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/repo/SharedSchemaRepositoryWithFeaturesTest.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6868Test.java [new file with mode: 0644]
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6869Test.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/DeclaredStatementsTest.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/IfFeatureResolutionTest.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/StmtTestUtils.java
yang/yang-parser-impl/src/test/resources/rfc7950/bug6868/invalid10.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/rfc7950/bug6868/yang11/foo.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/rfc7950/bug6868/yang11/imported.yang [new file with mode: 0644]
yang/yang-system-test/src/main/java/org/opendaylight/yangtools/yang/parser/system/test/Main.java
yang/yang-system-test/src/main/java/org/opendaylight/yangtools/yang/parser/system/test/SystemTestUtils.java
yang/yang-test-util/src/main/java/org/opendaylight/yangtools/yang/test/util/YangParserTestUtils.java

index 2ea8ab52dbe8e0e3eb5d83457fa5d2af42bf178a..a2284e5e73719c14e0a7da92130edeadedbeca95 100644 (file)
@@ -19,26 +19,8 @@ import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
  *
  * The "if-feature" statement makes its parent statement conditional.
  */
  *
  * The "if-feature" statement makes its parent statement conditional.
  */
-// FIXME: IfFeatureStatement should extend DeclaredStatement<Predicate<Set<QName>>> and
-// IfFeatureStatementImpl for Yang1.0 reworked to extend AbstractDeclaredStatement<Predicate<Set<QName>>>.
-public interface IfFeatureStatement extends DeclaredStatement<QName> {
-
+public interface IfFeatureStatement extends DeclaredStatement<Predicate<Set<QName>>> {
     /**
     /**
-     * Used in YANG 1.0 (RFC6020) implementation of IfFeatureStatement
-     * where the argument is the name of a feature
-     * as defined by a "feature" statement.
-     *
-     * To be replaced by {@link #getIfFeaturePredicate() getIfFeaturePredicate} method.
-     *
-     * @return QName object for the feature
-     */
-    @Deprecated
-    @Nonnull QName getName();
-
-    /**
-     * This method should be overridden for all Yang 1.1 implementation.
-     * The default implementation is only applicable for Yang 1.0 (RFC6020).
-     *
      * In Yang 1.1 (RFC7950) implementation of IfFeatureStatement, the
      * argument is a boolean expression over feature names defined by
      * "feature" statements. Hence, add implementation to return a
      * In Yang 1.1 (RFC7950) implementation of IfFeatureStatement, the
      * argument is a boolean expression over feature names defined by
      * "feature" statements. Hence, add implementation to return a
@@ -47,7 +29,6 @@ public interface IfFeatureStatement extends DeclaredStatement<QName> {
      * @return Predicate on a collection of QNames against which to evaluate
      */
     @Beta
      * @return Predicate on a collection of QNames against which to evaluate
      */
     @Beta
-    @Nonnull default Predicate<Set<QName>> getIfFeaturePredicate() {
-        return setQnames -> setQnames.contains(getName());
-    }
+    @Nonnull
+    Predicate<Set<QName>> getIfFeaturePredicate();
 }
\ No newline at end of file
 }
\ No newline at end of file
diff --git a/yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/repo/api/IfFeaturePredicates.java b/yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/repo/api/IfFeaturePredicates.java
deleted file mode 100644 (file)
index e381be6..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.yangtools.yang.model.repo.api;
-
-import com.google.common.annotations.Beta;
-import java.util.function.Predicate;
-import org.opendaylight.yangtools.yang.common.QName;
-
-@Beta
-/**
- * If-feature predicate constants.
- */
-public final class IfFeaturePredicates {
-    /**
-     * All features predicate constant. Using of this constant improves
-     * performance of schema context resolution.
-     */
-    public static final Predicate<QName> ALL_FEATURES = t -> true;
-
-    private IfFeaturePredicates() {
-        throw new UnsupportedOperationException("Utility class");
-    }
-}
index eaa06ce6ad8b71e1427b80ea9d4bc6feee81b12f..91dfc946f4c004df57ed157ba93c3e04d8b02c06 100644 (file)
@@ -10,7 +10,7 @@ package org.opendaylight.yangtools.yang.model.repo.api;
 import com.google.common.annotations.Beta;
 import com.google.common.util.concurrent.CheckedFuture;
 import java.util.Collection;
 import com.google.common.annotations.Beta;
 import com.google.common.util.concurrent.CheckedFuture;
 import java.util.Collection;
-import java.util.function.Predicate;
+import java.util.Set;
 import javax.annotation.Nonnull;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import javax.annotation.Nonnull;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
@@ -33,8 +33,8 @@ public interface SchemaContextFactory {
      *         failed.
      */
     default CheckedFuture<SchemaContext, SchemaResolutionException> createSchemaContext(
      *         failed.
      */
     default CheckedFuture<SchemaContext, SchemaResolutionException> createSchemaContext(
-            @Nonnull Collection<SourceIdentifier> requiredSources) {
-        return createSchemaContext(requiredSources, StatementParserMode.DEFAULT_MODE, IfFeaturePredicates.ALL_FEATURES);
+            @Nonnull final Collection<SourceIdentifier> requiredSources) {
+        return createSchemaContext(requiredSources, StatementParserMode.DEFAULT_MODE);
     }
 
     /**
     }
 
     /**
@@ -50,8 +50,8 @@ public interface SchemaContextFactory {
      *         failed.
      */
     default CheckedFuture<SchemaContext, SchemaResolutionException> createSchemaContext(
      *         failed.
      */
     default CheckedFuture<SchemaContext, SchemaResolutionException> createSchemaContext(
-            Collection<SourceIdentifier> requiredSources, StatementParserMode statementParserMode) {
-        return createSchemaContext(requiredSources, statementParserMode, IfFeaturePredicates.ALL_FEATURES);
+            final Collection<SourceIdentifier> requiredSources, final StatementParserMode statementParserMode) {
+        return createSchemaContext(requiredSources, statementParserMode, null);
     }
 
     /**
     }
 
     /**
@@ -60,16 +60,16 @@ public interface SchemaContextFactory {
      *
      * @param requiredSources
      *            a collection of sources which are required to be present
      *
      * @param requiredSources
      *            a collection of sources which are required to be present
-     * @param isFeatureSupported
-     *            a predicate based on which all if-feature statements in the
+     * @param supportedFeatures
+     *            set of supported features based on which all if-feature statements in the
      *            parsed yang models are resolved
      * @return A checked future, which will produce a schema context, or fail
      *         with an explanation why the creation of the schema context
      *         failed.
      */
     default CheckedFuture<SchemaContext, SchemaResolutionException> createSchemaContext(
      *            parsed yang models are resolved
      * @return A checked future, which will produce a schema context, or fail
      *         with an explanation why the creation of the schema context
      *         failed.
      */
     default CheckedFuture<SchemaContext, SchemaResolutionException> createSchemaContext(
-            @Nonnull Collection<SourceIdentifier> requiredSources, Predicate<QName> isFeatureSupported) {
-        return createSchemaContext(requiredSources, StatementParserMode.DEFAULT_MODE, isFeatureSupported);
+            @Nonnull final Collection<SourceIdentifier> requiredSources, final Set<QName> supportedFeatures) {
+        return createSchemaContext(requiredSources, StatementParserMode.DEFAULT_MODE, supportedFeatures);
     }
 
     /**
     }
 
     /**
@@ -80,8 +80,8 @@ public interface SchemaContextFactory {
      *            a collection of sources which are required to be present
      * @param statementParserMode
      *            mode of statement parser
      *            a collection of sources which are required to be present
      * @param statementParserMode
      *            mode of statement parser
-     * @param isFeatureSupported
-     *            a predicate based on which all if-feature statements in the
+     * @param supportedFeatures
+     *            set of supported features based on which all if-feature statements in the
      *            parsed yang models are resolved
      * @return A checked future, which will produce a schema context, or fail
      *         with an explanation why the creation of the schema context
      *            parsed yang models are resolved
      * @return A checked future, which will produce a schema context, or fail
      *         with an explanation why the creation of the schema context
@@ -89,5 +89,5 @@ public interface SchemaContextFactory {
      */
     CheckedFuture<SchemaContext, SchemaResolutionException> createSchemaContext(
             Collection<SourceIdentifier> requiredSources, StatementParserMode statementParserMode,
      */
     CheckedFuture<SchemaContext, SchemaResolutionException> createSchemaContext(
             Collection<SourceIdentifier> requiredSources, StatementParserMode statementParserMode,
-            Predicate<QName> isFeatureSupported);
+            Set<QName> supportedFeatures);
 }
 }
diff --git a/yang/yang-parser-impl/src/main/antlr/IfFeatureExpressionLexer.g4 b/yang/yang-parser-impl/src/main/antlr/IfFeatureExpressionLexer.g4
new file mode 100644 (file)
index 0000000..6b837a8
--- /dev/null
@@ -0,0 +1,21 @@
+//
+// Copyright (c) 2017 Cisco Systems, Inc. and others.  All rights reserved.
+//
+// This program and the accompanying materials are made available under the
+// terms of the Eclipse Public License v1.0 which accompanies this distribution,
+// and is available at http://www.eclipse.org/legal/epl-v10.html
+//
+lexer grammar IfFeatureExpressionLexer;
+
+@header {
+package org.opendaylight.yangtools.antlrv4.code.gen;
+}
+
+NOT : 'not';
+LP : '(';
+RP : ')';
+AND : 'and';
+OR : 'or';
+COLON : ':';
+SEP: [ \n\r\t]+;
+IDENTIFIER : [a-zA-Z][a-zA-Z0-9_-]*;
diff --git a/yang/yang-parser-impl/src/main/antlr/IfFeatureExpressionParser.g4 b/yang/yang-parser-impl/src/main/antlr/IfFeatureExpressionParser.g4
new file mode 100644 (file)
index 0000000..14c58d9
--- /dev/null
@@ -0,0 +1,25 @@
+//
+// Copyright (c) 2017 Cisco Systems, Inc. and others.  All rights reserved.
+//
+// This program and the accompanying materials are made available under the
+// terms of the Eclipse Public License v1.0 which accompanies this distribution,
+// and is available at http://www.eclipse.org/legal/epl-v10.html
+//
+parser grammar IfFeatureExpressionParser;
+
+@header {
+package org.opendaylight.yangtools.antlrv4.code.gen;
+}
+
+options{
+    tokenVocab = IfFeatureExpressionLexer;
+}
+
+
+if_feature_expr: if_feature_term (SEP OR SEP if_feature_expr)?;
+if_feature_term: if_feature_factor (SEP AND SEP if_feature_term)?;
+if_feature_factor: NOT SEP if_feature_factor
+                 | LP SEP? if_feature_expr SEP? RP
+                 | identifier_ref_arg;
+
+identifier_ref_arg : (IDENTIFIER COLON)? IDENTIFIER;
\ No newline at end of file
index cffd246daa760cab18bb6602f0ffdcb29ca0bd4e..f4cf163821e04d9e7bcd1648b30af711c1e4eb09 100644 (file)
@@ -27,7 +27,6 @@ import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
-import java.util.function.Predicate;
 import javax.annotation.Nonnull;
 import org.antlr.v4.runtime.ParserRuleContext;
 import org.opendaylight.yangtools.antlrv4.code.gen.YangStatementParser.StatementContext;
 import javax.annotation.Nonnull;
 import org.antlr.v4.runtime.ParserRuleContext;
 import org.opendaylight.yangtools.antlrv4.code.gen.YangStatementParser.StatementContext;
@@ -69,10 +68,10 @@ final class SharedSchemaContextFactory implements SchemaContextFactory {
     @Override
     public CheckedFuture<SchemaContext, SchemaResolutionException> createSchemaContext(
             final Collection<SourceIdentifier> requiredSources, final StatementParserMode statementParserMode,
     @Override
     public CheckedFuture<SchemaContext, SchemaResolutionException> createSchemaContext(
             final Collection<SourceIdentifier> requiredSources, final StatementParserMode statementParserMode,
-            final Predicate<QName> isFeatureSupported) {
+            final Set<QName> supportedFeatures) {
         return createSchemaContext(requiredSources,
                 statementParserMode == StatementParserMode.SEMVER_MODE ? this.semVerCache : this.cache,
         return createSchemaContext(requiredSources,
                 statementParserMode == StatementParserMode.SEMVER_MODE ? this.semVerCache : this.cache,
-                new AssembleSources(isFeatureSupported, statementParserMode));
+                new AssembleSources(supportedFeatures, statementParserMode));
     }
 
     private ListenableFuture<ASTSchemaSource> requestSource(final SourceIdentifier identifier) {
     }
 
     private ListenableFuture<ASTSchemaSource> requestSource(final SourceIdentifier identifier) {
@@ -170,13 +169,13 @@ final class SharedSchemaContextFactory implements SchemaContextFactory {
 
     private static final class AssembleSources implements AsyncFunction<List<ASTSchemaSource>, SchemaContext> {
 
 
     private static final class AssembleSources implements AsyncFunction<List<ASTSchemaSource>, SchemaContext> {
 
-        private final Predicate<QName> isFeatureSupported;
+        private final Set<QName> supportedFeatures;
         private final StatementParserMode statementParserMode;
         private final Function<ASTSchemaSource, SourceIdentifier> getIdentifier;
 
         private final StatementParserMode statementParserMode;
         private final Function<ASTSchemaSource, SourceIdentifier> getIdentifier;
 
-        private AssembleSources(final Predicate<QName> isFeatureSupported,
+        private AssembleSources(final Set<QName> supportedFeatures,
                 final StatementParserMode statementParserMode) {
                 final StatementParserMode statementParserMode) {
-            this.isFeatureSupported = Preconditions.checkNotNull(isFeatureSupported);
+            this.supportedFeatures = supportedFeatures;
             this.statementParserMode = Preconditions.checkNotNull(statementParserMode);
             switch (statementParserMode) {
             case SEMVER_MODE:
             this.statementParserMode = Preconditions.checkNotNull(statementParserMode);
             switch (statementParserMode) {
             case SEMVER_MODE:
@@ -206,7 +205,7 @@ final class SharedSchemaContextFactory implements SchemaContextFactory {
 
             final Map<SourceIdentifier, ParserRuleContext> asts = Maps.transformValues(srcs, ASTSchemaSource::getAST);
             final CrossSourceStatementReactor.BuildAction reactor =
 
             final Map<SourceIdentifier, ParserRuleContext> asts = Maps.transformValues(srcs, ASTSchemaSource::getAST);
             final CrossSourceStatementReactor.BuildAction reactor =
-                    YangInferencePipeline.RFC6020_REACTOR.newBuild(statementParserMode, isFeatureSupported);
+                    YangInferencePipeline.RFC6020_REACTOR.newBuild(statementParserMode, supportedFeatures);
 
             for (final Entry<SourceIdentifier, ParserRuleContext> e : asts.entrySet()) {
                 final ParserRuleContext parserRuleCtx = e.getValue();
 
             for (final Entry<SourceIdentifier, ParserRuleContext> e : asts.entrySet()) {
                 final ParserRuleContext parserRuleCtx = e.getValue();
@@ -219,7 +218,7 @@ final class SharedSchemaContextFactory implements SchemaContextFactory {
             final SchemaContext schemaContext;
             try {
                 schemaContext = reactor.buildEffective();
             final SchemaContext schemaContext;
             try {
                 schemaContext = reactor.buildEffective();
-            } catch (ReactorException ex) {
+            } catch (final ReactorException ex) {
                 throw new SchemaResolutionException("Failed to resolve required models", ex.getSourceIdentifier(), ex);
             }
 
                 throw new SchemaResolutionException("Failed to resolve required models", ex.getSourceIdentifier(), ex);
             }
 
index 3e5589264ffc19b79c1414eb9f7e30c166196b7c..ebd0d8174bea4cfed2bc059870fcf7bfaf677aec 100644 (file)
@@ -13,6 +13,7 @@ import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.ImmutableSet.Builder;
 import java.util.Collection;
 import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.ImmutableSet.Builder;
 import java.util.Collection;
+import java.util.Set;
 import java.util.function.Predicate;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.QNameModule;
 import java.util.function.Predicate;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.QNameModule;
@@ -24,7 +25,6 @@ import org.opendaylight.yangtools.yang.model.api.stmt.MandatoryStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.MinElementsStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.PresenceStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier;
 import org.opendaylight.yangtools.yang.model.api.stmt.MinElementsStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.PresenceStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier;
-import org.opendaylight.yangtools.yang.model.repo.api.IfFeaturePredicates;
 import org.opendaylight.yangtools.yang.parser.spi.source.SupportedFeaturesNamespace;
 import org.opendaylight.yangtools.yang.parser.spi.source.SupportedFeaturesNamespace.SupportedFeatures;
 import org.opendaylight.yangtools.yang.parser.stmt.reactor.RootStatementContext;
 import org.opendaylight.yangtools.yang.parser.spi.source.SupportedFeaturesNamespace;
 import org.opendaylight.yangtools.yang.parser.spi.source.SupportedFeaturesNamespace.SupportedFeatures;
 import org.opendaylight.yangtools.yang.parser.stmt.reactor.RootStatementContext;
@@ -226,26 +226,30 @@ public final class StmtContextUtils {
             break;
         }
 
             break;
         }
 
-        final Predicate<QName> isFeatureSupported = stmtContext.getFromNamespace(SupportedFeaturesNamespace.class,
+        final Set<QName> supportedFeatures = stmtContext.getFromNamespace(SupportedFeaturesNamespace.class,
                 SupportedFeatures.SUPPORTED_FEATURES);
                 SupportedFeatures.SUPPORTED_FEATURES);
-        if (IfFeaturePredicates.ALL_FEATURES.equals(isFeatureSupported)) {
+        /*
+         * If set of supported features has not been provided, all features are
+         * supported by default.
+         */
+        if (supportedFeatures == null) {
             stmtContext.setSupportedByFeatures(true);
             return true;
         }
 
             stmtContext.setSupportedByFeatures(true);
             return true;
         }
 
-        final boolean result = checkFeatureSupport(stmtContext, isFeatureSupported);
+        final boolean result = checkFeatureSupport(stmtContext, supportedFeatures);
         stmtContext.setSupportedByFeatures(result);
         return result;
     }
 
     private static boolean checkFeatureSupport(final StmtContext.Mutable<?, ?, ?> stmtContext,
         stmtContext.setSupportedByFeatures(result);
         return result;
     }
 
     private static boolean checkFeatureSupport(final StmtContext.Mutable<?, ?, ?> stmtContext,
-            final Predicate<QName> isFeatureSupported) {
+            final Set<QName> supportedFeatures) {
         boolean isSupported = false;
         boolean containsIfFeature = false;
         for (final StatementContextBase<?, ?, ?> stmt : stmtContext.declaredSubstatements()) {
             if (YangStmtMapping.IF_FEATURE.equals(stmt.getPublicDefinition())) {
                 containsIfFeature = true;
         boolean isSupported = false;
         boolean containsIfFeature = false;
         for (final StatementContextBase<?, ?, ?> stmt : stmtContext.declaredSubstatements()) {
             if (YangStmtMapping.IF_FEATURE.equals(stmt.getPublicDefinition())) {
                 containsIfFeature = true;
-                if (isFeatureSupported.test((QName) stmt.getStatementArgument())) {
+                if (((Predicate<Set<QName>>) stmt.getStatementArgument()).test(supportedFeatures)) {
                     isSupported = true;
                 } else {
                     isSupported = false;
                     isSupported = true;
                 } else {
                     isSupported = false;
index ac2632c11de046be250d9970f24b7fa4a99e1f48..95b8f954abdb90ee048959f65263392e434daeb5 100644 (file)
@@ -8,12 +8,12 @@
 
 package org.opendaylight.yangtools.yang.parser.spi.source;
 
 
 package org.opendaylight.yangtools.yang.parser.spi.source;
 
-import java.util.function.Predicate;
+import java.util.Set;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.meta.IdentifierNamespace;
 
 public interface SupportedFeaturesNamespace
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.meta.IdentifierNamespace;
 
 public interface SupportedFeaturesNamespace
-        extends IdentifierNamespace<SupportedFeaturesNamespace.SupportedFeatures, Predicate<QName>> {
+        extends IdentifierNamespace<SupportedFeaturesNamespace.SupportedFeatures, Set<QName>> {
 
     enum SupportedFeatures {
         SUPPORTED_FEATURES
 
     enum SupportedFeatures {
         SUPPORTED_FEATURES
index 6e67cd340b8720531478b9614d1007fc7ac0142f..26eb77fc5426562f90bf8762b266f89327348b43 100644 (file)
@@ -26,7 +26,6 @@ import java.util.Map.Entry;
 import java.util.Objects;
 import java.util.Optional;
 import java.util.Set;
 import java.util.Objects;
 import java.util.Optional;
 import java.util.Set;
-import java.util.function.Predicate;
 import javax.annotation.Nonnull;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.YangVersion;
 import javax.annotation.Nonnull;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.YangVersion;
@@ -79,13 +78,13 @@ class BuildGlobalContext extends NamespaceStorageSupport implements NamespaceBeh
     private final Set<YangVersion> supportedVersions;
 
     BuildGlobalContext(final Map<ModelProcessingPhase, StatementSupportBundle> supports,
     private final Set<YangVersion> supportedVersions;
 
     BuildGlobalContext(final Map<ModelProcessingPhase, StatementSupportBundle> supports,
-            final StatementParserMode statementParserMode, final Predicate<QName> isFeatureSupported) {
-        this(supports, ImmutableMap.of(), statementParserMode, isFeatureSupported);
+            final StatementParserMode statementParserMode, final Set<QName> supportedFeatures) {
+        this(supports, ImmutableMap.of(), statementParserMode, supportedFeatures);
     }
 
     BuildGlobalContext(final Map<ModelProcessingPhase, StatementSupportBundle> supports,
             final Map<ValidationBundleType, Collection<?>> supportedValidation,
     }
 
     BuildGlobalContext(final Map<ModelProcessingPhase, StatementSupportBundle> supports,
             final Map<ValidationBundleType, Collection<?>> supportedValidation,
-            final StatementParserMode statementParserMode, final Predicate<QName> isFeatureSupported) {
+            final StatementParserMode statementParserMode, final Set<QName> supportedFeatures) {
         super();
         this.supports = Preconditions.checkNotNull(supports, "BuildGlobalContext#supports cannot be null");
         Preconditions.checkNotNull(statementParserMode, "Statement parser mode must not be null.");
         super();
         this.supports = Preconditions.checkNotNull(supports, "BuildGlobalContext#supports cannot be null");
         Preconditions.checkNotNull(statementParserMode, "Statement parser mode must not be null.");
@@ -95,8 +94,12 @@ class BuildGlobalContext extends NamespaceStorageSupport implements NamespaceBeh
             addToNs(ValidationBundlesNamespace.class, validationBundle.getKey(), validationBundle.getValue());
         }
 
             addToNs(ValidationBundlesNamespace.class, validationBundle.getKey(), validationBundle.getValue());
         }
 
-        addToNs(SupportedFeaturesNamespace.class, SupportedFeatures.SUPPORTED_FEATURES,
-                Preconditions.checkNotNull(isFeatureSupported, "Supported feature predicate must not be null."));
+        if (supportedFeatures != null) {
+            addToNs(SupportedFeaturesNamespace.class, SupportedFeatures.SUPPORTED_FEATURES,
+                    ImmutableSet.copyOf(supportedFeatures));
+        } else {
+            LOG.warn("Set of supported features has not been provided, so all features are supported by default.");
+        }
         this.supportedVersions = ImmutableSet.copyOf(supports.get(ModelProcessingPhase.INIT).getSupportedVersions());
     }
 
         this.supportedVersions = ImmutableSet.copyOf(supports.get(ModelProcessingPhase.INIT).getSupportedVersions());
     }
 
@@ -336,7 +339,7 @@ class BuildGlobalContext extends NamespaceStorageSupport implements NamespaceBeh
                         default:
                             throw new IllegalStateException("Unsupported phase progress " + sourceProgress);
                     }
                         default:
                             throw new IllegalStateException("Unsupported phase progress " + sourceProgress);
                     }
-                } catch (RuntimeException ex) {
+                } catch (final RuntimeException ex) {
                     throw propagateException(nextSourceCtx, ex);
                 }
             }
                     throw propagateException(nextSourceCtx, ex);
                 }
             }
index 8ce59f70e5667a1f5f1ebea767d1307a353c5b06..5bfb6b12ff9d70c739faa3aed70db716b356b2a6 100644 (file)
@@ -15,10 +15,9 @@ import java.util.Collection;
 import java.util.EnumMap;
 import java.util.List;
 import java.util.Map;
 import java.util.EnumMap;
 import java.util.List;
 import java.util.Map;
-import java.util.function.Predicate;
+import java.util.Set;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.repo.api.IfFeaturePredicates;
 import org.opendaylight.yangtools.yang.model.repo.api.StatementParserMode;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ModelProcessingPhase;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 import org.opendaylight.yangtools.yang.model.repo.api.StatementParserMode;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ModelProcessingPhase;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
@@ -49,20 +48,20 @@ public class CrossSourceStatementReactor {
     }
 
     public final BuildAction newBuild() {
     }
 
     public final BuildAction newBuild() {
-        return newBuild(StatementParserMode.DEFAULT_MODE, IfFeaturePredicates.ALL_FEATURES);
+        return newBuild(StatementParserMode.DEFAULT_MODE);
     }
 
     }
 
-    public final BuildAction newBuild(final Predicate<QName> isFeatureSupported) {
-        return new BuildAction(StatementParserMode.DEFAULT_MODE, isFeatureSupported);
+    public final BuildAction newBuild(final Set<QName> supportedFeatures) {
+        return new BuildAction(StatementParserMode.DEFAULT_MODE, supportedFeatures);
     }
 
     public final BuildAction newBuild(final StatementParserMode statementParserMode) {
     }
 
     public final BuildAction newBuild(final StatementParserMode statementParserMode) {
-        return new BuildAction(statementParserMode, IfFeaturePredicates.ALL_FEATURES);
+        return new BuildAction(statementParserMode, null);
     }
 
     public final BuildAction newBuild(final StatementParserMode statementParserMode,
     }
 
     public final BuildAction newBuild(final StatementParserMode statementParserMode,
-            final Predicate<QName> isFeatureSupported) {
-        return new BuildAction(statementParserMode, isFeatureSupported);
+            final Set<QName> supportedFeatures) {
+        return new BuildAction(statementParserMode, supportedFeatures);
     }
 
     public static class Builder implements org.opendaylight.yangtools.concepts.Builder<CrossSourceStatementReactor> {
     }
 
     public static class Builder implements org.opendaylight.yangtools.concepts.Builder<CrossSourceStatementReactor> {
@@ -90,20 +89,20 @@ public class CrossSourceStatementReactor {
         private final BuildGlobalContext context;
 
         public BuildAction() {
         private final BuildGlobalContext context;
 
         public BuildAction() {
-            this(StatementParserMode.DEFAULT_MODE, IfFeaturePredicates.ALL_FEATURES);
+            this(StatementParserMode.DEFAULT_MODE);
         }
 
         public BuildAction(final StatementParserMode statementParserMode) {
         }
 
         public BuildAction(final StatementParserMode statementParserMode) {
-            this(statementParserMode, IfFeaturePredicates.ALL_FEATURES);
+            this(statementParserMode, null);
         }
 
         }
 
-        public BuildAction(final Predicate<QName> isFeatureSupported) {
-            this(StatementParserMode.DEFAULT_MODE, isFeatureSupported);
+        public BuildAction(final Set<QName> supportedFeatures) {
+            this(StatementParserMode.DEFAULT_MODE, supportedFeatures);
         }
 
         }
 
-        public BuildAction(final StatementParserMode statementParserMode, final Predicate<QName> isFeatureSupported) {
+        public BuildAction(final StatementParserMode statementParserMode, final Set<QName> supportedFeatures) {
             this.context = new BuildGlobalContext(supportedTerminology, supportedValidation, statementParserMode,
             this.context = new BuildGlobalContext(supportedTerminology, supportedValidation, statementParserMode,
-                    isFeatureSupported);
+                    supportedFeatures);
         }
 
         public void addSource(final StatementStreamSource source) {
         }
 
         public void addSource(final StatementStreamSource source) {
index e0d4e4e30251e32cb6c7a5e27fadce994edaa40a..15fb9d79b8500e83257e1025aa1f9cc859bd946f 100644 (file)
@@ -7,8 +7,20 @@
  */
 package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
 
  */
 package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
 
-import javax.annotation.Nonnull;
+import com.google.common.base.Preconditions;
+import java.util.Set;
+import java.util.function.Predicate;
+import org.antlr.v4.runtime.ANTLRInputStream;
+import org.antlr.v4.runtime.CommonTokenStream;
+import org.opendaylight.yangtools.antlrv4.code.gen.IfFeatureExpressionLexer;
+import org.opendaylight.yangtools.antlrv4.code.gen.IfFeatureExpressionParser;
+import org.opendaylight.yangtools.antlrv4.code.gen.IfFeatureExpressionParser.Identifier_ref_argContext;
+import org.opendaylight.yangtools.antlrv4.code.gen.IfFeatureExpressionParser.If_feature_exprContext;
+import org.opendaylight.yangtools.antlrv4.code.gen.IfFeatureExpressionParser.If_feature_factorContext;
+import org.opendaylight.yangtools.antlrv4.code.gen.IfFeatureExpressionParser.If_feature_termContext;
+import org.opendaylight.yangtools.antlrv4.code.gen.IfFeatureExpressionParserBaseVisitor;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.YangVersion;
 import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.IfFeatureStatement;
 import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.IfFeatureStatement;
@@ -16,41 +28,47 @@ import org.opendaylight.yangtools.yang.parser.spi.SubstatementValidator;
 import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
 import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
 import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
 import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.IfFeatureEffectiveStatementImpl;
 
 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.IfFeatureEffectiveStatementImpl;
 
-public class IfFeatureStatementImpl extends AbstractDeclaredStatement<QName>
+public class IfFeatureStatementImpl extends AbstractDeclaredStatement<Predicate<Set<QName>>>
         implements IfFeatureStatement {
     private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = SubstatementValidator.builder(YangStmtMapping
             .IF_FEATURE)
             .build();
 
     protected IfFeatureStatementImpl(
         implements IfFeatureStatement {
     private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = SubstatementValidator.builder(YangStmtMapping
             .IF_FEATURE)
             .build();
 
     protected IfFeatureStatementImpl(
-            final StmtContext<QName, IfFeatureStatement, ?> context) {
+            final StmtContext<Predicate<Set<QName>>, IfFeatureStatement, ?> context) {
         super(context);
     }
 
     public static class Definition
             extends
         super(context);
     }
 
     public static class Definition
             extends
-            AbstractStatementSupport<QName, IfFeatureStatement, EffectiveStatement<QName, IfFeatureStatement>> {
+            AbstractStatementSupport<Predicate<Set<QName>>, IfFeatureStatement, EffectiveStatement<Predicate<Set<QName>>, IfFeatureStatement>> {
 
         public Definition() {
             super(YangStmtMapping.IF_FEATURE);
         }
 
         @Override
 
         public Definition() {
             super(YangStmtMapping.IF_FEATURE);
         }
 
         @Override
-        public QName parseArgumentValue(final StmtContext<?, ?, ?> ctx, final String value) {
-            return Utils.qNameFromArgument(ctx, value);
+        public Predicate<Set<QName>> parseArgumentValue(final StmtContext<?, ?, ?> ctx, final String value) {
+            if(YangVersion.VERSION_1_1.equals(ctx.getRootVersion())) {
+                return parseIfFeatureExpression(ctx, value);
+            } else {
+                final QName qName = Utils.qNameFromArgument(ctx, value);
+                return setQNames -> setQNames.contains(qName);
+            }
         }
 
         @Override
         public IfFeatureStatement createDeclared(
         }
 
         @Override
         public IfFeatureStatement createDeclared(
-                final StmtContext<QName, IfFeatureStatement, ?> ctx) {
+                final StmtContext<Predicate<Set<QName>>, IfFeatureStatement, ?> ctx) {
             return new IfFeatureStatementImpl(ctx);
         }
 
         @Override
             return new IfFeatureStatementImpl(ctx);
         }
 
         @Override
-        public EffectiveStatement<QName, IfFeatureStatement> createEffective(
-                final StmtContext<QName, IfFeatureStatement, EffectiveStatement<QName, IfFeatureStatement>> ctx) {
+        public EffectiveStatement<Predicate<Set<QName>>, IfFeatureStatement> createEffective(
+                final StmtContext<Predicate<Set<QName>>, IfFeatureStatement, EffectiveStatement<Predicate<Set<QName>>, IfFeatureStatement>> ctx) {
             return new IfFeatureEffectiveStatementImpl(ctx);
         }
 
             return new IfFeatureEffectiveStatementImpl(ctx);
         }
 
@@ -58,12 +76,64 @@ public class IfFeatureStatementImpl extends AbstractDeclaredStatement<QName>
         protected SubstatementValidator getSubstatementValidator() {
             return SUBSTATEMENT_VALIDATOR;
         }
         protected SubstatementValidator getSubstatementValidator() {
             return SUBSTATEMENT_VALIDATOR;
         }
+
+        private static Predicate<Set<QName>> parseIfFeatureExpression(final StmtContext<?, ?, ?> ctx, final String value) {
+            final IfFeatureExpressionLexer lexer = new IfFeatureExpressionLexer(new ANTLRInputStream(value));
+            final CommonTokenStream tokens = new CommonTokenStream(lexer);
+            final IfFeatureExpressionParser parser = new IfFeatureExpressionParser(tokens);
+
+            return new IfFeaturePredicateVisitor(ctx).visit(parser.if_feature_expr());
+        }
+
+        private static class IfFeaturePredicateVisitor extends IfFeatureExpressionParserBaseVisitor<Predicate<Set<QName>>> {
+            private final StmtContext<?, ?, ?> stmtCtx;
+
+            public IfFeaturePredicateVisitor(final StmtContext<?, ?, ?> ctx) {
+                this.stmtCtx = Preconditions.checkNotNull(ctx);
+            }
+
+            @Override
+            public Predicate<Set<QName>> visitIf_feature_expr(final If_feature_exprContext ctx) {
+                if (ctx.if_feature_expr() != null) {
+                    return visitIf_feature_term(ctx.if_feature_term()).or(visitIf_feature_expr(ctx.if_feature_expr()));
+                } else {
+                    return visitIf_feature_term(ctx.if_feature_term());
+                }
+            }
+
+            @Override
+            public Predicate<Set<QName>> visitIf_feature_term(final If_feature_termContext ctx) {
+                if (ctx.if_feature_term() != null) {
+                    return visitIf_feature_factor(ctx.if_feature_factor()).and(visitIf_feature_term(ctx.if_feature_term()));
+                } else {
+                    return visitIf_feature_factor(ctx.if_feature_factor());
+                }
+            }
+
+            @Override
+            public Predicate<Set<QName>> visitIf_feature_factor(final If_feature_factorContext ctx) {
+                if (ctx.if_feature_expr() != null) {
+                    return visitIf_feature_expr(ctx.if_feature_expr());
+                } else if (ctx.if_feature_factor() != null) {
+                    return visitIf_feature_factor(ctx.if_feature_factor()).negate();
+                } else if (ctx.identifier_ref_arg() != null) {
+                    return visitIdentifier_ref_arg(ctx.identifier_ref_arg());
+                }
+
+                throw new SourceException("Unexpected grammar context during parsing of IfFeature expression. "
+                        + "Most probably IfFeature grammar has been changed.", stmtCtx.getStatementSourceReference());
+            }
+
+            @Override
+            public Predicate<Set<QName>> visitIdentifier_ref_arg(final Identifier_ref_argContext ctx) {
+                final QName featureQName = Utils.qNameFromArgument(stmtCtx, ctx.getText());
+                return setQNames -> setQNames.contains(featureQName);
+            }
+        }
     }
 
     }
 
-    @Nonnull
     @Override
     @Override
-    public QName getName() {
+    public Predicate<Set<QName>> getIfFeaturePredicate() {
         return argument();
     }
         return argument();
     }
-
 }
 }
index 7cfd2aa28114dc7ceb5f2d483164ebef8605e9c5..a1e3dc514de31e5ce79f09c6c24ee957f3a1234d 100644 (file)
@@ -7,12 +7,14 @@
  */
 package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
 
  */
 package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
 
+import java.util.Set;
+import java.util.function.Predicate;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.stmt.IfFeatureStatement;
 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
 
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.stmt.IfFeatureStatement;
 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
 
-public final class IfFeatureEffectiveStatementImpl extends DeclaredEffectiveStatementBase<QName, IfFeatureStatement> {
-    public IfFeatureEffectiveStatementImpl(final StmtContext<QName, IfFeatureStatement, ?> ctx) {
+public final class IfFeatureEffectiveStatementImpl extends DeclaredEffectiveStatementBase<Predicate<Set<QName>>, IfFeatureStatement> {
+    public IfFeatureEffectiveStatementImpl(final StmtContext<Predicate<Set<QName>>, IfFeatureStatement, ?> ctx) {
         super(ctx);
     }
 }
\ No newline at end of file
         super(ctx);
     }
 }
\ No newline at end of file
index 2f6b63ebb8420c459626bd53ec974b2b6a638a58..42c0b83360284720efa5236ec023309c140dfdf1 100644 (file)
@@ -12,11 +12,11 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
+
+import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Lists;
 import com.google.common.util.concurrent.CheckedFuture;
 import com.google.common.collect.Lists;
 import com.google.common.util.concurrent.CheckedFuture;
-import java.util.HashSet;
 import java.util.Set;
 import java.util.Set;
-import java.util.function.Predicate;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
@@ -34,12 +34,7 @@ public class SharedSchemaRepositoryWithFeaturesTest {
 
     @Test
     public void testSharedSchemaRepositoryWithSomeFeaturesSupported() throws Exception {
 
     @Test
     public void testSharedSchemaRepositoryWithSomeFeaturesSupported() throws Exception {
-        Predicate<QName> isFeatureSupported = qName -> {
-            Set<QName> supportedFeatures = new HashSet<>();
-            supportedFeatures.add(QName.create("foobar-namespace", "1970-01-01", "test-feature-1"));
-
-            return supportedFeatures.contains(qName);
-        };
+        final Set<QName> supportedFeatures = ImmutableSet.of(QName.create("foobar-namespace", "1970-01-01", "test-feature-1"));
 
         final SharedSchemaRepository sharedSchemaRepository = new SharedSchemaRepository(
                 "shared-schema-repo-with-features-test");
 
         final SharedSchemaRepository sharedSchemaRepository = new SharedSchemaRepository(
                 "shared-schema-repo-with-features-test");
@@ -53,29 +48,29 @@ public class SharedSchemaRepositoryWithFeaturesTest {
                 .createSchemaContextFactory(SchemaSourceFilter.ALWAYS_ACCEPT);
 
         final CheckedFuture<SchemaContext, SchemaResolutionException> testSchemaContextFuture =
                 .createSchemaContextFactory(SchemaSourceFilter.ALWAYS_ACCEPT);
 
         final CheckedFuture<SchemaContext, SchemaResolutionException> testSchemaContextFuture =
-                fact.createSchemaContext(Lists.newArrayList(foobar.getId()), isFeatureSupported);
+                fact.createSchemaContext(Lists.newArrayList(foobar.getId()), supportedFeatures);
         assertTrue(testSchemaContextFuture.isDone());
         assertSchemaContext(testSchemaContextFuture.checkedGet(), 1);
 
         assertTrue(testSchemaContextFuture.isDone());
         assertSchemaContext(testSchemaContextFuture.checkedGet(), 1);
 
-        Module module = testSchemaContextFuture.checkedGet().findModuleByName("foobar", null);
+        final Module module = testSchemaContextFuture.checkedGet().findModuleByName("foobar", null);
         assertNotNull(module);
         assertEquals(2, module.getChildNodes().size());
 
         assertNotNull(module);
         assertEquals(2, module.getChildNodes().size());
 
-        ContainerSchemaNode testContainerA = (ContainerSchemaNode) module.getDataChildByName(
+        final ContainerSchemaNode testContainerA = (ContainerSchemaNode) module.getDataChildByName(
                 QName.create(module.getQNameModule(), "test-container-a"));
         assertNotNull(testContainerA);
                 QName.create(module.getQNameModule(), "test-container-a"));
         assertNotNull(testContainerA);
-        LeafSchemaNode testLeafA = (LeafSchemaNode) testContainerA.getDataChildByName(
+        final LeafSchemaNode testLeafA = (LeafSchemaNode) testContainerA.getDataChildByName(
                 QName.create(module.getQNameModule(), "test-leaf-a"));
         assertNotNull(testLeafA);
 
                 QName.create(module.getQNameModule(), "test-leaf-a"));
         assertNotNull(testLeafA);
 
-        ContainerSchemaNode testContainerB = (ContainerSchemaNode) module.getDataChildByName(
+        final ContainerSchemaNode testContainerB = (ContainerSchemaNode) module.getDataChildByName(
                 QName.create(module.getQNameModule(), "test-container-b"));
         assertNull(testContainerB);
 
                 QName.create(module.getQNameModule(), "test-container-b"));
         assertNull(testContainerB);
 
-        ContainerSchemaNode testContainerC = (ContainerSchemaNode) module.getDataChildByName(
+        final ContainerSchemaNode testContainerC = (ContainerSchemaNode) module.getDataChildByName(
                 QName.create(module.getQNameModule(), "test-container-c"));
         assertNotNull(testContainerC);
                 QName.create(module.getQNameModule(), "test-container-c"));
         assertNotNull(testContainerC);
-        LeafSchemaNode testLeafC = (LeafSchemaNode) testContainerC.getDataChildByName(
+        final LeafSchemaNode testLeafC = (LeafSchemaNode) testContainerC.getDataChildByName(
                 QName.create(module.getQNameModule(), "test-leaf-c"));
         assertNotNull(testLeafC);
     }
                 QName.create(module.getQNameModule(), "test-leaf-c"));
         assertNotNull(testLeafC);
     }
@@ -98,35 +93,35 @@ public class SharedSchemaRepositoryWithFeaturesTest {
         assertTrue(testSchemaContextFuture.isDone());
         assertSchemaContext(testSchemaContextFuture.checkedGet(), 1);
 
         assertTrue(testSchemaContextFuture.isDone());
         assertSchemaContext(testSchemaContextFuture.checkedGet(), 1);
 
-        Module module = testSchemaContextFuture.checkedGet().findModuleByName("foobar", null);
+        final Module module = testSchemaContextFuture.checkedGet().findModuleByName("foobar", null);
         assertNotNull(module);
         assertEquals(3, module.getChildNodes().size());
 
         assertNotNull(module);
         assertEquals(3, module.getChildNodes().size());
 
-        ContainerSchemaNode testContainerA = (ContainerSchemaNode) module.getDataChildByName(
+        final ContainerSchemaNode testContainerA = (ContainerSchemaNode) module.getDataChildByName(
                 QName.create(module.getQNameModule(), "test-container-a"));
         assertNotNull(testContainerA);
                 QName.create(module.getQNameModule(), "test-container-a"));
         assertNotNull(testContainerA);
-        LeafSchemaNode testLeafA = (LeafSchemaNode) testContainerA.getDataChildByName(
+        final LeafSchemaNode testLeafA = (LeafSchemaNode) testContainerA.getDataChildByName(
                 QName.create(module.getQNameModule(), "test-leaf-a"));
         assertNotNull(testLeafA);
 
                 QName.create(module.getQNameModule(), "test-leaf-a"));
         assertNotNull(testLeafA);
 
-        ContainerSchemaNode testContainerB = (ContainerSchemaNode) module.getDataChildByName(
+        final ContainerSchemaNode testContainerB = (ContainerSchemaNode) module.getDataChildByName(
                 QName.create(module.getQNameModule(), "test-container-b"));
         assertNotNull(testContainerB);
                 QName.create(module.getQNameModule(), "test-container-b"));
         assertNotNull(testContainerB);
-        LeafSchemaNode testLeafB = (LeafSchemaNode) testContainerB.getDataChildByName(
+        final LeafSchemaNode testLeafB = (LeafSchemaNode) testContainerB.getDataChildByName(
                 QName.create(module.getQNameModule(), "test-leaf-b"));
         assertNotNull(testLeafB);
 
                 QName.create(module.getQNameModule(), "test-leaf-b"));
         assertNotNull(testLeafB);
 
-        ContainerSchemaNode testContainerC = (ContainerSchemaNode) module.getDataChildByName(
+        final ContainerSchemaNode testContainerC = (ContainerSchemaNode) module.getDataChildByName(
                 QName.create(module.getQNameModule(), "test-container-c"));
         assertNotNull(testContainerC);
                 QName.create(module.getQNameModule(), "test-container-c"));
         assertNotNull(testContainerC);
-        LeafSchemaNode testLeafC = (LeafSchemaNode) testContainerC.getDataChildByName(
+        final LeafSchemaNode testLeafC = (LeafSchemaNode) testContainerC.getDataChildByName(
                 QName.create(module.getQNameModule(), "test-leaf-c"));
         assertNotNull(testLeafC);
     }
 
     @Test
     public void testSharedSchemaRepositoryWithNoFeaturesSupported() throws Exception {
                 QName.create(module.getQNameModule(), "test-leaf-c"));
         assertNotNull(testLeafC);
     }
 
     @Test
     public void testSharedSchemaRepositoryWithNoFeaturesSupported() throws Exception {
-        Predicate<QName> isFeatureSupported = qName -> false;
+        final Set<QName> supportedFeatures = ImmutableSet.of();
 
         final SharedSchemaRepository sharedSchemaRepository = new SharedSchemaRepository(
                 "shared-schema-repo-with-features-test");
 
         final SharedSchemaRepository sharedSchemaRepository = new SharedSchemaRepository(
                 "shared-schema-repo-with-features-test");
@@ -140,18 +135,18 @@ public class SharedSchemaRepositoryWithFeaturesTest {
                 .createSchemaContextFactory(SchemaSourceFilter.ALWAYS_ACCEPT);
 
         final CheckedFuture<SchemaContext, SchemaResolutionException> testSchemaContextFuture = fact
                 .createSchemaContextFactory(SchemaSourceFilter.ALWAYS_ACCEPT);
 
         final CheckedFuture<SchemaContext, SchemaResolutionException> testSchemaContextFuture = fact
-                .createSchemaContext(Lists.newArrayList(foobar.getId()), isFeatureSupported);
+                .createSchemaContext(Lists.newArrayList(foobar.getId()), supportedFeatures);
         assertTrue(testSchemaContextFuture.isDone());
         assertSchemaContext(testSchemaContextFuture.checkedGet(), 1);
 
         assertTrue(testSchemaContextFuture.isDone());
         assertSchemaContext(testSchemaContextFuture.checkedGet(), 1);
 
-        Module module = testSchemaContextFuture.checkedGet().findModuleByName("foobar", null);
+        final Module module = testSchemaContextFuture.checkedGet().findModuleByName("foobar", null);
         assertNotNull(module);
         assertEquals(1, module.getChildNodes().size());
 
         assertNotNull(module);
         assertEquals(1, module.getChildNodes().size());
 
-        ContainerSchemaNode testContainerC = (ContainerSchemaNode) module.getDataChildByName(
+        final ContainerSchemaNode testContainerC = (ContainerSchemaNode) module.getDataChildByName(
                 QName.create(module.getQNameModule(), "test-container-c"));
         assertNotNull(testContainerC);
                 QName.create(module.getQNameModule(), "test-container-c"));
         assertNotNull(testContainerC);
-        LeafSchemaNode testLeafC = (LeafSchemaNode) testContainerC.getDataChildByName(
+        final LeafSchemaNode testLeafC = (LeafSchemaNode) testContainerC.getDataChildByName(
                 QName.create(module.getQNameModule(), "test-leaf-c"));
         assertNotNull(testLeafC);
     }
                 QName.create(module.getQNameModule(), "test-leaf-c"));
         assertNotNull(testLeafC);
     }
diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6868Test.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6868Test.java
new file mode 100644 (file)
index 0000000..6514223
--- /dev/null
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2017 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.yangtools.yang.parser.stmt.rfc7950;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Sets;
+import java.io.FileNotFoundException;
+import java.net.URISyntaxException;
+import java.util.HashSet;
+import java.util.Set;
+import org.junit.Test;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.SchemaNode;
+import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+import org.opendaylight.yangtools.yang.model.repo.api.StatementParserMode;
+import org.opendaylight.yangtools.yang.model.util.SchemaContextUtil;
+import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
+import org.opendaylight.yangtools.yang.parser.spi.meta.SomeModifiersUnresolvedException;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+import org.opendaylight.yangtools.yang.stmt.StmtTestUtils;
+
+public class Bug6868Test {
+    private static final String FOO_NS = "foo";
+    private static final String FOO_REV = "1970-01-01";
+    private static final String IMP_NS = "imp";
+    private static final String IMP_REV = "2017-01-09";
+    private static final Set<String> ALL_CONTAINERS = ImmutableSet.of("my-container-1", "my-container-2",
+            "my-container-3", "foo", "not-foo", "imp-bar", "imp-bar-2");
+
+    @Test
+    public void ifFeatureYang11ResolutionTest() throws ReactorException, SourceException, FileNotFoundException,
+            URISyntaxException {
+        assertSchemaContextFor(null, ALL_CONTAINERS);
+        assertSchemaContextFor(ImmutableSet.of(), ImmutableSet.of("my-container-1", "my-container-2", "not-foo"));
+        assertSchemaContextFor(ImmutableSet.of("foo"), ImmutableSet.of("foo"));
+        assertSchemaContextFor(ImmutableSet.of("baz"),
+                ImmutableSet.of("my-container-1", "my-container-2", "my-container-3", "not-foo"));
+        assertSchemaContextFor(ImmutableSet.of("bar", "baz"),
+                ImmutableSet.of("my-container-1", "my-container-2", "my-container-3", "not-foo"));
+        assertSchemaContextFor(ImmutableSet.of("foo", "bar", "baz"),
+                ImmutableSet.of("my-container-1", "my-container-2", "my-container-3", "foo"));
+        assertSchemaContextFor(ImmutableSet.of("foo", "bar", "baz", "imp:bar"),
+                ImmutableSet.of("my-container-1", "my-container-2", "my-container-3", "foo", "imp-bar"));
+        assertSchemaContextFor(ImmutableSet.of("foo", "baz", "imp:bar"), ImmutableSet.of("foo", "imp-bar", "imp-bar-2"));
+    }
+
+    private static void assertSchemaContextFor(final Set<String> supportedFeatures, final Set<String> expectedContainers)
+            throws SourceException, FileNotFoundException, ReactorException, URISyntaxException {
+        final SchemaContext schemaContext = StmtTestUtils.parseYangSources("/rfc7950/bug6868/yang11",
+                supportedFeatures != null ? createFeaturesSet(supportedFeatures) : null,
+                StatementParserMode.DEFAULT_MODE);
+        assertNotNull(schemaContext);
+
+        for (final String expectedContainer : expectedContainers) {
+            assertTrue(String.format("Expected container %s not found.", expectedContainer),
+                    findNode(schemaContext, expectedContainer) instanceof ContainerSchemaNode);
+        }
+
+        final Set<String> unexpectedContainers = Sets.difference(ALL_CONTAINERS, expectedContainers);
+        for (final String unexpectedContainer : unexpectedContainers) {
+            assertNull(String.format("Unexpected container %s.", unexpectedContainer),
+                    findNode(schemaContext, unexpectedContainer));
+        }
+    }
+
+    private static Set<QName> createFeaturesSet(final Set<String> featureNames) {
+        final Set<QName> supportedFeatures = new HashSet<>();
+        for (final String featureName : featureNames) {
+            if (featureName.indexOf(':') == -1) {
+                supportedFeatures.add(QName.create(FOO_NS, FOO_REV, featureName));
+            } else {
+                supportedFeatures
+                        .add(QName.create(IMP_NS, IMP_REV, featureName.substring(featureName.indexOf(':') + 1)));
+            }
+        }
+
+        return ImmutableSet.copyOf(supportedFeatures);
+    }
+
+    private static SchemaNode findNode(final SchemaContext context, final String localName) {
+        return SchemaContextUtil.findDataSchemaNode(context,
+                SchemaPath.create(true, QName.create(FOO_NS, FOO_REV, localName)));
+    }
+
+    @Test
+    public void invalidYang10Test() throws ReactorException, SourceException, FileNotFoundException, URISyntaxException {
+        try {
+            StmtTestUtils.parseYangSource("/rfc7950/bug6868/invalid10.yang");
+            fail("Test should fail due to invalid Yang 1.0");
+        } catch (final SomeModifiersUnresolvedException e) {
+            assertTrue(e.getCause().getMessage()
+                    .startsWith("Parameter 'localName':'(not foo) or (bar and baz)' contains illegal character '('"));
+        }
+    }
+}
\ No newline at end of file
index 5228b79914ae32716e716b5ae7e3402be8cea521..3d90a591598449ddf56f8f327fa802bf0ac75f33 100644 (file)
@@ -15,12 +15,12 @@ import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
 import com.google.common.collect.ImmutableList;
 import static org.junit.Assert.fail;
 
 import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Iterables;
 import java.io.FileNotFoundException;
 import java.net.URISyntaxException;
 import java.util.HashSet;
 import java.util.Set;
 import com.google.common.collect.Iterables;
 import java.io.FileNotFoundException;
 import java.net.URISyntaxException;
 import java.util.HashSet;
 import java.util.Set;
-import java.util.function.Predicate;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode;
@@ -43,7 +43,7 @@ public class Bug6869Test {
     public void identityNoFeaureTest() throws ReactorException, SourceException, FileNotFoundException,
             URISyntaxException {
         final SchemaContext schemaContext = StmtTestUtils.parseYangSource("/rfc7950/bug6869/foo.yang",
     public void identityNoFeaureTest() throws ReactorException, SourceException, FileNotFoundException,
             URISyntaxException {
         final SchemaContext schemaContext = StmtTestUtils.parseYangSource("/rfc7950/bug6869/foo.yang",
-                createIfFeaturesPredicate("no-feature"));
+                ImmutableSet.of());
         assertNotNull(schemaContext);
 
         final Set<IdentitySchemaNode> identities = getIdentities(schemaContext);
         assertNotNull(schemaContext);
 
         final Set<IdentitySchemaNode> identities = getIdentities(schemaContext);
@@ -59,7 +59,7 @@ public class Bug6869Test {
     public void identityAllFeauresTest() throws ReactorException, SourceException, FileNotFoundException,
             URISyntaxException {
         final SchemaContext schemaContext = StmtTestUtils.parseYangSource("/rfc7950/bug6869/foo.yang",
     public void identityAllFeauresTest() throws ReactorException, SourceException, FileNotFoundException,
             URISyntaxException {
         final SchemaContext schemaContext = StmtTestUtils.parseYangSource("/rfc7950/bug6869/foo.yang",
-                createIfFeaturesPredicate("identity-feature", "mandatory-leaf", "tls", "ssh", "two", "three"));
+                createFeaturesSet("identity-feature", "mandatory-leaf", "tls", "ssh", "two", "three"));
         assertNotNull(schemaContext);
 
         final Set<IdentitySchemaNode> identities = getIdentities(schemaContext);
         assertNotNull(schemaContext);
 
         final Set<IdentitySchemaNode> identities = getIdentities(schemaContext);
@@ -78,15 +78,13 @@ public class Bug6869Test {
         return module.getIdentities();
     }
 
         return module.getIdentities();
     }
 
-    private static Predicate<QName> createIfFeaturesPredicate(final String... featureNames) {
-        final Predicate<QName> ifFeaturesPredicate = qName -> {
-            final Set<QName> supportedFeatures = new HashSet<>();
-            for (final String featureName : featureNames) {
-                supportedFeatures.add(QName.create(FOO_NS, FOO_REV, featureName));
-            }
-            return supportedFeatures.contains(qName);
-        };
-        return ifFeaturesPredicate;
+    private static Set<QName> createFeaturesSet(final String... featureNames) {
+        final Set<QName> supportedFeatures = new HashSet<>();
+        for (final String featureName : featureNames) {
+            supportedFeatures.add(QName.create(FOO_NS, FOO_REV, featureName));
+        }
+
+        return ImmutableSet.copyOf(supportedFeatures);
     }
 
     private static SchemaNode findNode(final SchemaContext context, final Iterable<String> localNamesPath) {
     }
 
     private static SchemaNode findNode(final SchemaContext context, final Iterable<String> localNamesPath) {
index c685203de432706e148ed47f39ce2546f2102130..3aa9d229c26456aa0729feb3a6aa70be54fd384e 100644 (file)
@@ -17,6 +17,7 @@ import java.text.ParseException;
 import java.util.Collection;
 import java.util.Date;
 import java.util.Set;
 import java.util.Collection;
 import java.util.Date;
 import java.util.Set;
+import java.util.function.Predicate;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
@@ -75,163 +76,163 @@ public class DeclaredStatementsTest {
 
     @Test
     public void testDeclaredAnyXml() throws ReactorException {
 
     @Test
     public void testDeclaredAnyXml() throws ReactorException {
-        YangStatementSourceImpl anyxmlStmtModule =
+        final YangStatementSourceImpl anyxmlStmtModule =
                 new YangStatementSourceImpl("/declared-statements-test/anyxml-declared-test.yang", false);
 
                 new YangStatementSourceImpl("/declared-statements-test/anyxml-declared-test.yang", false);
 
-        SchemaContext schemaContext = StmtTestUtils.parseYangSources(anyxmlStmtModule);
+        final SchemaContext schemaContext = StmtTestUtils.parseYangSources(anyxmlStmtModule);
         assertNotNull(schemaContext);
 
         assertNotNull(schemaContext);
 
-        Module testModule = schemaContext.findModuleByName("anyxml-declared-test", null);
+        final Module testModule = schemaContext.findModuleByName("anyxml-declared-test", null);
         assertNotNull(testModule);
 
         assertNotNull(testModule);
 
-        AnyXmlSchemaNode anyxmlSchemaNode = (AnyXmlSchemaNode) testModule.getDataChildByName(
+        final AnyXmlSchemaNode anyxmlSchemaNode = (AnyXmlSchemaNode) testModule.getDataChildByName(
                 QName.create(testModule.getQNameModule(), "foobar"));
         assertNotNull(anyxmlSchemaNode);
                 QName.create(testModule.getQNameModule(), "foobar"));
         assertNotNull(anyxmlSchemaNode);
-        AnyxmlStatement anyxmlStatement = ((AnyXmlEffectiveStatementImpl) anyxmlSchemaNode).getDeclared();
+        final AnyxmlStatement anyxmlStatement = ((AnyXmlEffectiveStatementImpl) anyxmlSchemaNode).getDeclared();
 
 
-        QName name = anyxmlStatement.getName();
+        final QName name = anyxmlStatement.getName();
         assertNotNull(name);
 
         assertNotNull(name);
 
-        WhenStatement whenStatement = anyxmlStatement.getWhenStatement();
+        final WhenStatement whenStatement = anyxmlStatement.getWhenStatement();
         assertNotNull(whenStatement);
         assertNotNull(whenStatement);
-        RevisionAwareXPath whenRevisionAwareXPath = whenStatement.getCondition();
+        final RevisionAwareXPath whenRevisionAwareXPath = whenStatement.getCondition();
         assertNotNull(whenRevisionAwareXPath);
         assertNotNull(whenRevisionAwareXPath);
-        DescriptionStatement whenStatementDescription = whenStatement.getDescription();
+        final DescriptionStatement whenStatementDescription = whenStatement.getDescription();
         assertNotNull(whenStatementDescription);
         assertNotNull(whenStatementDescription);
-        ReferenceStatement whenStatementReference = whenStatement.getReference();
+        final ReferenceStatement whenStatementReference = whenStatement.getReference();
         assertNotNull(whenStatementReference);
 
         assertNotNull(whenStatementReference);
 
-        Collection<? extends IfFeatureStatement> ifFeatureStatements = anyxmlStatement.getIfFeatures();
+        final Collection<? extends IfFeatureStatement> ifFeatureStatements = anyxmlStatement.getIfFeatures();
         assertNotNull(ifFeatureStatements);
         assertEquals(1, ifFeatureStatements.size());
         assertNotNull(ifFeatureStatements);
         assertEquals(1, ifFeatureStatements.size());
-        QName ifFeatureName = ifFeatureStatements.iterator().next().getName();
-        assertNotNull(ifFeatureName);
+        final Predicate<Set<QName>> ifFeaturePredicate = ifFeatureStatements.iterator().next().getIfFeaturePredicate();
+        assertNotNull(ifFeaturePredicate);
 
 
-        Collection<? extends MustStatement> mustStatements = anyxmlStatement.getMusts();
+        final Collection<? extends MustStatement> mustStatements = anyxmlStatement.getMusts();
         assertNotNull(mustStatements);
         assertEquals(1, mustStatements.size());
         assertNotNull(mustStatements);
         assertEquals(1, mustStatements.size());
-        MustStatement mustStatement = mustStatements.iterator().next();
-        RevisionAwareXPath mustRevisionAwareXPath = mustStatement.getCondition();
+        final MustStatement mustStatement = mustStatements.iterator().next();
+        final RevisionAwareXPath mustRevisionAwareXPath = mustStatement.getCondition();
         assertNotNull(mustRevisionAwareXPath);
         assertNotNull(mustRevisionAwareXPath);
-        ErrorAppTagStatement errorAppTagStatement = mustStatement.getErrorAppTagStatement();
+        final ErrorAppTagStatement errorAppTagStatement = mustStatement.getErrorAppTagStatement();
         assertNotNull(errorAppTagStatement);
         assertNotNull(errorAppTagStatement);
-        ErrorMessageStatement errorMessageStatement = mustStatement.getErrorMessageStatement();
+        final ErrorMessageStatement errorMessageStatement = mustStatement.getErrorMessageStatement();
         assertNotNull(errorMessageStatement);
         assertNotNull(errorMessageStatement);
-        DescriptionStatement mustStatementDescription = mustStatement.getDescription();
+        final DescriptionStatement mustStatementDescription = mustStatement.getDescription();
         assertNotNull(mustStatementDescription);
         assertNotNull(mustStatementDescription);
-        ReferenceStatement mustStatementReference = mustStatement.getReference();
+        final ReferenceStatement mustStatementReference = mustStatement.getReference();
         assertNotNull(mustStatementReference);
 
         assertNotNull(mustStatementReference);
 
-        ConfigStatement configStatement = anyxmlStatement.getConfig();
+        final ConfigStatement configStatement = anyxmlStatement.getConfig();
         assertNotNull(configStatement);
         assertFalse(configStatement.getValue());
 
         assertNotNull(configStatement);
         assertFalse(configStatement.getValue());
 
-        StatusStatement statusStatement = anyxmlStatement.getStatus();
+        final StatusStatement statusStatement = anyxmlStatement.getStatus();
         assertNotNull(statusStatement);
         assertNotNull(statusStatement);
-        Status status = statusStatement.getValue();
+        final Status status = statusStatement.getValue();
         assertNotNull(status);
 
         assertNotNull(status);
 
-        DescriptionStatement descriptionStatement = anyxmlStatement.getDescription();
+        final DescriptionStatement descriptionStatement = anyxmlStatement.getDescription();
         assertNotNull(descriptionStatement);
         assertEquals("anyxml description", descriptionStatement.getText());
 
         assertNotNull(descriptionStatement);
         assertEquals("anyxml description", descriptionStatement.getText());
 
-        ReferenceStatement referenceStatement = anyxmlStatement.getReference();
+        final ReferenceStatement referenceStatement = anyxmlStatement.getReference();
         assertNotNull(referenceStatement);
         assertEquals("anyxml reference", referenceStatement.getText());
 
         assertNotNull(referenceStatement);
         assertEquals("anyxml reference", referenceStatement.getText());
 
-        MandatoryStatement mandatoryStatement = anyxmlStatement.getMandatory();
+        final MandatoryStatement mandatoryStatement = anyxmlStatement.getMandatory();
         assertNotNull(mandatoryStatement);
     }
 
     @Test
     public void testDeclaredChoice() throws ReactorException {
         assertNotNull(mandatoryStatement);
     }
 
     @Test
     public void testDeclaredChoice() throws ReactorException {
-        YangStatementSourceImpl choiceStmtModule =
+        final YangStatementSourceImpl choiceStmtModule =
                 new YangStatementSourceImpl("/declared-statements-test/choice-declared-test.yang", false);
 
                 new YangStatementSourceImpl("/declared-statements-test/choice-declared-test.yang", false);
 
-        SchemaContext schemaContext = StmtTestUtils.parseYangSources(choiceStmtModule);
+        final SchemaContext schemaContext = StmtTestUtils.parseYangSources(choiceStmtModule);
         assertNotNull(schemaContext);
 
         assertNotNull(schemaContext);
 
-        Module testModule = schemaContext.findModuleByName("choice-declared-test", null);
+        final Module testModule = schemaContext.findModuleByName("choice-declared-test", null);
         assertNotNull(testModule);
 
         assertNotNull(testModule);
 
-        ChoiceSchemaNode choiceSchemaNode = (ChoiceSchemaNode) testModule.getDataChildByName(
+        final ChoiceSchemaNode choiceSchemaNode = (ChoiceSchemaNode) testModule.getDataChildByName(
                 QName.create(testModule.getQNameModule(), "test-choice"));
         assertNotNull(choiceSchemaNode);
                 QName.create(testModule.getQNameModule(), "test-choice"));
         assertNotNull(choiceSchemaNode);
-        ChoiceStatement choiceStatement = ((ChoiceEffectiveStatementImpl) choiceSchemaNode).getDeclared();
+        final ChoiceStatement choiceStatement = ((ChoiceEffectiveStatementImpl) choiceSchemaNode).getDeclared();
 
 
-        QName name = choiceStatement.getName();
+        final QName name = choiceStatement.getName();
         assertNotNull(name);
 
         assertNotNull(name);
 
-        DefaultStatement defaultStatement = choiceStatement.getDefault();
+        final DefaultStatement defaultStatement = choiceStatement.getDefault();
         assertNotNull(defaultStatement);
         assertEquals("case-two", defaultStatement.getValue());
 
         assertNotNull(defaultStatement);
         assertEquals("case-two", defaultStatement.getValue());
 
-        ConfigStatement configStatement = choiceStatement.getConfig();
+        final ConfigStatement configStatement = choiceStatement.getConfig();
         assertNotNull(configStatement);
 
         assertNotNull(configStatement);
 
-        MandatoryStatement mandatoryStatement = choiceStatement.getMandatory();
+        final MandatoryStatement mandatoryStatement = choiceStatement.getMandatory();
         assertNotNull(mandatoryStatement);
 
         assertNotNull(mandatoryStatement);
 
-        Collection<? extends CaseStatement> caseStatements = choiceStatement.getCases();
+        final Collection<? extends CaseStatement> caseStatements = choiceStatement.getCases();
         assertNotNull(caseStatements);
         assertEquals(3, caseStatements.size());
         assertNotNull(caseStatements);
         assertEquals(3, caseStatements.size());
-        CaseStatement caseStatement = caseStatements.iterator().next();
-        QName caseStatementName = caseStatement.getName();
+        final CaseStatement caseStatement = caseStatements.iterator().next();
+        final QName caseStatementName = caseStatement.getName();
         assertNotNull(caseStatementName);
         assertNotNull(caseStatementName);
-        WhenStatement caseStatementWhen = caseStatement.getWhenStatement();
+        final WhenStatement caseStatementWhen = caseStatement.getWhenStatement();
         assertNotNull(caseStatementWhen);
         assertNotNull(caseStatementWhen);
-        Collection<? extends IfFeatureStatement> caseStatementIfFeatures = caseStatement.getIfFeatures();
+        final Collection<? extends IfFeatureStatement> caseStatementIfFeatures = caseStatement.getIfFeatures();
         assertNotNull(caseStatementIfFeatures);
         assertEquals(1, caseStatementIfFeatures.size());
         assertNotNull(caseStatementIfFeatures);
         assertEquals(1, caseStatementIfFeatures.size());
-        Collection<? extends DataDefinitionStatement> caseStatementDataDefinitions = caseStatement.getDataDefinitions();
+        final Collection<? extends DataDefinitionStatement> caseStatementDataDefinitions = caseStatement.getDataDefinitions();
         assertNotNull(caseStatementDataDefinitions);
         assertEquals(1, caseStatementDataDefinitions.size());
         assertNotNull(caseStatementDataDefinitions);
         assertEquals(1, caseStatementDataDefinitions.size());
-        StatusStatement caseStatementStatus = caseStatement.getStatus();
+        final StatusStatement caseStatementStatus = caseStatement.getStatus();
         assertNotNull(caseStatementStatus);
         assertNotNull(caseStatementStatus);
-        DescriptionStatement caseStatementDescription = caseStatement.getDescription();
+        final DescriptionStatement caseStatementDescription = caseStatement.getDescription();
         assertNotNull(caseStatementDescription);
         assertNotNull(caseStatementDescription);
-        ReferenceStatement caseStatementReference = caseStatement.getReference();
+        final ReferenceStatement caseStatementReference = caseStatement.getReference();
         assertNotNull(caseStatementReference);
 
         assertNotNull(caseStatementReference);
 
-        WhenStatement whenStatement = choiceStatement.getWhenStatement();
+        final WhenStatement whenStatement = choiceStatement.getWhenStatement();
         assertNotNull(whenStatement);
 
         assertNotNull(whenStatement);
 
-        Collection<? extends IfFeatureStatement> ifFeatureStatements = choiceStatement.getIfFeatures();
+        final Collection<? extends IfFeatureStatement> ifFeatureStatements = choiceStatement.getIfFeatures();
         assertNotNull(ifFeatureStatements);
         assertEquals(1, ifFeatureStatements.size());
 
         assertNotNull(ifFeatureStatements);
         assertEquals(1, ifFeatureStatements.size());
 
-        StatusStatement statusStatement = choiceStatement.getStatus();
+        final StatusStatement statusStatement = choiceStatement.getStatus();
         assertNotNull(statusStatement);
 
         assertNotNull(statusStatement);
 
-        DescriptionStatement descriptionStatement = choiceStatement.getDescription();
+        final DescriptionStatement descriptionStatement = choiceStatement.getDescription();
         assertNotNull(descriptionStatement);
 
         assertNotNull(descriptionStatement);
 
-        ReferenceStatement referenceStatement = choiceStatement.getReference();
+        final ReferenceStatement referenceStatement = choiceStatement.getReference();
         assertNotNull(referenceStatement);
     }
 
     @Test
     public void testDeclaredAugment() throws ReactorException {
         assertNotNull(referenceStatement);
     }
 
     @Test
     public void testDeclaredAugment() throws ReactorException {
-        YangStatementSourceImpl augmentStmtModule =
+        final YangStatementSourceImpl augmentStmtModule =
                 new YangStatementSourceImpl("/declared-statements-test/augment-declared-test.yang", false);
 
                 new YangStatementSourceImpl("/declared-statements-test/augment-declared-test.yang", false);
 
-        SchemaContext schemaContext = StmtTestUtils.parseYangSources(augmentStmtModule);
+        final SchemaContext schemaContext = StmtTestUtils.parseYangSources(augmentStmtModule);
         assertNotNull(schemaContext);
 
         assertNotNull(schemaContext);
 
-        Module testModule = schemaContext.findModuleByName("augment-declared-test", null);
+        final Module testModule = schemaContext.findModuleByName("augment-declared-test", null);
         assertNotNull(testModule);
 
         assertNotNull(testModule);
 
-        Set<AugmentationSchema> augmentationSchemas = testModule.getAugmentations();
+        final Set<AugmentationSchema> augmentationSchemas = testModule.getAugmentations();
         assertNotNull(augmentationSchemas);
         assertEquals(1, augmentationSchemas.size());
 
         assertNotNull(augmentationSchemas);
         assertEquals(1, augmentationSchemas.size());
 
-        AugmentationSchema augmentationSchema = augmentationSchemas.iterator().next();
-        AugmentStatement augmentStatement = ((AugmentEffectiveStatementImpl) augmentationSchema).getDeclared();
+        final AugmentationSchema augmentationSchema = augmentationSchemas.iterator().next();
+        final AugmentStatement augmentStatement = ((AugmentEffectiveStatementImpl) augmentationSchema).getDeclared();
 
 
-        SchemaNodeIdentifier targetNode = augmentStatement.getTargetNode();
+        final SchemaNodeIdentifier targetNode = augmentStatement.getTargetNode();
         assertNotNull(targetNode);
 
         assertNotNull(targetNode);
 
-        Collection<? extends DataDefinitionStatement> augmentStatementDataDefinitions =
+        final Collection<? extends DataDefinitionStatement> augmentStatementDataDefinitions =
                 augmentStatement.getDataDefinitions();
         assertNotNull(augmentStatementDataDefinitions);
         assertEquals(1, augmentStatementDataDefinitions.size());
                 augmentStatement.getDataDefinitions();
         assertNotNull(augmentStatementDataDefinitions);
         assertEquals(1, augmentStatementDataDefinitions.size());
@@ -239,53 +240,53 @@ public class DeclaredStatementsTest {
 
     @Test
     public void testDeclaredModuleAndSubmodule() throws ReactorException {
 
     @Test
     public void testDeclaredModuleAndSubmodule() throws ReactorException {
-        YangStatementSourceImpl parentModule =
+        final YangStatementSourceImpl parentModule =
                 new YangStatementSourceImpl("/declared-statements-test/parent-module-declared-test.yang", false);
 
                 new YangStatementSourceImpl("/declared-statements-test/parent-module-declared-test.yang", false);
 
-        YangStatementSourceImpl childModule =
+        final YangStatementSourceImpl childModule =
                 new YangStatementSourceImpl("/declared-statements-test/child-module-declared-test.yang", false);
 
                 new YangStatementSourceImpl("/declared-statements-test/child-module-declared-test.yang", false);
 
-        SchemaContext schemaContext = StmtTestUtils.parseYangSources(parentModule, childModule);
+        final SchemaContext schemaContext = StmtTestUtils.parseYangSources(parentModule, childModule);
         assertNotNull(schemaContext);
 
         assertNotNull(schemaContext);
 
-        Module testModule = schemaContext.findModuleByName("parent-module-declared-test", null);
+        final Module testModule = schemaContext.findModuleByName("parent-module-declared-test", null);
         assertNotNull(testModule);
 
         assertNotNull(testModule);
 
-        ModuleStatement moduleStatement = ((ModuleEffectiveStatementImpl) testModule).getDeclared();
+        final ModuleStatement moduleStatement = ((ModuleEffectiveStatementImpl) testModule).getDeclared();
 
 
-        String moduleStatementName = moduleStatement.getName();
+        final String moduleStatementName = moduleStatement.getName();
         assertNotNull(moduleStatementName);
 
         assertNotNull(moduleStatementName);
 
-        YangVersionStatement moduleStatementYangVersion = moduleStatement.getYangVersion();
+        final YangVersionStatement moduleStatementYangVersion = moduleStatement.getYangVersion();
         assertNotNull(moduleStatementYangVersion);
         assertNotNull(moduleStatementYangVersion.getValue());
 
         assertNotNull(moduleStatementYangVersion);
         assertNotNull(moduleStatementYangVersion.getValue());
 
-        NamespaceStatement moduleStatementNamspace = moduleStatement.getNamespace();
+        final NamespaceStatement moduleStatementNamspace = moduleStatement.getNamespace();
         assertNotNull(moduleStatementNamspace);
         assertNotNull(moduleStatementNamspace.getUri());
 
         assertNotNull(moduleStatementNamspace);
         assertNotNull(moduleStatementNamspace.getUri());
 
-        PrefixStatement moduleStatementPrefix= moduleStatement.getPrefix();
+        final PrefixStatement moduleStatementPrefix= moduleStatement.getPrefix();
         assertNotNull(moduleStatementPrefix);
         assertNotNull(moduleStatementPrefix.getValue());
 
         assertEquals(1, moduleStatement.getIncludes().size());
         assertNotNull(moduleStatementPrefix);
         assertNotNull(moduleStatementPrefix.getValue());
 
         assertEquals(1, moduleStatement.getIncludes().size());
-        IncludeStatement includeStatement = moduleStatement.getIncludes().iterator().next();
+        final IncludeStatement includeStatement = moduleStatement.getIncludes().iterator().next();
         assertEquals("child-module-declared-test", includeStatement.getModule());
 
         assertEquals("child-module-declared-test", includeStatement.getModule());
 
-        Set<Module> submodules = testModule.getSubmodules();
+        final Set<Module> submodules = testModule.getSubmodules();
         assertNotNull(submodules);
         assertEquals(1, submodules.size());
 
         assertNotNull(submodules);
         assertEquals(1, submodules.size());
 
-        Module submodule = submodules.iterator().next();
-        SubmoduleStatement submoduleStatement = ((SubmoduleEffectiveStatementImpl) submodule).getDeclared();
+        final Module submodule = submodules.iterator().next();
+        final SubmoduleStatement submoduleStatement = ((SubmoduleEffectiveStatementImpl) submodule).getDeclared();
 
 
-        String submoduleStatementName = submoduleStatement.getName();
+        final String submoduleStatementName = submoduleStatement.getName();
         assertNotNull(submoduleStatementName);
 
         assertNotNull(submoduleStatementName);
 
-        YangVersionStatement submoduleStatementYangVersion = submoduleStatement.getYangVersion();
+        final YangVersionStatement submoduleStatementYangVersion = submoduleStatement.getYangVersion();
         assertNotNull(submoduleStatementYangVersion);
 
         assertNotNull(submoduleStatementYangVersion);
 
-        BelongsToStatement belongsToStatement = submoduleStatement.getBelongsTo();
+        final BelongsToStatement belongsToStatement = submoduleStatement.getBelongsTo();
         assertNotNull(belongsToStatement);
         assertNotNull(belongsToStatement.getModule());
         assertNotNull(belongsToStatement.getPrefix());
         assertNotNull(belongsToStatement);
         assertNotNull(belongsToStatement.getModule());
         assertNotNull(belongsToStatement.getPrefix());
@@ -293,24 +294,24 @@ public class DeclaredStatementsTest {
 
     @Test
     public void testDeclaredModule() throws ReactorException, ParseException {
 
     @Test
     public void testDeclaredModule() throws ReactorException, ParseException {
-        YangStatementSourceImpl rootModule =
+        final YangStatementSourceImpl rootModule =
                 new YangStatementSourceImpl("/declared-statements-test/root-module-declared-test.yang", false);
 
                 new YangStatementSourceImpl("/declared-statements-test/root-module-declared-test.yang", false);
 
-        YangStatementSourceImpl importedModule =
+        final YangStatementSourceImpl importedModule =
                 new YangStatementSourceImpl("/declared-statements-test/imported-module-declared-test.yang", false);
 
                 new YangStatementSourceImpl("/declared-statements-test/imported-module-declared-test.yang", false);
 
-        SchemaContext schemaContext = StmtTestUtils.parseYangSources(rootModule, importedModule);
+        final SchemaContext schemaContext = StmtTestUtils.parseYangSources(rootModule, importedModule);
         assertNotNull(schemaContext);
 
         assertNotNull(schemaContext);
 
-        Date revision = SimpleDateFormatUtil.getRevisionFormat().parse("2016-09-28");
+        final Date revision = SimpleDateFormatUtil.getRevisionFormat().parse("2016-09-28");
 
 
-        Module testModule = schemaContext.findModuleByName("root-module-declared-test", revision);
+        final Module testModule = schemaContext.findModuleByName("root-module-declared-test", revision);
         assertNotNull(testModule);
 
         assertNotNull(testModule);
 
-        ModuleStatement moduleStatement = ((ModuleEffectiveStatementImpl) testModule).getDeclared();
+        final ModuleStatement moduleStatement = ((ModuleEffectiveStatementImpl) testModule).getDeclared();
 
         assertEquals(1, moduleStatement.getImports().size());
 
         assertEquals(1, moduleStatement.getImports().size());
-        ImportStatement importStatement = moduleStatement.getImports().iterator().next();
+        final ImportStatement importStatement = moduleStatement.getImports().iterator().next();
         assertEquals("imported-module-declared-test", importStatement.getModule());
         assertEquals("imdt", importStatement.getPrefix().getValue());
         assertEquals(revision, importStatement.getRevisionDate().getDate());
         assertEquals("imported-module-declared-test", importStatement.getModule());
         assertEquals("imdt", importStatement.getPrefix().getValue());
         assertEquals(revision, importStatement.getRevisionDate().getDate());
@@ -321,22 +322,22 @@ public class DeclaredStatementsTest {
         assertEquals("test contact", moduleStatement.getContact().getText());
 
         assertEquals(1, moduleStatement.getRevisions().size());
         assertEquals("test contact", moduleStatement.getContact().getText());
 
         assertEquals(1, moduleStatement.getRevisions().size());
-        RevisionStatement revisionStatement = moduleStatement.getRevisions().iterator().next();
+        final RevisionStatement revisionStatement = moduleStatement.getRevisions().iterator().next();
         assertEquals(revision, revisionStatement.getDate());
         assertEquals("test description", revisionStatement.getDescription().getText());
         assertEquals("test reference", revisionStatement.getReference().getText());
 
         assertEquals(1, moduleStatement.getExtensions().size());
         assertEquals(revision, revisionStatement.getDate());
         assertEquals("test description", revisionStatement.getDescription().getText());
         assertEquals("test reference", revisionStatement.getReference().getText());
 
         assertEquals(1, moduleStatement.getExtensions().size());
-        ExtensionStatement extensionStatement = moduleStatement.getExtensions().iterator().next();
+        final ExtensionStatement extensionStatement = moduleStatement.getExtensions().iterator().next();
         assertEquals(Status.CURRENT, extensionStatement.getStatus().getValue());
         assertEquals("test description", extensionStatement.getDescription().getText());
         assertEquals("test reference", extensionStatement.getReference().getText());
         assertEquals(Status.CURRENT, extensionStatement.getStatus().getValue());
         assertEquals("test description", extensionStatement.getDescription().getText());
         assertEquals("test reference", extensionStatement.getReference().getText());
-        ArgumentStatement argumentStatement = extensionStatement.getArgument();
+        final ArgumentStatement argumentStatement = extensionStatement.getArgument();
         assertEquals("ext-argument", argumentStatement.getName().getLocalName());
         assertTrue(argumentStatement.getYinElement().getValue());
 
         assertEquals(1, moduleStatement.getFeatures().size());
         assertEquals("ext-argument", argumentStatement.getName().getLocalName());
         assertTrue(argumentStatement.getYinElement().getValue());
 
         assertEquals(1, moduleStatement.getFeatures().size());
-        FeatureStatement featureStatement = moduleStatement.getFeatures().iterator().next();
+        final FeatureStatement featureStatement = moduleStatement.getFeatures().iterator().next();
         assertEquals(Status.CURRENT, featureStatement.getStatus().getValue());
         assertEquals("test description", featureStatement.getDescription().getText());
         assertEquals("test reference", featureStatement.getReference().getText());
         assertEquals(Status.CURRENT, featureStatement.getStatus().getValue());
         assertEquals("test description", featureStatement.getDescription().getText());
         assertEquals("test reference", featureStatement.getReference().getText());
@@ -345,7 +346,7 @@ public class DeclaredStatementsTest {
 
         assertEquals(2, moduleStatement.getIdentities().size());
         IdentityStatement identityStatement = null;
 
         assertEquals(2, moduleStatement.getIdentities().size());
         IdentityStatement identityStatement = null;
-        for (IdentityStatement identity : moduleStatement.getIdentities()) {
+        for (final IdentityStatement identity : moduleStatement.getIdentities()) {
             if (identity.getName().getLocalName().equals("test-id")) {
                 identityStatement = identity;
             }
             if (identity.getName().getLocalName().equals("test-id")) {
                 identityStatement = identity;
             }
@@ -358,7 +359,7 @@ public class DeclaredStatementsTest {
         assertEquals("test-id", identityStatement.getName().getLocalName());
 
         assertEquals(1, moduleStatement.getTypedefs().size());
         assertEquals("test-id", identityStatement.getName().getLocalName());
 
         assertEquals(1, moduleStatement.getTypedefs().size());
-        TypedefStatement typedefStatement = moduleStatement.getTypedefs().iterator().next();
+        final TypedefStatement typedefStatement = moduleStatement.getTypedefs().iterator().next();
         assertEquals(Status.CURRENT, typedefStatement.getStatus().getValue());
         assertEquals("test description", typedefStatement.getDescription().getText());
         assertEquals("test reference", typedefStatement.getReference().getText());
         assertEquals(Status.CURRENT, typedefStatement.getStatus().getValue());
         assertEquals("test description", typedefStatement.getDescription().getText());
         assertEquals("test reference", typedefStatement.getReference().getText());
@@ -369,59 +370,59 @@ public class DeclaredStatementsTest {
 
     @Test
     public void testDeclaredContainer() throws ReactorException {
 
     @Test
     public void testDeclaredContainer() throws ReactorException {
-        YangStatementSourceImpl containerStmtModule =
+        final YangStatementSourceImpl containerStmtModule =
                 new YangStatementSourceImpl("/declared-statements-test/container-declared-test.yang", false);
 
                 new YangStatementSourceImpl("/declared-statements-test/container-declared-test.yang", false);
 
-        SchemaContext schemaContext = StmtTestUtils.parseYangSources(containerStmtModule);
+        final SchemaContext schemaContext = StmtTestUtils.parseYangSources(containerStmtModule);
         assertNotNull(schemaContext);
 
         assertNotNull(schemaContext);
 
-        Module testModule = schemaContext.findModuleByName("container-declared-test", null);
+        final Module testModule = schemaContext.findModuleByName("container-declared-test", null);
         assertNotNull(testModule);
 
         assertNotNull(testModule);
 
-        ContainerSchemaNode containerSchemaNode = (ContainerSchemaNode) testModule.getDataChildByName(
+        final ContainerSchemaNode containerSchemaNode = (ContainerSchemaNode) testModule.getDataChildByName(
                 QName.create(testModule.getQNameModule(), "test-container"));
         assertNotNull(containerSchemaNode);
                 QName.create(testModule.getQNameModule(), "test-container"));
         assertNotNull(containerSchemaNode);
-        ContainerStatement containerStatement = ((ContainerEffectiveStatementImpl) containerSchemaNode).getDeclared();
+        final ContainerStatement containerStatement = ((ContainerEffectiveStatementImpl) containerSchemaNode).getDeclared();
 
 
-        QName name = containerStatement.getName();
+        final QName name = containerStatement.getName();
         assertNotNull(name);
 
         assertNotNull(name);
 
-        WhenStatement containerStatementWhen = containerStatement.getWhenStatement();
+        final WhenStatement containerStatementWhen = containerStatement.getWhenStatement();
         assertNotNull(containerStatementWhen);
 
         assertNotNull(containerStatementWhen);
 
-        Collection<? extends IfFeatureStatement> containerStatementIfFeatures = containerStatement.getIfFeatures();
+        final Collection<? extends IfFeatureStatement> containerStatementIfFeatures = containerStatement.getIfFeatures();
         assertNotNull(containerStatementIfFeatures);
         assertEquals(1, containerStatementIfFeatures.size());
 
         assertNotNull(containerStatementIfFeatures);
         assertEquals(1, containerStatementIfFeatures.size());
 
-        Collection<? extends MustStatement> containerStatementMusts = containerStatement.getMusts();
+        final Collection<? extends MustStatement> containerStatementMusts = containerStatement.getMusts();
         assertNotNull(containerStatementMusts);
         assertEquals(1, containerStatementMusts.size());
 
         assertNotNull(containerStatementMusts);
         assertEquals(1, containerStatementMusts.size());
 
-        PresenceStatement containerStatementPresence = containerStatement.getPresence();
+        final PresenceStatement containerStatementPresence = containerStatement.getPresence();
         assertNotNull(containerStatementPresence);
         assertNotNull(containerStatementPresence.getValue());
 
         assertNotNull(containerStatementPresence);
         assertNotNull(containerStatementPresence.getValue());
 
-        ConfigStatement containerStatementConfig = containerStatement.getConfig();
+        final ConfigStatement containerStatementConfig = containerStatement.getConfig();
         assertNotNull(containerStatementConfig);
 
         assertNotNull(containerStatementConfig);
 
-        StatusStatement containerStatementStatus = containerStatement.getStatus();
+        final StatusStatement containerStatementStatus = containerStatement.getStatus();
         assertNotNull(containerStatementStatus);
 
         assertNotNull(containerStatementStatus);
 
-        DescriptionStatement containerStatementDescription = containerStatement.getDescription();
+        final DescriptionStatement containerStatementDescription = containerStatement.getDescription();
         assertNotNull(containerStatementDescription);
 
         assertNotNull(containerStatementDescription);
 
-        ReferenceStatement containerStatementReference = containerStatement.getReference();
+        final ReferenceStatement containerStatementReference = containerStatement.getReference();
         assertNotNull(containerStatementReference);
 
         assertNotNull(containerStatementReference);
 
-        Collection<? extends TypedefStatement> containerStatementTypedefs = containerStatement.getTypedefs();
+        final Collection<? extends TypedefStatement> containerStatementTypedefs = containerStatement.getTypedefs();
         assertNotNull(containerStatementTypedefs);
         assertEquals(1, containerStatementTypedefs.size());
 
         assertNotNull(containerStatementTypedefs);
         assertEquals(1, containerStatementTypedefs.size());
 
-        Collection<? extends GroupingStatement> containerStatementGroupings = containerStatement.getGroupings();
+        final Collection<? extends GroupingStatement> containerStatementGroupings = containerStatement.getGroupings();
         assertNotNull(containerStatementGroupings);
         assertEquals(1, containerStatementGroupings.size());
 
         assertNotNull(containerStatementGroupings);
         assertEquals(1, containerStatementGroupings.size());
 
-        Collection<? extends DataDefinitionStatement> containerStatementDataDefinitions =
+        final Collection<? extends DataDefinitionStatement> containerStatementDataDefinitions =
                 containerStatement.getDataDefinitions();
 
         assertNotNull(containerStatementDataDefinitions);
                 containerStatement.getDataDefinitions();
 
         assertNotNull(containerStatementDataDefinitions);
index c26cb5ab5ab816c34757ab3c31e488ce114e4f06..5a2a5f9d0e07760909e7ce47099f93a7852eda73 100644 (file)
@@ -12,9 +12,8 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 
-import java.util.HashSet;
+import com.google.common.collect.ImmutableSet;
 import java.util.Set;
 import java.util.Set;
-import java.util.function.Predicate;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.AnyXmlSchemaNode;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.AnyXmlSchemaNode;
@@ -37,105 +36,101 @@ public class IfFeatureResolutionTest {
 
     @Test
     public void testSomeFeaturesSupported() throws ReactorException {
 
     @Test
     public void testSomeFeaturesSupported() throws ReactorException {
-        Predicate<QName> isFeatureSupported = qName -> {
-            Set<QName> supportedFeatures = new HashSet<>();
-            supportedFeatures.add(QName.create("foo-namespace", "1970-01-01", "test-feature-1"));
-            supportedFeatures.add(QName.create("foo-namespace", "1970-01-01", "test-feature-2"));
-            supportedFeatures.add(QName.create("foo-namespace", "1970-01-01", "test-feature-3"));
-            supportedFeatures.add(QName.create("bar-namespace", "1970-01-01", "imp-feature"));
+        final Set<QName> supportedFeatures = ImmutableSet.of(
+                QName.create("foo-namespace", "1970-01-01", "test-feature-1"),
+                QName.create("foo-namespace", "1970-01-01", "test-feature-2"),
+                QName.create("foo-namespace", "1970-01-01", "test-feature-3"),
+                QName.create("bar-namespace", "1970-01-01", "imp-feature"));
 
 
-            return supportedFeatures.contains(qName);
-        };
-
-        CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild(isFeatureSupported);
+        final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild(supportedFeatures);
         reactor.addSources(FOO_MODULE, BAR_MODULE);
 
         reactor.addSources(FOO_MODULE, BAR_MODULE);
 
-        SchemaContext schemaContext = reactor.buildEffective();
+        final SchemaContext schemaContext = reactor.buildEffective();
         assertNotNull(schemaContext);
 
         assertNotNull(schemaContext);
 
-        Module testModule = schemaContext.findModuleByName("foo", null);
+        final Module testModule = schemaContext.findModuleByName("foo", null);
         assertNotNull(testModule);
 
         assertEquals(9, testModule.getChildNodes().size());
 
         assertNotNull(testModule);
 
         assertEquals(9, testModule.getChildNodes().size());
 
-        ContainerSchemaNode testContainerA = (ContainerSchemaNode) testModule.getDataChildByName(
+        final ContainerSchemaNode testContainerA = (ContainerSchemaNode) testModule.getDataChildByName(
                 QName.create(testModule.getQNameModule(), "test-container-a"));
         assertNull(testContainerA);
 
                 QName.create(testModule.getQNameModule(), "test-container-a"));
         assertNull(testContainerA);
 
-        ContainerSchemaNode testContainerB = (ContainerSchemaNode) testModule.getDataChildByName(
+        final ContainerSchemaNode testContainerB = (ContainerSchemaNode) testModule.getDataChildByName(
                 QName.create(testModule.getQNameModule(), "test-container-b"));
         assertNotNull(testContainerB);
                 QName.create(testModule.getQNameModule(), "test-container-b"));
         assertNotNull(testContainerB);
-        LeafSchemaNode testLeafB = (LeafSchemaNode) testContainerB.getDataChildByName(
+        final LeafSchemaNode testLeafB = (LeafSchemaNode) testContainerB.getDataChildByName(
                 QName.create(testModule.getQNameModule(), "test-leaf-b"));
         assertNotNull(testLeafB);
 
                 QName.create(testModule.getQNameModule(), "test-leaf-b"));
         assertNotNull(testLeafB);
 
-        ContainerSchemaNode testContainerC = (ContainerSchemaNode) testModule.getDataChildByName(
+        final ContainerSchemaNode testContainerC = (ContainerSchemaNode) testModule.getDataChildByName(
                 QName.create(testModule.getQNameModule(), "test-container-c"));
         assertNotNull(testContainerC);
                 QName.create(testModule.getQNameModule(), "test-container-c"));
         assertNotNull(testContainerC);
-        LeafSchemaNode testLeafC = (LeafSchemaNode) testContainerC.getDataChildByName(
+        final LeafSchemaNode testLeafC = (LeafSchemaNode) testContainerC.getDataChildByName(
                 QName.create(testModule.getQNameModule(), "test-leaf-c"));
         assertNotNull(testLeafC);
 
                 QName.create(testModule.getQNameModule(), "test-leaf-c"));
         assertNotNull(testLeafC);
 
-        ContainerSchemaNode testContainerD = (ContainerSchemaNode) testModule.getDataChildByName(
+        final ContainerSchemaNode testContainerD = (ContainerSchemaNode) testModule.getDataChildByName(
                 QName.create(testModule.getQNameModule(), "test-container-d"));
         assertNull(testContainerD);
 
                 QName.create(testModule.getQNameModule(), "test-container-d"));
         assertNull(testContainerD);
 
-        ContainerSchemaNode testContainerE = (ContainerSchemaNode) testModule.getDataChildByName(
+        final ContainerSchemaNode testContainerE = (ContainerSchemaNode) testModule.getDataChildByName(
                 QName.create(testModule.getQNameModule(), "test-container-e"));
         assertNotNull(testContainerE);
                 QName.create(testModule.getQNameModule(), "test-container-e"));
         assertNotNull(testContainerE);
-        ContainerSchemaNode testSubContainerE = (ContainerSchemaNode) testContainerE.getDataChildByName(
+        final ContainerSchemaNode testSubContainerE = (ContainerSchemaNode) testContainerE.getDataChildByName(
                 QName.create(testModule.getQNameModule(), "test-subcontainer-e"));
         assertNotNull(testSubContainerE);
                 QName.create(testModule.getQNameModule(), "test-subcontainer-e"));
         assertNotNull(testSubContainerE);
-        LeafSchemaNode testLeafE = (LeafSchemaNode) testSubContainerE.getDataChildByName(
+        final LeafSchemaNode testLeafE = (LeafSchemaNode) testSubContainerE.getDataChildByName(
                 QName.create(testModule.getQNameModule(), "test-leaf-e"));
         assertNull(testLeafE);
 
                 QName.create(testModule.getQNameModule(), "test-leaf-e"));
         assertNull(testLeafE);
 
-        ContainerSchemaNode testContainerF = (ContainerSchemaNode) testModule.getDataChildByName(
+        final ContainerSchemaNode testContainerF = (ContainerSchemaNode) testModule.getDataChildByName(
                 QName.create(testModule.getQNameModule(), "test-container-f"));
         assertNotNull(testContainerF);
                 QName.create(testModule.getQNameModule(), "test-container-f"));
         assertNotNull(testContainerF);
-        ContainerSchemaNode testSubContainerF = (ContainerSchemaNode) testContainerF.getDataChildByName(
+        final ContainerSchemaNode testSubContainerF = (ContainerSchemaNode) testContainerF.getDataChildByName(
                 QName.create(testModule.getQNameModule(), "test-subcontainer-f"));
         assertNull(testSubContainerF);
 
                 QName.create(testModule.getQNameModule(), "test-subcontainer-f"));
         assertNull(testSubContainerF);
 
-        ContainerSchemaNode testContainerG = (ContainerSchemaNode) testModule.getDataChildByName(
+        final ContainerSchemaNode testContainerG = (ContainerSchemaNode) testModule.getDataChildByName(
                 QName.create(testModule.getQNameModule(), "test-container-g"));
         assertNotNull(testContainerG);
         assertEquals(1, testContainerG.getAvailableAugmentations().size());
                 QName.create(testModule.getQNameModule(), "test-container-g"));
         assertNotNull(testContainerG);
         assertEquals(1, testContainerG.getAvailableAugmentations().size());
-        LeafSchemaNode testLeafG = (LeafSchemaNode) testContainerG.getDataChildByName(
+        final LeafSchemaNode testLeafG = (LeafSchemaNode) testContainerG.getDataChildByName(
                 QName.create(testModule.getQNameModule(), "test-leaf-g"));
         assertNotNull(testLeafG);
                 QName.create(testModule.getQNameModule(), "test-leaf-g"));
         assertNotNull(testLeafG);
-        LeafSchemaNode augmentingTestLeafG = (LeafSchemaNode) testContainerG.getDataChildByName(
+        final LeafSchemaNode augmentingTestLeafG = (LeafSchemaNode) testContainerG.getDataChildByName(
                 QName.create(testModule.getQNameModule(), "augmenting-test-leaf-g"));
         assertNull(augmentingTestLeafG);
                 QName.create(testModule.getQNameModule(), "augmenting-test-leaf-g"));
         assertNull(augmentingTestLeafG);
-        AnyXmlSchemaNode augmentingTestAnyxmlG = (AnyXmlSchemaNode) testContainerG.getDataChildByName(
+        final AnyXmlSchemaNode augmentingTestAnyxmlG = (AnyXmlSchemaNode) testContainerG.getDataChildByName(
                 QName.create(testModule.getQNameModule(), "augmenting-test-anyxml-g"));
         assertNotNull(augmentingTestAnyxmlG);
 
                 QName.create(testModule.getQNameModule(), "augmenting-test-anyxml-g"));
         assertNotNull(augmentingTestAnyxmlG);
 
-        ContainerSchemaNode testContainerH = (ContainerSchemaNode) testModule.getDataChildByName(
+        final ContainerSchemaNode testContainerH = (ContainerSchemaNode) testModule.getDataChildByName(
                 QName.create(testModule.getQNameModule(), "test-container-h"));
         assertNotNull(testContainerH);
         assertEquals(0, testContainerH.getChildNodes().size());
         assertEquals(0, testContainerH.getUses().size());
 
                 QName.create(testModule.getQNameModule(), "test-container-h"));
         assertNotNull(testContainerH);
         assertEquals(0, testContainerH.getChildNodes().size());
         assertEquals(0, testContainerH.getUses().size());
 
-        ContainerSchemaNode testContainerI = (ContainerSchemaNode) testModule.getDataChildByName(
+        final ContainerSchemaNode testContainerI = (ContainerSchemaNode) testModule.getDataChildByName(
                 QName.create(testModule.getQNameModule(), "test-container-i"));
         assertNotNull(testContainerI);
         assertEquals(1, testContainerI.getUses().size());
         ContainerSchemaNode testGroupingSubContainer = (ContainerSchemaNode) testContainerI.getDataChildByName(
                 QName.create(testModule.getQNameModule(), "test-grouping-subcontainer"));
         assertNotNull(testGroupingSubContainer);
                 QName.create(testModule.getQNameModule(), "test-container-i"));
         assertNotNull(testContainerI);
         assertEquals(1, testContainerI.getUses().size());
         ContainerSchemaNode testGroupingSubContainer = (ContainerSchemaNode) testContainerI.getDataChildByName(
                 QName.create(testModule.getQNameModule(), "test-grouping-subcontainer"));
         assertNotNull(testGroupingSubContainer);
-        LeafSchemaNode testGroupingLeaf = (LeafSchemaNode) testGroupingSubContainer.getDataChildByName(
+        final LeafSchemaNode testGroupingLeaf = (LeafSchemaNode) testGroupingSubContainer.getDataChildByName(
                 QName.create(testModule.getQNameModule(), "test-grouping-leaf"));
         assertNull(testGroupingLeaf);
 
                 QName.create(testModule.getQNameModule(), "test-grouping-leaf"));
         assertNull(testGroupingLeaf);
 
-        ContainerSchemaNode testContainerJ = (ContainerSchemaNode) testModule.getDataChildByName(
+        final ContainerSchemaNode testContainerJ = (ContainerSchemaNode) testModule.getDataChildByName(
                 QName.create(testModule.getQNameModule(), "test-container-j"));
         assertNotNull(testContainerJ);
                 QName.create(testModule.getQNameModule(), "test-container-j"));
         assertNotNull(testContainerJ);
-        LeafSchemaNode testLeafJ = (LeafSchemaNode) testContainerJ.getDataChildByName(
+        final LeafSchemaNode testLeafJ = (LeafSchemaNode) testContainerJ.getDataChildByName(
                 QName.create(testModule.getQNameModule(), "test-leaf-j"));
         assertNotNull(testLeafJ);
 
                 QName.create(testModule.getQNameModule(), "test-leaf-j"));
         assertNotNull(testLeafJ);
 
-        ContainerSchemaNode testContainerK = (ContainerSchemaNode) testModule.getDataChildByName(
+        final ContainerSchemaNode testContainerK = (ContainerSchemaNode) testModule.getDataChildByName(
                 QName.create(testModule.getQNameModule(), "test-container-k"));
         assertNotNull(testContainerK);
         assertEquals(1, testContainerK.getUses().size());
                 QName.create(testModule.getQNameModule(), "test-container-k"));
         assertNotNull(testContainerK);
         assertEquals(1, testContainerK.getUses().size());
@@ -143,94 +138,94 @@ public class IfFeatureResolutionTest {
                 QName.create(testModule.getQNameModule(), "test-grouping-subcontainer"));
         assertNotNull(testGroupingSubContainer);
         assertEquals(1, testGroupingSubContainer.getAvailableAugmentations().size());
                 QName.create(testModule.getQNameModule(), "test-grouping-subcontainer"));
         assertNotNull(testGroupingSubContainer);
         assertEquals(1, testGroupingSubContainer.getAvailableAugmentations().size());
-        LeafSchemaNode augmentingTestGroupingLeaf = (LeafSchemaNode) testGroupingSubContainer.getDataChildByName(
+        final LeafSchemaNode augmentingTestGroupingLeaf = (LeafSchemaNode) testGroupingSubContainer.getDataChildByName(
                 QName.create(testModule.getQNameModule(), "augmenting-test-grouping-leaf"));
         assertNotNull(augmentingTestGroupingLeaf);
                 QName.create(testModule.getQNameModule(), "augmenting-test-grouping-leaf"));
         assertNotNull(augmentingTestGroupingLeaf);
-        LeafSchemaNode augmentingTestGroupingLeaf2 = (LeafSchemaNode) testGroupingSubContainer.getDataChildByName(
+        final LeafSchemaNode augmentingTestGroupingLeaf2 = (LeafSchemaNode) testGroupingSubContainer.getDataChildByName(
                 QName.create(testModule.getQNameModule(), "augmenting-test-grouping-leaf-2"));
         assertNull(augmentingTestGroupingLeaf2);
     }
 
     @Test
     public void testAllFeaturesSupported() throws ReactorException {
                 QName.create(testModule.getQNameModule(), "augmenting-test-grouping-leaf-2"));
         assertNull(augmentingTestGroupingLeaf2);
     }
 
     @Test
     public void testAllFeaturesSupported() throws ReactorException {
-        CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
+        final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
         reactor.addSources(FOO_MODULE, BAR_MODULE);
 
         reactor.addSources(FOO_MODULE, BAR_MODULE);
 
-        SchemaContext schemaContext = reactor.buildEffective();
+        final SchemaContext schemaContext = reactor.buildEffective();
         assertNotNull(schemaContext);
 
         assertNotNull(schemaContext);
 
-        Module testModule = schemaContext.findModuleByName("foo", null);
+        final Module testModule = schemaContext.findModuleByName("foo", null);
         assertNotNull(testModule);
 
         assertEquals(11, testModule.getChildNodes().size());
 
         assertNotNull(testModule);
 
         assertEquals(11, testModule.getChildNodes().size());
 
-        ContainerSchemaNode testContainerA = (ContainerSchemaNode) testModule.getDataChildByName(
+        final ContainerSchemaNode testContainerA = (ContainerSchemaNode) testModule.getDataChildByName(
                 QName.create(testModule.getQNameModule(), "test-container-a"));
         assertNotNull(testContainerA);
                 QName.create(testModule.getQNameModule(), "test-container-a"));
         assertNotNull(testContainerA);
-        LeafSchemaNode testLeafA = (LeafSchemaNode) testContainerA.getDataChildByName(
+        final LeafSchemaNode testLeafA = (LeafSchemaNode) testContainerA.getDataChildByName(
                 QName.create(testModule.getQNameModule(), "test-leaf-a"));
         assertNotNull(testLeafA);
 
 
                 QName.create(testModule.getQNameModule(), "test-leaf-a"));
         assertNotNull(testLeafA);
 
 
-        ContainerSchemaNode testContainerB = (ContainerSchemaNode) testModule.getDataChildByName(
+        final ContainerSchemaNode testContainerB = (ContainerSchemaNode) testModule.getDataChildByName(
                 QName.create(testModule.getQNameModule(), "test-container-b"));
         assertNotNull(testContainerB);
                 QName.create(testModule.getQNameModule(), "test-container-b"));
         assertNotNull(testContainerB);
-        LeafSchemaNode testLeafB = (LeafSchemaNode) testContainerB.getDataChildByName(
+        final LeafSchemaNode testLeafB = (LeafSchemaNode) testContainerB.getDataChildByName(
                 QName.create(testModule.getQNameModule(), "test-leaf-b"));
         assertNotNull(testLeafB);
 
                 QName.create(testModule.getQNameModule(), "test-leaf-b"));
         assertNotNull(testLeafB);
 
-        ContainerSchemaNode testContainerC = (ContainerSchemaNode) testModule.getDataChildByName(
+        final ContainerSchemaNode testContainerC = (ContainerSchemaNode) testModule.getDataChildByName(
                 QName.create(testModule.getQNameModule(), "test-container-c"));
         assertNotNull(testContainerC);
                 QName.create(testModule.getQNameModule(), "test-container-c"));
         assertNotNull(testContainerC);
-        LeafSchemaNode testLeafC = (LeafSchemaNode) testContainerC.getDataChildByName(
+        final LeafSchemaNode testLeafC = (LeafSchemaNode) testContainerC.getDataChildByName(
                 QName.create(testModule.getQNameModule(), "test-leaf-c"));
         assertNotNull(testLeafC);
 
                 QName.create(testModule.getQNameModule(), "test-leaf-c"));
         assertNotNull(testLeafC);
 
-        ContainerSchemaNode testContainerD = (ContainerSchemaNode) testModule.getDataChildByName(
+        final ContainerSchemaNode testContainerD = (ContainerSchemaNode) testModule.getDataChildByName(
                 QName.create(testModule.getQNameModule(), "test-container-d"));
         assertNotNull(testContainerD);
                 QName.create(testModule.getQNameModule(), "test-container-d"));
         assertNotNull(testContainerD);
-        LeafSchemaNode testLeafD = (LeafSchemaNode) testContainerD.getDataChildByName(
+        final LeafSchemaNode testLeafD = (LeafSchemaNode) testContainerD.getDataChildByName(
                 QName.create(testModule.getQNameModule(), "test-leaf-d"));
         assertNotNull(testLeafD);
 
                 QName.create(testModule.getQNameModule(), "test-leaf-d"));
         assertNotNull(testLeafD);
 
-        ContainerSchemaNode testContainerE = (ContainerSchemaNode) testModule.getDataChildByName(
+        final ContainerSchemaNode testContainerE = (ContainerSchemaNode) testModule.getDataChildByName(
                 QName.create(testModule.getQNameModule(), "test-container-e"));
         assertNotNull(testContainerE);
                 QName.create(testModule.getQNameModule(), "test-container-e"));
         assertNotNull(testContainerE);
-        ContainerSchemaNode testSubContainerE = (ContainerSchemaNode) testContainerE.getDataChildByName(
+        final ContainerSchemaNode testSubContainerE = (ContainerSchemaNode) testContainerE.getDataChildByName(
                 QName.create(testModule.getQNameModule(), "test-subcontainer-e"));
         assertNotNull(testSubContainerE);
                 QName.create(testModule.getQNameModule(), "test-subcontainer-e"));
         assertNotNull(testSubContainerE);
-        LeafSchemaNode testLeafE = (LeafSchemaNode) testSubContainerE.getDataChildByName(
+        final LeafSchemaNode testLeafE = (LeafSchemaNode) testSubContainerE.getDataChildByName(
                 QName.create(testModule.getQNameModule(), "test-leaf-e"));
         assertNotNull(testLeafE);
 
                 QName.create(testModule.getQNameModule(), "test-leaf-e"));
         assertNotNull(testLeafE);
 
-        ContainerSchemaNode testContainerF = (ContainerSchemaNode) testModule.getDataChildByName(
+        final ContainerSchemaNode testContainerF = (ContainerSchemaNode) testModule.getDataChildByName(
                 QName.create(testModule.getQNameModule(), "test-container-f"));
         assertNotNull(testContainerF);
                 QName.create(testModule.getQNameModule(), "test-container-f"));
         assertNotNull(testContainerF);
-        ContainerSchemaNode testSubContainerF = (ContainerSchemaNode) testContainerF.getDataChildByName(
+        final ContainerSchemaNode testSubContainerF = (ContainerSchemaNode) testContainerF.getDataChildByName(
                 QName.create(testModule.getQNameModule(), "test-subcontainer-f"));
         assertNotNull(testSubContainerF);
                 QName.create(testModule.getQNameModule(), "test-subcontainer-f"));
         assertNotNull(testSubContainerF);
-        ContainerSchemaNode testSubSubContainerF = (ContainerSchemaNode) testSubContainerF.getDataChildByName(
+        final ContainerSchemaNode testSubSubContainerF = (ContainerSchemaNode) testSubContainerF.getDataChildByName(
                 QName.create(testModule.getQNameModule(), "test-subsubcontainer-f"));
         assertNotNull(testSubSubContainerF);
                 QName.create(testModule.getQNameModule(), "test-subsubcontainer-f"));
         assertNotNull(testSubSubContainerF);
-        LeafSchemaNode testLeafF = (LeafSchemaNode) testSubSubContainerF.getDataChildByName(
+        final LeafSchemaNode testLeafF = (LeafSchemaNode) testSubSubContainerF.getDataChildByName(
                 QName.create(testModule.getQNameModule(), "test-leaf-f"));
         assertNotNull(testLeafF);
 
                 QName.create(testModule.getQNameModule(), "test-leaf-f"));
         assertNotNull(testLeafF);
 
-        ContainerSchemaNode testContainerG = (ContainerSchemaNode) testModule.getDataChildByName(
+        final ContainerSchemaNode testContainerG = (ContainerSchemaNode) testModule.getDataChildByName(
                 QName.create(testModule.getQNameModule(), "test-container-g"));
         assertNotNull(testContainerG);
         assertEquals(2, testContainerG.getAvailableAugmentations().size());
                 QName.create(testModule.getQNameModule(), "test-container-g"));
         assertNotNull(testContainerG);
         assertEquals(2, testContainerG.getAvailableAugmentations().size());
-        LeafSchemaNode testLeafG = (LeafSchemaNode) testContainerG.getDataChildByName(
+        final LeafSchemaNode testLeafG = (LeafSchemaNode) testContainerG.getDataChildByName(
                 QName.create(testModule.getQNameModule(), "test-leaf-g"));
         assertNotNull(testLeafG);
                 QName.create(testModule.getQNameModule(), "test-leaf-g"));
         assertNotNull(testLeafG);
-        LeafSchemaNode augmentingTestLeafG = (LeafSchemaNode) testContainerG.getDataChildByName(
+        final LeafSchemaNode augmentingTestLeafG = (LeafSchemaNode) testContainerG.getDataChildByName(
                 QName.create(testModule.getQNameModule(), "augmenting-test-leaf-g"));
         assertNotNull(augmentingTestLeafG);
                 QName.create(testModule.getQNameModule(), "augmenting-test-leaf-g"));
         assertNotNull(augmentingTestLeafG);
-        AnyXmlSchemaNode augmentingTestAnyxmlG = (AnyXmlSchemaNode) testContainerG.getDataChildByName(
+        final AnyXmlSchemaNode augmentingTestAnyxmlG = (AnyXmlSchemaNode) testContainerG.getDataChildByName(
                 QName.create(testModule.getQNameModule(), "augmenting-test-anyxml-g"));
         assertNotNull(augmentingTestAnyxmlG);
 
                 QName.create(testModule.getQNameModule(), "augmenting-test-anyxml-g"));
         assertNotNull(augmentingTestAnyxmlG);
 
-        ContainerSchemaNode testContainerH = (ContainerSchemaNode) testModule.getDataChildByName(
+        final ContainerSchemaNode testContainerH = (ContainerSchemaNode) testModule.getDataChildByName(
                 QName.create(testModule.getQNameModule(), "test-container-h"));
         assertNotNull(testContainerH);
         assertEquals(1, testContainerH.getUses().size());
                 QName.create(testModule.getQNameModule(), "test-container-h"));
         assertNotNull(testContainerH);
         assertEquals(1, testContainerH.getUses().size());
@@ -241,7 +236,7 @@ public class IfFeatureResolutionTest {
                 QName.create(testModule.getQNameModule(), "test-grouping-leaf"));
         assertNotNull(testGroupingLeaf);
 
                 QName.create(testModule.getQNameModule(), "test-grouping-leaf"));
         assertNotNull(testGroupingLeaf);
 
-        ContainerSchemaNode testContainerI = (ContainerSchemaNode) testModule.getDataChildByName(
+        final ContainerSchemaNode testContainerI = (ContainerSchemaNode) testModule.getDataChildByName(
                 QName.create(testModule.getQNameModule(), "test-container-i"));
         assertNotNull(testContainerI);
         assertEquals(1, testContainerI.getUses().size());
                 QName.create(testModule.getQNameModule(), "test-container-i"));
         assertNotNull(testContainerI);
         assertEquals(1, testContainerI.getUses().size());
@@ -252,14 +247,14 @@ public class IfFeatureResolutionTest {
                 QName.create(testModule.getQNameModule(), "test-grouping-leaf"));
         assertNotNull(testGroupingLeaf);
 
                 QName.create(testModule.getQNameModule(), "test-grouping-leaf"));
         assertNotNull(testGroupingLeaf);
 
-        ContainerSchemaNode testContainerJ = (ContainerSchemaNode) testModule.getDataChildByName(
+        final ContainerSchemaNode testContainerJ = (ContainerSchemaNode) testModule.getDataChildByName(
                 QName.create(testModule.getQNameModule(), "test-container-j"));
         assertNotNull(testContainerJ);
                 QName.create(testModule.getQNameModule(), "test-container-j"));
         assertNotNull(testContainerJ);
-        LeafSchemaNode testLeafJ = (LeafSchemaNode) testContainerJ.getDataChildByName(
+        final LeafSchemaNode testLeafJ = (LeafSchemaNode) testContainerJ.getDataChildByName(
                 QName.create(testModule.getQNameModule(), "test-leaf-j"));
         assertNotNull(testLeafJ);
 
                 QName.create(testModule.getQNameModule(), "test-leaf-j"));
         assertNotNull(testLeafJ);
 
-        ContainerSchemaNode testContainerK = (ContainerSchemaNode) testModule.getDataChildByName(
+        final ContainerSchemaNode testContainerK = (ContainerSchemaNode) testModule.getDataChildByName(
                 QName.create(testModule.getQNameModule(), "test-container-k"));
         assertNotNull(testContainerK);
         assertEquals(1, testContainerK.getUses().size());
                 QName.create(testModule.getQNameModule(), "test-container-k"));
         assertNotNull(testContainerK);
         assertEquals(1, testContainerK.getUses().size());
@@ -267,10 +262,10 @@ public class IfFeatureResolutionTest {
                 QName.create(testModule.getQNameModule(), "test-grouping-subcontainer"));
         assertNotNull(testGroupingSubContainer);
         assertEquals(1, testGroupingSubContainer.getAvailableAugmentations().size());
                 QName.create(testModule.getQNameModule(), "test-grouping-subcontainer"));
         assertNotNull(testGroupingSubContainer);
         assertEquals(1, testGroupingSubContainer.getAvailableAugmentations().size());
-        LeafSchemaNode augmentingTestGroupingLeaf = (LeafSchemaNode) testGroupingSubContainer.getDataChildByName(
+        final LeafSchemaNode augmentingTestGroupingLeaf = (LeafSchemaNode) testGroupingSubContainer.getDataChildByName(
                 QName.create(testModule.getQNameModule(), "augmenting-test-grouping-leaf"));
         assertNotNull(augmentingTestGroupingLeaf);
                 QName.create(testModule.getQNameModule(), "augmenting-test-grouping-leaf"));
         assertNotNull(augmentingTestGroupingLeaf);
-        LeafSchemaNode augmentingTestGroupingLeaf2 = (LeafSchemaNode) testGroupingSubContainer.getDataChildByName(
+        final LeafSchemaNode augmentingTestGroupingLeaf2 = (LeafSchemaNode) testGroupingSubContainer.getDataChildByName(
                 QName.create(testModule.getQNameModule(), "augmenting-test-grouping-leaf-2"));
         assertNotNull(augmentingTestGroupingLeaf2);
         testGroupingLeaf = (LeafSchemaNode) testGroupingSubContainer.getDataChildByName(
                 QName.create(testModule.getQNameModule(), "augmenting-test-grouping-leaf-2"));
         assertNotNull(augmentingTestGroupingLeaf2);
         testGroupingLeaf = (LeafSchemaNode) testGroupingSubContainer.getDataChildByName(
@@ -280,57 +275,57 @@ public class IfFeatureResolutionTest {
 
     @Test
     public void testNoFeaturesSupported() throws ReactorException {
 
     @Test
     public void testNoFeaturesSupported() throws ReactorException {
-        Predicate<QName> isFeatureSupported = qName -> false;
+        final Set<QName> supportedFeatures = ImmutableSet.of();
 
 
-        CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild(isFeatureSupported);
+        final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild(supportedFeatures);
         reactor.addSources(FOO_MODULE, BAR_MODULE);
 
         reactor.addSources(FOO_MODULE, BAR_MODULE);
 
-        SchemaContext schemaContext = reactor.buildEffective();
+        final SchemaContext schemaContext = reactor.buildEffective();
         assertNotNull(schemaContext);
 
         assertNotNull(schemaContext);
 
-        Module testModule = schemaContext.findModuleByName("foo", null);
+        final Module testModule = schemaContext.findModuleByName("foo", null);
         assertNotNull(testModule);
 
         assertEquals(6, testModule.getChildNodes().size());
 
         assertNotNull(testModule);
 
         assertEquals(6, testModule.getChildNodes().size());
 
-        ContainerSchemaNode testContainerE = (ContainerSchemaNode) testModule.getDataChildByName(
+        final ContainerSchemaNode testContainerE = (ContainerSchemaNode) testModule.getDataChildByName(
                 QName.create(testModule.getQNameModule(), "test-container-e"));
         assertNotNull(testContainerE);
                 QName.create(testModule.getQNameModule(), "test-container-e"));
         assertNotNull(testContainerE);
-        ContainerSchemaNode testSubContainerE = (ContainerSchemaNode) testContainerE.getDataChildByName(
+        final ContainerSchemaNode testSubContainerE = (ContainerSchemaNode) testContainerE.getDataChildByName(
                 QName.create(testModule.getQNameModule(), "test-subcontainer-e"));
         assertNotNull(testSubContainerE);
                 QName.create(testModule.getQNameModule(), "test-subcontainer-e"));
         assertNotNull(testSubContainerE);
-        LeafSchemaNode testLeafE = (LeafSchemaNode) testSubContainerE.getDataChildByName(
+        final LeafSchemaNode testLeafE = (LeafSchemaNode) testSubContainerE.getDataChildByName(
                 QName.create(testModule.getQNameModule(), "test-leaf-e"));
         assertNull(testLeafE);
 
                 QName.create(testModule.getQNameModule(), "test-leaf-e"));
         assertNull(testLeafE);
 
-        ContainerSchemaNode testContainerF = (ContainerSchemaNode) testModule.getDataChildByName(
+        final ContainerSchemaNode testContainerF = (ContainerSchemaNode) testModule.getDataChildByName(
                 QName.create(testModule.getQNameModule(), "test-container-f"));
         assertNotNull(testContainerF);
                 QName.create(testModule.getQNameModule(), "test-container-f"));
         assertNotNull(testContainerF);
-        ContainerSchemaNode testSubContainerF = (ContainerSchemaNode) testContainerF.getDataChildByName(
+        final ContainerSchemaNode testSubContainerF = (ContainerSchemaNode) testContainerF.getDataChildByName(
                 QName.create(testModule.getQNameModule(), "test-subcontainer-f"));
         assertNull(testSubContainerF);
 
                 QName.create(testModule.getQNameModule(), "test-subcontainer-f"));
         assertNull(testSubContainerF);
 
-        ContainerSchemaNode testContainerG = (ContainerSchemaNode) testModule.getDataChildByName(
+        final ContainerSchemaNode testContainerG = (ContainerSchemaNode) testModule.getDataChildByName(
                 QName.create(testModule.getQNameModule(), "test-container-g"));
         assertNotNull(testContainerG);
         assertEquals(1, testContainerG.getAvailableAugmentations().size());
                 QName.create(testModule.getQNameModule(), "test-container-g"));
         assertNotNull(testContainerG);
         assertEquals(1, testContainerG.getAvailableAugmentations().size());
-        LeafSchemaNode testLeafG = (LeafSchemaNode) testContainerG.getDataChildByName(
+        final LeafSchemaNode testLeafG = (LeafSchemaNode) testContainerG.getDataChildByName(
                 QName.create(testModule.getQNameModule(), "test-leaf-g"));
         assertNotNull(testLeafG);
                 QName.create(testModule.getQNameModule(), "test-leaf-g"));
         assertNotNull(testLeafG);
-        LeafSchemaNode augmentingTestLeafG = (LeafSchemaNode) testContainerG.getDataChildByName(
+        final LeafSchemaNode augmentingTestLeafG = (LeafSchemaNode) testContainerG.getDataChildByName(
                 QName.create(testModule.getQNameModule(), "augmenting-test-leaf-g"));
         assertNull(augmentingTestLeafG);
                 QName.create(testModule.getQNameModule(), "augmenting-test-leaf-g"));
         assertNull(augmentingTestLeafG);
-        AnyXmlSchemaNode augmentingTestAnyxmlG = (AnyXmlSchemaNode) testContainerG.getDataChildByName(
+        final AnyXmlSchemaNode augmentingTestAnyxmlG = (AnyXmlSchemaNode) testContainerG.getDataChildByName(
                 QName.create(testModule.getQNameModule(), "augmenting-test-anyxml-g"));
         assertNotNull(augmentingTestAnyxmlG);
 
                 QName.create(testModule.getQNameModule(), "augmenting-test-anyxml-g"));
         assertNotNull(augmentingTestAnyxmlG);
 
-        ContainerSchemaNode testContainerH = (ContainerSchemaNode) testModule.getDataChildByName(
+        final ContainerSchemaNode testContainerH = (ContainerSchemaNode) testModule.getDataChildByName(
                 QName.create(testModule.getQNameModule(), "test-container-h"));
         assertNotNull(testContainerH);
         assertEquals(0, testContainerH.getChildNodes().size());
         assertEquals(0, testContainerH.getUses().size());
 
                 QName.create(testModule.getQNameModule(), "test-container-h"));
         assertNotNull(testContainerH);
         assertEquals(0, testContainerH.getChildNodes().size());
         assertEquals(0, testContainerH.getUses().size());
 
-        ContainerSchemaNode testContainerI = (ContainerSchemaNode) testModule.getDataChildByName(
+        final ContainerSchemaNode testContainerI = (ContainerSchemaNode) testModule.getDataChildByName(
                 QName.create(testModule.getQNameModule(), "test-container-i"));
         assertNotNull(testContainerI);
         assertEquals(1, testContainerI.getUses().size());
                 QName.create(testModule.getQNameModule(), "test-container-i"));
         assertNotNull(testContainerI);
         assertEquals(1, testContainerI.getUses().size());
@@ -341,7 +336,7 @@ public class IfFeatureResolutionTest {
                 QName.create(testModule.getQNameModule(), "test-grouping-leaf"));
         assertNull(testGroupingLeaf);
 
                 QName.create(testModule.getQNameModule(), "test-grouping-leaf"));
         assertNull(testGroupingLeaf);
 
-        ContainerSchemaNode testContainerK = (ContainerSchemaNode) testModule.getDataChildByName(
+        final ContainerSchemaNode testContainerK = (ContainerSchemaNode) testModule.getDataChildByName(
                 QName.create(testModule.getQNameModule(), "test-container-k"));
         assertNotNull(testContainerK);
         assertEquals(1, testContainerK.getUses().size());
                 QName.create(testModule.getQNameModule(), "test-container-k"));
         assertNotNull(testContainerK);
         assertEquals(1, testContainerK.getUses().size());
@@ -349,10 +344,10 @@ public class IfFeatureResolutionTest {
                 QName.create(testModule.getQNameModule(), "test-grouping-subcontainer"));
         assertNotNull(testGroupingSubContainer);
         assertEquals(1, testGroupingSubContainer.getAvailableAugmentations().size());
                 QName.create(testModule.getQNameModule(), "test-grouping-subcontainer"));
         assertNotNull(testGroupingSubContainer);
         assertEquals(1, testGroupingSubContainer.getAvailableAugmentations().size());
-        LeafSchemaNode augmentingTestGroupingLeaf = (LeafSchemaNode) testGroupingSubContainer.getDataChildByName(
+        final LeafSchemaNode augmentingTestGroupingLeaf = (LeafSchemaNode) testGroupingSubContainer.getDataChildByName(
                 QName.create(testModule.getQNameModule(), "augmenting-test-grouping-leaf"));
         assertNull(augmentingTestGroupingLeaf);
                 QName.create(testModule.getQNameModule(), "augmenting-test-grouping-leaf"));
         assertNull(augmentingTestGroupingLeaf);
-        LeafSchemaNode augmentingTestGroupingLeaf2 = (LeafSchemaNode) testGroupingSubContainer.getDataChildByName(
+        final LeafSchemaNode augmentingTestGroupingLeaf2 = (LeafSchemaNode) testGroupingSubContainer.getDataChildByName(
                 QName.create(testModule.getQNameModule(), "augmenting-test-grouping-leaf-2"));
         assertNull(augmentingTestGroupingLeaf2);
         testGroupingLeaf = (LeafSchemaNode) testGroupingSubContainer.getDataChildByName(
                 QName.create(testModule.getQNameModule(), "augmenting-test-grouping-leaf-2"));
         assertNull(augmentingTestGroupingLeaf2);
         testGroupingLeaf = (LeafSchemaNode) testGroupingSubContainer.getDataChildByName(
index a3435cabc5203c3d1b1cbf55dd8906ac4dbae51b..efd1fc33c068aace899403dfa8497a8407890a9d 100644 (file)
@@ -17,14 +17,12 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 import java.util.Set;
 import java.util.Collection;
 import java.util.List;
 import java.util.Set;
-import java.util.function.Predicate;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.ModuleImport;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.ModuleImport;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.repo.api.IfFeaturePredicates;
 import org.opendaylight.yangtools.yang.model.repo.api.StatementParserMode;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
 import org.opendaylight.yangtools.yang.model.repo.api.StatementParserMode;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
@@ -101,13 +99,13 @@ public class StmtTestUtils {
 
     public static SchemaContext parseYangSources(final StatementStreamSource... sources) throws SourceException,
             ReactorException {
 
     public static SchemaContext parseYangSources(final StatementStreamSource... sources) throws SourceException,
             ReactorException {
-        return parseYangSources(StatementParserMode.DEFAULT_MODE, IfFeaturePredicates.ALL_FEATURES, sources);
+        return parseYangSources(StatementParserMode.DEFAULT_MODE, null, sources);
     }
 
     }
 
-    public static SchemaContext parseYangSources(final StatementParserMode statementParserMode, final Predicate<QName> ifFeaturePredicate, final StatementStreamSource... sources)
+    public static SchemaContext parseYangSources(final StatementParserMode statementParserMode, final Set<QName> supportedFeatures, final StatementStreamSource... sources)
             throws SourceException, ReactorException {
 
             throws SourceException, ReactorException {
 
-        final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild(statementParserMode, ifFeaturePredicate);
+        final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild(statementParserMode, supportedFeatures);
         reactor.addSources(sources);
 
         return reactor.buildEffective();
         reactor.addSources(sources);
 
         return reactor.buildEffective();
@@ -115,10 +113,10 @@ public class StmtTestUtils {
 
     public static SchemaContext parseYangSources(final File... files) throws SourceException, ReactorException,
             FileNotFoundException {
 
     public static SchemaContext parseYangSources(final File... files) throws SourceException, ReactorException,
             FileNotFoundException {
-        return parseYangSources(StatementParserMode.DEFAULT_MODE, IfFeaturePredicates.ALL_FEATURES, files);
+        return parseYangSources(StatementParserMode.DEFAULT_MODE, null, files);
     }
 
     }
 
-    public static SchemaContext parseYangSources(final StatementParserMode statementParserMode, final Predicate<QName> ifFeaturePredicate, final File... files) throws SourceException,
+    public static SchemaContext parseYangSources(final StatementParserMode statementParserMode, final Set<QName> supportedFeatures, final File... files) throws SourceException,
             ReactorException, FileNotFoundException {
 
         final StatementStreamSource[] sources = new StatementStreamSource[files.length];
             ReactorException, FileNotFoundException {
 
         final StatementStreamSource[] sources = new StatementStreamSource[files.length];
@@ -127,7 +125,7 @@ public class StmtTestUtils {
             sources[i] = new YangStatementSourceImpl(new NamedFileInputStream(files[i], files[i].getPath()));
         }
 
             sources[i] = new YangStatementSourceImpl(new NamedFileInputStream(files[i], files[i].getPath()));
         }
 
-        return parseYangSources(statementParserMode, ifFeaturePredicate, sources);
+        return parseYangSources(statementParserMode, supportedFeatures, sources);
     }
 
     public static SchemaContext parseYangSources(final Collection<File> files) throws SourceException, ReactorException,
     }
 
     public static SchemaContext parseYangSources(final Collection<File> files) throws SourceException, ReactorException,
@@ -137,7 +135,7 @@ public class StmtTestUtils {
 
     public static SchemaContext parseYangSources(final Collection<File> files, final StatementParserMode statementParserMode)
             throws SourceException, ReactorException, FileNotFoundException {
 
     public static SchemaContext parseYangSources(final Collection<File> files, final StatementParserMode statementParserMode)
             throws SourceException, ReactorException, FileNotFoundException {
-        return parseYangSources(statementParserMode, IfFeaturePredicates.ALL_FEATURES, files.toArray(new File[files.size()]));
+        return parseYangSources(statementParserMode, null, files.toArray(new File[files.size()]));
     }
 
     public static SchemaContext parseYangSources(final String yangSourcesDirectoryPath) throws SourceException,
     }
 
     public static SchemaContext parseYangSources(final String yangSourcesDirectoryPath) throws SourceException,
@@ -147,29 +145,36 @@ public class StmtTestUtils {
 
     public static SchemaContext parseYangSource(final String yangSourcePath) throws SourceException, ReactorException,
             FileNotFoundException, URISyntaxException {
 
     public static SchemaContext parseYangSource(final String yangSourcePath) throws SourceException, ReactorException,
             FileNotFoundException, URISyntaxException {
-        return parseYangSource(yangSourcePath, StatementParserMode.DEFAULT_MODE, IfFeaturePredicates.ALL_FEATURES);
+        return parseYangSource(yangSourcePath, StatementParserMode.DEFAULT_MODE, null);
     }
 
     }
 
-    public static SchemaContext parseYangSource(final String yangSourcePath, final Predicate<QName> ifFeaturesPredicate)
+    public static SchemaContext parseYangSource(final String yangSourcePath, final Set<QName> supportedFeatures)
             throws SourceException, FileNotFoundException, ReactorException, URISyntaxException {
             throws SourceException, FileNotFoundException, ReactorException, URISyntaxException {
-        return parseYangSource(yangSourcePath, StatementParserMode.DEFAULT_MODE, ifFeaturesPredicate);
+        return parseYangSource(yangSourcePath, StatementParserMode.DEFAULT_MODE, supportedFeatures);
     }
 
     public static SchemaContext parseYangSource(final String yangSourcePath,
     }
 
     public static SchemaContext parseYangSource(final String yangSourcePath,
-            final StatementParserMode statementParserMode, final Predicate<QName> ifFeaturePredicate)
+            final StatementParserMode statementParserMode, final Set<QName> supportedFeatures)
             throws SourceException, ReactorException, FileNotFoundException, URISyntaxException {
         final URL source = StmtTestUtils.class.getResource(yangSourcePath);
         final File sourceFile = new File(source.toURI());
             throws SourceException, ReactorException, FileNotFoundException, URISyntaxException {
         final URL source = StmtTestUtils.class.getResource(yangSourcePath);
         final File sourceFile = new File(source.toURI());
-        return parseYangSources(statementParserMode, ifFeaturePredicate, sourceFile);
+        return parseYangSources(statementParserMode, supportedFeatures, sourceFile);
     }
 
     }
 
-    public static SchemaContext parseYangSources(final String yangSourcesDirectoryPath, final StatementParserMode statementParserMode)
-            throws SourceException, ReactorException, FileNotFoundException, URISyntaxException {
+    public static SchemaContext parseYangSources(final String yangSourcesDirectoryPath,
+            final StatementParserMode statementParserMode) throws SourceException, ReactorException,
+            FileNotFoundException, URISyntaxException {
+        return parseYangSources(yangSourcesDirectoryPath, null, statementParserMode);
+    }
+
+    public static SchemaContext parseYangSources(final String yangSourcesDirectoryPath,
+            final Set<QName> supportedFeatures, final StatementParserMode statementParserMode) throws SourceException,
+            ReactorException, FileNotFoundException, URISyntaxException {
 
         final URL resourceDir = StmtTestUtils.class.getResource(yangSourcesDirectoryPath);
         final File testSourcesDir = new File(resourceDir.toURI());
 
 
         final URL resourceDir = StmtTestUtils.class.getResource(yangSourcesDirectoryPath);
         final File testSourcesDir = new File(resourceDir.toURI());
 
-        return parseYangSources(statementParserMode, IfFeaturePredicates.ALL_FEATURES, testSourcesDir.listFiles(YANG_FILE_FILTER));
+        return parseYangSources(statementParserMode, supportedFeatures, testSourcesDir.listFiles(YANG_FILE_FILTER));
     }
 
     public static SchemaContext parseYinSources(final String yinSourcesDirectoryPath, final StatementParserMode statementParserMode)
     }
 
     public static SchemaContext parseYinSources(final String yinSourcesDirectoryPath, final StatementParserMode statementParserMode)
diff --git a/yang/yang-parser-impl/src/test/resources/rfc7950/bug6868/invalid10.yang b/yang/yang-parser-impl/src/test/resources/rfc7950/bug6868/invalid10.yang
new file mode 100644 (file)
index 0000000..5d78fb6
--- /dev/null
@@ -0,0 +1,16 @@
+module foo {
+    namespace "foo";
+    prefix foo;
+
+    container my-container-1 {
+        if-feature "(not foo) or (bar and baz)";
+    }
+
+    container my-container-2 {
+        if-feature "not foo or bar and baz";
+    }
+
+    container my-container-3 {
+        if-feature "(not foo or bar) and baz)";
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/rfc7950/bug6868/yang11/foo.yang b/yang/yang-parser-impl/src/test/resources/rfc7950/bug6868/yang11/foo.yang
new file mode 100644 (file)
index 0000000..0e4b686
--- /dev/null
@@ -0,0 +1,39 @@
+module foo {
+    namespace "foo";
+    prefix foo;
+    yang-version 1.1;
+
+    import imported { prefix imp; revision-date 2017-01-09; }
+
+    feature foo;
+    feature bar;
+    feature baz;
+
+    container my-container-1 {
+        if-feature "(not foo) or (bar and baz)";
+    }
+
+    container my-container-2 {
+        if-feature "not foo or bar and baz";
+    }
+
+    container my-container-3 {
+        if-feature "((not foo or bar) and baz)";
+    }
+
+    container foo {
+        if-feature "foo";
+    }
+
+    container not-foo {
+        if-feature "not foo";
+    }
+
+    container imp-bar {
+        if-feature "imp:bar";
+    }
+
+    container imp-bar-2 {
+        if-feature "imp:bar and not bar";
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/rfc7950/bug6868/yang11/imported.yang b/yang/yang-parser-impl/src/test/resources/rfc7950/bug6868/yang11/imported.yang
new file mode 100644 (file)
index 0000000..8c7dfe8
--- /dev/null
@@ -0,0 +1,9 @@
+module imported {
+    namespace "imp";
+    prefix imp;
+    yang-version 1;
+
+    revision "2017-01-09";
+
+    feature bar;
+}
index 256ac65a1a7ab5ee1bd0b1f2653ff303cf1454a0..2f2926bad51af1c32508ab628683833688e70954 100644 (file)
@@ -13,7 +13,6 @@ import java.util.Arrays;
 import java.util.Collection;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Collection;
 import java.util.HashSet;
 import java.util.List;
-import java.util.function.Predicate;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 import org.apache.commons.cli.BasicParser;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 import org.apache.commons.cli.BasicParser;
@@ -26,7 +25,6 @@ import org.apache.commons.cli.ParseException;
 import org.apache.log4j.BasicConfigurator;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.apache.log4j.BasicConfigurator;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.repo.api.IfFeaturePredicates;
 
 /**
  * Main class of Yang parser system test.
 
 /**
  * Main class of Yang parser system test.
@@ -107,15 +105,13 @@ public class Main {
         LOG.log(Level.INFO, "Yang model files: {0} ", yangFiles);
         LOG.log(Level.INFO, "Supported features: {0} ", supportedFeatures);
 
         LOG.log(Level.INFO, "Yang model files: {0} ", yangFiles);
         LOG.log(Level.INFO, "Supported features: {0} ", supportedFeatures);
 
-        final Predicate<QName> isFeatureSupported = supportedFeatures == null ? IfFeaturePredicates.ALL_FEATURES
-                : q -> supportedFeatures.contains(q);
         SchemaContext context = null;
 
         printMemoryInfo("start");
         final Stopwatch stopWatch = Stopwatch.createStarted();
 
         try {
         SchemaContext context = null;
 
         printMemoryInfo("start");
         final Stopwatch stopWatch = Stopwatch.createStarted();
 
         try {
-            context = SystemTestUtils.parseYangSources(yangDirs, yangFiles, isFeatureSupported);
+            context = SystemTestUtils.parseYangSources(yangDirs, yangFiles, supportedFeatures);
         } catch (final Exception e) {
             LOG.log(Level.SEVERE, "Failed to create SchemaContext.", e);
             System.exit(1);
         } catch (final Exception e) {
             LOG.log(Level.SEVERE, "Failed to create SchemaContext.", e);
             System.exit(1);
index 7ffcfce5c3de26778192020d35e96b62d2a8943f..20448408221fbd7f7b7d96d17950bc6dac22940f 100644 (file)
@@ -15,7 +15,7 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.List;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.List;
-import java.util.function.Predicate;
+import java.util.Set;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.repo.api.StatementParserMode;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.repo.api.StatementParserMode;
@@ -35,18 +35,18 @@ class SystemTestUtils {
         }
     };
 
         }
     };
 
-    static SchemaContext parseYangSources(final Collection<File> files, final Predicate<QName> isFeatureSupported)
+    static SchemaContext parseYangSources(final Collection<File> files, final Set<QName> supportedFeatures)
             throws ReactorException, FileNotFoundException {
             throws ReactorException, FileNotFoundException {
-        return parseYangSources(files, StatementParserMode.DEFAULT_MODE, isFeatureSupported);
+        return parseYangSources(files, StatementParserMode.DEFAULT_MODE, supportedFeatures);
     }
 
     static SchemaContext parseYangSources(final Collection<File> files,
     }
 
     static SchemaContext parseYangSources(final Collection<File> files,
-            final StatementParserMode statementParserMode, final Predicate<QName> isFeatureSupported)
+            final StatementParserMode statementParserMode, final Set<QName> supportedFeatures)
             throws ReactorException, FileNotFoundException {
             throws ReactorException, FileNotFoundException {
-        return parseYangSources(isFeatureSupported, statementParserMode, files.toArray(new File[files.size()]));
+        return parseYangSources(supportedFeatures, statementParserMode, files.toArray(new File[files.size()]));
     }
 
     }
 
-    static SchemaContext parseYangSources(final Predicate<QName> isFeatureSupported,
+    static SchemaContext parseYangSources(final Set<QName> supportedFeatures,
             final StatementParserMode statementParserMode, final File... files) throws ReactorException,
             FileNotFoundException {
         final YangStatementSourceImpl [] sources = new YangStatementSourceImpl[files.length];
             final StatementParserMode statementParserMode, final File... files) throws ReactorException,
             FileNotFoundException {
         final YangStatementSourceImpl [] sources = new YangStatementSourceImpl[files.length];
@@ -55,21 +55,21 @@ class SystemTestUtils {
             sources[i] = new YangStatementSourceImpl(new NamedFileInputStream(files[i], files[i].getPath()));
         }
 
             sources[i] = new YangStatementSourceImpl(new NamedFileInputStream(files[i], files[i].getPath()));
         }
 
-        return parseYangSources(isFeatureSupported, statementParserMode, sources);
+        return parseYangSources(supportedFeatures, statementParserMode, sources);
     }
 
     }
 
-    static SchemaContext parseYangSources(final Predicate<QName> isFeatureSupported,
+    static SchemaContext parseYangSources(final Set<QName> supportedFeatures,
             final StatementParserMode statementParserMode, final YangStatementSourceImpl... sources)
             throws ReactorException {
         final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild(
             final StatementParserMode statementParserMode, final YangStatementSourceImpl... sources)
             throws ReactorException {
         final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild(
-                statementParserMode, isFeatureSupported);
+                statementParserMode, supportedFeatures);
         reactor.addSources(sources);
 
         return reactor.buildEffective();
     }
 
     static SchemaContext parseYangSources(final List<String> yangDirs, final List<String> yangFiles,
         reactor.addSources(sources);
 
         return reactor.buildEffective();
     }
 
     static SchemaContext parseYangSources(final List<String> yangDirs, final List<String> yangFiles,
-            final Predicate<QName> isFeatureSupported) throws FileNotFoundException, ReactorException {
+            final Set<QName> supportedFeatures) throws FileNotFoundException, ReactorException {
         final List<File> allYangFiles = new ArrayList<>();
         for (final String yangDir : yangDirs) {
             allYangFiles.addAll(getYangFiles(yangDir));
         final List<File> allYangFiles = new ArrayList<>();
         for (final String yangDir : yangDirs) {
             allYangFiles.addAll(getYangFiles(yangDir));
@@ -79,7 +79,7 @@ class SystemTestUtils {
             allYangFiles.add(new File(yangFile));
         }
 
             allYangFiles.add(new File(yangFile));
         }
 
-        return parseYangSources(allYangFiles, isFeatureSupported);
+        return parseYangSources(allYangFiles, supportedFeatures);
     }
 
     private static Collection<File> getYangFiles(final String yangSourcesDirectoryPath) {
     }
 
     private static Collection<File> getYangFiles(final String yangSourcesDirectoryPath) {
index 0f4e5c13664acfc2b1ec41dcc4d7cab0264871dc..2892589e8253d19f8bad4ff9c9d3fcd25b5cd521 100644 (file)
@@ -20,10 +20,9 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.List;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.List;
-import java.util.function.Predicate;
+import java.util.Set;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.repo.api.IfFeaturePredicates;
 import org.opendaylight.yangtools.yang.model.repo.api.StatementParserMode;
 import org.opendaylight.yangtools.yang.parser.rfc6020.repo.YinStatementStreamSource;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 import org.opendaylight.yangtools.yang.model.repo.api.StatementParserMode;
 import org.opendaylight.yangtools.yang.parser.rfc6020.repo.YinStatementStreamSource;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
@@ -62,14 +61,14 @@ public final class YangParserTestUtils {
      */
     @Deprecated
     public static SchemaContext parseYangSources(final YangStatementSourceImpl... sources) throws ReactorException {
      */
     @Deprecated
     public static SchemaContext parseYangSources(final YangStatementSourceImpl... sources) throws ReactorException {
-        return parseYangSources(IfFeaturePredicates.ALL_FEATURES, StatementParserMode.DEFAULT_MODE, sources);
+        return parseYangSources(StatementParserMode.DEFAULT_MODE, sources);
     }
 
     /**
      * Creates a new effective schema context containing the specified YANG sources. Statement parser mode is set to
      * default mode.
      *
     }
 
     /**
      * Creates a new effective schema context containing the specified YANG sources. Statement parser mode is set to
      * default mode.
      *
-     * @param isFeatureSupported predicate based on which all if-feature statements in the parsed YANG models are resolved
+     * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG models are resolved
      * @param sources YANG sources to be parsed
      *
      * @return effective schema context
      * @param sources YANG sources to be parsed
      *
      * @return effective schema context
@@ -78,9 +77,9 @@ public final class YangParserTestUtils {
      * @deprecated Migration method only, do not use.
      */
     @Deprecated
      * @deprecated Migration method only, do not use.
      */
     @Deprecated
-    public static SchemaContext parseYangSources(final Predicate<QName> isFeatureSupported,
+    public static SchemaContext parseYangSources(final Set<QName> supportedFeatures,
             final YangStatementSourceImpl... sources) throws ReactorException {
             final YangStatementSourceImpl... sources) throws ReactorException {
-        return parseYangSources(isFeatureSupported, StatementParserMode.DEFAULT_MODE, sources);
+        return parseYangSources(supportedFeatures, StatementParserMode.DEFAULT_MODE, sources);
     }
 
     /**
     }
 
     /**
@@ -97,13 +96,13 @@ public final class YangParserTestUtils {
     @Deprecated
     public static SchemaContext parseYangSources(final StatementParserMode statementParserMode,
             final YangStatementSourceImpl... sources) throws ReactorException {
     @Deprecated
     public static SchemaContext parseYangSources(final StatementParserMode statementParserMode,
             final YangStatementSourceImpl... sources) throws ReactorException {
-        return parseYangSources(IfFeaturePredicates.ALL_FEATURES, statementParserMode, sources);
+        return parseYangSources(null, statementParserMode, sources);
     }
 
     /**
      * Creates a new effective schema context containing the specified YANG sources.
      *
     }
 
     /**
      * Creates a new effective schema context containing the specified YANG sources.
      *
-     * @param isFeatureSupported predicate based on which all if-feature statements in the parsed YANG models are resolved
+     * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG models are resolved
      * @param statementParserMode mode of statement parser
      * @param sources YANG sources to be parsed
      *
      * @param statementParserMode mode of statement parser
      * @param sources YANG sources to be parsed
      *
@@ -111,11 +110,11 @@ public final class YangParserTestUtils {
      *
      * @throws ReactorException if there is an error in one of the parsed YANG sources
      */
      *
      * @throws ReactorException if there is an error in one of the parsed YANG sources
      */
-    public static SchemaContext parseYangSources(final Predicate<QName> isFeatureSupported,
+    public static SchemaContext parseYangSources(final Set<QName> supportedFeatures,
             final StatementParserMode statementParserMode, final YangStatementSourceImpl... sources)
                     throws ReactorException {
         final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild(
             final StatementParserMode statementParserMode, final YangStatementSourceImpl... sources)
                     throws ReactorException {
         final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild(
-                statementParserMode, isFeatureSupported);
+                statementParserMode, supportedFeatures);
         reactor.addSources(sources);
 
         return reactor.buildEffective();
         reactor.addSources(sources);
 
         return reactor.buildEffective();
@@ -133,14 +132,14 @@ public final class YangParserTestUtils {
      * @throws FileNotFoundException if one of the specified files does not exist
      */
     public static SchemaContext parseYangSources(final File... files) throws ReactorException, FileNotFoundException {
      * @throws FileNotFoundException if one of the specified files does not exist
      */
     public static SchemaContext parseYangSources(final File... files) throws ReactorException, FileNotFoundException {
-        return parseYangSources(IfFeaturePredicates.ALL_FEATURES, StatementParserMode.DEFAULT_MODE, files);
+        return parseYangSources(StatementParserMode.DEFAULT_MODE, files);
     }
 
     /**
      * Creates a new effective schema context containing the specified YANG sources. Statement parser mode is set to
      * default mode.
      *
     }
 
     /**
      * Creates a new effective schema context containing the specified YANG sources. Statement parser mode is set to
      * default mode.
      *
-     * @param isFeatureSupported predicate based on which all if-feature statements in the parsed YANG models are resolved
+     * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG models are resolved
      * @param files YANG files to be parsed
      *
      * @return effective schema context
      * @param files YANG files to be parsed
      *
      * @return effective schema context
@@ -148,9 +147,9 @@ public final class YangParserTestUtils {
      * @throws ReactorException if there is an error in one of the parsed YANG sources
      * @throws FileNotFoundException if one of the specified files does not exist
      */
      * @throws ReactorException if there is an error in one of the parsed YANG sources
      * @throws FileNotFoundException if one of the specified files does not exist
      */
-    public static SchemaContext parseYangSources(final Predicate<QName> isFeatureSupported, final File... files)
+    public static SchemaContext parseYangSources(final Set<QName> supportedFeatures, final File... files)
             throws ReactorException, FileNotFoundException {
             throws ReactorException, FileNotFoundException {
-        return parseYangSources(isFeatureSupported, StatementParserMode.DEFAULT_MODE, files);
+        return parseYangSources(supportedFeatures, StatementParserMode.DEFAULT_MODE, files);
     }
 
     /**
     }
 
     /**
@@ -166,13 +165,13 @@ public final class YangParserTestUtils {
      */
     public static SchemaContext parseYangSources(final StatementParserMode statementParserMode, final File... files)
             throws ReactorException, FileNotFoundException {
      */
     public static SchemaContext parseYangSources(final StatementParserMode statementParserMode, final File... files)
             throws ReactorException, FileNotFoundException {
-        return parseYangSources(IfFeaturePredicates.ALL_FEATURES, statementParserMode, files);
+        return parseYangSources(null, statementParserMode, files);
     }
 
     /**
      * Creates a new effective schema context containing the specified YANG sources.
      *
     }
 
     /**
      * Creates a new effective schema context containing the specified YANG sources.
      *
-     * @param isFeatureSupported predicate based on which all if-feature statements in the parsed YANG models are resolved
+     * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG models are resolved
      * @param statementParserMode mode of statement parser
      * @param files YANG files to be parsed
      *
      * @param statementParserMode mode of statement parser
      * @param files YANG files to be parsed
      *
@@ -181,7 +180,7 @@ public final class YangParserTestUtils {
      * @throws ReactorException if there is an error in one of the parsed YANG sources
      * @throws FileNotFoundException if one of the specified files does not exist
      */
      * @throws ReactorException if there is an error in one of the parsed YANG sources
      * @throws FileNotFoundException if one of the specified files does not exist
      */
-    public static SchemaContext parseYangSources(final Predicate<QName> isFeatureSupported,
+    public static SchemaContext parseYangSources(final Set<QName> supportedFeatures,
             final StatementParserMode statementParserMode, final File... files) throws ReactorException,
             FileNotFoundException {
         final YangStatementSourceImpl[] sources = new YangStatementSourceImpl[files.length];
             final StatementParserMode statementParserMode, final File... files) throws ReactorException,
             FileNotFoundException {
         final YangStatementSourceImpl[] sources = new YangStatementSourceImpl[files.length];
@@ -189,7 +188,7 @@ public final class YangParserTestUtils {
             sources[i] = new YangStatementSourceImpl(new NamedFileInputStream(files[i], files[i].getPath()));
         }
 
             sources[i] = new YangStatementSourceImpl(new NamedFileInputStream(files[i], files[i].getPath()));
         }
 
-        return parseYangSources(isFeatureSupported, statementParserMode, sources);
+        return parseYangSources(supportedFeatures, statementParserMode, sources);
     }
 
     /**
     }
 
     /**
@@ -205,14 +204,14 @@ public final class YangParserTestUtils {
      */
     public static SchemaContext parseYangSources(final Collection<File> files) throws ReactorException,
             FileNotFoundException {
      */
     public static SchemaContext parseYangSources(final Collection<File> files) throws ReactorException,
             FileNotFoundException {
-        return parseYangSources(files, IfFeaturePredicates.ALL_FEATURES, StatementParserMode.DEFAULT_MODE);
+        return parseYangSources(files, StatementParserMode.DEFAULT_MODE);
     }
 
     /**
      * Creates a new effective schema context containing the specified YANG sources. Statement parser mode is set to
      * default mode.
      *
     }
 
     /**
      * Creates a new effective schema context containing the specified YANG sources. Statement parser mode is set to
      * default mode.
      *
-     * @param isFeatureSupported predicate based on which all if-feature statements in the parsed YANG models are resolved
+     * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG models are resolved
      * @param files collection of YANG files to be parsed
      *
      * @return effective schema context
      * @param files collection of YANG files to be parsed
      *
      * @return effective schema context
@@ -220,9 +219,9 @@ public final class YangParserTestUtils {
      * @throws ReactorException if there is an error in one of the parsed YANG sources
      * @throws FileNotFoundException if one of the specified files does not exist
      */
      * @throws ReactorException if there is an error in one of the parsed YANG sources
      * @throws FileNotFoundException if one of the specified files does not exist
      */
-    public static SchemaContext parseYangSources(final Collection<File> files, final Predicate<QName> isFeatureSupported)
+    public static SchemaContext parseYangSources(final Collection<File> files, final Set<QName> supportedFeatures)
             throws ReactorException, FileNotFoundException {
             throws ReactorException, FileNotFoundException {
-        return parseYangSources(files, isFeatureSupported, StatementParserMode.DEFAULT_MODE);
+        return parseYangSources(files, supportedFeatures, StatementParserMode.DEFAULT_MODE);
     }
 
     /**
     }
 
     /**
@@ -238,13 +237,13 @@ public final class YangParserTestUtils {
      */
     public static SchemaContext parseYangSources(final Collection<File> files, final StatementParserMode statementParserMode)
             throws ReactorException, FileNotFoundException {
      */
     public static SchemaContext parseYangSources(final Collection<File> files, final StatementParserMode statementParserMode)
             throws ReactorException, FileNotFoundException {
-        return parseYangSources(files, IfFeaturePredicates.ALL_FEATURES, statementParserMode);
+        return parseYangSources(files, null, statementParserMode);
     }
 
     /**
      * Creates a new effective schema context containing the specified YANG sources.
      *
     }
 
     /**
      * Creates a new effective schema context containing the specified YANG sources.
      *
-     * @param isFeatureSupported predicate based on which all if-feature statements in the parsed YANG models are resolved
+     * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG models are resolved
      * @param statementParserMode mode of statement parser
      * @param files collection of YANG files to be parsed
      *
      * @param statementParserMode mode of statement parser
      * @param files collection of YANG files to be parsed
      *
@@ -253,9 +252,9 @@ public final class YangParserTestUtils {
      * @throws ReactorException if there is an error in one of the parsed YANG sources
      * @throws FileNotFoundException if one of the specified files does not exist
      */
      * @throws ReactorException if there is an error in one of the parsed YANG sources
      * @throws FileNotFoundException if one of the specified files does not exist
      */
-    public static SchemaContext parseYangSources(final Collection<File> files, final Predicate<QName> isFeatureSupported,
+    public static SchemaContext parseYangSources(final Collection<File> files, final Set<QName> supportedFeatures,
             final StatementParserMode statementParserMode) throws ReactorException, FileNotFoundException {
             final StatementParserMode statementParserMode) throws ReactorException, FileNotFoundException {
-        return parseYangSources(isFeatureSupported, statementParserMode, files.toArray(new File[files.size()]));
+        return parseYangSources(supportedFeatures, statementParserMode, files.toArray(new File[files.size()]));
     }
 
     /**
     }
 
     /**
@@ -272,8 +271,7 @@ public final class YangParserTestUtils {
      */
     public static SchemaContext parseYangSources(final String yangSourcesDirectoryPath) throws ReactorException,
             FileNotFoundException, URISyntaxException {
      */
     public static SchemaContext parseYangSources(final String yangSourcesDirectoryPath) throws ReactorException,
             FileNotFoundException, URISyntaxException {
-        return parseYangSources(yangSourcesDirectoryPath, IfFeaturePredicates.ALL_FEATURES,
-            StatementParserMode.DEFAULT_MODE);
+        return parseYangSources(yangSourcesDirectoryPath, StatementParserMode.DEFAULT_MODE);
     }
 
     /**
     }
 
     /**
@@ -281,7 +279,7 @@ public final class YangParserTestUtils {
      * default mode.
      *
      * @param yangSourcesDirectoryPath relative path to the directory with YANG files to be parsed
      * default mode.
      *
      * @param yangSourcesDirectoryPath relative path to the directory with YANG files to be parsed
-     * @param isFeatureSupported predicate based on which all if-feature statements in the parsed YANG models are resolved
+     * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG models are resolved
      *
      * @return effective schema context
      *
      *
      * @return effective schema context
      *
@@ -290,9 +288,9 @@ public final class YangParserTestUtils {
      * @throws URISyntaxException if the specified directory does not exist
      */
     public static SchemaContext parseYangSources(final String yangSourcesDirectoryPath,
      * @throws URISyntaxException if the specified directory does not exist
      */
     public static SchemaContext parseYangSources(final String yangSourcesDirectoryPath,
-            final Predicate<QName> isFeatureSupported) throws ReactorException, FileNotFoundException,
+            final Set<QName> supportedFeatures) throws ReactorException, FileNotFoundException,
             URISyntaxException {
             URISyntaxException {
-        return parseYangSources(yangSourcesDirectoryPath, isFeatureSupported, StatementParserMode.DEFAULT_MODE);
+        return parseYangSources(yangSourcesDirectoryPath, supportedFeatures, StatementParserMode.DEFAULT_MODE);
     }
 
     /**
     }
 
     /**
@@ -310,14 +308,14 @@ public final class YangParserTestUtils {
     public static SchemaContext parseYangSources(final String yangSourcesDirectoryPath,
             final StatementParserMode statementParserMode) throws ReactorException, FileNotFoundException,
             URISyntaxException {
     public static SchemaContext parseYangSources(final String yangSourcesDirectoryPath,
             final StatementParserMode statementParserMode) throws ReactorException, FileNotFoundException,
             URISyntaxException {
-        return parseYangSources(yangSourcesDirectoryPath, IfFeaturePredicates.ALL_FEATURES, statementParserMode);
+        return parseYangSources(yangSourcesDirectoryPath, null, statementParserMode);
     }
 
     /**
      * Creates a new effective schema context containing the specified YANG sources.
      *
      * @param yangSourcesDirectoryPath relative path to the directory with YANG files to be parsed
     }
 
     /**
      * Creates a new effective schema context containing the specified YANG sources.
      *
      * @param yangSourcesDirectoryPath relative path to the directory with YANG files to be parsed
-     * @param isFeatureSupported predicate based on which all if-feature statements in the parsed YANG models are resolved
+     * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG models are resolved
      * @param statementParserMode mode of statement parser
      *
      * @return effective schema context
      * @param statementParserMode mode of statement parser
      *
      * @return effective schema context
@@ -327,12 +325,12 @@ public final class YangParserTestUtils {
      * @throws URISyntaxException if the specified directory does not exist
      */
     public static SchemaContext parseYangSources(final String yangSourcesDirectoryPath,
      * @throws URISyntaxException if the specified directory does not exist
      */
     public static SchemaContext parseYangSources(final String yangSourcesDirectoryPath,
-            final Predicate<QName> isFeatureSupported, final StatementParserMode statementParserMode)
+            final Set<QName> supportedFeatures, final StatementParserMode statementParserMode)
                     throws ReactorException, FileNotFoundException, URISyntaxException {
         final URI directoryPath = YangParserTestUtils.class.getResource(yangSourcesDirectoryPath).toURI();
         final File dir = new File(directoryPath);
 
                     throws ReactorException, FileNotFoundException, URISyntaxException {
         final URI directoryPath = YangParserTestUtils.class.getResource(yangSourcesDirectoryPath).toURI();
         final File dir = new File(directoryPath);
 
-        return parseYangSources(isFeatureSupported, statementParserMode, dir.listFiles(YANG_FILE_FILTER));
+        return parseYangSources(supportedFeatures, statementParserMode, dir.listFiles(YANG_FILE_FILTER));
     }
 
     /**
     }
 
     /**
@@ -349,7 +347,7 @@ public final class YangParserTestUtils {
      */
     public static SchemaContext parseYangSource(final String yangSourcePath) throws ReactorException,
             FileNotFoundException, URISyntaxException {
      */
     public static SchemaContext parseYangSource(final String yangSourcePath) throws ReactorException,
             FileNotFoundException, URISyntaxException {
-        return parseYangSource(yangSourcePath, IfFeaturePredicates.ALL_FEATURES, StatementParserMode.DEFAULT_MODE);
+        return parseYangSource(yangSourcePath, StatementParserMode.DEFAULT_MODE);
     }
 
     /**
     }
 
     /**
@@ -357,7 +355,7 @@ public final class YangParserTestUtils {
      * default mode.
      *
      * @param yangSourcePath relative path to the YANG file to be parsed
      * default mode.
      *
      * @param yangSourcePath relative path to the YANG file to be parsed
-     * @param isFeatureSupported predicate based on which all if-feature statements in the parsed YANG model are resolved
+     * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG model are resolved
      *
      * @return effective schema context
      *
      *
      * @return effective schema context
      *
@@ -365,9 +363,9 @@ public final class YangParserTestUtils {
      * @throws FileNotFoundException if the specified file does not exist
      * @throws URISyntaxException if the specified file does not exist
      */
      * @throws FileNotFoundException if the specified file does not exist
      * @throws URISyntaxException if the specified file does not exist
      */
-    public static SchemaContext parseYangSource(final String yangSourcePath, final Predicate<QName> isFeatureSupported)
+    public static SchemaContext parseYangSource(final String yangSourcePath, final Set<QName> supportedFeatures)
             throws ReactorException, FileNotFoundException, URISyntaxException {
             throws ReactorException, FileNotFoundException, URISyntaxException {
-        return parseYangSource(yangSourcePath, isFeatureSupported, StatementParserMode.DEFAULT_MODE);
+        return parseYangSource(yangSourcePath, supportedFeatures, StatementParserMode.DEFAULT_MODE);
     }
 
     /**
     }
 
     /**
@@ -384,14 +382,14 @@ public final class YangParserTestUtils {
      */
     public static SchemaContext parseYangSource(final String yangSourcePath, final StatementParserMode statementParserMode)
             throws ReactorException, FileNotFoundException, URISyntaxException {
      */
     public static SchemaContext parseYangSource(final String yangSourcePath, final StatementParserMode statementParserMode)
             throws ReactorException, FileNotFoundException, URISyntaxException {
-        return parseYangSource(yangSourcePath, IfFeaturePredicates.ALL_FEATURES, statementParserMode);
+        return parseYangSource(yangSourcePath, null, statementParserMode);
     }
 
     /**
      * Creates a new effective schema context containing the specified YANG source.
      *
      * @param yangSourcePath relative path to the YANG file to be parsed
     }
 
     /**
      * Creates a new effective schema context containing the specified YANG source.
      *
      * @param yangSourcePath relative path to the YANG file to be parsed
-     * @param isFeatureSupported predicate based on which all if-feature statements in the parsed YANG model are resolved
+     * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG model are resolved
      * @param statementParserMode mode of statement parser
      *
      * @return effective schema context
      * @param statementParserMode mode of statement parser
      *
      * @return effective schema context
@@ -400,12 +398,12 @@ public final class YangParserTestUtils {
      * @throws FileNotFoundException if the specified file does not exist
      * @throws URISyntaxException if the specified file does not exist
      */
      * @throws FileNotFoundException if the specified file does not exist
      * @throws URISyntaxException if the specified file does not exist
      */
-    public static SchemaContext parseYangSource(final String yangSourcePath, final Predicate<QName> isFeatureSupported,
+    public static SchemaContext parseYangSource(final String yangSourcePath, final Set<QName> supportedFeatures,
             final StatementParserMode statementParserMode) throws ReactorException, FileNotFoundException,
             URISyntaxException {
         final URI sourcePath = YangParserTestUtils.class.getResource(yangSourcePath).toURI();
         final File sourceFile = new File(sourcePath);
             final StatementParserMode statementParserMode) throws ReactorException, FileNotFoundException,
             URISyntaxException {
         final URI sourcePath = YangParserTestUtils.class.getResource(yangSourcePath).toURI();
         final File sourceFile = new File(sourcePath);
-        return parseYangSources(isFeatureSupported, statementParserMode, sourceFile);
+        return parseYangSources(supportedFeatures, statementParserMode, sourceFile);
     }
 
     /**
     }
 
     /**
@@ -423,7 +421,7 @@ public final class YangParserTestUtils {
      */
     public static SchemaContext parseYangSources(final List<String> yangDirs, final List<String> yangFiles)
             throws FileNotFoundException, ReactorException, URISyntaxException {
      */
     public static SchemaContext parseYangSources(final List<String> yangDirs, final List<String> yangFiles)
             throws FileNotFoundException, ReactorException, URISyntaxException {
-        return parseYangSources(yangDirs, yangFiles, IfFeaturePredicates.ALL_FEATURES, StatementParserMode.DEFAULT_MODE);
+        return parseYangSources(yangDirs, yangFiles, StatementParserMode.DEFAULT_MODE);
     }
 
     /**
     }
 
     /**
@@ -432,7 +430,7 @@ public final class YangParserTestUtils {
      *
      * @param yangDirs relative paths to the directories containing YANG files to be parsed
      * @param yangFiles relative paths to the YANG files to be parsed
      *
      * @param yangDirs relative paths to the directories containing YANG files to be parsed
      * @param yangFiles relative paths to the YANG files to be parsed
-     * @param isFeatureSupported predicate based on which all if-feature statements in the parsed YANG models are resolved
+     * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG models are resolved
      *
      * @return effective schema context
      *
      *
      * @return effective schema context
      *
@@ -441,9 +439,9 @@ public final class YangParserTestUtils {
      * @throws URISyntaxException if one of the specified directories or files does not exist
      */
     public static SchemaContext parseYangSources(final List<String> yangDirs, final List<String> yangFiles,
      * @throws URISyntaxException if one of the specified directories or files does not exist
      */
     public static SchemaContext parseYangSources(final List<String> yangDirs, final List<String> yangFiles,
-            final Predicate<QName> isFeatureSupported) throws FileNotFoundException, ReactorException,
+            final Set<QName> supportedFeatures) throws FileNotFoundException, ReactorException,
             URISyntaxException {
             URISyntaxException {
-        return parseYangSources(yangDirs, yangFiles, isFeatureSupported, StatementParserMode.DEFAULT_MODE);
+        return parseYangSources(yangDirs, yangFiles, supportedFeatures, StatementParserMode.DEFAULT_MODE);
     }
 
     /**
     }
 
     /**
@@ -462,7 +460,7 @@ public final class YangParserTestUtils {
     public static SchemaContext parseYangSources(final List<String> yangDirs, final List<String> yangFiles,
             final StatementParserMode statementParserMode) throws FileNotFoundException, ReactorException,
             URISyntaxException {
     public static SchemaContext parseYangSources(final List<String> yangDirs, final List<String> yangFiles,
             final StatementParserMode statementParserMode) throws FileNotFoundException, ReactorException,
             URISyntaxException {
-        return parseYangSources(yangDirs, yangFiles, IfFeaturePredicates.ALL_FEATURES, statementParserMode);
+        return parseYangSources(yangDirs, yangFiles, null, statementParserMode);
     }
 
     /**
     }
 
     /**
@@ -470,7 +468,7 @@ public final class YangParserTestUtils {
      *
      * @param yangDirs relative paths to the directories containing YANG files to be parsed
      * @param yangFiles relative paths to the YANG files to be parsed
      *
      * @param yangDirs relative paths to the directories containing YANG files to be parsed
      * @param yangFiles relative paths to the YANG files to be parsed
-     * @param isFeatureSupported predicate based on which all if-feature statements in the parsed YANG models are resolved
+     * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG models are resolved
      * @param statementParserMode mode of statement parser
      *
      * @return effective schema context
      * @param statementParserMode mode of statement parser
      *
      * @return effective schema context
@@ -480,7 +478,7 @@ public final class YangParserTestUtils {
      * @throws URISyntaxException if one of the specified directories or files does not exist
      */
     public static SchemaContext parseYangSources(final List<String> yangDirs, final List<String> yangFiles,
      * @throws URISyntaxException if one of the specified directories or files does not exist
      */
     public static SchemaContext parseYangSources(final List<String> yangDirs, final List<String> yangFiles,
-            final Predicate<QName> isFeatureSupported, final StatementParserMode statementParserMode)
+            final Set<QName> supportedFeatures, final StatementParserMode statementParserMode)
             throws FileNotFoundException, ReactorException, URISyntaxException {
         final List<File> allYangFiles = new ArrayList<>();
         for (final String yangDir : yangDirs) {
             throws FileNotFoundException, ReactorException, URISyntaxException {
         final List<File> allYangFiles = new ArrayList<>();
         for (final String yangDir : yangDirs) {
@@ -492,7 +490,7 @@ public final class YangParserTestUtils {
             allYangFiles.add(new File(filePath));
         }
 
             allYangFiles.add(new File(filePath));
         }
 
-        return parseYangSources(allYangFiles, isFeatureSupported, statementParserMode);
+        return parseYangSources(allYangFiles, supportedFeatures, statementParserMode);
     }
 
     private static Collection<File> getYangFiles(final String yangSourcesDirectoryPath) throws URISyntaxException {
     }
 
     private static Collection<File> getYangFiles(final String yangSourcesDirectoryPath) throws URISyntaxException {
@@ -513,23 +511,23 @@ public final class YangParserTestUtils {
      * @throws ReactorException if there is an error in one of the parsed YANG sources
      */
     public static SchemaContext parseYangSources(final List<String> filePaths) throws ReactorException {
      * @throws ReactorException if there is an error in one of the parsed YANG sources
      */
     public static SchemaContext parseYangSources(final List<String> filePaths) throws ReactorException {
-        return parseYangSources(filePaths, IfFeaturePredicates.ALL_FEATURES, StatementParserMode.DEFAULT_MODE);
+        return parseYangSources(filePaths, StatementParserMode.DEFAULT_MODE);
     }
 
     /**
      * Creates a new effective schema context containing the specified YANG sources. Statement parser mode is set to
      * default mode.
      *
     }
 
     /**
      * Creates a new effective schema context containing the specified YANG sources. Statement parser mode is set to
      * default mode.
      *
-     * @param isFeatureSupported predicate based on which all if-feature statements in the parsed YANG models are resolved
+     * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG models are resolved
      * @param filePaths relative paths to the YANG files to be parsed
      *
      * @return effective schema context
      *
      * @throws ReactorException if there is an error in one of the parsed YANG sources
      */
      * @param filePaths relative paths to the YANG files to be parsed
      *
      * @return effective schema context
      *
      * @throws ReactorException if there is an error in one of the parsed YANG sources
      */
-    public static SchemaContext parseYangSources(final List<String> filePaths, final Predicate<QName> isFeatureSupported)
+    public static SchemaContext parseYangSources(final List<String> filePaths, final Set<QName> supportedFeatures)
             throws ReactorException {
             throws ReactorException {
-        return parseYangSources(filePaths, isFeatureSupported, StatementParserMode.DEFAULT_MODE);
+        return parseYangSources(filePaths, supportedFeatures, StatementParserMode.DEFAULT_MODE);
     }
 
     /**
     }
 
     /**
@@ -542,15 +540,15 @@ public final class YangParserTestUtils {
      *
      * @throws ReactorException if there is an error in one of the parsed YANG sources
      */
      *
      * @throws ReactorException if there is an error in one of the parsed YANG sources
      */
-    public static SchemaContext parseYangSources(final List<String> filePaths,final StatementParserMode statementParserMode)
-            throws ReactorException {
-        return parseYangSources(filePaths, IfFeaturePredicates.ALL_FEATURES, statementParserMode);
+    public static SchemaContext parseYangSources(final List<String> filePaths,
+            final StatementParserMode statementParserMode) throws ReactorException {
+        return parseYangSources(filePaths, (Set<QName>) null, statementParserMode);
     }
 
     /**
      * Creates a new effective schema context containing the specified YANG sources.
      *
     }
 
     /**
      * Creates a new effective schema context containing the specified YANG sources.
      *
-     * @param isFeatureSupported predicate based on which all if-feature statements in the parsed YANG models are resolved
+     * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG models are resolved
      * @param statementParserMode mode of statement parser
      * @param filePaths relative paths to the YANG files to be parsed
      *
      * @param statementParserMode mode of statement parser
      * @param filePaths relative paths to the YANG files to be parsed
      *
@@ -559,7 +557,7 @@ public final class YangParserTestUtils {
      * @throws ReactorException if there is an error in one of the parsed YANG sources
      */
     public static SchemaContext parseYangSources(final List<String> filePaths,
      * @throws ReactorException if there is an error in one of the parsed YANG sources
      */
     public static SchemaContext parseYangSources(final List<String> filePaths,
-            final Predicate<QName> isFeatureSupported, final StatementParserMode statementParserMode)
+            final Set<QName> supportedFeatures, final StatementParserMode statementParserMode)
                     throws ReactorException {
         final YangStatementSourceImpl[] sources = new YangStatementSourceImpl[filePaths.size()];
 
                     throws ReactorException {
         final YangStatementSourceImpl[] sources = new YangStatementSourceImpl[filePaths.size()];
 
@@ -567,7 +565,7 @@ public final class YangParserTestUtils {
             sources[i] = new YangStatementSourceImpl(YangParserTestUtils.class.getResourceAsStream(filePaths.get(i)));
         }
 
             sources[i] = new YangStatementSourceImpl(YangParserTestUtils.class.getResourceAsStream(filePaths.get(i)));
         }
 
-        return parseYangSources(isFeatureSupported, statementParserMode, sources);
+        return parseYangSources(supportedFeatures, statementParserMode, sources);
     }
 
     /**
     }
 
     /**
@@ -581,7 +579,7 @@ public final class YangParserTestUtils {
      * @throws ReactorException if there is an error in one of the parsed YANG sources
      */
     public static SchemaContext parseYangStreams(final List<InputStream> streams) throws ReactorException {
      * @throws ReactorException if there is an error in one of the parsed YANG sources
      */
     public static SchemaContext parseYangStreams(final List<InputStream> streams) throws ReactorException {
-        return parseYangStreams(streams, IfFeaturePredicates.ALL_FEATURES, StatementParserMode.DEFAULT_MODE);
+        return parseYangStreams(streams, StatementParserMode.DEFAULT_MODE);
     }
 
     /**
     }
 
     /**
@@ -589,15 +587,15 @@ public final class YangParserTestUtils {
      * default mode.
      *
      * @param streams input streams containing YANG sources to be parsed
      * default mode.
      *
      * @param streams input streams containing YANG sources to be parsed
-     * @param isFeatureSupported predicate based on which all if-feature statements in the parsed YANG models are resolved
+     * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG models are resolved
      *
      * @return effective schema context
      *
      * @throws ReactorException if there is an error in one of the parsed YANG sources
      */
      *
      * @return effective schema context
      *
      * @throws ReactorException if there is an error in one of the parsed YANG sources
      */
-    public static SchemaContext parseYangStreams(final List<InputStream> streams, final Predicate<QName> isFeatureSupported)
+    public static SchemaContext parseYangStreams(final List<InputStream> streams, final Set<QName> supportedFeatures)
             throws ReactorException {
             throws ReactorException {
-        return parseYangStreams(streams, isFeatureSupported, StatementParserMode.DEFAULT_MODE);
+        return parseYangStreams(streams, supportedFeatures, StatementParserMode.DEFAULT_MODE);
     }
 
     /**
     }
 
     /**
@@ -612,13 +610,13 @@ public final class YangParserTestUtils {
      */
     public static SchemaContext parseYangStreams(final List<InputStream> streams, final StatementParserMode statementParserMode)
             throws ReactorException {
      */
     public static SchemaContext parseYangStreams(final List<InputStream> streams, final StatementParserMode statementParserMode)
             throws ReactorException {
-        return parseYangStreams(streams, IfFeaturePredicates.ALL_FEATURES, statementParserMode);
+        return parseYangStreams(streams, null, statementParserMode);
     }
 
     /**
      * Creates a new effective schema context containing the specified YANG sources.
      *
     }
 
     /**
      * Creates a new effective schema context containing the specified YANG sources.
      *
-     * @param isFeatureSupported predicate based on which all if-feature statements in the parsed YANG models are resolved
+     * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG models are resolved
      * @param statementParserMode mode of statement parser
      * @param streams input streams containing YANG sources to be parsed
      *
      * @param statementParserMode mode of statement parser
      * @param streams input streams containing YANG sources to be parsed
      *
@@ -626,10 +624,10 @@ public final class YangParserTestUtils {
      *
      * @throws ReactorException if there is an error in one of the parsed YANG sources
      */
      *
      * @throws ReactorException if there is an error in one of the parsed YANG sources
      */
-    public static SchemaContext parseYangStreams(final List<InputStream> streams, final Predicate<QName> isFeatureSupported,
+    public static SchemaContext parseYangStreams(final List<InputStream> streams, final Set<QName> supportedFeatures,
             final StatementParserMode statementParserMode) throws ReactorException {
         final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild(
             final StatementParserMode statementParserMode) throws ReactorException {
         final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild(
-                statementParserMode, isFeatureSupported);
+                statementParserMode, supportedFeatures);
         return reactor.buildEffective(streams);
     }
 
         return reactor.buildEffective(streams);
     }
 
@@ -647,7 +645,7 @@ public final class YangParserTestUtils {
     public static SchemaContext parseYangResources(final Class<?> clazz, final String... resources)
             throws ReactorException {
         final List<InputStream> streams = new ArrayList<>(resources.length);
     public static SchemaContext parseYangResources(final Class<?> clazz, final String... resources)
             throws ReactorException {
         final List<InputStream> streams = new ArrayList<>(resources.length);
-        for (String r : resources) {
+        for (final String r : resources) {
             final InputStream is = clazz.getResourceAsStream(r);
             Preconditions.checkArgument(is != null, "Resource %s not found", r);
             streams.add(is);
             final InputStream is = clazz.getResourceAsStream(r);
             Preconditions.checkArgument(is != null, "Resource %s not found", r);
             streams.add(is);
@@ -674,16 +672,16 @@ public final class YangParserTestUtils {
      * Creates a new effective schema context containing the specified YANG sources. Statement parser mode is set to
      * default mode.
      *
      * Creates a new effective schema context containing the specified YANG sources. Statement parser mode is set to
      * default mode.
      *
-     * @param isFeatureSupported predicate based on which all if-feature statements in the parsed YANG models are resolved
+     * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG models are resolved
      * @param streams input streams containing YANG sources to be parsed
      *
      * @return effective schema context
      *
      * @throws ReactorException if there is an error in one of the parsed YANG sources
      */
      * @param streams input streams containing YANG sources to be parsed
      *
      * @return effective schema context
      *
      * @throws ReactorException if there is an error in one of the parsed YANG sources
      */
-    public static SchemaContext parseYangStreams(final Predicate<QName> isFeatureSupported,
+    public static SchemaContext parseYangStreams(final Set<QName> supportedFeatures,
             final InputStream... streams) throws ReactorException {
             final InputStream... streams) throws ReactorException {
-        return parseYangStreams(Arrays.asList(streams), isFeatureSupported);
+        return parseYangStreams(Arrays.asList(streams), supportedFeatures);
     }
 
     /**
     }
 
     /**
@@ -704,7 +702,7 @@ public final class YangParserTestUtils {
     /**
      * Creates a new effective schema context containing the specified YANG sources.
      *
     /**
      * Creates a new effective schema context containing the specified YANG sources.
      *
-     * @param isFeatureSupported predicate based on which all if-feature statements in the parsed YANG models are resolved
+     * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG models are resolved
      * @param statementParserMode mode of statement parser
      * @param streams input streams containing YANG sources to be parsed
      *
      * @param statementParserMode mode of statement parser
      * @param streams input streams containing YANG sources to be parsed
      *
@@ -712,9 +710,9 @@ public final class YangParserTestUtils {
      *
      * @throws ReactorException if there is an error in one of the parsed YANG sources
      */
      *
      * @throws ReactorException if there is an error in one of the parsed YANG sources
      */
-    public static SchemaContext parseYangStreams(final Predicate<QName> isFeatureSupported,
+    public static SchemaContext parseYangStreams(final Set<QName> supportedFeatures,
             final StatementParserMode statementParserMode, final InputStream... streams) throws ReactorException {
             final StatementParserMode statementParserMode, final InputStream... streams) throws ReactorException {
-        return parseYangStreams(Arrays.asList(streams), isFeatureSupported, statementParserMode);
+        return parseYangStreams(Arrays.asList(streams), supportedFeatures, statementParserMode);
     }
 
     /**
     }
 
     /**
@@ -728,22 +726,22 @@ public final class YangParserTestUtils {
      * @throws ReactorException if there is an error in one of the parsed YIN sources
      */
     public static SchemaContext parseYinSources(final YinStatementStreamSource... sources) throws ReactorException {
      * @throws ReactorException if there is an error in one of the parsed YIN sources
      */
     public static SchemaContext parseYinSources(final YinStatementStreamSource... sources) throws ReactorException {
-        return parseYinSources(IfFeaturePredicates.ALL_FEATURES, StatementParserMode.DEFAULT_MODE, sources);
+        return parseYinSources(StatementParserMode.DEFAULT_MODE, sources);
     }
 
     /**
      * Creates a new effective schema context containing the specified YIN sources. Statement parser mode is set to
      * default mode.
      *
     }
 
     /**
      * Creates a new effective schema context containing the specified YIN sources. Statement parser mode is set to
      * default mode.
      *
-     * @param isFeatureSupported predicate based on which all if-feature statements in the parsed YIN models are resolved
+     * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YIN models are resolved
      * @param sources YIN sources to be parsed
      *
      * @return effective schema context
      * @throws ReactorException if there is an error in one of the parsed YIN sources
      */
      * @param sources YIN sources to be parsed
      *
      * @return effective schema context
      * @throws ReactorException if there is an error in one of the parsed YIN sources
      */
-    public static SchemaContext parseYinSources(final Predicate<QName> isFeatureSupported,
+    public static SchemaContext parseYinSources(final Set<QName> supportedFeatures,
             final YinStatementStreamSource... sources) throws ReactorException {
             final YinStatementStreamSource... sources) throws ReactorException {
-        return parseYinSources(isFeatureSupported, StatementParserMode.DEFAULT_MODE, sources);
+        return parseYinSources(supportedFeatures, StatementParserMode.DEFAULT_MODE, sources);
     }
 
     /**
     }
 
     /**
@@ -758,13 +756,13 @@ public final class YangParserTestUtils {
      */
     public static SchemaContext parseYinSources(final StatementParserMode statementParserMode,
             final YinStatementStreamSource... sources) throws ReactorException {
      */
     public static SchemaContext parseYinSources(final StatementParserMode statementParserMode,
             final YinStatementStreamSource... sources) throws ReactorException {
-        return parseYinSources(IfFeaturePredicates.ALL_FEATURES, statementParserMode, sources);
+        return parseYinSources(null, statementParserMode, sources);
     }
 
     /**
      * Creates a new effective schema context containing the specified YIN sources.
      *
     }
 
     /**
      * Creates a new effective schema context containing the specified YIN sources.
      *
-     * @param isFeatureSupported predicate based on which all if-feature statements in the parsed YIN models are resolved
+     * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YIN models are resolved
      * @param statementParserMode mode of statement parser
      * @param sources YIN sources to be parsed
      *
      * @param statementParserMode mode of statement parser
      * @param sources YIN sources to be parsed
      *
@@ -772,11 +770,11 @@ public final class YangParserTestUtils {
      *
      * @throws ReactorException if there is an error in one of the parsed YIN sources
      */
      *
      * @throws ReactorException if there is an error in one of the parsed YIN sources
      */
-    public static SchemaContext parseYinSources(final Predicate<QName> isFeatureSupported,
+    public static SchemaContext parseYinSources(final Set<QName> supportedFeatures,
             final StatementParserMode statementParserMode, final YinStatementStreamSource... sources)
                     throws ReactorException {
         final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild(
             final StatementParserMode statementParserMode, final YinStatementStreamSource... sources)
                     throws ReactorException {
         final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild(
-                statementParserMode, isFeatureSupported);
+                statementParserMode, supportedFeatures);
         reactor.addSources(sources);
 
         return reactor.buildEffective();
         reactor.addSources(sources);
 
         return reactor.buildEffective();