Turn ParserNamespace into an abstract class 40/102140/18
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 17 Aug 2022 17:28:40 +0000 (19:28 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Thu, 18 Aug 2022 21:29:28 +0000 (23:29 +0200)
This is an effort to stop addressing namespaces through .class objects,
but rather through objects. As a first step switch to the hierarchy to
be based on an abstract class and make concrete namespaces final.

JIRA: YANGTOOLS-1453
Change-Id: Ib09406f8c4d667d45676c6cd3f01cd64434f1c0c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
46 files changed:
parser/rfc8040-parser-support/src/main/java/org/opendaylight/yangtools/rfc8040/parser/YangDataArgumentNamespace.java
parser/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/namespace/ModuleQNameToPrefix.java
parser/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/namespace/YangNamespaceContextNamespace.java
parser/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/augment/AugmentImplicitHandlingNamespace.java
parser/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/import_/ImportedVersionNamespace.java
parser/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/list/ConfigListWarningNamespace.java
parser/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/module/QNameModuleNamespace.java
parser/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/refine/RefineTargetNamespace.java
parser/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/type/BaseTypeNamespace.java
parser/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/uses/SourceGroupingNamespace.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/thirdparty/plugin/ThirdPartyExtensionPluginTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/thirdparty/plugin/ThirdPartyNamespace.java
parser/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/ExtensionNamespace.java
parser/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/FeatureNamespace.java
parser/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/GroupingNamespace.java
parser/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/IdentityNamespace.java
parser/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/ModuleNamespace.java
parser/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/NamespaceToModule.java
parser/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/PreLinkageModuleNamespace.java
parser/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/SchemaTreeNamespace.java
parser/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/SubmoduleNamespace.java
parser/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/TypeNamespace.java
parser/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/ImportedNamespaceContext.java
parser/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/ParserNamespace.java
parser/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/StatementDefinitionNamespace.java
parser/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/StatementNamespace.java
parser/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/StatementSupportBundle.java
parser/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/StatementSupportNamespace.java
parser/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/source/BelongsToPrefixToModuleCtx.java
parser/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/source/BelongsToPrefixToModuleName.java
parser/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/source/ImpPrefixToNamespace.java
parser/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/source/ImportPrefixToModuleCtx.java
parser/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/source/ImportedModuleContext.java
parser/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/source/IncludedModuleContext.java
parser/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/source/IncludedSubmoduleNameToModuleCtx.java
parser/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/source/ModuleCtxToModuleQName.java
parser/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/source/ModuleCtxToSourceIdentifier.java
parser/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/source/ModuleNameToModuleQName.java
parser/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/source/ModuleNameToNamespace.java
parser/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/source/ModuleNamespaceForBelongsTo.java
parser/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/source/ModuleQNameToModuleName.java
parser/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/source/ModulesDeviatedByModules.java
parser/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/source/PrefixToModule.java
parser/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/source/SupportedFeaturesNamespace.java
parser/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/validation/ValidationBundlesNamespace.java
parser/yang-parser-spi/src/test/java/org/opendaylight/yangtools/yang/parser/spi/validation/ValidationBundlesNamespaceTest.java [deleted file]

index c05187235eecf0bcc29ffd24423d4437cfe60fee..5a353695066ff7506ee8b4a59eccf2a9954994e0 100644 (file)
@@ -20,8 +20,11 @@ import org.opendaylight.yangtools.yang.parser.spi.meta.ParserNamespace;
 @Beta
 // FIXME: We should not be needing this namespace, as yang-data's argument is not documented anywhere to be compatible
 //        with 'identifier', hence we cannot safely form a QName.
-public interface YangDataArgumentNamespace extends ParserNamespace<Empty, QName> {
-    NamespaceBehaviour<Empty, QName, @NonNull YangDataArgumentNamespace> BEHAVIOUR =
+public final class YangDataArgumentNamespace extends ParserNamespace<Empty, QName> {
+    public static final @NonNull NamespaceBehaviour<?, ? ,?> BEHAVIOUR =
         NamespaceBehaviour.statementLocal(YangDataArgumentNamespace.class);
 
+    private YangDataArgumentNamespace() {
+        // Hidden on purpose
+    }
 }
index b2a91c0b3d221793acc92fcef3c63e99cb96ba30..eed73dd3b52157bb33a4d3d08ee6b6df688a6044 100644 (file)
@@ -18,7 +18,11 @@ import org.opendaylight.yangtools.yang.parser.spi.meta.ParserNamespace;
  * some quality parsing time.
  */
 @Beta
-public interface ModuleQNameToPrefix extends ParserNamespace<QNameModule, String> {
-    NamespaceBehaviour<QNameModule, String, @NonNull ModuleQNameToPrefix> BEHAVIOUR =
-            NamespaceBehaviour.rootStatementLocal(ModuleQNameToPrefix.class);
+public final class ModuleQNameToPrefix extends ParserNamespace<QNameModule, String> {
+    public static final @NonNull NamespaceBehaviour<?, ?, ?> BEHAVIOUR =
+        NamespaceBehaviour.rootStatementLocal(ModuleQNameToPrefix.class);
+
+    private ModuleQNameToPrefix() {
+        // Hidden on purpose
+    }
 }
index dceb43aad521b692d9ae93c0c9e6c100d96e1174..76788692af614094079bf96c4b71e7d95537b0cb 100644 (file)
@@ -14,16 +14,21 @@ import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.yang.common.YangNamespaceContext;
 import org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceBehaviour;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ParserNamespace;
+import org.opendaylight.yangtools.yang.parser.spi.meta.RootStmtContext;
 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext.Mutable;
 
 @Beta
-public interface YangNamespaceContextNamespace extends ParserNamespace<StmtContext<?, ?, ?>, YangNamespaceContext> {
-    NamespaceBehaviour<StmtContext<?, ?, ?>, YangNamespaceContext, @NonNull YangNamespaceContextNamespace> BEHAVIOUR =
-            NamespaceBehaviour.global(YangNamespaceContextNamespace.class);
+public final class YangNamespaceContextNamespace extends ParserNamespace<StmtContext<?, ?, ?>, YangNamespaceContext> {
+    public static final @NonNull NamespaceBehaviour<?, ?, ?> BEHAVIOUR =
+        NamespaceBehaviour.global(YangNamespaceContextNamespace.class);
 
-    static @NonNull YangNamespaceContext computeIfAbsent(final StmtContext<?, ?, ?> ctx) {
-        final StmtContext<?, ?, ?> root = ctx.getRoot();
+    private YangNamespaceContextNamespace() {
+        // Hidden on purpose
+    }
+
+    public static @NonNull YangNamespaceContext computeIfAbsent(final StmtContext<?, ?, ?> ctx) {
+        final RootStmtContext<?, ?, ?> root = ctx.getRoot();
         YangNamespaceContext ret = ctx.getFromNamespace(YangNamespaceContextNamespace.class, root);
         if (ret == null) {
             verify(ctx instanceof Mutable, "Cannot populate namespace context to %s", ctx);
index a37f2b165d6f56cf28199fe4a9ee48c031c67948..c3175c71739b7e03dd5648f439eceb6726457f6b 100644 (file)
@@ -19,7 +19,11 @@ import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext.Mutable;
  * the effective augment has correct implicit statements created.
  */
 @Beta
-public interface AugmentImplicitHandlingNamespace extends ParserNamespace<Empty, Mutable<?, ?, ?>> {
-    NamespaceBehaviour<Empty, Mutable<?, ?, ?>, @NonNull AugmentImplicitHandlingNamespace>
-        BEHAVIOUR = NamespaceBehaviour.statementLocal(AugmentImplicitHandlingNamespace.class);
+public final class AugmentImplicitHandlingNamespace extends ParserNamespace<Empty, Mutable<?, ?, ?>> {
+    public static final @NonNull NamespaceBehaviour<?, ?, ?> BEHAVIOUR =
+        NamespaceBehaviour.statementLocal(AugmentImplicitHandlingNamespace.class);
+
+    private AugmentImplicitHandlingNamespace() {
+        // Hidden on purpose
+    }
 }
index ee965ef75d8abdbe3c655696b44de6526a084aa8..99250dcba13f17167906b4ab69d8483a9da54109 100644 (file)
@@ -18,8 +18,11 @@ import org.opendaylight.yangtools.yang.parser.spi.meta.ParserNamespace;
  * Statement-local namespace carrying the versioning information about how the import was satisfied.
  */
 @Beta
-public interface ImportedVersionNamespace extends ParserNamespace<Empty, SourceIdentifier> {
-    NamespaceBehaviour<Empty, SourceIdentifier, @NonNull ImportedVersionNamespace> BEHAVIOUR =
+public final class ImportedVersionNamespace extends ParserNamespace<Empty, SourceIdentifier> {
+    public static final @NonNull NamespaceBehaviour<?, ?, ?> BEHAVIOUR =
         NamespaceBehaviour.statementLocal(ImportedVersionNamespace.class);
 
+    private ImportedVersionNamespace() {
+        // Hidden on purpose
+    }
 }
index 9282f157c8d96c58f71f802e60b23bbf7ff7c3d1..a6653d9c262717e5116a02df3f035acabda90475 100644 (file)
@@ -14,7 +14,11 @@ import org.opendaylight.yangtools.yang.parser.spi.meta.ParserNamespace;
 import org.opendaylight.yangtools.yang.parser.spi.source.StatementSourceReference;
 
 @Beta
-public interface ConfigListWarningNamespace extends ParserNamespace<StatementSourceReference, Boolean> {
-    NamespaceBehaviour<StatementSourceReference, Boolean, @NonNull ConfigListWarningNamespace> BEHAVIOUR =
-            NamespaceBehaviour.global(ConfigListWarningNamespace.class);
+public final class ConfigListWarningNamespace extends ParserNamespace<StatementSourceReference, Boolean> {
+    public static final @NonNull NamespaceBehaviour<?, ?, ?> BEHAVIOUR =
+        NamespaceBehaviour.global(ConfigListWarningNamespace.class);
+
+    private ConfigListWarningNamespace() {
+        // Hidden on purpose
+    }
 }
index f8fee1405d272bd16edb77ec4335c66072f4b273..adf7f6188a3ab9fb162f071ba3d66bf088780cb6 100644 (file)
@@ -18,8 +18,11 @@ import org.opendaylight.yangtools.yang.parser.spi.meta.ParserNamespace;
  * Module-local namespace holding the module's QName.
  */
 @Beta
-public interface QNameModuleNamespace extends ParserNamespace<Empty, QNameModule> {
-    NamespaceBehaviour<Empty, QNameModule, @NonNull QNameModuleNamespace> BEHAVIOUR =
+public final class QNameModuleNamespace extends ParserNamespace<Empty, QNameModule> {
+    public static final @NonNull NamespaceBehaviour<?, ?, ?> BEHAVIOUR =
         NamespaceBehaviour.statementLocal(QNameModuleNamespace.class);
 
+    private QNameModuleNamespace() {
+        // Hidden on purpose
+    }
 }
index ba0c8bfd3c0d267aa04ffe901a8684d1c64a1818..f0d05a8d15ff0fdeef847445a7927f91df340256 100644 (file)
@@ -15,8 +15,11 @@ import org.opendaylight.yangtools.yang.parser.spi.meta.ParserNamespace;
 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
 
 @Beta
-public interface RefineTargetNamespace extends ParserNamespace<Empty, StmtContext<?, ?, ?>> {
-    NamespaceBehaviour<Empty, StmtContext<?, ?, ?>, @NonNull RefineTargetNamespace>
-        BEHAVIOUR = NamespaceBehaviour.statementLocal(RefineTargetNamespace.class);
+public final class RefineTargetNamespace extends ParserNamespace<Empty, StmtContext<?, ?, ?>> {
+    public static final @NonNull NamespaceBehaviour<?, ?, ?> BEHAVIOUR =
+        NamespaceBehaviour.statementLocal(RefineTargetNamespace.class);
 
+    private RefineTargetNamespace() {
+        // Hidden on purpose
+    }
 }
index ecb04ab2b72a6d689384e4477e72f5b4ba562d15..66b69ebbda044c743b88287cc17ab33ed1ff0f9c 100644 (file)
@@ -14,7 +14,11 @@ import org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceBehaviour;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ParserNamespace;
 
 @Beta
-public interface BaseTypeNamespace extends ParserNamespace<Empty, Object> {
-    NamespaceBehaviour<Empty, Object, @NonNull BaseTypeNamespace> BEHAVIOUR =
+public final class BaseTypeNamespace extends ParserNamespace<Empty, Object> {
+    public static final @NonNull NamespaceBehaviour<?, ?, ?> BEHAVIOUR =
         NamespaceBehaviour.statementLocal(BaseTypeNamespace.class);
+
+    private BaseTypeNamespace() {
+        // Hidden on purpose
+    }
 }
index fc4f50fa2faf2785fb7f51150ab2339739f7cb59..64239b2c6a76b0438bf76466b45eff22f0205224 100644 (file)
@@ -15,7 +15,11 @@ import org.opendaylight.yangtools.yang.parser.spi.meta.ParserNamespace;
 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
 
 @Beta
-public interface SourceGroupingNamespace extends ParserNamespace<Empty, StmtContext<?, ?, ?>> {
-    NamespaceBehaviour<Empty, StmtContext<?, ?, ?>, @NonNull SourceGroupingNamespace> BEHAVIOUR =
+public final class SourceGroupingNamespace extends ParserNamespace<Empty, StmtContext<?, ?, ?>> {
+    public static final @NonNull NamespaceBehaviour<?, ?, ?> BEHAVIOUR =
         NamespaceBehaviour.statementLocal(SourceGroupingNamespace.class);
+
+    private SourceGroupingNamespace() {
+        // Hidden on purpose
+    }
 }
index 4eeb396e74fb6ecaaa580f2d011d4169324de12c..ddac05e19d559cc35a8ba5e58c8c73cb8b932b35 100644 (file)
@@ -37,7 +37,7 @@ public class ThirdPartyExtensionPluginTest {
         final BuildAction reactor = RFC7950Reactors.defaultReactorBuilder()
             .addStatementSupport(ModelProcessingPhase.FULL_DECLARATION,
                 new ThirdPartyExtensionSupport(YangParserConfiguration.DEFAULT))
-            .addNamespaceSupport(ModelProcessingPhase.FULL_DECLARATION, ThirdPartyNamespace.BEHAVIOR)
+            .addNamespaceSupport(ModelProcessingPhase.FULL_DECLARATION, ThirdPartyNamespace.BEHAVIOUR)
             .build()
             .newBuild();
         reactor.addSource(StmtTestUtils.sourceForResource("/plugin-test/foo.yang"));
index 50d54c88ca9dd22630b13790dddd707da121b5dd..be92f06b232f1a17d1a5c52178812c9ce09e0950 100644 (file)
@@ -15,8 +15,11 @@ import org.opendaylight.yangtools.yang.parser.spi.meta.ParserNamespace;
 /**
  * ThirdPartyNamespace.
  */
-public interface ThirdPartyNamespace extends ParserNamespace<Empty, String> {
-    @NonNull NamespaceBehaviour<Empty, String, @NonNull ThirdPartyNamespace> BEHAVIOR =
+public final class ThirdPartyNamespace extends ParserNamespace<Empty, String> {
+    public static final @NonNull NamespaceBehaviour<?, ?, ?> BEHAVIOUR =
         NamespaceBehaviour.statementLocal(ThirdPartyNamespace.class);
 
+    private ThirdPartyNamespace() {
+        // Hidden on purpose
+    }
 }
index 6bd2bd2e3452449bfe06c8578b7f83f331f0fca5..2dc91601db978deb5a7e48deb39d9e11fad9d376 100644 (file)
@@ -13,15 +13,18 @@ import org.opendaylight.yangtools.yang.model.api.stmt.ExtensionEffectiveStatemen
 import org.opendaylight.yangtools.yang.model.api.stmt.ExtensionStatement;
 import org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceBehaviour;
 import org.opendaylight.yangtools.yang.parser.spi.meta.StatementNamespace;
-import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
 
 /**
- * Extension namespace. All extension names defined in a module and its submodules share the same
- * extension identifier namespace, where each extension is identified by a QName formed from the
- * defining module's QNameModule and the identifier specified in extension statement's argument.
+ * Extension namespace. All extension names defined in a module and its submodules share the same extension identifier
+ * namespace, where each extension is identified by a QName formed from the defining module's QNameModule and the
+ * identifier specified in extension statement's argument.
  */
-public interface ExtensionNamespace extends StatementNamespace<QName, ExtensionStatement, ExtensionEffectiveStatement> {
-    NamespaceBehaviour<QName, StmtContext<?, ExtensionStatement, ExtensionEffectiveStatement>,
-            @NonNull ExtensionNamespace> BEHAVIOUR = NamespaceBehaviour.global(ExtensionNamespace.class);
+public final class ExtensionNamespace
+        extends StatementNamespace<QName, ExtensionStatement, ExtensionEffectiveStatement> {
+    public static final @NonNull NamespaceBehaviour<?, ?, ?> BEHAVIOUR =
+        NamespaceBehaviour.global(ExtensionNamespace.class);
 
+    private ExtensionNamespace() {
+        // Hidden on purpose
+    }
 }
index 0e7b050d6c260fcee8864af55fca65c731c5e6bf..dad26b2114b3d59bf934aa5312d411b7f8d02148 100644 (file)
@@ -13,15 +13,16 @@ import org.opendaylight.yangtools.yang.model.api.stmt.FeatureEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.FeatureStatement;
 import org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceBehaviour;
 import org.opendaylight.yangtools.yang.parser.spi.meta.StatementNamespace;
-import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
 
 /**
- * Feature namespace. All feature names defined in a module and its submodules share the
- * same feature identifier namespace. Each feature is identified by a QName formed from
- * the defining module's QNameModule and the feature name.
+ * Feature namespace. All feature names defined in a module and its submodules share the same feature identifier
+ * namespace. Each feature is identified by a QName formed from the defining module's QNameModule and the feature name.
  */
-public interface FeatureNamespace extends StatementNamespace<QName, FeatureStatement, FeatureEffectiveStatement> {
-    NamespaceBehaviour<QName, StmtContext<?, FeatureStatement, FeatureEffectiveStatement>,
-            @NonNull FeatureNamespace> BEHAVIOUR = NamespaceBehaviour.global(FeatureNamespace.class);
+public final class FeatureNamespace extends StatementNamespace<QName, FeatureStatement, FeatureEffectiveStatement> {
+    public static final @NonNull NamespaceBehaviour<?, ?, ?> BEHAVIOUR =
+        NamespaceBehaviour.global(FeatureNamespace.class);
 
+    private FeatureNamespace() {
+        // Hidden on purpose
+    }
 }
index c407ef9ed682f581d6a91706d1d63580e799dfb3..c3d010c594b2359e255e47b3d22c046d148e50f0 100644 (file)
@@ -13,7 +13,6 @@ import org.opendaylight.yangtools.yang.model.api.stmt.GroupingEffectiveStatement
 import org.opendaylight.yangtools.yang.model.api.stmt.GroupingStatement;
 import org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceBehaviour;
 import org.opendaylight.yangtools.yang.parser.spi.meta.StatementNamespace.TreeScoped;
-import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
 
 /**
  * Grouping namespace. * All grouping names defined within a parent node or at the top level of the module
@@ -23,8 +22,11 @@ import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
  * <p>
  * This means that any descendant node may use that grouping, and it MUST NOT define a grouping with the same name.
  */
-public interface GroupingNamespace extends TreeScoped<QName, GroupingStatement, GroupingEffectiveStatement> {
-    NamespaceBehaviour<QName, StmtContext<?, GroupingStatement, GroupingEffectiveStatement>,
-            @NonNull GroupingNamespace> BEHAVIOUR = NamespaceBehaviour.treeScoped(GroupingNamespace.class);
+public final class GroupingNamespace extends TreeScoped<QName, GroupingStatement, GroupingEffectiveStatement> {
+    public static final @NonNull NamespaceBehaviour<?, ?, ?> BEHAVIOUR =
+        NamespaceBehaviour.treeScoped(GroupingNamespace.class);
 
+    private GroupingNamespace() {
+        // Hidden on purpose
+    }
 }
index b092406658567ea12734145e6dbb6b005c6ac5ee..ac101ff069bc5c003c9572f2e551c93a22b4b327 100644 (file)
@@ -13,15 +13,16 @@ import org.opendaylight.yangtools.yang.model.api.stmt.IdentityEffectiveStatement
 import org.opendaylight.yangtools.yang.model.api.stmt.IdentityStatement;
 import org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceBehaviour;
 import org.opendaylight.yangtools.yang.parser.spi.meta.StatementNamespace;
-import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
 
 /**
  * Identity namespace. All identity names defined in a module and its submodules share the same identity identifier
  * namespace.
  */
-public interface IdentityNamespace extends
-        StatementNamespace<QName, IdentityStatement, IdentityEffectiveStatement> {
-    NamespaceBehaviour<QName, StmtContext<?, IdentityStatement, IdentityEffectiveStatement>,
-            @NonNull IdentityNamespace> BEHAVIOUR = NamespaceBehaviour.global(IdentityNamespace.class);
+public final class IdentityNamespace extends StatementNamespace<QName, IdentityStatement, IdentityEffectiveStatement> {
+    public static final @NonNull NamespaceBehaviour<?, ?, ?> BEHAVIOUR =
+        NamespaceBehaviour.global(IdentityNamespace.class);
 
+    private IdentityNamespace() {
+        // Hidden on purpose
+    }
 }
index 9788fde789ed4f71c0b1b141978ed5c6cd25c6c1..daf6162797118a7c4521c914afa14b6389ad27ad 100644 (file)
@@ -13,14 +13,17 @@ import org.opendaylight.yangtools.yang.model.api.stmt.ModuleStatement;
 import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
 import org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceBehaviour;
 import org.opendaylight.yangtools.yang.parser.spi.meta.StatementNamespace;
-import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
 
 /**
  * Module namespace. All modules known to the reactor are populated to this namespace. Each module is identified
  * by a {@link SourceIdentifier}.
  */
-public interface ModuleNamespace
+public final class ModuleNamespace
         extends StatementNamespace<SourceIdentifier, ModuleStatement, ModuleEffectiveStatement> {
-    NamespaceBehaviour<SourceIdentifier, StmtContext<?, ModuleStatement, ModuleEffectiveStatement>,
-            @NonNull ModuleNamespace> BEHAVIOUR = NamespaceBehaviour.global(ModuleNamespace.class);
+    public static final @NonNull NamespaceBehaviour<?, ?, ?> BEHAVIOUR =
+        NamespaceBehaviour.global(ModuleNamespace.class);
+
+    private ModuleNamespace() {
+        // Hidden on purpose
+    }
 }
index dc81edf388ca0556eb47e327d1a4bdad0c113671..7218155b6729663077daccfd362e37a24c3ac6e2 100644 (file)
@@ -13,12 +13,16 @@ import org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.ModuleStatement;
 import org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceBehaviour;
 import org.opendaylight.yangtools.yang.parser.spi.meta.StatementNamespace;
-import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
 
 /**
  * A derived namespace allowing lookup of modules based on their {@link QNameModule}.
  */
-public interface NamespaceToModule extends StatementNamespace<QNameModule, ModuleStatement, ModuleEffectiveStatement> {
-    NamespaceBehaviour<QNameModule, StmtContext<?, ModuleStatement, ModuleEffectiveStatement>,
-            @NonNull NamespaceToModule> BEHAVIOUR = NamespaceBehaviour.global(NamespaceToModule.class);
+public final class NamespaceToModule
+        extends StatementNamespace<QNameModule, ModuleStatement, ModuleEffectiveStatement> {
+    public static final @NonNull NamespaceBehaviour<?, ?, ?> BEHAVIOUR =
+        NamespaceBehaviour.global(NamespaceToModule.class);
+
+    private NamespaceToModule() {
+        // Hidden on purpose
+    }
 }
index 6203991f69b1b20ec971f97a65af597452d6a45b..141ecfe8998fdee2544d3141725f699df2dc1b4e 100644 (file)
@@ -13,15 +13,17 @@ import org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.ModuleStatement;
 import org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceBehaviour;
 import org.opendaylight.yangtools.yang.parser.spi.meta.StatementNamespace;
-import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
 
 /**
  * Intermediate-stage namespace equivalent to ModuleNamespace except it is keyed by module names. This namespace is
  * used to resolve inter-module references before actual linkage occurs.
  */
-public interface PreLinkageModuleNamespace
+public final class PreLinkageModuleNamespace
         extends StatementNamespace<Unqualified, ModuleStatement, ModuleEffectiveStatement> {
-    NamespaceBehaviour<Unqualified, StmtContext<?, ModuleStatement, ModuleEffectiveStatement>,
-            @NonNull PreLinkageModuleNamespace> BEHAVIOUR = NamespaceBehaviour.global(PreLinkageModuleNamespace.class);
+    public static final @NonNull NamespaceBehaviour<?, ?, ?> BEHAVIOUR =
+        NamespaceBehaviour.global(PreLinkageModuleNamespace.class);
 
+    private PreLinkageModuleNamespace() {
+        // Hidden on purpose
+    }
 }
index e3629175d9da14d5a004720636035207c8c48cb8..4402843ea98f9a0616a0d82a46137edc421976a9 100644 (file)
@@ -36,12 +36,11 @@ import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
 //               into yang-(parser-)reactor-api.
 @Beta
 public final class SchemaTreeNamespace<D extends DeclaredStatement<QName>, E extends SchemaTreeEffectiveStatement<D>>
-        implements StatementNamespace<QName, D, E> {
+        extends StatementNamespace<QName, D, E> {
     public static final class Behaviour<D extends DeclaredStatement<QName>, E extends SchemaTreeEffectiveStatement<D>>
             extends NamespaceBehaviour<QName, StmtContext<?, D, E>, SchemaTreeNamespace<D, E>> {
-
         @SuppressWarnings({ "rawtypes", "unchecked" })
-        private Behaviour() {
+        Behaviour() {
             super((Class) SchemaTreeNamespace.class);
         }
 
@@ -81,6 +80,12 @@ public final class SchemaTreeNamespace<D extends DeclaredStatement<QName>, E ext
             }
         }
 
+        private static <D extends DeclaredStatement<QName>, E extends SchemaTreeEffectiveStatement<D>>
+                StmtContext<?, D, E> requestFrom(final NamespaceStorageNode storageNode, final QName key) {
+            return storageNode instanceof OnDemandSchemaTreeStorageNode ondemand ? ondemand.requestSchemaTreeChild(key)
+                : null;
+        }
+
         private static NamespaceStorageNode globalOrStatementSpecific(final NamespaceStorageNode storage) {
             NamespaceStorageNode current = requireNonNull(storage);
             while (!isLocalOrGlobal(current.getStorageNodeType())) {
@@ -92,12 +97,6 @@ public final class SchemaTreeNamespace<D extends DeclaredStatement<QName>, E ext
         private static boolean isLocalOrGlobal(final StorageNodeType type) {
             return type == StorageNodeType.STATEMENT_LOCAL || type == StorageNodeType.GLOBAL;
         }
-
-        private static <D extends DeclaredStatement<QName>, E extends SchemaTreeEffectiveStatement<D>>
-                StmtContext<?, D, E> requestFrom(final NamespaceStorageNode storageNode, final QName key) {
-            return storageNode instanceof OnDemandSchemaTreeStorageNode ondemand ? ondemand.requestSchemaTreeChild(key)
-                : null;
-        }
     }
 
     public static final @NonNull NamespaceBehaviour<?, ?, ?> BEHAVIOUR = new Behaviour<>();
index 0fbb318c9d6e27dffc2800af7956283716735fad..cd5009ca548e4d161e5f9bc5edc9ab4fa0ca8762 100644 (file)
@@ -13,15 +13,17 @@ import org.opendaylight.yangtools.yang.model.api.stmt.SubmoduleStatement;
 import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
 import org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceBehaviour;
 import org.opendaylight.yangtools.yang.parser.spi.meta.StatementNamespace;
-import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
 
 /**
  * Submodule equivalent of ModuleNamespace.
  */
 // FIXME: describe scoping of this namespace
-public interface SubmoduleNamespace
-    extends StatementNamespace<SourceIdentifier, SubmoduleStatement, SubmoduleEffectiveStatement> {
-    NamespaceBehaviour<SourceIdentifier, StmtContext<?, SubmoduleStatement, SubmoduleEffectiveStatement>,
-            @NonNull SubmoduleNamespace> BEHAVIOUR =
-            NamespaceBehaviour.global(SubmoduleNamespace.class);
+public final class SubmoduleNamespace
+        extends StatementNamespace<SourceIdentifier, SubmoduleStatement, SubmoduleEffectiveStatement> {
+    public static final @NonNull NamespaceBehaviour<?, ?, ?> BEHAVIOUR =
+        NamespaceBehaviour.global(SubmoduleNamespace.class);
+
+    private SubmoduleNamespace() {
+        // Hidden on purpose
+    }
 }
index 52ea1016b9dc90662a6b0c2c8e77e00eddf3b8cd..49966d9f86de092919dbbd8928153f085cf5af6e 100644 (file)
@@ -13,7 +13,6 @@ import org.opendaylight.yangtools.yang.model.api.stmt.TypedefEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.TypedefStatement;
 import org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceBehaviour;
 import org.opendaylight.yangtools.yang.parser.spi.meta.StatementNamespace.TreeScoped;
-import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
 
 /**
  * Derived types namespace. All derived type names defined within a parent node or at the top level of the module
@@ -27,8 +26,11 @@ import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
  * This namespace includes all type definitions implied by the language in which the current statement resides
  * (e.g. RFC6020/RFC7950 for YANG 1.0/1.1).
  */
-public interface TypeNamespace extends TreeScoped<QName, TypedefStatement, TypedefEffectiveStatement> {
-    NamespaceBehaviour<QName, StmtContext<?, TypedefStatement, TypedefEffectiveStatement>, @NonNull TypeNamespace>
-        BEHAVIOUR = NamespaceBehaviour.treeScoped(TypeNamespace.class);
+public final class TypeNamespace extends TreeScoped<QName, TypedefStatement, TypedefEffectiveStatement> {
+    public static final @NonNull NamespaceBehaviour<?, ?, ?> BEHAVIOUR =
+        NamespaceBehaviour.treeScoped(TypeNamespace.class);
 
+    private TypeNamespace() {
+        // Hidden on purpose
+    }
 }
index f62115aafe16415187ae16ef317bb4adc5049e18..0c51ce934c9d81b81a1fe18720d4aa34daf53767 100644 (file)
@@ -11,15 +11,15 @@ package org.opendaylight.yangtools.yang.parser.spi.meta;
  * Special namespace which allows import of namespaces from other sources.
  *
  * <p>
- * This namespace and its subclasses are used by model processor to
- * link / import namespaces to context node from supplied {@link StmtContext}.
+ * This namespace and its subclasses are used by model processor to link / import namespaces to context node from
+ * supplied {@link StmtContext}.
  *
  * <p>
- * This abstraction allows for imports and includes be implement as derived
- * namespaces of this, but is not tied only for import and include statements.
+ * This abstraction allows for imports and includes be implement as derived namespaces of this, but is not tied only for
+ * import and include statements.
  *
  * @param <K> Imported context identifier
  */
-public interface ImportedNamespaceContext<K> extends ParserNamespace<K, StmtContext<?, ?, ?>> {
+public abstract class ImportedNamespaceContext<K> extends ParserNamespace<K, StmtContext<?, ?, ?>> {
 
 }
index 7b15a301b7dea79a73595039e754cfe166da2a98..ed4089c73ae7149517d37d740b75ff0c2b599b79 100644 (file)
@@ -7,7 +7,9 @@
  */
 package org.opendaylight.yangtools.yang.parser.spi.meta;
 
-import com.google.common.annotations.Beta;
+import com.google.common.base.MoreObjects;
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
 
 /**
  * {@link ParserNamespace} serves as common superclass for namespaces used during parser operation. Each such namespace,
@@ -18,7 +20,20 @@ import com.google.common.annotations.Beta;
  * @param <K> Identifier type
  * @param <V> Value type
  */
-@Beta
-public interface ParserNamespace<K, V> {
+@NonNullByDefault
+public abstract class ParserNamespace<K, V> {
+    @Override
+    public final int hashCode() {
+        return super.hashCode();
+    }
 
+    @Override
+    public final boolean equals(final @Nullable Object obj) {
+        return super.equals(obj);
+    }
+
+    @Override
+    public final String toString() {
+        return MoreObjects.toStringHelper(this).toString();
+    }
 }
index fee21c432e9298e5a00dac15714789f18fd00c8b..2d0e44a31aabe3d98f56ca33fc8c7bfd6a0dd7b2 100644 (file)
@@ -34,8 +34,11 @@ import org.opendaylight.yangtools.yang.model.api.meta.StatementDefinition;
 // At the end of the day this feels like an under-utilized namespace: provided the contents of ExtensionNamespace and
 // StatementSupportBundles, SourceSpecificSpecificContext should be able to work its magic even without this namespace.
 @Beta
-public interface StatementDefinitionNamespace extends ParserNamespace<QName, StatementSupport<?, ?, ?>> {
-    NamespaceBehaviour<QName, StatementSupport<?, ?, ?>, @NonNull StatementDefinitionNamespace> BEHAVIOUR =
-            NamespaceBehaviour.global(StatementDefinitionNamespace.class);
+public final class StatementDefinitionNamespace extends ParserNamespace<QName, StatementSupport<?, ?, ?>> {
+    public static final @NonNull NamespaceBehaviour<?, ?, ?> BEHAVIOUR =
+        NamespaceBehaviour.global(StatementDefinitionNamespace.class);
 
+    private StatementDefinitionNamespace() {
+        // Hidden on purpose
+    }
 }
index 5c0ad935f916a2fa38ea7ef50b93129ce2744d33..28b4fa51ec7e8cd4dbb0fcaaa74614d86cb2fbf8 100644 (file)
@@ -10,10 +10,9 @@ package org.opendaylight.yangtools.yang.parser.spi.meta;
 import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
 
-public interface StatementNamespace<K, D extends DeclaredStatement<?>, E extends EffectiveStatement<?, D>>
+public abstract class StatementNamespace<K, D extends DeclaredStatement<?>, E extends EffectiveStatement<?, D>>
         extends ParserNamespace<K, StmtContext<?, D, E>> {
-
-    interface TreeScoped<K, D extends DeclaredStatement<?>, E extends EffectiveStatement<?, D>>
+    public abstract static class TreeScoped<K, D extends DeclaredStatement<?>, E extends EffectiveStatement<?, D>>
             extends StatementNamespace<K, D, E> {
 
     }
index 33bb8b64545de1727629d77a1ea988f931f2fd1d..246447fa4ed1f0b0a20b29b486d5f66e4002a054 100644 (file)
@@ -116,7 +116,7 @@ public final class StatementSupportBundle implements Immutable, NamespaceBehavio
         return null;
     }
 
-    public <K, V, N extends ParserNamespace<K, V>> boolean hasNamespaceBehaviour(final Class<N> namespace) {
+    public boolean hasNamespaceBehaviour(final Class<? extends ParserNamespace<?, ?>> namespace) {
         if (namespaceDefinitions.containsKey(namespace)) {
             return true;
         }
@@ -185,9 +185,8 @@ public final class StatementSupportBundle implements Immutable, NamespaceBehavio
             return this;
         }
 
-        public <K, V, N extends ParserNamespace<K, V>> @NonNull Builder addSupport(
-                final NamespaceBehaviour<K, V, N> namespaceSupport) {
-            final Class<N> identifier = namespaceSupport.getIdentifier();
+        public @NonNull Builder addSupport(final NamespaceBehaviour<?, ? ,?> namespaceSupport) {
+            final var identifier = namespaceSupport.getIdentifier();
             checkState(!namespaces.containsKey(identifier));
             checkState(!parent.hasNamespaceBehaviour(identifier));
             namespaces.put(identifier, namespaceSupport);
index 266a6480bbd94ae710bb34cafec7582c0a1bcee8..685c9a6ff5dec3935984ef9deaa4be4cbe685f85 100644 (file)
@@ -17,6 +17,8 @@ import org.opendaylight.yangtools.yang.common.QName;
  * as {@link StatementDefinitionNamespace} and {@link StmtContext#yangVersion()} of the source root statement.
  */
 @Beta
-public interface StatementSupportNamespace extends ParserNamespace<QName, StatementSupport<?, ?, ?>> {
-
+public final class StatementSupportNamespace extends ParserNamespace<QName, StatementSupport<?, ?, ?>> {
+    StatementSupportNamespace() {
+        // FIXME: is this really used?!
+    }
 }
index d13687e601b49693903bd0fbab2db1a3dde7976e..5e7a1698b5dafb9325e78c6bd35901511cf9c43b 100644 (file)
@@ -10,14 +10,17 @@ package org.opendaylight.yangtools.yang.parser.spi.source;
 import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ImportedNamespaceContext;
 import org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceBehaviour;
-import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
 
 /**
  * Source-specific mapping of belongsTo prefixes to module identifiers. This mapping allows source-specific context
  * to correctly populate prefixes map for actual parsing phase and eventually, resolve QName for any valid declared
  * statement.
  */
-public interface BelongsToPrefixToModuleCtx extends ImportedNamespaceContext<String> {
-    NamespaceBehaviour<String, StmtContext<?, ?, ?>, @NonNull BelongsToPrefixToModuleCtx> BEHAVIOUR =
-            NamespaceBehaviour.sourceLocal(BelongsToPrefixToModuleCtx.class);
+public final class BelongsToPrefixToModuleCtx extends ImportedNamespaceContext<String> {
+    public static final @NonNull NamespaceBehaviour<?, ?, ?> BEHAVIOUR =
+        NamespaceBehaviour.sourceLocal(BelongsToPrefixToModuleCtx.class);
+
+    private BelongsToPrefixToModuleCtx() {
+        // Hidden on purpose
+    }
 }
index d7746bdb4a990fa2f5a9c602d224c330e0234fa9..c576f3d3ae332e5777a0a970427d3d9d20bf4878 100644 (file)
@@ -15,7 +15,11 @@ import org.opendaylight.yangtools.yang.parser.spi.meta.ParserNamespace;
 /**
  * Source-specific mapping of prefixes to namespaces.
  */
-public interface BelongsToPrefixToModuleName extends ParserNamespace<String, Unqualified> {
-    NamespaceBehaviour<String, Unqualified, @NonNull BelongsToPrefixToModuleName> BEHAVIOUR =
-            NamespaceBehaviour.sourceLocal(BelongsToPrefixToModuleName.class);
+public final class BelongsToPrefixToModuleName extends ParserNamespace<String, Unqualified> {
+    public static final @NonNull NamespaceBehaviour<?, ?, ?> BEHAVIOUR =
+        NamespaceBehaviour.sourceLocal(BelongsToPrefixToModuleName.class);
+
+    private BelongsToPrefixToModuleName() {
+        // Hidden on purpose
+    }
 }
index 9c811ccd790a6fcda510b54ad71d6f4e94ced521..6d506a70d10d861ca05a6fbeb1c004ddea61a750 100644 (file)
@@ -15,7 +15,11 @@ import org.opendaylight.yangtools.yang.parser.spi.meta.ParserNamespace;
 /**
  * Pre-linkage source-specific mapping of prefixes to module namespaces.
  */
-public interface ImpPrefixToNamespace extends ParserNamespace<String, XMLNamespace> {
-    NamespaceBehaviour<String, XMLNamespace, @NonNull ImpPrefixToNamespace> BEHAVIOUR =
-            NamespaceBehaviour.rootStatementLocal(ImpPrefixToNamespace.class);
+public final class ImpPrefixToNamespace extends ParserNamespace<String, XMLNamespace> {
+    public static final @NonNull NamespaceBehaviour<?, ?, ?> BEHAVIOUR =
+        NamespaceBehaviour.rootStatementLocal(ImpPrefixToNamespace.class);
+
+    private ImpPrefixToNamespace() {
+        // Hidden on purpose
+    }
 }
index 9ab50474d3c0191528998c74cbc4cb8ec3bf2322..68d9d1941d33f9a9096805bcab6bfafa1f96f670 100644 (file)
@@ -15,7 +15,11 @@ import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
 /**
  * Source-specific mapping of prefix strings to module context.
  */
-public interface ImportPrefixToModuleCtx extends ParserNamespace<String, StmtContext<?, ?, ?>> {
-    NamespaceBehaviour<String, StmtContext<?, ?, ?>, @NonNull ImportPrefixToModuleCtx> BEHAVIOUR =
-            NamespaceBehaviour.rootStatementLocal(ImportPrefixToModuleCtx.class);
+public final class ImportPrefixToModuleCtx extends ParserNamespace<String, StmtContext<?, ?, ?>> {
+    public static final @NonNull NamespaceBehaviour<?, ?, ?> BEHAVIOUR =
+        NamespaceBehaviour.rootStatementLocal(ImportPrefixToModuleCtx.class);
+
+    private ImportPrefixToModuleCtx() {
+        // Hidden on purpose
+    }
 }
index 3cabb5e719e9ff19abeea140965a331a189d134b..42add724163c44add1f5a29c860fd1bc7b5eaea8 100644 (file)
@@ -11,9 +11,12 @@ import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ImportedNamespaceContext;
 import org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceBehaviour;
-import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
 
-public interface ImportedModuleContext extends ImportedNamespaceContext<SourceIdentifier> {
-    NamespaceBehaviour<SourceIdentifier, StmtContext<?, ?, ?>, @NonNull ImportedModuleContext> BEHAVIOUR =
-            NamespaceBehaviour.sourceLocal(ImportedModuleContext.class);
+public final class ImportedModuleContext extends ImportedNamespaceContext<SourceIdentifier> {
+    public static final @NonNull NamespaceBehaviour<?, ?, ?> BEHAVIOUR =
+        NamespaceBehaviour.sourceLocal(ImportedModuleContext.class);
+
+    private ImportedModuleContext() {
+        // Hidden on purpose
+    }
 }
index 8500decf9b56564da0d2640ad3fc491968769a01..b3986af0639230763ab32e1fa50003e1a2144b0d 100644 (file)
@@ -11,9 +11,12 @@ import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ImportedNamespaceContext;
 import org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceBehaviour;
-import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
 
-public interface IncludedModuleContext extends ImportedNamespaceContext<SourceIdentifier> {
-    NamespaceBehaviour<SourceIdentifier, StmtContext<?, ?, ?>, @NonNull IncludedModuleContext> BEHAVIOUR =
-            NamespaceBehaviour.sourceLocal(IncludedModuleContext.class);
+public final class IncludedModuleContext extends ImportedNamespaceContext<SourceIdentifier> {
+    public static final @NonNull NamespaceBehaviour<?, ?, ?> BEHAVIOUR =
+        NamespaceBehaviour.sourceLocal(IncludedModuleContext.class);
+
+    private IncludedModuleContext() {
+        // Hidden on purpose
+    }
 }
index 91b256dc9ddd87046891c575414e3f06c4dddf7c..621d9953f68bfd7361d1316c15eeb3be8c8d7522 100644 (file)
@@ -16,7 +16,11 @@ import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
 /**
  * Source-specific mapping of prefixes to namespaces.
  */
-public interface IncludedSubmoduleNameToModuleCtx extends ParserNamespace<Unqualified, StmtContext<?, ?, ?>> {
-    NamespaceBehaviour<Unqualified, StmtContext<?, ?, ?>, @NonNull IncludedSubmoduleNameToModuleCtx> BEHAVIOUR =
-            NamespaceBehaviour.sourceLocal(IncludedSubmoduleNameToModuleCtx.class);
+public final class IncludedSubmoduleNameToModuleCtx extends ParserNamespace<Unqualified, StmtContext<?, ?, ?>> {
+    public static final @NonNull NamespaceBehaviour<?, ?, ?> BEHAVIOUR =
+        NamespaceBehaviour.sourceLocal(IncludedSubmoduleNameToModuleCtx.class);
+
+    private IncludedSubmoduleNameToModuleCtx() {
+        // Hidden on purpose
+    }
 }
index bf5c4448d2dc3ed79531fa552c951b03ddbd753c..c6404ac387db9147d7350930c1ce115dc7b4e3a3 100644 (file)
@@ -16,8 +16,11 @@ import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
 /**
  * Global mapping of modules to QNameModules.
  */
-public interface ModuleCtxToModuleQName extends ParserNamespace<StmtContext<?,?,?>, QNameModule> {
-    NamespaceBehaviour<StmtContext<?, ?, ?>, QNameModule, @NonNull ModuleCtxToModuleQName> BEHAVIOUR =
-            NamespaceBehaviour.global(ModuleCtxToModuleQName.class);
+public final class ModuleCtxToModuleQName extends ParserNamespace<StmtContext<?,?,?>, QNameModule> {
+    public static final @NonNull NamespaceBehaviour<?, ?, ?> BEHAVIOUR =
+        NamespaceBehaviour.global(ModuleCtxToModuleQName.class);
 
+    private ModuleCtxToModuleQName() {
+        // Hidden on purpose
+    }
 }
index 36fa78cfc5606e4df34b548eda824cb91d98f1e9..52cf3bf3539f6b74b7a306dcb6de3ce318cbaf81 100644 (file)
@@ -16,7 +16,11 @@ import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
 /**
  * Global mapping of modules to source identifier.
  */
-public interface ModuleCtxToSourceIdentifier extends ParserNamespace<StmtContext<?, ?, ?>, SourceIdentifier> {
-    NamespaceBehaviour<StmtContext<?, ?, ?>, SourceIdentifier, @NonNull ModuleCtxToSourceIdentifier> BEHAVIOUR =
-            NamespaceBehaviour.global(ModuleCtxToSourceIdentifier.class);
+public final class ModuleCtxToSourceIdentifier extends ParserNamespace<StmtContext<?, ?, ?>, SourceIdentifier> {
+    public static final @NonNull NamespaceBehaviour<?, ?, ?> BEHAVIOUR =
+        NamespaceBehaviour.global(ModuleCtxToSourceIdentifier.class);
+
+    private ModuleCtxToSourceIdentifier() {
+        // Hidden on purpose
+    }
 }
index 7da584425bb7da4623c5904c4ec963e4e9408658..d66d513cd801a6b22e3af27e747bb313758d05ea 100644 (file)
@@ -16,7 +16,11 @@ import org.opendaylight.yangtools.yang.parser.spi.meta.ParserNamespace;
 /**
  * Source-specific mapping of prefixes to namespaces.
  */
-public interface ModuleNameToModuleQName extends ParserNamespace<Unqualified, QNameModule> {
-    NamespaceBehaviour<Unqualified, QNameModule, @NonNull ModuleNameToModuleQName> BEHAVIOUR =
-            NamespaceBehaviour.sourceLocal(ModuleNameToModuleQName.class);
+public final class ModuleNameToModuleQName extends ParserNamespace<Unqualified, QNameModule> {
+    public static final @NonNull NamespaceBehaviour<?, ?, ?> BEHAVIOUR =
+        NamespaceBehaviour.sourceLocal(ModuleNameToModuleQName.class);
+
+    private ModuleNameToModuleQName() {
+        // Hidden on purpose
+    }
 }
index 8da9a9f7f32d0750be417b5c3e77919ee7dae8f0..1347b91c9502d3cbe1dbd121446ffd7530c38950 100644 (file)
@@ -16,7 +16,11 @@ import org.opendaylight.yangtools.yang.parser.spi.meta.ParserNamespace;
 /**
  * Pre-linkage global mapping of module names to namespaces.
  */
-public interface ModuleNameToNamespace extends ParserNamespace<Unqualified, XMLNamespace> {
-    NamespaceBehaviour<Unqualified, XMLNamespace, @NonNull ModuleNameToNamespace> BEHAVIOUR =
-            NamespaceBehaviour.global(ModuleNameToNamespace.class);
+public final class ModuleNameToNamespace extends ParserNamespace<Unqualified, XMLNamespace> {
+    public static final @NonNull NamespaceBehaviour<?, ?, ?> BEHAVIOUR =
+        NamespaceBehaviour.global(ModuleNameToNamespace.class);
+
+    private ModuleNameToNamespace() {
+        // Hidden on purpose
+    }
 }
index eb9a346e8ce5d4ced518497b064ce26b3fa9a4c5..78a82237bcbd4c33890dacaa5c6f8991c4c87a3f 100644 (file)
@@ -13,14 +13,17 @@ import org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.ModuleStatement;
 import org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceBehaviour;
 import org.opendaylight.yangtools.yang.parser.spi.meta.StatementNamespace;
-import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
 
 /**
- * namespace class similar to {@link org.opendaylight.yangtools.yang.parser.spi.ModuleNamespace} for storing modules
+ * Namespace class similar to {@link org.opendaylight.yangtools.yang.parser.spi.ModuleNamespace} for storing modules
  * into Yang model storage but keyed by plain name.
  */
-public interface ModuleNamespaceForBelongsTo
+public final class ModuleNamespaceForBelongsTo
         extends StatementNamespace<Unqualified, ModuleStatement, ModuleEffectiveStatement> {
-    NamespaceBehaviour<Unqualified, StmtContext<?, ModuleStatement, ModuleEffectiveStatement>,
-        @NonNull ModuleNamespaceForBelongsTo> BEHAVIOUR = NamespaceBehaviour.global(ModuleNamespaceForBelongsTo.class);
+    public static final @NonNull NamespaceBehaviour<?, ?, ?> BEHAVIOUR =
+        NamespaceBehaviour.global(ModuleNamespaceForBelongsTo.class);
+
+    private ModuleNamespaceForBelongsTo() {
+        // Hidden on purpose
+    }
 }
index e02716ddf42dad1679de7370852ce09e46044308..5abe546faaa3315f212df2a15d8cd30bd8dcd8e3 100644 (file)
@@ -16,7 +16,11 @@ import org.opendaylight.yangtools.yang.parser.spi.meta.ParserNamespace;
 /**
  * Source-specific mapping of prefixes to namespaces.
  */
-public interface ModuleQNameToModuleName extends ParserNamespace<QNameModule, Unqualified> {
-    NamespaceBehaviour<QNameModule, Unqualified, @NonNull ModuleQNameToModuleName> BEHAVIOUR =
-            NamespaceBehaviour.global(ModuleQNameToModuleName.class);
+public final class ModuleQNameToModuleName extends ParserNamespace<QNameModule, Unqualified> {
+    public static final @NonNull NamespaceBehaviour<?, ?, ?> BEHAVIOUR =
+        NamespaceBehaviour.global(ModuleQNameToModuleName.class);
+
+    private ModuleQNameToModuleName() {
+        // Hidden on purpose
+    }
 }
index bbbc4d462c19ad538e0b9bd1d4e6e3193f61849c..cb1144667820743bd896fa03dc257a7fa1fab8e1 100644 (file)
@@ -20,7 +20,11 @@ import org.opendaylight.yangtools.yang.parser.spi.meta.ParserNamespace;
  * Map key (QNameModule) denotes a module which can be deviated by the modules specified in the Map value.
  */
 @Beta
-public interface ModulesDeviatedByModules extends ParserNamespace<Empty, SetMultimap<QNameModule, QNameModule>> {
-    NamespaceBehaviour<Empty, SetMultimap<QNameModule, QNameModule>, @NonNull ModulesDeviatedByModules>
-        BEHAVIOUR = NamespaceBehaviour.global(ModulesDeviatedByModules.class);
+public final class ModulesDeviatedByModules extends ParserNamespace<Empty, SetMultimap<QNameModule, QNameModule>> {
+    public static final @NonNull NamespaceBehaviour<?, ?, ?> BEHAVIOUR =
+        NamespaceBehaviour.global(ModulesDeviatedByModules.class);
+
+    private ModulesDeviatedByModules() {
+        // Hidden on purpose
+    }
 }
index 965bfc16cd330b6d2a1fd014da72329a13db8fc4..ba97db26fe5fc5182238f8e37431faef5b4a8a02 100644 (file)
@@ -19,7 +19,11 @@ import org.opendaylight.yangtools.yang.parser.spi.meta.ParserNamespace;
  *
  * @see PrefixResolver
  */
-public interface PrefixToModule extends ParserNamespace<String, QNameModule> {
-    NamespaceBehaviour<String, QNameModule, @NonNull PrefixToModule> BEHAVIOUR =
-            NamespaceBehaviour.global(PrefixToModule.class);
+public final class PrefixToModule extends ParserNamespace<String, QNameModule> {
+    public static final @NonNull NamespaceBehaviour<?, ?, ?> BEHAVIOUR =
+        NamespaceBehaviour.global(PrefixToModule.class);
+
+    private PrefixToModule() {
+        // Hidden on purpose
+    }
 }
index c524c706c4d306dd6321ac6dca7c88abc5ba9a53..6b7c87f96a9c42479da0153c2d3b57d900ecd68f 100644 (file)
@@ -14,7 +14,11 @@ import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceBehaviour;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ParserNamespace;
 
-public interface SupportedFeaturesNamespace extends ParserNamespace<Empty, Set<QName>> {
-    NamespaceBehaviour<Empty, Set<QName>, @NonNull SupportedFeaturesNamespace> BEHAVIOUR =
-            NamespaceBehaviour.global(SupportedFeaturesNamespace.class);
+public final class SupportedFeaturesNamespace extends ParserNamespace<Empty, Set<QName>> {
+    public static final @NonNull NamespaceBehaviour<?, ?, ?> BEHAVIOUR =
+        NamespaceBehaviour.global(SupportedFeaturesNamespace.class);
+
+    private SupportedFeaturesNamespace() {
+        // Hidden on purpose
+    }
 }
index 18069b3b1faf1842d878f23284f74aec04771981..d58d2ac6bd29455737f58c778513330c7b06a116 100644 (file)
@@ -17,12 +17,16 @@ import org.opendaylight.yangtools.yang.parser.spi.meta.ParserNamespace;
  * Namespace used for validating whether a node is of some type, e.g. usable target for some operation or has other
  * significant properties.
  */
-public interface ValidationBundlesNamespace
+public final class ValidationBundlesNamespace
         extends ParserNamespace<ValidationBundlesNamespace.ValidationBundleType, Collection<?>> {
-    NamespaceBehaviour<ValidationBundleType, Collection<?>, @NonNull ValidationBundlesNamespace> BEHAVIOUR =
-            NamespaceBehaviour.global(ValidationBundlesNamespace.class);
+    public static final @NonNull NamespaceBehaviour<?, ?, ?> BEHAVIOUR =
+        NamespaceBehaviour.global(ValidationBundlesNamespace.class);
 
-    enum ValidationBundleType {
+    private ValidationBundlesNamespace() {
+        // Hidden on purpose
+    }
+
+    public enum ValidationBundleType {
         /**
          * Whether a node is suitable refine substatement.
          */
diff --git a/parser/yang-parser-spi/src/test/java/org/opendaylight/yangtools/yang/parser/spi/validation/ValidationBundlesNamespaceTest.java b/parser/yang-parser-spi/src/test/java/org/opendaylight/yangtools/yang/parser/spi/validation/ValidationBundlesNamespaceTest.java
deleted file mode 100644 (file)
index 45a9e24..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (c) 2017 Pantheon Technologies s.r.o. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.yangtools.yang.parser.spi.validation;
-
-import static org.junit.Assert.assertSame;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
-import static org.opendaylight.yangtools.yang.parser.spi.validation.ValidationBundlesNamespace.BEHAVIOUR;
-import static org.opendaylight.yangtools.yang.parser.spi.validation.ValidationBundlesNamespace.ValidationBundleType.SUPPORTED_DATA_NODES;
-
-import java.util.Collection;
-import org.junit.Test;
-import org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceBehaviour.NamespaceStorageNode;
-import org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceBehaviour.StorageNodeType;
-
-public class ValidationBundlesNamespaceTest {
-    @Test
-    public void testBehaviour() {
-        final NamespaceStorageNode node = mock(NamespaceStorageNode.class);
-        doReturn(StorageNodeType.GLOBAL).when(node).getStorageNodeType();
-
-        final Collection<?> result = mock(Collection.class);
-        doReturn(result).when(node).getFromLocalStorage(ValidationBundlesNamespace.class, SUPPORTED_DATA_NODES);
-        assertSame(result, BEHAVIOUR.getFrom(node, SUPPORTED_DATA_NODES));
-    }
-}