Interface ExecutableValidator



  • public interface ExecutableValidator
    Validates parameters and return values of methods and constructors. Implementations of this interface must be thread-safe.
    Since:
    1.1
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      <T> java.util.Set<ConstraintViolation<T>> validateConstructorParameters​(java.lang.reflect.Constructor<? extends T> constructor, java.lang.Object[] parameterValues, java.lang.Class<?>... groups)
      Validates all constraints placed on the parameters of the given constructor.
      <T> java.util.Set<ConstraintViolation<T>> validateConstructorReturnValue​(java.lang.reflect.Constructor<? extends T> constructor, T createdObject, java.lang.Class<?>... groups)
      Validates all return value constraints of the given constructor.
      <T> java.util.Set<ConstraintViolation<T>> validateParameters​(T object, java.lang.reflect.Method method, java.lang.Object[] parameterValues, java.lang.Class<?>... groups)
      Validates all constraints placed on the parameters of the given method.
      <T> java.util.Set<ConstraintViolation<T>> validateReturnValue​(T object, java.lang.reflect.Method method, java.lang.Object returnValue, java.lang.Class<?>... groups)
      Validates all return value constraints of the given method.
    • Method Detail

      • validateParameters

        <T> java.util.Set<ConstraintViolation<T>> validateParameters​(T object,
                                                                     java.lang.reflect.Method method,
                                                                     java.lang.Object[] parameterValues,
                                                                     java.lang.Class<?>... groups)
        Validates all constraints placed on the parameters of the given method.
        Type Parameters:
        T - the type hosting the method to validate
        Parameters:
        object - the object on which the method to validate is invoked
        method - the method for which the parameter constraints is validated
        parameterValues - the values provided by the caller for the given method's parameters
        groups - the group or list of groups targeted for validation (defaults to Default)
        Returns:
        a set with the constraint violations caused by this validation; will be empty if no error occurs, but never null
        Throws:
        java.lang.IllegalArgumentException - if null is passed for any of the parameters or if parameters don't match with each other
        ValidationException - if a non recoverable error happens during the validation process
      • validateReturnValue

        <T> java.util.Set<ConstraintViolation<T>> validateReturnValue​(T object,
                                                                      java.lang.reflect.Method method,
                                                                      java.lang.Object returnValue,
                                                                      java.lang.Class<?>... groups)
        Validates all return value constraints of the given method.
        Type Parameters:
        T - the type hosting the method to validate
        Parameters:
        object - the object on which the method to validate is invoked
        method - the method for which the return value constraints is validated
        returnValue - the value returned by the given method
        groups - the group or list of groups targeted for validation (defaults to Default)
        Returns:
        a set with the constraint violations caused by this validation; will be empty if no error occurs, but never null
        Throws:
        java.lang.IllegalArgumentException - if null is passed for any of the object, method or groups parameters or if parameters don't match with each other
        ValidationException - if a non recoverable error happens during the validation process
      • validateConstructorParameters

        <T> java.util.Set<ConstraintViolation<T>> validateConstructorParameters​(java.lang.reflect.Constructor<? extends T> constructor,
                                                                                java.lang.Object[] parameterValues,
                                                                                java.lang.Class<?>... groups)
        Validates all constraints placed on the parameters of the given constructor.
        Type Parameters:
        T - the type hosting the constructor to validate
        Parameters:
        constructor - the constructor for which the parameter constraints is validated
        parameterValues - the values provided by the caller for the given constructor's parameters
        groups - the group or list of groups targeted for validation (defaults to Default)
        Returns:
        a set with the constraint violations caused by this validation; Will be empty if no error occurs, but never null
        Throws:
        java.lang.IllegalArgumentException - if null is passed for any of the parameters or if parameters don't match with each other
        ValidationException - if a non recoverable error happens during the validation process
      • validateConstructorReturnValue

        <T> java.util.Set<ConstraintViolation<T>> validateConstructorReturnValue​(java.lang.reflect.Constructor<? extends T> constructor,
                                                                                 T createdObject,
                                                                                 java.lang.Class<?>... groups)
        Validates all return value constraints of the given constructor.
        Type Parameters:
        T - the type hosting the constructor to validate
        Parameters:
        constructor - the constructor for which the return value constraints is validated
        createdObject - the object instantiated by the given method
        groups - the group or list of groups targeted for validation (defaults to Default)
        Returns:
        a set with the constraint violations caused by this validation; will be empty, if no error occurs, but never null
        Throws:
        java.lang.IllegalArgumentException - if null is passed for any of the parameters or if parameters don't match with each other
        ValidationException - if a non recoverable error happens during the validation process