Package org.uncommons.maths.random
Class DefaultSeedGenerator
java.lang.Object
org.uncommons.maths.random.DefaultSeedGenerator
- All Implemented Interfaces:
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
FieldsModifier and TypeFieldDescriptionprivate static final String
private static final SeedGenerator[]
Delegate generators.private static final DefaultSeedGenerator
Singleton instance. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbyte[]
generateSeed
(int length) Generates a seed by trying each of the available strategies in turn until one succeeds.static DefaultSeedGenerator
-
Field Details
-
DEBUG_PROPERTY
- See Also:
-
INSTANCE
Singleton instance. -
GENERATORS
Delegate generators.
-
-
Constructor Details
-
DefaultSeedGenerator
private DefaultSeedGenerator()
-
-
Method Details
-
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.
-