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

commonMain.com.bselzer.gw2.v2.db.metadata.TranslationMetadataExtractor.kt Maven / Gradle / Ivy

There is a newer version: 3.13.0
Show newest version
package com.bselzer.gw2.v2.db.metadata

import com.bselzer.gw2.v2.intl.model.Translation
import org.kodein.db.Options
import org.kodein.db.Value
import org.kodein.db.model.orm.Metadata
import org.kodein.db.model.orm.MetadataExtractor

/**
 * A metadata extractor for [Translation] models.
 */
class TranslationMetadataExtractor : MetadataExtractor {
    override fun extractMetadata(model: Any, vararg options: Options.Puts): Metadata? = when (model) {
        is Translation -> Metadata(model.id())
        else -> null
    }
}

/**
 * Creates an id using the default text and language of the translation.
 * @return the id
 */
fun Translation.id() = Value.of(default, language)




© 2015 - 2024 Weber Informatics LLC | Privacy Policy