Package org.uncommons.maths.random
Class DefaultSeedGenerator
- java.lang.Object
-
- org.uncommons.maths.random.DefaultSeedGenerator
-
- All Implemented Interfaces:
SeedGenerator
public final class DefaultSeedGenerator extends java.lang.Object implements SeedGenerator
Seed generator that maintains multiple strategies for seed generation and will delegate to the best one available for the current operating environment.
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String
DEBUG_PROPERTY
private static SeedGenerator[]
GENERATORS
Delegate generators.private static DefaultSeedGenerator
INSTANCE
Singleton instance.
-
Constructor Summary
Constructors Modifier Constructor Description private
DefaultSeedGenerator()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]
generateSeed(int length)
Generates a seed by trying each of the available strategies in turn until one succeeds.static DefaultSeedGenerator
getInstance()
-
-
-
Field Detail
-
DEBUG_PROPERTY
private static final java.lang.String DEBUG_PROPERTY
- See Also:
- Constant Field Values
-
INSTANCE
private static final DefaultSeedGenerator INSTANCE
Singleton instance.
-
GENERATORS
private static final SeedGenerator[] GENERATORS
Delegate generators.
-
-
Method Detail
-
getInstance
public static DefaultSeedGenerator getInstance()
- Returns:
- The singleton instance of this class.
-
generateSeed
public byte[] generateSeed(int length)
Generates a seed by trying each of the available strategies in turn until one succeeds. Tries the most suitable strategy first and eventually degrades to the least suitable (but guaranteed to work) strategy.- Specified by:
generateSeed
in interfaceSeedGenerator
- Parameters:
length
- The length (in bytes) of the seed.- Returns:
- A random seed of the requested length.
-
-