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.nb.rfc8040;
10 import static java.util.Objects.requireNonNull;
12 import com.google.common.annotations.Beta;
13 import com.google.common.base.MoreObjects;
14 import org.eclipse.jdt.annotation.NonNull;
15 import org.eclipse.jdt.annotation.Nullable;
16 import org.opendaylight.yangtools.concepts.Immutable;
19 * Parser and holder of query parameters from uriInfo for data and datastore read operations.
22 // FIXME: this should be a record once we have JDK17+
23 public final class ReadDataParams implements Immutable {
24 private static final @NonNull ReadDataParams EMPTY =
25 new ReadDataParams(ContentParam.ALL, null, null, null, false, null);
27 private final @NonNull ContentParam content;
28 private final WithDefaultsParam withDefaults;
29 private final PrettyPrintParam prettyPrint;
30 private final FieldsParam fields;
31 private final DepthParam depth;
32 private final boolean tagged;
34 private ReadDataParams(final ContentParam content, final DepthParam depth, final FieldsParam fields,
35 final WithDefaultsParam withDefaults, final boolean tagged, final PrettyPrintParam prettyPrint) {
36 this.content = requireNonNull(content);
39 this.withDefaults = withDefaults;
41 this.prettyPrint = prettyPrint;
44 public static @NonNull ReadDataParams empty() {
48 public static @NonNull ReadDataParams of(final ContentParam content, final DepthParam depth,
49 final FieldsParam fields, final WithDefaultsParam withDefaults, final boolean tagged,
50 final PrettyPrintParam prettyPrint) {
51 return new ReadDataParams(content, depth, fields, withDefaults, tagged, prettyPrint);
54 public @NonNull ContentParam content() {
58 public @Nullable DepthParam depth() {
62 public @Nullable FieldsParam fields() {
66 public @Nullable WithDefaultsParam withDefaults() {
70 public @Nullable PrettyPrintParam prettyPrint() {
74 // FIXME: for migration only
75 public boolean tagged() {
80 public String toString() {
81 final var helper = MoreObjects.toStringHelper(this).add("content", content.paramValue());
83 helper.add("depth", depth.value());
86 helper.add("fields", fields.toString());
88 if (withDefaults != null) {
89 helper.add("withDefaults", withDefaults.paramValue());
91 helper.add("tagged", tagged);
92 if (prettyPrint != null) {
93 helper.add("prettyPrint", prettyPrint.value());
95 return helper.toString();