Class ExchangeRate


  • public class ExchangeRate
    extends java.lang.Object
    An exchange rate is expressed as a ratio of a Coin and a Fiat amount.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      Coin coin  
      Fiat fiat  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Fiat coinToFiat​(Coin convertCoin)
      Convert a coin amount to a fiat amount using this exchange rate.
      boolean equals​(java.lang.Object o)  
      Coin fiatToCoin​(Fiat convertFiat)
      Convert a fiat amount to a coin amount using this exchange rate.
      int hashCode()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • coin

        public final Coin coin
      • fiat

        public final Fiat fiat
    • Constructor Detail

      • ExchangeRate

        public ExchangeRate​(Coin coin,
                            Fiat fiat)
        Construct exchange rate. This amount of coin is worth that amount of fiat.
      • ExchangeRate

        public ExchangeRate​(Fiat fiat)
        Construct exchange rate. One coin is worth this amount of fiat.
    • Method Detail

      • coinToFiat

        public Fiat coinToFiat​(Coin convertCoin)
        Convert a coin amount to a fiat amount using this exchange rate.
        Throws:
        java.lang.ArithmeticException - if the converted fiat amount is too high or too low.
      • fiatToCoin

        public Coin fiatToCoin​(Fiat convertFiat)
        Convert a fiat amount to a coin amount using this exchange rate.
        Throws:
        java.lang.ArithmeticException - if the converted coin amount is too high or too low.
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object