// Path: src/main/java/org/springframework/data/hazelcast/repository/query/HazelcastCriteriaAccessor.java
// public class HazelcastCriteriaAccessor
//         implements CriteriaAccessor<Predicate<?, ?>> {
// 
//     /**
//      * @param A query in Spring form
//      * @return The same in Hazelcast form
//      */
//     public Predicate<?, ?> resolve(KeyValueQuery<?> query) {
// 
//         if (query == null) {
//             return null;
//         }
// 
//         final Object criteria = query.getCriteria();
//         if (criteria == null) {
//             return null;
//         }
// 
//         if (criteria instanceof PagingPredicateImpl) {
//             PagingPredicateImpl pagingPredicate = (PagingPredicateImpl) criteria;
//             query.limit(pagingPredicate.getPageSize());
//             return pagingPredicate.getPredicate();
//         }
// 
//         if (criteria instanceof Predicate) {
//             return (Predicate<?, ?>) criteria;
//         }
// 
//         throw new UnsupportedOperationException(query.toString());
//     }
// 
// }
// 
// Path: src/main/java/org/springframework/data/hazelcast/repository/query/HazelcastSortAccessor.java
// public class HazelcastSortAccessor
//         implements SortAccessor<Comparator<Entry<?, ?>>> {
// 
//     /**
//      * <p>
//      * Sort on a sequence of fields, possibly none.
//      * </P>
//      *
//      * @param query If not null, will contain one of more {@link Sort.Order} objects.
//      * @return A sequence of comparators or {@code null}
//      */
//     public Comparator<Entry<?, ?>> resolve(KeyValueQuery<?> query) {
// 
//         if (query == null || query.getSort() == Sort.unsorted()) {
//             return null;
//         }
// 
//         Comparator hazelcastPropertyComparator = null;
// 
//         for (Order order : query.getSort()) {
// 
//             if (order.getProperty().indexOf('.') > -1) {
//                 throw new UnsupportedOperationException("Embedded fields not implemented: " + order);
//             }
// 
//             if (order.isIgnoreCase()) {
//                 throw new UnsupportedOperationException("Ignore case not implemented: " + order);
//             }
// 
//             if (NullHandling.NATIVE != order.getNullHandling()) {
//                 throw new UnsupportedOperationException("Null handling not implemented: " + order);
//             }
// 
//             if (hazelcastPropertyComparator == null) {
//                 hazelcastPropertyComparator = new HazelcastPropertyComparator(order.getProperty(),
//                         order.isAscending());
//             } else {
//                 hazelcastPropertyComparator = hazelcastPropertyComparator.thenComparing(
//                         new HazelcastPropertyComparator(order.getProperty(),
//                         order.isAscending()));
//             }
//         }
// 
//         return hazelcastPropertyComparator;
//     }
// 
// }


import com.hazelcast.query.PagingPredicate;
import com.hazelcast.query.Predicate;
import com.hazelcast.query.impl.predicates.PagingPredicateImpl;
import org.springframework.data.hazelcast.repository.query.HazelcastCriteriaAccessor;
import org.springframework.data.hazelcast.repository.query.HazelcastSortAccessor;
import org.springframework.data.keyvalue.core.QueryEngine;
import org.springframework.util.Assert;
import java.util.Collection;
import java.util.Comparator;
import java.util.Map.Entry;
/*
 * Copyright (c) 2008-2018, Hazelcast, Inc. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.springframework.data.hazelcast;



/**
 * <p>
 * Implementation of {@code findBy*()} and {@code countBy*{}} queries.
 * </P>
 *
 * @author Christoph Strobl
 * @author Neil Stevenson
 * @author Viacheslav Petriaiev
 */
