io.github.binaryfoo.decoders.annotator.BackgroundReading.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of emv-bertlv Show documentation
Show all versions of emv-bertlv Show documentation
Some decoders for the data used in EMV credit card transactions.
package io.github.binaryfoo.decoders.annotator
import io.github.binaryfoo.decoders.apdu.APDUCommand
import io.github.binaryfoo.res.ClasspathIO
import org.yaml.snakeyaml.Yaml
import kotlin.collections.mapOf
/**
* Some english description for each field. From a set of .yaml files.
*/
class BackgroundReading {
companion object {
@JvmStatic fun readingFor(apdu: APDUCommand): Map? {
return apduDescriptions["$apdu"]
}
@JvmStatic fun readingFor(field: String): Map? {
return descriptions["$field"]
}
private val apduDescriptions: Map> by lazy(LazyThreadSafetyMode.SYNCHRONIZED) {
@Suppress("UNCHECKED_CAST")
(Yaml().load(ClasspathIO.open("apdus.yaml")) as Map>)
}
private val descriptions: Map> by lazy(LazyThreadSafetyMode.SYNCHRONIZED) {
@Suppress("UNCHECKED_CAST")
(Yaml().load(ClasspathIO.open("descriptions.yaml")) as Map>)
}
}
}
fun backgroundOf(short: String, long: String? = null): Map = mapOf("short" to short, "long" to long)
© 2015 - 2024 Weber Informatics LLC | Privacy Policy