@Override
    public Predicate visit(AndPredicate predicate, IndexRegistry indexes) {
        Predicate[] predicates = predicate.predicates;
        Ranges ranges = null;

        for (int i = 0; i < predicates.length; ++i) {
            ranges = intersect(predicates, i, ranges, indexes);
            if (ranges == Ranges.UNSATISFIABLE) {
                return Predicates.alwaysFalse();
            }
        }

        return ranges == null ? predicate : ranges.generate(predicate);
    }
@Test
    public void testBetweenPredicateOptimization() {
        BetweenPredicate predicate = new BetweenPredicate("age", 20, 10);
        assertSame(Predicates.alwaysFalse(), visitor.visit(predicate, indexes));

        predicate = new BetweenPredicate("noConverter", 20, 10);
        assertSame(predicate, visitor.visit(predicate, indexes));

        predicate = new BetweenPredicate("unindexed", "20", "10");
        assertSame(predicate, visitor.visit(predicate, indexes));

        predicate = new BetweenPredicate("age", "10", 20);
        assertSame(predicate, visitor.visit(predicate, indexes));

        predicate = new BetweenPredicate("age", "10", "10");
        assertEqualPredicate(new EqualPredicate("age", 10), visitor.visit(predicate, indexes));
    }