@Override public MonetaryFormat getMonetaryFormat() { if (friendlyFormat == null) { friendlyFormat = FRIENDLY_FORMAT.code(0, currencyCode); } return friendlyFormat; }
/** * Set character range to use for representing digits. It starts with the specified character representing zero. */ public MonetaryFormat digits(char zeroDigit) { if (zeroDigit == this.zeroDigit) return this; else return new MonetaryFormat(negativeSign, positiveSign, zeroDigit, decimalMark, minDecimals, decimalGroups, shift, roundingMode, codes, codeSeparator, codePrefixed); }
/** Construct exchange rate. This amount of coin is worth that amount of fiat. */ public ExchangeRateBase(Value value1, Value value2) { this.value1 = checkNonZero(value1); this.value2 = checkNonZero(value2); }
@Override public MonetaryFormat getPlainFormat() { if (plainFormat == null) { plainFormat = new MonetaryFormat().shift(0) .minDecimals(0).repeatOptionalDecimals(1, unitExponent).noCode(); } return plainFormat; }
public void setExchangeRate(ExchangeRate rate) { if (outputAmount != null) { Value fiatAmount = rate.convert(type, outputAmount.toCoin()); output.setAmountLocal(GenericUtils.formatFiatValue(fiatAmount)); output.setSymbolLocal(fiatAmount.type.getSymbol()); } if (isSending && feeAmount != null) { Value fiatAmount = rate.convert(type, feeAmount.toCoin()); fee.setAmountLocal(GenericUtils.formatFiatValue(fiatAmount)); fee.setSymbolLocal(fiatAmount.type.getSymbol()); } }
public static List<CoinType> typesFromAddress(String address) throws AddressMalformedException { return GenericUtils.getPossibleTypes(address); }
public static String addressSplitToGroupsMultiline(final NxtAddress address) { // Nxt addresses are short, so no need to split them in multiple lines return addressSplitToGroups(address); }
public static String formatFiatValue(Value fiat) { return formatFiatValue(fiat, 2, 0); }
@Override public boolean isType(ValueType otherType) { return TypeUtils.is(type, otherType); }
@Override public boolean canConvert(ValueType type1, ValueType type2) { try { checkIfValueTypeAvailable(type1); checkIfValueTypeAvailable(type2); return true; } catch (IllegalArgumentException ignored) { return false; } }
@Override public Value convert(Value convertingValue) { return convertValue(convertingValue); }
public static boolean hasMultipleTypes(String addressStr) { try { return getPossibleTypes(addressStr).size() > 1; } catch (AddressMalformedException e) { return false; } } }
/** * Set number of digits to shift the decimal separator to the right, coming from the standard BTC notation that was * common pre-2014. Note this will change the currency code if enabled. */ public MonetaryFormat shift(int shift) { if (shift == this.shift) return this; else return new MonetaryFormat(negativeSign, positiveSign, zeroDigit, decimalMark, minDecimals, decimalGroups, shift, roundingMode, codes, codeSeparator, codePrefixed); }
@Override public boolean isType(WalletAccount other) { return TypeUtils.is(type, other); }
/** * Don't display currency code when formatting. This configuration is not relevant for parsing. */ public MonetaryFormat noCode() { if (codes == null) return this; else return new MonetaryFormat(negativeSign, positiveSign, zeroDigit, decimalMark, minDecimals, decimalGroups, shift, roundingMode, null, codeSeparator, codePrefixed); }
@Override public boolean isType(AbstractAddress address) { return TypeUtils.is(type, address); }
/** * Set rounding mode to use when it becomes necessary. */ public MonetaryFormat roundingMode(RoundingMode roundingMode) { if (roundingMode == this.roundingMode) return this; else return new MonetaryFormat(negativeSign, positiveSign, zeroDigit, decimalMark, minDecimals, decimalGroups, shift, roundingMode, codes, codeSeparator, codePrefixed); }
/** * Prefix formatted output by currency code. This configuration is not relevant for parsing. */ public MonetaryFormat prefixCode() { if (codePrefixed) return this; else return new MonetaryFormat(negativeSign, positiveSign, zeroDigit, decimalMark, minDecimals, decimalGroups, shift, roundingMode, codes, codeSeparator, true); }
/** * Postfix formatted output with currency code. This configuration is not relevant for parsing. */ public MonetaryFormat postfixCode() { if (!codePrefixed) return this; else return new MonetaryFormat(negativeSign, positiveSign, zeroDigit, decimalMark, minDecimals, decimalGroups, shift, roundingMode, codes, codeSeparator, false); }
/** * Set minimum number of decimals to use for formatting. If the value precision exceeds all decimals specified * (including additional decimals specified by {@link #optionalDecimals(int...)} or * {@link #repeatOptionalDecimals(int, int)}), the value will be rounded. This configuration is not relevant for * parsing. */ public MonetaryFormat minDecimals(int minDecimals) { if (minDecimals == this.minDecimals) return this; else return new MonetaryFormat(negativeSign, positiveSign, zeroDigit, decimalMark, minDecimals, decimalGroups, shift, roundingMode, codes, codeSeparator, codePrefixed); }