main.com.sceyt.chatuikit.persistence.converters.ChannelConverter.kt Maven / Gradle / Ivy
package com.sceyt.chatuikit.persistence.converters
import androidx.room.TypeConverter
import com.sceyt.chat.models.user.PresenceState
import com.sceyt.chat.models.user.UserState
import com.sceyt.chatuikit.data.models.channels.ChannelTypeEnum
import com.sceyt.chatuikit.data.models.channels.RoleTypeEnum
import com.sceyt.chatuikit.persistence.extensions.toEnum
class ChannelConverter {
@TypeConverter
fun channelTypeEnumToTnt(value: ChannelTypeEnum) = value.ordinal
@TypeConverter
fun intToChannelTypeEnum(value: Int) = value.toEnum()
@TypeConverter
fun presenceStateToTnt(value: PresenceState) = value.ordinal
@TypeConverter
fun intToPresenceState(value: Int) = value.toEnum()
@TypeConverter
fun userActivityStatusToTnt(value: UserState) = value.ordinal
@TypeConverter
fun intToUserActivityStatus(value: Int) = value.toEnum()
@TypeConverter
fun memberTypeEnumToTnt(value: RoleTypeEnum?) = value?.ordinal
@TypeConverter
fun intToMemberTypeEnum(value: Int?) = value?.toEnum()
}