RocketMqGroupNameNormalizier { public static String normalize(String groupName) { char[] originalChars = groupName.toCharArray(); char[] newChars = new char[originalChars.length]; for (int i = 0; i < originalChars.length; i++) { char originalChar = originalChars[i]; char newChar = isLegalChar(originalChar) ? originalChar : '-'; newChars[i] = newChar; } return new String(newChars); } private  RocketMqGroupNameNormalizier(); static String normalize(String groupName);  }
@Test public void test1() { String originalGroupName = "com.guosen.zebra.hello1.service"; String normalizedGroupName = RocketMqGroupNameNormalizier.normalize(originalGroupName); assertThat(normalizedGroupName, is("com-guosen-zebra-hello1-service")); }
@Test public void test2() { String originalGroupName = "com.$GUOSEN.z%ebra.hello1.service"; String normalizedGroupName = RocketMqGroupNameNormalizier.normalize(originalGroupName); assertThat(normalizedGroupName, is("com--GUOSEN-z%ebra-hello1-service")); }