Interface ValidationResponse
public interface ValidationResponse
Represents a response of a custom annotation value validation.
- Since:
- 2.0.0
- Author:
- MrIvanPlays
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ValidationResponseReturns a failure validation response, which is going to cancel field set silently.static final ValidationResponseReturns successful validation response. -
Method Summary
Modifier and TypeMethodDescriptionstatic ValidationResponseReturns a failure validation response.static ValidationResponseReturns a failure validation response, which is going to cancel field set silently.static ValidationResponsefromBooleanValue(boolean successful) Returns validation response given the boolean value.static ValidationResponsefromBooleanValue(boolean successful, Throwable onFailError) Returns validation response given the boolean value.static ValidationResponsefromBooleanValue(boolean successful, Throwable onFailError, Runnable onSuccess) Returns validation response given the boolean value.default RunnableReturns aRunnableto run, which marks this validation response is successful.default booleanReturns whether to fail silently, which marks this validation response is not successful.static ValidationResponsesuccess()Returns successful validation response.static ValidationResponseReturns a successful validation response.default ThrowableReturns aThrowableto 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 specifiedThrowableonFailErrorwill 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 specifiedThrowableonFailErrorwill be thrown via a wrappedRuntimeException. If it is successful, it will execute the specifiedRunnableonSuccess.- Parameters:
successful- whether successfulonFailError- error, thrown on failonSuccess- runnable, ran on success- Returns:
- validation response
-
success
Returns a successful validation response. The specifiedRunnablerunnablewill 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 specifiedThrowableerrorwill be thrown via a wrappedRuntimeExceptionwhenever 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 aRunnableto 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 aThrowableto throw, which marks this validation response is not successful. The returned throwable will be thrown via a wrappedRuntimeException.- Returns:
- throwable to throw
-