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.api.FormatParameters;
18 import org.opendaylight.restconf.api.query.DepthParam;
19 import org.opendaylight.restconf.api.query.PrettyPrintParam;
20 import org.opendaylight.yangtools.yang.common.QName;
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).
28 public record WriterParameters(
29 @NonNull PrettyPrintParam prettyPrint,
30 @Nullable DepthParam depth,
31 @Nullable List<Set<QName>> fields) implements FormatParameters {
32 public static final @NonNull WriterParameters EMPTY = new WriterParameters(PrettyPrintParam.FALSE, null, null);
34 public WriterParameters {
35 requireNonNull(prettyPrint);
38 public static @NonNull WriterParameters of(final @NonNull PrettyPrintParam prettyPrint,
39 final @Nullable DepthParam depth) {
40 return depth == null && !prettyPrint.value() ? EMPTY : new WriterParameters(prettyPrint, depth, null);