FormatOptions { public StringBuilder appendPrintfOptions(StringBuilder out) { if (!isDefault()) { int optionFlags = flags & ~FLAG_UPPER_CASE; for (int bit = 0; (1 << bit) <= optionFlags; bit++) { if ((optionFlags & (1 << bit)) != 0) { out.append(FLAG_CHARS_ORDERED.charAt(bit)); } } if (width != UNSET) { out.append(width); } if (precision != UNSET) { out.append('.').append(precision); } } return out; } private  FormatOptions(int flags, int width, int precision); static FormatOptions getDefault(); static FormatOptions of(int flags, int width, int precision); static FormatOptions parse(String message, int pos, int end, boolean isUpperCase); FormatOptions filter(int allowedFlags, boolean allowWidth, boolean allowPrecision); @SuppressWarnings("ReferenceEquality") boolean isDefault(); int getWidth(); int getPrecision(); boolean validate(int allowedFlags, boolean allowPrecision); boolean areValidFor(FormatChar formatChar); int getFlags(); boolean shouldLeftAlign(); boolean shouldShowAltForm(); boolean shouldShowLeadingZeros(); boolean shouldPrefixPlusForPositiveValues(); boolean shouldPrefixSpaceForPositiveValues(); boolean shouldShowGrouping(); boolean shouldUpperCase(); StringBuilder appendPrintfOptions(StringBuilder out); @Override boolean equals(@NullableDecl Object o); @Override int hashCode(); static final int FLAG_PREFIX_SPACE_FOR_POSITIVE_VALUES; static final int FLAG_SHOW_ALT_FORM; static final int FLAG_USE_PARENS_FOR_NEGATIVE_VALUES; static final int FLAG_PREFIX_PLUS_FOR_POSITIVE_VALUES; static final int FLAG_SHOW_GROUPING; static final int FLAG_LEFT_ALIGN; static final int FLAG_SHOW_LEADING_ZEROS; static final int FLAG_UPPER_CASE; static final int ALL_FLAGS; static final int UNSET; }
@Test public void testAppendPrintfOptions() { StringBuilder out = new StringBuilder(); FormatOptions options = parse("+-( #0,123.456", false); options.appendPrintfOptions(out); assertThat(out.toString()).isEqualTo(" #(+,-0123.456"); }