From cd1b635b2ae90d9ac2d8b1779183a1fbd8c5fd5c Mon Sep 17 00:00:00 2001 From: vlad Date: Tue, 13 Jun 2017 16:12:20 -0700 Subject: Adding domain entities --- src/main/scala/xyz/driver/common/domain/Id.scala | 51 ------------------------ 1 file changed, 51 deletions(-) delete mode 100644 src/main/scala/xyz/driver/common/domain/Id.scala (limited to 'src/main/scala/xyz/driver/common/domain/Id.scala') diff --git a/src/main/scala/xyz/driver/common/domain/Id.scala b/src/main/scala/xyz/driver/common/domain/Id.scala deleted file mode 100644 index 9f9604e..0000000 --- a/src/main/scala/xyz/driver/common/domain/Id.scala +++ /dev/null @@ -1,51 +0,0 @@ -package xyz.driver.common.domain - -import java.util.UUID - -import xyz.driver.common.logging._ - -sealed trait Id[+T] - -case class CompoundId[Id1 <: Id[_], Id2 <: Id[_]](part1: Id1, part2: Id2) extends Id[(Id1, Id2)] - -case class LongId[+T](id: Long) extends Id[T] { - override def toString: String = id.toString - - def is(longId: Long): Boolean = { - id == longId - } -} - -object LongId { - implicit def toPhiString[T](x: LongId[T]): PhiString = Unsafe(s"LongId(${x.id})") -} - -case class StringId[+T](id: String) extends Id[T] { - override def toString: String = id - - def is(stringId: String): Boolean = { - id == stringId - } -} - -object StringId { - implicit def toPhiString[T](x: StringId[T]): PhiString = Unsafe(s"StringId(${x.id})") -} - -case class UuidId[+T](id: UUID) extends Id[T] { - override def toString: String = id.toString -} - -object UuidId { - - /** - * @note May fail, if `string` is invalid UUID. - */ - def apply[T](string: String): UuidId[T] = new UuidId[T](UUID.fromString(string)) - - def apply[T](): UuidId[T] = new UuidId[T](UUID.randomUUID()) - - implicit def ordering[T] = Ordering.by[UuidId[T], String](_.toString) - - implicit def toPhiString[T](x: UuidId[T]): PhiString = Unsafe(s"UuidId(${x.id})") -} -- cgit v1.2.3