mirror of
https://github.com/corda/corda.git
synced 2025-01-29 15:43:55 +00:00
RollOut/Continuation
This commit is contained in:
parent
84700ce1b9
commit
7284896375
@ -52,4 +52,10 @@ data class Action(val name: String, val condition: Perceivable<Boolean>,
|
||||
data class Or(val actions: Set<Action>) : Arrangement
|
||||
|
||||
|
||||
data class RollOut(val startDate: String, val endDate: String, val frequency: Frequency, val arrangement: Arrangement) : Arrangement
|
||||
// Roll out of arrangement
|
||||
data class RollOut(val startDate: String, val endDate: String, val frequency: Frequency, val template: Arrangement) : Arrangement
|
||||
|
||||
|
||||
// Continuation of roll out
|
||||
// May only be used inside template for RollOut
|
||||
class Continuation : Arrangement
|
@ -23,17 +23,23 @@ data class Const<T>(val value: T) : Perceivable<T>
|
||||
|
||||
fun<T> const(k: T) = Const(k)
|
||||
|
||||
//
|
||||
class StartDate : Perceivable<Instant>
|
||||
class EndDate : Perceivable<Instant>
|
||||
|
||||
/**
|
||||
* Perceivable based on time
|
||||
*/
|
||||
data class TimePerceivable(val cmp: Comparison, val instant: Instant) : Perceivable<Boolean>
|
||||
data class TimePerceivable(val cmp: Comparison, val instant: Perceivable<Instant>) : Perceivable<Boolean>
|
||||
|
||||
fun parseInstant(str: String) = DateFormat.getDateInstance(DateFormat.SHORT, Locale.US).parse(str).toInstant()
|
||||
|
||||
fun before(expiry: Instant) = TimePerceivable(Comparison.LTE, expiry)
|
||||
fun after(expiry: Instant) = TimePerceivable(Comparison.GTE, expiry)
|
||||
fun before(expiry: String) = TimePerceivable(Comparison.LTE, parseInstant(expiry))
|
||||
fun after(expiry: String) = TimePerceivable(Comparison.GTE, parseInstant(expiry))
|
||||
fun before(expiry: Perceivable<Instant>) = TimePerceivable(Comparison.LTE, expiry)
|
||||
fun after(expiry: Perceivable<Instant>) = TimePerceivable(Comparison.GTE, expiry)
|
||||
fun before(expiry: Instant) = TimePerceivable(Comparison.LTE, const(expiry))
|
||||
fun after(expiry: Instant) = TimePerceivable(Comparison.GTE, const(expiry))
|
||||
fun before(expiry: String) = TimePerceivable(Comparison.LTE, const(parseInstant(expiry)))
|
||||
fun after(expiry: String) = TimePerceivable(Comparison.GTE, const(parseInstant(expiry)))
|
||||
|
||||
data class PerceivableAnd(val left: Perceivable<Boolean>, val right: Perceivable<Boolean>) : Perceivable<Boolean>
|
||||
infix fun Perceivable<Boolean>.and(obs: Perceivable<Boolean>) = PerceivableAnd(this, obs)
|
||||
|
@ -99,9 +99,9 @@ fun arrange(init: ContractBuilder.() -> Unit ) : Arrangement {
|
||||
|
||||
class RolloutBuilder(val startDate: String, val endDate: String, val frequency: Frequency) {
|
||||
|
||||
val start = "start date"
|
||||
val end = "end date"
|
||||
fun recurse() = zero
|
||||
val start = StartDate()
|
||||
val end = EndDate()
|
||||
fun recurse() = Continuation()
|
||||
|
||||
fun final() =
|
||||
RollOut(startDate, endDate, frequency, zero)
|
||||
|
@ -5,6 +5,7 @@ import com.r3corda.core.crypto.Party
|
||||
import com.r3corda.core.crypto.generateKeyPair
|
||||
import org.junit.Test
|
||||
import java.math.BigDecimal
|
||||
import java.time.Instant
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
@ -20,10 +21,13 @@ class DummyPerceivable<T> : Perceivable<T>
|
||||
val acmeCorporationHasDefaulted = DummyPerceivable<Boolean>()
|
||||
|
||||
|
||||
fun libor(amount: Amount<Currency>, start: String, end: String) : Perceivable<Amount<Currency>> = DummyPerceivable()
|
||||
fun libor(@Suppress("UNUSED_PARAMETER") amount: Amount<Currency>, @Suppress("UNUSED_PARAMETER") start: String, @Suppress("UNUSED_PARAMETER") end: String) : Perceivable<Amount<Currency>> = DummyPerceivable()
|
||||
fun libor(@Suppress("UNUSED_PARAMETER") amount: Amount<Currency>, @Suppress("UNUSED_PARAMETER") start: Perceivable<Instant>, @Suppress("UNUSED_PARAMETER") end: Perceivable<Instant>) : Perceivable<Amount<Currency>> = DummyPerceivable()
|
||||
|
||||
fun interest(rate: Amount<Currency>, dayCountConvention: String, interest: Double /* todo - appropriate type */,
|
||||
start: String, end: String) : Perceivable<Amount<Currency>> = DummyPerceivable()
|
||||
fun interest(@Suppress("UNUSED_PARAMETER") rate: Amount<Currency>, @Suppress("UNUSED_PARAMETER") dayCountConvention: String, @Suppress("UNUSED_PARAMETER") interest: Double /* todo - appropriate type */,
|
||||
@Suppress("UNUSED_PARAMETER") start: String, @Suppress("UNUSED_PARAMETER") end: String) : Perceivable<Amount<Currency>> = DummyPerceivable()
|
||||
fun interest(@Suppress("UNUSED_PARAMETER") rate: Amount<Currency>, @Suppress("UNUSED_PARAMETER") dayCountConvention: String, @Suppress("UNUSED_PARAMETER") interest: Double /* todo - appropriate type */,
|
||||
@Suppress("UNUSED_PARAMETER") start: Perceivable<Instant>, @Suppress("UNUSED_PARAMETER") end: Perceivable<Instant>) : Perceivable<Amount<Currency>> = DummyPerceivable()
|
||||
|
||||
// Test parties
|
||||
val roadRunner = Party("Road Runner", generateKeyPair().public)
|
||||
|
Loading…
x
Reference in New Issue
Block a user