DefaultBraceStyleMessageParser extends BraceStyleMessageParser { @Override public void parseBraceFormatTerm( MessageBuilder<?> builder, int index, String message, int termStart, int formatStart, int termEnd) throws ParseException { if (formatStart != -1) { throw ParseException.withBounds( "the default brace style parser does not allow trailing format specifiers", message, formatStart - 1, termEnd - 1); } builder.addParameter(termStart, termEnd, BraceStyleParameter.of(index)); } private  DefaultBraceStyleMessageParser(); static BraceStyleMessageParser getInstance(); @Override void parseBraceFormatTerm(
      MessageBuilder<?> builder,
      int index,
      String message,
      int termStart,
      int formatStart,
      int termEnd);  }
@Test public void testParseBraceFormat() throws ParseException { MessageBuilder<?> builder = mock(MessageBuilder.class); PARSER.parseBraceFormatTerm(builder, 1, "Hello {1} World", 6, -1, 9); ArgumentCaptor<Parameter> param = ArgumentCaptor.forClass(Parameter.class); verify(builder).addParameterImpl(eq(6), eq(9), param.capture()); assertThat(param.getValue().getIndex()).isEqualTo(1); ParameterVisitor out = mock(ParameterVisitor.class); param.getValue().accept(out, new Object[] {"Answer: ", 42}); verify(out).visit(eq(42), eq(FormatChar.DECIMAL), eq(WITH_GROUPING)); }
@Test public void testTrailingFormatNotSupportedInBraceFormat() { try { PARSER.parseBraceFormatTerm(null, 0, "{0:x}", 0, 3, 5); fail("expected ParseException"); } catch (ParseException expected) { assertThat(expected.getMessage()).contains("[:x]"); } }