money-module/src/main/kotlin/com/cubetiqs/money/MoneyCurrency.kt
Sambo Chea 31760ee901 Add and updated for whole the money modules with new style and some operators and computation
But money object not full implementation yet, because we need the exchange and filter the object states for money
2021-02-08 12:39:52 +07:00

43 lines
998 B
Kotlin

package com.cubetiqs.money
import java.io.Serializable
/**
* Money Currency Object with flexible currency based on data and configs
*
* @author sombochea
* @since 1.0
*/
open class MoneyCurrency(
private val name: String,
private val symbol: String? = null,
private val configs: Map<String, Any?>? = null,
) : Serializable, StdMoney.Currency {
override fun getCurrency(): String {
return name.toUpperCase().trim()
}
fun getSymbol(): String? {
return symbol ?: getConfigs()["symbol"]?.toString()
}
fun getConfigs(): Map<String, Any?> {
return configs ?: emptyMap()
}
override fun toString(): String {
return "MoneyCurrency(name='$name', symbol=$symbol, configs=$configs)"
}
companion object {
fun create(name: String): MoneyCurrency {
return MoneyCurrency(name = name)
}
val USD
get() = create("USD")
val KHR
get() = create("KHR")
}
}