// Path: src/main/java/ru/shadam/tarantool/core/mapping/TarantoolMappingContext.java
// public class TarantoolMappingContext extends AbstractMappingContext<TarantoolPersistentEntity<?>, TarantoolPersistentProperty> {
//     private KeySpaceResolver fallbackKeySpaceResolver;
// 
//     public void setFallbackKeySpaceResolver(KeySpaceResolver fallbackKeySpaceResolver) {
//         this.fallbackKeySpaceResolver = fallbackKeySpaceResolver;
//     }
// 
//     @Override
//     public TarantoolPersistentEntity<?> getPersistentEntity(Class<?> type) {
//         return super.getPersistentEntity(type);
//     }
// 
//     @Override
//     public TarantoolPersistentEntity<?> getPersistentEntity(TypeInformation<?> type) {
//         return super.getPersistentEntity(type);
// 
//     }
// 
//     @Override
//     protected <T> TarantoolPersistentEntity<T> createPersistentEntity(TypeInformation<T> typeInformation) {
//         return new BasicTarantoolPersistentEntity<>(typeInformation, fallbackKeySpaceResolver);
//     }
// 
//     @Override
//     protected TarantoolPersistentPropertyImpl createPersistentProperty(Field field,
//                                                                        PropertyDescriptor descriptor,
//                                                                        TarantoolPersistentEntity<?> owner,
//                                                                        SimpleTypeHolder simpleTypeHolder) {
//         return new TarantoolPersistentPropertyImpl(field, descriptor, owner, simpleTypeHolder);
//     }
// }
// 
// Path: src/main/java/ru/shadam/tarantool/core/mapping/TarantoolPersistentEntity.java
// public interface TarantoolPersistentEntity<T>  extends MutablePersistentEntity<T, TarantoolPersistentProperty> {
//     String getSpaceName();
// }
// 
// Path: src/main/java/ru/shadam/tarantool/core/mapping/TarantoolPersistentProperty.java
// public interface TarantoolPersistentProperty extends PersistentProperty<TarantoolPersistentProperty> {
//     OptionalInt getTupleIndex();
// 
//     Optional<String> getSpaceIndexName();
// }


