I would like to use something like the following, which does not compile:
value class PositiveDecimal(val d: BigDecimal): BigDecimal by d {
init {
require(d > BigDecimal.ZERO) { "Value must be positive, was: $d" }
}
}
so that I can use my positive decimal without unboxing, like this:
val length = PositiveDecimal(BigDecimal.ONE)
if(length < maxLength) {
...
(snip)
is there a way to have all the public methods/properties of the embedded value d
exposed by delegation?