This is the original com.eaio.uuid
, and you can now create pull requests for features that you've implemented yourself. :)
This is an implementation of the UUIDs and GUIDs specification in Java. UUIDs are 128 bit long identifiers that are guaranteed to be unique.
Download UUID 3.4 (Source JAR)
Or get UUID through Maven:
<dependencies>
<dependency>
<groupId>com.eaio.uuid</groupId>
<artifactId>uuid</artifactId>
<version>3.4</version>
</dependency>
</dependencies>
…
<repositories>
<repository>
<id>eaio.com</id>
<url>https://repo.eaio.com/maven2</url>
</repository>
</repositories>
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. To obtain it, the following commands are invoked and their respective output parsed:
- Microsoft Windows
- ipconfig /all
- Solaris
- arp
uname -n
- arp
- Mac OS X, Linux, BSD, other Unices
- ifconfig -a
- HP-UX
- /usr/sbin/lanscan
- Solaris 11
- dladm show-phys -m
UUID is licensed under the MIT License (OSI certified).
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 Strings:
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.