2 * Copyright (c) 2024 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 java.io.IOException;
13 import java.io.OutputStream;
14 import org.eclipse.jdt.annotation.NonNullByDefault;
15 import org.opendaylight.restconf.api.FormattableBody;
16 import org.opendaylight.restconf.api.query.PrettyPrintParam;
19 * A {@link FormattableBody} which has an attached {@link DatabindContext}.
22 public abstract class DatabindFormattableBody extends FormattableBody {
23 private final DatabindContext databind;
25 protected DatabindFormattableBody(final DatabindContext databind) {
26 this.databind = requireNonNull(databind);
30 public final void formatToJSON(final PrettyPrintParam prettyPrint, final OutputStream out) throws IOException {
31 formatToJSON(databind, prettyPrint, out);
34 protected abstract void formatToJSON(DatabindContext databind, PrettyPrintParam prettyPrint, OutputStream out)
38 public final void formatToXML(final PrettyPrintParam prettyPrint, final OutputStream out) throws IOException {
39 formatToXML(databind, prettyPrint, out);
42 protected abstract void formatToXML(DatabindContext databind, PrettyPrintParam prettyPrint, OutputStream out)