Awesome
typeid
A Java implementation of TypeID.
TypeIDs are a modern, type-safe, globally unique identifier based on the upcoming UUIDv7 standard. They provide a ton of nice properties that make them a great choice as the primary identifiers for your data in a database, APIs, and distributed systems. Read more about TypeIDs in their spec.
Installation
To add this library as a dependency in your app add the following to your build
Gradle
implementation("me.lessis:typeid:0.0.2")
Maven
<dependency>
<groupId>me.lessis</groupId>
<artifactId>typeid</artifactId>
<version>0.0.2</version>
</dependency>
Usage
import typeid.TypeID
// generate type ids (prefix_7zzzzzzzzqf3b80018tr001cg3)
var id = new TypeID("prefix");
// parse typed ids from their string representation
var parsed = TypeID.fromString(id.toString());
// this is a fallible operation so the value returned
// is an Optional, present when values are valid, empty when not
parsed.ifPresent(
id -> {
System.out.println(
"prefix %s suffix %s".formmated(
id.prefix(), id.suffix();
)
);
}
);
// get a java.util.UUID representation of a type id (ffffffff-fff7-78d6-8000-28d60000b203)
id.uuid();