public class AmountTransfer<T,P>
This class represents a possibly negative transfer of tokens from one vault state to another, possibly at a future date.
Modifier and Type | Class and Description |
---|---|
static class |
AmountTransfer.Companion |
Modifier and Type | Field and Description |
---|---|
static AmountTransfer.Companion |
Companion |
Constructor and Description |
---|
AmountTransfer(long quantityDelta,
T token,
P source,
P destination)
This class represents a possibly negative transfer of tokens from one vault state to another, possibly at a future date.
|
Modifier and Type | Method and Description |
---|---|
java.util.List<net.corda.core.contracts.SourceAndAmount> |
apply(java.util.List<? extends net.corda.core.contracts.SourceAndAmount<T,? extends P>> balances,
java.lang.Object newRef)
Applies this AmountTransfer to a list of
class SourceAndAmount objects representing balances.
The list can be heterogeneous in terms of token types and parties, so long as there is sufficient balance
of the correct token type held with the party paying for the transfer. |
boolean |
equals(java.lang.Object other)
Checks value equality of AmountTransfer objects, but also matches the reversed source and destination equivalent.
|
P |
getDestination()
is the
|
long |
getQuantityDelta()
is a signed Long value representing the exchanged number of tokens.
|
P |
getSource()
is the
|
T |
getToken()
represents the type of asset token as would be used to construct Amount
|
int |
hashCode()
This hash code function ensures that reversed source and destination equivalents will hash to the same value.
|
java.util.List<net.corda.core.contracts.AmountTransfer> |
novate(P centralParty)
Returns a list of two new AmountTransfers each between one of the original parties and the centralParty. The net
total exchange is the same as in the original input. Novation is a common financial operation in which a
bilateral exchange is modified so that the same relative asset exchange happens, but with each party exchanging
versus a central counterparty, or clearing house.
|
AmountTransfer<T,P> |
plus(AmountTransfer<T,P> other)
Add together two
class AmountTransfer objects to produce the single equivalent net flow.
The addition only applies to AmountTransfer objects with the same token type.
Also the pair of parties must be aligned, although source destination may be
swapped in the second item. |
java.math.BigDecimal |
toDecimal()
Convert the quantityDelta to a displayable format BigDecimal value. The conversion ratio is the same as for
class Amount of the same token type. |
public static AmountTransfer.Companion Companion
public AmountTransfer(long quantityDelta, T token, P source, P destination)
This class represents a possibly negative transfer of tokens from one vault state to another, possibly at a future date.
quantityDelta
- is a signed Long value representing the exchanged number of tokens. If positive thenit represents the movement of Math.abs(quantityDelta) tokens away from source and receipt of Math.abs(quantityDelta)at the destination. If the quantityDelta is negative then the source will receive Math.abs(quantityDelta) tokensand the destination will lose Math.abs(quantityDelta) tokens.Where possible the source and destination should be coded to ensure a positive quantityDelta,but in various scenarios it may be more consistent to allow positive and negative values.For example it is common for a bank to code asset flows as gains and losses from its perspective i.e. always the destination.token
- represents the type of asset token as would be used to construct Amount objects.source
- is the class Party
, class CompositeKey
, or other identifier of the token source if quantityDelta is positive,or the token sink if quantityDelta is negative. The type P should support value equality.destination
- is the class Party
, class CompositeKey
, or other identifier of the token sink if quantityDelta is positive,or the token source if quantityDelta is negative. The type P should support value equality.public AmountTransfer<T,P> plus(AmountTransfer<T,P> other)
Add together two class AmountTransfer
objects to produce the single equivalent net flow.
The addition only applies to AmountTransfer objects with the same token type.
Also the pair of parties must be aligned, although source destination may be
swapped in the second item.
class AmountTransfer
public java.math.BigDecimal toDecimal()
Convert the quantityDelta to a displayable format BigDecimal value. The conversion ratio is the same as for
class Amount
of the same token type.
class Amount
public boolean equals(java.lang.Object other)
Checks value equality of AmountTransfer objects, but also matches the reversed source and destination equivalent.
public int hashCode()
This hash code function ensures that reversed source and destination equivalents will hash to the same value.
public java.util.List<net.corda.core.contracts.AmountTransfer> novate(P centralParty)
Returns a list of two new AmountTransfers each between one of the original parties and the centralParty. The net total exchange is the same as in the original input. Novation is a common financial operation in which a bilateral exchange is modified so that the same relative asset exchange happens, but with each party exchanging versus a central counterparty, or clearing house.
centralParty
- The central party to face the exchange against.public java.util.List<net.corda.core.contracts.SourceAndAmount> apply(java.util.List<? extends net.corda.core.contracts.SourceAndAmount<T,? extends P>> balances, java.lang.Object newRef)
Applies this AmountTransfer to a list of class SourceAndAmount
objects representing balances.
The list can be heterogeneous in terms of token types and parties, so long as there is sufficient balance
of the correct token type held with the party paying for the transfer.
balances
- The source list of class SourceAndAmount
objects containing the funds to satisfy the exchange.newRef
- An optional marker object which is attached to any new class SourceAndAmount
objects created in the output.
i.e. To the new payment destination entry and to any residual change output.class SourceAndAmount
public long getQuantityDelta()
is a signed Long value representing the exchanged number of tokens.
If positive thenit represents the movement of Math.abs(quantityDelta) tokens away from source and receipt of Math.abs(quantityDelta)at the destination. If the quantityDelta is negative then the source will receive Math.abs(quantityDelta) tokensand the destination will lose Math.abs(quantityDelta) tokens.Where possible the source and destination should be coded to ensure a positive quantityDelta,but in various scenarios it may be more consistent to allow positive and negative values.For example it is common for a bank to code asset flows as gains and losses from its perspective i.e. always the destination.
public T getToken()
represents the type of asset token as would be used to construct Amount
objects.
public P getSource()
is the
class Party
, class CompositeKey
, or other identifier of the token source if quantityDelta is positive,or the token sink if quantityDelta is negative. The type P should support value equality.
class Party
,
class CompositeKey
public P getDestination()
is the
class Party
, class CompositeKey
, or other identifier of the token sink if quantityDelta is positive,or the token source if quantityDelta is negative. The type P should support value equality.
class Party
,
class CompositeKey