Class AmountTransfer

  • All Implemented Interfaces:

    
    public final class AmountTransfer<T extends Object, P extends Object>
    
                        

    This class represents a possibly negative transfer of tokens from one vault state to another, possibly at a future date.

    • Constructor Summary

      Constructors 
      Constructor Description
      AmountTransfer(Long quantityDelta, T token, P source, P destination)
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      final Long getQuantityDelta() is a signed Long value representing the exchanged number of tokens.
      final T getToken() represents the type of asset token as would be used to construct Amount<T> objects.
      final P getSource() is the Party, CompositeKey, or other identifier of the token source if quantityDelta is positive, or the token sink if quantityDelta is negative.
      final P getDestination() is the Party, CompositeKey, or other identifier of the token sink if quantityDelta is positive, or the token source if quantityDelta is negative.
      final AmountTransfer<T, P> plus(AmountTransfer<T, P> other) Add together two AmountTransfer objects to produce the single equivalent net flow.
      final BigDecimal toDecimal() Convert the quantityDelta to a displayable format BigDecimal value.
      Boolean equals(Object other) Checks value equality of AmountTransfer objects, but also matches the reversed source and destination equivalent.
      Integer hashCode() This hash code function ensures that reversed source and destination equivalents will hash to the same value.
      final List<AmountTransfer<T, P>> novate(P centralParty) Returns a list of two new AmountTransfers each between one of the original parties and the centralParty.
      final List<SourceAndAmount<T, P>> apply(List<SourceAndAmount<T, P>> balances, Object newRef) Applies this AmountTransfer to a list of SourceAndAmount objects representing balances.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AmountTransfer

        AmountTransfer(Long quantityDelta, T token, P source, P destination)
    • Method Detail

      • getQuantityDelta

         final Long getQuantityDelta()

        is a signed Long value representing the exchanged number of tokens. If positive then it 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) tokens and 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.

      • getToken

         final T getToken()

        represents the type of asset token as would be used to construct Amount<T> objects.

      • getSource

         final P getSource()

        is the Party, 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.

      • getDestination

         final P getDestination()

        is the Party, 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.

      • plus

         final AmountTransfer<T, P> plus(AmountTransfer<T, P> other)

        Add together two 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.

      • toDecimal

         final BigDecimal toDecimal()

        Convert the quantityDelta to a displayable format BigDecimal value. The conversion ratio is the same as for Amount of the same token type.

      • equals

         Boolean equals(Object other)

        Checks value equality of AmountTransfer objects, but also matches the reversed source and destination equivalent.

      • hashCode

         Integer hashCode()

        This hash code function ensures that reversed source and destination equivalents will hash to the same value.

      • novate

         final List<AmountTransfer<T, P>> 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.

        Parameters:
        centralParty - The central party to face the exchange against.
      • apply

         final List<SourceAndAmount<T, P>> apply(List<SourceAndAmount<T, P>> balances, Object newRef)

        Applies this AmountTransfer to a list of 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.

        Parameters:
        balances - The source list of SourceAndAmount objects containing the funds to satisfy the exchange.
        newRef - An optional marker object which is attached to any new SourceAndAmount objects created in the output.