@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")); }
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); }
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); } }
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(); }
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); }
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);  }