public E getNextValue ( ) throws ValueGenerationException { if ( ! isValid ( ) ) throw new ValueGenerationException ( "Cannot provide elements in invalid state." ) ; Double random = rand . nextDouble ( ) ; for ( int i = 0 ; i < limits . size ( ) ; i ++ ) if ( random <= limits . get ( i ) ) { return keys . get ( i ) ; } return null ; }
Conducts a stochastic element choice based on the maintained occurrence probabilities .