Skip to content

Commit

Permalink
add a type conversion from a JUG UUID to Array[Byte]
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesgolick committed Mar 19, 2010
1 parent b1c9853 commit 306d884
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/main/scala/TypeConversions.scala
@@ -1,14 +1,16 @@
package com.protose.telephos

object TypeConversions {
type ColumnMap = Map[Array[Byte], Array[Byte]]
import org.safehaus.uuid.UUID

object TypeConversions {
implicit def string2ByteArray(string: String): Array[Byte] = string.getBytes
implicit def map2ColumnMap[A <% Array[Byte], B <% Array[Byte]](map: Map[A, B]):
ColumnMap = {
Map[Array[Byte], Array[Byte]] = {
map.foldLeft(Map[Array[Byte], Array[Byte]]()) { case (map, (k, v)) =>
val tuple = (k: Array[Byte], v: Array[Byte])
map + tuple
}
}

implicit def uuid2ByteArray(uuid: UUID): Array[Byte] = uuid.asByteArray
}

0 comments on commit 306d884

Please sign in to comment.