Add new book management
This commit is contained in:
parent
bb9e1b36f7
commit
a822d7f008
12 changed files with 63 additions and 236 deletions
|
|
@ -11,7 +11,11 @@ import java.util.*
|
|||
class BookFactory {
|
||||
private val parser get() = SimpleDateFormat(FORMAT, Locale.getDefault())
|
||||
|
||||
fun fromListResponseToBook(response: BookListResponse.Book, isNew: Boolean = false): Book {
|
||||
fun fromListResponseToBook(
|
||||
response: BookListResponse.Book,
|
||||
isNew: Boolean = false,
|
||||
newOrder: Int? = null
|
||||
): Book {
|
||||
fun error(name: String) =
|
||||
MandatoryFieldMissingException("#fromListResponseToBook()", name, response)
|
||||
|
||||
|
|
@ -65,6 +69,11 @@ class BookFactory {
|
|||
} else {
|
||||
null
|
||||
}
|
||||
val newOrder = if (isNew) {
|
||||
newOrder
|
||||
} else {
|
||||
null
|
||||
}
|
||||
|
||||
return Book(
|
||||
id = id ?: throw error("id"),
|
||||
|
|
@ -76,7 +85,8 @@ class BookFactory {
|
|||
series = series,
|
||||
language = language,
|
||||
rating = rating,
|
||||
isNew = isNew
|
||||
isNew = isNew,
|
||||
newOrder = newOrder,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue