Use RevisionUnion in QNameModule
[yangtools.git] / common / yang-common / src / main / java / org / opendaylight / yangtools / yang / common / YangConstants.java
1 /*
2  * Copyright (c) 2015 Cisco Systems, Inc. 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.common;
9
10 import org.eclipse.jdt.annotation.NonNullByDefault;
11 import org.opendaylight.yangtools.yang.common.UnresolvedQName.Unqualified;
12
13 /**
14  * Constant definitions present in RFC documents related to the YANG language.
15  */
16 @NonNullByDefault
17 public final class YangConstants {
18     /**
19      * YANG File Extension, as defined in <a href="https://www.rfc-editor.org/rfc/rfc6020#section-14.1">RFC6020</a>.
20      */
21     public static final String RFC6020_YANG_FILE_EXTENSION = ".yang";
22     /**
23      * YANG Media Type, as defined in <a href="https://www.rfc-editor.org/rfc/rfc6020#section-14.1">RFC6020</a>.
24      */
25     public static final String RFC6020_YANG_MAC_FILE_TYPE = "TEXT";
26     /**
27      * YANG Media Type, as defined in h<a href="https://www.rfc-editor.org/rfc/rfc6020#section-14.1">RFC6020</a>.
28      */
29     public static final String RFC6020_YANG_MEDIA_TYPE = "application/yang";
30     /**
31      * YANG namespace, as defined in https://www.rfc-editor.org/rfc/rfc6020#section-14, in String format.
32      */
33     public static final String RFC6020_YANG_NAMESPACE_STRING = "urn:ietf:params:xml:ns:yang:1";
34     /**
35      * YANG namespace, as defined in https://www.rfc-editor.org/rfc/rfc6020#section-14, in URI format.
36      */
37     public static final XMLNamespace RFC6020_YANG_NAMESPACE = XMLNamespace.of(RFC6020_YANG_NAMESPACE_STRING).intern();
38     /**
39      * Base QNameModule for all YANG statements.
40      */
41     public static final QNameModule RFC6020_YANG_MODULE = QNameModule.of(RFC6020_YANG_NAMESPACE).intern();
42     /**
43      * YIN File Extension, as defined in <a href="https://www.rfc-editor.org/rfc/rfc6020#section-14.2">RFC6020</a>.
44      */
45     public static final String RFC6020_YIN_FILE_EXTENSION = ".yin";
46     /**
47      * YANG Media Type, as defined in <a href="https://www.rfc-editor.org/rfc/rfc6020#section-14.1">RFC6020</a>.
48      */
49     public static final String RFC6020_MAC_FILE_TYPE = "TEXT";
50     /**
51      * YANG Media Type, as defined in <a href="https://www.rfc-editor.org/rfc/rfc6020#section-14.2">RFC6020</a>.
52      */
53     public static final String RFC6020_YIN_MEDIA_TYPE = "application/yin+xml";
54     /**
55      * YIN namespace, as defined in https://www.rfc-editor.org/rfc/rfc6020#section-14, in String format.
56      */
57     public static final String RFC6020_YIN_NAMESPACE_STRING = "urn:ietf:params:xml:ns:yang:yin:1";
58     /**
59      * YIN namespace, as defined in https://www.rfc-editor.org/rfc/rfc6020#section-14, in URI format.
60      */
61     public static final XMLNamespace RFC6020_YIN_NAMESPACE = XMLNamespace.of(RFC6020_YIN_NAMESPACE_STRING).intern();
62     /**
63      * Base QNameModule for all YIN statements.
64      */
65     public static final QNameModule RFC6020_YIN_MODULE = QNameModule.of(RFC6020_YIN_NAMESPACE).intern();
66     /**
67      * Prefix for YANG-specific XPath functions.
68      */
69     public static final String YANG_XPATH_FUNCTIONS_PREFIX = "yang";
70     /**
71      * NETCONF protocol elements' namespace, as defined in
72      * <a href="https://www.rfc-editor.org/rfc/rfc4741#section-3.1">RFC4741 section 3.1</a>, in String format.
73      */
74     public static final String NETCONF_NAMESPACE_STRING = "urn:ietf:params:xml:ns:netconf:base:1.0";
75     /**
76      * NETCONF protocol elements' namespace, as defined in
77      * <a href="https://www.rfc-editor.org/rfc/rfc4741#section-3.1">RFC4741 section 3.1</a>, in String format.
78      */
79     public static final XMLNamespace NETCONF_NAMESPACE = XMLNamespace.of(NETCONF_NAMESPACE_STRING).intern();
80     /**
81      * NETCONF namespace bound to YANG through
82      * <a href="https://www.rfc-editor.org/rfc/rfc6241#section-10.3">ietf-netconf@2011-06-01.yang</a>.
83      */
84     public static final QNameModule RFC6241_YANG_MODULE =
85         QNameModule.of(NETCONF_NAMESPACE, Revision.of("2011-06-01")).intern();
86     /**
87      * {@code bad-attribute}, value is the name of the attribute.
88      */
89     public static final QName BAD_ATTRIBUTE_QNAME = QName.create(RFC6241_YANG_MODULE, "bad-attribute").intern();
90     /**
91      * {@code bad-element}, value is the name of the element.
92      */
93     public static final QName BAD_ELEMENT_QNAME = QName.create(RFC6241_YANG_MODULE, "bad-element").intern();
94     /**
95      * {@code bad-namespace}, value is the name of the namespace.
96      */
97     public static final QName BAD_NAMESPACE_QNAME = QName.create(RFC6241_YANG_MODULE, "bad-namespace").intern();
98     /**
99      * {@code session-id}, value the session identifier, as modeled in {@code SessionIdOrZero}.
100      */
101     public static final QName SESSION_ID_QNAME = QName.create(RFC6241_YANG_MODULE, "session-id").intern();
102     @Deprecated(since = "RFC6241")
103     public static final QName ERR_ELEMENT_QNAME = QName.create(RFC6241_YANG_MODULE, "err-element").intern();
104     @Deprecated(since = "RFC6241")
105     public static final QName NOOP_ELEMENT_QNAME = QName.create(RFC6241_YANG_MODULE, "noop-element").intern();
106     @Deprecated(since = "RFC6241")
107     public static final QName OK_ELEMENT_QNAME = QName.create(RFC6241_YANG_MODULE, "ok-element").intern();
108     /**
109      * {@code missing-choice} as defined in
110      * <a href="https://www.rfc-editor.org/rfc/rfc6020#section-13.7">RFC6020, section 13.7</a>.
111      */
112     public static final QName MISSING_CHOICE_QNAME = QName.create(RFC6020_YANG_MODULE, "missing-choice").intern();
113     /**
114      * {@code non-unique} as defined in
115      * <a href="https://www.rfc-editor.org/rfc/rfc6020#section-13.1">RFC6020, section 13.1</a>.
116      */
117     public static final QName NON_UNIQUE_QNAME = QName.create(RFC6020_YANG_MODULE, "non-unique").intern();
118     /**
119      * The module name assigned to {@code ietf-yang-library}. This constant is required for JSON-like parsers, using
120      * module names to reference modules.
121      */
122     public static final String YANG_LIBRARY_MODULE_NAME = "ietf-yang-library";
123     /**
124      * The namespace assigned to {@code ietf-yang-library}. This constant is required for XML-like parsers, using
125      * XML namespaces to reference modules.
126      */
127     public static final String YANG_LIBRARY_NAMESPACE_STRING = "urn:ietf:params:xml:ns:yang:ietf-yang-library";
128     /**
129      * The namespace assigned to {@code ietf-yang-library}. This constant is useful for referencing things in a
130      * type-safe manner.
131      */
132     public static final XMLNamespace YANG_LIBRARY_NAMESPACE = XMLNamespace.of(YANG_LIBRARY_NAMESPACE_STRING).intern();
133     /**
134      * {@code ietf-yang-library} namespace bound to YANG through
135      * <a href="https://www.rfc-editor.org/rfc/rfc7895#section-2.2">ietf-yang-library@2016-06-21.yang</a>.
136      */
137     public static final QNameModule RFC7895_YANG_MODULE =
138         QNameModule.of(YANG_LIBRARY_NAMESPACE, Revision.of("2016-06-21")).intern();
139     /**
140      * {@code ietf-yang-library} namespace bound to YANG through
141      * <a href="https://www.rfc-editor.org/rfc/rfc8525#section-4">ietf-yang-library@2019-01-04.yang</a>.
142      */
143     public static final QNameModule RFC8525_YANG_MODULE =
144         QNameModule.of(YANG_LIBRARY_NAMESPACE, Revision.of("2019-01-04")).intern();
145
146     // Dummy template UnqualifiedQName. These are never leaked, but are used for efficient instantiation via
147     // UnqualifiedQName#bindTo()
148     private static final Unqualified DUMMY_OPERATION_INPUT = Unqualified.of("input");
149     private static final Unqualified DUMMY_OPERATION_OUTPUT = Unqualified.of("output");
150
151     private YangConstants() {
152         // Hidden on purpose
153     }
154
155     /**
156      * Create a {@link QName} representing the 'input' statement of an operation (RPC or action) within specified
157      * {@link QNameModule}.
158      *
159      * @param module Desired module
160      * @return A QName representing action or RPC input.
161      * @throws NullPointerException if {@code module} is null
162      */
163     public static QName operationInputQName(final QNameModule module) {
164         return DUMMY_OPERATION_INPUT.bindTo(module);
165     }
166
167     /**
168      * Create a {@link QName} representing the 'output' statement of an operation (RPC or action) within specified
169      * {@link QNameModule}.
170      *
171      * @param module Desired module
172      * @return A QName representing action or RPC output.
173      * @throws NullPointerException if {@code module} is null
174      */
175     public static QName operationOutputQName(final QNameModule module) {
176         return DUMMY_OPERATION_OUTPUT.bindTo(module);
177     }
178 }