@Override
protected void readField(Object record, Field f, Object oldDatum,
ResolvingDecoder in, Object state) throws IOException {
if (state != null) {
FieldAccessor accessor = ((FieldAccessor[]) state)[f.pos()];
if (accessor != null) {
if (accessor.supportsIO()
&& (!Schema.Type.UNION.equals(f.schema().getType())
|| accessor.isCustomEncoded())) {
accessor.read(record, in);
return;
}
if (accessor.isStringable()) {
try {
String asString = (String) read(null, f.schema(), in);
accessor.set(record, asString == null
? null
: newInstanceFromString(accessor.getField().getType(), asString));
return;
} catch (Exception e) {
throw new AvroRuntimeException("Failed to read Stringable", e);
}
}
}
}
super.readField(record, f, oldDatum, in, state);
}
}