Has anyone tried to use inline classes in a Room e...
# android
g
Has anyone tried to use inline classes in a Room entity? I'm trying this:
Copy code
@Entity
data class DailySummary(
        @PrimaryKey val date: LocalDate,
        val activeTime: Duration,
        val calories: KCal // <- inline class wrapping a Float
)
and it doesn't work even if I provide a
@TypeConverter
for it. The error coming from Gradle is very meaningless so i won't post it here but changing the entity above to use
Float
instead of
KCal
automatically works. The Type Converters are these:
Copy code
@TypeConverter
    fun toKCal(value: Float?): KCal? {
        return value?.let { KCal(it) }
    }

    @TypeConverter
    fun fromKCal(kcal: KCal?): Float? {
        return kcal?.value
    }
g
Ok... Star and wait I guess. Thanks 👍
r
Arent inline classes still experimental? probably when they reach a more stable version, support for it will be available . it probably wouldn't make sense for them to add support now, when they api itself is subject to change in the future
g
I guess that's true. I really hoped it would at least work providing the
TypeConverter
for it