StringToCharacterConverter implements StringConverter<Character> { @Override public Character convert(String source) { int length = length(source); if (length == 0) { return null; } if (length > 1) { throw new IllegalArgumentException("The source String is more than one character!"); } return source.charAt(0); }  @Override Character convert(String source); @Override int getPriority();  }
@Test public void testConvert() { assertEquals('t', converter.convert("t")); assertNull(converter.convert(null)); assertThrows(IllegalArgumentException.class, () -> { converter.convert("ttt"); }); }