Skip to content

Instantly share code, notes, and snippets.

@enginebai
Created April 1, 2019 00:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save enginebai/3191009c8a7c884339e3dd2d152991e7 to your computer and use it in GitHub Desktop.
Save enginebai/3191009c8a7c884339e3dd2d152991e7 to your computer and use it in GitHub Desktop.
object NewPostFieldConvert {
@TypeConverter
fun postTypeToStr(type: PostType?): String? = type?.name
@TypeConverter
fun strToPostType(str: String?): PostType? = str?.let { PostType.valueOf(it) }
@TypeConverter
fun fileToPath(file: File?): String? = file?.absolutePath
@TypeConverter
fun pathToFile(path: String?): File? = path?.let { File(it) }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment