// 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/repository/core/MappingTarantoolEntityInformation.java
// public class MappingTarantoolEntityInformation<T> extends PersistentEntityInformation<T, Serializable> {
// 
//     public MappingTarantoolEntityInformation(TarantoolPersistentEntity<T> entity) {
//         super(entity);
// 
//         if(!entity.hasIdProperty()) {
// 
//             throw new MappingException(
//                     String.format("Entity %s requires to have an explicit id field. Did you forget to provide one using @Id?",
//                             entity.getName())
//             );
//         }
//     }
// }
// 
// Path: src/main/java/ru/shadam/tarantool/repository/query/TarantoolQueryCreator.java
// public class TarantoolQueryCreator extends AbstractQueryCreator<KeyValueQuery<TarantoolQuery>, TarantoolQuery> {
// 
//     public TarantoolQueryCreator(PartTree tree, ParameterAccessor parameters) {
//         super(tree, parameters);
//     }
// 
//     @Override
//     protected TarantoolQuery create(Part part, Iterator<Object> iterator) {
//         switch (part.getType()) {
//             case SIMPLE_PROPERTY:
//                 return new TarantoolQuery(part.getProperty().toDotPath(), iterator.next());
//             default:
//                 throw new IllegalArgumentException(part.getType() + "is not supported for redis query derivation");
//         }
//     }
// 
//     @Override
//     protected TarantoolQuery and(Part part, TarantoolQuery base, Iterator<Object> iterator) {
//         throw new UnsupportedOperationException("and is not supported");
//     }
// 
//     @Override
//     protected TarantoolQuery or(TarantoolQuery base, TarantoolQuery criteria) {
//         throw new UnsupportedOperationException("or is not supported");
//     }
// 
//     @Override
//     protected KeyValueQuery<TarantoolQuery> complete(TarantoolQuery criteria, Sort sort) {
//         final KeyValueQuery<TarantoolQuery> tarantoolQueryKeyValueQuery = new KeyValueQuery<>(criteria);
//         tarantoolQueryKeyValueQuery.setSort(sort);
//         return tarantoolQueryKeyValueQuery;
//     }
// }


import org.springframework.data.keyvalue.core.KeyValueOperations;
import org.springframework.data.keyvalue.repository.query.KeyValuePartTreeQuery;
import org.springframework.data.keyvalue.repository.support.KeyValueRepositoryFactory;
import org.springframework.data.repository.core.EntityInformation;
import org.springframework.data.repository.query.RepositoryQuery;
import org.springframework.data.repository.query.parser.AbstractQueryCreator;
import ru.shadam.tarantool.core.mapping.TarantoolPersistentEntity;
import ru.shadam.tarantool.repository.core.MappingTarantoolEntityInformation;
import ru.shadam.tarantool.repository.query.TarantoolQueryCreator;
import java.io.Serializable;
package ru.shadam.tarantool.repository.support;



/**
 * @author sala
 */
public class TarantoolRepositoryFactory extends KeyValueRepositoryFactory {
    private final KeyValueOperations keyValueOperations;

    /**
     * @param keyValueOperations
     * @see KeyValueRepositoryFactory#KeyValueRepositoryFactory(KeyValueOperations)
     */
    public TarantoolRepositoryFactory(KeyValueOperations keyValueOperations) {
        this(keyValueOperations, TarantoolQueryCreator.class);
    }

    public TarantoolRepositoryFactory(
            KeyValueOperations keyValueOperations,
            Class<? extends AbstractQueryCreator<?, ?>> queryCreator
    ) {
        this(keyValueOperations, queryCreator, KeyValuePartTreeQuery.class);
    }

    public TarantoolRepositoryFactory(
            KeyValueOperations keyValueOperations,
            Class<? extends AbstractQueryCreator<?, ?>> queryCreator,
            Class<? extends RepositoryQuery> repositoryQueryType
    ) {
        super(keyValueOperations, queryCreator, repositoryQueryType);
        this.keyValueOperations = keyValueOperations;
    }

