Separate out ReadDataParams
[netconf.git] / restconf / restconf-nb-rfc8040 / src / main / java / org / opendaylight / restconf / nb / rfc8040 / WithDefaultsParameter.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 java.net.URI;
13 import org.eclipse.jdt.annotation.NonNull;
14 import org.eclipse.jdt.annotation.Nullable;
15
16 /**
17  * Enumeration of possible {@code with-defaults} parameter values as defined by
18  * <a href="https://datatracker.ietf.org/doc/html/rfc8040#section-4.8.9">RFC8040, section 4.8.9</a>.
19  */
20 public enum WithDefaultsParameter {
21     /**
22      * Data nodes set to the YANG default by the client are reported.
23      */
24     EXPLICIT("explicit"),
25     /**
26      * All data nodes are reported.
27      */
28     REPORT_ALL("report-all"),
29     /**
30      * All data nodes are reported, and defaults are tagged.
31      */
32     REPORT_ALL_TAGGED("report-all-tagged"),
33     /**
34      * Data nodes set to the YANG default are not reported.
35      */
36     TRIM("trim");
37
38     private static final @NonNull URI CAPABILITY = URI.create("urn:ietf:params:restconf:capability:with-defaults:1.0");
39
40     private final @NonNull String uriValue;
41
42     WithDefaultsParameter(final String uriValue) {
43         this.uriValue = requireNonNull(uriValue);
44     }
45
46     public static @NonNull String uriName() {
47         return "with-defaults";
48     }
49
50     public @NonNull String uriValue() {
51         return uriValue;
52     }
53
54     public static @Nullable WithDefaultsParameter forUriValue(final String uriValue) {
55         switch (uriValue) {
56             case "explicit":
57                 return EXPLICIT;
58             case "report-all":
59                 return REPORT_ALL;
60             case "report-all-tagged":
61                 return REPORT_ALL_TAGGED;
62             case "trim":
63                 return TRIM;
64             default:
65                 return null;
66         }
67     }
68
69     public static @NonNull URI capabilityUri() {
70         return CAPABILITY;
71     }
72 }