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(",")); + } +}