
se.fortnox.reactivewizard.client.SingleWithResponse Maven / Gradle / Ivy
package se.fortnox.reactivewizard.client;
import reactor.netty.http.client.HttpClientResponse;
import rx.Single;
import java.util.concurrent.atomic.AtomicReference;
/**
* Internal class to help support getting the full response as return value when Single is returned
* @param the type of data to be returned
*/
class SingleWithResponse extends Single {
private final AtomicReference httpClientResponse;
SingleWithResponse(Single inner, AtomicReference httpClientResponse) {
super((OnSubscribe)inner::subscribe);
this.httpClientResponse = httpClientResponse;
}
HttpClientResponse getResponse() {
if (httpClientResponse.get() == null) {
throw new IllegalStateException("This method can only be called after the response has been received");
}
return httpClientResponse.get();
}
static SingleWithResponse from(SingleWithResponse singleWithResponse, Single inner) {
return new SingleWithResponse(inner, singleWithResponse.httpClientResponse);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy