class CommandHelper {

    public static ResponseEntity<Void> async(final GenericCommand<?> command) {
        final Observable<?> stream = command.toObservable();
        return stream.map(is -> {
            // copy all headers from the command response so that the mime-type is correctly forwarded. Command has
            // the correct headers due to call to toBlocking() below.
            final MultiValueMap<String, String> headers = new HttpHeaders();
            HttpStatus status = command.getStatus();
            for (Header header : command.getCommandResponseHeaders()) {
                headers.put(header.getName(), Collections.singletonList(header.getValue()));
            }
            return new ResponseEntity<Void>(null, headers, status);
        }).toBlocking().first();
    }

    private  CommandHelper();

}