Class RandomFactory


  • public class RandomFactory
    extends java.lang.Object
    Acts as a constructor for java.util.Random objects. This avoids the anti-pattern of int randomInt = new Random().nextInt(); Which is not really random because the default seed is the current time. So this class provides the seed automatically from a master random number generator.
    • Constructor Summary

      Constructors 
      Constructor Description
      RandomFactory()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.util.Random create()
      Returns a new random number generator.
      static long getSeed()
      Returns a good seed for a random number generator.
      • Methods inherited from class java.lang.Object

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

      • RandomFactory

        public RandomFactory()
    • Method Detail

      • create

        public static java.util.Random create()
        Returns a new random number generator.
        Returns:
        a new random number generator.
      • getSeed

        public static long getSeed()
        Returns a good seed for a random number generator.
        Returns:
        a good seed for a random number generator.