From e845b370e9e46929ab39e937869ac9b92ceb04c9 Mon Sep 17 00:00:00 2001 From: Chi Nul Date: Sun, 19 Aug 2018 13:29:25 +0200 Subject: [PATCH] Add some comments to Price --- src/main/java/bisq/core/monetary/Price.java | 28 +++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/src/main/java/bisq/core/monetary/Price.java b/src/main/java/bisq/core/monetary/Price.java index 55073eac..aa4703e9 100644 --- a/src/main/java/bisq/core/monetary/Price.java +++ b/src/main/java/bisq/core/monetary/Price.java @@ -30,16 +30,33 @@ import org.jetbrains.annotations.NotNull; /** - * Wrapper for price values with variable precision. If monetary is Altcoin we use precision 8 otherwise Fiat with precision 4. - * The inverted price notation in the offer will be refactored once in a bigger refactoring update. + * Bitcoin price value with variable precision. + * + *
+ * We wrap an object implementing the {@link Monetary} interface from bitcoinj. We respect the + * number of decimal digits of precision defined in the {@code smallestUnitExponent()} defined in + * those classes, like {@link Fiat} or {@link Altcoin}. + * */ public class Price extends MonetaryWrapper implements Comparable { private static final Logger log = LoggerFactory.getLogger(Price.class); + /** + * Create a new {@code Price} from specified {@code Monetary}. + * + * @param monetary + */ public Price(Monetary monetary) { super(monetary); } + /** + * Parse the Bitcoin {@code Price} given a {@code currencyCode} and {@code inputValue}. + * + * @param currencyCode The currency code to parse, e.g "USD" or "LTC". + * @param inputValue The value to parse as a String, e.g "2.54" or "-0.0001". + * @return The parsed Price. + */ public static Price parse(String currencyCode, String inputValue) { final String cleaned = inputValue.replace(",", "."); if (CurrencyUtil.isFiatCurrency(currencyCode)) @@ -48,6 +65,13 @@ public static Price parse(String currencyCode, String inputValue) { return new Price(Altcoin.parseAltcoin(currencyCode, cleaned)); } + /** + * Parse the Bitcoin {@code Price} given a {@code currencyCode} and {@code inputValue}. + * + * @param currencyCode The currency code to parse, e.g "USD" or "LTC". + * @param value The value to parse. + * @return The parsed Price. + */ public static Price valueOf(String currencyCode, long value) { if (CurrencyUtil.isFiatCurrency(currencyCode)) { return new Price(Fiat.valueOf(currencyCode, value));