question: public static String generateRandomFinNumber ( Delegator delegator , int length , boolean isId ) throws GenericEntityException { if ( length > 19 ) { length = 19 ; } Random rand = new Random ( ) ; boolean isValid = false ; String number = null ; while ( ! isValid ) { number = "" ; for ( int i = 0 ; i < length ; i ++ ) { int randInt = rand . nextInt ( 9 ) ; number = number + randInt ; } if ( isId ) { int check = UtilValidate . getLuhnCheckDigit ( number ) ; number = number + check ; if ( checkFinAccountNumber ( number ) ) { isValid = checkIsNumberInDatabase ( delegator , number ) ; } } else { isValid = true ; } } return number ; }
target:  Generate a random financial number