Interface ValidationResponse


public interface ValidationResponse
Represents a response of a custom annotation value validation.
Since:
2.0.0
Author:
MrIvanPlays
  • Field Details

  • Method Details

    • fromBooleanValue

      static ValidationResponse fromBooleanValue(boolean successful)
      Returns validation response given the boolean value.
      Parameters:
      successful - whether successful
      Returns:
      validation response
    • fromBooleanValue

      static ValidationResponse fromBooleanValue(boolean successful, Throwable onFailError)
      Returns validation response given the boolean value. If it fails, the specified Throwable onFailError will be thrown via a wrapped RuntimeException.
      Parameters:
      successful - whether successful
      onFailError - 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 specified Throwable onFailError will be thrown via a wrapped RuntimeException. If it is successful, it will execute the specified Runnable onSuccess.
      Parameters:
      successful - whether successful
      onFailError - error, thrown on fail
      onSuccess - runnable, ran on success
      Returns:
      validation response
    • success

      static ValidationResponse success(Runnable runnable)
      Returns a successful validation response. The specified Runnable 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 specified Throwable error will be thrown via a wrapped RuntimeException 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

      default Runnable onSuccess()
      Returns a Runnable to run, which marks this validation response is successful.
      Returns:
      runnable to run
    • shouldFailSilently

      default boolean shouldFailSilently()
      Returns whether to fail silently, which marks this validation response is not successful.
      Returns:
      true in order to fail silently, false otherwise
    • throwError

      default Throwable throwError()
      Returns a Throwable to throw, which marks this validation response is not successful. The returned throwable will be thrown via a wrapped RuntimeException.
      Returns:
      throwable to throw