    @Override
    public <T, ID extends Serializable> EntityInformation<T, ID> getEntityInformation(Class<T> domainClass) {
// 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/repository/core/MappingTarantoolEntityInformation.java
// public class MappingTarantoolEntityInformation<T> extends PersistentEntityInformation<T, Serializable> {
// 
//     public MappingTarantoolEntityInformation(TarantoolPersistentEntity<T> entity) {
//         super(entity);
// 
//         if(!entity.hasIdProperty()) {
// 
//             throw new MappingException(
//                     String.format("Entity %s requires to have an explicit id field. Did you forget to provide one using @Id?",
//                             entity.getName())
//             );
//         }
//     }
// }
// 
// Path: src/main/java/ru/shadam/tarantool/repository/query/TarantoolQueryCreator.java
// public class TarantoolQueryCreator extends AbstractQueryCreator<KeyValueQuery<TarantoolQuery>, TarantoolQuery> {
// 
//     public TarantoolQueryCreator(PartTree tree, ParameterAccessor parameters) {
//         super(tree, parameters);
//     }
// 
//     @Override
//     protected TarantoolQuery create(Part part, Iterator<Object> iterator) {
//         switch (part.getType()) {
//             case SIMPLE_PROPERTY:
//                 return new TarantoolQuery(part.getProperty().toDotPath(), iterator.next());
//             default:
//                 throw new IllegalArgumentException(part.getType() + "is not supported for redis query derivation");
//         }
//     }
// 
//     @Override
//     protected TarantoolQuery and(Part part, TarantoolQuery base, Iterator<Object> iterator) {
//         throw new UnsupportedOperationException("and is not supported");
//     }
// 
//     @Override
//     protected TarantoolQuery or(TarantoolQuery base, TarantoolQuery criteria) {
//         throw new UnsupportedOperationException("or is not supported");
//     }
// 
//     @Override
//     protected KeyValueQuery<TarantoolQuery> complete(TarantoolQuery criteria, Sort sort) {
//         final KeyValueQuery<TarantoolQuery> tarantoolQueryKeyValueQuery = new KeyValueQuery<>(criteria);
//         tarantoolQueryKeyValueQuery.setSort(sort);
//         return tarantoolQueryKeyValueQuery;
//     }
// }


// Path: src/main/java/ru/shadam/tarantool/repository/support/TarantoolRepositoryFactory.java
import org.springframework.data.keyvalue.core.KeyValueOperations;
import org.springframework.data.keyvalue.repository.query.KeyValuePartTreeQuery;
import org.springframework.data.keyvalue.repository.support.KeyValueRepositoryFactory;
import org.springframework.data.repository.core.EntityInformation;
import org.springframework.data.repository.query.RepositoryQuery;
import org.springframework.data.repository.query.parser.AbstractQueryCreator;
import ru.shadam.tarantool.core.mapping.TarantoolPersistentEntity;
import ru.shadam.tarantool.repository.core.MappingTarantoolEntityInformation;
import ru.shadam.tarantool.repository.query.TarantoolQueryCreator;
import java.io.Serializable;

package ru.shadam.tarantool.repository.support;



/**
 * @author sala
 */
public class TarantoolRepositoryFactory extends KeyValueRepositoryFactory {
    private final KeyValueOperations keyValueOperations;

    /**
     * @param keyValueOperations
     * @see KeyValueRepositoryFactory#KeyValueRepositoryFactory(KeyValueOperations)
     */
    public TarantoolRepositoryFactory(KeyValueOperations keyValueOperations) {
        this(keyValueOperations, TarantoolQueryCreator.class);
    }

    public TarantoolRepositoryFactory(
            KeyValueOperations keyValueOperations,
            Class<? extends AbstractQueryCreator<?, ?>> queryCreator
    ) {
        this(keyValueOperations, queryCreator, KeyValuePartTreeQuery.class);
    }

    public TarantoolRepositoryFactory(
            KeyValueOperations keyValueOperations,
            Class<? extends AbstractQueryCreator<?, ?>> queryCreator,
            Class<? extends RepositoryQuery> repositoryQueryType
    ) {
        super(keyValueOperations, queryCreator, repositoryQueryType);
        this.keyValueOperations = keyValueOperations;
    }

    @Override
    public <T, ID extends Serializable> EntityInformation<T, ID> getEntityInformation(Class<T> domainClass) {
        TarantoolPersistentEntity<T> entity = ((TarantoolPersistentEntity<T>) keyValueOperations