Interface ValidationResponse
public interface ValidationResponse
Represents a response of a custom annotation value validation.
- Since:
- 2.0.0
- Author:
- MrIvanPlays
-
Field Summary
Modifier and TypeFieldDescriptionstatic final ValidationResponse
Returns a failure validation response, which is going to cancel field set silently.static final ValidationResponse
Returns successful validation response. -
Method Summary
Modifier and TypeMethodDescriptionstatic ValidationResponse
Returns a failure validation response.static ValidationResponse
Returns a failure validation response, which is going to cancel field set silently.static ValidationResponse
fromBooleanValue
(boolean successful) Returns validation response given the boolean value.static ValidationResponse
fromBooleanValue
(boolean successful, Throwable onFailError) Returns validation response given the boolean value.static ValidationResponse
fromBooleanValue
(boolean successful, Throwable onFailError, Runnable onSuccess) Returns validation response given the boolean value.default Runnable
Returns aRunnable
to run, which marks this validation response is successful.default boolean
Returns whether to fail silently, which marks this validation response is not successful.static ValidationResponse
success()
Returns successful validation response.static ValidationResponse
Returns a successful validation response.default Throwable
Returns aThrowable
to throw, which marks this validation response is not successful.
-
Field Details
-
SUCCESS
Returns successful validation response. -
SILENT_FAIL
Returns a failure validation response, which is going to cancel field set silently.
-
-
Method Details
-
fromBooleanValue
Returns validation response given the boolean value.- Parameters:
successful
- whether successful- Returns:
- validation response
-
fromBooleanValue
Returns validation response given the boolean value. If it fails, the specifiedThrowable
onFailError
will be thrown via a wrappedRuntimeException
.- Parameters:
successful
- whether successfulonFailError
- error, thrown on fail- Returns:
- validation response
-
fromBooleanValue
static ValidationResponse fromBooleanValue(boolean successful, Throwable onFailError, Runnable onSuccess) Returns validation response given the boolean value. If it fails, the specifiedThrowable
onFailError
will be thrown via a wrappedRuntimeException
. If it is successful, it will execute the specifiedRunnable
onSuccess
.- Parameters:
successful
- whether successfulonFailError
- error, thrown on failonSuccess
- runnable, ran on success- Returns:
- validation response
-
success
Returns a successful validation response. The specifiedRunnable
runnable
will be executed whenever we get to this response.- Parameters:
runnable
- runnable to execute- Returns:
- successful validation response
-
success
Returns successful validation response.- Returns:
- successful validation response
-
fail
Returns a failure validation response. The specifiedThrowable
error
will be thrown via a wrappedRuntimeException
whenever we get to this response.- Parameters:
error
- the error to throw- Returns:
- failure validation response
-
failSilently
Returns a failure validation response, which is going to cancel field set silently.- Returns:
- silent failure validation response
-
onSuccess
Returns aRunnable
to run, which marks this validation response is successful.- Returns:
- runnable to run
-
shouldFailSilently
Returns whether to fail silently, which marks this validation response is not successful.- Returns:
- true in order to fail silently, false otherwise
-
throwError
Returns aThrowable
to throw, which marks this validation response is not successful. The returned throwable will be thrown via a wrappedRuntimeException
.- Returns:
- throwable to throw
-