retrofit / retrofit2 / CallAdapter / adapt

adapt

abstract fun adapt(call: Call<R>!): T

Returns an instance of T which delegates to call.

For example, given an instance for a hypothetical utility, Async, this instance would return a new Async<R> which invoked call when run.


    @Override
    public <R> Async<R> adapt(final Call<R> call) {
      return Async.create(new Callable<Response<R>>() {
        @Override
        public Response<R> call() throws Exception {
          return call.execute();
        }
      });
    }