From: Robert Varga Date: Mon, 19 Apr 2021 08:12:07 +0000 (+0200) Subject: Refactor IdentifierNamespace X-Git-Tag: v7.0.0~54 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=fec95fb7669d2fd38bc4de5e89b4eebfc23c04ec;p=yangtools.git Refactor IdentifierNamespace IdentifierNamespace.get() is not used anywhere, hence remove this method. Furthermore this class is only used for specifying a key, hence make sure it is an abstract class without the possibility of instantiating. JIRA: YANGTOOLS-1205 Change-Id: I56f22af2d4bb21caab5dd47da6dfa1b1753777cd Signed-off-by: Robert Varga --- diff --git a/yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/meta/IdentifierNamespace.java b/yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/meta/IdentifierNamespace.java index d6d0f78f86..91da55e65a 100644 --- a/yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/meta/IdentifierNamespace.java +++ b/yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/meta/IdentifierNamespace.java @@ -7,26 +7,17 @@ */ package org.opendaylight.yangtools.yang.model.api.meta; -import org.eclipse.jdt.annotation.NonNull; -import org.eclipse.jdt.annotation.Nullable; +import org.eclipse.jdt.annotation.NonNullByDefault; /** - * Model specific namespace which allows access to specific - * - * {@link IdentifierNamespace} serves as common superclass for YANG model namespaces, which are type-captured - * subclasses. This type capture of namespace allows for handy type-safe reading methods such as - * {@link EffectiveStatement#get(Class, Object)} and still allows introduction of new namespaces without need to change - * model APIs. + * Common base class for various YANG statement namespaces. * * @param Identifier type * @param Value type */ -public interface IdentifierNamespace { - /** - * Returns value associated with supplied identifier. - * - * @param identifier Identifier of value - * @return value or null, if identifier is not present in namespace. - */ - @Nullable V get(@NonNull K identifier); +@NonNullByDefault +public abstract class IdentifierNamespace { + protected IdentifierNamespace() { + throw new UnsupportedOperationException(getClass() + " should never be instantiated"); + } } diff --git a/yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/stmt/EffectiveStatementNamespace.java b/yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/stmt/EffectiveStatementNamespace.java index 188034b144..9d8a67447f 100644 --- a/yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/stmt/EffectiveStatementNamespace.java +++ b/yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/stmt/EffectiveStatementNamespace.java @@ -21,9 +21,8 @@ import org.opendaylight.yangtools.yang.model.api.meta.IdentifierNamespace; */ @Beta public abstract class EffectiveStatementNamespace> - implements IdentifierNamespace { - + extends IdentifierNamespace { protected EffectiveStatementNamespace() { - // Subclasses should guard against instantiation + // Hidden on purpose } } diff --git a/yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/stmt/ModuleEffectiveStatement.java b/yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/stmt/ModuleEffectiveStatement.java index e6028a7ca4..7df36936d9 100644 --- a/yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/stmt/ModuleEffectiveStatement.java +++ b/yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/stmt/ModuleEffectiveStatement.java @@ -27,7 +27,7 @@ public interface ModuleEffectiveStatement * in which it is instantiated. */ abstract class PrefixToEffectiveModuleNamespace - implements IdentifierNamespace { + extends IdentifierNamespace { private PrefixToEffectiveModuleNamespace() { // This class should never be subclassed } @@ -37,7 +37,7 @@ public interface ModuleEffectiveStatement * Namespace mapping all known {@link QNameModule}s to their encoding prefixes. This includes the declaration * from prefix/namespace/revision and all imports as they were resolved. */ - abstract class QNameModuleToPrefixNamespace implements IdentifierNamespace { + abstract class QNameModuleToPrefixNamespace extends IdentifierNamespace { private QNameModuleToPrefixNamespace() { // This class should never be subclassed } @@ -47,7 +47,7 @@ public interface ModuleEffectiveStatement * Namespace mapping all included submodules. The namespaces is keyed by submodule name. */ abstract class NameToEffectiveSubmoduleNamespace - implements IdentifierNamespace { + extends IdentifierNamespace { private NameToEffectiveSubmoduleNamespace() { // This class should never be subclassed }