/*
 * Copyright 2015 Delft University of Technology
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package nl.tudelft.graphalytics.util;

import java.util.UUID;

/**
 * @author Wing Lung Ngai
 */
public class UuidUtil {

    public static String getRandomUUID() {
        return String.valueOf(UUID.randomUUID().getLeastSignificantBits() * -1l);
    }

    public static String getRandomUUID(String prefix, int length) {
        return prefix + String.valueOf(UUID.randomUUID().getLeastSignificantBits() * -1l).substring(0, length);
    }

    public static String getRandomUUID(int length) {
        return getRandomUUID("", length);
    }

}

@@ -651,16 +651,64 @@
 .util;%0A%0A
+import java.util.HashSet;%0Aimport java.util.Set;%0A
 import j
@@ -791,60 +791,257 @@
    p
-ublic static String getRandomUUID() %7B%0A        return
+rivate static Set%3CString%3E usedUUIDs = new HashSet%3C%3E();%0A%0A    public static String getRandomUUID() %7B%0A        String uuid = String.valueOf(UUID.randomUUID().getLeastSignificantBits() * -1l);%0A%0A        while(usedUUIDs.contains(uuid)) %7B%0A            uuid =
  Str
@@ -1104,16 +1104,77 @@
 * -1l);%0A
+        %7D%0A        usedUUIDs.add(uuid);%0A%0A        return uuid;%0A
     %7D%0A%0A 
@@ -1248,22 +1248,29 @@
         
-return
+String uuid =
  prefix 
@@ -1278,38 +1278,36 @@
  String.valueOf(
-UUID.r
+getR
 andomUUID().getL
@@ -1306,61 +1306,215 @@
 D().
-getLeastSignificantBits() * -1l).substring(0, length)
+substring(0, length));%0A%0A        while(usedUUIDs.contains(uuid)) %7B%0A            uuid = prefix + String.valueOf(getRandomUUID().substring(0, length));%0A        %7D%0A        usedUUIDs.add(uuid);%0A%0A        return uuid
 ;%0A  

Make sure short UUIDs are unique in the same benchmark.