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

org.powerscala.Unique.scala Maven / Gradle / Ivy

The newest version!
package org.powerscala

import java.util.UUID
import java.util.concurrent.ThreadLocalRandom
import scala.annotation.tailrec

/**
 * @author Matt Hicks 
 */
object Unique {
  private def r = ThreadLocalRandom.current()

  @tailrec
  final def apply(): String = new UUID(r.nextLong(), r.nextLong()).toString.replace("-", "") match {
    case s if !s.charAt(0).isDigit => s
    case s => apply()
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy