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
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.yangtools.yang.model.repo.api;
9
10 import com.google.common.annotations.Beta;
11 import com.google.common.util.concurrent.CheckedFuture;
12 import java.util.Collection;
13 import java.util.function.Predicate;
14 import javax.annotation.Nonnull;
15 import org.opendaylight.yangtools.yang.common.QName;
16 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
17
18 /**
19  * An asynchronous factory for building {@link SchemaContext} instances
20  * based on a specification of what {@link SourceIdentifier}s are required
21  * and dynamic recursive resolution.
22  */
23 @Beta
24 public interface SchemaContextFactory {
25     /**
26      * Create a new schema context containing specified sources, pulling in
27      * any dependencies they may have.
28      *
29      * @param requiredSources a collection of sources which are required to
30      *                        be present
31      * @return A checked future, which will produce a schema context, or
32      *         fail with an explanation why the creation of the schema context
33      *         failed.
34      */
35     default CheckedFuture<SchemaContext, SchemaResolutionException> createSchemaContext(
36             @Nonnull Collection<SourceIdentifier> requiredSources) {
37         return createSchemaContext(requiredSources, t -> true);
38     }
39
40     /**
41      * Create a new schema context containing specified sources, pulling in
42      * any dependencies they may have.
43      *
44      * @param requiredSources a collection of sources which are required to
45      *                        be present
46      * @param isFeatureSupported a predicate based on which all if-feature statements in the parsed yang
47      *                          models are resolved
48      * @return A checked future, which will produce a schema context, or
49      *         fail with an explanation why the creation of the schema context
50      *         failed.
51      */
52     CheckedFuture<SchemaContext, SchemaResolutionException> createSchemaContext(
53             @Nonnull Collection<SourceIdentifier> requiredSources, Predicate<QName> isFeatureSupported);
54 }