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(ContentParameter.ALL, null, null, null, false, false);
27 private final @NonNull ContentParameter content;
28 private final WithDefaultsParameter withDefaults;
29 private final FieldsParameter fields;
30 private final DepthParameter depth;
31 private final boolean prettyPrint;
32 private final boolean tagged;
34 private ReadDataParams(final ContentParameter content, final DepthParameter depth, final FieldsParameter fields,
35 final WithDefaultsParameter withDefaults, final boolean tagged, final boolean 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 ContentParameter content, final DepthParameter depth,
49 final FieldsParameter fields, final WithDefaultsParameter withDefaults, final boolean tagged,
50 final boolean prettyPrint) {
51 return new ReadDataParams(content, depth, fields, withDefaults, tagged, prettyPrint);
54 public @NonNull ContentParameter content() {
58 public @Nullable DepthParameter depth() {
62 public @Nullable FieldsParameter fields() {
66 public @Nullable WithDefaultsParameter withDefaults() {
70 public boolean prettyPrint() {
74 // FIXME: for migration only
75 public boolean tagged() {
80 public String toString() {
81 final var helper = MoreObjects.toStringHelper(this).add("content", content.uriValue());
83 helper.add("depth", depth.value());
86 helper.add("fields", fields.toString());
88 if (withDefaults != null) {
89 helper.add("withDefaults", withDefaults.uriValue());
91 return helper.add("tagged", tagged).add("prettyPrint", prettyPrint).toString();