当前位置: 首页>>代码示例>>Java>>正文


Java ComparatorUtils.chainedComparator方法代码示例

本文整理汇总了Java中org.apache.commons.collections.ComparatorUtils.chainedComparator方法的典型用法代码示例。如果您正苦于以下问题:Java ComparatorUtils.chainedComparator方法的具体用法?Java ComparatorUtils.chainedComparator怎么用?Java ComparatorUtils.chainedComparator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.collections.ComparatorUtils的用法示例。


在下文中一共展示了ComparatorUtils.chainedComparator方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: attachRoutesForClass

import org.apache.commons.collections.ComparatorUtils; //导入方法依赖的package包/类
private void attachRoutesForClass(Router router, Class<? extends ServerResource> clazz) {
  TreeSet<String> pathsOrderedByLength = new TreeSet<String>(ComparatorUtils.chainedComparator(new Comparator<String>() {
    private IntComparator _intComparator = IntComparators.NATURAL_COMPARATOR;
    @Override
    public int compare(String o1, String o2) {
      return _intComparator.compare(o1.length(), o2.length());
    }
  }, ComparatorUtils.NATURAL_COMPARATOR));

  for (Method method : clazz.getDeclaredMethods()) {
    Annotation annotationInstance = method.getAnnotation(Paths.class);
    if (annotationInstance != null) {
      pathsOrderedByLength.addAll(Arrays.asList(((Paths) annotationInstance).value()));
    }
  }

  for (String routePath : pathsOrderedByLength) {
    LOGGER.info("Attaching route {} -> {}", routePath, clazz.getSimpleName());
    router.attach(routePath, new AddHeaderFilter(getContext(), createFinder(clazz)));
  }
}
 
开发者ID:Hanmourang,项目名称:Pinot,代码行数:22,代码来源:ControllerRestApplication.java

示例2: getComparator

import org.apache.commons.collections.ComparatorUtils; //导入方法依赖的package包/类
@SuppressWarnings("unchecked") // unchecked cast
private Comparator<?> getComparator(ExtendedProperties properties, String keyPreffix) {
    String key = keyPreffix + ".comparator";
    String[] classNames = properties.getStringArray(key);
    List<Comparator<?>> comparators = new ArrayList<>();
    Comparator<?> c;
    for (String name : classNames) {
        c = getComparator(name);
        if (c != null) {
            comparators.add(c);
        }
    }
    return comparators.isEmpty() ? null : (Comparator<?>) ComparatorUtils.chainedComparator(comparators); // unchecked cast
}
 
开发者ID:proyecto-adalid,项目名称:adalid,代码行数:15,代码来源:Writer.java

示例3: sort

import org.apache.commons.collections.ComparatorUtils; //导入方法依赖的package包/类
@SuppressWarnings("unchecked") // unchecked cast
public static <T> Collection<T> sort(Collection<T> collection, Comparator<T>... comparators) {
    if (collection instanceof List && !collection.isEmpty() && comparators != null) {
        List<T> list = (List<T>) collection;
        Comparator<T> comparator = (Comparator<T>) ComparatorUtils.chainedComparator(comparators); // unchecked cast
        Collections.sort(list, comparator);
    }
    return collection;
}
 
开发者ID:proyecto-adalid,项目名称:adalid,代码行数:10,代码来源:ColUtils.java

示例4: testSortingByMultipleColumn

import org.apache.commons.collections.ComparatorUtils; //导入方法依赖的package包/类
@Test
public void testSortingByMultipleColumn() {
	Comparator<User> byAge = new ArgumentComparator<User, Integer>(on(User.class).getAge());
	Comparator<User> byRegistYmdt = new ArgumentComparator<User, Date>(on(User.class).getRegistYmdt());
	@SuppressWarnings("unchecked") Comparator<User> orderBy = ComparatorUtils.chainedComparator(byAge, byRegistYmdt);

	List<User> sortedList = sort(userList, on(User.class), orderBy);
	println("Test sorting:", sortedList);
}
 
开发者ID:iandmyhand,项目名称:java-library-tester,代码行数:10,代码来源:LambdajTest.java

示例5: compareTo

import org.apache.commons.collections.ComparatorUtils; //导入方法依赖的package包/类
/**
 * compare to ReleaseChannelMap
 * @param o the other object
 * @return the compare return
 */
public int compareTo(ReleaseChannelMap o) {
    List<Comparator> compar = new ArrayList<Comparator>();

    compar.add(new DynamicComparator("channel", true));
    compar.add(new DynamicComparator("channelArch", true));
    compar.add(new DynamicComparator("product", true));
    compar.add(new DynamicComparator("version", true));
    compar.add(new DynamicComparator("release", true));

    Comparator com = ComparatorUtils.chainedComparator(
                            (Comparator[]) compar.toArray());
    return com.compare(this, o);
}
 
开发者ID:spacewalkproject,项目名称:spacewalk,代码行数:19,代码来源:ReleaseChannelMap.java


注:本文中的org.apache.commons.collections.ComparatorUtils.chainedComparator方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。