@Ignore("non-determinism between OpenJDK versions") @Test public void builderTest() { Locale locale; if (Locale.getDefault().equals(GERMANY)) locale = FRANCE; else locale = GERMANY; assertEquals(BtcFormat.builder().build(), BtcFormat.getCoinInstance()); try { BtcFormat.builder().scale(0).style(CODE); fail("Invoking both scale() and style() on a Builder should raise exception"); } catch (IllegalStateException e) {} try { BtcFormat.builder().style(CODE).scale(0); fail("Invoking both style() and scale() on a Builder should raise exception"); } catch (IllegalStateException e) {} BtcFormat built = BtcFormat.builder().style(BtcAutoFormat.Style.CODE).fractionDigits(4).build(); assertEquals(built, BtcFormat.getCodeInstance(4)); built = BtcFormat.builder().style(BtcAutoFormat.Style.SYMBOL).fractionDigits(4).build(); assertEquals(built, BtcFormat.getSymbolInstance(4)); built = BtcFormat.builder().scale(0).build(); assertEquals(built, BtcFormat.getCoinInstance()); built = BtcFormat.builder().scale(3).build(); assertEquals(built, BtcFormat.getMilliInstance()); built = BtcFormat.builder().scale(6).build(); assertEquals(built, BtcFormat.getMicroInstance()); built = BtcFormat.builder().locale(locale).scale(0).build(); assertEquals(built, BtcFormat.getCoinInstance(locale)); built = BtcFormat.builder().locale(locale).scale(3).build(); assertEquals(built, BtcFormat.getMilliInstance(locale)); built = BtcFormat.builder().locale(locale).scale(6).build(); assertEquals(built, BtcFormat.getMicroInstance(locale)); built = BtcFormat.builder().minimumFractionDigits(3).scale(0).build(); assertEquals(built, BtcFormat.getCoinInstance(3)); built = BtcFormat.builder().minimumFractionDigits(3).scale(3).build(); assertEquals(built, BtcFormat.getMilliInstance(3)); built = BtcFormat.builder().minimumFractionDigits(3).scale(6).build(); assertEquals(built, BtcFormat.getMicroInstance(3)); built = BtcFormat.builder().fractionGroups(3,4).scale(0).build(); assertEquals(built, BtcFormat.getCoinInstance(2,3,4)); built = BtcFormat.builder().fractionGroups(3,4).scale(3).build(); assertEquals(built, BtcFormat.getMilliInstance(2,3,4)); built = BtcFormat.builder().fractionGroups(3,4).scale(6).build(); assertEquals(built, BtcFormat.getMicroInstance(2,3,4)); built = BtcFormat.builder().pattern("#,####.#").scale(6).locale(GERMANY).build(); assertEquals("100.0000,00", built.format(COIN)); built = BtcFormat.builder().pattern("#,####.#").scale(6).locale(GERMANY).build(); assertEquals("-100.0000,00", built.format(COIN.multiply(-1))); built = BtcFormat.builder().localizedPattern("#.####,#").scale(6).locale(GERMANY).build(); assertEquals("100.0000,00", built.format(COIN)); built = BtcFormat.builder().pattern("¤#,####.#").style(CODE).locale(GERMANY).build(); assertEquals("฿-1,00", built.format(COIN.multiply(-1))); built = BtcFormat.builder().pattern("¤¤ #,####.#").style(SYMBOL).locale(GERMANY).build(); assertEquals("BTC -1,00", built.format(COIN.multiply(-1))); built = BtcFormat.builder().pattern("¤¤##,###.#").scale(3).locale(US).build(); assertEquals("mBTC1,000.00", built.format(COIN)); built = BtcFormat.builder().pattern("¤ ##,###.#").scale(3).locale(US).build(); assertEquals("₥฿ 1,000.00", built.format(COIN)); try { BtcFormat.builder().pattern("¤¤##,###.#").scale(4).locale(US).build().format(COIN); fail("Pattern with currency sign and non-standard denomination should raise exception"); } catch (IllegalStateException e) {} try { BtcFormat.builder().localizedPattern("¤¤##,###.#").scale(4).locale(US).build().format(COIN); fail("Localized pattern with currency sign and non-standard denomination should raise exception"); } catch (IllegalStateException e) {} built = BtcFormat.builder().style(SYMBOL).symbol("B\u20e6").locale(US).build(); assertEquals("B⃦1.00", built.format(COIN)); built = BtcFormat.builder().style(CODE).code("XBT").locale(US).build(); assertEquals("XBT 1.00", built.format(COIN)); built = BtcFormat.builder().style(SYMBOL).symbol("$").locale(GERMANY).build(); assertEquals("1,00 $", built.format(COIN)); built = BtcFormat.builder().style(SYMBOL).code("USD").locale(US).build(); assertEquals("฿1.00", built.format(COIN)); built = BtcFormat.builder().style(SYMBOL).symbol("B\u20e6").locale(US).build(); assertEquals("₥B⃦1.00", built.format(COIN.divide(1000))); built = BtcFormat.builder().style(CODE).code("XBT").locale(US).build(); assertEquals("mXBT 1.00", built.format(COIN.divide(1000))); built = BtcFormat.builder().style(SYMBOL).symbol("B\u20e6").locale(US).build(); assertEquals("µB⃦1.00", built.format(valueOf(100))); built = BtcFormat.builder().style(CODE).code("XBT").locale(US).build(); assertEquals("µXBT 1.00", built.format(valueOf(100))); built = BtcFormat.builder().pattern("'#'¤#0").scale(0).locale(US).build(); assertEquals("#฿-1.00", built.format(COIN.multiply(-1))); built = BtcFormat.builder().pattern("'#0'¤#0").scale(0).locale(US).build(); assertEquals("#0฿-1.00", built.format(COIN.multiply(-1))); built = BtcFormat.builder().pattern("'#''#'¤#0").scale(0).locale(US).build(); assertEquals("#'#฿-1.00", built.format(COIN.multiply(-1))); built = BtcFormat.builder().pattern("'#0''#'¤#0").scale(0).locale(US).build(); assertEquals("#0'#฿-1.00", built.format(COIN.multiply(-1))); built = BtcFormat.builder().pattern("'#0#'¤#0").scale(0).locale(US).build(); assertEquals("#0#฿-1.00", built.format(COIN.multiply(-1))); built = BtcFormat.builder().pattern("'#0'E'#'¤#0").scale(0).locale(US).build(); assertEquals("#0E#฿-1.00", built.format(COIN.multiply(-1))); built = BtcFormat.builder().pattern("E'#0''#'¤#0").scale(0).locale(US).build(); assertEquals("E#0'#฿-1.00", built.format(COIN.multiply(-1))); built = BtcFormat.builder().pattern("E'#0#'¤#0").scale(0).locale(US).build(); assertEquals("E#0#฿-1.00", built.format(COIN.multiply(-1))); built = BtcFormat.builder().pattern("E'#0''''#'¤#0").scale(0).locale(US).build(); assertEquals("E#0''#฿-1.00", built.format(COIN.multiply(-1))); built = BtcFormat.builder().pattern("''#0").scale(0).locale(US).build(); assertEquals("'-1.00", built.format(COIN.multiply(-1))); BtcFormat a = BtcFormat.builder().scale(3).build(); BtcFormat b = BtcFormat.builder().scale(3).build(); assertEquals(a, b); assertEquals(a.hashCode(), b.hashCode()); a.format(COIN.multiply(1000000)); assertEquals(a, b); assertEquals(a.hashCode(), b.hashCode()); b.format(COIN.divide(1000000)); assertEquals(a, b); assertEquals(a.hashCode(), b.hashCode()); a = BtcFormat.builder().scale(3).pattern("¤#.#").build(); b = BtcFormat.builder().scale(3).pattern("¤#.#").build(); assertEquals(a, b); assertEquals(a.hashCode(), b.hashCode()); a.format(COIN.multiply(1000000)); assertEquals(a, b); assertEquals(a.hashCode(), b.hashCode()); b.format(COIN.divide(1000000)); assertEquals(a, b); assertEquals(a.hashCode(), b.hashCode()); }
public static Builder builder() { return new Builder(); }
BtcFormat extends Format { public static Builder builder() { return new Builder(); } }
BtcFormat extends Format { public static Builder builder() { return new Builder(); } protected  BtcFormat(DecimalFormat numberFormat, int minDecimals, List<Integer> groups); }
BtcFormat extends Format { public static Builder builder() { return new Builder(); } protected  BtcFormat(DecimalFormat numberFormat, int minDecimals, List<Integer> groups); static Builder builder(); static BtcFormat getInstance(); static BtcFormat getSymbolInstance(); static BtcFormat getCodeInstance(); static BtcFormat getSymbolInstance(int fractionPlaces); static BtcFormat getCodeInstance(int minDecimals); static BtcFormat getInstance(Locale locale); static BtcFormat getCodeInstance(Locale locale); static BtcFormat getInstance(Locale locale, int minDecimals); static BtcFormat getCodeInstance(Locale locale, int minDecimals); static BtcFormat getSymbolInstance(Locale locale); static BtcFormat getSymbolInstance(Locale locale, int fractionPlaces); static BtcFormat getInstance(Style style); static BtcFormat getInstance(Style style, int fractionPlaces); static BtcFormat getInstance(Style style, Locale locale); static BtcFormat getInstance(Style style, Locale locale, int fractionPlaces); static BtcFormat getCoinInstance(); static BtcFormat getCoinInstance(int minFractionPlaces, int... groups); static BtcFormat getCoinInstance(Locale locale); static BtcFormat getCoinInstance(Locale locale, int scale, int... groups); static BtcFormat getMilliInstance(); static BtcFormat getMilliInstance(Locale locale); static BtcFormat getMilliInstance(int scale, int... groups); static BtcFormat getMilliInstance(Locale locale, int scale, int... groups); static BtcFormat getMicroInstance(); static BtcFormat getMicroInstance(Locale locale); static BtcFormat getMicroInstance(int scale, int... groups); static BtcFormat getMicroInstance(Locale locale, int scale, int... groups); static BtcFormat getInstance(int scale, int minDecimals, int... groups); static BtcFormat getInstance(int scale); static BtcFormat getInstance(int scale, Locale locale); static BtcFormat getInstance(int scale, Locale locale, int minDecimals, int... groups); static BtcFormat getInstance(int scale, Locale locale, int minDecimals, List<Integer> groups); @Override AttributedCharacterIterator formatToCharacterIterator(Object obj); @Override StringBuffer format(Object qty, StringBuffer toAppendTo, FieldPosition pos); String format(Object qty, int minDecimals, int... fractionGroups); StringBuffer format(Object qty, StringBuffer toAppendTo, FieldPosition pos,
                                            int minDecimals, int... fractionGroups); @Override final Object parseObject(String source, ParsePosition pos); Coin parse(String source, ParsePosition pos); Coin parse(String source); static Locale[] getAvailableLocales(); String coinSymbol(); String coinCode(); String pattern(); DecimalFormatSymbols symbols(); @Override boolean equals(Object o); @Override int hashCode(); }
