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 com.google.common.base.Preconditions.checkArgument;
13 import org.eclipse.jdt.annotation.NonNull;
14 import org.eclipse.jdt.annotation.Nullable;
17 * This class represents a {@code depth} parameter as defined in
18 * <a href="https://www.rfc-editor.org/rfc/rfc8040#section-4.8.2">RFC8040 section 4.8.2</a>.
20 public final class DepthParam implements RestconfQueryParam<DepthParam> {
21 // API consistency: must not be confused with enum constants
22 @SuppressWarnings("checkstyle:ConstantName")
23 public static final @NonNull String uriName = "depth";
25 private static final @NonNull URI CAPABILITY = URI.create("urn:ietf:params:restconf:capability:depth:1.0");
26 private static final @NonNull DepthParam MIN = of(1);
27 private static final @NonNull DepthParam MAX = of(65535);
29 private final int value;
31 private DepthParam(final int value) {
33 checkArgument(value >= 1 && value <= 65535);
36 public static @NonNull DepthParam of(final int value) {
37 return new DepthParam(value);
41 public Class<DepthParam> javaClass() {
42 return DepthParam.class;
46 public String paramName() {
51 public String paramValue() {
52 return String.valueOf(value);
55 public static @NonNull DepthParam min() {
59 public static @NonNull DepthParam max() {
63 public static @Nullable DepthParam forUriValue(final String uriValue) {
64 return "unbounded".equals(uriValue) ? null : of(Integer.parseUnsignedInt(uriValue, 10));
71 public static @NonNull URI capabilityUri() {