Interface SeedGenerator
-
- All Superinterfaces:
Serializable
- All Known Implementing Classes:
AnuQuantumSeedClient,BufferedSeedGenerator,DefaultSeedGenerator,DevRandomSeedGenerator,RandomDotOrgAnonymousClient,RandomDotOrgApi2Client,SecureRandomSeedGenerator,SeedGeneratorPreferenceList,WebSeedClient
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface public interface SeedGenerator extends Serializable
Strategy interface for seeding random number generators. Implementations that can have multiple equivalent instances that contend for a resource should implementObject.equals(Object)andObject.hashCode()to help with de-duplication ofRandomSeederinstances.- Author:
- Daniel Dyer, Chris Hennick
-
-
Field Summary
Fields Modifier and Type Field Description static byte[]EMPTY_SEEDAn empty byte array.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description voidgenerateSeed(byte[] output)Generates a seed value for a random number generator in an existing array.default byte[]generateSeed(int length)Generates and returns a seed value for a random number generator as a new array.default booleanisWorthTrying()Returns true if we cannot determine quickly (i.e.
-
-
-
Method Detail
-
generateSeed
void generateSeed(byte[] output) throws SeedExceptionGenerates a seed value for a random number generator in an existing array.- Parameters:
output- The array that is to be populated with the seed.- Throws:
SeedException- If a seed cannot be generated for any reason.
-
generateSeed
default byte[] generateSeed(int length) throws SeedExceptionGenerates and returns a seed value for a random number generator as a new array.- Parameters:
length- The length of the seed to generate (in bytes).- Returns:
- A byte array containing the seed data.
- Throws:
SeedException- If a seed cannot be generated for any reason.
-
isWorthTrying
default boolean isWorthTrying()
Returns true if we cannot determine quickly (i.e. without I/O calls) that this SeedGenerator would throw aSeedExceptionifgenerateSeed(int)orgenerateSeed(byte[])were being called right now.- Returns:
- true if this SeedGenerator will get as far as an I/O call or other slow operation in attempting to generate a seed immediately.
-
-