![]() ![]() JUG jar built under target/: target/java-uuid-generator-4.1.1-SNAPSHOT.jarĬan also be used as a simple Command-line UUID generation tool. Measuring performance of Java omString(). It is rather slower than JUG version: for more information, read Note that while JDK has functionality for constructing UUID from String, like so: UUID uuidFromStr = omString("ebb8e8fe-b1b1-11d7-8adb-00b0d078fa18") UUID uuidFromBytes = UUIDUtil.uuid(rawUuidBytes) JUG has optimized conversion functionality available via class UUIDUtil (packageĬom.), used as follows: UUID uuidFromStr = UUIDUtil.uuid("ebb8e8fe-b1b1-11d7-8adb-00b0d078fa18") īyte rawUuidBytes =. UUID values are often passed as java Strings or bytes (byte arrays),Īnd conversion is needed to get to actual instances. UUIDUtil.toByteArray(uuid, outputBuffer, 100) Ĭonstructing values from String, byte Sometimes you may want to convert from into external serialization:įor example, as Strings or byte arrays ( byte).Ĭonversion to String is easy with UUID.toString() (provided by JDK), but there is no similar functionality for converting into byte.īut UUIDUtil class provides methods for efficient conversions: byte asBytes = UUIDUtil.asByteArray(uuid) Javadocs for further information can be found from Project Wiki. Generators are fully thread-safe, so a single instance may be shared among multiple threads. This is likely a good choice for common usage scenarios if you want a version 1 UUID generator: TimeBasedGenerator gen = Generators.egressTimeBasedGenerator() If your machine has a standard IP networking setup, the Generators.egressTimeBasedGenerator (added in JUG 4.1)įactory method will try to determine which network interface corresponds to the default route forĪll outgoing network traffic, and use that for creating a time based generator. If you want customize generators, you may also just want to hold on to generator instance: TimeBasedGenerator gen = Generators.timeBasedGenerator(omInterface()) UUID uuid = Generators.timeBasedGenerator().generate() This is done by first selecting a kind of generator to use, and then calling its generate() method.įor example: UUID uuid = Generators.randomBasedGenerator().generate() The original use case for JUG was generation of UUID values. Downloadsįor direct downloads, check out Project Wiki. Since version 3.2.0, JUG defines JDK9+ compatible module-info.class, with module name of. For versions 4.x and up, slf4j API is used: logging implementation to be provided by calling application.For versions up to 3.x, log4j is used, optionally (runtime dependency).The only dependency for JUG is the logging library: JUG can be used as a command-line tool (via class ), JUG is licensed under Apache License 2.0. In addition, many other individuals have helped fix bugs and implement new features: please see release-notes/CREDITS for the complete list. JUG was written by Tatu Saloranta ( ) originally in 2002 and has been updated over the years. (also see Wikipedia UUID page for more explanation) It generates UUIDs according to the UUID specification (RFC-4122) JUG is a set of Java classes for working with UUIDs: generating UUIDs using any of standard methods, outputting
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |