@Test public void test_format() { assertThat(Strings.format("Total: %if0[no files]1[one file]<15[%<d files][many files] found", 12), is("Total: 12 files found")); assertThat(Strings.format("%d %<if=1[%s][%iP]", 12, "file"), is("12 files")); }
@Override public int format(FormatterAPI formatter, Object value, Locale locale, String flags, int width, int precision, String formatString, int position) throws IOException { ensureNoWidth(width); ensureNoPrecision(precision); ensureNoFlags(flags); return new Conditional(formatter, value, formatString, position).apply() - position; }
ConditionalConversion extends FormatConversionBase { @Override public int format(FormatterAPI formatter, Object value, Locale locale, String flags, int width, int precision, String formatString, int position) throws IOException { ensureNoWidth(width); ensureNoPrecision(precision); ensureNoFlags(flags); return new Conditional(formatter, value, formatString, position).apply() - position; } }
ConditionalConversion extends FormatConversionBase { @Override public int format(FormatterAPI formatter, Object value, Locale locale, String flags, int width, int precision, String formatString, int position) throws IOException { ensureNoWidth(width); ensureNoPrecision(precision); ensureNoFlags(flags); return new Conditional(formatter, value, formatString, position).apply() - position; }  }
ConditionalConversion extends FormatConversionBase { @Override public int format(FormatterAPI formatter, Object value, Locale locale, String flags, int width, int precision, String formatString, int position) throws IOException { ensureNoWidth(width); ensureNoPrecision(precision); ensureNoFlags(flags); return new Conditional(formatter, value, formatString, position).apply() - position; }  void register(FormatterConfiguration conf); @Override int format(FormatterAPI formatter, Object value, Locale locale, String flags, int width, int precision, String formatString, int position); }
ConditionalConversion extends FormatConversionBase { @Override public int format(FormatterAPI formatter, Object value, Locale locale, String flags, int width, int precision, String formatString, int position) throws IOException { ensureNoWidth(width); ensureNoPrecision(precision); ensureNoFlags(flags); return new Conditional(formatter, value, formatString, position).apply() - position; }  void register(FormatterConfiguration conf); @Override int format(FormatterAPI formatter, Object value, Locale locale, String flags, int width, int precision, String formatString, int position); static final ConditionalConversion INSTANCE; }