private void validateMethod ( Method method , CallbackType callbackType ) { int modifiers = method . getModifiers ( ) ; if ( ! Modifier . isPublic ( modifiers ) ) { String message = String . format ( "Method %s in class %s must be public" , method . getName ( ) , method . getDeclaringClass ( ) . getName ( ) ) ; throw new EntityManagerException ( message ) ; } if ( Modifier . isStatic ( modifiers ) ) { String message = String . format ( "Method %s in class %s must not be static" , method . getName ( ) , method . getDeclaringClass ( ) . getName ( ) ) ; throw new EntityManagerException ( message ) ; } if ( Modifier . isAbstract ( modifiers ) ) { String message = String . format ( "Method %s in class %s must not be abstract" , method . getName ( ) , method . getDeclaringClass ( ) . getName ( ) ) ; throw new EntityManagerException ( message ) ; } Class < ? > [ ] parameters = method . getParameterTypes ( ) ; if ( parameters . length != 0 ) { String pattern = "Method %s in class %s is not a valid %s callback method. Method must not " + "have any parameters. " ; String message = String . format ( pattern , method . getName ( ) , method . getDeclaringClass ( ) . getName ( ) , callbackType ) ; throw new EntityManagerException ( message ) ; } if ( method . getReturnType ( ) != void . class ) { String message = String . format ( "Method %s in class %s must have a return type of %s" , method . getName ( ) , method . getDeclaringClass ( ) . getName ( ) , void . class . getName ( ) ) ; throw new EntityManagerException ( message ) ; } }
Validates the given method to ensure if it is a valid callback method for the given event type .