CodeFormatter { void putFormatter(Character identifier, BiFunction<Object, String, String> formatter) { if (!VALID_FORMATTER_CHARS.contains(identifier)) { throw new IllegalArgumentException("Invalid formatter identifier: " + identifier); } formatters.put(identifier, formatter); }    }
@Test public void formattersMustNotBeLowercase() { Assertions.assertThrows(IllegalArgumentException.class, () -> { CodeFormatter formatter = new CodeFormatter(); formatter.putFormatter('a', CodeFormatterTest::valueOf); }); }
@Test public void formattersMustNotBeNumbers() { Assertions.assertThrows(IllegalArgumentException.class, () -> { CodeFormatter formatter = new CodeFormatter(); formatter.putFormatter('1', CodeFormatterTest::valueOf); }); }
@Test public void formattersMustNotBeDollar() { Assertions.assertThrows(IllegalArgumentException.class, () -> { CodeFormatter formatter = new CodeFormatter(); formatter.putFormatter('$', CodeFormatterTest::valueOf); }); }