gilt / gfc-id

A library that contains typed Id and Guid (UUID) classes

Version Matrix

gfc-id Maven Central Build Status Coverage Status Join the chat at

A library that contains typed Id and Guid classes. Part of the Gilt Foundation Classes.

Getting gfc-id

The latest version is 0.0.7, which is cross-built against Scala 2.10.x, 2.11.x and 2.12.x.

If you're using SBT, add the following line to your build file:

libraryDependencies += "com.gilt" %% "gfc-id" % "0.0.7"

For Maven and other build tools, you can visit (This search will also list other available libraries from the gilt fundation classes.)

Contents and Example Usage

Typed identifiers allow compile-time checking that an identifier that is passed into a function or object is of the correct type, which is not the case with "untyped" String, Long or UUID types.

Guid is a space/cpu efficient and type safe replacement for java.util.UUID

val userGuid: Guid[User] = Guid.randomGuid
val user: User = new User(userGuid, firstName, lastName)

Id can be used for typed identifiers (e.g. rdbms auto-increment ids).

val userId: Id[User, Long] = Random.nextLong
val user: User = new User(userId, firstName, lastName)

Type aliases

Both Guid and Id can be used in conjunction with type aliases:

type UserGuid = Guid[User]
type UserId = Id[User, Long]
case class User(guid: UserGuid, id: UserId, firstName: String, lastName: String)


Copyright 2016 Gilt Groupe, Inc.

Licensed under the Apache License, Version 2.0: