Add SchemaTreeAwareEffectiveStatement
[yangtools.git] / yang / yang-model-api / src / main / java / org / opendaylight / yangtools / yang / model / api / stmt / ModuleEffectiveStatement.java
1 /*
2  * Copyright (c) 2017 Pantheon Technologies, 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.api.stmt;
9
10 import com.google.common.annotations.Beta;
11 import org.eclipse.jdt.annotation.NonNull;
12 import org.opendaylight.yangtools.yang.common.QNameModule;
13 import org.opendaylight.yangtools.yang.model.api.meta.IdentifierNamespace;
14
15 /**
16  * Effective view of a {@link ModuleStatement}.
17  */
18 @Beta
19 // FIXME: 3.0.0: we should reshuffle the String here, as module name is in reality a YANG identifier, e.g. not just
20 //               an ordinary String. We really want this to be a QName, so that we do not need the localQNameModule
21 //               bit, but that may be problematic with ModuleStatement, which is getting created before we even know
22 //               the namespace :( A type capture of the string may just be sufficient.
23 public interface ModuleEffectiveStatement extends SchemaTreeAwareEffectiveStatement<String, ModuleStatement> {
24     /**
25      * Namespace mapping all known prefixes in a module to their modules. Note this namespace includes the module
26      * in which it is instantiated.
27      */
28     abstract class PrefixToEffectiveModuleNamespace
29             implements IdentifierNamespace<String, @NonNull ModuleEffectiveStatement> {
30         private PrefixToEffectiveModuleNamespace() {
31             // This class should never be subclassed
32         }
33     }
34
35     /**
36      * Namespace mapping all known {@link QNameModule}s to their encoding prefixes. This includes the declaration
37      * from prefix/namespace/revision and all imports as they were resolved.
38      */
39     abstract class QNameModuleToPrefixNamespace implements IdentifierNamespace<QNameModule, @NonNull String> {
40         private QNameModuleToPrefixNamespace() {
41             // This class should never be subclassed
42         }
43     }
44
45     /**
46      * Namespace mapping all included submodules. The namespaces is keyed by submodule name.
47      */
48     abstract class NameToEffectiveSubmoduleNamespace
49             implements IdentifierNamespace<String, @NonNull SubmoduleEffectiveStatement> {
50         private NameToEffectiveSubmoduleNamespace() {
51             // This class should never be subclassed
52         }
53     }
54
55     /**
56      * Get the local QNameModule of this module. All implementations need to override this default method.
57      *
58      * @return Local QNameModule
59      */
60     // FIXME: 3.0.0 make this method non-default.
61     default @NonNull QNameModule localQNameModule() {
62         throw new UnsupportedOperationException(getClass() + " is missing an implementation");
63     }
64 }