-
-
Save lfx/854cb6ffd9f566fedf0aa0a373648ec8 to your computer and use it in GitHub Desktop.
NullConverter for Debezium sample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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