mirror of
https://github.com/corda/corda.git
synced 2025-02-06 11:09:18 +00:00
Minor: add an "until" infix function that applies to Temporal's ... the primary purpose of this beyond a trivial bit of extra readability, is null safety.
This commit is contained in:
parent
2190fbf2ee
commit
5f8dec4ff9
@ -14,6 +14,7 @@ import com.google.common.util.concurrent.SettableFuture
|
|||||||
import org.slf4j.Logger
|
import org.slf4j.Logger
|
||||||
import java.security.SecureRandom
|
import java.security.SecureRandom
|
||||||
import java.time.Duration
|
import java.time.Duration
|
||||||
|
import java.time.temporal.Temporal
|
||||||
import java.util.concurrent.Executor
|
import java.util.concurrent.Executor
|
||||||
|
|
||||||
val Int.days: Duration get() = Duration.ofDays(this.toLong())
|
val Int.days: Duration get() = Duration.ofDays(this.toLong())
|
||||||
@ -41,3 +42,6 @@ fun <T> SettableFuture<T>.setFrom(logger: Logger? = null, block: () -> T): Setta
|
|||||||
}
|
}
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Simple infix function to add back null safety that the JDK lacks: timeA until timeB
|
||||||
|
infix fun Temporal.until(endExclusive: Temporal) = Duration.between(this, endExclusive)
|
Loading…
x
Reference in New Issue
Block a user