From 8c99e61e01ae792bdf2687eef07d714fc1d63591 Mon Sep 17 00:00:00 2001 From: Andreas Schildbach Date: Sun, 12 Oct 2014 19:11:04 +0200 Subject: [PATCH] Add missing JavaDocs for ExchangeRate. --- .../src/main/java/org/bitcoinj/utils/ExchangeRate.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/core/src/main/java/org/bitcoinj/utils/ExchangeRate.java b/core/src/main/java/org/bitcoinj/utils/ExchangeRate.java index c4829bc5e..10c928e6a 100644 --- a/core/src/main/java/org/bitcoinj/utils/ExchangeRate.java +++ b/core/src/main/java/org/bitcoinj/utils/ExchangeRate.java @@ -31,16 +31,22 @@ public class ExchangeRate implements Serializable { public final Coin coin; public final Fiat fiat; + /** Construct exchange rate. This amount of coin is worth that amount of fiat. */ public ExchangeRate(Coin coin, Fiat fiat) { this.coin = coin; this.fiat = fiat; } + /** Construct exchange rate. One coin is worth this amount of fiat. */ public ExchangeRate(Fiat fiat) { this.coin = Coin.COIN; this.fiat = fiat; } + /** + * Convert a coin amount to a fiat amount using this exchange rate. + * @throws ArithmeticException if the converted fiat amount is too high or too low. + */ public Fiat coinToFiat(Coin convertCoin) { // Use BigInteger because it's much easier to maintain full precision without overflowing. final BigInteger converted = BigInteger.valueOf(convertCoin.value).multiply(BigInteger.valueOf(fiat.value)) @@ -51,6 +57,10 @@ public class ExchangeRate implements Serializable { return Fiat.valueOf(fiat.currencyCode, converted.longValue()); } + /** + * Convert a fiat amount to a coin amount using this exchange rate. + * @throws ArithmeticException if the converted coin amount is too high or too low. + */ public Coin fiatToCoin(Fiat convertFiat) { checkArgument(convertFiat.currencyCode.equals(fiat.currencyCode), "Currency mismatch: %s vs %s", convertFiat.currencyCode, fiat.currencyCode);