本文整理汇总了Java中org.springframework.util.comparator.ComparableComparator类的典型用法代码示例。如果您正苦于以下问题:Java ComparableComparator类的具体用法?Java ComparableComparator怎么用?Java ComparableComparator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ComparableComparator类属于org.springframework.util.comparator包,在下文中一共展示了ComparableComparator类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: assertCollate
import org.springframework.util.comparator.ComparableComparator; //导入依赖的package包/类
public void assertCollate(List<Integer> results, Integer[] source, int skip, int pageSize, boolean boundsError)
throws Exception
{
Arrays.sort(source);
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);
}
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:38,代码来源:PageCollatorTest.java
示例2: shouldGetMapEntryKeys
import org.springframework.util.comparator.ComparableComparator; //导入依赖的package包/类
@Test
public void shouldGetMapEntryKeys() throws Exception {
ArrayList<Entry<String, Integer>> list = createReverseOrderMapEntryList();
Comparator<Map.Entry<String, Integer>> comparator = ConvertingComparator.mapEntryKeys(new ComparableComparator<String>());
Collections.sort(list, comparator);
assertThat(list.get(0).getKey(), is("a"));
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:8,代码来源:ConvertingComparatorTests.java
示例3: shouldGetMapEntryValues
import org.springframework.util.comparator.ComparableComparator; //导入依赖的package包/类
@Test
public void shouldGetMapEntryValues() throws Exception {
ArrayList<Entry<String, Integer>> list = createReverseOrderMapEntryList();
Comparator<Map.Entry<String, Integer>> comparator = ConvertingComparator.mapEntryValues(new ComparableComparator<Integer>());
Collections.sort(list, comparator);
assertThat(list.get(0).getValue(), is(1));
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:8,代码来源:ConvertingComparatorTests.java
示例4: findAll
import org.springframework.util.comparator.ComparableComparator; //导入依赖的package包/类
@Override
public List<VistaAccount> findAll(final Sort sort) {
List<VistaAccount> accounts = getVistaAccounts();
if (sort == null) return Collections.unmodifiableList(accounts);
Collections.sort(accounts, new Comparator<VistaAccount>() {
private Comparator nullSafeComparableComparator = new NullSafeComparator(new ComparableComparator(), false);
@Override
public int compare(VistaAccount a1, VistaAccount a2) {
BeanWrapper b1 = new BeanWrapperImpl(a1);
BeanWrapper b2 = new BeanWrapperImpl(a2);
for (Sort.Order order : sort) {
Object val1 = b1.getPropertyValue(order.getProperty());
Object val2 = b2.getPropertyValue(order.getProperty());
int val = nullSafeComparableComparator.compare(val1, val2);
if (val != 0) return val;
}
return 0;
}
});
return Collections.unmodifiableList(accounts);
}
开发者ID:KRMAssociatesInc,项目名称:eHMP,代码行数:28,代码来源:JsonVistaAccountDao.java
示例5: doBindControl
import org.springframework.util.comparator.ComparableComparator; //导入依赖的package包/类
protected void doBindControl(ListModel bindingModel) {
setRenderer(new LabeledEnumListRenderer(getMessageSource()));
setEditor(new LabeledEnumComboBoxEditor(getMessageSource(), getEditor()));
CompoundComparator comparator = new CompoundComparator();
comparator.addComparator(LabeledEnum.LABEL_ORDER);
comparator.addComparator(new ComparableComparator());
setComparator(comparator);
super.doBindControl(bindingModel);
}
开发者ID:shevek,项目名称:spring-rich-client,代码行数:10,代码来源:LabeledEnumComboBoxBinding.java
示例6: configureForEnum
import org.springframework.util.comparator.ComparableComparator; //导入依赖的package包/类
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 + "]");
}
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()));
}
开发者ID:shevek,项目名称:spring-rich-client,代码行数:14,代码来源:DefaultComponentFactory.java
示例7: testComparator
import org.springframework.util.comparator.ComparableComparator; //导入依赖的package包/类
public void testComparator() {
ComboBoxBinder binder = new ComboBoxBinder();
binder.setSelectableItems(new Object[] { "2", "4", "1", "2", "3" });
binder.setComparator(new ComparableComparator());
ComboBoxBinding binding = (ComboBoxBinding) binder.bind(fm, "simpleProperty", Collections.EMPTY_MAP);
ListModel bindingModel = binding.getBindingModel();
assertEquals(5, bindingModel.getSize());
assertEquals("1", bindingModel.getElementAt(0));
assertEquals("2", bindingModel.getElementAt(1));
assertEquals("2", bindingModel.getElementAt(2));
assertEquals("3", bindingModel.getElementAt(3));
assertEquals("4", bindingModel.getElementAt(4));
}
开发者ID:shevek,项目名称:spring-rich-client,代码行数:14,代码来源:ComboBoxBindingTests.java
示例8: ConvertingComparator
import org.springframework.util.comparator.ComparableComparator; //导入依赖的package包/类
/**
* Create a new {@link ConvertingComparator} instance.
* @param converter the converter
*/
@SuppressWarnings("unchecked")
public ConvertingComparator(Converter<S, T> converter) {
this(ComparableComparator.INSTANCE, converter);
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:9,代码来源:ConvertingComparator.java
示例9: getMappingComparator
import org.springframework.util.comparator.ComparableComparator; //导入依赖的package包/类
@Override
protected Comparator<MappingInformation> getMappingComparator(Message<?> message) {
return new ComparableComparator<>();
}
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:5,代码来源:QueueMessageHandler.java
示例10: ConvertingComparator
import org.springframework.util.comparator.ComparableComparator; //导入依赖的package包/类
/**
* Create a new {@link ConvertingComparator} instance.
*
* @param converter the converter
*/
@SuppressWarnings("unchecked")
public ConvertingComparator(Converter<S, T> converter) {
this(ComparableComparator.INSTANCE, converter);
}
开发者ID:deathspeeder,项目名称:class-guard,代码行数:10,代码来源:ConvertingComparator.java
注:本文中的org.springframework.util.comparator.ComparableComparator类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论