(patch) update to latest scala, minor documentation/code improvements #17

Merged
pfm merged 1 commit from latest-scala into main 2026-04-07 03:50:46 +00:00
5 changed files with 52 additions and 7 deletions

View file

@ -1,5 +1,5 @@
// See: https://github.com/scalameta/scalafmt/tags for the latest tags.
version = 3.10.4
version = 3.10.7
runner.dialect = scala3
maxColumn = 80

View file

@ -1,4 +1,4 @@
val scala3: String = "3.8.1"
val scala3: String = "3.8.3"
ThisBuild / scalaVersion := scala3
ThisBuild / versionScheme := Some("semver-spec")
@ -20,7 +20,7 @@ val sharedSettings = Seq(
lazy val testSettings = Seq(
libraryDependencies ++= Seq(
"org.scalameta" %% "munit" % "1.2.1" % Test
"org.scalameta" %% "munit" % "1.2.4" % Test
)
)
@ -31,6 +31,6 @@ lazy val `gs-uuid` = project
.settings(name := s"${gsProjectName.value}-v${semVerMajor.value}")
.settings(
libraryDependencies ++= Seq(
"com.fasterxml.uuid" % "java-uuid-generator" % "5.1.0"
"com.fasterxml.uuid" % "java-uuid-generator" % "5.2.0"
)
)

View file

@ -1 +1 @@
sbt.version=1.12.0
sbt.version=1.12.8

View file

@ -2,8 +2,8 @@ package gs.uuid.v0
import com.fasterxml.uuid.Generators
/** Alias for the `java.util.UUID` type, which represents a 128-bit (16-byte)
* value.
/** `gs.uuid.v0.UUID` is an alias for the `java.util.UUID` type, which
* represents a 128-bit (16-byte) value.
*
* ## ID Generation
*
@ -26,6 +26,28 @@ import com.fasterxml.uuid.Generators
*/
opaque type UUID = java.util.UUID
/** `gs.uuid.v0.UUID` is an alias for the `java.util.UUID` type, which
* represents a 128-bit (16-byte) value.
*
* ## ID Generation
*
* This library provides generator implementations for the following types of
* UUID:
*
* - Type 4: `UUID.v4()`
* - Type 7: `UUID.v7()`
*
* These implementations are provided by JUG.
*
* ## Serialization
*
* This library supports the following representations:
*
* - Hexadecimal string without dashes
* - Byte array
*
* Serialization code is based on Jackson Databind (Apache 2.0).
*/
object UUID:
/** Express any `java.util.UUID` as a GS UUID.
*
@ -66,6 +88,13 @@ object UUID:
G: Generator
): UUID = G.next()
/** Alias for `v4()`.
*
* @return
* New v4 UUID (Random).
*/
def random(): UUID = v4()
/** @return
* New v4 UUID (Random).
*/
@ -101,6 +130,12 @@ object UUID:
.getOrElse(None)
extension (uid: UUID)
/** @return
* The unwrapped value -- the underlying `java.util.UUID`.
*/
def unwrap(): java.util.UUID = uid
/** @return
* The underlying `java.util.UUID`.
*/

View file

@ -5,6 +5,15 @@ class UUIDTests extends munit.FunSuite:
private val v7 = UUID.Generator.version7
given CanEqual[java.util.UUID, java.util.UUID] = CanEqual.derived
test(
"should instantiate a random UUID, serialize it, and parse the result"
) {
val base = UUID.random()
val str = base.str()
val parsed = UUID.parse(str)
assertEquals(parsed, Some(base))
}
test(
"should instantiate a type 4 UUID, serialize it, and parse the result"
) {
@ -48,6 +57,7 @@ class UUIDTests extends munit.FunSuite:
val parsed = UUID.fromString(str)
assertEquals(parsed, Some(base))
assertEquals(parsed.map(_.toUUID()), Some(raw))
assertEquals(parsed.map(_.unwrap()), Some(raw))
}
test("should successfully parse a UUID with dashes") {