mirror of
https://github.com/corda/corda.git
synced 2025-01-12 07:52:38 +00:00
Merged in clint-array-removal (pull request #273)
Replaced array with list where possible.
This commit is contained in:
commit
493f7f1fd1
@ -461,7 +461,7 @@ class InterestRateSwap() : ClauseVerifier() {
|
|||||||
override val ifNotMatched = MatchBehaviour.CONTINUE
|
override val ifNotMatched = MatchBehaviour.CONTINUE
|
||||||
|
|
||||||
// These functions may make more sense to use for basket types, but for now let's leave them here
|
// These functions may make more sense to use for basket types, but for now let's leave them here
|
||||||
fun checkLegDates(legs: Array<CommonLeg>) {
|
fun checkLegDates(legs: List<CommonLeg>) {
|
||||||
requireThat {
|
requireThat {
|
||||||
"Effective date is before termination date" by legs.all { it.effectiveDate < it.terminationDate }
|
"Effective date is before termination date" by legs.all { it.effectiveDate < it.terminationDate }
|
||||||
"Effective dates are in alignment" by legs.all { it.effectiveDate == legs[0].effectiveDate }
|
"Effective dates are in alignment" by legs.all { it.effectiveDate == legs[0].effectiveDate }
|
||||||
@ -469,7 +469,7 @@ class InterestRateSwap() : ClauseVerifier() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun checkLegAmounts(legs: Array<CommonLeg>) {
|
fun checkLegAmounts(legs: List<CommonLeg>) {
|
||||||
requireThat {
|
requireThat {
|
||||||
"The notional is non zero" by legs.any { it.notional.quantity > (0).toLong() }
|
"The notional is non zero" by legs.any { it.notional.quantity > (0).toLong() }
|
||||||
"The notional for all legs must be the same" by legs.all { it.notional == legs[0].notional }
|
"The notional for all legs must be the same" by legs.all { it.notional == legs[0].notional }
|
||||||
@ -485,9 +485,9 @@ class InterestRateSwap() : ClauseVerifier() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: After business rules discussion, add further checks to the schedules and rates
|
// TODO: After business rules discussion, add further checks to the schedules and rates
|
||||||
fun checkSchedules(@Suppress("UNUSED_PARAMETER") legs: Array<CommonLeg>): Boolean = true
|
fun checkSchedules(@Suppress("UNUSED_PARAMETER") legs: List<CommonLeg>): Boolean = true
|
||||||
|
|
||||||
fun checkRates(@Suppress("UNUSED_PARAMETER") legs: Array<CommonLeg>): Boolean = true
|
fun checkRates(@Suppress("UNUSED_PARAMETER") legs: List<CommonLeg>): Boolean = true
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compares two schedules of Floating Leg Payments, returns the difference (i.e. omissions in either leg or changes to the values).
|
* Compares two schedules of Floating Leg Payments, returns the difference (i.e. omissions in either leg or changes to the values).
|
||||||
@ -550,14 +550,14 @@ class InterestRateSwap() : ClauseVerifier() {
|
|||||||
"The effective date is before the termination date for the floating leg" by (irs.floatingLeg.effectiveDate < irs.floatingLeg.terminationDate)
|
"The effective date is before the termination date for the floating leg" by (irs.floatingLeg.effectiveDate < irs.floatingLeg.terminationDate)
|
||||||
"The effective dates are aligned" by (irs.floatingLeg.effectiveDate == irs.fixedLeg.effectiveDate)
|
"The effective dates are aligned" by (irs.floatingLeg.effectiveDate == irs.fixedLeg.effectiveDate)
|
||||||
"The termination dates are aligned" by (irs.floatingLeg.terminationDate == irs.fixedLeg.terminationDate)
|
"The termination dates are aligned" by (irs.floatingLeg.terminationDate == irs.fixedLeg.terminationDate)
|
||||||
"The rates are valid" by checkRates(arrayOf(irs.fixedLeg, irs.floatingLeg))
|
"The rates are valid" by checkRates(listOf(irs.fixedLeg, irs.floatingLeg))
|
||||||
"The schedules are valid" by checkSchedules(arrayOf(irs.fixedLeg, irs.floatingLeg))
|
"The schedules are valid" by checkSchedules(listOf(irs.fixedLeg, irs.floatingLeg))
|
||||||
"The fixing period date offset cannot be negative" by (irs.floatingLeg.fixingPeriodOffset >= 0)
|
"The fixing period date offset cannot be negative" by (irs.floatingLeg.fixingPeriodOffset >= 0)
|
||||||
|
|
||||||
// TODO: further tests
|
// TODO: further tests
|
||||||
}
|
}
|
||||||
checkLegAmounts(arrayOf(irs.fixedLeg, irs.floatingLeg))
|
checkLegAmounts(listOf(irs.fixedLeg, irs.floatingLeg))
|
||||||
checkLegDates(arrayOf(irs.fixedLeg, irs.floatingLeg))
|
checkLegDates(listOf(irs.fixedLeg, irs.floatingLeg))
|
||||||
|
|
||||||
return setOf(command.value)
|
return setOf(command.value)
|
||||||
}
|
}
|
||||||
@ -672,8 +672,8 @@ class InterestRateSwap() : ClauseVerifier() {
|
|||||||
return (fixedLeg.fixedRatePayer.owningKey in ourKeys) || (floatingLeg.floatingRatePayer.owningKey in ourKeys)
|
return (fixedLeg.fixedRatePayer.owningKey in ourKeys) || (floatingLeg.floatingRatePayer.owningKey in ourKeys)
|
||||||
}
|
}
|
||||||
|
|
||||||
override val parties: Array<Party>
|
override val parties: List<Party>
|
||||||
get() = arrayOf(fixedLeg.fixedRatePayer, floatingLeg.floatingRatePayer)
|
get() = listOf(fixedLeg.fixedRatePayer, floatingLeg.floatingRatePayer)
|
||||||
|
|
||||||
override fun nextScheduledActivity(thisStateRef: StateRef, protocolLogicRefFactory: ProtocolLogicRefFactory): ScheduledActivity? {
|
override fun nextScheduledActivity(thisStateRef: StateRef, protocolLogicRefFactory: ProtocolLogicRefFactory): ScheduledActivity? {
|
||||||
val nextFixingOf = nextFixingOf() ?: return null
|
val nextFixingOf = nextFixingOf() ?: return null
|
||||||
|
@ -230,7 +230,7 @@ interface DealState : LinearState {
|
|||||||
val ref: String
|
val ref: String
|
||||||
|
|
||||||
/** Exposes the Parties involved in a generic way */
|
/** Exposes the Parties involved in a generic way */
|
||||||
val parties: Array<Party>
|
val parties: List<Party>
|
||||||
|
|
||||||
// TODO: This works by editing the keys used by a Party which is invalid.
|
// TODO: This works by editing the keys used by a Party which is invalid.
|
||||||
fun withPublicKey(before: Party, after: PublicKey): DealState
|
fun withPublicKey(before: Party, after: PublicKey): DealState
|
||||||
|
@ -102,7 +102,7 @@ object AutoOfferProtocol {
|
|||||||
|
|
||||||
val notary = serviceHub.networkMapCache.notaryNodes.first().identity
|
val notary = serviceHub.networkMapCache.notaryNodes.first().identity
|
||||||
// need to pick which ever party is not us
|
// need to pick which ever party is not us
|
||||||
val otherParty = notUs(*dealToBeOffered.parties).single()
|
val otherParty = notUs(dealToBeOffered.parties).single()
|
||||||
progressTracker.currentStep = ANNOUNCING
|
progressTracker.currentStep = ANNOUNCING
|
||||||
send(otherParty, 0, AutoOfferMessage(serviceHub.storageService.myLegalIdentity, notary, ourSessionID, dealToBeOffered))
|
send(otherParty, 0, AutoOfferMessage(serviceHub.storageService.myLegalIdentity, notary, ourSessionID, dealToBeOffered))
|
||||||
progressTracker.currentStep = DEALING
|
progressTracker.currentStep = DEALING
|
||||||
@ -110,7 +110,7 @@ object AutoOfferProtocol {
|
|||||||
return stx
|
return stx
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun notUs(vararg parties: Party): List<Party> {
|
private fun notUs(parties: List<Party>): List<Party> {
|
||||||
val notUsParties: MutableList<Party> = arrayListOf()
|
val notUsParties: MutableList<Party> = arrayListOf()
|
||||||
for (party in parties) {
|
for (party in parties) {
|
||||||
if (serviceHub.storageService.myLegalIdentity != party) {
|
if (serviceHub.storageService.myLegalIdentity != party) {
|
||||||
|
Loading…
Reference in New Issue
Block a user