Package com.github.f4b6a3.ulid.factory
Class UlidFactory
- java.lang.Object
-
- com.github.f4b6a3.ulid.factory.UlidFactory
-
- Direct Known Subclasses:
DefaultUlidFactory,MonotonicUlidFactory
public abstract class UlidFactory extends Object
An abstract factory for generating ULIDs. The only method that must be implemented iscreate(long).
-
-
Field Summary
Fields Modifier and Type Field Description protected RandomGeneratorrandomGenerator
-
Constructor Summary
Constructors Constructor Description UlidFactory()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description Ulidcreate()Returns a UUID.abstract Ulidcreate(long time)Returns a UUID with a specific time.<T extends UlidFactory>
TwithRandomGenerator(RandomGenerator randomGenerator)Replaces the default random generator with another.
-
-
-
Field Detail
-
randomGenerator
protected RandomGenerator randomGenerator
-
-
Method Detail
-
create
public Ulid create()
Returns a UUID.- Returns:
- a ULID
-
create
public abstract Ulid create(long time)
Returns a UUID with a specific time. This method must be implemented by all subclasses.- Parameters:
time- a specific time- Returns:
- a ULID
-
withRandomGenerator
public <T extends UlidFactory> T withRandomGenerator(RandomGenerator randomGenerator)
Replaces the default random generator with another. The default random generator usesSecureRandom. SeeRandom.- Type Parameters:
T- the type parameter- Parameters:
randomGenerator- a random generator- Returns:
UlidFactory
-
-