Skip to content

Instantly share code, notes, and snippets.

@cokeSchlumpf
Created July 7, 2014 19:25
Show Gist options
  • Save cokeSchlumpf/bbad848d4c44aadd7fa7 to your computer and use it in GitHub Desktop.
Save cokeSchlumpf/bbad848d4c44aadd7fa7 to your computer and use it in GitHub Desktop.
Slick Column Mapper for wellnr commons Enumerations
/**
* Returns a mapper for an enumeration.
*
* @param enumeration
* The Enumeration object.
* @tparam ENUM
* The type of the enumeration.
* @return
* The mapper column mapper for the enumeration.
*/
def enumColumnType[ENUM <: EnumerationCapabilities](enumeration: ENUM)(implicit classTag: ClassTag[enumeration.type#ENUM_TYPE]) =
MappedColumnType.base[enumeration.type#ENUM_TYPE, String](
enumValue => enumeration.asString(enumValue),
stringValue => enumeration.forString(stringValue))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment