2021-02-08 11:24:14 +07:00
|
|
|
package com.cubetiqs.money
|
2020-08-26 20:02:36 +07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Default standard money style
|
|
|
|
* We have only value and currency of money
|
2020-08-26 20:06:06 +07:00
|
|
|
*
|
|
|
|
* @author sombochea
|
|
|
|
* @since 1.0
|
2020-08-26 20:02:36 +07:00
|
|
|
*/
|
|
|
|
interface StdMoney {
|
|
|
|
/**
|
|
|
|
* Get money's value from current state.
|
|
|
|
*
|
|
|
|
* @return Double
|
|
|
|
*/
|
2020-08-26 21:32:06 +07:00
|
|
|
fun getMoneyValue(): Double
|
2020-08-26 20:02:36 +07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get money's currency from current state.
|
2020-08-26 20:06:06 +07:00
|
|
|
*
|
|
|
|
* @return String
|
2020-08-26 20:02:36 +07:00
|
|
|
*/
|
2021-02-08 12:39:52 +07:00
|
|
|
fun getMoneyCurrency(): Currency
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Allow for money currency called and implemented
|
|
|
|
*/
|
|
|
|
interface Currency {
|
|
|
|
fun getCurrency(): String
|
|
|
|
}
|
|
|
|
|
|
|
|
interface ExchangeOperator {
|
|
|
|
fun StdMoney.getExchangedTo(currency: Currency): Double
|
|
|
|
}
|
|
|
|
|
|
|
|
interface Operator<T : StdMoney> {
|
|
|
|
fun plus(other: StdMoney): T
|
|
|
|
fun divide(other: StdMoney): T
|
|
|
|
|
|
|
|
fun inc(): T
|
|
|
|
fun dec(): T
|
|
|
|
fun multiply(other: StdMoney): T
|
|
|
|
|
|
|
|
// assign operators
|
|
|
|
fun plusAssign(other: StdMoney)
|
|
|
|
fun divideAssign(other: StdMoney)
|
|
|
|
fun multiplyAssign(other: StdMoney)
|
|
|
|
}
|
2020-08-26 20:02:36 +07:00
|
|
|
}
|