Package org.springframework.core
Class ExceptionDepthComparator
java.lang.Object
org.springframework.core.ExceptionDepthComparator
- All Implemented Interfaces:
- Comparator<Class<? extends Throwable>>
public class ExceptionDepthComparator
extends Object
implements Comparator<Class<? extends Throwable>>
Comparator capable of sorting exceptions based on their depth from the thrown exception type.
- Since:
- 3.0.3
- Author:
- Juergen Hoeller, Arjen Poutsma
- 
Constructor SummaryConstructorsConstructorDescriptionExceptionDepthComparator(Class<? extends Throwable> exceptionType) Create a new ExceptionDepthComparator for the given exception type.ExceptionDepthComparator(Throwable exception) Create a new ExceptionDepthComparator for the given exception.
- 
Method SummaryModifier and TypeMethodDescriptionintfindClosestMatch(Collection<Class<? extends Throwable>> exceptionTypes, Throwable targetException) Obtain the closest match from the given exception types for the given target exception.Methods 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- 
ExceptionDepthComparatorCreate a new ExceptionDepthComparator for the given exception.- Parameters:
- exception- the target exception to compare to when sorting by depth
 
- 
ExceptionDepthComparatorCreate a new ExceptionDepthComparator for the given exception type.- Parameters:
- exceptionType- the target exception type to compare to when sorting by depth
 
 
- 
- 
Method Details- 
compare- Specified by:
- comparein interface- Comparator<Class<? extends Throwable>>
 
- 
findClosestMatchpublic static Class<? extends Throwable> findClosestMatch(Collection<Class<? extends Throwable>> exceptionTypes, Throwable targetException) Obtain the closest match from the given exception types for the given target exception.- Parameters:
- exceptionTypes- the collection of exception types
- targetException- the target exception to find a match for
- Returns:
- the closest matching exception type from the given collection
 
 
-