You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
importtypeid.TypeID// generate type ids (prefix_7zzzzzzzzqf3b80018tr001cg3)varid = newTypeID("prefix");
// parse typed ids from their string representationvarparsed = TypeID.fromString(id.toString());
// this is a fallible operation so the value returned// is an Optional, present when values are valid, empty when notparsed.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();
About
A Java implementation of TypeID (Type-safe, K-sortable, globally unique identifier inspired by Stripe IDs).