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 java.util.List;
12 import org.eclipse.jdt.annotation.NonNull;
13 import org.opendaylight.restconf.nb.rfc8040.ContentParameter;
14 import org.opendaylight.restconf.nb.rfc8040.WithDefaultsParameter;
15 import org.opendaylight.yangtools.yang.common.QName;
16 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
19 * This holds various options acquired from a requests's query part. This class needs to be further split up to make
20 * sense of it, as parts of it pertain to how a {@link NormalizedNodePayload} should be created while others how it
21 * needs to be processed (for example filtered).
23 public final class QueryParameters {
24 public static final class Builder {
25 private List<YangInstanceIdentifier> fieldPaths;
26 private List<Set<QName>> fields;
27 private ContentParameter content;
28 private WithDefaultsParameter withDefault;
29 // FIXME: this should be a DepthParameter
30 private Integer depth;
31 private boolean prettyPrint;
32 private boolean tagged;
38 public Builder setContent(final ContentParameter content) {
39 this.content = content;
43 public Builder setDepth(final int depth) {
48 public Builder setFields(final List<Set<QName>> fields) {
53 public Builder setFieldPaths(final List<YangInstanceIdentifier> fieldPaths) {
54 this.fieldPaths = fieldPaths;
58 // FIXME: this is not called from anywhere. Create a PrettyPrintParameter or similar to hold it
59 public Builder setPrettyPrint(final boolean prettyPrint) {
60 this.prettyPrint = prettyPrint;
64 public Builder setTagged(final boolean tagged) {
69 public Builder setWithDefault(final WithDefaultsParameter withDefault) {
70 this.withDefault = withDefault;
74 public @NonNull QueryParameters build() {
75 return new QueryParameters(this);
79 private static final @NonNull QueryParameters EMPTY = new Builder().build();
81 private final List<YangInstanceIdentifier> fieldPaths;
82 private final List<Set<QName>> fields;
83 private final WithDefaultsParameter withDefault;
84 private final ContentParameter content;
85 private final Integer depth;
86 private final boolean prettyPrint;
87 private final boolean tagged;
89 private QueryParameters(final Builder builder) {
90 content = builder.content;
91 depth = builder.depth;
92 fields = builder.fields;
93 fieldPaths = builder.fieldPaths;
94 tagged = builder.tagged;
95 prettyPrint = builder.prettyPrint;
96 withDefault = builder.withDefault;
99 public static @NonNull QueryParameters empty() {
103 public static @NonNull Builder builder() {
104 return new Builder();
107 public ContentParameter getContent() {
111 public Integer getDepth() {
115 public List<Set<QName>> getFields() {
119 public List<YangInstanceIdentifier> getFieldPaths() {
123 public WithDefaultsParameter getWithDefault() {
127 public boolean isPrettyPrint() {
131 public boolean isTagged() {