All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.com.michaeltroger.latintocyrillic.alphabets.CustomAlphabet.kt Maven / Gradle / Ivy

The newest version!
package com.michaeltroger.latintocyrillic.alphabets


internal class CustomAlphabet(latin: List, cyrillic: List) : LatinCyrillicAlphabet() {

    init {
        require(latin.size == cyrillic.size) {
            "Latin and Cyrillic alphabets must have same size. But have: Latin:${latin.size}/Cyrillic:${cyrillic.size}"
        }
        latin.forEach {
            require(it.isNotEmpty() && it.length < 3) {
                "Only 1 or 2 latin characters allowed to describe a letter in alphabet. But were:${it.length}/Letter:${it}\""
            }
        }
    }

    override val latinToCyrillicAlphabet: Map by lazy {
        var i = 0
        latin.associateWith {
            cyrillic[i++].toString()
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy