Use pattern matching on instanceof in yang-common
[yangtools.git] / common / yang-common / src / main / java / org / opendaylight / yangtools / yang / common / NetconfLayer.java
1 /*
2  * Copyright (c) 2021 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.yang.common;
9
10 /**
11  * Enumeration of NETCONF layers, as established in
12  * <a href="https://datatracker.ietf.org/doc/html/rfc4741#section-1.1">NETCONF</a>. This enumeration exists because
13  * its semantics are implied by RFC6020 references to {@code error-tag} and its XML encoding.
14  *
15  * <p>
16  * This enumeration corresponds to the {@code Layer} in:
17  * <pre><code>
18  *   NETCONF can be conceptually partitioned into four layers:
19  *
20  *              Layer                      Example
21  *         +-------------+      +-----------------------------+
22  *     (4) |   Content   |      |     Configuration data      |
23  *         +-------------+      +-----------------------------+
24  *                |                           |
25  *         +-------------+      +-----------------------------+
26  *     (3) | Operations  |      | &lt;get-config&gt;, &lt;edit-config&gt; |
27  *         +-------------+      +-----------------------------+
28  *                |                           |
29  *         +-------------+      +-----------------------------+
30  *     (2) |     RPC     |      |    &lt;rpc&gt;, &lt;rpc-reply&gt;       |
31  *         +-------------+      +-----------------------------+
32  *                |                           |
33  *         +-------------+      +-----------------------------+
34  *     (1) |  Transport  |      |   BEEP, SSH, SSL, console   |
35  *         |   Protocol  |      |                             |
36  *         +-------------+      +-----------------------------+
37  * </code></pre>
38  * as acknowledged in <a href="https://datatracker.ietf.org/doc/html/rfc6241#section-1.2">RFC6241</a>:
39  * <pre>
40  *   The YANG data modeling language [RFC6020] has been developed for
41  *   specifying NETCONF data models and protocol operations, covering the
42  *   Operations and the Content layers of Figure 1.
43  * </pre>
44  */
45 public enum NetconfLayer {
46     /**
47      * Content layer, for example configuration data. This layer is implied indirectly in all YANG-based validation and
48      * corresponds to {@link ErrorType#APPLICATION}
49      */
50     CONTENT,
51     /**
52      * Operations layer, for example {@code <get-config>}, {@code <edit-config>} configuration data. This corresponds to
53      * {@link ErrorType#PROTOCOL}.
54      */
55     OPERATIONS,
56     /**
57      * RPC layer, for example {@code <rpc>}, {@code <rpc-reply>}. This corresponds to {@link ErrorType#RPC}.
58      */
59     RPC,
60     /**
61      * Transport protocol layer, for example BEEP, SSH, TLS, console. This corresponds to {@link ErrorType#TRANSPORT}.
62      */
63     TRANSPORT;
64 }