1 package net.sf.openrocket.util;
4 import java.util.concurrent.atomic.AtomicInteger;
6 public class UniqueID {
8 private static AtomicInteger nextId = new AtomicInteger(1);
11 * Return a positive integer ID unique during this program execution.
13 * The following is guaranteed of the returned ID values:
15 * <li>The value is unique during this program execution
16 * <li>The value is positive
17 * <li>The values are monotonically increasing
20 * This method is thread-safe and fast.
22 * @return a positive integer ID unique in this program execution.
24 public static int next() {
25 return nextId.getAndIncrement();
30 * Return a new universally unique ID string.
32 * @return a unique identifier string.
34 public static String uuid() {
35 return UUID.randomUUID().toString();