@Override
    public String filterCharacters(String input) {
        char[] chars = null;
        final int strLen = input.length();
        int pos = 0;

        for (int i = 0; i < strLen; i++) {
            final char c = input.charAt(i);
            switch (c) {
                case ':':
                    if (chars == null) {
                        chars = input.toCharArray();
                    }
                    chars[pos++] = '-';
                    break;

                default:
                    if (chars != null) {
                        chars[pos] = c;
                    }
                    pos++;
            }
        }

        return chars == null ? input : new String(chars, 0, pos);
    }
@Test
    void testReplaceInvalidChars() {
        StatsDReporter reporter = new StatsDReporter();

        assertThat(reporter.filterCharacters("")).isEqualTo("");
        assertThat(reporter.filterCharacters("abc")).isEqualTo("abc");
        assertThat(reporter.filterCharacters("a:b::")).isEqualTo("a-b--");
    }