Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
UUID |
|
| 1.0;1 |
1 | /* | |
2 | * $Id: UUID.java 19191 2010-08-25 21:05:23Z tcarlson $ | |
3 | * -------------------------------------------------------------------------------------- | |
4 | * Copyright (c) MuleSoft, Inc. All rights reserved. http://www.mulesoft.com | |
5 | * | |
6 | * The software in this package is published under the terms of the CPAL v1.0 | |
7 | * license, a copy of which has been included with this distribution in the | |
8 | * LICENSE.txt file. | |
9 | */ | |
10 | ||
11 | package org.mule.util; | |
12 | ||
13 | import org.safehaus.uuid.UUIDGenerator; | |
14 | ||
15 | /** | |
16 | * <code>UUID</code> Generates a UUID using JDK 5. THe reason for this class is that we have changed the UUID impl in the past. | |
17 | * using this class makes it easy to switch out implementations | |
18 | */ | |
19 | // @ThreadSafe | |
20 | public final class UUID | |
21 | { | |
22 | private UUID() | |
23 | 0 | { |
24 | // no go | |
25 | 0 | } |
26 | ||
27 | public static String getUUID() | |
28 | { | |
29 | 0 | return java.util.UUID.randomUUID().toString(); |
30 | } | |
31 | ||
32 | /** | |
33 | * Generates incremental and unique ids. | |
34 | * | |
35 | * @return an id that will be different from the previous ones. | |
36 | */ | |
37 | public static String getAscendingOrderUUID() | |
38 | { | |
39 | // The timeBasedUUID will generate strictly incremental unique ids. | |
40 | // Sorting all the ids will give us the ids in the order that were | |
41 | // generated. | |
42 | 0 | return UUIDGenerator.getInstance().generateTimeBasedUUID().toString(); |
43 | } | |
44 | ||
45 | } |