public class HazelcastQueryEngine
        extends QueryEngine<HazelcastKeyValueAdapter, Predicate<?, ?>, Comparator<Entry<?, ?>>> {

    public HazelcastQueryEngine() {
// Path: src/main/java/org/springframework/data/hazelcast/repository/query/HazelcastCriteriaAccessor.java
// public class HazelcastCriteriaAccessor
//         implements CriteriaAccessor<Predicate<?, ?>> {
// 
//     /**
//      * @param A query in Spring form
//      * @return The same in Hazelcast form
//      */
//     public Predicate<?, ?> resolve(KeyValueQuery<?> query) {
// 
//         if (query == null) {
//             return null;
//         }
// 
//         final Object criteria = query.getCriteria();
//         if (criteria == null) {
//             return null;
//         }
// 
//         if (criteria instanceof PagingPredicateImpl) {
//             PagingPredicateImpl pagingPredicate = (PagingPredicateImpl) criteria;
//             query.limit(pagingPredicate.getPageSize());
//             return pagingPredicate.getPredicate();
//         }
// 
//         if (criteria instanceof Predicate) {
//             return (Predicate<?, ?>) criteria;
//         }
// 
//         throw new UnsupportedOperationException(query.toString());
//     }
// 
// }
// 
// Path: src/main/java/org/springframework/data/hazelcast/repository/query/HazelcastSortAccessor.java
// public class HazelcastSortAccessor
//         implements SortAccessor<Comparator<Entry<?, ?>>> {
// 
//     /**
//      * <p>
//      * Sort on a sequence of fields, possibly none.
//      * </P>
//      *
//      * @param query If not null, will contain one of more {@link Sort.Order} objects.
//      * @return A sequence of comparators or {@code null}
//      */
//     public Comparator<Entry<?, ?>> resolve(KeyValueQuery<?> query) {
// 
//         if (query == null || query.getSort() == Sort.unsorted()) {
//             return null;
//         }
// 
//         Comparator hazelcastPropertyComparator = null;
// 
//         for (Order order : query.getSort()) {
// 
//             if (order.getProperty().indexOf('.') > -1) {
//                 throw new UnsupportedOperationException("Embedded fields not implemented: " + order);
//             }
// 
//             if (order.isIgnoreCase()) {
//                 throw new UnsupportedOperationException("Ignore case not implemented: " + order);
//             }
// 
//             if (NullHandling.NATIVE != order.getNullHandling()) {
//                 throw new UnsupportedOperationException("Null handling not implemented: " + order);
//             }
// 
//             if (hazelcastPropertyComparator == null) {
//                 hazelcastPropertyComparator = new HazelcastPropertyComparator(order.getProperty(),
//                         order.isAscending());
//             } else {
//                 hazelcastPropertyComparator = hazelcastPropertyComparator.thenComparing(
//                         new HazelcastPropertyComparator(order.getProperty(),
//                         order.isAscending()));
//             }
//         }
// 
//         return hazelcastPropertyComparator;
//     }
// 
// }


// Path: src/main/java/org/springframework/data/hazelcast/HazelcastQueryEngine.java
import com.hazelcast.query.PagingPredicate;
import com.hazelcast.query.Predicate;
import com.hazelcast.query.impl.predicates.PagingPredicateImpl;
import org.springframework.data.hazelcast.repository.query.HazelcastCriteriaAccessor;
import org.springframework.data.hazelcast.repository.query.HazelcastSortAccessor;
import org.springframework.data.keyvalue.core.QueryEngine;
import org.springframework.util.Assert;
import java.util.Collection;
import java.util.Comparator;
import java.util.Map.Entry;

/*
 * Copyright (c) 2008-2018, Hazelcast, Inc. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.springframework.data.hazelcast;



/**
 * <p>
 * Implementation of {@code findBy*()} and {@code countBy*{}} queries.
 * </P>
 *
 * @author Christoph Strobl
 * @author Neil Stevenson
 * @author Viacheslav Petriaiev
 */
public class HazelcastQueryEngine
        extends QueryEngine<HazelcastKeyValueAdapter, Predicate<?, ?>, Comparator<Entry<?, ?>>> {

    public HazelcastQueryEngine() {
        super(new HazelcastCriteriaAccessor(), new HazelcastSortAccessor());