private List < Class < ? > > getValidJPAAnnotationsFromMethod ( Class < ? > clazz , Method method , int numberOfParams , Class < ? > entityClazz ) { List < Class < ? > > annotations = new ArrayList < Class < ? > > ( ) ; for ( Annotation methodAnnotation : method . getAnnotations ( ) ) { Class < ? > methodAnnotationType = methodAnnotation . annotationType ( ) ; if ( isValidJPAEntityListenerAnnotation ( methodAnnotationType ) ) { // verify method signature // verify exceptions boolean hasUncheckedExceptions = false ; for ( Class < ? > exception : method . getExceptionTypes ( ) ) { if ( ! ReflectUtils . hasSuperClass ( RuntimeException . class , exception ) ) { hasUncheckedExceptions = true ; break ; } } if ( hasUncheckedExceptions ) { log . info ( "Skipped method(" + clazz . getName ( ) + "." + method . getName ( ) + ") Must not throw unchecked exceptions." ) ; continue ; } // return type must be "void" if ( ! method . getReturnType ( ) . getSimpleName ( ) . equals ( "void" ) ) { log . info ( "Skipped method(" + clazz . getName ( ) + "." + method . getName ( ) + ") Must have \"void\" return type." ) ; continue ; } // argument must be an Entity or Object Class < ? > [ ] paramTypes = method . getParameterTypes ( ) ; if ( paramTypes . length != numberOfParams ) { log . info ( "Skipped method(" + clazz . getName ( ) + "." + method . getName ( ) + ") Must have " + numberOfParams + " parameter." ) ; continue ; } if ( numberOfParams == 1 ) { Class < ? > parameter = paramTypes [ 0 ] ; if ( ! ( parameter != null && parameter . isAssignableFrom ( entityClazz ) ) ) { log . info ( "Skipped method(" + clazz . getName ( ) + "." + method . getName ( ) + ") Must have only 1 \"Object\" type parameter." ) ; continue ; } } annotations . add ( methodAnnotationType ) ; } } return annotations ; }
Gets the valid jpa annotations from method .