create changelog entry
[debian/openrocket] / core / src / net / sf / openrocket / util / UniqueID.java
1 package net.sf.openrocket.util;
2
3 import java.util.UUID;
4 import java.util.concurrent.atomic.AtomicInteger;
5
6 public class UniqueID {
7         
8         private static AtomicInteger nextId = new AtomicInteger(1);
9         
10         /**
11          * Return a positive integer ID unique during this program execution.
12          * <p>
13          * The following is guaranteed of the returned ID values:
14          * <ul>
15          *      <li>The value is unique during this program execution
16          *      <li>The value is positive
17          *      <li>The values are monotonically increasing
18          * </ul>
19          * <p>
20          * This method is thread-safe and fast.
21          * 
22          * @return      a positive integer ID unique in this program execution.
23          */
24         public static int next() {
25                 return nextId.getAndIncrement();
26         }
27
28         
29         /**
30          * Return a new universally unique ID string.
31          * 
32          * @return      a unique identifier string.
33          */
34         public static String uuid() {
35                 return UUID.randomUUID().toString();
36         }
37         
38 }