- java.lang.Object
-
- cz.jiripinkas.jsitemapgenerator.PingResponse
-
public class PingResponse extends Object
Ping response reacts to response of Ping call. If operation failed, *failure() methods will be called. If operation succeeds, *success() method will be called.
-
-
Constructor Summary
Constructors Constructor Description PingResponse(boolean operationFailed)PingResponse(boolean operationFailed, RuntimeException exception)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PingResponsecallOnSuccess(Runnable runnable)On success call RunnablevoidcatchOnFailure(Consumer<RuntimeException> consumer)On failure call consumer.voidthrowOnFailure()Throw original exception on failurevoidthrowOnFailure(UnaryOperator<RuntimeException> function)Throw user-defined exception on failure
-
-
-
Constructor Detail
-
PingResponse
public PingResponse(boolean operationFailed, RuntimeException exception)
-
PingResponse
public PingResponse(boolean operationFailed)
-
-
Method Detail
-
callOnSuccess
public PingResponse callOnSuccess(Runnable runnable)
On success call Runnable- Parameters:
runnable- Runnable to call- Returns:
- Current PingResponse object, which can be used to define what happens on failure. On failure exception should be either catched, or re-thrown.
-
throwOnFailure
public void throwOnFailure(UnaryOperator<RuntimeException> function)
Throw user-defined exception on failure- Parameters:
function- Function, input: original exception, output: user-defined exception
-
throwOnFailure
public void throwOnFailure()
Throw original exception on failure
-
catchOnFailure
public void catchOnFailure(Consumer<RuntimeException> consumer)
On failure call consumer.- Parameters:
consumer- Consumer to call
-
-