import org.springframework.beans.factory.InitializingBean;
import org.springframework.core.CollectionFactory;
import org.springframework.core.convert.ConversionService;
import org.springframework.data.convert.*;
import org.springframework.data.mapping.PersistentPropertyAccessor;
import org.springframework.data.mapping.PreferredConstructor;
import org.springframework.data.mapping.PropertyHandler;
import org.springframework.data.mapping.model.MappingException;
import org.springframework.data.mapping.model.PersistentEntityParameterValueProvider;
import org.springframework.data.mapping.model.PropertyValueProvider;
import org.springframework.data.util.ClassTypeInformation;
import org.springframework.data.util.TypeInformation;
import org.springframework.util.ClassUtils;
import org.springframework.util.CollectionUtils;
import ru.shadam.tarantool.core.mapping.TarantoolMappingContext;
import ru.shadam.tarantool.core.mapping.TarantoolPersistentEntity;
import ru.shadam.tarantool.core.mapping.TarantoolPersistentProperty;
import java.lang.reflect.Array;
import java.util.*;
    }

    @Override
    public <R> R read(Class<R> type, TarantoolData source) {
        return readInternal(Path.empty(), type, source);
    }

    @SuppressWarnings("unchecked")
    private <R> R readInternal(Path path, Class<R> type, TarantoolData source) {
        // first item in tuple is class information.
        if (source.getTuple() == null || source.getTuple().isEmpty()) {
            return null;
        }

        TypeInformation<?> readType = typeMapper.readType(source);
        TypeInformation<?> typeToUse = readType != null ? readType : ClassTypeInformation.from(type);
        final TarantoolPersistentEntity<?> entity = mappingContext.getPersistentEntity(typeToUse);

        if (conversionService.canConvert(Tuple.class, typeToUse.getType())) {
            return ((R) conversionService.convert(source.getTuple(), typeToUse.getType()));
        }

        final EntityInstantiator instantiator = entityInstantiators.getInstantiatorFor(entity);

        final Object instance = instantiator.createInstance(entity,
                new PersistentEntityParameterValueProvider<>(entity,
                        new ConverterAwareParameterValueProvider(source, conversionService), null));

        final PersistentPropertyAccessor accessor = entity.getPropertyAccessor(instance);

// Path: src/main/java/ru/shadam/tarantool/core/mapping/TarantoolMappingContext.java
// public class TarantoolMappingContext extends AbstractMappingContext<TarantoolPersistentEntity<?>, TarantoolPersistentProperty> {
//     private KeySpaceResolver fallbackKeySpaceResolver;
// 
//     public void setFallbackKeySpaceResolver(KeySpaceResolver fallbackKeySpaceResolver) {
//         this.fallbackKeySpaceResolver = fallbackKeySpaceResolver;
//     }
// 
//     @Override
//     public TarantoolPersistentEntity<?> getPersistentEntity(Class<?> type) {
//         return super.getPersistentEntity(type);
//     }
// 
//     @Override
//     public TarantoolPersistentEntity<?> getPersistentEntity(TypeInformation<?> type) {
//         return super.getPersistentEntity(type);
// 
//     }
// 
//     @Override
//     protected <T> TarantoolPersistentEntity<T> createPersistentEntity(TypeInformation<T> typeInformation) {
//         return new BasicTarantoolPersistentEntity<>(typeInformation, fallbackKeySpaceResolver);
//     }
// 
//     @Override
//     protected TarantoolPersistentPropertyImpl createPersistentProperty(Field field,
//                                                                        PropertyDescriptor descriptor,
//                                                                        TarantoolPersistentEntity<?> owner,
//                                                                        SimpleTypeHolder simpleTypeHolder) {
//         return new TarantoolPersistentPropertyImpl(field, descriptor, owner, simpleTypeHolder);
//     }
// }
// 
// Path: src/main/java/ru/shadam/tarantool/core/mapping/TarantoolPersistentEntity.java
// public interface TarantoolPersistentEntity<T>  extends MutablePersistentEntity<T, TarantoolPersistentProperty> {
//     String getSpaceName();
// }
// 
// Path: src/main/java/ru/shadam/tarantool/core/mapping/TarantoolPersistentProperty.java
// public interface TarantoolPersistentProperty extends PersistentProperty<TarantoolPersistentProperty> {
//     OptionalInt getTupleIndex();
// 
//     Optional<String> getSpaceIndexName();
// }


// Path: src/main/java/ru/shadam/tarantool/core/convert/MappingTarantoolConverter.java
import org.springframework.beans.factory.InitializingBean;
import org.springframework.core.CollectionFactory;
import org.springframework.core.convert.ConversionService;
import org.springframework.data.convert.*;
import org.springframework.data.mapping.PersistentPropertyAccessor;
import org.springframework.data.mapping.PreferredConstructor;
import org.springframework.data.mapping.PropertyHandler;
import org.springframework.data.mapping.model.MappingException;
import org.springframework.data.mapping.model.PersistentEntityParameterValueProvider;
import org.springframework.data.mapping.model.PropertyValueProvider;
import org.springframework.data.util.ClassTypeInformation;
import org.springframework.data.util.TypeInformation;
import org.springframework.util.ClassUtils;
import org.springframework.util.CollectionUtils;
import ru.shadam.tarantool.core.mapping.TarantoolMappingContext;
import ru.shadam.tarantool.core.mapping.TarantoolPersistentEntity;
import ru.shadam.tarantool.core.mapping.TarantoolPersistentProperty;
import java.lang.reflect.Array;
import java.util.*;

    }

    @Override
    public <R> R read(Class<R> type, TarantoolData source) {
        return readInternal(Path.empty(), type, source);
    }

    @SuppressWarnings("unchecked")
    private <R> R readInternal(Path path, Class<R> type, TarantoolData source) {
        // first item in tuple is class information.
        if (source.getTuple() == null || source.getTuple().isEmpty()) {
            return null;
        }

        TypeInformation<?> readType = typeMapper.readType(source);
        TypeInformation<?> typeToUse = readType != null ? readType : ClassTypeInformation.from(type);
        final TarantoolPersistentEntity<?> entity = mappingContext.getPersistentEntity(typeToUse);

        if (conversionService.canConvert(Tuple.class, typeToUse.getType())) {
            return ((R) conversionService.convert(source.getTuple(), typeToUse.getType()));
        }

        final EntityInstantiator instantiator = entityInstantiators.getInstantiatorFor(entity);

        final Object instance = instantiator.createInstance(entity,
                new PersistentEntityParameterValueProvider<>(entity,
                        new ConverterAwareParameterValueProvider(source, conversionService), null));

        final PersistentPropertyAccessor accessor = entity.getPropertyAccessor(instance);

        entity.doWithProperties(new PropertyHandler<TarantoolPersistentProperty>() {