Java Code Examples for org.springframework.core.OrderComparator

Following code examples demonstrate how to use org.springframework.core.OrderComparatorfrom spring-framework. These examples are extracted from various highly rated open source projects. You can directly use these code snippets or view their entire linked source code. These snippets are extracted to provide contextual information about how to use this class in the real world. These samples also let you understand some good practices on how to use org.springframework.core.OrderComparatorand various code implementation of this class.

	public static void reorder(List<? extends Ordered> list) {
		Collections.sort(list, new OrderComparator());
		int i = 0;
		for (Ordered o: list) {
			o.setOrder(++i);
		}
	} 


	protected List sortAdvisors(List advisors) {
		Collections.sort(advisors, new OrderComparator());
		return advisors;
	} 

Advertisement
Javadoc
Comparator implementation for Ordered objects, sorting by order value ascending, respectively by pri

ority descending. Same Order Objects

Objects that have the same order value will be sorted with arbitrary ordering with respect to other objects with the same order value. Non-ordered Objects

Any object that does not provide its own order value is implicitly assigned a value of Ordered#LOWEST_PRECEDENCE, thus ending up at the end of a sorted collection in arbitrary order with respect to other objects with the same order value. @author Juergen Hoeller @author Sam Brannen @since 07.04.2003 @see Ordered @see org.springframework.core.annotation.AnnotationAwareOrderComparator @see java.util.List#sort(java.util.Comparator) @see java.util.Arrays#sort(Object[], java.util.Comparator)

Read More
Advertisement