Move WriterParameters.tagged
[netconf.git] / restconf / restconf-nb-rfc8040 / src / main / java / org / opendaylight / restconf / nb / rfc8040 / legacy / QueryParameters.java
1 /*
2  * Copyright (c) 2021 PANTHEON.tech, s.r.o. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.restconf.nb.rfc8040.legacy;
9
10 import java.util.List;
11 import java.util.Set;
12 import org.eclipse.jdt.annotation.NonNull;
13 import org.opendaylight.restconf.common.context.WriterParameters;
14 import org.opendaylight.yangtools.yang.common.QName;
15 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
16
17 /**
18  * A RFC8040 overlay over {@link WriterParameters}. This holds various options acquired from a requests's query part.
19  * This class needs to be further split up to make sense of it, as parts of it pertain to how a
20  * {@link NormalizedNodePayload} should be created while others how it needs to be processed (for example filtered).
21  */
22 public final class QueryParameters extends WriterParameters {
23     public static final class Builder extends WriterParametersBuilder {
24         private List<YangInstanceIdentifier> fieldPaths;
25         private List<Set<QName>> fields;
26         private String withDefault;
27         private boolean tagged;
28         private String content;
29
30         Builder() {
31             // Hidden on purpose
32         }
33
34         public Builder setContent(final String content) {
35             this.content = content;
36             return this;
37         }
38
39         public Builder setFields(final List<Set<QName>> fields) {
40             this.fields = fields;
41             return this;
42         }
43
44         public Builder setFieldPaths(final List<YangInstanceIdentifier> fieldPaths) {
45             this.fieldPaths = fieldPaths;
46             return this;
47         }
48
49         public Builder setTagged(final boolean tagged) {
50             this.tagged = tagged;
51             return this;
52         }
53
54         public Builder setWithDefault(final String withDefault) {
55             this.withDefault = withDefault;
56             return this;
57         }
58
59         @Override
60         public @NonNull QueryParameters build() {
61             return new QueryParameters(this);
62         }
63     }
64
65     private static final @NonNull QueryParameters EMPTY = new Builder().build();
66
67     private final List<YangInstanceIdentifier> fieldPaths;
68     private final List<Set<QName>> fields;
69     private final String withDefault;
70     private final boolean tagged;
71     private final String content;
72
73     private QueryParameters(final Builder builder) {
74         super(builder);
75         content = builder.content;
76         fields = builder.fields;
77         fieldPaths = builder.fieldPaths;
78         tagged = builder.tagged;
79         withDefault = builder.withDefault;
80     }
81
82     public static @NonNull QueryParameters empty() {
83         return EMPTY;
84     }
85
86     public static @NonNull Builder builder() {
87         return new Builder();
88     }
89
90     public String getContent() {
91         return content;
92     }
93
94     public List<Set<QName>> getFields() {
95         return fields;
96     }
97
98     public List<YangInstanceIdentifier> getFieldPaths() {
99         return fieldPaths;
100     }
101
102     public String getWithDefault() {
103         return withDefault;
104     }
105
106     public boolean isTagged() {
107         return tagged;
108     }
109 }