25392c7d48f9b944e908dfe8175a729ba6060ef3
[yangtools.git] / yang / rfc8528-model-api / src / main / java / org / opendaylight / yangtools / rfc8528 / model / api / YangLibraryConstants.java
1 /*
2  * Copyright (c) 2019 PANTHEON.tech 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.rfc8528.model.api;
9
10 import static java.util.Objects.requireNonNull;
11
12 import com.google.common.annotations.Beta;
13 import java.net.URI;
14 import org.eclipse.jdt.annotation.NonNullByDefault;
15
16 /**
17  * Constants related to {@code ietf-yang-library.yang}. As schema-mount works in concert with yang-library, we need
18  * these constants to interpret correctly categorize incoming data and present them to schema resolution process.
19  *
20  * <p>
21  * While RFC7895 and RFC8525 are not strictly required by YANG, RFC7950 contains a weak reference to it when dealing
22  * with capability negotiation on protocol layers. Moreover RFC8528 makes it explicit that an instance of yang-library
23  * is mounted underneath both {@code inline} and {@code shared-schema} types of mount.
24  *
25  * <p>
26  * While we could mandate use of either RFC7895 or RFC8525 across the board, this is not feasible, as mount points may
27  * be nested and point to external systems -- hence it is completely possible to encounter both old and new information
28  * in a single mount point tree.
29  */
30 @Beta
31 @NonNullByDefault
32 public final class YangLibraryConstants {
33     /**
34      * The namespace assigned to {@code ietf-yang-library}. This constant is required for XML-like parsers, using
35      * XML namespaces to reference modules.
36      */
37     public static final URI MODULE_NAMESPACE = URI.create("urn:ietf:params:xml:ns:yang:ietf-yang-library");
38     /**
39      * The module name assigned to {@code ietf-yang-library}. This constant is required for JSON-like parsers, using
40      * module names to reference modules.
41      */
42     public static final String MODULE_NAME = "ietf-yang-library";
43
44     /**
45      * Top-level containers which hold YANG Library information.
46      */
47     public enum ContainerName {
48         /**
49          * Container in RFC7895 (pre-NMDA) YANG Library.
50          */
51         RFC7895("modules-state"),
52         /**
53          * Container in RFC8525 (NMDA) YANG Library.
54          */
55         RFC8525("yang-library");
56
57         private final String localName;
58
59         ContainerName(final String localName) {
60             this.localName = requireNonNull(localName);
61         }
62
63         public String getLocalName() {
64             return localName;
65         }
66     }
67
68     private YangLibraryConstants() {
69         // Hidden
70     }
71 }