/** * Create a stateful Avro fullname adjuster that calls the supplied {@link ReplacementOccurred} function when an invalid * fullname is seen and replaced with a valid fullname. * * @param replacement the character sequence that should be used to replace all invalid characters * @param uponReplacement the function called each time the original fullname is replaced; may be null * @return the adjuster; never null */ public static SchemaNameAdjuster create(String replacement, ReplacementOccurred uponReplacement) { return (original) -> validFullname(original, c -> replacement, uponReplacement); }
/** * Create a stateful Avro fullname adjuster that calls the supplied {@link ReplacementOccurred} function when an invalid * fullname is seen and replaced with a valid fullname. * * @param function the replacement function * @param uponReplacement the function called each time the original fullname is replaced; may be null * @return the adjuster; never null */ public static SchemaNameAdjuster create(ReplacementFunction function, ReplacementOccurred uponReplacement) { return (original) -> validFullname(original, function, uponReplacement); }
/** * Convert the proposed string to a valid Avro fullname, replacing all invalid characters with the underscore ('_') character. * * @param proposedName the proposed fullname; may not be null * @return the valid fullname for Avro; never null */ public static String validFullname(String proposedName) { return validFullname(proposedName, "_"); }
/** * Convert the proposed string to a valid Avro fullname, replacing all invalid characters with the supplied string. * * @param proposedName the proposed fullname; may not be null * @param replacement the character sequence that should be used to replace all invalid characters * @return the valid fullname for Avro; never null */ public static String validFullname(String proposedName, String replacement) { return validFullname(proposedName, c -> replacement); }
/** * Convert the proposed string to a valid Avro fullname, using the supplied function to replace all invalid characters. * * @param proposedName the proposed fullname; may not be null * @param replacement the character sequence that should be used to replace all invalid characters * @return the valid fullname for Avro; never null */ public static String validFullname(String proposedName, ReplacementFunction replacement) { return validFullname(proposedName, replacement, null); }
/** * Create a stateful Avro fullname adjuster that calls the supplied {@link ReplacementOccurred} function when an invalid * fullname is seen and replaced with a valid fullname. * * @param replacement the character that should be used to replace all invalid characters * @param uponReplacement the function called each time the original fullname is replaced; may be null * @return the adjuster; never null */ public static SchemaNameAdjuster create(char replacement, ReplacementOccurred uponReplacement) { String replacementStr = "" + replacement; return (original) -> validFullname(original, c -> replacementStr, uponReplacement); }
private String validFullName(String proposedName, String suffix) { TableId id = TableId.parse(proposedName, false); return SchemaNameAdjuster.validFullname(TestHelper.TEST_SERVER + "." + id.schema() + "." + id.table() + suffix); }
protected void assertTableIncluded(String fullyQualifiedTableName) { TableId tableId = TableId.parse(fullyQualifiedTableName); TableSchema tableSchema = mysql.schemaFor(tableId); assertThat(tableSchema).isNotNull(); assertThat(tableSchema.keySchema().name()).isEqualTo(SchemaNameAdjuster.validFullname(SERVER_NAME + "." + fullyQualifiedTableName + ".Key")); assertThat(tableSchema.valueSchema().name()).isEqualTo(SchemaNameAdjuster.validFullname(SERVER_NAME + "." + fullyQualifiedTableName + ".Value")); }
/** * Convert the proposed string to a valid Avro fullname, replacing all invalid characters with the underscore ('_') character. * * @param proposedName the proposed fullname; may not be null * @return the valid fullname for Avro; never null */ public static String validFullname(String proposedName) { return validFullname(proposedName, "_"); }
/** * Convert the proposed string to a valid Avro fullname, replacing all invalid characters with the supplied string. * * @param proposedName the proposed fullname; may not be null * @param replacement the character sequence that should be used to replace all invalid characters * @return the valid fullname for Avro; never null */ public static String validFullname(String proposedName, String replacement) { return validFullname(proposedName, c -> replacement); }
/** * Create a stateful Avro fullname adjuster that calls the supplied {@link ReplacementOccurred} function when an invalid * fullname is seen and replaced with a valid fullname. * * @param replacement the character that should be used to replace all invalid characters * @param uponReplacement the function called each time the original fullname is replaced; may be null * @return the adjuster; never null */ public static SchemaNameAdjuster create(char replacement, ReplacementOccurred uponReplacement) { String replacementStr = "" + replacement; return (original) -> validFullname(original, c -> replacementStr, uponReplacement); }
/** * Create a stateful Avro fullname adjuster that calls the supplied {@link ReplacementOccurred} function when an invalid * fullname is seen and replaced with a valid fullname. * * @param replacement the character sequence that should be used to replace all invalid characters * @param uponReplacement the function called each time the original fullname is replaced; may be null * @return the adjuster; never null */ public static SchemaNameAdjuster create(String replacement, ReplacementOccurred uponReplacement) { return (original) -> validFullname(original, c -> replacement, uponReplacement); }
/** * Create a stateful Avro fullname adjuster that calls the supplied {@link ReplacementOccurred} function when an invalid * fullname is seen and replaced with a valid fullname. * * @param function the replacement function * @param uponReplacement the function called each time the original fullname is replaced; may be null * @return the adjuster; never null */ public static SchemaNameAdjuster create(ReplacementFunction function, ReplacementOccurred uponReplacement) { return (original) -> validFullname(original, function, uponReplacement); }
/** * Convert the proposed string to a valid Avro fullname, using the supplied function to replace all invalid characters. * * @param proposedName the proposed fullname; may not be null * @param replacement the character sequence that should be used to replace all invalid characters * @return the valid fullname for Avro; never null */ public static String validFullname(String proposedName, ReplacementFunction replacement) { return validFullname(proposedName, replacement, null); }
private String validFullName(String proposedName, String suffix) { TableId id = TableId.parse(proposedName, false); return SchemaNameAdjuster.validFullname(TestHelper.TEST_SERVER + "." + id.schema() + "." + id.table() + suffix); }
protected void assertTableIncluded(String fullyQualifiedTableName) { TableId tableId = TableId.parse(fullyQualifiedTableName); TableSchema tableSchema = mysql.schemaFor(tableId); assertThat(tableSchema).isNotNull(); assertThat(tableSchema.keySchema().name()).isEqualTo(SchemaNameAdjuster.validFullname(SERVER_NAME + "." + fullyQualifiedTableName + ".Key")); assertThat(tableSchema.valueSchema().name()).isEqualTo(SchemaNameAdjuster.validFullname(SERVER_NAME + "." + fullyQualifiedTableName + ".Value")); }