Package org.apache.pekko.http.javadsl
Class HttpResponseResult
java.lang.Object
org.apache.pekko.http.javadsl.HttpResponseResult
The outcome of sending a request through a connection pool flow: either the
HttpResponse or the
failure that prevented one from being received.
Emitted by the *WithResult connection pool flows of Http as a Java-friendly alternative to scala.util.Try.
- Since:
- 2.0.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanstatic HttpResponseResultCreates a failed result holding the given failure.<R> Rfold(org.apache.pekko.japi.function.Function<HttpResponse, R> onSuccess, org.apache.pekko.japi.function.Function<Throwable, R> onFailure) AppliesonSuccessto the response if this result is a success, otherwise appliesonFailureto the failure.static HttpResponseResultfromTry(scala.util.Try<HttpResponse> result) INTERNAL APIReturns the failure.Returns the response.<R> Rhandle(org.apache.pekko.japi.function.Function2<HttpResponse, Throwable, R> f) LikeCompletionStage.handle, appliesfto the response and anullfailure if this result is a success, or to anullresponse and the failure otherwise.inthashCode()booleanReturns `true` if no response was received because of a failure.booleanReturns `true` if a response was received.static HttpResponseResultsuccess(HttpResponse response) Creates a successful result holding the given response.toString()
-
Constructor Details
-
HttpResponseResult
public HttpResponseResult()
-
-
Method Details
-
success
Creates a successful result holding the given response. -
failure
Creates a failed result holding the given failure. -
fromTry
INTERNAL API -
isSuccess
public boolean isSuccess()Returns `true` if a response was received. -
isFailure
public boolean isFailure()Returns `true` if no response was received because of a failure. -
getResponse
Returns the response.- Returns:
- (undocumented)
- Throws:
IllegalStateException- if this result is a failure; the failure is attached as the cause
-
getFailure
Returns the failure.- Returns:
- (undocumented)
- Throws:
IllegalStateException- if this result is a success
-
fold
public <R> R fold(org.apache.pekko.japi.function.Function<HttpResponse, R> onSuccess, org.apache.pekko.japi.function.Function<Throwable, R> onFailure) AppliesonSuccessto the response if this result is a success, otherwise appliesonFailureto the failure. Exceptions thrown by either function are rethrown to the caller.- Parameters:
onSuccess- (undocumented)onFailure- (undocumented)- Returns:
- (undocumented)
-
handle
LikeCompletionStage.handle, appliesfto the response and anullfailure if this result is a success, or to anullresponse and the failure otherwise. Exceptions thrown byfare rethrown to the caller.- Parameters:
f- (undocumented)- Returns:
- (undocumented)
-
equals
-
hashCode
public int hashCode() -
toString
-