Eliminate YangLibraryConstants 99/105999/9
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 16 May 2023 17:28:55 +0000 (19:28 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Tue, 16 May 2023 21:42:21 +0000 (23:42 +0200)
RFC7950 implies integration with at least RFC7895, hence
ietf-yang-library constants are a fair game in YangConstants. Expand the
number of constants we keep and adjust users.

JIRA: YANGTOOLS-1172
Change-Id: Id32a8621b4bac8725239e3cb4d3046e3ddb06565
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
codec/yang-data-codec-xml/src/main/java/org/opendaylight/yangtools/yang/data/codec/xml/XmlParserStream.java
common/yang-common/src/main/java/org/opendaylight/yangtools/yang/common/YangConstants.java
data/rfc8528-data-api/src/main/java/org/opendaylight/yangtools/rfc8528/data/api/YangLibraryConstants.java [deleted file]

index 6610da5c0df0326e130ef21a8599e8827dc1c426..b462d3939615e4e96658f0861dd12ab7a5ac7e5b 100644 (file)
@@ -42,12 +42,12 @@ import javax.xml.transform.dom.DOMResult;
 import javax.xml.transform.dom.DOMSource;
 import javax.xml.transform.stax.StAXSource;
 import org.opendaylight.yangtools.rfc7952.model.api.AnnotationSchemaNode;
-import org.opendaylight.yangtools.rfc8528.data.api.YangLibraryConstants;
 import org.opendaylight.yangtools.rfc8528.model.api.MountPointSchemaNode;
 import org.opendaylight.yangtools.rfc8528.model.api.SchemaMountConstants;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.QNameModule;
 import org.opendaylight.yangtools.yang.common.XMLNamespace;
+import org.opendaylight.yangtools.yang.common.YangConstants;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.MountPointContext;
 import org.opendaylight.yangtools.yang.data.api.schema.MountPointContextFactory.ContainerName;
@@ -629,7 +629,7 @@ public final class XmlParserStream implements Closeable, Flushable {
     private static void addMountPointChild(final MountPointData mount, final XMLNamespace namespace,
             final String localName, final DOMSource source) {
         final DOMSourceMountPointChild child = new DOMSourceMountPointChild(source);
-        if (YangLibraryConstants.MODULE_NAMESPACE.equals(namespace)) {
+        if (YangConstants.YANG_LIBRARY_NAMESPACE.equals(namespace)) {
             final var optName = ContainerName.forLocalName(localName);
             if (optName != null) {
                 mount.setContainer(optName, child);
index f7660b26fdfebe91adc92574beb99f48e2479b22..fc18c5e0d03567a93987d44a80aae4cabfc1c00f 100644 (file)
@@ -115,6 +115,33 @@ public final class YangConstants {
      * <a href="https://datatracker.ietf.org/doc/html/rfc6020#section-13.1">RFC6020, section 13.1</a>.
      */
     public static final QName NON_UNIQUE_QNAME = QName.create(RFC6020_YANG_MODULE, "non-unique").intern();
+    /**
+     * The module name assigned to {@code ietf-yang-library}. This constant is required for JSON-like parsers, using
+     * module names to reference modules.
+     */
+    public static final String YANG_LIBRARY_MODULE_NAME = "ietf-yang-library";
+    /**
+     * The namespace assigned to {@code ietf-yang-library}. This constant is required for XML-like parsers, using
+     * XML namespaces to reference modules.
+     */
+    public static final String YANG_LIBRARY_NAMESPACE_STRING = "urn:ietf:params:xml:ns:yang:ietf-yang-library";
+    /**
+     * The namespace assigned to {@code ietf-yang-library}. This constant is useful for referencing things in a
+     * type-safe manner.
+     */
+    public static final XMLNamespace YANG_LIBRARY_NAMESPACE = XMLNamespace.of(YANG_LIBRARY_NAMESPACE_STRING).intern();
+    /**
+     * {@code ietf-yang-library} namespace bound to YANG through
+     * <a href="https://www.rfc-editor.org/rfc/rfc7895#section-2.2">ietf-yang-library@2016-06-21.yang</a>.
+     */
+    public static final QNameModule RFC7895_YANG_MODULE =
+        QNameModule.create(YANG_LIBRARY_NAMESPACE, Revision.of("2016-06-21")).intern();
+    /**
+     * {@code ietf-yang-library} namespace bound to YANG through
+     * <a href="https://datatracker.ietf.org/doc/html/rfc8525#section-4">ietf-yang-library@2019-01-04.yang</a>.
+     */
+    public static final QNameModule RFC8525_YANG_MODULE =
+        QNameModule.create(YANG_LIBRARY_NAMESPACE, Revision.of("2019-01-04")).intern();
 
     // Dummy template UnqualifiedQName. These are never leaked, but are used for efficient instantiation via
     // UnqualifiedQName#bindTo()
diff --git a/data/rfc8528-data-api/src/main/java/org/opendaylight/yangtools/rfc8528/data/api/YangLibraryConstants.java b/data/rfc8528-data-api/src/main/java/org/opendaylight/yangtools/rfc8528/data/api/YangLibraryConstants.java
deleted file mode 100644 (file)
index 9448abb..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 2019 PANTHEON.tech 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.rfc8528.data.api;
-
-import com.google.common.annotations.Beta;
-import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.opendaylight.yangtools.yang.common.XMLNamespace;
-
-/**
- * Constants related to {@code ietf-yang-library.yang}. As schema-mount works in concert with yang-library, we need
- * these constants to interpret correctly categorize incoming data and present them to schema resolution process.
- *
- * <p>
- * While RFC7895 and RFC8525 are not strictly required by YANG, RFC7950 contains a weak reference to it when dealing
- * with capability negotiation on protocol layers. Moreover RFC8528 makes it explicit that an instance of yang-library
- * is mounted underneath both {@code inline} and {@code shared-schema} types of mount.
- *
- * <p>
- * While we could mandate use of either RFC7895 or RFC8525 across the board, this is not feasible, as mount points may
- * be nested and point to external systems -- hence it is completely possible to encounter both old and new information
- * in a single mount point tree.
- */
-@Beta
-@NonNullByDefault
-public final class YangLibraryConstants {
-    /**
-     * The namespace assigned to {@code ietf-yang-library}. This constant is required for XML-like parsers, using
-     * XML namespaces to reference modules.
-     */
-    public static final XMLNamespace MODULE_NAMESPACE =
-        XMLNamespace.of("urn:ietf:params:xml:ns:yang:ietf-yang-library");
-    /**
-     * The module name assigned to {@code ietf-yang-library}. This constant is required for JSON-like parsers, using
-     * module names to reference modules.
-     */
-    public static final String MODULE_NAME = "ietf-yang-library";
-
-    private YangLibraryConstants() {
-        // Hidden
-    }
-}