Skip to content

Instantly share code, notes, and snippets.

@lfx
Created October 13, 2023 21:02
Show Gist options
  • Save lfx/854cb6ffd9f566fedf0aa0a373648ec8 to your computer and use it in GitHub Desktop.
Save lfx/854cb6ffd9f566fedf0aa0a373648ec8 to your computer and use it in GitHub Desktop.
NullConverter for Debezium sample
public class NullConverter implements CustomConverter<SchemaBuilder, RelationalColumn> {
private SchemaBuilder stringSchema;
public void configure(Properties props) {
stringSchema = SchemaBuilder.string(); }
public void converterFor(RelationalColumn column, ConverterRegistration<SchemaBuilder> registration) {
Converter converter = this::anyToString;
registration.register(stringSchema, converter);
}
private String anyToString(Object rawValue) {
String converted;
if (rawValue == null) {
converted = "[null]";
} else {
converted = rawValue.toString();
}
return converted;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment