/** * Determine if the supplied string is a valid Avro namespace. * * @param fullname the name to be used as an Avro fullname; may not be null * @return {@code true} if the fullname satisfies Avro rules, or {@code false} otherwise */ public static boolean isValidFullname(String fullname) { if (fullname.length() == 0) return true; char c = fullname.charAt(0); if (!isValidFullnameFirstCharacter(c)) return false; for (int i = 1; i != fullname.length(); ++i) { c = fullname.charAt(i); if (!isValidFullnameNonFirstCharacter(c)) return false; } return true; }
if (isValidFullnameNonFirstCharacter(c)) { sb.append(c); } else {
@Test public void shouldDetermineValidNonFirstCharacters() { String validChars = ".abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_"; for (int i = 0; i != validChars.length(); ++i) { assertThat(SchemaNameAdjuster.isValidFullnameNonFirstCharacter(validChars.charAt(i))).isTrue(); } }
/** * Determine if the supplied string is a valid Avro namespace. * * @param fullname the name to be used as an Avro fullname; may not be null * @return {@code true} if the fullname satisfies Avro rules, or {@code false} otherwise */ public static boolean isValidFullname(String fullname) { if (fullname.length() == 0) return true; char c = fullname.charAt(0); if (!isValidFullnameFirstCharacter(c)) return false; for (int i = 1; i != fullname.length(); ++i) { c = fullname.charAt(i); if (!isValidFullnameNonFirstCharacter(c)) return false; } return true; }
if (isValidFullnameNonFirstCharacter(c)) { sb.append(c); } else {