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 com.google.common.annotations.Beta;
13 import java.util.List;
15 import org.eclipse.jdt.annotation.NonNull;
16 import org.eclipse.jdt.annotation.Nullable;
17 import org.opendaylight.restconf.nb.rfc8040.DepthParam;
18 import org.opendaylight.restconf.nb.rfc8040.PrettyPrintParam;
19 import org.opendaylight.restconf.nb.rfc8040.ReadDataParams;
20 import org.opendaylight.yangtools.yang.common.QName;
21 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
24 * This holds various options acquired from a requests's query part. This class needs to be further split up to make
25 * sense of it, as parts of it pertain to how a {@link NormalizedNodePayload} should be created while others how it
26 * needs to be processed (for example filtered).
29 // FIXME: this probably needs to be renamed back to WriterParams, or somesuch
30 public final class QueryParameters {
31 private static final @NonNull QueryParameters EMPTY = of(ReadDataParams.empty());
33 private final @NonNull ReadDataParams params;
34 private final List<YangInstanceIdentifier> fieldPaths;
35 private final List<Set<QName>> fields;
37 private QueryParameters(final ReadDataParams params, final List<Set<QName>> fields,
38 final List<YangInstanceIdentifier> fieldPaths) {
39 this.params = requireNonNull(params);
41 this.fieldPaths = fieldPaths;
44 public static @NonNull QueryParameters empty() {
48 public static @NonNull QueryParameters of(final ReadDataParams params) {
49 return new QueryParameters(params, null, null);
52 public static @NonNull QueryParameters ofFields(final ReadDataParams params, final List<Set<QName>> fields) {
53 return new QueryParameters(params, fields, null);
56 public static @NonNull QueryParameters ofFieldPaths(final ReadDataParams params,
57 final List<YangInstanceIdentifier> fieldPaths) {
58 return new QueryParameters(params, null, fieldPaths);
61 public @NonNull ReadDataParams params() {
65 public @Nullable DepthParam depth() {
66 return params.depth();
69 public @Nullable PrettyPrintParam prettyPrint() {
70 return params.prettyPrint();
73 public @Nullable List<Set<QName>> fields() {
77 public @Nullable List<YangInstanceIdentifier> fieldPaths() {