private static final class LinksRewriter implements ODocumentFieldVisitor {
@Override
public Object visitField(OType type, OType linkedType, Object value) {
boolean oldAutoConvertValue = false;
if (value instanceof ORecordLazyMultiValue) {
ORecordLazyMultiValue multiValue = (ORecordLazyMultiValue) value;
oldAutoConvertValue = multiValue.isAutoConvertToRecord();
multiValue.setAutoConvertToRecord(false);
}
final ValuesConverter valuesConverter = ConvertersFactory.INSTANCE.getConverter(value);
if (valuesConverter == null)
return value;
final Object newValue = valuesConverter.convert(value);
if (value instanceof ORecordLazyMultiValue) {
ORecordLazyMultiValue multiValue = (ORecordLazyMultiValue) value;
multiValue.setAutoConvertToRecord(oldAutoConvertValue);
}
return newValue;
}