Slf4jMessageFormatter { public static int getFormatParameterNumber(@Nonnull final String messagePattern) { int nrParams = 0; int i = 0; int j; while ((j = messagePattern.indexOf(DELIM_STR, i)) >= 0) { if (isEscapedDelimeter(messagePattern, j)) { if (isDoubleEscaped(messagePattern, j)) { nrParams++; i = j + 2; } else { i = j + 1; } } else { nrParams++; i = j + 2; } } return nrParams; } private  Slf4jMessageFormatter(); @SuppressWarnings("checkstyle:regexp") static void exHandle(final Object obj, final Appendable sbuf, final Throwable t); static String toString(@Nonnull final String messagePattern,
          final Object... argArray); static int format(@Nonnull final Appendable to, @Nonnull final String messagePattern,
          final Object... argArray); static int format(@Nonnull final Appendable to,
          @Nonnull final ObjectAppenderSupplier appSupplier, @Nonnull final String messagePattern,
          final Object... argArray); static int format(@Nonnull final Appendable to, @Nonnull final String messagePattern,
          @Nonnull final ObjectAppenderSupplier appSupplier, final Object... argArray); static int format(final int firstArgIdx, @Nonnull final Appendable to, @Nonnull final String messagePattern,
          @Nonnull final ObjectAppenderSupplier appSupplier, final Object... argArray); static int getFormatParameterNumber(@Nonnull final String messagePattern); static int format(final ErrorHandler exHandler, final int firstArgIdx,
          @Nonnull final Appendable to, @Nonnull final String messagePattern,
          @Nonnull final ObjectAppenderSupplier appSupplier, final Object... argArray); @SuppressWarnings("unchecked") static void safeObjectAppend(final ErrorHandler exHandler, final Appendable sbuf, final Object obj,
          final ObjectAppenderSupplier appSupplier);  }
@Test public void testGetFormatParameterNumber() { Assert.assertEquals(0, Slf4jMessageFormatter.getFormatParameterNumber("bla bla")); Assert.assertEquals(1, Slf4jMessageFormatter.getFormatParameterNumber("bla bla {}")); Assert.assertEquals(2, Slf4jMessageFormatter.getFormatParameterNumber("{} bla bla {}")); Assert.assertEquals(1, Slf4jMessageFormatter.getFormatParameterNumber("\\{} bla bla {}")); }