Created
June 16, 2017 15:20
-
-
Save rostyslav-y/9dc57d1fc244dc1c74a12d0d119dd00f to your computer and use it in GitHub Desktop.
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
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