class OneRowActionListener<Response> implements ActionListener<Response>, BiConsumer<Response, Throwable> {

    private final RowConsumer consumer;
    private final Function<? super Response, ? extends Row> toRowFunction;

    public static OneRowActionListener<? super AcknowledgedResponse> oneIfAcknowledged(RowConsumer consumer) {
        return new OneRowActionListener<>(consumer, resp -> resp.isAcknowledged() ? new Row1(1L) : new Row1(0L));
    }

    public OneRowActionListener(RowConsumer consumer, Function<? super Response, ? extends Row> toRowFunction) {
        this.consumer = consumer;
        this.toRowFunction = toRowFunction;
    }

    @Override
    public void onResponse(Response response) {
        final Row row;
        try {
            row = toRowFunction.apply(response);
        } catch (Throwable t) {
            consumer.accept(null, t);
            return;
        }
        consumer.accept(InMemoryBatchIterator.of(row, SENTINEL), null);
    }

    @Override
    public void onFailure(@NotNull Exception e) {
        consumer.accept(null, e);
    }

    @Override
    public void accept(Response response, Throwable t) {<FILL_FUNCTION_BODY>}
}

        if (t == null) {
            onResponse(response);
        } else {
            consumer.accept(null, t);
        }
    
<no_super_class>