Class KRandom

  • All Implemented Interfaces:
    java.io.Serializable , java.util.random.RandomGenerator

    
    public class KRandom
    extends Random
                        

    Extension of java.util.Random that is able to generate random Java objects.

    Author:

    Mahmoud Ben Hassine ([email protected])

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      <T> T nextObject(Class<T> type) Generate a random instance of the given type.
      <T> Stream<T> objects(Class<T> type, int streamSize) Generate a stream of random instances of the given type.
      • Methods inherited from class java.util.Random

        doubles, from, ints, longs, nextBoolean, nextBytes, nextDouble, nextFloat, nextGaussian, nextInt, nextLong, setSeed
      • Methods inherited from class java.util.random.RandomGenerator

        getDefault, isDeprecated, nextExponential, of
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • KRandom

        KRandom()
        Create a new KRandom instance with default parameters.
      • KRandom

        KRandom(KRandomParameters kRandomParameters)
        Create a new KRandom instance.
        Parameters:
        kRandomParameters - randomization parameters
    • Method Detail

      • nextObject

         <T> T nextObject(Class<T> type)

        Generate a random instance of the given type.

        Parameters:
        type - the type for which an instance will be generated
        Returns:

        a random instance of the given type

      • objects

         <T> Stream<T> objects(Class<T> type, int streamSize)

        Generate a stream of random instances of the given type.

        Parameters:
        type - the type for which instances will be generated
        streamSize - the number of instances to generate
        Returns:

        a stream of random instances of the given type