mirror of
https://github.com/corda/corda.git
synced 2025-04-15 06:56:59 +00:00
CORDA-540: Fix to make IRS demo code pass in AMQP mode (#1769)
* CORDA-540: Do not use concrete instance of an ArrayList as wire representation of it may be different * CORDA-540: Make data structures suitable for AMQP serialization * CORDA-540: Use "name" instead of "toString()" Classes like "net.corda.finance.contracts.DayCountBasisDay" override "toString()" which leads to error behaviour
This commit is contained in:
parent
ef9b54327a
commit
383eb2bef8
@ -30,9 +30,9 @@ class EnumSerializer(declaredType: Type, declaredClass: Class<*>, factory: Seria
|
||||
override fun readObject(obj: Any, schema: Schema, input: DeserializationInput): Any {
|
||||
val enumName = (obj as List<*>)[0] as String
|
||||
val enumOrd = obj[1] as Int
|
||||
val fromOrd = type.asClass()!!.enumConstants[enumOrd]
|
||||
val fromOrd = type.asClass()!!.enumConstants[enumOrd] as Enum<*>?
|
||||
|
||||
if (enumName != fromOrd?.toString()) {
|
||||
if (enumName != fromOrd?.name) {
|
||||
throw NotSerializableException("Deserializing obj as enum $type with value $enumName.$enumOrd but "
|
||||
+ "ordinality has changed")
|
||||
}
|
||||
|
@ -22,9 +22,9 @@ open class RatioUnit(val value: BigDecimal) { // TODO: Discuss this type
|
||||
}
|
||||
|
||||
/**
|
||||
* A class to reprecent a percentage in an unambiguous way.
|
||||
* A class to represent a percentage in an unambiguous way.
|
||||
*/
|
||||
open class PercentageRatioUnit(percentageAsString: String) : RatioUnit(BigDecimal(percentageAsString).divide(BigDecimal("100"))) {
|
||||
open class PercentageRatioUnit(val percentageAsString: String) : RatioUnit(BigDecimal(percentageAsString).divide(BigDecimal("100"))) {
|
||||
override fun toString() = value.times(BigDecimal(100)).toString() + "%"
|
||||
}
|
||||
|
||||
@ -39,6 +39,7 @@ val String.percent: PercentageRatioUnit get() = PercentageRatioUnit(this)
|
||||
* Parent of the Rate family. Used to denote fixed rates, floating rates, reference rates etc.
|
||||
*/
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
@CordaSerializable
|
||||
open class Rate(val ratioUnit: RatioUnit? = null) {
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
|
@ -5,7 +5,6 @@ import net.corda.core.crypto.TransactionSignature
|
||||
import net.corda.core.crypto.isFulfilledBy
|
||||
import net.corda.core.flows.FlowException
|
||||
import net.corda.core.flows.FlowLogic
|
||||
import net.corda.core.flows.FlowSession
|
||||
import net.corda.core.flows.InitiatingFlow
|
||||
import net.corda.core.identity.Party
|
||||
import net.corda.core.serialization.CordaSerializable
|
||||
@ -17,7 +16,6 @@ import net.corda.finance.contracts.Fix
|
||||
import net.corda.finance.contracts.FixOf
|
||||
import net.corda.irs.flows.RatesFixFlow.FixOutOfRange
|
||||
import java.math.BigDecimal
|
||||
import java.util.*
|
||||
import java.util.function.Predicate
|
||||
|
||||
// This code is unit tested in NodeInterestRates.kt
|
||||
@ -100,7 +98,7 @@ open class RatesFixFlow(protected val tx: TransactionBuilder,
|
||||
override fun call(): Fix {
|
||||
val oracleSession = initiateFlow(oracle)
|
||||
// TODO: add deadline to receive
|
||||
val resp = oracleSession.sendAndReceive<ArrayList<Fix>>(QueryRequest(listOf(fixOf)))
|
||||
val resp = oracleSession.sendAndReceive<List<Fix>>(QueryRequest(listOf(fixOf)))
|
||||
|
||||
return resp.unwrap {
|
||||
val fix = it.first()
|
||||
|
Loading…
x
Reference in New Issue
Block a user