Functions

Function with no Parameter and No Return Value

You can just use the Runnable interface as a way for a callback. Runnable also has the FunctionalInterface annotation and as such is a valid interface for a Java 8 function.

Interface:

    void delete(int id, Runnable callback);

Caller:

    delete(id, () -> {
        // do some stuff like return data from a REST service
        response.noContent().build();
    });

Callee:

    public void delete(int id, Runnable callback) {
      getConnection(connection -> {
          connection.delete(id, result -> {
              if (result.success()) {
                  callback.run();
              }
              else {
                  throw result.cause();
              }
          });
          
      });