package ru.fincode.tsudesk.core.database

import androidx.room.TypeConverter

class StringListConverter {

    private val separator = "||"

    @TypeConverter
    fun fromList(list: List<String>?): String =
        list
            ?.joinToString(separator = separator)
            .orEmpty()

    @TypeConverter
    fun toList(value: String?): List<String> =
        value
            ?.takeIf { it.isNotBlank() }
            ?.split(separator)
            .orEmpty()
}
