@Override public String convertToAvro(String value) { // String to Character (datum type), then Character (datum type to String (Avro-compatible types) return StringUtils.isEmpty(value) ? null : ParserUtils.parseToCharacter(value).toString(); } }
NumberConverter(Schema.Field field, FileDelimitedProperties properties) { this.field = field; this.properties = properties; if (properties.advancedSeparator.getValue()) { this.thousandsSepChar = ParserUtils.parseToCharacter(properties.thousandsSeparator.getValue()); this.decimalSepChar = ParserUtils.parseToCharacter(properties.decimalSeparator.getValue()); } if ((properties instanceof TFileInputDelimitedProperties) && ((TFileInputDelimitedProperties) properties).enableDecode.getValue()) { Object values = ((TFileInputDelimitedProperties) properties).decodeTable.decode.getValue(); if (values != null && values instanceof List) { decodeList = (List<Boolean>) values; } } }
@Test public void testParseToCharacter() throws Exception { assertNull(ParserUtils.parseToCharacter(null)); assertEquals((Character) 'a', ParserUtils.parseToCharacter("a")); assertEquals((Character) 'b', ParserUtils.parseToCharacter("bc")); }