From cd881b07154e28075fb9498a5a62281b02fa95c0 Mon Sep 17 00:00:00 2001 From: sya-ri Date: Fri, 12 Aug 2022 18:43:38 +0900 Subject: [PATCH] tweak: Change GofileChildContent.Folder#tags to List --- src/commonMain/kotlin/dev/s7a/gofile/GofileChildContent.kt | 2 +- .../kotlin/dev/s7a/gofile/GofileChildContentSerializer.kt | 4 ++-- src/commonTest/kotlin/ChildContentTests.kt | 4 ++-- src/commonTest/kotlin/ContentTests.kt | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/commonMain/kotlin/dev/s7a/gofile/GofileChildContent.kt b/src/commonMain/kotlin/dev/s7a/gofile/GofileChildContent.kt index 0430df8..20bcce9 100644 --- a/src/commonMain/kotlin/dev/s7a/gofile/GofileChildContent.kt +++ b/src/commonMain/kotlin/dev/s7a/gofile/GofileChildContent.kt @@ -79,7 +79,7 @@ sealed class GofileChildContent { val password: Boolean = false, val description: String? = null, val expire: Long? = null, - val tags: String? = null + val tags: List = emptyList() ) : GofileChildContent() { override val type = GofileContentType.Folder } diff --git a/src/commonMain/kotlin/dev/s7a/gofile/GofileChildContentSerializer.kt b/src/commonMain/kotlin/dev/s7a/gofile/GofileChildContentSerializer.kt index edd3abe..167634c 100644 --- a/src/commonMain/kotlin/dev/s7a/gofile/GofileChildContentSerializer.kt +++ b/src/commonMain/kotlin/dev/s7a/gofile/GofileChildContentSerializer.kt @@ -93,7 +93,7 @@ class GofileChildContentSerializer : KSerializer { val password = element["password"]?.jsonPrimitive?.boolean ?: false val description = element["description"]?.jsonPrimitive?.content val expire = element["expire"]?.jsonPrimitive?.long - val tags = element["tags"]?.jsonPrimitive?.content + val tags = element["tags"]?.jsonPrimitive?.content?.split(",").orEmpty() GofileChildContent.Folder(id, name, parentFolder, createTime, childs, code, public, password, description, expire, tags) } } @@ -125,7 +125,7 @@ class GofileChildContentSerializer : KSerializer { if (value.password) put("password", true) if (value.description != null) put("description", value.description) if (value.expire != null) put("expire", value.expire) - if (value.tags != null) put("tags", value.tags) + if (value.tags.isNotEmpty()) put("tags", value.tags.joinToString(",")) } } } diff --git a/src/commonTest/kotlin/ChildContentTests.kt b/src/commonTest/kotlin/ChildContentTests.kt index 7292408..3c63f4d 100644 --- a/src/commonTest/kotlin/ChildContentTests.kt +++ b/src/commonTest/kotlin/ChildContentTests.kt @@ -112,7 +112,7 @@ class ChildContentTests { password = true, "_description", 987654321, - "t,a,g,s" + listOf("t", "a", "g", "s") ) ) ) @@ -241,7 +241,7 @@ class ChildContentTests { password = true, "_description", 987654321, - "t,a,g,s" + listOf("t", "a", "g", "s") ), json.decodeFromString( GofileChildContent.serializer(), diff --git a/src/commonTest/kotlin/ContentTests.kt b/src/commonTest/kotlin/ContentTests.kt index 22a233d..f4e3275 100644 --- a/src/commonTest/kotlin/ContentTests.kt +++ b/src/commonTest/kotlin/ContentTests.kt @@ -181,7 +181,7 @@ class ContentTests { password = true, "_description3", 12345, - "t,a,g,s,3" + listOf("t", "a", "g", "s", "3") ) ) ) @@ -299,7 +299,7 @@ class ContentTests { password = true, "_description3", 12345, - "t,a,g,s,3" + listOf("t", "a", "g", "s", "3") ) ) ),