Rework body formatting wiring
[netconf.git] / restconf / restconf-nb / src / main / java / org / opendaylight / restconf / nb / jaxrs / FormattableBodyCallback.java
index 045875293f11b7a3173ff5c8685e9a52a276a2b5..8d5aebb00be3ca6bc1ce35fa7fe5cc2abc4863ae 100644 (file)
@@ -7,8 +7,12 @@
  */
 package org.opendaylight.restconf.nb.jaxrs;
 
+import static java.util.Objects.requireNonNull;
+
 import javax.ws.rs.container.AsyncResponse;
 import javax.ws.rs.core.Response;
+import org.eclipse.jdt.annotation.NonNull;
+import org.opendaylight.restconf.api.FormatParameters;
 import org.opendaylight.restconf.api.FormattableBody;
 import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
 
@@ -16,12 +20,15 @@ import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
  * A {@link JaxRsRestconfCallback} producing a {@link FormattableBody}.
  */
 final class FormattableBodyCallback extends JaxRsRestconfCallback<FormattableBody> {
-    FormattableBodyCallback(final AsyncResponse ar) {
+    private final @NonNull FormatParameters format;
+
+    FormattableBodyCallback(final AsyncResponse ar, final FormatParameters format) {
         super(ar);
+        this.format = requireNonNull(format);
     }
 
     @Override
     Response transform(final FormattableBody result) throws RestconfDocumentedException {
-        return Response.ok().entity(result).build();
+        return Response.ok().entity(new JaxRsFormattableBody(result, format)).build();
     }
 }