b55bcfa5a624c7adbcfa9c4e9767f3cdd70ee48b
[netconf.git] / restconf / restconf-nb-rfc8040 / src / main / java / org / opendaylight / restconf / nb / rfc8040 / ContentParameter.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.restconf.nb.rfc8040;
9
10 import static java.util.Objects.requireNonNull;
11
12 import org.eclipse.jdt.annotation.NonNull;
13 import org.eclipse.jdt.annotation.Nullable;
14
15 /**
16  * Enumeration of possible {@code content} values as defined by
17  * <a href="https://datatracker.ietf.org/doc/html/rfc8040#section-4.8.1">RFC8040, section 4.8.1</a>.
18  */
19 public enum ContentParameter {
20     /**
21      * Return all descendant data nodes.
22      */
23     ALL("all"),
24     /**
25      * Return only configuration descendant data nodes.
26      */
27     CONFIG("config"),
28     /**
29      * Return only non-configuration descendant data nodes.
30      */
31     NONCONFIG("nonconfig");
32
33     private final @NonNull String uriValue;
34
35     ContentParameter(final String uriValue) {
36         this.uriValue = requireNonNull(uriValue);
37     }
38
39     public @NonNull String uriValue() {
40         return uriValue;
41     }
42
43     public static @NonNull String uriName() {
44         return "content";
45     }
46
47     // Note: returns null of unknowns
48     public static @Nullable ContentParameter forUriValue(final String uriValue) {
49         switch (uriValue) {
50             case "all":
51                 return ALL;
52             case "config":
53                 return CONFIG;
54             case "nonconfig":
55                 return NONCONFIG;
56             default:
57                 return null;
58         }
59     }
60 }