2 * Copyright (c) 2019 PANTHEON.tech, s.r.o. and others. All rights reserved.
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
8 package org.opendaylight.yangtools.yang.model.repo.api;
10 import com.google.common.annotations.Beta;
11 import com.google.common.util.concurrent.Futures;
12 import com.google.common.util.concurrent.ListenableFuture;
13 import com.google.common.util.concurrent.MoreExecutors;
14 import java.util.Arrays;
15 import java.util.Collection;
16 import org.eclipse.jdt.annotation.NonNull;
17 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
18 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
21 * An asynchronous factory for building {@link SchemaContext} instances based on a specification of what
22 * {@link SourceIdentifier}s are required and dynamic recursive resolution.
25 //FIXME: 5.0.0: evaluate if we still need to extend SchemaContext here
26 public interface EffectiveModelContextFactory extends SchemaContextFactory {
28 * Create a new schema context containing specified sources, pulling in any dependencies they may have.
30 * @param requiredSources a collection of sources which are required to be present
31 * @return A checked future, which will produce a schema context, or fail with an explanation why the creation
32 * of the schema context failed.
34 @NonNull ListenableFuture<EffectiveModelContext> createEffectiveModelContext(
35 @NonNull Collection<SourceIdentifier> requiredSources);
37 default @NonNull ListenableFuture<EffectiveModelContext> createEffectiveModelContext(
38 final SourceIdentifier... requiredSources) {
39 return createEffectiveModelContext(Arrays.asList(requiredSources));
44 default ListenableFuture<SchemaContext> createSchemaContext(
45 final Collection<SourceIdentifier> requiredSources) {
46 return Futures.transform(createEffectiveModelContext(requiredSources), ctx -> ctx,
47 MoreExecutors.directExecutor());