Class InstanceComparator<T>
java.lang.Object
org.springframework.util.comparator.InstanceComparator<T>
- Type Parameters:
- T- the type of objects that may be compared by this comparator
- All Implemented Interfaces:
- Comparator<T>
Compares objects based on an arbitrary class order. Allows objects to be sorted based
 on the types of class that they inherit — for example, this comparator can be used
 to sort a list of 
Numbers such that Longs occur before Integers.
 Only the specified instanceOrder classes are considered during comparison.
 If two objects are both instances of the ordered type this comparator will return a
 value of 0. Consider combining with Comparator.thenComparing(Comparator)
 if additional sorting is required.
- Since:
- 3.2
- Author:
- Phillip Webb
- See Also:
- 
Constructor SummaryConstructorsConstructorDescriptionInstanceComparator(Class<?>... instanceOrder) Create a newInstanceComparatorinstance.
- 
Method SummaryMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Comparatorequals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
- 
Constructor Details- 
InstanceComparatorCreate a newInstanceComparatorinstance.- Parameters:
- instanceOrder- the ordered list of classes that should be used when comparing objects. Classes earlier in the list will be given a higher priority.
 
 
- 
- 
Method Details- 
compare- Specified by:
- comparein interface- Comparator<T>
 
 
-