### Generate UUIDs using JUG CLI Source: https://github.com/cowtowncoder/java-uuid-generator/blob/main/README.md Illustrates how to use the JUG JAR file as a command-line tool to generate UUIDs. This example shows generating 5 random-based UUIDs. ```bash java -jar target/java-uuid-generator-5.1.0-SNAPSHOT.jar -c 5 r ``` -------------------------------- ### Construct UUID from String (JDK) Source: https://github.com/cowtowncoder/java-uuid-generator/blob/main/README.md Shows the standard JDK method for constructing a `java.util.UUID` from a String. Note that JUG's `UUIDUtil.uuid(String)` is generally faster. ```java UUID uuidFromStr = UUID.fromString("ebb8e8fe-b1b1-11d7-8adb-00b0d078fa18"); ``` -------------------------------- ### Customize and Reuse Time-Based Generator Source: https://github.com/cowtowncoder/java-uuid-generator/blob/main/README.md Shows how to create a custom time-based UUID generator instance, potentially configured with a specific network interface, and reuse it for multiple generations. ```java TimeBasedGenerator gen = Generators.timeBasedGenerator(EthernetAddress.fromInterface()); UUID uuid = gen.generate(); UUID anotherUuid = gen.generate(); ``` -------------------------------- ### Generate UUIDs using JUG CLI (older versions) Source: https://github.com/cowtowncoder/java-uuid-generator/blob/main/README.md Provides the command-line invocation for older JUG versions (prior to 4.1) where the JAR metadata did not specify a 'Main-Class', requiring explicit class path usage. ```bash java -cp target/java-uuid-generator-5.1.0-SNAPSHOT.jar com.fasterxml.uuid.Jug -c 5 r ``` -------------------------------- ### Generate Various UUID Versions Source: https://github.com/cowtowncoder/java-uuid-generator/blob/main/README.md Demonstrates generating different versions of UUIDs using the JUG library. Supports time-based (v1, v6, v7), random-based (v4), and name-based (v5) generators. ```java UUID uuid = Generators.timeBasedGenerator().generate(); // Version 1 UUID uuid = Generators.randomBasedGenerator().generate(); // Version 4 UUID uuid = Generators.nameBasedGenerator().generate("string to hash"); // Version 5 // With JUG 4.1+: support for https://github.com/uuid6/uuid6-ietf-draft versions 6 and 7: UUID uuid = Generators.timeBasedReorderedGenerator().generate(); // Version 6 UUID uuid = Generators.timeBasedEpochGenerator().generate(); // Version 7 // With JUG 5.0 added variation: UUID uuid = Generators.timeBasedEpochRandomGenerator().generate(); // Version 7 with per-call random values ``` -------------------------------- ### Construct UUID from String and Byte Array Source: https://github.com/cowtowncoder/java-uuid-generator/blob/main/README.md Demonstrates using `UUIDUtil` for efficient conversion of String and byte array representations into `java.util.UUID` objects. This is an optimized alternative to `java.util.UUID.fromString()`. ```java UUID uuidFromStr = UUIDUtil.uuid("ebb8e8fe-b1b1-11d7-8adb-00b0d078fa18"); byte[] rawUuidBytes = ...; // byte array with 16 bytes UUID uuidFromBytes = UUIDUtil.uuid(rawUuidBytes) ``` -------------------------------- ### Use Default Time-Based Generator Source: https://github.com/cowtowncoder/java-uuid-generator/blob/main/README.md Illustrates using the `defaultTimeBasedGenerator` factory method, which attempts to automatically detect the default network interface for creating a Version 1 UUID generator. This is suitable for common usage scenarios. ```java TimeBasedGenerator gen = Generators.defaultTimeBasedGenerator(); UUID uuid = gen.generate(); UUID anotherUuid = gen.generate(); ``` -------------------------------- ### UUID Comparison Issue in JDK Source: https://github.com/cowtowncoder/java-uuid-generator/blob/main/README.md Illustrates the flawed `compareTo()` implementation in JDK's `java.util.UUID` which uses naive 64-bit comparison, leading to incorrect ordering for unsigned values. Always use an external comparator like `com.fasterxml.uuid.UUIDComparator` for correct unsigned or lexicographical sorting. ```text 7f905a0b-bb6e-11e3-9e8f-000000000000 8028f08c-bb6e-11e3-9e8f-000000000000 ``` -------------------------------- ### Convert UUID to Byte Array Source: https://github.com/cowtowncoder/java-uuid-generator/blob/main/README.md Provides methods for converting a `java.util.UUID` object into a byte array. This is useful for external serialization or when a byte representation is required. ```java byte[] asBytes = UUIDUtil.asByteArray(uuid); // or if you have longer buffer already byte[] outputBuffer = new byte[1000]; // append at position #100 UUIDUtil.toByteArray(uuid, outputBuffer, 100); ``` -------------------------------- ### Gradle Dependency for Java UUID Generator Source: https://github.com/cowtowncoder/java-uuid-generator/blob/main/README.md Include this line in your Gradle build file to add the Java UUID Generator library. ```groovy implementation 'com.fasterxml.uuid:java-uuid-generator:5.1.0' ``` -------------------------------- ### Maven Dependency for Java UUID Generator Source: https://github.com/cowtowncoder/java-uuid-generator/blob/main/README.md Add this dependency to your Maven project to include the Java UUID Generator library. ```xml com.fasterxml.uuid java-uuid-generator 5.1.0 ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.