From c18579fd60b85d50cc2081c1c2c3eda4298e92a0 Mon Sep 17 00:00:00 2001 From: Mike Hearn Date: Tue, 8 Mar 2016 13:55:03 +0100 Subject: [PATCH] Minor: add extension method to support "1.234".d to create a BigDecimal --- core/src/main/kotlin/core/Utils.kt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/src/main/kotlin/core/Utils.kt b/core/src/main/kotlin/core/Utils.kt index 5d140972e9..59243ac333 100644 --- a/core/src/main/kotlin/core/Utils.kt +++ b/core/src/main/kotlin/core/Utils.kt @@ -15,6 +15,7 @@ import com.google.common.util.concurrent.SettableFuture import org.slf4j.Logger import java.io.BufferedInputStream import java.io.InputStream +import java.math.BigDecimal import java.nio.file.Files import java.nio.file.Path 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.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 * avoid potential bugs where the value is used in a context where negative numbers are not expected.