Class LegacyRandomSeeder
- java.lang.Object
-
- io.github.pr0methean.betterrandom.util.Looper
-
- io.github.pr0methean.betterrandom.seed.RandomSeeder
-
- io.github.pr0methean.betterrandom.seed.LegacyRandomSeeder
-
- All Implemented Interfaces:
Serializable
public final class LegacyRandomSeeder extends RandomSeeder
ARandomSeederthat can reseed any instance ofRandom.- Author:
- Chris Hennick
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class io.github.pr0methean.betterrandom.seed.RandomSeeder
RandomSeeder.DefaultThreadFactory
-
-
Field Summary
-
Fields inherited from class io.github.pr0methean.betterrandom.seed.RandomSeeder
byteArrayPrngs, DEFAULT_STOP_IF_EMPTY_FOR_NANOS, FIRST_POLL_INTERVAL, REPEAT_POLL_INTERVAL, seedGenerator, stopIfEmptyForNanos, waitForEntropyDrain, waitWhileEmpty
-
Fields inherited from class io.github.pr0methean.betterrandom.util.Looper
DEFAULT_THREAD_FACTORY, factory, lock, thread, threadLock
-
-
Constructor Summary
Constructors Constructor Description LegacyRandomSeeder(SeedGenerator seedGenerator)Creates an instance using aRandomSeeder.DefaultThreadFactory.LegacyRandomSeeder(SeedGenerator seedGenerator, ThreadFactory threadFactory)Creates an instance whose thread will terminate if no PRNGs have been associated with it for 5 seconds.LegacyRandomSeeder(SeedGenerator seedGenerator, ThreadFactory threadFactory, long stopIfEmptyForNanos)Creates an instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddLegacyRandoms(Collection<? extends Random> randoms)AddsRandominstances.voidaddLegacyRandoms(Random... randoms)AddsRandominstances.protected voidclear()Removes all PRNGs from this seeder.booleancontains(Object random)Checks whether the given PRNG is currently registered with this RandomSeeder.protected voidinitTransientFields()Initializes the transient instance fields for this class.booleanisEmpty()Returns true if noRandominstances are registered with this LegacyRandomSeeder.protected booleaniterate()The task that will be iterated until it returns false.voidremoveLegacyRandoms(Collection<?> randoms)Removes instances ofRandomand/orByteArrayReseedableRandom.voidremoveLegacyRandoms(Random... randoms)RemovesRandominstances.StringtoString()-
Methods inherited from class io.github.pr0methean.betterrandom.seed.RandomSeeder
add, add, equals, getSeedGenerator, hashCode, remove, remove, reseedByteArrayReseedableRandoms, reseedWithLong, shutDown, stillEmptyAfterWaiting, stopIfEmpty, unregisterWithAll, waitForEntropyDrainOrUpdateFlag, wakeUp
-
-
-
-
Constructor Detail
-
LegacyRandomSeeder
public LegacyRandomSeeder(SeedGenerator seedGenerator, ThreadFactory threadFactory)
Creates an instance whose thread will terminate if no PRNGs have been associated with it for 5 seconds.- Parameters:
seedGenerator- the seed generatorthreadFactory- theThreadFactorythat will create this seeder's thread
-
LegacyRandomSeeder
public LegacyRandomSeeder(SeedGenerator seedGenerator, ThreadFactory threadFactory, long stopIfEmptyForNanos)
Creates an instance.- Parameters:
seedGenerator- the seed generatorthreadFactory- theThreadFactorythat will create this seeder's threadstopIfEmptyForNanos- time in nanoseconds after which this thread will terminate if no PRNGs are attached
-
LegacyRandomSeeder
public LegacyRandomSeeder(SeedGenerator seedGenerator)
Creates an instance using aRandomSeeder.DefaultThreadFactory.- Parameters:
seedGenerator- the seed generator
-
-
Method Detail
-
initTransientFields
protected void initTransientFields()
Description copied from class:RandomSeederInitializes the transient instance fields for this class. Called by constructors and during deserialization.- Overrides:
initTransientFieldsin classRandomSeeder
-
removeLegacyRandoms
public void removeLegacyRandoms(Random... randoms)
RemovesRandominstances.- Parameters:
randoms- the instances to remove
-
removeLegacyRandoms
public void removeLegacyRandoms(Collection<?> randoms)
Removes instances ofRandomand/orByteArrayReseedableRandom.- Parameters:
randoms- the instances to remove
-
addLegacyRandoms
public void addLegacyRandoms(Random... randoms)
AddsRandominstances.- Parameters:
randoms- the PRNGs to start reseeding
-
addLegacyRandoms
public void addLegacyRandoms(Collection<? extends Random> randoms)
AddsRandominstances.- Parameters:
randoms- the PRNGs to start reseeding
-
contains
public boolean contains(Object random)
Description copied from class:RandomSeederChecks whether the given PRNG is currently registered with this RandomSeeder.- Overrides:
containsin classRandomSeeder- Parameters:
random- the PRNG to check the status of- Returns:
- true if registered; false if not
-
iterate
protected boolean iterate()
Description copied from class:LooperThe task that will be iterated until it returns false. Cannot be abstract for serialization reasons, but must be overridden in subclasses if they are instantiated without a targetRunnable.- Overrides:
iteratein classRandomSeeder- Returns:
- true if this thread should iterate again.
-
isEmpty
public boolean isEmpty()
Description copied from class:RandomSeederReturns true if noRandominstances are registered with this LegacyRandomSeeder.- Overrides:
isEmptyin classRandomSeeder- Returns:
- true if no
Randominstances are registered with this LegacyRandomSeeder.
-
clear
protected void clear()
Description copied from class:RandomSeederRemoves all PRNGs from this seeder.- Overrides:
clearin classRandomSeeder
-
-