Bug 6868: If-feature argument may be boolean expression
[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.Set;
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 based on
20  * a specification of what {@link SourceIdentifier}s are required and dynamic
21  * recursive resolution.
22  */
23 @Beta
24 public interface SchemaContextFactory {
25     /**
26      * Create a new schema context containing specified sources, pulling in any
27      * dependencies they may have.
28      *
29      * @param requiredSources
30      *            a collection of sources which are required to be present
31      * @return A checked future, which will produce a schema context, or fail
32      *         with an explanation why the creation of the schema context
33      *         failed.
34      */
35     default CheckedFuture<SchemaContext, SchemaResolutionException> createSchemaContext(
36             @Nonnull final Collection<SourceIdentifier> requiredSources) {
37         return createSchemaContext(requiredSources, StatementParserMode.DEFAULT_MODE);
38     }
39
40     /**
41      * Create a new schema context containing specified sources, pulling in any
42      * dependencies they may have.
43      *
44      * @param requiredSources
45      *            a collection of sources which are required to be present
46      * @param statementParserMode
47      *            mode of statement parser
48      * @return A checked future, which will produce a schema context, or fail
49      *         with an explanation why the creation of the schema context
50      *         failed.
51      */
52     default CheckedFuture<SchemaContext, SchemaResolutionException> createSchemaContext(
53             final Collection<SourceIdentifier> requiredSources, final StatementParserMode statementParserMode) {
54         return createSchemaContext(requiredSources, statementParserMode, null);
55     }
56
57     /**
58      * Create a new schema context containing specified sources, pulling in any
59      * dependencies they may have.
60      *
61      * @param requiredSources
62      *            a collection of sources which are required to be present
63      * @param supportedFeatures
64      *            set of supported features based on which all if-feature statements in the
65      *            parsed yang models are resolved
66      * @return A checked future, which will produce a schema context, or fail
67      *         with an explanation why the creation of the schema context
68      *         failed.
69      */
70     default CheckedFuture<SchemaContext, SchemaResolutionException> createSchemaContext(
71             @Nonnull final Collection<SourceIdentifier> requiredSources, final Set<QName> supportedFeatures) {
72         return createSchemaContext(requiredSources, StatementParserMode.DEFAULT_MODE, supportedFeatures);
73     }
74
75     /**
76      * Create a new schema context containing specified sources, pulling in any
77      * dependencies they may have.
78      *
79      * @param requiredSources
80      *            a collection of sources which are required to be present
81      * @param statementParserMode
82      *            mode of statement parser
83      * @param supportedFeatures
84      *            set of supported features based on which all if-feature statements in the
85      *            parsed yang models are resolved
86      * @return A checked future, which will produce a schema context, or fail
87      *         with an explanation why the creation of the schema context
88      *         failed.
89      */
90     CheckedFuture<SchemaContext, SchemaResolutionException> createSchemaContext(
91             Collection<SourceIdentifier> requiredSources, StatementParserMode statementParserMode,
92             Set<QName> supportedFeatures);
93 }