Converter実装

This commit is contained in:
ろむねこ 2023-12-14 11:10:02 +09:00
parent e033eb754d
commit 878480097a
No known key found for this signature in database
GPG Key ID: FA1F39A1BA37D168

View File

@ -0,0 +1,28 @@
package one.nem.lacerta.source.database.common;
import androidx.room.TypeConverter;
import java.util.ArrayList;
import java.util.Arrays;
public class TagArrayListConverter {
@TypeConverter
public static ArrayList<String> fromString(String value) {
return value == null ? null : new ArrayList<String>(Arrays.asList(value.split(",")));
}
@TypeConverter
public static String fromArrayList(ArrayList<String> list) {
if (list == null) {
return null;
}
StringBuilder sb = new StringBuilder();
for (String s : list) {
sb.append(s);
sb.append(",");
}
return sb.toString();
}
}