2 * Copyright (c) 2023 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.server.api;
10 import static java.util.Objects.requireNonNull;
12 import com.google.common.collect.ImmutableList;
13 import java.io.InputStream;
14 import org.eclipse.jdt.annotation.NonNull;
15 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
16 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
18 public abstract sealed class ChildBody extends RequestBody permits JsonChildBody, XmlChildBody {
19 public record PrefixAndBody(@NonNull ImmutableList<PathArgument> prefix, @NonNull NormalizedNode body) {
20 public PrefixAndBody {
21 requireNonNull(prefix);
26 ChildBody(final InputStream inputStream) {
31 * Interpret this object as a child of specified path.
33 * @param path POST request path
34 * @return A {@link PrefixAndBody}
36 public final @NonNull PrefixAndBody toPayload(final DatabindPath.@NonNull Data path) {
37 return toPayload(path, acquireStream());
40 abstract @NonNull PrefixAndBody toPayload(DatabindPath.@NonNull Data path, @NonNull InputStream inputStream);