use of org.apache.avro.Schema.Type in project apex-malhar by apache.
the class AvroRecordHelper method convertValueStringToAvroKeyType.
/**
* Convert a passed String value to the given type for the key as per Schema
*/
public static Object convertValueStringToAvroKeyType(Schema schema, String key, String value) throws ParseException {
Type type = null;
if (schema.getField(key) != null) {
type = schema.getField(key).schema().getType();
} else {
return value;
}
Object convertedValue = null;
if (type == Type.UNION) {
convertedValue = convertAndResolveUnionToPrimitive(schema, key, value);
} else {
convertedValue = convertValueToAvroPrimitive(type, key, value);
}
return convertedValue;
}
Aggregations