org.whitesource.utils.files.UniqueNamesGenerator Maven / Gradle / Ivy
package org.whitesource.utils.files;
import org.whitesource.utils.Constants;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.UUID;
/**
* @author raz.nitzan
*/
public class UniqueNamesGenerator {
/* --- public static methods --- */
public static String createUniqueName(String name, String extension) {
if (name == null) {
name = Constants.EMPTY_STRING;
}
if (extension == null) {
extension = Constants.EMPTY_STRING;
}
String uuid = UUID.randomUUID().toString();
//use hash as 10 character
return name + Constants.UNDERSCORE + uuid + extension;
}
}