org.springframework.validation.beanvalidation

## 类 MethodValidationInterceptor

- java.lang.Object
- - org.springframework.validation.beanvalidation.MethodValidationInterceptor

- 所有已实现的接口:
    org.aopalliance.aop.Advice, org.aopalliance.intercept.Interceptor, org.aopalliance.intercept.MethodInterceptor

      public class MethodValidationInterceptor
      extends Object
      implements org.aopalliance.intercept.MethodInterceptor

  An AOP Alliance `MethodInterceptor` implementation that delegates to a JSR-303 provider for performing method-level validation on annotated methods.

  Applicable methods have JSR-303 constraint annotations on their parameters and/or on their return value (in the latter case specified at the method level, typically as inline annotation).

  E.g.: `public @NotNull Object myValidMethod(@NotNull String arg1, @Max(10) int arg2)`

  Validation groups can be specified through Spring's `Validated` annotation at the type level of the containing target class, applying to all public service methods of that class. By default, JSR-303 will validate against its default group only.

  As of Spring 5.0, this functionality requires a Bean Validation 1.1 provider.

  从以下版本开始:
    3.1
  作者:
    Juergen Hoeller
  另请参阅:
    `MethodValidationPostProcessor`, `ExecutableValidator`

- - ### 构造器概要

    构造器
    构造器和说明
    `MethodValidationInterceptor()` Create a new MethodValidationInterceptor using a default JSR-303 validator underneath.
    `MethodValidationInterceptor(Validator validator)` Create a new MethodValidationInterceptor using the given JSR-303 Validator.
    `MethodValidationInterceptor(ValidatorFactory validatorFactory)` Create a new MethodValidationInterceptor using the given JSR-303 ValidatorFactory.

  - ### 方法概要

    所有方法 实例方法 具体方法
    限定符和类型 | 方法和说明
    --- | ---
    `protected Class<?>[]` | `determineValidationGroups(org.aopalliance.intercept.MethodInvocation invocation)` Determine the validation groups to validate against for the given method invocation.
    `Object` | `invoke(org.aopalliance.intercept.MethodInvocation invocation)`

    - ### 从类继承的方法 java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### 构造器详细资料

    - #### MethodValidationInterceptor

          public MethodValidationInterceptor()

      Create a new MethodValidationInterceptor using a default JSR-303 validator underneath.

    - #### MethodValidationInterceptor

          public MethodValidationInterceptor(ValidatorFactory validatorFactory)

      Create a new MethodValidationInterceptor using the given JSR-303 ValidatorFactory.
      参数:
        `validatorFactory` - the JSR-303 ValidatorFactory to use

    - #### MethodValidationInterceptor

          public MethodValidationInterceptor(Validator validator)

      Create a new MethodValidationInterceptor using the given JSR-303 Validator.
      参数:
        `validator` - the JSR-303 Validator to use

  - ### 方法详细资料

    - #### invoke

          public Object invoke(org.aopalliance.intercept.MethodInvocation invocation)
                        throws Throwable

      指定者:
        `invoke` 在接口中 `org.aopalliance.intercept.MethodInterceptor`
      抛出:
        `Throwable`

    - #### determineValidationGroups

          protected Class<?>[] determineValidationGroups(org.aopalliance.intercept.MethodInvocation invocation)

      Determine the validation groups to validate against for the given method invocation.

      Default are the validation groups as specified in the `Validated` annotation on the containing target class of the method.

      参数:
        `invocation` - the current MethodInvocation
      返回:
        the applicable validation groups as a Class array