Skip to content

Instantly share code, notes, and snippets.

@zamahaka
Created December 17, 2017 13:19
Show Gist options
  • Save zamahaka/f4928d3ad959b423ba40021d07f9d7a7 to your computer and use it in GitHub Desktop.
Save zamahaka/f4928d3ad959b423ba40021d07f9d7a7 to your computer and use it in GitHub Desktop.
new typeConverters
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