-
-
Save zamahaka/f4928d3ad959b423ba40021d07f9d7a7 to your computer and use it in GitHub Desktop.
new typeConverters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object DatabaseTypeConverters { | |
@TypeConverter | |
@JvmStatic | |
fun userTypeListToString(types: MutableList<UserType?>?): String = | |
GsonBuilder().apply { registerAdapterFor<UserType>() }.create().toJson(types) | |
@TypeConverter | |
@JvmStatic | |
fun stringToUserTypeList(name: String?): MutableList<UserType?>? = name?.let { | |
GsonBuilder().apply { registerAdapterFor<UserType>() }.create().fromJson(it) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment