mirror of
https://github.com/lacerta-doc/Lacerta.git
synced 2024-11-23 00:13:16 +00:00
Converter実装
This commit is contained in:
parent
e033eb754d
commit
878480097a
|
@ -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();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user