java-helidon.client.libraries.se.ApiResponseBase.mustache Maven / Gradle / Ivy
{{>licenseInfo}}
package {{invokerPackage}};
{{#x-helidon-v3}}import java.util.concurrent.ExecutionException;
{{/x-helidon-v3}}
import io.helidon.common.GenericType;
{{#x-helidon-v3}}import io.helidon.common.reactive.Single;
import io.helidon.webclient.WebClientResponse;
{{/x-helidon-v3}}{{!
}}{{^x-helidon-v3}}import io.helidon.webclient.api.HttpClientResponse;
{{/x-helidon-v3}}
{{#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 {{#x-helidon-v3}}Single{{/x-helidon-v3}} webClientResponse;
private final GenericType responseType;
protected ApiResponseBase(GenericType responseType, {{#x-helidon-v3}}Single{{/x-helidon-v3}} webClientResponse) {
this.webClientResponse = webClientResponse;
this.responseType = responseType;
}
@Override
public {{#x-helidon-v3}}Single{{/x-helidon-v3}}{{^x-helidon-v3}}HttpClientResponse{{/x-helidon-v3}} webClientResponse() {
return webClientResponse;
}
@Override
public {{#x-helidon-v3}}Single<{{/x-helidon-v3}}T{{#x-helidon-v3}}>{{/x-helidon-v3}} result() {{#x-helidon-v3}}throws ExecutionException, InterruptedException{{/x-helidon-v3}} {
return webClientResponse.{{#x-helidon-v3}}get().content(){{/x-helidon-v3}}{{^x-helidon-v3}}entity(){{/x-helidon-v3}}.as(responseType);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy