@Override protected void writeRecord(Schema schema, Object datum, Encoder out) throws IOException { if (datum instanceof SpecificRecordBase && this.getSpecificData().useCustomCoders()) { SpecificRecordBase d = (SpecificRecordBase) datum; if (d.hasCustomCoders()) { d.customEncode(out); return; } } super.writeRecord(schema, datum, out); }
@Override protected Object readRecord(Object old, Schema expected, ResolvingDecoder in) throws IOException { SpecificData data = getSpecificData(); if (data.useCustomCoders()) { old = data.newRecord(old, expected); if (old instanceof SpecificRecordBase) { SpecificRecordBase d = (SpecificRecordBase) old; if (d.hasCustomCoders()) { d.customDecode(in); return d; } } } return super.readRecord(old, expected, in); }