@ SuppressWarnings ( { "ThrowableInstanceNeverThrown" } ) public static void validatePrimitiveArray ( Method method , Class type , List < Throwable > errors ) { Class returnType = method . getReturnType ( ) ; if ( ! returnType . isArray ( ) || ! returnType . getComponentType ( ) . equals ( type ) ) { errors . add ( new Exception ( "Method " + method . getName ( ) + "() should return " + type . getName ( ) + "[]" ) ) ; } }
Validate that a method returns primitive array of specific type .