Java Code Examples for org.apache.commons.collections4.ComparatorUtils#naturalComparator()

The following examples show how to use org.apache.commons.collections4.ComparatorUtils#naturalComparator() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SelectRejectedPredicateTest.java    From feilong-core with Apache License 2.0 5 votes vote down vote up
/**
 * Test select rejected predicate.
 */
@Test
public void testSelectRejectedPredicate(){
    Predicate<Integer> predicate = new ComparatorPredicate<Integer>(10, ComparatorUtils.<Integer> naturalComparator(), Criterion.LESS);

    List<Integer> result = CollectionsUtil.selectRejected(toList(1, 5, 10, 30, 55, 88, 1, 12, 3), predicate);
    assertThat(result, contains(1, 5, 10, 1, 3));
}
 
Example 2
Source File: SelectPredicateTest.java    From feilong-core with Apache License 2.0 5 votes vote down vote up
/**
 * Test select predicate.
 */
@Test
public void testSelectPredicate(){
    //查询 >10 的元素
    Predicate<Integer> predicate = new ComparatorPredicate<Integer>(10, ComparatorUtils.<Integer> naturalComparator(), Criterion.LESS);

    List<Integer> result = CollectionsUtil.select(toList(1, 5, 10, 30, 55, 88, 1, 12, 3), predicate);
    assertThat(result, contains(30, 55, 88, 12));
}