Remove "/" sign in AbstractRestconfStreamRegistry
[netconf.git] / restconf / restconf-nb / src / main / java / org / opendaylight / restconf / server / api / ChildBody.java
1 /*
2  * Copyright (c) 2023 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.server.api;
9
10 import static java.util.Objects.requireNonNull;
11
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;
17
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);
22             requireNonNull(body);
23         }
24     }
25
26     ChildBody(final InputStream inputStream) {
27         super(inputStream);
28     }
29
30     /**
31      * Interpret this object as a child of specified path.
32      *
33      * @param path POST request path
34      * @return A {@link PrefixAndBody}
35      */
36     public final @NonNull PrefixAndBody toPayload(final DatabindPath.@NonNull Data path) {
37         return toPayload(path, consume());
38     }
39
40     abstract @NonNull PrefixAndBody toPayload(DatabindPath.@NonNull Data path, @NonNull InputStream inputStream);
41 }