@Test public void builderTest() { Locale locale; if (Locale.getDefault().equals(GERMANY)) locale = FRANCE; else locale = GERMANY; assertEquals(NbtFormat.builder().build(), NbtFormat.getCoinInstance()); try { NbtFormat.builder().scale(0).style(CODE); fail("Invoking both scale() and style() on a Builder should raise exception"); } catch (IllegalStateException e) {} try { NbtFormat.builder().style(CODE).scale(0); fail("Invoking both style() and scale() on a Builder should raise exception"); } catch (IllegalStateException e) {} NbtFormat built = NbtFormat.builder().style(NbtAutoFormat.Style.CODE).fractionDigits(4).build(); assertEquals(built, NbtFormat.getCodeInstance(4)); built = NbtFormat.builder().style(NbtAutoFormat.Style.SYMBOL).fractionDigits(4).build(); assertEquals(built, NbtFormat.getSymbolInstance(4)); built = NbtFormat.builder().scale(0).build(); assertEquals(built, NbtFormat.getCoinInstance()); built = NbtFormat.builder().locale(locale).scale(0).build(); assertEquals(built, NbtFormat.getCoinInstance(locale)); built = NbtFormat.builder().minimumFractionDigits(3).scale(0).build(); assertEquals(built, NbtFormat.getCoinInstance(3)); built = NbtFormat.builder().fractionGroups(3,4).scale(0).build(); assertEquals(built, NbtFormat.getCoinInstance(2,3,4)); built = NbtFormat.builder().pattern("#,###.#").scale(3).locale(GERMANY).build(); assertEquals("1.000,0", built.format(COIN)); built = NbtFormat.builder().pattern("#,###.#").scale(3).locale(GERMANY).build(); assertEquals("-1.000,0", built.format(COIN.multiply(-1))); built = NbtFormat.builder().localizedPattern("#.###,#").scale(3).locale(GERMANY).build(); assertEquals("1.000,0", built.format(COIN)); built = NbtFormat.builder().pattern("¤#,###.#").style(CODE).locale(GERMANY).build(); assertEquals("𝑵-1,00", built.format(COIN.multiply(-1))); built = NbtFormat.builder().pattern("¤¤ #,###.#").style(SYMBOL).locale(GERMANY).build(); assertEquals("NBT -1,00", built.format(COIN.multiply(-1))); built = NbtFormat.builder().pattern("¤¤##,###.#").scale(3).locale(US).build(); try { NbtFormat.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 { NbtFormat.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 = NbtFormat.builder().style(SYMBOL).symbol("\uD835\uDC75").locale(US).build(); assertEquals("𝑵1.00", built.format(COIN)); built = NbtFormat.builder().style(CODE).code("NBT").locale(US).build(); assertEquals("NBT 1.00", built.format(COIN)); built = NbtFormat.builder().style(SYMBOL).symbol("$").locale(GERMANY).build(); assertEquals("1,00 $", built.format(COIN)); built = NbtFormat.builder().style(SYMBOL).code("USD").locale(US).build(); assertEquals("𝑵1.00", built.format(COIN)); built = NbtFormat.builder().pattern("'#'¤#0").scale(0).locale(US).build(); assertEquals("#𝑵-1.00", built.format(COIN.multiply(-1))); built = NbtFormat.builder().pattern("'#0'¤#0").scale(0).locale(US).build(); assertEquals("#0𝑵-1.00", built.format(COIN.multiply(-1))); built = NbtFormat.builder().pattern("'#''#'¤#0").scale(0).locale(US).build(); assertEquals("#'#𝑵-1.00", built.format(COIN.multiply(-1))); built = NbtFormat.builder().pattern("'#0''#'¤#0").scale(0).locale(US).build(); assertEquals("#0'#𝑵-1.00", built.format(COIN.multiply(-1))); built = NbtFormat.builder().pattern("'#0#'¤#0").scale(0).locale(US).build(); assertEquals("#0#𝑵-1.00", built.format(COIN.multiply(-1))); built = NbtFormat.builder().pattern("'#0'E'#'¤#0").scale(0).locale(US).build(); assertEquals("#0E#𝑵-1.00", built.format(COIN.multiply(-1))); built = NbtFormat.builder().pattern("E'#0''#'¤#0").scale(0).locale(US).build(); assertEquals("E#0'#𝑵-1.00", built.format(COIN.multiply(-1))); built = NbtFormat.builder().pattern("E'#0#'¤#0").scale(0).locale(US).build(); assertEquals("E#0#𝑵-1.00", built.format(COIN.multiply(-1))); built = NbtFormat.builder().pattern("E'#0''''#'¤#0").scale(0).locale(US).build(); assertEquals("E#0''#𝑵-1.00", built.format(COIN.multiply(-1))); built = NbtFormat.builder().pattern("''#0").scale(0).locale(US).build(); assertEquals("'-1.00", built.format(COIN.multiply(-1))); NbtFormat a = NbtFormat.builder().scale(3).build(); NbtFormat b = NbtFormat.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 = NbtFormat.builder().scale(3).pattern("¤#.#").build(); b = NbtFormat.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(); }
NbtFormat extends Format { public static Builder builder() { return new Builder(); } }
NbtFormat extends Format { public static Builder builder() { return new Builder(); } protected  NbtFormat(DecimalFormat numberFormat, int minDecimals, List<Integer> groups); }
NbtFormat extends Format { public static Builder builder() { return new Builder(); } protected  NbtFormat(DecimalFormat numberFormat, int minDecimals, List<Integer> groups); static Builder builder(); static NbtFormat getInstance(); static NbtFormat getSymbolInstance(); static NbtFormat getCodeInstance(); static NbtFormat getSymbolInstance(int fractionPlaces); static NbtFormat getCodeInstance(int minDecimals); static NbtFormat getInstance(Locale locale); static NbtFormat getCodeInstance(Locale locale); static NbtFormat getInstance(Locale locale, int minDecimals); static NbtFormat getCodeInstance(Locale locale, int minDecimals); static NbtFormat getSymbolInstance(Locale locale); static NbtFormat getSymbolInstance(Locale locale, int fractionPlaces); static NbtFormat getInstance(Style style); static NbtFormat getInstance(Style style, int fractionPlaces); static NbtFormat getInstance(Style style, Locale locale); static NbtFormat getInstance(Style style, Locale locale, int fractionPlaces); static NbtFormat getCoinInstance(); static NbtFormat getCoinInstance(int minFractionPlaces, int... groups); static NbtFormat getCoinInstance(Locale locale); static NbtFormat getCoinInstance(Locale locale, int scale, int... groups); static NbtFormat getInstance(int scale, int minDecimals, int... groups); static NbtFormat getInstance(int scale); static NbtFormat getInstance(int scale, Locale locale); static NbtFormat getInstance(int scale, Locale locale, int minDecimals, int... groups); static NbtFormat 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(); }
NbtFormat extends Format { public static Builder builder() { return new Builder(); } protected  NbtFormat(DecimalFormat numberFormat, int minDecimals, List<Integer> groups); static Builder builder(); static NbtFormat getInstance(); static NbtFormat getSymbolInstance(); static NbtFormat getCodeInstance(); static NbtFormat getSymbolInstance(int fractionPlaces); static NbtFormat getCodeInstance(int minDecimals); static NbtFormat getInstance(Locale locale); static NbtFormat getCodeInstance(Locale locale); static NbtFormat getInstance(Locale locale, int minDecimals); static NbtFormat getCodeInstance(Locale locale, int minDecimals); static NbtFormat getSymbolInstance(Locale locale); static NbtFormat getSymbolInstance(Locale locale, int fractionPlaces); static NbtFormat getInstance(Style style); static NbtFormat getInstance(Style style, int fractionPlaces); static NbtFormat getInstance(Style style, Locale locale); static NbtFormat getInstance(Style style, Locale locale, int fractionPlaces); static NbtFormat getCoinInstance(); static NbtFormat getCoinInstance(int minFractionPlaces, int... groups); static NbtFormat getCoinInstance(Locale locale); static NbtFormat getCoinInstance(Locale locale, int scale, int... groups); static NbtFormat getInstance(int scale, int minDecimals, int... groups); static NbtFormat getInstance(int scale); static NbtFormat getInstance(int scale, Locale locale); static NbtFormat getInstance(int scale, Locale locale, int minDecimals, int... groups); static NbtFormat 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; }