updates for 0.9.4
[debian/openrocket] / 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          * The values are taken as sequential numbers, and will re-occur in 
13          * later executions of the program.
14          * <p>
15          * This method is thread-safe and fast.
16          * 
17          * @return      a positive integer ID unique in this program execution.
18          */
19         public static int next() {
20                 return nextId.getAndIncrement();
21         }
22
23         
24         /**
25          * Return a new universally unique ID string.
26          * 
27          * @return      a unique identifier string.
28          */
29         public static String uuid() {
30                 return UUID.randomUUID().toString();
31         }
32         
33 }