@ SuppressWarnings ( "unchecked" ) private String getConfigPropertyType ( Annotation annotation , Class < ? > type , ClassLoader classLoader ) throws ClassNotFoundException , ValidateException { if ( annotation . isOnField ( ) ) { Class clz = Class . forName ( annotation . getClassName ( ) , true , classLoader ) ; while ( ! Object . class . equals ( clz ) ) { try { Field field = SecurityActions . getDeclaredField ( clz , annotation . getMemberName ( ) ) ; if ( type == null || type . equals ( Object . class ) || type . equals ( field . getType ( ) ) ) { return field . getType ( ) . getName ( ) ; } else { throw new ValidateException ( bundle . wrongAnnotationType ( annotation ) ) ; } } catch ( NoSuchFieldException nsfe ) { clz = clz . getSuperclass ( ) ; } } } else if ( annotation . isOnMethod ( ) ) { Class clz = Class . forName ( annotation . getClassName ( ) , true , classLoader ) ; Class [ ] parameters = null ; if ( annotation . getParameterTypes ( ) != null ) { parameters = new Class [ annotation . getParameterTypes ( ) . size ( ) ] ; for ( int i = 0 ; i < annotation . getParameterTypes ( ) . size ( ) ; i ++ ) { String parameter = annotation . getParameterTypes ( ) . get ( i ) ; parameters [ i ] = Class . forName ( parameter , true , classLoader ) ; } } while ( ! Object . class . equals ( clz ) ) { try { Method method = SecurityActions . getDeclaredMethod ( clz , annotation . getMemberName ( ) , parameters ) ; if ( void . class . equals ( method . getReturnType ( ) ) ) { if ( parameters != null && parameters . length > 0 ) { if ( type == null || type . equals ( Object . class ) || type . equals ( parameters [ 0 ] ) ) { return parameters [ 0 ] . getName ( ) ; } else { throw new ValidateException ( bundle . wrongAnnotationType ( annotation ) ) ; } } } else { if ( type == null || type . equals ( Object . class ) || type . equals ( method . getReturnType ( ) ) ) { return method . getReturnType ( ) . getName ( ) ; } else { throw new ValidateException ( bundle . wrongAnnotationType ( annotation ) ) ; } } } catch ( NoSuchMethodException nsme ) { clz = clz . getSuperclass ( ) ; } } } throw new IllegalArgumentException ( bundle . unknownAnnotation ( annotation ) ) ; }
Get the config - property - type for an annotation