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;
11 import org.eclipse.jdt.annotation.NonNull;
14 * OpenDaylight extension parameter. When used as {@code odl-pretty-print=true}, it will instruct outbound XML/JSON
15 * formatters to make the output easier for humans to understand.
17 public final class PrettyPrintParam implements RestconfQueryParam<PrettyPrintParam> {
18 // API consistency: must not be confused with enum constants
19 @SuppressWarnings("checkstyle:ConstantName")
20 public static final String uriName = "odl-pretty-print";
22 public static final @NonNull PrettyPrintParam FALSE = new PrettyPrintParam(false);
23 public static final @NonNull PrettyPrintParam TRUE = new PrettyPrintParam(true);
25 private static final @NonNull URI CAPABILITY =
26 URI.create("urn:opendaylight:params:restconf:capability:pretty-print:1.0");
28 private final boolean value;
30 private PrettyPrintParam(final boolean value) {
34 public static @NonNull PrettyPrintParam of(final boolean value) {
35 return value ? TRUE : FALSE;
38 public static @NonNull PrettyPrintParam forUriValue(final String uriValue) {
39 return switch (uriValue) {
40 case "false" -> FALSE;
42 default -> throw new IllegalArgumentException("Value can be 'false' or 'true', not '" + uriValue + "'");
47 public Class<PrettyPrintParam> javaClass() {
48 return PrettyPrintParam.class;
52 public String paramName() {
57 public String paramValue() {
58 return String.valueOf(value);
61 public boolean value() {
65 public static @NonNull URI capabilityUri() {