temporary remove @Serializable annotation from PaginationResult

This commit is contained in:
InsanusMokrassar 2019-11-04 20:41:52 +06:00
parent f2d66b2fe9
commit 5017e66dad
6 changed files with 23 additions and 65 deletions

View File

@ -1,17 +1,30 @@
package com.insanusmokrassar.postssystem.core.content
import kotlinx.serialization.Serializable
typealias ContentId = String
/**
* Content which is planned to be registered in database
*/
interface Content
sealed class Content
@Serializable
data class SimpleSpecialContent(
val internalId: ContentId
) : Content()
@Serializable
data class SimpleTextContent(
val text: String
) : Content()
/**
* Content which is already registered in database. Using its [id] you can retrieve all known
* [com.insanusmokrassar.postssystem.core.post.RegisteredPost]s by using
* [com.insanusmokrassar.postssystem.core.post.api.ReadPostsAPI.getPostsByContent]
*/
interface RegisteredContent : Content {
val id: ContentId
}
data class RegisteredContent(
val id: ContentId,
val content: Content
)

View File

@ -1,31 +0,0 @@
package com.insanusmokrassar.postssystem.core.content
import kotlinx.serialization.Serializable
/**
* Special content, which usually better known in some plugin or system, but is not representable in others. For
* example, it could be issue in some git system, which is unknown for all other systems.
*
* @property internalId Represent Id of this content in system which knows exact type and can correctly handle this
* content
*/
interface SpecialContent : Content {
val internalId: ContentId
}
/**
* As [SpecialContent], but already registered in posts system
*/
interface SpecialRegisteredContent : RegisteredContent, SpecialContent
@Serializable
data class SimpleSpecialContent(
override val internalId: ContentId
) : SpecialContent
@Serializable
data class SimpleSpecialRegisteredContent(
override val id: ContentId,
override val internalId: ContentId
) : SpecialRegisteredContent

View File

@ -1,20 +0,0 @@
package com.insanusmokrassar.postssystem.core.content
import kotlinx.serialization.Serializable
interface TextContent : Content {
val text: String
}
interface TextRegisteredContent : RegisteredContent, TextContent
@Serializable
data class SimpleTextContent(
override val text: String
) : TextContent
@Serializable
data class SimpleTextRegisteredContent(
override val id: ContentId,
override val text: String
) : TextRegisteredContent

View File

@ -0,0 +1,2 @@
package com.insanusmokrassar.postssystem.core.utils

View File

@ -2,7 +2,6 @@ package com.insanusmokrassar.postssystem.core.utils.pagination
import kotlinx.serialization.Serializable
@Serializable
data class PaginationResult<T>(
override val page: Int,
val pagesNumber: Int,

View File

@ -31,7 +31,10 @@ class InMemoryContentAPI(
.toMutableMap()
override suspend fun createContent(content: Content): RegisteredContent? {
return content.createRegisteredEntity(generateId())?.also { registeredContent ->
return RegisteredContent(
generateId(),
content
).also { registeredContent ->
contents[registeredContent.id] = registeredContent
contentCreatedBroadcastChannel.send(registeredContent)
}
@ -51,12 +54,4 @@ class InMemoryContentAPI(
contentDeletedBroadcastChannel.send(content)
} != null
}
private fun Content.createRegisteredEntity(id: ContentId): RegisteredContent? {
return when(this) {
is TextContent -> SimpleTextRegisteredContent(id, text)
is SpecialContent -> SimpleTextRegisteredContent(id, internalId)
else -> null
}
}
}