From 957ad6aacb6adc2fa839dc91dd4d772c790aac03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Thu, 14 Dec 2023 11:36:09 +0900 Subject: [PATCH] =?UTF-8?q?TagList=E3=81=AEConverter=E3=82=92=E5=AE=9F?= =?UTF-8?q?=E8=A3=85=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../database/common/TagListConverter.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 source/src/main/java/one/nem/lacerta/source/database/common/TagListConverter.java diff --git a/source/src/main/java/one/nem/lacerta/source/database/common/TagListConverter.java b/source/src/main/java/one/nem/lacerta/source/database/common/TagListConverter.java new file mode 100644 index 00000000..0a738651 --- /dev/null +++ b/source/src/main/java/one/nem/lacerta/source/database/common/TagListConverter.java @@ -0,0 +1,19 @@ +package one.nem.lacerta.source.database.common; + +import androidx.room.TypeConverter; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +public class TagListConverter { + @TypeConverter + public static String fromList(List list) { + return list == null ? null : String.join(",", list); + } + + @TypeConverter + public static List fromString(String value) { + return value == null ? Collections.emptyList() : Arrays.asList(value.split(",")); + } +}