Module com.github.f4b6a3.uuid
Package com.github.f4b6a3.uuid.factory
Class AbstRandomBasedFactory.Builder<T,B extends AbstRandomBasedFactory.Builder<T,B>>
- java.lang.Object
-
- com.github.f4b6a3.uuid.factory.AbstRandomBasedFactory.Builder<T,B>
-
- Type Parameters:
T- factory typeB- builder type
- Direct Known Subclasses:
AbstCombFactory.Builder,RandomBasedFactory.Builder
- Enclosing class:
- AbstRandomBasedFactory
protected abstract static class AbstRandomBasedFactory.Builder<T,B extends AbstRandomBasedFactory.Builder<T,B>> extends Object
Abstract builder for creating a random-based factory.
-
-
Field Summary
Fields Modifier and Type Field Description protected AbstRandomBasedFactory.IRandomrandomA random generator.
-
Constructor Summary
Constructors Modifier Constructor Description protectedBuilder()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract Tbuild()Finishes the factory building.protected AbstRandomBasedFactory.IRandomgetRandom()Get the random generator.BwithFastRandom()Set the random generator with a fast algorithm.BwithRandom(Random random)Set the random generator.BwithRandomFunction(LongSupplier randomFunction)Set a random function which returns random numbers.BwithSafeRandom()Set the random generator with a safe algorithm.
-
-
-
Field Detail
-
random
protected AbstRandomBasedFactory.IRandom random
A random generator.
-
-
Method Detail
-
getRandom
protected AbstRandomBasedFactory.IRandom getRandom()
Get the random generator.- Returns:
- a random generator
-
withFastRandom
public B withFastRandom()
Set the random generator with a fast algorithm. Use it to replace theDefaultRandomFunctionwithThreadLocalRandom.- Returns:
- the generator
-
withSafeRandom
public B withSafeRandom()
Set the random generator with a safe algorithm. Use it to replace theDefaultRandomFunctionwithSecureRandom.- Returns:
- the generator
-
withRandom
public B withRandom(Random random)
Set the random generator.- Parameters:
random- a random- Returns:
- the builder
-
withRandomFunction
public B withRandomFunction(LongSupplier randomFunction)
Set a random function which returns random numbers.- Parameters:
randomFunction- a function- Returns:
- the builder
-
build
public abstract T build()
Finishes the factory building.- Returns:
- the build factory
-
-