Bug 4506: Honor if-feature during SchemaContext assembly
[yangtools.git] / yang / yang-model-api / src / main / java / org / opendaylight / yangtools / yang / model / repo / api / SchemaContextFactory.java
index 11782fe2acbc58820883fb70f900c624acc41cf5..9b338a742b601ac66db2bcd95e006ab7c9665322 100644 (file)
@@ -10,7 +10,9 @@ 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 java.util.function.Predicate;
 import javax.annotation.Nonnull;
+import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 
 /**
@@ -30,5 +32,23 @@ public interface SchemaContextFactory {
      *         fail with an explanation why the creation of the schema context
      *         failed.
      */
-    CheckedFuture<SchemaContext, SchemaResolutionException> createSchemaContext(@Nonnull Collection<SourceIdentifier> requiredSources);
+    default CheckedFuture<SchemaContext, SchemaResolutionException> createSchemaContext(
+            @Nonnull Collection<SourceIdentifier> requiredSources) {
+        return createSchemaContext(requiredSources, t -> true);
+    }
+
+    /**
+     * Create a new schema context containing specified sources, pulling in
+     * any dependencies they may have.
+     *
+     * @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 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.
+     */
+    CheckedFuture<SchemaContext, SchemaResolutionException> createSchemaContext(
+            @Nonnull Collection<SourceIdentifier> requiredSources, Predicate<QName> isFeatureSupported);
 }