Add Case/Extension/Feature/IdentityEffectiveStatementNamespace
[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.EffectiveStatement;
14 import org.opendaylight.yangtools.yang.model.api.meta.IdentifierNamespace;
15
16 /**
17  * Effective view of a {@link ModuleStatement}.
18  */
19 @Beta
20 public interface ModuleEffectiveStatement extends EffectiveStatement<String, ModuleStatement> {
21     /**
22      * Namespace mapping all known prefixes in a module to their modules. Note this namespace includes the module
23      * in which it is instantiated.
24      */
25     abstract class PrefixToEffectiveModuleNamespace
26             implements IdentifierNamespace<String, @NonNull ModuleEffectiveStatement> {
27         private PrefixToEffectiveModuleNamespace() {
28             // This class should never be subclassed
29         }
30     }
31
32     /**
33      * Namespace mapping all known {@link QNameModule}s to their encoding prefixes. This includes the declaration
34      * from prefix/namespace/revision and all imports as they were resolved.
35      */
36     abstract class QNameModuleToPrefixNamespace implements IdentifierNamespace<QNameModule, @NonNull String> {
37         private QNameModuleToPrefixNamespace() {
38             // This class should never be subclassed
39         }
40     }
41
42     /**
43      * Namespace mapping all included submodules. The namespaces is keyed by submodule name.
44      */
45     abstract class NameToEffectiveSubmoduleNamespace
46             implements IdentifierNamespace<String, @NonNull SubmoduleEffectiveStatement> {
47         private NameToEffectiveSubmoduleNamespace() {
48             // This class should never be subclassed
49         }
50     }
51
52     /**
53      * Get the local QNameModule of this module. All implementations need to override this default method.
54      *
55      * @return Local QNameModule
56      */
57     // FIXME: 3.0.0 make this method non-default
58     default @NonNull QNameModule localQNameModule() {
59         throw new UnsupportedOperationException(getClass() + " is missing an implementation");
60     }
61 }