java-helidon.client.libraries.se.ApiResponseBase.mustache Maven / Gradle / Ivy
{{>licenseInfo}}
package {{invokerPackage}};
import java.util.concurrent.ExecutionException;
import io.helidon.common.GenericType;
import io.helidon.common.reactive.Single;
import io.helidon.webclient.WebClientResponse;
{{#appName}}
/**
* Implementation of a generic-typed response.
*
* @param type of the return value from the generated API method
*/
{{/appName}}
class ApiResponseBase implements ApiResponse {
private final Single webClientResponse;
private final GenericType responseType;
protected ApiResponseBase(GenericType responseType, Single webClientResponse) {
this.webClientResponse = webClientResponse;
this.responseType = responseType;
}
@Override
public Single webClientResponse() {
return webClientResponse;
}
@Override
public Single result() throws ExecutionException, InterruptedException {
return webClientResponse.get().content().as(responseType);
}
}