aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/xyz/driver/pdsuidomain/formats/json/document/ApiDocumentType.scala
diff options
context:
space:
mode:
authorMarvin Bertin <marvin.bertin@gmail.com>2017-10-03 13:09:49 -0700
committerMarvin Bertin <marvin.bertin@gmail.com>2017-10-03 13:09:49 -0700
commit98d6f3d136a16310300e23b12e6b730ac7ade6b6 (patch)
tree34ef97bc59f3c34d20a18cd65107655d319097fc /src/main/scala/xyz/driver/pdsuidomain/formats/json/document/ApiDocumentType.scala
parent1d0202a3964637ffb93180a1c89617633ab5ab18 (diff)
parent0653b90dddc294fddb0e81059aef00b202113d78 (diff)
downloadrest-query-98d6f3d136a16310300e23b12e6b730ac7ade6b6.tar.gz
rest-query-98d6f3d136a16310300e23b12e6b730ac7ade6b6.tar.bz2
rest-query-98d6f3d136a16310300e23b12e6b730ac7ade6b6.zip
Merge branch 'add-slot-eligibility-arms' into trial-46-disease-entity
Diffstat (limited to 'src/main/scala/xyz/driver/pdsuidomain/formats/json/document/ApiDocumentType.scala')
-rw-r--r--src/main/scala/xyz/driver/pdsuidomain/formats/json/document/ApiDocumentType.scala9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/document/ApiDocumentType.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/document/ApiDocumentType.scala
index 8b4974f..22bea6b 100644
--- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/document/ApiDocumentType.scala
+++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/document/ApiDocumentType.scala
@@ -2,15 +2,14 @@ package xyz.driver.pdsuidomain.formats.json.document
import play.api.libs.functional.syntax._
import play.api.libs.json.{Format, JsPath}
-import xyz.driver.pdsuicommon.domain.LongId
import xyz.driver.pdsuidomain.entities.DocumentType
final case class ApiDocumentType(id: Long, name: String) {
- def toDomain = DocumentType(
- id = LongId(this.id),
- name = this.name
- )
+ def toDomain: DocumentType =
+ DocumentType
+ .fromString(name)
+ .getOrElse(throw new IllegalArgumentException(s"Unknown document type name $name"))
}