Minor: run code cleanup inspections

This commit is contained in:
Mike Hearn 2017-04-11 13:09:58 +02:00
parent e62250ff7b
commit c097229935
41 changed files with 69 additions and 80 deletions

View File

@ -10,7 +10,7 @@ class StringToMethodCallParserTest {
fun simple() = "simple" fun simple() = "simple"
fun string(note: String) = note fun string(note: String) = note
fun twoStrings(a: String, b: String) = a + b fun twoStrings(a: String, b: String) = a + b
fun simpleObject(hash: SecureHash.SHA256) = hash.toString()!! fun simpleObject(hash: SecureHash.SHA256) = hash.toString()
fun complexObject(pair: Pair<Int, String>) = pair fun complexObject(pair: Pair<Int, String>) = pair
fun overload(a: String) = a fun overload(a: String) = a

View File

@ -119,7 +119,7 @@ class CordaRPCClientImpl(private val session: ClientSession,
private var producer: ClientProducer? = null private var producer: ClientProducer? = null
class ObservableDeserializer() : Serializer<Observable<Any>>() { class ObservableDeserializer : Serializer<Observable<Any>>() {
override fun read(kryo: Kryo, input: Input, type: Class<Observable<Any>>): Observable<Any> { override fun read(kryo: Kryo, input: Input, type: Class<Observable<Any>>): Observable<Any> {
val qName = kryo.context[RPCKryoQNameKey] as String val qName = kryo.context[RPCKryoQNameKey] as String
val rpcName = kryo.context[RPCKryoMethodNameKey] as String val rpcName = kryo.context[RPCKryoMethodNameKey] as String

View File

@ -244,7 +244,7 @@ interface LinearState : ContractState {
* Standard clause to verify the LinearState safety properties. * Standard clause to verify the LinearState safety properties.
*/ */
@CordaSerializable @CordaSerializable
class ClauseVerifier<S : LinearState, C : CommandData>() : Clause<S, C, Unit>() { class ClauseVerifier<S : LinearState, C : CommandData> : Clause<S, C, Unit>() {
override fun verify(tx: TransactionForContract, override fun verify(tx: TransactionForContract,
inputs: List<S>, inputs: List<S>,
outputs: List<S>, outputs: List<S>,

View File

@ -33,7 +33,7 @@ fun String.base58ToByteArray(): ByteArray = Base58.decode(this)
fun String.base64ToByteArray(): ByteArray = Base64.getDecoder().decode(this) fun String.base64ToByteArray(): ByteArray = Base64.getDecoder().decode(this)
/** Hex-String to [ByteArray]. Accept any hex form (capitalized, lowercase, mixed). */ /** Hex-String to [ByteArray]. Accept any hex form (capitalized, lowercase, mixed). */
fun String.hexToByteArray(): ByteArray = DatatypeConverter.parseHexBinary(this); fun String.hexToByteArray(): ByteArray = DatatypeConverter.parseHexBinary(this)
// Encoding changers // Encoding changers

View File

@ -6,4 +6,4 @@ import net.corda.core.node.services.Vault
/** /**
* Converter which persists a [Vault.StateStatus] enum using its enum ordinal representation * Converter which persists a [Vault.StateStatus] enum using its enum ordinal representation
*/ */
class VaultStateStatusConverter() : EnumOrdinalConverter<Vault.StateStatus>(Vault.StateStatus::class.java) class VaultStateStatusConverter : EnumOrdinalConverter<Vault.StateStatus>(Vault.StateStatus::class.java)

View File

@ -127,7 +127,7 @@ data class SingletonSerializationToken private constructor(private val className
* A base class for implementing large objects / components / services that need to serialize themselves to a string token * A base class for implementing large objects / components / services that need to serialize themselves to a string token
* to indicate which instance the token is a serialized form of. * to indicate which instance the token is a serialized form of.
*/ */
abstract class SingletonSerializeAsToken() : SerializeAsToken { abstract class SingletonSerializeAsToken : SerializeAsToken {
@Suppress("LeakingThis") @Suppress("LeakingThis")
private val token = SingletonSerializationToken(this) private val token = SingletonSerializationToken(this)

View File

@ -69,7 +69,7 @@ class ResolveTransactionsFlow(private val txHashes: Set<SecureHash>,
} }
@CordaSerializable @CordaSerializable
class ExcessivelyLargeTransactionGraph() : Exception() class ExcessivelyLargeTransactionGraph : Exception()
// Transactions to verify after the dependencies. // Transactions to verify after the dependencies.
private var stx: SignedTransaction? = null private var stx: SignedTransaction? = null

View File

@ -37,7 +37,7 @@ class TransactionSerializationTests {
} }
interface Commands : CommandData { interface Commands : CommandData {
class Move() : TypeOnlyCommandData(), Commands class Move : TypeOnlyCommandData(), Commands
} }
} }

View File

@ -96,7 +96,7 @@ class AmountGenerator<T : Any>(val tokenGenerator: Generator<T>) : Generator<Amo
} }
} }
class CurrencyGenerator() : Generator<Currency>(Currency::class.java) { class CurrencyGenerator : Generator<Currency>(Currency::class.java) {
companion object { companion object {
val currencies = Currency.getAvailableCurrencies().toList() val currencies = Currency.getAvailableCurrencies().toList()
} }

View File

@ -214,8 +214,6 @@ public class CandidacyStatus {
return false; return false;
if (!Objects.equals(this.reason, other.reason)) if (!Objects.equals(this.reason, other.reason))
return false; return false;
if (this.recursiveDepth != other.recursiveDepth) return this.recursiveDepth == other.recursiveDepth;
return false;
return true;
} }
} }

View File

@ -178,11 +178,7 @@ public final class Utils {
* @return * @return
*/ */
public static boolean shouldAttemptToTransitivelyLoad(final String qualifiedClassName) { public static boolean shouldAttemptToTransitivelyLoad(final String qualifiedClassName) {
if (JAVA_PATTERN_QUALIFIED.asPredicate().test(qualifiedClassName)) { return !JAVA_PATTERN_QUALIFIED.asPredicate().test(qualifiedClassName);
return false;
}
return true;
} }
/** /**
@ -200,11 +196,7 @@ public final class Utils {
return false; return false;
} }
if (SANDBOX_PATTERN_INTERNAL.asPredicate().test(clazzName)) { return !SANDBOX_PATTERN_INTERNAL.asPredicate().test(clazzName);
return false;
}
return true;
} }

View File

@ -62,7 +62,7 @@ public class TestUtils {
assertEquals(throwCost, RuntimeCostAccounter.getThrowCost()); assertEquals(throwCost, RuntimeCostAccounter.getThrowCost());
} }
public static Class<?> transformClass(final String classFName, final int originalLength, final int newLength) throws IOException, Exception { public static Class<?> transformClass(final String classFName, final int originalLength, final int newLength) throws Exception {
byte[] basic = getBytes(classFName); byte[] basic = getBytes(classFName);
assertEquals(originalLength, basic.length); assertEquals(originalLength, basic.length);
final byte[] tfmd = instrumentWithCosts(basic, new HashSet<>()); final byte[] tfmd = instrumentWithCosts(basic, new HashSet<>());

View File

@ -11,7 +11,7 @@ import java.util.*
interface Arrangement interface Arrangement
// A base arrangement with no rights and no obligations. Contract cancellation/termination is a transition to ``Zero``. // A base arrangement with no rights and no obligations. Contract cancellation/termination is a transition to ``Zero``.
class Zero() : Arrangement { class Zero : Arrangement {
override fun hashCode(): Int { override fun hashCode(): Int {
return 0 return 0
} }
@ -46,7 +46,7 @@ data class RollOut(val startDate: LocalDate, val endDate: LocalDate, val frequen
// Continuation of roll out // Continuation of roll out
// May only be used inside template for RollOut // May only be used inside template for RollOut
class Continuation() : Arrangement { class Continuation : Arrangement {
override fun hashCode(): Int { override fun hashCode(): Int {
return 1 return 1
} }

View File

@ -196,4 +196,4 @@ class RollOutBuilder<T>(val startDate: LocalDate, val endDate: LocalDate, val fr
RollOut(startDate, endDate, frequency, super.final()) RollOut(startDate, endDate, frequency, super.final())
} }
class Dummy {} class Dummy

View File

@ -152,7 +152,7 @@ class CommercialPaper : Contract {
} }
} }
class Redeem() : Clause<State, Commands, Issued<Terms>>() { class Redeem : Clause<State, Commands, Issued<Terms>>() {
override val requiredCommands: Set<Class<out CommandData>> = setOf(Commands.Redeem::class.java) override val requiredCommands: Set<Class<out CommandData>> = setOf(Commands.Redeem::class.java)
override fun verify(tx: TransactionForContract, override fun verify(tx: TransactionForContract,

View File

@ -62,7 +62,7 @@ class KotlinCommercialPaperTest : ICommercialPaperTestTemplate {
override fun getMoveCommand(): CommandData = CommercialPaper.Commands.Move() override fun getMoveCommand(): CommandData = CommercialPaper.Commands.Move()
} }
class KotlinCommercialPaperLegacyTest() : ICommercialPaperTestTemplate { class KotlinCommercialPaperLegacyTest : ICommercialPaperTestTemplate {
override fun getPaper(): ICommercialPaperState = CommercialPaperLegacy.State( override fun getPaper(): ICommercialPaperState = CommercialPaperLegacy.State(
issuance = MEGA_CORP.ref(123), issuance = MEGA_CORP.ref(123),
owner = MEGA_CORP_PUBKEY, owner = MEGA_CORP_PUBKEY,

View File

@ -76,7 +76,7 @@ class VaultSchemaTest {
data.close() data.close()
} }
private class VaultNoopContract() : Contract { private class VaultNoopContract : Contract {
override val legalContractReference = SecureHash.sha256("") override val legalContractReference = SecureHash.sha256("")
data class VaultNoopState(override val owner: CompositeKey) : OwnableState { data class VaultNoopState(override val owner: CompositeKey) : OwnableState {

View File

@ -202,12 +202,12 @@ abstract class MQSecurityTest : NodeBasedTest() {
fun assertSendAttackFails(address: String) { fun assertSendAttackFails(address: String) {
val message = attacker.createMessage() val message = attacker.createMessage()
assertEquals(true, attacker.producer.isBlockOnNonDurableSend()) assertEquals(true, attacker.producer.isBlockOnNonDurableSend)
assertAttackFails(address, "SEND") { assertAttackFails(address, "SEND") {
attacker.producer.send(address, message) attacker.producer.send(address, message)
} }
assertEquals(0, message.getDeliveryCount()) assertEquals(0, message.deliveryCount)
assertEquals(0, message.getBodySize()) assertEquals(0, message.bodySize)
} }
fun assertConsumeAttackFails(queue: String) { fun assertConsumeAttackFails(queue: String) {

View File

@ -16,7 +16,7 @@ import javax.annotation.concurrent.ThreadSafe
* Simple identity service which caches parties and provides functionality for efficient lookup. * Simple identity service which caches parties and provides functionality for efficient lookup.
*/ */
@ThreadSafe @ThreadSafe
class InMemoryIdentityService() : SingletonSerializeAsToken(), IdentityService { class InMemoryIdentityService : SingletonSerializeAsToken(), IdentityService {
companion object { companion object {
private val log = loggerFor<InMemoryIdentityService>() private val log = loggerFor<InMemoryIdentityService>()
} }

View File

@ -153,7 +153,7 @@ class NodeMessagingClient(override val config: NodeConfiguration,
// TODO Add broker CN to config for host verification in case the embedded broker isn't used // TODO Add broker CN to config for host verification in case the embedded broker isn't used
val tcpTransport = ArtemisTcpTransport.tcpTransport(ConnectionDirection.Outbound(), serverHostPort, config) val tcpTransport = ArtemisTcpTransport.tcpTransport(ConnectionDirection.Outbound(), serverHostPort, config)
val locator = ActiveMQClient.createServerLocatorWithoutHA(tcpTransport) val locator = ActiveMQClient.createServerLocatorWithoutHA(tcpTransport)
locator.setMinLargeMessageSize(ArtemisMessagingServer.MAX_FILE_SIZE) locator.minLargeMessageSize = ArtemisMessagingServer.MAX_FILE_SIZE
clientFactory = locator.createSessionFactory() clientFactory = locator.createSessionFactory()
// Login using the node username. The broker will authentiate us as its node (as opposed to another peer) // Login using the node username. The broker will authentiate us as its node (as opposed to another peer)

View File

@ -52,7 +52,7 @@ abstract class RPCDispatcher(val ops: RPCOps, val userService: RPCUserService, v
// //
// When the observables are deserialised on the client side, the handle is read from the byte stream and // When the observables are deserialised on the client side, the handle is read from the byte stream and
// the queue is filtered to extract just those observations. // the queue is filtered to extract just those observations.
class ObservableSerializer() : Serializer<Observable<Any>>() { class ObservableSerializer : Serializer<Observable<Any>>() {
private fun toQName(kryo: Kryo): String = kryo.context[RPCKryoQNameKey] as String private fun toQName(kryo: Kryo): String = kryo.context[RPCKryoQNameKey] as String
private fun toDispatcher(kryo: Kryo): RPCDispatcher = kryo.context[RPCKryoDispatcherKey] as RPCDispatcher private fun toDispatcher(kryo: Kryo): RPCDispatcher = kryo.context[RPCKryoDispatcherKey] as RPCDispatcher

View File

@ -11,7 +11,7 @@ import javax.annotation.concurrent.ThreadSafe
/** A dummy Uniqueness provider that stores the whole history of consumed states in memory */ /** A dummy Uniqueness provider that stores the whole history of consumed states in memory */
@ThreadSafe @ThreadSafe
class InMemoryUniquenessProvider() : UniquenessProvider { class InMemoryUniquenessProvider : UniquenessProvider {
/** For each input state store the consuming transaction information */ /** For each input state store the consuming transaction information */
private val committedStates = ThreadBox(HashMap<StateRef, UniquenessProvider.ConsumingTx>()) private val committedStates = ThreadBox(HashMap<StateRef, UniquenessProvider.ConsumingTx>())

View File

@ -16,7 +16,7 @@ import javax.annotation.concurrent.ThreadSafe
/** A RDBMS backed Uniqueness provider */ /** A RDBMS backed Uniqueness provider */
@ThreadSafe @ThreadSafe
class PersistentUniquenessProvider() : UniquenessProvider, SingletonSerializeAsToken() { class PersistentUniquenessProvider : UniquenessProvider, SingletonSerializeAsToken() {
companion object { companion object {
private val TABLE_NAME = "${NODE_DATABASE_PREFIX}notary_commit_log" private val TABLE_NAME = "${NODE_DATABASE_PREFIX}notary_commit_log"
private val log = loggerFor<PersistentUniquenessProvider>() private val log = loggerFor<PersistentUniquenessProvider>()
@ -66,7 +66,7 @@ class PersistentUniquenessProvider() : UniquenessProvider, SingletonSerializeAsT
if (consumingTx != null) conflictingStates[inputState] = consumingTx if (consumingTx != null) conflictingStates[inputState] = consumingTx
} }
if (conflictingStates.isNotEmpty()) { if (conflictingStates.isNotEmpty()) {
log.debug("Failure, input states already committed: ${conflictingStates.keys.toString()}") log.debug("Failure, input states already committed: ${conflictingStates.keys}")
UniquenessProvider.Conflict(conflictingStates) UniquenessProvider.Conflict(conflictingStates)
} else { } else {
states.forEachIndexed { i, stateRef -> states.forEachIndexed { i, stateRef ->

View File

@ -61,7 +61,7 @@ class HTTPNetworkRegistrationService(val server: URL) : NetworkRegistrationServi
throw IOException("Unexpected response code ${connection.responseCode} - ${connection.errorMessage}") throw IOException("Unexpected response code ${connection.responseCode} - ${connection.errorMessage}")
} }
private val HttpURLConnection.charset: String get() = MediaType.parse(getContentType()).charset().or(Charsets.UTF_8).name() private val HttpURLConnection.charset: String get() = MediaType.parse(contentType).charset().or(Charsets.UTF_8).name()
private val HttpURLConnection.errorMessage: String get() = IOUtils.toString(errorStream, charset) private val HttpURLConnection.errorMessage: String get() = IOUtils.toString(errorStream, charset)
} }

View File

@ -165,7 +165,7 @@ class TwoPartyTradeFlowTests {
val bobTransactionsBeforeCrash = databaseTransaction(bobNode.database) { val bobTransactionsBeforeCrash = databaseTransaction(bobNode.database) {
(storage as DBTransactionStorage).transactions (storage as DBTransactionStorage).transactions
} }
assertThat(bobTransactionsBeforeCrash).isNotEmpty() assertThat(bobTransactionsBeforeCrash).isNotEmpty
// .. and let's imagine that Bob's computer has a power cut. He now has nothing now beyond what was on disk. // .. and let's imagine that Bob's computer has a power cut. He now has nothing now beyond what was on disk.
bobNode.stop() bobNode.stop()

View File

@ -106,7 +106,7 @@ class NodeAttachmentStorageTest {
val id = testJar.read { storage.importAttachment(it) } val id = testJar.read { storage.importAttachment(it) }
// Corrupt the file in the store. // Corrupt the file in the store.
val bytes = testJar.readAll(); val bytes = testJar.readAll()
val corruptBytes = "arggghhhh".toByteArray() val corruptBytes = "arggghhhh".toByteArray()
System.arraycopy(corruptBytes, 0, bytes, 0, corruptBytes.size) System.arraycopy(corruptBytes, 0, bytes, 0, corruptBytes.size)
val corruptAttachment = AttachmentEntity() val corruptAttachment = AttachmentEntity()

View File

@ -139,7 +139,7 @@ object FixingFlow {
constructor(ref: StateRef) : this(ref, tracker()) constructor(ref: StateRef) : this(ref, tracker())
companion object { companion object {
class LOADING() : ProgressTracker.Step("Loading state to decide fixing role") class LOADING : ProgressTracker.Step("Loading state to decide fixing role")
fun tracker() = ProgressTracker(LOADING()) fun tracker() = ProgressTracker(LOADING())
} }

View File

@ -402,7 +402,7 @@ class IRSTests {
fun `ensure failure occurs when there are inbound states for an agreement command`() { fun `ensure failure occurs when there are inbound states for an agreement command`() {
val irs = singleIRS() val irs = singleIRS()
transaction { transaction {
input() { irs } input { irs }
output("irs post agreement") { irs } output("irs post agreement") { irs }
command(MEGA_CORP_PUBKEY) { InterestRateSwap.Commands.Agree() } command(MEGA_CORP_PUBKEY) { InterestRateSwap.Commands.Agree() }
timestamp(TEST_TX_TIME) timestamp(TEST_TX_TIME)
@ -415,7 +415,7 @@ class IRSTests {
val irs = singleIRS() val irs = singleIRS()
val emptySchedule = mutableMapOf<LocalDate, FixedRatePaymentEvent>() val emptySchedule = mutableMapOf<LocalDate, FixedRatePaymentEvent>()
transaction { transaction {
output() { output {
irs.copy(calculation = irs.calculation.copy(fixedLegPaymentSchedule = emptySchedule)) irs.copy(calculation = irs.calculation.copy(fixedLegPaymentSchedule = emptySchedule))
} }
command(MEGA_CORP_PUBKEY) { InterestRateSwap.Commands.Agree() } command(MEGA_CORP_PUBKEY) { InterestRateSwap.Commands.Agree() }
@ -429,7 +429,7 @@ class IRSTests {
val irs = singleIRS() val irs = singleIRS()
val emptySchedule = mutableMapOf<LocalDate, FloatingRatePaymentEvent>() val emptySchedule = mutableMapOf<LocalDate, FloatingRatePaymentEvent>()
transaction { transaction {
output() { output {
irs.copy(calculation = irs.calculation.copy(floatingLegPaymentSchedule = emptySchedule)) irs.copy(calculation = irs.calculation.copy(floatingLegPaymentSchedule = emptySchedule))
} }
command(MEGA_CORP_PUBKEY) { InterestRateSwap.Commands.Agree() } command(MEGA_CORP_PUBKEY) { InterestRateSwap.Commands.Agree() }
@ -442,7 +442,7 @@ class IRSTests {
fun `ensure notionals are non zero`() { fun `ensure notionals are non zero`() {
val irs = singleIRS() val irs = singleIRS()
transaction { transaction {
output() { output {
irs.copy(irs.fixedLeg.copy(notional = irs.fixedLeg.notional.copy(quantity = 0))) irs.copy(irs.fixedLeg.copy(notional = irs.fixedLeg.notional.copy(quantity = 0)))
} }
command(MEGA_CORP_PUBKEY) { InterestRateSwap.Commands.Agree() } command(MEGA_CORP_PUBKEY) { InterestRateSwap.Commands.Agree() }
@ -451,7 +451,7 @@ class IRSTests {
} }
transaction { transaction {
output() { output {
irs.copy(irs.fixedLeg.copy(notional = irs.floatingLeg.notional.copy(quantity = 0))) irs.copy(irs.fixedLeg.copy(notional = irs.floatingLeg.notional.copy(quantity = 0)))
} }
command(MEGA_CORP_PUBKEY) { InterestRateSwap.Commands.Agree() } command(MEGA_CORP_PUBKEY) { InterestRateSwap.Commands.Agree() }
@ -465,7 +465,7 @@ class IRSTests {
val irs = singleIRS() val irs = singleIRS()
val modifiedIRS = irs.copy(fixedLeg = irs.fixedLeg.copy(fixedRate = FixedRate(PercentageRatioUnit("-0.1")))) val modifiedIRS = irs.copy(fixedLeg = irs.fixedLeg.copy(fixedRate = FixedRate(PercentageRatioUnit("-0.1"))))
transaction { transaction {
output() { output {
modifiedIRS modifiedIRS
} }
command(MEGA_CORP_PUBKEY) { InterestRateSwap.Commands.Agree() } command(MEGA_CORP_PUBKEY) { InterestRateSwap.Commands.Agree() }
@ -482,7 +482,7 @@ class IRSTests {
val irs = singleIRS() val irs = singleIRS()
val modifiedIRS = irs.copy(fixedLeg = irs.fixedLeg.copy(notional = Amount(irs.fixedLeg.notional.quantity, Currency.getInstance("JPY")))) val modifiedIRS = irs.copy(fixedLeg = irs.fixedLeg.copy(notional = Amount(irs.fixedLeg.notional.quantity, Currency.getInstance("JPY"))))
transaction { transaction {
output() { output {
modifiedIRS modifiedIRS
} }
command(MEGA_CORP_PUBKEY) { InterestRateSwap.Commands.Agree() } command(MEGA_CORP_PUBKEY) { InterestRateSwap.Commands.Agree() }
@ -496,7 +496,7 @@ class IRSTests {
val irs = singleIRS() val irs = singleIRS()
val modifiedIRS = irs.copy(fixedLeg = irs.fixedLeg.copy(notional = Amount(irs.floatingLeg.notional.quantity + 1, irs.floatingLeg.notional.token))) val modifiedIRS = irs.copy(fixedLeg = irs.fixedLeg.copy(notional = Amount(irs.floatingLeg.notional.quantity + 1, irs.floatingLeg.notional.token)))
transaction { transaction {
output() { output {
modifiedIRS modifiedIRS
} }
command(MEGA_CORP_PUBKEY) { InterestRateSwap.Commands.Agree() } command(MEGA_CORP_PUBKEY) { InterestRateSwap.Commands.Agree() }
@ -510,7 +510,7 @@ class IRSTests {
val irs = singleIRS() val irs = singleIRS()
val modifiedIRS1 = irs.copy(fixedLeg = irs.fixedLeg.copy(terminationDate = irs.fixedLeg.effectiveDate.minusDays(1))) val modifiedIRS1 = irs.copy(fixedLeg = irs.fixedLeg.copy(terminationDate = irs.fixedLeg.effectiveDate.minusDays(1)))
transaction { transaction {
output() { output {
modifiedIRS1 modifiedIRS1
} }
command(MEGA_CORP_PUBKEY) { InterestRateSwap.Commands.Agree() } command(MEGA_CORP_PUBKEY) { InterestRateSwap.Commands.Agree() }
@ -520,7 +520,7 @@ class IRSTests {
val modifiedIRS2 = irs.copy(floatingLeg = irs.floatingLeg.copy(terminationDate = irs.floatingLeg.effectiveDate.minusDays(1))) val modifiedIRS2 = irs.copy(floatingLeg = irs.floatingLeg.copy(terminationDate = irs.floatingLeg.effectiveDate.minusDays(1)))
transaction { transaction {
output() { output {
modifiedIRS2 modifiedIRS2
} }
command(MEGA_CORP_PUBKEY) { InterestRateSwap.Commands.Agree() } command(MEGA_CORP_PUBKEY) { InterestRateSwap.Commands.Agree() }
@ -535,7 +535,7 @@ class IRSTests {
val modifiedIRS3 = irs.copy(floatingLeg = irs.floatingLeg.copy(terminationDate = irs.fixedLeg.terminationDate.minusDays(1))) val modifiedIRS3 = irs.copy(floatingLeg = irs.floatingLeg.copy(terminationDate = irs.fixedLeg.terminationDate.minusDays(1)))
transaction { transaction {
output() { output {
modifiedIRS3 modifiedIRS3
} }
command(MEGA_CORP_PUBKEY) { InterestRateSwap.Commands.Agree() } command(MEGA_CORP_PUBKEY) { InterestRateSwap.Commands.Agree() }
@ -546,7 +546,7 @@ class IRSTests {
val modifiedIRS4 = irs.copy(floatingLeg = irs.floatingLeg.copy(effectiveDate = irs.fixedLeg.effectiveDate.minusDays(1))) val modifiedIRS4 = irs.copy(floatingLeg = irs.floatingLeg.copy(effectiveDate = irs.fixedLeg.effectiveDate.minusDays(1)))
transaction { transaction {
output() { output {
modifiedIRS4 modifiedIRS4
} }
command(MEGA_CORP_PUBKEY) { InterestRateSwap.Commands.Agree() } command(MEGA_CORP_PUBKEY) { InterestRateSwap.Commands.Agree() }
@ -575,7 +575,7 @@ class IRSTests {
oldIRS.common) oldIRS.common)
transaction { transaction {
input() { input {
oldIRS oldIRS
} }
@ -586,7 +586,7 @@ class IRSTests {
InterestRateSwap.Commands.Refix(Fix(FixOf("ICE LIBOR", ld, Tenor("3M")), bd)) InterestRateSwap.Commands.Refix(Fix(FixOf("ICE LIBOR", ld, Tenor("3M")), bd))
} }
timestamp(TEST_TX_TIME) timestamp(TEST_TX_TIME)
output() { newIRS } output { newIRS }
this.verifies() this.verifies()
} }
@ -594,7 +594,7 @@ class IRSTests {
tweak { tweak {
command(ORACLE_PUBKEY) { InterestRateSwap.Commands.Refix(Fix(FixOf("ICE LIBOR", ld, Tenor("3M")), bd)) } command(ORACLE_PUBKEY) { InterestRateSwap.Commands.Refix(Fix(FixOf("ICE LIBOR", ld, Tenor("3M")), bd)) }
timestamp(TEST_TX_TIME) timestamp(TEST_TX_TIME)
output() { oldIRS } output { oldIRS }
this `fails with` "There is at least one difference in the IRS floating leg payment schedules" this `fails with` "There is at least one difference in the IRS floating leg payment schedules"
} }
@ -607,7 +607,7 @@ class IRSTests {
val firstResetValue = newIRS.calculation.floatingLegPaymentSchedule[firstResetKey] val firstResetValue = newIRS.calculation.floatingLegPaymentSchedule[firstResetKey]
val modifiedFirstResetValue = firstResetValue!!.copy(notional = Amount(firstResetValue.notional.quantity, Currency.getInstance("JPY"))) val modifiedFirstResetValue = firstResetValue!!.copy(notional = Amount(firstResetValue.notional.quantity, Currency.getInstance("JPY")))
output() { output {
newIRS.copy( newIRS.copy(
newIRS.fixedLeg, newIRS.fixedLeg,
newIRS.floatingLeg, newIRS.floatingLeg,
@ -627,7 +627,7 @@ class IRSTests {
val latestReset = newIRS.calculation.floatingLegPaymentSchedule.filter { it.value.rate is FixedRate }.maxBy { it.key } val latestReset = newIRS.calculation.floatingLegPaymentSchedule.filter { it.value.rate is FixedRate }.maxBy { it.key }
val modifiedLatestResetValue = latestReset!!.value.copy(notional = Amount(latestReset.value.notional.quantity, Currency.getInstance("JPY"))) val modifiedLatestResetValue = latestReset!!.value.copy(notional = Amount(latestReset.value.notional.quantity, Currency.getInstance("JPY")))
output() { output {
newIRS.copy( newIRS.copy(
newIRS.fixedLeg, newIRS.fixedLeg,
newIRS.floatingLeg, newIRS.floatingLeg,

View File

@ -52,7 +52,7 @@ class NetworkMapVisualiser : Application() {
sealed class RunningPausedState { sealed class RunningPausedState {
class Running(val tickTimer: TimerTask) : RunningPausedState() class Running(val tickTimer: TimerTask) : RunningPausedState()
class Paused() : RunningPausedState() class Paused : RunningPausedState()
val buttonLabel: RunPauseButtonLabel val buttonLabel: RunPauseButtonLabel
get() { get() {

View File

@ -25,7 +25,7 @@ import net.corda.netmap.VisualiserViewModel.Style
data class TrackerWidget(val vbox: VBox, val cursorBox: Pane, val label: Label, val cursor: Polygon) data class TrackerWidget(val vbox: VBox, val cursorBox: Pane, val label: Label, val cursor: Polygon)
internal class VisualiserView() { internal class VisualiserView {
lateinit var root: Pane lateinit var root: Pane
lateinit var stage: Stage lateinit var stage: Stage
lateinit var splitter: SplitPane lateinit var splitter: SplitPane
@ -70,7 +70,7 @@ internal class VisualiserView() {
//repositionNodes() //repositionNodes()
} }
} }
scaleMap(displayStyle); scaleMap(displayStyle)
root = Pane(mapImage) root = Pane(mapImage)
root.background = Background(BackgroundFill(backgroundColor, CornerRadii.EMPTY, Insets.EMPTY)) root.background = Background(BackgroundFill(backgroundColor, CornerRadii.EMPTY, Insets.EMPTY))
scrollPane = buildScrollPane(backgroundColor, displayStyle) scrollPane = buildScrollPane(backgroundColor, displayStyle)

View File

@ -105,8 +105,8 @@ class VisualiserViewModel {
val yOffset = -80 val yOffset = -80
val circleX = view.stageWidth / 2 + xOffset val circleX = view.stageWidth / 2 + xOffset
val circleY = view.stageHeight / 2 + yOffset val circleY = view.stageHeight / 2 + yOffset
val x: Double = radius * Math.cos(tangentRad) + circleX; val x: Double = radius * Math.cos(tangentRad) + circleX
val y: Double = radius * Math.sin(tangentRad) + circleY; val y: Double = radius * Math.sin(tangentRad) + circleY
return Pair(x, y) return Pair(x, y)
} }

View File

@ -80,7 +80,7 @@ class OGSIMMAnalyticsEngine : AnalyticsEngine() {
var totalSensitivities = CurrencyParameterSensitivities.empty() var totalSensitivities = CurrencyParameterSensitivities.empty()
var totalCurrencyExposure = MultiCurrencyAmount.empty() var totalCurrencyExposure = MultiCurrencyAmount.empty()
for (resolvedTrade in trades) { for (resolvedTrade in trades) {
val swap = resolvedTrade.getProduct() val swap = resolvedTrade.product
val pointSensitivities = pricer.presentValueSensitivity(swap, combinedRatesProvider).build() val pointSensitivities = pricer.presentValueSensitivity(swap, combinedRatesProvider).build()
val sensitivities = combinedRatesProvider.parameterSensitivity(pointSensitivities) val sensitivities = combinedRatesProvider.parameterSensitivity(pointSensitivities)

View File

@ -11,20 +11,20 @@ import com.opengamma.strata.pricer.rate.ImmutableRatesProvider
*/ */
@Suppress("UNUSED_PARAMETER") @Suppress("UNUSED_PARAMETER")
class PortfolioNormalizer(eur: Currency?, combinedRatesProvider: ImmutableRatesProvider?) {} class PortfolioNormalizer(eur: Currency?, combinedRatesProvider: ImmutableRatesProvider?)
/** /**
* Stub class for the real BIMM implementation * Stub class for the real BIMM implementation
*/ */
@Suppress("UNUSED_PARAMETER") @Suppress("UNUSED_PARAMETER")
class RwamBimmNotProductClassesCalculator(fxRateProvider: MarketDataFxRateProvider?, eur: Currency?, instance: Any) {} class RwamBimmNotProductClassesCalculator(fxRateProvider: MarketDataFxRateProvider?, eur: Currency?, instance: Any)
/** /**
* Stub class for the real BIMM implementation * Stub class for the real BIMM implementation
*/ */
@Suppress("UNUSED_PARAMETER") @Suppress("UNUSED_PARAMETER")
class IsdaConfiguration { class IsdaConfiguration {
object INSTANCE {} object INSTANCE
} }
/** /**

View File

@ -24,8 +24,7 @@ data class SwapDataView(
var IM: Double? = null, var IM: Double? = null,
var MTM: Double? = null, var MTM: Double? = null,
var margined: Boolean = false, var margined: Boolean = false,
var marginedText: String = "❌️") { var marginedText: String = "❌️")
}
fun SwapData.toView(viewingParty: Party, portfolio: Portfolio? = null, fun SwapData.toView(viewingParty: Party, portfolio: Portfolio? = null,
presentValue: MultiCurrencyAmount? = null, presentValue: MultiCurrencyAmount? = null,

View File

@ -31,7 +31,7 @@ data class OGTrade(override val legalContractReference: SecureHash = SecureHash.
class Group : GroupClauseVerifier<IRSState, Commands, UniqueIdentifier>(AnyOf(Agree())) { class Group : GroupClauseVerifier<IRSState, Commands, UniqueIdentifier>(AnyOf(Agree())) {
override fun groupStates(tx: TransactionForContract): List<TransactionForContract.InOutGroup<IRSState, UniqueIdentifier>> override fun groupStates(tx: TransactionForContract): List<TransactionForContract.InOutGroup<IRSState, UniqueIdentifier>>
// Group by Trade ID for in / out states // Group by Trade ID for in / out states
= tx.groupStates() { state -> state.linearId } = tx.groupStates { state -> state.linearId }
} }
class Agree : Clause<IRSState, Commands, UniqueIdentifier>() { class Agree : Clause<IRSState, Commands, UniqueIdentifier>() {

View File

@ -33,7 +33,7 @@ data class PortfolioSwap(override val legalContractReference: SecureHash = Secur
class Group : GroupClauseVerifier<PortfolioState, Commands, UniqueIdentifier>(FirstOf(Agree(), Update())) { class Group : GroupClauseVerifier<PortfolioState, Commands, UniqueIdentifier>(FirstOf(Agree(), Update())) {
override fun groupStates(tx: TransactionForContract): List<TransactionForContract.InOutGroup<PortfolioState, UniqueIdentifier>> override fun groupStates(tx: TransactionForContract): List<TransactionForContract.InOutGroup<PortfolioState, UniqueIdentifier>>
// Group by Trade ID for in / out states // Group by Trade ID for in / out states
= tx.groupStates() { state -> state.linearId } = tx.groupStates { state -> state.linearId }
} }
class Update : Clause<PortfolioState, Commands, UniqueIdentifier>() { class Update : Clause<PortfolioState, Commands, UniqueIdentifier>() {

View File

@ -29,7 +29,7 @@ class NodeApi {
} }
private fun waitForNodeStartup(nodeWebserverAddr: HostAndPort) { private fun waitForNodeStartup(nodeWebserverAddr: HostAndPort) {
val url = URL("http://${nodeWebserverAddr.toString()}/api/status") val url = URL("http://$nodeWebserverAddr/api/status")
var retries = 0 var retries = 0
var respCode: Int var respCode: Int
do { do {
@ -45,10 +45,10 @@ class NodeApi {
"Node hasn't started" "Node hasn't started"
} catch(e: SocketException) { } catch(e: SocketException) {
respCode = -1 respCode = -1
"Could not connect: ${e.toString()}" "Could not connect: $e"
} catch (e: IOException) { } catch (e: IOException) {
respCode = -1 respCode = -1
"IOException: ${e.toString()}" "IOException: $e"
} }
if (retries > NODE_WAIT_RETRY_COUNT) { if (retries > NODE_WAIT_RETRY_COUNT) {

View File

@ -3,7 +3,7 @@ package net.corda.demobench.ui
import javafx.scene.control.Label import javafx.scene.control.Label
import javafx.scene.layout.HBox import javafx.scene.layout.HBox
class PropertyLabel() : HBox() { class PropertyLabel : HBox() {
val nameLabel = Label() val nameLabel = Label()
val valueLabel = Label() val valueLabel = Label()

View File

@ -12,7 +12,7 @@ class LocalWebServer : WebServer() {
@Throws(SQLException::class) @Throws(SQLException::class)
override fun addSession(conn: Connection): String { override fun addSession(conn: Connection): String {
val session = createNewSession("local") val session = createNewSession("local")
session.setConnection(conn) session.connection = conn
session.put("url", conn.metaData.url) session.put("url", conn.metaData.url)
val s = session.get("sessionId") as String val s = session.get("sessionId") as String
return url + "/frame.jsp?jsessionid=" + s return url + "/frame.jsp?jsessionid=" + s

View File

@ -156,7 +156,7 @@ class TransactionViewer : CordaView("Transactions") {
private fun ObservableList<StateAndRef<ContractState>>.getParties() = map { it.state.data.participants.map { getModel<NetworkIdentityModel>().lookup(it) } } private fun ObservableList<StateAndRef<ContractState>>.getParties() = map { it.state.data.participants.map { getModel<NetworkIdentityModel>().lookup(it) } }
private fun ObservableList<StateAndRef<ContractState>>.toText() = map { it.contract().javaClass.simpleName }.groupBy { it }.map { "${it.key} (${it.value.size})" }.joinToString() private fun ObservableList<StateAndRef<ContractState>>.toText() = map { it.contract().javaClass.simpleName }.groupBy { it }.map { "${it.key} (${it.value.size})" }.joinToString()
private class TransactionWidget() : BorderPane() { private class TransactionWidget : BorderPane() {
private val partiallyResolvedTransactions by observableListReadOnly(TransactionDataModel::partiallyResolvedTransactions) private val partiallyResolvedTransactions by observableListReadOnly(TransactionDataModel::partiallyResolvedTransactions)
// TODO : Add a scrolling table to show latest transaction. // TODO : Add a scrolling table to show latest transaction.

View File

@ -213,7 +213,7 @@ class CashViewer : CordaView("Cash") {
treeItem treeItem
} }
cashViewerTable.apply() { cashViewerTable.apply {
root = TreeItem() root = TreeItem()
val children: List<TreeItem<out ViewerNode>> = root.children val children: List<TreeItem<out ViewerNode>> = root.children
Bindings.bindContent(children, cashViewerIssueNodes) Bindings.bindContent(children, cashViewerIssueNodes)
@ -280,7 +280,7 @@ class CashViewer : CordaView("Cash") {
} }
} }
private class CashWidget() : VBox() { private class CashWidget : VBox() {
// Inject data. // Inject data.
private val reportingCurrency by observableValue(SettingsModel::reportingCurrencyProperty) private val reportingCurrency by observableValue(SettingsModel::reportingCurrencyProperty)
private val cashStates by observableList(ContractStateModel::cashStates) private val cashStates by observableList(ContractStateModel::cashStates)