All Downloads are FREE. Search and download functionalities are using the official Maven repository.

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;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy