package ru.fincode.core.database.impl

import androidx.room.TypeConverter

class StringListConverter {

    private companion object {
        const val SEPARATOR = "||"
    }

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

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