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.legacy;
10 import static java.util.Objects.requireNonNull;
12 import java.util.List;
14 import org.eclipse.jdt.annotation.NonNull;
15 import org.eclipse.jdt.annotation.Nullable;
16 import org.opendaylight.restconf.nb.rfc8040.ContentParameter;
17 import org.opendaylight.restconf.nb.rfc8040.DepthParameter;
18 import org.opendaylight.restconf.nb.rfc8040.WithDefaultsParameter;
19 import org.opendaylight.yangtools.yang.common.QName;
20 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
23 * This holds various options acquired from a requests's query part. This class needs to be further split up to make
24 * sense of it, as parts of it pertain to how a {@link NormalizedNodePayload} should be created while others how it
25 * needs to be processed (for example filtered).
27 public final class QueryParameters {
28 public static final class Builder {
29 private @NonNull ContentParameter content = ContentParameter.ALL;
30 private List<YangInstanceIdentifier> fieldPaths;
31 private List<Set<QName>> fields;
32 private WithDefaultsParameter withDefault;
33 private DepthParameter depth;
34 private boolean prettyPrint;
35 private boolean tagged;
41 public Builder setContent(final ContentParameter content) {
42 this.content = requireNonNull(content);
46 public Builder setDepth(final DepthParameter depth) {
51 public Builder setFields(final List<Set<QName>> fields) {
56 public Builder setFieldPaths(final List<YangInstanceIdentifier> fieldPaths) {
57 this.fieldPaths = fieldPaths;
61 // FIXME: this is not called from anywhere. Create a PrettyPrintParameter or similar to hold it
62 public Builder setPrettyPrint(final boolean prettyPrint) {
63 this.prettyPrint = prettyPrint;
67 public Builder setTagged(final boolean tagged) {
72 public Builder setWithDefault(final WithDefaultsParameter withDefault) {
73 this.withDefault = withDefault;
77 public @NonNull QueryParameters build() {
78 return new QueryParameters(this);
82 private static final @NonNull QueryParameters EMPTY = new Builder().build();
84 private final List<YangInstanceIdentifier> fieldPaths;
85 private final List<Set<QName>> fields;
86 private final WithDefaultsParameter withDefault;
87 private final @NonNull ContentParameter content;
88 private final DepthParameter depth;
89 private final boolean prettyPrint;
90 private final boolean tagged;
92 private QueryParameters(final Builder builder) {
93 content = builder.content;
94 depth = builder.depth;
95 fields = builder.fields;
96 fieldPaths = builder.fieldPaths;
97 tagged = builder.tagged;
98 prettyPrint = builder.prettyPrint;
99 withDefault = builder.withDefault;
102 public static @NonNull QueryParameters empty() {
106 public static @NonNull Builder builder() {
107 return new Builder();
110 public @NonNull ContentParameter getContent() {
114 public @Nullable DepthParameter getDepth() {
118 public List<Set<QName>> getFields() {
122 public List<YangInstanceIdentifier> getFieldPaths() {
126 public WithDefaultsParameter getWithDefault() {
130 public boolean isPrettyPrint() {
134 public boolean isTagged() {