BtcFormat extends Format { public static Builder builder() { return new Builder(); } protected  BtcFormat(DecimalFormat numberFormat, int minDecimals, List<Integer> groups); static Builder builder(); static BtcFormat getInstance(); static BtcFormat getSymbolInstance(); static BtcFormat getCodeInstance(); static BtcFormat getSymbolInstance(int fractionPlaces); static BtcFormat getCodeInstance(int minDecimals); static BtcFormat getInstance(Locale locale); static BtcFormat getCodeInstance(Locale locale); static BtcFormat getInstance(Locale locale, int minDecimals); static BtcFormat getCodeInstance(Locale locale, int minDecimals); static BtcFormat getSymbolInstance(Locale locale); static BtcFormat getSymbolInstance(Locale locale, int fractionPlaces); static BtcFormat getInstance(Style style); static BtcFormat getInstance(Style style, int fractionPlaces); static BtcFormat getInstance(Style style, Locale locale); static BtcFormat getInstance(Style style, Locale locale, int fractionPlaces); static BtcFormat getCoinInstance(); static BtcFormat getCoinInstance(int minFractionPlaces, int... groups); static BtcFormat getCoinInstance(Locale locale); static BtcFormat getCoinInstance(Locale locale, int scale, int... groups); static BtcFormat getMilliInstance(); static BtcFormat getMilliInstance(Locale locale); static BtcFormat getMilliInstance(int scale, int... groups); static BtcFormat getMilliInstance(Locale locale, int scale, int... groups); static BtcFormat getMicroInstance(); static BtcFormat getMicroInstance(Locale locale); static BtcFormat getMicroInstance(int scale, int... groups); static BtcFormat getMicroInstance(Locale locale, int scale, int... groups); static BtcFormat getInstance(int scale, int minDecimals, int... groups); static BtcFormat getInstance(int scale); static BtcFormat getInstance(int scale, Locale locale); static BtcFormat getInstance(int scale, Locale locale, int minDecimals, int... groups); static BtcFormat getInstance(int scale, Locale locale, int minDecimals, List<Integer> groups); @Override AttributedCharacterIterator formatToCharacterIterator(Object obj); @Override StringBuffer format(Object qty, StringBuffer toAppendTo, FieldPosition pos); String format(Object qty, int minDecimals, int... fractionGroups); StringBuffer format(Object qty, StringBuffer toAppendTo, FieldPosition pos,
                                            int minDecimals, int... fractionGroups); @Override final Object parseObject(String source, ParsePosition pos); Coin parse(String source, ParsePosition pos); Coin parse(String source); static Locale[] getAvailableLocales(); String coinSymbol(); String coinCode(); String pattern(); DecimalFormatSymbols symbols(); @Override boolean equals(Object o); @Override int hashCode(); static final int COIN_SCALE; static final int MILLICOIN_SCALE; static final int MICROCOIN_SCALE; }