Example usage for org.springframework.util.comparator ComparableComparator ComparableComparator

List of usage examples for org.springframework.util.comparator ComparableComparator ComparableComparator

Introduction

In this page you can find the example usage for org.springframework.util.comparator ComparableComparator ComparableComparator.

Prototype

ComparableComparator

Source Link

Usage

From source file:org.springmodules.validation.util.condition.range.AbstractBetweenConditionTests.java

public void testConstructor_WithNullLowerBound() throws Exception {
    try {/* w ww  .ja  v  a 2  s . c  o m*/
        createBetweenCondition(null, new Integer(3));
        fail("An IllegalArgumentException must be thrown if the condition is initialized with a null lower bound");
    } catch (IllegalArgumentException iae) {
        // expected
    }

    try {
        createBetweenCondition(null, new Integer(3), new ComparableComparator());
        fail("An IllegalArgumentException must be thrown if the condition is initialized with a null lower bound");
    } catch (IllegalArgumentException iae) {
        // expected
    }
}

From source file:org.springmodules.validation.util.condition.range.AbstractBetweenConditionTests.java

public void testConstructor_WithNullUpperBound() throws Exception {
    try {//from  ww  w  .  j ava 2  s. co m
        createBetweenCondition(new Integer(3), null);
        fail("An IllegalArgumentException must be thrown if the condition is initialized with a null upper bound");
    } catch (IllegalArgumentException iae) {
        // expected
    }

    try {
        createBetweenCondition(new Integer(3), null, new ComparableComparator());
        fail("An IllegalArgumentException must be thrown if the condition is initialized with a null upper bound");
    } catch (IllegalArgumentException iae) {
        // expected
    }
}

From source file:org.springframework.cloud.aws.messaging.listener.QueueMessageHandler.java

@Override
protected Comparator<MappingInformation> getMappingComparator(Message<?> message) {
    return new ComparableComparator<>();
}

From source file:org.alfresco.repo.virtual.page.PageCollatorTest.java

public void assertCollate(List<Integer> results, Integer[] source, int skip, int pageSize, boolean boundsError)
        throws Exception {
    Arrays.sort(source);/* w w  w  .  ja  va  2  s.  c om*/
    Collections.sort(results);
    int[] expected = createMergedPage(skip, pageSize, results, source);
    PagingResults<Integer> actualResults = new PageCollator<Integer>().collate(results,
            new ArrayPageSource(source), new PagingRequest(skip, pageSize),
            new ComparableComparator<Integer>());
    List<Integer> actualPage = actualResults.getPage();

    final String message = "[" + results + " + " + Arrays.toString(source) + " ] -> "
            + Arrays.toString(expected) + " != " + actualPage;
    assertEqualPages(message, expected, actualPage);
    assertEquals("Invalid moreItems info!",
            (pageSize != 0) && (skip + pageSize < results.size() + source.length),
            actualResults.hasMoreItems());
    assertTrue(message, (pageSize == 0) || actualPage.size() <= pageSize);
    final int expectedTotal = source.length + results.size();
    if (boundsError && !new Pair<Integer, Integer>(null, null).equals(actualResults.getTotalResultCount())) {
        assertEquals("Invalid total info", new Pair<Integer, Integer>(expectedTotal, expectedTotal),
                actualResults.getTotalResultCount());
    }
    logger.info(actualPage);
}

From source file:org.alfresco.repo.virtual.page.PageCollatorTest.java

public void testCollateFalsePositive1() throws Exception {
    final List<Integer> s1 = Arrays.asList(2, 3);
    final Integer[] s2 = new Integer[] { 7, 10, 13 };

    try {//from  w w w  .j  av  a2s  .c o  m
        new PageCollator<Integer>().collate(s1, new ArrayPageSource(s2), new PagingRequest(-1, 1),
                new ComparableComparator<Integer>());
        fail("Invalid page data.");
    } catch (PageCollationException e) {
        logger.info(e.getMessage());
    }

    try {
        new PageCollator<Integer>().collate(s1, new ArrayPageSource(s2), new PagingRequest(1, -1),
                new ComparableComparator<Integer>());
        fail("Invalid page data.");
    } catch (PageCollationException e) {
        logger.info(e.getMessage());
    }
}

From source file:org.springframework.richclient.factory.DefaultComponentFactory.java

public void configureForEnum(JComboBox comboBox, Class enumType) {
    Collection enumValues = getEnumResolver().getLabeledEnumSet(enumType);
    if (logger.isDebugEnabled()) {
        logger.debug("Populating combo box model with enums of type '" + enumType.getName() + "'; enums are ["
                + enumValues + "]");
    }//from  w  w w.  j  a v a  2s.  c o  m
    CompoundComparator comparator = new CompoundComparator();
    comparator.addComparator(LabeledEnum.LABEL_ORDER);
    comparator.addComparator(new ComparableComparator());
    comboBox.setModel(new ComboBoxListModel(new ArrayList(enumValues), comparator));
    comboBox.setRenderer(new LabeledEnumListRenderer(messageSource));
    comboBox.setEditor(new LabeledEnumComboBoxEditor(messageSource, comboBox.getEditor()));
}