diff options
author | vlad <vlad@driver.xyz> | 2017-10-02 01:05:42 -0700 |
---|---|---|
committer | vlad <vlad@driver.xyz> | 2017-10-02 01:05:42 -0700 |
commit | d0482b45b6f9149f050c5e5a6dbab6f059229282 (patch) | |
tree | c82ce57536dc2ec51b34f1b6f8159835d95c2cc6 /src/main/scala/xyz/driver/pdsuidomain/formats/json/document/ApiDocumentType.scala | |
parent | c5b7f009479930b82f0fb839971eeb2c457dcef0 (diff) | |
download | rest-query-d0482b45b6f9149f050c5e5a6dbab6f059229282.tar.gz rest-query-d0482b45b6f9149f050c5e5a6dbab6f059229282.tar.bz2 rest-query-d0482b45b6f9149f050c5e5a6dbab6f059229282.zip |
DocumentType and ProviderType as enumsv0.5.3
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.scala | 9 |
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")) } |