Promote SchemaSourceRepresentation
[yangtools.git] / yang / yang-repo-api / src / main / java / org / opendaylight / yangtools / yang / model / repo / api / EffectiveModelContextFactory.java
1 /*
2  * Copyright (c) 2019 PANTHEON.tech, s.r.o. 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.ListenableFuture;
12 import java.util.Collection;
13 import java.util.List;
14 import org.eclipse.jdt.annotation.NonNull;
15 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
16 import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
17
18 /**
19  * An asynchronous factory for building {@link EffectiveModelContext} instances based on a specification of what
20  * {@link SourceIdentifier}s are required and dynamic recursive resolution.
21  */
22 @Beta
23 public interface EffectiveModelContextFactory {
24     /**
25      * Create a new schema context containing specified sources, pulling in any dependencies they may have.
26      *
27      * @param requiredSources a collection of sources which are required to be present
28      * @return A checked future, which will produce a schema context, or fail with an explanation why the creation
29      *         of the schema context failed.
30      */
31     @NonNull ListenableFuture<EffectiveModelContext> createEffectiveModelContext(
32             @NonNull Collection<SourceIdentifier> requiredSources);
33
34     default @NonNull ListenableFuture<EffectiveModelContext> createEffectiveModelContext(
35             final SourceIdentifier... requiredSources) {
36         return createEffectiveModelContext(List.of(requiredSources));
37     }
38 }