UUID
Generate UUIDs (or GUIDs) in Java
This is an implementation of the UUIDs and GUIDs specification in Java. UUIDs are 128 bit long identifiers that are guaranteed to be unique.
Watch StarDownload
Documentation
A UUID (or GUID) is a unique identifier that can be created whithout a central authority. UUIDs can be used if a sequence number is not good enough. This implementation is thread safe and very fast.
UUID generates version 1 UUIDs that contain the the MAC address of a network card.
UUID is licensed under the MIT License (OSI certified).
Example code
UUID is very easy to use.
import com.eaio.uuid.UUID; public class UUIDTest { public static void main(String[] args) { UUID u = new UUID(); System.out.println(u); } }
You can assemble UUIDs yourself:
UUID u = new UUID(4242L, 4242L);
Of course, comparing and equality testing is fully implemented:
UUID u1 = new UUID(4242L, 0L); UUID u2 = new UUID(5203L, 9412); System.out.println(u1.equals(u2)); // prints out "false" System.out.println(u1.compareTo(u2)); // prints out "-1"
As well as cloning:
UUID u1 = new UUID(4242L, 0L); UUID u2 = (UUID) u1.clone(); UUID u3 = new UUID(u1); // or use the clone constructor
And parsing from String
s:
UUID u = new UUID("00000000-0000-002a-0000-00000000002a");
Keep in mind that this UUID implementation has public field, so cloning should be used for security purposes between in-VM system boundaries.
Maven
To get UUID through Maven, add the following to your pom.xml
:
<dependencies> <dependency> <groupId>com.eaio.uuid</groupId> <artifactId>uuid</artifactId> <version>3.5</version> </dependency> </dependencies> … <repositories> <repository> <id>eaio.com</id> <url>https://repo.eaio.com/maven2</url> </repository> </repositories>
Other resources
Subscribe
RSS 2.0, Atom or subscribe by Email.
Top Posts
- DynaCloud - a dynamic JavaScript tag/keyword cloud with jQuery
- 6 fast jQuery Tips: More basic Snippets
- xslt.js version 3.2 released
- xslt.js version 3.0 released XML XSLT now with jQuery plugin
- Forum Scanners - prevent forum abuse
- Automate JavaScript compression with YUI Compressor and /packer/