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.eclipse.jdt.annotation.Nullable;
14 import org.opendaylight.restconf.nb.rfc8040.ContentParameter;
15 import org.opendaylight.restconf.nb.rfc8040.DepthParameter;
16 import org.opendaylight.restconf.nb.rfc8040.WithDefaultsParameter;
17 import org.opendaylight.yangtools.yang.common.QName;
18 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
21 * This holds various options acquired from a requests's query part. This class needs to be further split up to make
22 * sense of it, as parts of it pertain to how a {@link NormalizedNodePayload} should be created while others how it
23 * needs to be processed (for example filtered).
25 public final class QueryParameters {
26 public static final class Builder {
27 private List<YangInstanceIdentifier> fieldPaths;
28 private List<Set<QName>> fields;
29 private ContentParameter content;
30 private WithDefaultsParameter withDefault;
31 private DepthParameter depth;
32 private boolean prettyPrint;
33 private boolean tagged;
39 public Builder setContent(final ContentParameter content) {
40 this.content = content;
44 public Builder setDepth(final DepthParameter depth) {
49 public Builder setFields(final List<Set<QName>> fields) {
54 public Builder setFieldPaths(final List<YangInstanceIdentifier> fieldPaths) {
55 this.fieldPaths = fieldPaths;
59 // FIXME: this is not called from anywhere. Create a PrettyPrintParameter or similar to hold it
60 public Builder setPrettyPrint(final boolean prettyPrint) {
61 this.prettyPrint = prettyPrint;
65 public Builder setTagged(final boolean tagged) {
70 public Builder setWithDefault(final WithDefaultsParameter withDefault) {
71 this.withDefault = withDefault;
75 public @NonNull QueryParameters build() {
76 return new QueryParameters(this);
80 private static final @NonNull QueryParameters EMPTY = new Builder().build();
82 private final List<YangInstanceIdentifier> fieldPaths;
83 private final List<Set<QName>> fields;
84 private final WithDefaultsParameter withDefault;
85 private final ContentParameter content;
86 private final DepthParameter depth;
87 private final boolean prettyPrint;
88 private final boolean tagged;
90 private QueryParameters(final Builder builder) {
91 content = builder.content;
92 depth = builder.depth;
93 fields = builder.fields;
94 fieldPaths = builder.fieldPaths;
95 tagged = builder.tagged;
96 prettyPrint = builder.prettyPrint;
97 withDefault = builder.withDefault;
100 public static @NonNull QueryParameters empty() {
104 public static @NonNull Builder builder() {
105 return new Builder();
108 public ContentParameter getContent() {
112 public @Nullable DepthParameter getDepth() {
116 public List<Set<QName>> getFields() {
120 public List<YangInstanceIdentifier> getFieldPaths() {
124 public WithDefaultsParameter getWithDefault() {
128 public boolean isPrettyPrint() {
132 public boolean isTagged() {