/** * Construct a CompoundComparator from the Comparators in the provided array. * <p>All Comparators will default to ascending sort order, * unless they are InvertibleComparators. * @param comparators the comparators to build into a compound comparator * @see InvertibleComparator */ @SuppressWarnings("unchecked") public CompoundComparator(Comparator... comparators) { Assert.notNull(comparators, "Comparators must not be null"); this.comparators = new ArrayList<>(comparators.length); for (Comparator comparator : comparators) { addComparator(comparator); } }
/** * Construct a CompoundComparator from the Comparators in the provided array. * <p>All Comparators will default to ascending sort order, * unless they are InvertibleComparators. * @param comparators the comparators to build into a compound comparator * @see InvertibleComparator */ @SuppressWarnings("unchecked") public CompoundComparator(Comparator... comparators) { Assert.notNull(comparators, "Comparators must not be null"); this.comparators = new ArrayList<>(comparators.length); for (Comparator comparator : comparators) { addComparator(comparator); } }
/** * Construct a CompoundComparator from the Comparators in the provided array. * <p>All Comparators will default to ascending sort order, * unless they are InvertibleComparators. * @param comparators the comparators to build into a compound comparator * @see InvertibleComparator */ public CompoundComparator(Comparator[] comparators) { this.comparators = new ArrayList<InvertibleComparator<T>>(comparators.length); for (Comparator<T> comparator : comparators) { addComparator(comparator); } }
/** * Construct a CompoundComparator from the Comparators in the provided array. * <p>All Comparators will default to ascending sort order, * unless they are InvertibleComparators. * @param comparators the comparators to build into a compound comparator * @see InvertibleComparator */ public CompoundComparator(Comparator[] comparators) { this.comparators = new ArrayList(comparators.length); for (int i = 0; i < comparators.length; i++) { addComparator(comparators[i]); } }
/** * Construct a CompoundComparator from the Comparators in the provided array. * <p>All Comparators will default to ascending sort order, * unless they are InvertibleComparators. * @param comparators the comparators to build into a compound comparator * @see InvertibleComparator */ @SuppressWarnings("unchecked") public CompoundComparator(Comparator... comparators) { Assert.notNull(comparators, "Comparators must not be null"); this.comparators = new ArrayList<>(comparators.length); for (Comparator comparator : comparators) { addComparator(comparator); } }
/** * Construct a CompoundComparator from the Comparators in the provided array. * <p>All Comparators will default to ascending sort order, * unless they are InvertibleComparators. * @param comparators the comparators to build into a compound comparator * @see InvertibleComparator */ @SuppressWarnings("unchecked") public CompoundComparator(Comparator... comparators) { Assert.notNull(comparators, "Comparators must not be null"); this.comparators = new ArrayList<>(comparators.length); for (Comparator comparator : comparators) { addComparator(comparator); } }
@SuppressWarnings({ "rawtypes", "unchecked" }) public Comparator<?> aerospikePropertyComparator(Query<?> query ) { if (query == null || query.getSort() == null) { return null; } CompoundComparator compoundComperator = new CompoundComparator(); for (Order order : query.getSort()) { if (Direction.DESC.equals(order.getDirection())) { compoundComperator.addComparator(new PropertyComparator(order.getProperty(), true, false)); }else { compoundComperator.addComparator(new PropertyComparator(order.getProperty(), true, true)); } } return compoundComperator; }
/** * <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; } CompoundComparator<Entry<?, ?>> compoundComparator = new CompoundComparator<>(); 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); } HazelcastPropertyComparator hazelcastPropertyComparator = new HazelcastPropertyComparator(order.getProperty(), order.isAscending()); compoundComparator.addComparator(hazelcastPropertyComparator); } return compoundComparator; }