Minor: add extension method to support "1.234".d to create a BigDecimal

This commit is contained in:
Mike Hearn 2016-03-08 13:55:03 +01:00
parent dc6ef73b6b
commit c18579fd60

View File

@ -15,6 +15,7 @@ import com.google.common.util.concurrent.SettableFuture
import org.slf4j.Logger import org.slf4j.Logger
import java.io.BufferedInputStream import java.io.BufferedInputStream
import java.io.InputStream import java.io.InputStream
import java.math.BigDecimal
import java.nio.file.Files import java.nio.file.Files
import java.nio.file.Path import java.nio.file.Path
import java.security.SecureRandom import java.security.SecureRandom
@ -32,6 +33,8 @@ val Int.hours: Duration get() = Duration.ofHours(this.toLong())
val Int.minutes: Duration get() = Duration.ofMinutes(this.toLong()) val Int.minutes: Duration get() = Duration.ofMinutes(this.toLong())
val Int.seconds: Duration get() = Duration.ofSeconds(this.toLong()) val Int.seconds: Duration get() = Duration.ofSeconds(this.toLong())
val String.d: BigDecimal get() = BigDecimal(this)
/** /**
* Returns a random positive long generated using a secure RNG. This function sacrifies a bit of entropy in order to * Returns a random positive long generated using a secure RNG. This function sacrifies a bit of entropy in order to
* avoid potential bugs where the value is used in a context where negative numbers are not expected. * avoid potential bugs where the value is used in a context where negative numbers are not expected.