money-module/src/main/kotlin/com/cubetiqs/libra/moneyutils/MoneyOperator.kt

13 lines
571 B
Kotlin
Raw Normal View History

2020-08-26 20:06:06 +07:00
package com.cubetiqs.libra.moneyutils
2020-08-26 21:32:06 +07:00
operator fun Money.unaryMinus() = (-getMoneyValue())
operator fun Money.unaryPlus() = (+getMoneyValue())
2020-08-26 20:06:06 +07:00
operator fun Money.inc() = Money(value++)
operator fun Money.dec() = Money(value--)
operator fun Money.plus(other: Money) = Money(value + other.value)
operator fun Money.times(other: Money) = Money(value * other.value)
operator fun Money.div(other: Money) = Money(value / other.value)
operator fun Money.timesAssign(other: Money) {
this.value = this.value * other.value
}
operator fun Money.not() = this.value != this.value