Refactor DOMYangTextSourceProvider
[mdsal.git] / dom / mdsal-dom-api / src / main / java / org / opendaylight / mdsal / dom / api / DOMSchemaService.java
1 /*
2  * Copyright (c) 2013 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.mdsal.dom.api;
9
10 import com.google.common.util.concurrent.ListenableFuture;
11 import java.util.function.Consumer;
12 import org.eclipse.jdt.annotation.NonNullByDefault;
13 import org.opendaylight.yangtools.concepts.Registration;
14 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
15 import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
16 import org.opendaylight.yangtools.yang.model.api.source.YangTextSource;
17
18 @NonNullByDefault
19 public interface DOMSchemaService extends DOMService<DOMSchemaService, DOMSchemaService.Extension> {
20     /**
21      * Type capture of a {@link DOMService.Extension} applicable to {@link DOMSchemaService} implementations.
22      */
23     interface Extension extends DOMService.Extension<DOMSchemaService, Extension> {
24         // Marker interface
25     }
26
27     /**
28      * Returns global schema context.
29      *
30      * @return schemaContext
31      */
32     EffectiveModelContext getGlobalContext();
33
34     /**
35      * Register a listener for changes in schema context.
36      *
37      * @param listener Listener which should be registered
38      * @return Listener registration handle
39      * @throws NullPointerException if {@code listener} is {@code null}
40      */
41     Registration registerSchemaContextListener(Consumer<EffectiveModelContext> listener);
42
43     /**
44      * An {@link Extension} exposing access to {@link YangTextSource}.
45      */
46     @FunctionalInterface
47     interface YangTextSourceExtension extends Extension {
48         /**
49          * Return a future producing a {@link YangTextSource} containing the YANG text of specified source.
50          *
51          * @param sourceId A {@link SourceIdentifier}
52          * @return A future
53          */
54         ListenableFuture<YangTextSource> getYangTexttSource(SourceIdentifier sourceId);
55     }
56 }