Class NullnessMethodInvocationValidator

java.lang.Object
org.springframework.data.util.NullnessMethodInvocationValidator
All Implemented Interfaces:
Advice, Interceptor, MethodInterceptor
Direct Known Subclasses:
MethodInvocationValidator

public class NullnessMethodInvocationValidator extends Object implements MethodInterceptor
Interceptor enforcing required return value and method parameter constraints declared on repository query methods. Supports Kotlin nullness markers and JSR-305 Non-null annotations. Originally implemented via MethodInvocationValidator.
Since:
3.5
Author:
Mark Paluch, Johannes Englmeier, Christoph Strobl
See Also:
  • Constructor Details

    • NullnessMethodInvocationValidator

      public NullnessMethodInvocationValidator()
  • Method Details

    • supports

      public static boolean supports(Class<?> type)
      Returns true if the type is supported by this interceptor.
      Parameters:
      type - the interface class.
      Returns:
      true if the type is supported by this interceptor.
    • invoke

      @Nullable public Object invoke(MethodInvocation invocation) throws Throwable
      Specified by:
      invoke in interface MethodInterceptor
      Throws:
      Throwable
    • argumentIsNull

      protected RuntimeException argumentIsNull(Method method, String parameterName)
      Template method to construct a RuntimeException indicating failure to provide a non-null value for a method parameter.
      Parameters:
      method -
      parameterName -
      Returns:
    • returnValueIsNull

      protected RuntimeException returnValueIsNull(Method method)
      Template method to construct a RuntimeException indicating failure to return a non-null return value.
      Parameters:
      method -
      Returns: