2 * Copyright (c) 2021 PANTHEON.tech, s.r.o. and others. All rights reserved.
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
8 package org.opendaylight.restconf.api.query;
10 import static java.util.Objects.requireNonNull;
13 import org.eclipse.jdt.annotation.NonNull;
14 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.with.defaults.rev110601.WithDefaultsMode;
17 * Enumeration of possible {@code with-defaults} parameter values as defined by
18 * <a href="https://www.rfc-editor.org/rfc/rfc8040#section-4.8.9">RFC8040, section 4.8.9</a>. This is an equivalent
19 * of with-defaults retrieval mode as defined by
20 * <a href="https://www.rfc-editor.org/rfc/rfc6243#section-3">RFC6243 section 3</a> and expressed as the
21 * {@code typedef with-defaults-mode}} in the corresponding YANG model.
23 public enum WithDefaultsParam implements RestconfQueryParam<WithDefaultsParam> {
25 * Data nodes set to the YANG default by the client are reported.
27 EXPLICIT(WithDefaultsMode.Explicit),
29 * All data nodes are reported.
31 REPORT_ALL(WithDefaultsMode.ReportAll),
33 * All data nodes are reported, and defaults are tagged.
35 REPORT_ALL_TAGGED(WithDefaultsMode.ReportAllTagged),
37 * Data nodes set to the YANG default are not reported.
39 TRIM(WithDefaultsMode.Trim);
41 // API consistency: must not be confused with enum constants
42 @SuppressWarnings("checkstyle:ConstantName")
43 public static final @NonNull String uriName = "with-defaults";
45 private static final @NonNull URI CAPABILITY = URI.create("urn:ietf:params:restconf:capability:with-defaults:1.0");
47 private final @NonNull WithDefaultsMode mode;
49 WithDefaultsParam(final WithDefaultsMode mode) {
50 this.mode = requireNonNull(mode);
53 public static @NonNull WithDefaultsParam of(final WithDefaultsMode mode) {
54 return switch (mode) {
55 case Explicit -> EXPLICIT;
56 case ReportAll -> REPORT_ALL;
57 case ReportAllTagged -> REPORT_ALL_TAGGED;
62 public static @NonNull WithDefaultsParam forUriValue(final String uriValue) {
63 return of(WithDefaultsMode.ofName(uriValue));
67 public Class<WithDefaultsParam> javaClass() {
68 return WithDefaultsParam.class;
72 public String paramName() {
77 public String paramValue() {
78 return mode.getName();
81 public @NonNull WithDefaultsMode mode() {
85 public static @NonNull URI capabilityUri() {