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

webecho.tools.UniqueIdentifiers.scala Maven / Gradle / Ivy

package webecho.tools

import com.fasterxml.uuid.Generators

import java.util.UUID
import scala.util.Try

object UniqueIdentifiers {
  private val timeBasedGenerator   = Generators.timeBasedEpochRandomGenerator
  private val randomBasedGenerator = Generators.randomBasedGenerator

  def timedUUID(): UUID  = timeBasedGenerator.generate()
  def randomUUID(): UUID = randomBasedGenerator.generate()

  def getTime(uuid: UUID): Try[Long] = Try(uuid.timestamp())

  def fromString(uuid: String): Try[UUID] = Try(UUID.fromString(uuid))
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy