Skip to content

Instantly share code, notes, and snippets.

@rostyslav-y
Created June 16, 2017 15:20
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 rostyslav-y/9dc57d1fc244dc1c74a12d0d119dd00f to your computer and use it in GitHub Desktop.
Save rostyslav-y/9dc57d1fc244dc1c74a12d0d119dd00f to your computer and use it in GitHub Desktop.
class BodyTypeAdapter : ColumnAdapter<BodyType, Long> {
override fun encode(enumValue: BodyType): Long {
return enumValue.ordinal.toLong()
}
override fun decode(databaseValue: Long?): BodyType {
return BodyType.values()[databaseValue?.toInt() ?: BodyType.UNKNOWN.ordinal]
}
companion object {
val INSTANCE by lazy { BodyTypeAdapter() }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment